LibreOffice Module sw (master)  1
txtfrm.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <hints.hxx>
22 #include <svl/ctloptions.hxx>
23 #include <editeng/lspcitem.hxx>
24 #include <editeng/lrspitem.hxx>
25 #include <editeng/brushitem.hxx>
26 #include <editeng/pgrditem.hxx>
27 #include <unotools/configmgr.hxx>
28 #include <swmodule.hxx>
29 #include <SwSmartTagMgr.hxx>
30 #include <doc.hxx>
34 #include <rootfrm.hxx>
35 #include <pagefrm.hxx>
36 #include <viewsh.hxx>
37 #include <pam.hxx>
38 #include <ndtxt.hxx>
39 #include <paratr.hxx>
40 #include <viewopt.hxx>
41 #include <flyfrm.hxx>
42 #include <tabfrm.hxx>
43 #include <frmatr.hxx>
44 #include <frmtool.hxx>
45 #include <tgrditem.hxx>
46 #include <dbg_lay.hxx>
47 #include <fmtfld.hxx>
48 #include <fmtftn.hxx>
49 #include <txtfld.hxx>
50 #include <txtftn.hxx>
51 #include <ftninfo.hxx>
52 #include <fmtline.hxx>
53 #include <txtfrm.hxx>
54 #include <notxtfrm.hxx>
55 #include <sectfrm.hxx>
56 #include "itrform2.hxx"
57 #include "widorp.hxx"
58 #include "txtcache.hxx"
59 #include <fntcache.hxx>
60 #include <SwGrammarMarkUp.hxx>
61 #include <lineinfo.hxx>
62 #include <SwPortionHandler.hxx>
63 #include <dcontact.hxx>
64 #include <sortedobjs.hxx>
65 #include <txtflcnt.hxx>
66 #include <fmtflcnt.hxx>
67 #include <fmtcntnt.hxx>
68 #include <numrule.hxx>
69 #include <IGrammarContact.hxx>
70 #include <calbck.hxx>
71 #include <ftnidx.hxx>
72 #include <ftnfrm.hxx>
73 
74 
75 namespace sw {
76 
78  : m_pMerged(rFrame.GetMergedPara())
79  , m_pNode(m_pMerged ? nullptr : rFrame.GetTextNodeFirst())
80  , m_CurrentExtent(0)
81  , m_CurrentHint(0)
82  {
83  }
84 
86  {
87  if (m_pMerged)
88  {
89  while (m_CurrentExtent < m_pMerged->extents.size())
90  {
91  sw::Extent const& rExtent(m_pMerged->extents[m_CurrentExtent]);
92  if (SwpHints const*const pHints = rExtent.pNode->GetpSwpHints())
93  {
94  while (m_CurrentHint < pHints->Count())
95  {
96  SwTextAttr *const pHint(pHints->Get(m_CurrentHint));
97  if (rExtent.nEnd < pHint->GetStart()
98  // <= if it has no end or isn't empty
99  || (rExtent.nEnd == pHint->GetStart()
100  && (!pHint->GetEnd()
101  || *pHint->GetEnd() != pHint->GetStart())))
102  {
103  break;
104  }
105  ++m_CurrentHint;
106  if (rExtent.nStart <= pHint->GetStart())
107  {
108  if (ppNode)
109  {
110  *ppNode = rExtent.pNode;
111  }
112  return pHint;
113  }
114  }
115  }
116  ++m_CurrentExtent;
117  if (m_CurrentExtent < m_pMerged->extents.size() &&
118  rExtent.pNode != m_pMerged->extents[m_CurrentExtent].pNode)
119  {
120  m_CurrentHint = 0; // reset
121  }
122  }
123  return nullptr;
124  }
125  else
126  {
127  SwpHints const*const pHints(m_pNode->GetpSwpHints());
128  if (pHints)
129  {
130  if (m_CurrentHint < pHints->Count())
131  {
132  SwTextAttr const*const pHint(pHints->Get(m_CurrentHint));
133  ++m_CurrentHint;
134  if (ppNode)
135  {
136  *ppNode = m_pNode;
137  }
138  return pHint;
139  }
140  }
141  return nullptr;
142  }
143  }
144 
146  : m_pNode(rFrame.GetMergedPara() ? nullptr : rFrame.GetTextNodeFirst())
147  , m_CurrentHint(0)
148  {
149  if (!m_pNode)
150  {
151  MergedAttrIterReverse iter(rFrame);
152  SwTextNode const* pNode(nullptr);
153  while (SwTextAttr const* pHint = iter.PrevAttr(&pNode))
154  {
155  m_Hints.emplace_back(pNode, pHint);
156  }
157  }
158  }
159 
161  {
162  if (m_pNode)
163  {
164  SwpHints const*const pHints(m_pNode->GetpSwpHints());
165  if (pHints)
166  {
167  if (m_CurrentHint < pHints->Count())
168  {
169  SwTextAttr const*const pHint(
170  pHints->GetSortedByEnd(m_CurrentHint));
171  ++m_CurrentHint;
172  rpNode = m_pNode;
173  return pHint;
174  }
175  }
176  return nullptr;
177  }
178  else
179  {
180  if (m_CurrentHint < m_Hints.size())
181  {
182  auto const ret = m_Hints[m_Hints.size() - m_CurrentHint - 1];
183  ++m_CurrentHint;
184  rpNode = ret.first;
185  return ret.second;
186  }
187  return nullptr;
188  }
189  }
190 
192  {
193  assert(0 < m_CurrentHint); // should only rewind as far as 0
194  --m_CurrentHint;
195  }
196 
198  : MergedAttrIterBase(rFrame)
199  {
200  if (m_pMerged)
201  {
203  SwpHints const*const pHints(0 < m_CurrentExtent
204  ? m_pMerged->extents[m_CurrentExtent-1].pNode->GetpSwpHints()
205  : nullptr);
206  if (pHints)
207  {
208  pHints->SortIfNeedBe();
209  m_CurrentHint = pHints->Count();
210  }
211  }
212  else
213  {
214  if (SwpHints const*const pHints = m_pNode->GetpSwpHints())
215  {
216  pHints->SortIfNeedBe();
217  m_CurrentHint = pHints->Count();
218  }
219  }
220  }
221 
223  {
224  if (m_pMerged)
225  {
226  while (0 < m_CurrentExtent)
227  {
228  sw::Extent const& rExtent(m_pMerged->extents[m_CurrentExtent-1]);
229  if (SwpHints const*const pHints = rExtent.pNode->GetpSwpHints())
230  {
231  while (0 < m_CurrentHint)
232  {
233  SwTextAttr *const pHint(
234  pHints->GetSortedByEnd(m_CurrentHint - 1));
235  if (pHint->GetAnyEnd() < rExtent.nStart
236  // <= if it has end and isn't empty
237  || (pHint->GetEnd()
238  && *pHint->GetEnd() != pHint->GetStart()
239  && *pHint->GetEnd() == rExtent.nStart))
240  {
241  break;
242  }
243  --m_CurrentHint;
244  if (pHint->GetAnyEnd() <= rExtent.nEnd)
245  {
246  if (ppNode)
247  {
248  *ppNode = rExtent.pNode;
249  }
250  return pHint;
251  }
252  }
253  }
254  --m_CurrentExtent;
255  if (0 < m_CurrentExtent &&
256  rExtent.pNode != m_pMerged->extents[m_CurrentExtent-1].pNode)
257  {
258  SwpHints const*const pHints(
259  m_pMerged->extents[m_CurrentExtent-1].pNode->GetpSwpHints());
260  m_CurrentHint = pHints ? pHints->Count() : 0; // reset
261  if (pHints)
262  pHints->SortIfNeedBe();
263  }
264  }
265  return nullptr;
266  }
267  else
268  {
269  SwpHints const*const pHints(m_pNode->GetpSwpHints());
270  if (pHints && 0 < m_CurrentHint)
271  {
272  SwTextAttr const*const pHint(pHints->GetSortedByEnd(m_CurrentHint - 1));
273  --m_CurrentHint;
274  if (ppNode)
275  {
276  *ppNode = m_pNode;
277  }
278  return pHint;
279  }
280  return nullptr;
281  }
282  }
283 
284  bool FrameContainsNode(SwContentFrame const& rFrame, sal_uLong const nNodeIndex)
285  {
286  if (rFrame.IsTextFrame())
287  {
288  SwTextFrame const& rTextFrame(static_cast<SwTextFrame const&>(rFrame));
289  if (sw::MergedPara const*const pMerged = rTextFrame.GetMergedPara())
290  {
291  sal_uLong const nFirst(pMerged->pFirstNode->GetIndex());
292  sal_uLong const nLast(pMerged->pLastNode->GetIndex());
293  return (nFirst <= nNodeIndex && nNodeIndex <= nLast);
294  }
295  else
296  {
297  return rTextFrame.GetTextNodeFirst()->GetIndex() == nNodeIndex;
298  }
299  }
300  else
301  {
302  assert(rFrame.IsNoTextFrame());
303  return static_cast<SwNoTextFrame const&>(rFrame).GetNode()->GetIndex() == nNodeIndex;
304  }
305  }
306 
307  bool IsParaPropsNode(SwRootFrame const& rLayout, SwTextNode const& rNode)
308  {
309  if (rLayout.HasMergedParas())
310  {
311  if (SwTextFrame const*const pFrame = static_cast<SwTextFrame*>(rNode.getLayoutFrame(&rLayout)))
312  {
313  sw::MergedPara const*const pMerged(pFrame->GetMergedPara());
314  if (pMerged && pMerged->pParaPropsNode != &rNode)
315  {
316  return false;
317  }
318  }
319  }
320  return true;
321  }
322 
323  SwTextNode *
324  GetParaPropsNode(SwRootFrame const& rLayout, SwNodeIndex const& rPos)
325  {
326  SwTextNode *const pTextNode(rPos.GetNode().GetTextNode());
327  if (pTextNode && !sw::IsParaPropsNode(rLayout, *pTextNode))
328  {
329  return static_cast<SwTextFrame*>(pTextNode->getLayoutFrame(&rLayout))->GetMergedPara()->pParaPropsNode;
330  }
331  else
332  {
333  return pTextNode;
334  }
335  }
336 
337  SwPosition
338  GetParaPropsPos(SwRootFrame const& rLayout, SwPosition const& rPos)
339  {
340  SwPosition pos(rPos);
341  SwTextNode const*const pNode(pos.nNode.GetNode().GetTextNode());
342  if (pNode)
343  {
344  pos.nNode = *sw::GetParaPropsNode(rLayout, *pNode);
345  pos.nContent.Assign(pos.nNode.GetNode().GetContentNode(), 0);
346  }
347  return pos;
348  }
349 
350  std::pair<SwTextNode *, SwTextNode *>
351  GetFirstAndLastNode(SwRootFrame const& rLayout, SwNodeIndex const& rPos)
352  {
353  SwTextNode *const pTextNode(rPos.GetNode().GetTextNode());
354  if (pTextNode && rLayout.HasMergedParas())
355  {
356  if (SwTextFrame const*const pFrame = static_cast<SwTextFrame*>(pTextNode->getLayoutFrame(&rLayout)))
357  {
358  if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
359  {
360  return std::make_pair(pMerged->pFirstNode, const_cast<SwTextNode*>(pMerged->pLastNode));
361  }
362  }
363  }
364  return std::make_pair(pTextNode, pTextNode);
365  }
366 
367  SwTextNode const& GetAttrMerged(SfxItemSet & rFormatSet,
368  SwTextNode const& rNode, SwRootFrame const*const pLayout)
369  {
370  rNode.SwContentNode::GetAttr(rFormatSet);
371  if (pLayout && pLayout->HasMergedParas())
372  {
373  auto pFrame = static_cast<SwTextFrame*>(rNode.getLayoutFrame(pLayout));
374  if (sw::MergedPara const*const pMerged = pFrame ? pFrame->GetMergedPara() : nullptr)
375  {
376  if (pMerged->pFirstNode != &rNode)
377  {
378  rFormatSet.ClearItem(RES_PAGEDESC);
379  rFormatSet.ClearItem(RES_BREAK);
380  static_assert(RES_PAGEDESC + 1 == sal_uInt16(RES_BREAK),
381  "first-node items must be adjacent");
382  SfxItemSet firstSet(*rFormatSet.GetPool(),
384  pMerged->pFirstNode->SwContentNode::GetAttr(firstSet);
385  rFormatSet.Put(firstSet);
386 
387  }
388  if (pMerged->pParaPropsNode != &rNode)
389  {
390  for (sal_uInt16 i = RES_PARATR_BEGIN; i != RES_FRMATR_END; ++i)
391  {
392  if (i != RES_PAGEDESC && i != RES_BREAK)
393  {
394  rFormatSet.ClearItem(i);
395  }
396  }
397  for (sal_uInt16 i = XATTR_FILL_FIRST; i <= XATTR_FILL_LAST; ++i)
398  {
399  rFormatSet.ClearItem(i);
400  }
401  SfxItemSet propsSet(*rFormatSet.GetPool(),
405  pMerged->pParaPropsNode->SwContentNode::GetAttr(propsSet);
406  rFormatSet.Put(propsSet);
407  return *pMerged->pParaPropsNode;
408  }
409  // keep all the CHRATR/UNKNOWNATR anyway...
410  }
411  }
412  return rNode;
413  }
414 
415 } // namespace sw
416 
419 {
420  {
422 
423  if ( ! mbIsSwapped )
424  {
425  const tools::Long nPrtOfstX = aPrt.Pos().X();
426  aPrt.Pos().setX( aPrt.Pos().Y() );
427 
428  if( IsVertLR() )
429  {
430  aPrt.Pos().setY( nPrtOfstX );
431  }
432  else
433  {
434  aPrt.Pos().setY( getFrameArea().Width() - ( nPrtOfstX + aPrt.Width() ) );
435  }
436  }
437  else
438  {
439  const tools::Long nPrtOfstY = aPrt.Pos().Y();
440  aPrt.Pos().setY( aPrt.Pos().X() );
441 
442  if( IsVertLR() )
443  {
444  aPrt.Pos().setX( nPrtOfstY );
445  }
446  else
447  {
448  aPrt.Pos().setX( getFrameArea().Height() - ( nPrtOfstY + aPrt.Height() ) );
449  }
450  }
451 
452  const tools::Long nPrtWidth = aPrt.Width();
453  aPrt.Width( aPrt.Height() );
454  aPrt.Height( nPrtWidth );
455  }
456 
457  {
458  const tools::Long nFrameWidth = getFrameArea().Width();
460  aFrm.Width( aFrm.Height() );
461  aFrm.Height( nFrameWidth );
462  }
463 
465 }
466 
472 {
473  // calc offset inside frame
474  tools::Long nOfstX, nOfstY;
475  if ( IsVertLR() )
476  {
477  if (IsVertLRBT())
478  {
479  // X and Y offsets here mean the position of the point that will be the top left corner
480  // after the switch.
481  nOfstX = rRect.Left() + rRect.Width() - getFrameArea().Left();
482  nOfstY = rRect.Top() - getFrameArea().Top();
483  }
484  else
485  {
486  nOfstX = rRect.Left() - getFrameArea().Left();
487  nOfstY = rRect.Top() - getFrameArea().Top();
488  }
489  }
490  else
491  {
492  nOfstX = rRect.Left() - getFrameArea().Left();
493  nOfstY = rRect.Top() + rRect.Height() - getFrameArea().Top();
494  }
495 
496  const tools::Long nWidth = rRect.Width();
497  const tools::Long nHeight = rRect.Height();
498 
499  if ( IsVertLR() )
500  {
501  rRect.Left(getFrameArea().Left() + nOfstY);
502  }
503  else
504  {
505  if ( mbIsSwapped )
506  rRect.Left( getFrameArea().Left() + getFrameArea().Height() - nOfstY );
507  else
508  // frame is rotated
509  rRect.Left( getFrameArea().Left() + getFrameArea().Width() - nOfstY );
510  }
511 
512  if (IsVertLRBT())
513  {
514  if (mbIsSwapped)
515  rRect.Top(getFrameArea().Top() + getFrameArea().Width() - nOfstX);
516  else
517  rRect.Top(getFrameArea().Top() + getFrameArea().Height() - nOfstX);
518  }
519  else
520  rRect.Top(getFrameArea().Top() + nOfstX);
521  rRect.Width( nHeight );
522  rRect.Height( nWidth );
523 }
524 
529 void SwTextFrame::SwitchHorizontalToVertical( Point& rPoint ) const
530 {
531  if (IsVertLRBT())
532  {
533  // The horizontal origo is the top left corner, the LRBT origo is the
534  // bottom left corner. Finally x and y has to be swapped.
535  SAL_WARN_IF(!mbIsSwapped, "sw.core",
536  "SwTextFrame::SwitchHorizontalToVertical, IsVertLRBT, not swapped");
537  Point aPoint(rPoint);
538  rPoint.setX(getFrameArea().Left() + (aPoint.Y() - getFrameArea().Top()));
539  // This would be bottom - x delta, but bottom is top + height, finally
540  // width (and not height), as it's swapped.
541  rPoint.setY(getFrameArea().Top() + getFrameArea().Width()
542  - (aPoint.X() - getFrameArea().Left()));
543  return;
544  }
545 
546  // calc offset inside frame
547  const tools::Long nOfstX = rPoint.X() - getFrameArea().Left();
548  const tools::Long nOfstY = rPoint.Y() - getFrameArea().Top();
549  if ( IsVertLR() )
550  rPoint.setX( getFrameArea().Left() + nOfstY );
551  else
552  {
553  if ( mbIsSwapped )
554  rPoint.setX( getFrameArea().Left() + getFrameArea().Height() - nOfstY );
555  else
556  // calc rotated coords
557  rPoint.setX( getFrameArea().Left() + getFrameArea().Width() - nOfstY );
558  }
559 
560  rPoint.setY( getFrameArea().Top() + nOfstX );
561 }
562 
568 {
569  Point aTmp( 0, nLimit );
571  return aTmp.X();
572 }
573 
579 {
580  tools::Long nOfstX;
581 
582  // calc offset inside frame
583  if ( IsVertLR() )
584  nOfstX = rRect.Left() - getFrameArea().Left();
585  else
586  {
587  if ( mbIsSwapped )
588  nOfstX = getFrameArea().Left() + getFrameArea().Height() - ( rRect.Left() + rRect.Width() );
589  else
590  nOfstX = getFrameArea().Left() + getFrameArea().Width() - ( rRect.Left() + rRect.Width() );
591  }
592 
593  tools::Long nOfstY;
594  if (IsVertLRBT())
595  {
596  // Note that mbIsSwapped only affects the frame area, not rRect, so rRect.Height() is used
597  // here unconditionally.
598  if (mbIsSwapped)
599  nOfstY = getFrameArea().Top() + getFrameArea().Width() - (rRect.Top() + rRect.Height());
600  else
601  nOfstY = getFrameArea().Top() + getFrameArea().Height() - (rRect.Top() + rRect.Height());
602  }
603  else
604  nOfstY = rRect.Top() - getFrameArea().Top();
605  const tools::Long nWidth = rRect.Height();
606  const tools::Long nHeight = rRect.Width();
607 
608  // calc rotated coords
609  rRect.Left( getFrameArea().Left() + nOfstY );
610  rRect.Top( getFrameArea().Top() + nOfstX );
611  rRect.Width( nWidth );
612  rRect.Height( nHeight );
613 }
614 
619 void SwTextFrame::SwitchVerticalToHorizontal( Point& rPoint ) const
620 {
621  tools::Long nOfstX;
622 
623  // calc offset inside frame
624  if ( IsVertLR() )
625  // X offset is Y - left.
626  nOfstX = rPoint.X() - getFrameArea().Left();
627  else
628  {
629  // X offset is right - X.
630  if ( mbIsSwapped )
631  nOfstX = getFrameArea().Left() + getFrameArea().Height() - rPoint.X();
632  else
633  nOfstX = getFrameArea().Left() + getFrameArea().Width() - rPoint.X();
634  }
635 
636  tools::Long nOfstY;
637  if (IsVertLRBT())
638  {
639  // Y offset is bottom - Y.
640  if (mbIsSwapped)
641  nOfstY = getFrameArea().Top() + getFrameArea().Width() - rPoint.Y();
642  else
643  nOfstY = getFrameArea().Top() + getFrameArea().Height() - rPoint.Y();
644  }
645  else
646  // Y offset is Y - top.
647  nOfstY = rPoint.Y() - getFrameArea().Top();
648 
649  // calc rotated coords
650  rPoint.setX( getFrameArea().Left() + nOfstY );
651  rPoint.setY( getFrameArea().Top() + nOfstX );
652 }
653 
659 {
660  Point aTmp( nLimit, 0 );
662  return aTmp.Y();
663 }
664 
665 SwFrameSwapper::SwFrameSwapper( const SwTextFrame* pTextFrame, bool bSwapIfNotSwapped )
666  : pFrame( pTextFrame ), bUndo( false )
667 {
668  if (pFrame->IsVertical() && bSwapIfNotSwapped != pFrame->IsSwapped())
669  {
670  bUndo = true;
671  const_cast<SwTextFrame*>(pFrame)->SwapWidthAndHeight();
672  }
673 }
674 
676 {
677  if ( bUndo )
678  const_cast<SwTextFrame*>(pFrame)->SwapWidthAndHeight();
679 }
680 
682 {
683  SwSwapIfNotSwapped swap(const_cast<SwTextFrame *>(this));
684 
685  tools::Long nWidth = rRect.Width();
686  rRect.Left( 2 * ( getFrameArea().Left() + getFramePrintArea().Left() ) +
687  getFramePrintArea().Width() - rRect.Right() - 1 );
688 
689  rRect.Width( nWidth );
690 }
691 
692 void SwTextFrame::SwitchLTRtoRTL( Point& rPoint ) const
693 {
694  SwSwapIfNotSwapped swap(const_cast<SwTextFrame *>(this));
695 
696  rPoint.setX( 2 * ( getFrameArea().Left() + getFramePrintArea().Left() ) + getFramePrintArea().Width() - rPoint.X() - 1 );
697 }
698 
700  m_rOut( rOutp ), m_nOldLayoutMode( rOutp.GetLayoutMode() )
701 {
702 }
703 
705 {
706  const_cast<OutputDevice&>(m_rOut).SetLayoutMode( m_nOldLayoutMode );
707 }
708 
709 void SwLayoutModeModifier::Modify( bool bChgToRTL )
710 {
711  const_cast<OutputDevice&>(m_rOut).SetLayoutMode( bChgToRTL ?
712  ComplexTextLayoutFlags::BiDiStrong | ComplexTextLayoutFlags::BiDiRtl :
713  ComplexTextLayoutFlags::BiDiStrong );
714 }
715 
717 {
718  const ComplexTextLayoutFlags nNewLayoutMode = m_nOldLayoutMode & ~ComplexTextLayoutFlags::BiDiStrong;
719  const_cast<OutputDevice&>(m_rOut).SetLayoutMode( nNewLayoutMode );
720 }
721 
723  rOut( rOutp ), nOldLanguageType( rOutp.GetDigitLanguage() )
724 {
725  LanguageType eLang = eCurLang;
727  eLang = LANGUAGE_ENGLISH_US;
728  else
729  {
730  const SvtCTLOptions::TextNumerals nTextNumerals = SW_MOD()->GetCTLOptions().GetCTLTextNumerals();
731 
732  if ( SvtCTLOptions::NUMERALS_HINDI == nTextNumerals )
734  else if ( SvtCTLOptions::NUMERALS_ARABIC == nTextNumerals )
735  eLang = LANGUAGE_ENGLISH;
736  else if ( SvtCTLOptions::NUMERALS_SYSTEM == nTextNumerals )
737  eLang = ::GetAppLanguage();
738  }
739 
740  const_cast<OutputDevice&>(rOut).SetDigitLanguage( eLang );
741 }
742 
744 {
745  const_cast<OutputDevice&>(rOut).SetDigitLanguage( nOldLanguageType );
746 }
747 
749 {
750  OSL_ENSURE( !IsLocked(), "+SwTextFrame::Init: this is locked." );
751  if( !IsLocked() )
752  {
753  ClearPara();
754  SetHasRotatedPortions(false);
755  // set flags directly to save a ResetPreps call,
756  // and thereby an unnecessary GetPara call
757  // don't set bOrphan, bLocked or bWait to false!
758  // bOrphan = bFlag7 = bFlag8 = false;
759  }
760 }
761 
763  sw::FrameMode const eMode)
764  : SwContentFrame( pNode, pSib )
765  , mnAllLines( 0 )
766  , mnThisLines( 0 )
767  , mnFlyAnchorOfst( 0 )
768  , mnFlyAnchorOfstNoWrap( 0 )
769  , mnFlyAnchorVertOfstNoWrap( 0 )
770  , mnFootnoteLine( 0 )
771  , mnHeightOfLastLine( 0 )
772  , mnAdditionalFirstLineOffset( 0 )
773  , mnOffset( 0 )
774  , mnCacheIndex( USHRT_MAX )
775  , mbLocked( false )
776  , mbWidow( false )
777  , mbJustWidow( false )
778  , mbEmpty( false )
779  , mbInFootnoteConnect( false )
780  , mbFootnote( false )
781  , mbRepaint( false )
782  , mbHasRotatedPortions( false )
783  , mbFieldFollow( false )
784  , mbHasAnimation( false )
785  , mbIsSwapped( false )
786  , mbFollowFormatAllowed( true )
787 {
789  // note: this may call SwClientNotify if it's in a list so do it last
790  // note: this may change this->pRegisteredIn to m_pMergedPara->listeners
791  m_pMergedPara = CheckParaRedlineMerge(*this, *pNode, eMode);
792 }
793 
794 namespace sw {
795 
796 SwTextFrame * MakeTextFrame(SwTextNode & rNode, SwFrame *const pSibling,
797  sw::FrameMode const eMode)
798 {
799  return new SwTextFrame(&rNode, pSibling, eMode);
800 }
801 
803  SwRootFrame const& rLayout, SwTextNode const& rTextNode,
804  std::vector<std::pair<sal_Int32, sal_Int32>> const*const pExtents)
805 {
806  if (pExtents && pExtents->empty())
807  {
808  return; // nothing to do
809  }
810  const SwFootnoteIdxs &rFootnoteIdxs = rTextNode.GetDoc().GetFootnoteIdxs();
811  size_t nPos = 0;
812  sal_uLong const nIndex = rTextNode.GetIndex();
813  rFootnoteIdxs.SeekEntry( rTextNode, &nPos );
814  if (nPos < rFootnoteIdxs.size())
815  {
816  while (nPos && &rTextNode == &(rFootnoteIdxs[ nPos ]->GetTextNode()))
817  --nPos;
818  if (nPos || &rTextNode != &(rFootnoteIdxs[ nPos ]->GetTextNode()))
819  ++nPos;
820  }
821  size_t iter(0);
822  for ( ; nPos < rFootnoteIdxs.size(); ++nPos)
823  {
824  SwTextFootnote* pTextFootnote = rFootnoteIdxs[ nPos ];
825  if (pTextFootnote->GetTextNode().GetIndex() > nIndex)
826  break;
827  if (pExtents)
828  {
829  while ((*pExtents)[iter].second <= pTextFootnote->GetStart())
830  {
831  ++iter;
832  if (iter == pExtents->size())
833  {
834  return;
835  }
836  }
837  if (pTextFootnote->GetStart() < (*pExtents)[iter].first)
838  {
839  continue;
840  }
841  }
842  pTextFootnote->DelFrames(&rLayout);
843  }
844 }
845 
846 } // namespace sw
847 
849 {
850  // Remove associated SwParaPortion from s_pTextCache
851  ClearPara();
852 
853  assert(!GetDoc().IsInDtor()); // this shouldn't be happening with ViewShell owning layout
854  if (!GetDoc().IsInDtor() && HasFootnote())
855  {
856  if (m_pMergedPara)
857  {
858  SwTextNode const* pNode(nullptr);
859  for (auto const& e : m_pMergedPara->extents)
860  {
861  if (e.pNode != pNode)
862  {
863  pNode = e.pNode;
864  // sw_redlinehide: not sure if it's necessary to check
865  // if the nodes are still alive here, which would require
866  // accessing WriterMultiListener::m_vDepends
867  sw::RemoveFootnotesForNode(*getRootFrame(), *pNode, nullptr);
868  }
869  }
870  }
871  else
872  {
873  SwTextNode *const pNode(static_cast<SwTextNode*>(GetDep()));
874  if (pNode)
875  {
876  sw::RemoveFootnotesForNode(*getRootFrame(), *pNode, nullptr);
877  }
878  }
879  }
880 
882 }
883 
885 {
886  RemoveFromCache();
887 }
888 
889 namespace sw {
890 
891 // 1. if real insert => correct nStart/nEnd for full nLen
892 // 2. if rl un-delete => do not correct nStart/nEnd but just include un-deleted
894  bool const isRealInsert,
895  SwTextNode const& rNode, sal_Int32 const nIndex, sal_Int32 const nLen)
896 {
897  assert(!isRealInsert || nLen); // can 0 happen? yes, for redline in empty node
898  assert(nIndex <= rNode.Len());
899  assert(nIndex + nLen <= rNode.Len());
900  assert(rMerged.pFirstNode->GetIndex() <= rNode.GetIndex() && rNode.GetIndex() <= rMerged.pLastNode->GetIndex());
901  if (!nLen)
902  {
903  return TextFrameIndex(0);
904  }
905  OUStringBuffer text(rMerged.mergedText);
906  sal_Int32 nTFIndex(0); // index used for insertion at the end
907  sal_Int32 nInserted(0);
908  bool bInserted(false);
909  bool bFoundNode(false);
910  auto itInsert(rMerged.extents.end());
911  for (auto it = rMerged.extents.begin(); it != rMerged.extents.end(); ++it)
912  {
913  if (it->pNode == &rNode)
914  {
915  if (isRealInsert)
916  {
917  bFoundNode = true;
918  if (it->nStart <= nIndex && nIndex <= it->nEnd)
919  { // note: this can happen only once
920  text.insert(nTFIndex + (nIndex - it->nStart),
921  rNode.GetText().subView(nIndex, nLen));
922  it->nEnd += nLen;
923  nInserted = nLen;
924  assert(!bInserted);
925  bInserted = true;
926  }
927  else if (nIndex < it->nStart)
928  {
929  if (itInsert == rMerged.extents.end())
930  {
931  itInsert = it;
932  }
933  it->nStart += nLen;
934  it->nEnd += nLen;
935  }
936  }
937  else
938  {
939  assert(it == rMerged.extents.begin() || (it-1)->pNode != &rNode || (it-1)->nEnd < nIndex);
940  if (nIndex + nLen < it->nStart)
941  {
942  itInsert = it;
943  break;
944  }
945  if (nIndex < it->nStart)
946  {
947  text.insert(nTFIndex,
948  rNode.GetText().subView(nIndex, it->nStart - nIndex));
949  nInserted += it->nStart - nIndex;
950  it->nStart = nIndex;
951  bInserted = true;
952  }
953  assert(it->nStart <= nIndex);
954  if (nIndex <= it->nEnd)
955  {
956  nTFIndex += it->nEnd - it->nStart;
957  while (it->nEnd < nIndex + nLen)
958  {
959  auto *const pNext(
960  (it+1) != rMerged.extents.end() && (it+1)->pNode == it->pNode
961  ? &*(it+1)
962  : nullptr);
963  if (pNext && pNext->nStart <= nIndex + nLen)
964  {
965  text.insert(nTFIndex,
966  rNode.GetText().subView(it->nEnd, pNext->nStart - it->nEnd));
967  nTFIndex += pNext->nStart - it->nEnd;
968  nInserted += pNext->nStart - it->nEnd;
969  pNext->nStart = it->nStart;
970  it = rMerged.extents.erase(it);
971  }
972  else
973  {
974  text.insert(nTFIndex,
975  rNode.GetText().subView(it->nEnd, nIndex + nLen - it->nEnd));
976  nTFIndex += nIndex + nLen - it->nEnd;
977  nInserted += nIndex + nLen - it->nEnd;
978  it->nEnd = nIndex + nLen;
979  }
980  }
981  bInserted = true;
982  break;
983  }
984  }
985  }
986  else if (rNode.GetIndex() < it->pNode->GetIndex() || bFoundNode)
987  {
988  if (itInsert == rMerged.extents.end())
989  {
990  itInsert = it;
991  }
992  break;
993  }
994  if (itInsert == rMerged.extents.end())
995  {
996  nTFIndex += it->nEnd - it->nStart;
997  }
998  }
999 // assert((bFoundNode || rMerged.extents.empty()) && "text node not found - why is it sending hints to us");
1000  if (!bInserted)
1001  { // must be in a gap
1002  rMerged.extents.emplace(itInsert, const_cast<SwTextNode*>(&rNode), nIndex, nIndex + nLen);
1003  text.insert(nTFIndex, rNode.GetText().subView(nIndex, nLen));
1004  nInserted = nLen;
1005  if (rMerged.extents.size() == 1 // also if it was empty!
1006  || rMerged.pParaPropsNode->GetIndex() < rNode.GetIndex())
1007  { // text inserted after current para-props node
1009  rMerged.pParaPropsNode = &const_cast<SwTextNode&>(rNode);
1010  rMerged.pParaPropsNode->AddToListRLHidden();
1011  }
1012  // called from SwRangeRedline::InvalidateRange()
1014  {
1015  const_cast<SwTextNode&>(rNode).SetRedlineMergeFlag(SwNode::Merge::NonFirst);
1016  }
1017  }
1018  rMerged.mergedText = text.makeStringAndClear();
1019  return TextFrameIndex(nInserted);
1020 }
1021 
1022 // 1. if real delete => correct nStart/nEnd for full nLen
1023 // 2. if rl delete => do not correct nStart/nEnd but just exclude deleted
1025  bool const isRealDelete,
1026  SwTextNode const& rNode, sal_Int32 nIndex, sal_Int32 const nLen)
1027 {
1028  assert(nIndex <= rNode.Len());
1029  assert(rMerged.pFirstNode->GetIndex() <= rNode.GetIndex() && rNode.GetIndex() <= rMerged.pLastNode->GetIndex());
1030  OUStringBuffer text(rMerged.mergedText);
1031  sal_Int32 nTFIndex(0);
1032  sal_Int32 nToDelete(nLen);
1033  sal_Int32 nDeleted(0);
1034  size_t nFoundNode(0);
1035  size_t nErased(0);
1036  auto it = rMerged.extents.begin();
1037  for (; it != rMerged.extents.end(); )
1038  {
1039  bool bErase(false);
1040  if (it->pNode == &rNode)
1041  {
1042  ++nFoundNode;
1043  if (nIndex + nToDelete < it->nStart)
1044  {
1045  nToDelete = 0;
1046  if (!isRealDelete)
1047  {
1048  break;
1049  }
1050  it->nStart -= nLen;
1051  it->nEnd -= nLen;
1052  }
1053  else
1054  {
1055  if (nIndex < it->nStart)
1056  {
1057  // do not adjust nIndex into the text frame index space!
1058  nToDelete -= it->nStart - nIndex;
1059  nIndex = it->nStart;
1060  // note: continue with the if check below, no else!
1061  }
1062  if (it->nStart <= nIndex && nIndex < it->nEnd)
1063  {
1064  sal_Int32 const nDeleteHere(nIndex + nToDelete <= it->nEnd
1065  ? nToDelete
1066  : it->nEnd - nIndex);
1067  text.remove(nTFIndex + (nIndex - it->nStart), nDeleteHere);
1068  bErase = nDeleteHere == it->nEnd - it->nStart;
1069  if (bErase)
1070  {
1071  ++nErased;
1072  assert(it->nStart == nIndex);
1073  it = rMerged.extents.erase(it);
1074  }
1075  else if (isRealDelete)
1076  { // adjust for deleted text
1077  it->nStart -= (nLen - nToDelete);
1078  it->nEnd -= (nLen - nToDelete + nDeleteHere);
1079  if (it != rMerged.extents.begin()
1080  && (it-1)->pNode == &rNode
1081  && (it-1)->nEnd == it->nStart)
1082  { // merge adjacent extents
1083  nTFIndex += it->nEnd - it->nStart;
1084  (it-1)->nEnd = it->nEnd;
1085  it = rMerged.extents.erase(it);
1086  bErase = true; // skip increment
1087  }
1088  }
1089  else
1090  { // exclude text marked as deleted
1091  if (nIndex + nDeleteHere == it->nEnd)
1092  {
1093  it->nEnd -= nDeleteHere;
1094  }
1095  else
1096  {
1097  if (nIndex == it->nStart)
1098  {
1099  it->nStart += nDeleteHere;
1100  }
1101  else
1102  {
1103  sal_Int32 const nOldEnd(it->nEnd);
1104  it->nEnd = nIndex;
1105  it = rMerged.extents.emplace(it+1,
1106  it->pNode, nIndex + nDeleteHere, nOldEnd);
1107  }
1108  assert(nDeleteHere == nToDelete);
1109  }
1110  }
1111  nDeleted += nDeleteHere;
1112  nToDelete -= nDeleteHere;
1113  nIndex += nDeleteHere;
1114  if (!isRealDelete && nToDelete == 0)
1115  {
1116  break;
1117  }
1118  }
1119  }
1120  }
1121  else if (nFoundNode != 0)
1122  {
1123  break;
1124  }
1125  if (!bErase)
1126  {
1127  nTFIndex += it->nEnd - it->nStart;
1128  ++it;
1129  }
1130  }
1131 // assert(nFoundNode != 0 && "text node not found - why is it sending hints to us");
1132  assert(nIndex <= rNode.Len() + nLen);
1133  // if there's a remaining deletion, it must be in gap at the end of the node
1134 // can't do: might be last one in node was erased assert(nLen == 0 || rMerged.empty() || (it-1)->nEnd <= nIndex);
1135  // note: if first node gets deleted then that must call DelFrames as
1136  // pFirstNode is never updated
1137  if (nErased && nErased == nFoundNode)
1138  { // all visible text from node was erased
1139 #if 1
1140  if (rMerged.pParaPropsNode == &rNode)
1141  {
1143  rMerged.pParaPropsNode = rMerged.extents.empty()
1144  ? const_cast<SwTextNode*>(rMerged.pLastNode)
1145  : rMerged.extents.front().pNode;
1146  rMerged.pParaPropsNode->AddToListRLHidden();
1147  }
1148 #endif
1149 // NOPE must listen on all non-hidden nodes; particularly on pLastNode rMerged.listener.EndListening(&const_cast<SwTextNode&>(rNode));
1150  }
1151  rMerged.mergedText = text.makeStringAndClear();
1152  return TextFrameIndex(nDeleted);
1153 }
1154 
1155 std::pair<SwTextNode*, sal_Int32>
1156 MapViewToModel(MergedPara const& rMerged, TextFrameIndex const i_nIndex)
1157 {
1158  sal_Int32 nIndex(i_nIndex);
1159  sw::Extent const* pExtent(nullptr);
1160  for (const auto& rExt : rMerged.extents)
1161  {
1162  pExtent = &rExt;
1163  if (nIndex < (pExtent->nEnd - pExtent->nStart))
1164  {
1165  return std::make_pair(pExtent->pNode, pExtent->nStart + nIndex);
1166  }
1167  nIndex = nIndex - (pExtent->nEnd - pExtent->nStart);
1168  }
1169  assert(nIndex == 0 && "view index out of bounds");
1170  return pExtent
1171  ? std::make_pair(pExtent->pNode, pExtent->nEnd) //1-past-the-end index
1172  : std::make_pair(const_cast<SwTextNode*>(rMerged.pLastNode), rMerged.pLastNode->Len());
1173 }
1174 
1175 TextFrameIndex MapModelToView(MergedPara const& rMerged, SwTextNode const*const pNode, sal_Int32 const nIndex)
1176 {
1177  assert(rMerged.pFirstNode->GetIndex() <= pNode->GetIndex()
1178  && pNode->GetIndex() <= rMerged.pLastNode->GetIndex());
1179  sal_Int32 nRet(0);
1180  bool bFoundNode(false);
1181  for (auto const& e : rMerged.extents)
1182  {
1183  if (pNode->GetIndex() < e.pNode->GetIndex())
1184  {
1185  return TextFrameIndex(nRet);
1186  }
1187  if (e.pNode == pNode)
1188  {
1189  if (e.nStart <= nIndex && nIndex <= e.nEnd)
1190  {
1191  return TextFrameIndex(nRet + (nIndex - e.nStart));
1192  }
1193  else if (nIndex < e.nStart)
1194  {
1195  // in gap before this extent => map to 0 here TODO???
1196  return TextFrameIndex(nRet);
1197  }
1198  bFoundNode = true;
1199  }
1200  else if (bFoundNode)
1201  {
1202  break;
1203  }
1204  nRet += e.nEnd - e.nStart;
1205  }
1206  if (bFoundNode)
1207  {
1208  // must be in a gap at the end of the node
1209  assert(nIndex <= pNode->Len());
1210  return TextFrameIndex(nRet);
1211  }
1212  else if (rMerged.extents.empty())
1213  {
1214  assert(nIndex <= pNode->Len());
1215  return TextFrameIndex(0);
1216  }
1217  return TextFrameIndex(rMerged.mergedText.getLength());
1218 }
1219 
1220 } // namespace sw
1221 
1222 std::pair<SwTextNode*, sal_Int32>
1224 {
1225 //nope assert(GetPara());
1226  sw::MergedPara const*const pMerged(GetMergedPara());
1227  if (pMerged)
1228  {
1229  return sw::MapViewToModel(*pMerged, nIndex);
1230  }
1231  else
1232  {
1233  return std::make_pair(static_cast<SwTextNode*>(const_cast<sw::BroadcastingModify*>(
1234  SwFrame::GetDep())), sal_Int32(nIndex));
1235  }
1236 }
1237 
1239 {
1240  std::pair<SwTextNode*, sal_Int32> const ret(MapViewToModel(nIndex));
1241  return SwPosition(*ret.first, ret.second);
1242 }
1243 
1244 TextFrameIndex SwTextFrame::MapModelToView(SwTextNode const*const pNode, sal_Int32 const nIndex) const
1245 {
1246 //nope assert(GetPara());
1247  sw::MergedPara const*const pMerged(GetMergedPara());
1248  if (pMerged)
1249  {
1250  return sw::MapModelToView(*pMerged, pNode, nIndex);
1251  }
1252  else
1253  {
1254  assert(static_cast<SwTextNode*>(const_cast<sw::BroadcastingModify*>(SwFrame::GetDep())) == pNode);
1255  return TextFrameIndex(nIndex);
1256  }
1257 }
1258 
1260 {
1261  SwTextNode const*const pNode(rPos.nNode.GetNode().GetTextNode());
1262  sal_Int32 const nIndex(rPos.nContent.GetIndex());
1263  return MapModelToView(pNode, nIndex);
1264 }
1265 
1266 void SwTextFrame::SetMergedPara(std::unique_ptr<sw::MergedPara> p)
1267 {
1268  SwTextNode *const pFirst(m_pMergedPara ? m_pMergedPara->pFirstNode : nullptr);
1269  m_pMergedPara = std::move(p);
1270  if (pFirst)
1271  {
1272  if (m_pMergedPara)
1273  {
1274  assert(pFirst == m_pMergedPara->pFirstNode);
1275  }
1276  else
1277  {
1278  pFirst->Add(this); // must register at node again
1279  }
1280  }
1281  // postcondition: frame must be listening somewhere
1282  assert(m_pMergedPara || GetDep());
1283 }
1284 
1285 const OUString& SwTextFrame::GetText() const
1286 {
1287 //nope assert(GetPara());
1288  sw::MergedPara const*const pMerged(GetMergedPara());
1289  if (pMerged)
1290  return pMerged->mergedText;
1291  else
1292  return static_cast<SwTextNode const*>(SwFrame::GetDep())->GetText();
1293 }
1294 
1296 {
1297  // FIXME can GetPara be 0 ? yes... this is needed in SwContentNotify::SwContentNotify() which is called before any formatting is started
1298 //nope assert(GetPara());
1299  sw::MergedPara const*const pMerged(GetMergedPara());
1300  if (pMerged)
1301  {
1302 // assert(pMerged->pFirstNode == pMerged->pParaPropsNode); // surprising news!
1303  return pMerged->pParaPropsNode;
1304  }
1305  else
1306  return static_cast<SwTextNode const*>(SwFrame::GetDep());
1307 }
1308 
1310 {
1311  sw::MergedPara const*const pMerged(GetMergedPara());
1312  if (pMerged)
1313  return pMerged->extents.empty()
1314  ? pMerged->pFirstNode
1315  : pMerged->extents.front().pNode;
1316  else
1317  return static_cast<SwTextNode const*>(SwFrame::GetDep());
1318 }
1319 
1321 {
1322 //nope assert(GetPara());
1323  sw::MergedPara const*const pMerged(GetMergedPara());
1324  if (pMerged)
1325  return pMerged->pFirstNode;
1326  else
1327  return static_cast<SwTextNode const*>(SwFrame::GetDep());
1328 }
1329 
1331 {
1332  return GetTextNodeFirst()->GetDoc();
1333 }
1334 
1336  sal_uInt16 const nScript, bool const bNoChar) const
1337 {
1338  // a single character can be mapped uniquely!
1339  std::pair<SwTextNode const*, sal_Int32> const pos(MapViewToModel(nIndex));
1340  return pos.first->GetLang(pos.second, bNoChar ? 0 : 1, nScript);
1341 }
1342 
1344 {
1345  if ( GetCacheIdx() != USHRT_MAX )
1346  {
1347  if (SwParaPortion *pPara = GetPara())
1348  pPara->ResetPreps();
1349  }
1350 }
1351 
1353 {
1354  SwFrameSwapper aSwapper( this, true );
1355 
1356  if( !getFrameArea().Width() && isFrameAreaDefinitionValid() && GetUpper()->isFrameAreaDefinitionValid() ) // invalid when stack overflows (StackHack)!
1357  {
1358 // OSL_FAIL( "SwTextFrame::IsHiddenNow: thin frame" );
1359  return true;
1360  }
1361 
1362  bool bHiddenCharsHidePara(false);
1363  bool bHiddenParaField(false);
1364  if (m_pMergedPara)
1365  {
1366  TextFrameIndex nHiddenStart(COMPLETE_STRING);
1367  TextFrameIndex nHiddenEnd(0);
1368  if (auto const pScriptInfo = GetScriptInfo())
1369  {
1370  pScriptInfo->GetBoundsOfHiddenRange(TextFrameIndex(0),
1371  nHiddenStart, nHiddenEnd);
1372  }
1373  else // ParaPortion is created in Format, but this is called earlier
1374  {
1375  SwScriptInfo aInfo;
1376  aInfo.InitScriptInfo(*m_pMergedPara->pFirstNode, m_pMergedPara.get(), IsRightToLeft());
1378  nHiddenStart, nHiddenEnd);
1379  }
1380  if (TextFrameIndex(0) == nHiddenStart &&
1381  TextFrameIndex(GetText().getLength()) <= nHiddenEnd)
1382  {
1383  bHiddenCharsHidePara = true;
1384  }
1385  sw::MergedAttrIter iter(*this);
1386  SwTextNode const* pNode(nullptr);
1387  int nNewResultWeight = 0;
1388  for (SwTextAttr const* pHint = iter.NextAttr(&pNode); pHint; pHint = iter.NextAttr(&pNode))
1389  {
1390  if (pHint->Which() == RES_TXTATR_FIELD)
1391  {
1392  // see also SwpHints::CalcHiddenParaField()
1393  const SwFormatField& rField = pHint->GetFormatField();
1394  int nCurWeight = pNode->GetDoc().FieldCanHideParaWeight(rField.GetField()->GetTyp()->Which());
1395  if (nCurWeight > nNewResultWeight)
1396  {
1397  nNewResultWeight = nCurWeight;
1398  bHiddenParaField = pNode->GetDoc().FieldHidesPara(*rField.GetField());
1399  }
1400  else if (nCurWeight == nNewResultWeight && bHiddenParaField)
1401  {
1402  // Currently, for both supported hiding types (HiddenPara, Database), "Don't hide"
1403  // takes precedence - i.e., if there's a "Don't hide" field of that weight, we only
1404  // care about fields of higher weight.
1405  bHiddenParaField = pNode->GetDoc().FieldHidesPara(*rField.GetField());
1406  }
1407  }
1408  }
1409  }
1410  else
1411  {
1412  bHiddenCharsHidePara = static_cast<SwTextNode const*>(SwFrame::GetDep())->HasHiddenCharAttribute( true );
1413  bHiddenParaField = static_cast<SwTextNode const*>(SwFrame::GetDep())->IsHiddenByParaField();
1414  }
1415  const SwViewShell* pVsh = getRootFrame()->GetCurrShell();
1416 
1417  if ( pVsh && ( bHiddenCharsHidePara || bHiddenParaField ) )
1418  {
1419 
1420  if (
1421  ( bHiddenParaField &&
1422  ( !pVsh->GetViewOptions()->IsShowHiddenPara() &&
1423  !pVsh->GetViewOptions()->IsFieldName() ) ) ||
1424  ( bHiddenCharsHidePara &&
1425  !pVsh->GetViewOptions()->IsShowHiddenChar() ) )
1426  {
1427  return true;
1428  }
1429  }
1430 
1431  return false;
1432 }
1433 
1436 {
1437  OSL_ENSURE( !GetFollow() && IsHiddenNow(),
1438  "HideHidden on visible frame of hidden frame has follow" );
1439 
1442 
1443  // format information is obsolete
1444  ClearPara();
1445 }
1446 
1448 {
1449  SwPageFrame *pPage = nullptr;
1450  sw::MergedAttrIter iter(*this);
1451  SwTextNode const* pNode(nullptr);
1452  for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
1453  {
1454  if (pHt->Which() == RES_TXTATR_FTN)
1455  {
1456  TextFrameIndex const nIdx(MapModelToView(pNode, pHt->GetStart()));
1457  if (nEnd < nIdx)
1458  break;
1459  if (nStart <= nIdx)
1460  {
1461  if (!pPage)
1462  pPage = FindPageFrame();
1463  pPage->RemoveFootnote( this, static_cast<const SwTextFootnote*>(pHt) );
1464  }
1465  }
1466  }
1467 }
1468 
1478 bool sw_HideObj( const SwTextFrame& _rFrame,
1479  const RndStdIds _eAnchorType,
1480  SwPosition const& rAnchorPos,
1481  SwAnchoredObject* _pAnchoredObj )
1482 {
1483  bool bRet( true );
1484 
1485  if (_eAnchorType == RndStdIds::FLY_AT_CHAR)
1486  {
1487  const IDocumentSettingAccess *const pIDSA = &_rFrame.GetDoc().getIDocumentSettingAccess();
1492  _rFrame.IsInDocBody() && !_rFrame.FindNextCnt() )
1493  {
1494  SwTextNode const& rNode(*rAnchorPos.nNode.GetNode().GetTextNode());
1495  assert(FrameContainsNode(_rFrame, rNode.GetIndex()));
1496  sal_Int32 const nObjAnchorPos(rAnchorPos.nContent.GetIndex());
1497  const sal_Unicode cAnchorChar = nObjAnchorPos < rNode.Len()
1498  ? rNode.GetText()[nObjAnchorPos]
1499  : 0;
1500  if (cAnchorChar == CH_TXTATR_BREAKWORD)
1501  {
1502  const SwTextAttr* const pHint(
1503  rNode.GetTextAttrForCharAt(nObjAnchorPos, RES_TXTATR_FLYCNT));
1504  if ( pHint )
1505  {
1506  const SwFrameFormat* pFrameFormat =
1507  static_cast<const SwTextFlyCnt*>(pHint)->GetFlyCnt().GetFrameFormat();
1508  if ( pFrameFormat->Which() == RES_FLYFRMFMT )
1509  {
1510  SwNodeIndex nContentIndex = *(pFrameFormat->GetContent().GetContentIdx());
1511  ++nContentIndex;
1512  if ( nContentIndex.GetNode().IsNoTextNode() )
1513  {
1514  bRet = false;
1515  // set needed data structure values for object positioning
1516  SwRectFnSet aRectFnSet(&_rFrame);
1517  SwRect aLastCharRect( _rFrame.getFrameArea() );
1518  aRectFnSet.SetWidth( aLastCharRect, 1 );
1519  _pAnchoredObj->maLastCharRect = aLastCharRect;
1520  _pAnchoredObj->mnLastTopOfLine = aRectFnSet.GetTop(aLastCharRect);
1521  }
1522  }
1523  }
1524  }
1525  }
1526  }
1527 
1528  return bRet;
1529 }
1530 
1542 {
1543  if ( GetDrawObjs() )
1544  {
1545  if ( IsHiddenNow() )
1546  {
1547  // complete paragraph is hidden. Thus, hide all objects
1548  for (SwAnchoredObject* i : *GetDrawObjs())
1549  {
1550  SdrObject* pObj = i->DrawObj();
1551  SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
1552  // under certain conditions
1553  const RndStdIds eAnchorType( pContact->GetAnchorId() );
1554  if ((eAnchorType != RndStdIds::FLY_AT_CHAR) ||
1555  sw_HideObj(*this, eAnchorType, pContact->GetContentAnchor(),
1556  i ))
1557  {
1558  pContact->MoveObjToInvisibleLayer( pObj );
1559  }
1560  }
1561  }
1562  else
1563  {
1564  // paragraph is visible, but can contain hidden text portion.
1565  // first we check if objects are allowed to be hidden:
1566  const SwViewShell* pVsh = getRootFrame()->GetCurrShell();
1567  const bool bShouldBeHidden = !pVsh || !pVsh->GetWin() ||
1568  !pVsh->GetViewOptions()->IsShowHiddenChar();
1569 
1570  // Thus, show all objects, which are anchored at paragraph and
1571  // hide/show objects, which are anchored at/as character, according
1572  // to the visibility of the anchor character.
1573  for (SwAnchoredObject* i : *GetDrawObjs())
1574  {
1575  SdrObject* pObj = i->DrawObj();
1576  SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
1577  // Determine anchor type only once
1578  const RndStdIds eAnchorType( pContact->GetAnchorId() );
1579 
1580  if (eAnchorType == RndStdIds::FLY_AT_PARA)
1581  {
1582  pContact->MoveObjToVisibleLayer( pObj );
1583  }
1584  else if ((eAnchorType == RndStdIds::FLY_AT_CHAR) ||
1585  (eAnchorType == RndStdIds::FLY_AS_CHAR))
1586  {
1587  sal_Int32 nHiddenStart;
1588  sal_Int32 nHiddenEnd;
1589  const SwPosition& rAnchor = pContact->GetContentAnchor();
1591  *rAnchor.nNode.GetNode().GetTextNode(),
1592  rAnchor.nContent.GetIndex(), nHiddenStart, nHiddenEnd);
1593  // Under certain conditions
1594  if ( nHiddenStart != COMPLETE_STRING && bShouldBeHidden &&
1595  sw_HideObj(*this, eAnchorType, rAnchor, i))
1596  {
1597  pContact->MoveObjToInvisibleLayer( pObj );
1598  }
1599  else
1600  pContact->MoveObjToVisibleLayer( pObj );
1601  }
1602  else
1603  {
1604  OSL_FAIL( "<SwTextFrame::HideAndShowObjects()> - object not anchored at/inside paragraph!?" );
1605  }
1606  }
1607  }
1608  }
1609 
1610  if (IsFollow())
1611  {
1612  SwTextFrame *pMaster = FindMaster();
1613  OSL_ENSURE(pMaster, "SwTextFrame without master");
1614  if (pMaster)
1615  pMaster->HideAndShowObjects();
1616  }
1617 }
1618 
1625 TextFrameIndex SwTextFrame::FindBrk(const OUString &rText,
1626  const TextFrameIndex nStart,
1627  const TextFrameIndex nEnd)
1628 {
1629  sal_Int32 nFound = sal_Int32(nStart);
1630  const sal_Int32 nEndLine = std::min(sal_Int32(nEnd), rText.getLength() - 1);
1631 
1632  // Skip all leading blanks.
1633  while( nFound <= nEndLine && ' ' == rText[nFound] )
1634  {
1635  nFound++;
1636  }
1637 
1638  // A tricky situation with the TextAttr-Dummy-character (in this case "$"):
1639  // "Dr.$Meyer" at the beginning of the second line. Typing a blank after that
1640  // doesn't result in the word moving into first line, even though that would work.
1641  // For this reason we don't skip the dummy char.
1642  while( nFound <= nEndLine && ' ' != rText[nFound] )
1643  {
1644  nFound++;
1645  }
1646 
1647  return TextFrameIndex(nFound);
1648 }
1649 
1650 bool SwTextFrame::IsIdxInside(TextFrameIndex const nPos, TextFrameIndex const nLen) const
1651 {
1652 // Silence over-eager warning emitted at least by GCC trunk towards 6:
1653 #if defined __GNUC__ && !defined __clang__
1654 #pragma GCC diagnostic push
1655 #pragma GCC diagnostic ignored "-Wstrict-overflow"
1656 #endif
1657  if (nLen != TextFrameIndex(COMPLETE_STRING) && GetOffset() > nPos + nLen) // the range preceded us
1658 #if defined __GNUC__ && !defined __clang__
1659 #pragma GCC diagnostic pop
1660 #endif
1661  return false;
1662 
1663  if( !GetFollow() ) // the range doesn't precede us,
1664  return true; // nobody follows us.
1665 
1666  TextFrameIndex const nMax = GetFollow()->GetOffset();
1667 
1668  // either the range overlap or our text has been deleted
1669  // sw_redlinehide: GetText() should be okay here because it has already
1670  // been updated in the INS/DEL hint case
1671  if (nMax > nPos || nMax > TextFrameIndex(GetText().getLength()))
1672  return true;
1673 
1674  // changes made in the first line of a follow can modify the master
1675  const SwParaPortion* pPara = GetFollow()->GetPara();
1676  return pPara && ( nPos <= nMax + pPara->GetLen() );
1677 }
1678 
1679 inline void SwTextFrame::InvalidateRange(const SwCharRange &aRange, const tools::Long nD)
1680 {
1681  if ( IsIdxInside( aRange.Start(), aRange.Len() ) )
1682  InvalidateRange_( aRange, nD );
1683 }
1684 
1686 {
1687  if ( !HasPara() )
1688  { InvalidateSize();
1689  return;
1690  }
1691 
1692  SetWidow( false );
1693  SwParaPortion *pPara = GetPara();
1694 
1695  bool bInv = false;
1696  if( 0 != nD )
1697  {
1698  // In nDelta the differences between old and new
1699  // linelengths are being added, that's why it's negative
1700  // if chars have been added and positive, if chars have
1701  // deleted
1702  pPara->GetDelta() += nD;
1703  bInv = true;
1704  }
1705  SwCharRange &rReformat = pPara->GetReformat();
1706  if(aRange != rReformat) {
1707  if (TextFrameIndex(COMPLETE_STRING) == rReformat.Len())
1708  rReformat = aRange;
1709  else
1710  rReformat += aRange;
1711  bInv = true;
1712  }
1713  if(bInv)
1714  {
1715  InvalidateSize();
1716  }
1717 }
1718 
1720 {
1721  OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
1722  "SwTextFrame::CalcLineSpace with swapped frame!" );
1723 
1724  if( IsLocked() || !HasPara() )
1725  return;
1726 
1727  if( GetDrawObjs() ||
1728  GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace().IsAutoFirst())
1729  {
1730  Init();
1731  return;
1732  }
1733 
1734  SwParaPortion *const pPara(GetPara());
1735  assert(pPara);
1736  if (pPara->IsFixLineHeight())
1737  {
1738  Init();
1739  return;
1740  }
1741 
1742  Size aNewSize( getFramePrintArea().SSize() );
1743 
1744  SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this );
1745  SwTextFormatter aLine( this, &aInf );
1746  if( aLine.GetDropLines() )
1747  {
1748  Init();
1749  return;
1750  }
1751 
1752  aLine.Top();
1753  aLine.RecalcRealHeight();
1754 
1755  aNewSize.setHeight( (aLine.Y() - getFrameArea().Top()) + aLine.GetLineHeight() );
1756 
1757  SwTwips nDelta = aNewSize.Height() - getFramePrintArea().Height();
1758  // Underflow with free-flying frames
1759  if( aInf.GetTextFly().IsOn() )
1760  {
1761  SwRect aTmpFrame( getFrameArea() );
1762  if( nDelta < 0 )
1763  aTmpFrame.Height( getFramePrintArea().Height() );
1764  else
1765  aTmpFrame.Height( aNewSize.Height() );
1766  if( aInf.GetTextFly().Relax( aTmpFrame ) )
1767  {
1768  Init();
1769  return;
1770  }
1771  }
1772 
1773  if( !nDelta )
1774  return;
1775 
1776  SwTextFrameBreak aBreak( this );
1777  if( GetFollow() || aBreak.IsBreakNow( aLine ) )
1778  {
1779  // if there is a Follow() or if we need to break here, reformat
1780  Init();
1781  }
1782  else
1783  {
1784  // everything is business as usual...
1785  pPara->SetPrepAdjust();
1786  pPara->SetPrep();
1787  }
1788 }
1789 
1790 static void lcl_SetWrong( SwTextFrame& rFrame, SwTextNode const& rNode,
1791  sal_Int32 const nPos, sal_Int32 const nCnt, bool const bMove)
1792 {
1793  if ( !rFrame.IsFollow() )
1794  {
1795  SwTextNode* pTextNode = const_cast<SwTextNode*>(&rNode);
1796  IGrammarContact* pGrammarContact = getGrammarContact( *pTextNode );
1797  SwGrammarMarkUp* pWrongGrammar = pGrammarContact ?
1798  pGrammarContact->getGrammarCheck( *pTextNode, false ) :
1799  pTextNode->GetGrammarCheck();
1800  bool bGrammarProxy = pWrongGrammar != pTextNode->GetGrammarCheck();
1801  if( bMove )
1802  {
1803  if( pTextNode->GetWrong() )
1804  pTextNode->GetWrong()->Move( nPos, nCnt );
1805  if( pWrongGrammar )
1806  pWrongGrammar->MoveGrammar( nPos, nCnt );
1807  if( bGrammarProxy && pTextNode->GetGrammarCheck() )
1808  pTextNode->GetGrammarCheck()->MoveGrammar( nPos, nCnt );
1809  if( pTextNode->GetSmartTags() )
1810  pTextNode->GetSmartTags()->Move( nPos, nCnt );
1811  }
1812  else
1813  {
1814  if( pTextNode->GetWrong() )
1815  pTextNode->GetWrong()->Invalidate( nPos, nCnt );
1816  if( pWrongGrammar )
1817  pWrongGrammar->Invalidate( nPos, nCnt );
1818  if( pTextNode->GetSmartTags() )
1819  pTextNode->GetSmartTags()->Invalidate( nPos, nCnt );
1820  }
1821  const sal_Int32 nEnd = nPos + (nCnt > 0 ? nCnt : 1 );
1822  if ( !pTextNode->GetWrong() && !pTextNode->IsWrongDirty() )
1823  {
1824  pTextNode->SetWrong( new SwWrongList( WRONGLIST_SPELL ) );
1825  pTextNode->GetWrong()->SetInvalid( nPos, nEnd );
1826  }
1827  if ( !pTextNode->GetSmartTags() && !pTextNode->IsSmartTagDirty() )
1828  {
1829  pTextNode->SetSmartTags( new SwWrongList( WRONGLIST_SMARTTAG ) );
1830  pTextNode->GetSmartTags()->SetInvalid( nPos, nEnd );
1831  }
1833  pTextNode->SetGrammarCheckDirty( true );
1834  pTextNode->SetWordCountDirty( true );
1835  pTextNode->SetAutoCompleteWordDirty( true );
1836  pTextNode->SetSmartTagDirty( true );
1837  }
1838 
1839  SwRootFrame *pRootFrame = rFrame.getRootFrame();
1840  if (pRootFrame)
1841  {
1842  pRootFrame->SetNeedGrammarCheck( true );
1843  }
1844 
1845  SwPageFrame *pPage = rFrame.FindPageFrame();
1846  if( pPage )
1847  {
1848  pPage->InvalidateSpelling();
1849  pPage->InvalidateAutoCompleteWords();
1850  pPage->InvalidateWordCount();
1851  pPage->InvalidateSmartTags();
1852  }
1853 }
1854 
1855 static void lcl_SetScriptInval(SwTextFrame& rFrame, TextFrameIndex const nPos)
1856 {
1857  if( rFrame.GetPara() )
1858  rFrame.GetPara()->GetScriptInfo().SetInvalidityA( nPos );
1859 }
1860 
1861 // note: SwClientNotify will be called once for every frame => just fix own Ofst
1862 static void lcl_ModifyOfst(SwTextFrame & rFrame,
1863  TextFrameIndex const nPos, TextFrameIndex const nLen,
1864  TextFrameIndex (* op)(TextFrameIndex const&, TextFrameIndex const&))
1865 {
1867  if (rFrame.IsFollow() && nPos < rFrame.GetOffset())
1868  {
1869  rFrame.ManipOfst( std::max(nPos, op(rFrame.GetOffset(), nLen)) );
1870  assert(sal_Int32(rFrame.GetOffset()) <= rFrame.GetText().getLength());
1871  }
1872 }
1873 
1874 namespace {
1875 
1876 void UpdateMergedParaForMove(sw::MergedPara & rMerged,
1877  SwTextFrame & rTextFrame,
1878  bool & o_rbRecalcFootnoteFlag,
1879  SwTextNode const& rDestNode,
1880  SwTextNode const& rNode,
1881  sal_Int32 const nDestStart,
1882  sal_Int32 const nSourceStart,
1883  sal_Int32 const nLen)
1884 {
1885  std::vector<std::pair<sal_Int32, sal_Int32>> deleted;
1886  sal_Int32 const nSourceEnd(nSourceStart + nLen);
1887  sal_Int32 nLastEnd(0);
1888  for (const auto& rExt : rMerged.extents)
1889  {
1890  if (rExt.pNode == &rNode)
1891  {
1892  sal_Int32 const nStart(std::max(nLastEnd, nSourceStart));
1893  sal_Int32 const nEnd(std::min(rExt.nStart, nSourceEnd));
1894  if (nStart < nEnd)
1895  {
1896  deleted.emplace_back(nStart, nEnd);
1897  }
1898  nLastEnd = rExt.nEnd;
1899  if (nSourceEnd <= rExt.nEnd)
1900  {
1901  break;
1902  }
1903  }
1904  else if (rNode.GetIndex() < rExt.pNode->GetIndex())
1905  {
1906  break;
1907  }
1908  }
1909  if (nLastEnd != rNode.Len()) // without nLen, string yet to be removed
1910  {
1911  if (nLastEnd < nSourceEnd)
1912  {
1913  deleted.emplace_back(std::max(nLastEnd, nSourceStart), nSourceEnd);
1914  }
1915  }
1916  if (deleted.empty())
1917  return;
1918 
1919  o_rbRecalcFootnoteFlag = true;
1920  for (auto const& it : deleted)
1921  {
1922  sal_Int32 const nStart(it.first - nSourceStart + nDestStart);
1923  TextFrameIndex const nDeleted = UpdateMergedParaForDelete(rMerged, false,
1924  rDestNode, nStart, it.second - it.first);
1925 //FIXME asserts valid for join - but if called from split, the new node isn't there yet and it will be added later... assert(nDeleted);
1926 // assert(nDeleted == it.second - it.first);
1927  if(nDeleted)
1928  {
1929  // InvalidateRange/lcl_SetScriptInval was called sufficiently for SwInsText
1930  lcl_SetWrong(rTextFrame, rDestNode, nStart, it.first - it.second, false);
1931  TextFrameIndex const nIndex(sw::MapModelToView(rMerged, &rDestNode, nStart));
1932  lcl_ModifyOfst(rTextFrame, nIndex, nDeleted, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
1933  }
1934  }
1935 }
1936 
1937 } // namespace
1938 
1943 static bool isA11yRelevantAttribute(sal_uInt16 nWhich)
1944 {
1945  return nWhich != RES_CHRATR_RSID;
1946 }
1947 
1948 static bool hasA11yRelevantAttribute( const std::vector<sal_uInt16>& rWhichFmtAttr )
1949 {
1950  for( sal_uInt16 nWhich : rWhichFmtAttr )
1951  if ( isA11yRelevantAttribute( nWhich ) )
1952  return true;
1953 
1954  return false;
1955 }
1956 
1957 // Note: for now this overrides SwClient::SwClientNotify; the intermediary
1958 // classes still override SwClient::Modify, which should continue to work
1959 // as their implementation of SwClientNotify is SwClient's which calls Modify.
1960 // Therefore we also don't need to call SwClient::SwClientNotify(rModify, rHint)
1961 // because that's all it does, and this implementation calls
1962 // SwContentFrame::SwClientNotify() when appropriate.
1963 void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
1964 {
1965  SfxPoolItem const* pOld(nullptr);
1966  SfxPoolItem const* pNew(nullptr);
1967  sw::MoveText const* pMoveText(nullptr);
1968  sw::RedlineDelText const* pRedlineDelText(nullptr);
1969  sw::RedlineUnDelText const* pRedlineUnDelText(nullptr);
1970 
1971  sal_uInt16 nWhich = 0;
1972  if (auto const pHint = dynamic_cast<sw::LegacyModifyHint const*>(&rHint))
1973  {
1974  pOld = pHint->m_pOld;
1975  pNew = pHint->m_pNew;
1976  nWhich = pHint->GetWhich();
1977  }
1978  else if (auto const pHt = dynamic_cast<sw::MoveText const*>(&rHint))
1979  {
1980  pMoveText = pHt;
1981  }
1982  else if (auto const pHynt = dynamic_cast<sw::RedlineDelText const*>(&rHint))
1983  {
1984  pRedlineDelText = pHynt;
1985  }
1986  else if (auto const pHnt = dynamic_cast<sw::RedlineUnDelText const*>(&rHint))
1987  {
1988  pRedlineUnDelText = pHnt;
1989  }
1990  else
1991  {
1992  assert(!"unexpected hint");
1993  }
1994 
1995  if (m_pMergedPara)
1996  {
1997  assert(m_pMergedPara->listener.IsListeningTo(&rModify));
1998  }
1999 
2000  SwTextNode const& rNode(static_cast<SwTextNode const&>(rModify));
2001 
2002  // modifications concerning frame attributes are processed by the base class
2003  if( IsInRange( aFrameFormatSetRange, nWhich ) || RES_FMT_CHG == nWhich )
2004  {
2005  if (m_pMergedPara)
2006  { // ignore item set changes that don't apply
2007  SwTextNode const*const pAttrNode(
2008  (nWhich == RES_PAGEDESC || nWhich == RES_BREAK)
2009  ? m_pMergedPara->pFirstNode
2010  : m_pMergedPara->pParaPropsNode);
2011  if (pAttrNode != &rModify)
2012  {
2013  return;
2014  }
2015  }
2017  if( nWhich == RES_FMT_CHG && getRootFrame()->GetCurrShell() )
2018  {
2019  // collection has changed
2020  Prepare();
2021  InvalidatePrt_();
2022  lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
2023  SetDerivedR2L( false );
2024  CheckDirChange();
2025  // Force complete paint due to existing indents.
2026  SetCompletePaint();
2028  }
2029  return;
2030  }
2031 
2032  if (m_pMergedPara && m_pMergedPara->pParaPropsNode != &rModify)
2033  {
2034  if (isPARATR(nWhich) || isPARATR_LIST(nWhich)) // FRMATR handled above
2035  {
2036  return; // ignore it
2037  }
2038  }
2039 
2040  Broadcast(SfxHint()); // notify SwAccessibleParagraph
2041 
2042  // while locked ignore all modifications
2043  if( IsLocked() )
2044  return;
2045 
2046  // save stack
2047  // warning: one has to ensure that all variables are set
2048  TextFrameIndex nPos;
2049  TextFrameIndex nLen;
2050  bool bSetFieldsDirty = false;
2051  bool bRecalcFootnoteFlag = false;
2052 
2053  if (pRedlineDelText)
2054  {
2055  if (m_pMergedPara)
2056  {
2057  sal_Int32 const nNPos = pRedlineDelText->nStart;
2058  sal_Int32 const nNLen = pRedlineDelText->nLen;
2059  nPos = MapModelToView(&rNode, nNPos);
2060  // update merged before doing anything else
2061  nLen = UpdateMergedParaForDelete(*m_pMergedPara, false, rNode, nNPos, nNLen);
2062  const sal_Int32 m = -nNLen;
2063  if (nLen && IsIdxInside(nPos, nLen))
2064  {
2065  InvalidateRange( SwCharRange(nPos, TextFrameIndex(1)), m );
2066  }
2067  lcl_SetWrong( *this, rNode, nNPos, m, false );
2068  if (nLen)
2069  {
2070  lcl_SetScriptInval( *this, nPos );
2071  bSetFieldsDirty = bRecalcFootnoteFlag = true;
2072  lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
2073  }
2074  }
2075  }
2076  else if (pRedlineUnDelText)
2077  {
2078  if (m_pMergedPara)
2079  {
2080  sal_Int32 const nNPos = pRedlineUnDelText->nStart;
2081  sal_Int32 const nNLen = pRedlineUnDelText->nLen;
2082  nPos = MapModelToView(&rNode, nNPos);
2083  nLen = UpdateMergedParaForInsert(*m_pMergedPara, false, rNode, nNPos, nNLen);
2084  if (IsIdxInside(nPos, nLen))
2085  {
2086  if (!nLen)
2087  {
2088  // Refresh NumPortions even when line is empty!
2089  if (nPos)
2090  InvalidateSize();
2091  else
2092  Prepare();
2093  }
2094  else
2095  InvalidateRange_( SwCharRange( nPos, nLen ), nNLen );
2096  }
2097  lcl_SetWrong( *this, rNode, nNPos, nNLen, false );
2098  lcl_SetScriptInval( *this, nPos );
2099  bSetFieldsDirty = true;
2100  lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>);
2101  }
2102  }
2103  else if (pMoveText)
2104  {
2105  if (m_pMergedPara
2106  && m_pMergedPara->pFirstNode->GetIndex() <= pMoveText->pDestNode->GetIndex()
2107  && pMoveText->pDestNode->GetIndex() <= m_pMergedPara->pLastNode->GetIndex())
2108  { // if it's not 2 nodes in merged frame, assume the target node doesn't have frames at all
2109  assert(std::abs(static_cast<tools::Long>(rNode.GetIndex()) - static_cast<tools::Long>(pMoveText->pDestNode->GetIndex())) == 1);
2110  UpdateMergedParaForMove(*m_pMergedPara,
2111  *this,
2112  bRecalcFootnoteFlag,
2113  *pMoveText->pDestNode, rNode,
2114  pMoveText->nDestStart,
2115  pMoveText->nSourceStart,
2116  pMoveText->nLen);
2117  }
2118  else
2119  {
2120  // there is a situation where this is okay: from JoinNext, which will then call CheckResetRedlineMergeFlag, which will then create merged from scratch for this frame
2121  // assert(!m_pMergedPara || !getRootFrame()->IsHideRedlines() || !pMoveText->pDestNode->getLayoutFrame(getRootFrame()));
2122  }
2123  }
2124  else switch (nWhich)
2125  {
2126  case RES_LINENUMBER:
2127  {
2128  assert(false); // should have been forwarded to SwContentFrame
2130  }
2131  break;
2132  case RES_INS_TXT:
2133  {
2134  sal_Int32 const nNPos = static_cast<const SwInsText*>(pNew)->nPos;
2135  sal_Int32 const nNLen = static_cast<const SwInsText*>(pNew)->nLen;
2136  nPos = MapModelToView(&rNode, nNPos);
2137  nLen = TextFrameIndex(nNLen);
2138  if (m_pMergedPara)
2139  {
2140  UpdateMergedParaForInsert(*m_pMergedPara, true, rNode, nNPos, nNLen);
2141  }
2142  if( IsIdxInside( nPos, nLen ) )
2143  {
2144  if( !nLen )
2145  {
2146  // Refresh NumPortions even when line is empty!
2147  if( nPos )
2148  InvalidateSize();
2149  else
2150  Prepare();
2151  }
2152  else
2153  InvalidateRange_( SwCharRange( nPos, nLen ), nNLen );
2154  }
2155  lcl_SetWrong( *this, rNode, nNPos, nNLen, true );
2156  lcl_SetScriptInval( *this, nPos );
2157  bSetFieldsDirty = true;
2158  lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>);
2159  }
2160  break;
2161  case RES_DEL_CHR:
2162  {
2163  sal_Int32 const nNPos = static_cast<const SwDelChr*>(pNew)->nPos;
2164  nPos = MapModelToView(&rNode, nNPos);
2165  if (m_pMergedPara)
2166  {
2167  nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, nNPos, 1);
2168  }
2169  else
2170  {
2171  nLen = TextFrameIndex(1);
2172  }
2173  lcl_SetWrong( *this, rNode, nNPos, -1, true );
2174  if (nLen)
2175  {
2176  InvalidateRange( SwCharRange(nPos, nLen), -1 );
2177  lcl_SetScriptInval( *this, nPos );
2178  bSetFieldsDirty = bRecalcFootnoteFlag = true;
2179  lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
2180  }
2181  }
2182  break;
2183  case RES_DEL_TXT:
2184  {
2185  sal_Int32 const nNPos = static_cast<const SwDelText*>(pNew)->nStart;
2186  sal_Int32 const nNLen = static_cast<const SwDelText*>(pNew)->nLen;
2187  nPos = MapModelToView(&rNode, nNPos);
2188  if (m_pMergedPara)
2189  { // update merged before doing anything else
2190  nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, nNPos, nNLen);
2191  }
2192  else
2193  {
2194  nLen = TextFrameIndex(nNLen);
2195  }
2196  const sal_Int32 m = -nNLen;
2197  if ((!m_pMergedPara || nLen) && IsIdxInside(nPos, nLen))
2198  {
2199  if( !nLen )
2200  InvalidateSize();
2201  else
2202  InvalidateRange( SwCharRange(nPos, TextFrameIndex(1)), m );
2203  }
2204  lcl_SetWrong( *this, rNode, nNPos, m, true );
2205  if (nLen)
2206  {
2207  lcl_SetScriptInval( *this, nPos );
2208  bSetFieldsDirty = bRecalcFootnoteFlag = true;
2209  lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
2210  }
2211  }
2212  break;
2213  case RES_UPDATE_ATTR:
2214  {
2215  const SwUpdateAttr* pNewUpdate = static_cast<const SwUpdateAttr*>(pNew);
2216 
2217  sal_Int32 const nNPos = pNewUpdate->getStart();
2218  sal_Int32 const nNLen = pNewUpdate->getEnd() - nNPos;
2219  nPos = MapModelToView(&rNode, nNPos);
2220  nLen = MapModelToView(&rNode, nNPos + nNLen) - nPos;
2221  if( IsIdxInside( nPos, nLen ) )
2222  {
2223  // We need to reformat anyways, even if the invalidated
2224  // range is empty.
2225  // E.g.: empty line, set 14 pt!
2226 
2227  // FootnoteNumbers need to be formatted
2228  if( !nLen )
2229  nLen = TextFrameIndex(1);
2230 
2231  InvalidateRange_( SwCharRange( nPos, nLen) );
2232  const sal_uInt16 nTmp = pNewUpdate->getWhichAttr();
2233 
2234  if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_INETFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp ||
2235  RES_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp )
2236  {
2237  lcl_SetWrong( *this, rNode, nNPos, nNPos + nNLen, false );
2238  lcl_SetScriptInval( *this, nPos );
2239  }
2240  }
2241 
2242  if( isA11yRelevantAttribute( pNewUpdate->getWhichAttr() ) &&
2243  hasA11yRelevantAttribute( pNewUpdate->getFmtAttrs() ) )
2244  {
2245  SwViewShell* pViewSh = getRootFrame() ? getRootFrame()->GetCurrShell() : nullptr;
2246  if ( pViewSh )
2247  {
2248  pViewSh->InvalidateAccessibleParaAttrs( *this );
2249  }
2250  }
2251  }
2252  break;
2253  case RES_OBJECTDYING:
2254  break;
2255 
2257  {
2258  CalcLineSpace();
2259  InvalidateSize();
2260  InvalidatePrt_();
2261  if( IsInSct() && !GetPrev() )
2262  {
2263  SwSectionFrame *pSect = FindSctFrame();
2264  if( pSect->ContainsAny() == this )
2265  pSect->InvalidatePrt();
2266  }
2267 
2268  // i#11859
2269  // (1) Also invalidate next frame on next page/column.
2270  // (2) Skip empty sections and hidden paragraphs
2271  // Thus, use method <InvalidateNextPrtArea()>
2273 
2274  SetCompletePaint();
2275  }
2276  break;
2277 
2278  case RES_TXTATR_FIELD:
2279  case RES_TXTATR_ANNOTATION:
2280  {
2281  sal_Int32 const nNPos = static_cast<const SwFormatField*>(pNew)->GetTextField()->GetStart();
2282  nPos = MapModelToView(&rNode, nNPos);
2283  if (IsIdxInside(nPos, TextFrameIndex(1)))
2284  {
2285  if( pNew == pOld )
2286  {
2287  // only repaint
2288  // opt: invalidate window?
2289  InvalidatePage();
2290  SetCompletePaint();
2291  }
2292  else
2294  }
2295  bSetFieldsDirty = true;
2296  // ST2
2297  if ( SwSmartTagMgr::Get().IsSmartTagsEnabled() )
2298  lcl_SetWrong( *this, rNode, nNPos, nNPos + 1, false );
2299  }
2300  break;
2301 
2302  case RES_TXTATR_FTN :
2303  {
2304  if (!IsInFootnote())
2305  { // the hint may be sent from the anchor node, or from a
2306  // node in the footnote; the anchor index is only valid in the
2307  // anchor node!
2308  assert(&rNode == &static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote()->GetTextNode());
2309  nPos = MapModelToView(&rNode,
2310  static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote()->GetStart());
2311  }
2312 #ifdef _MSC_VER
2313  else nPos = TextFrameIndex(42); // shut up MSVC 2017 spurious warning C4701
2314 #endif
2315  if (IsInFootnote() || IsIdxInside(nPos, TextFrameIndex(1)))
2316  Prepare( PrepareHint::FootnoteInvalidation, static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote() );
2317  break;
2318  }
2319 
2320  case RES_ATTRSET_CHG:
2321  {
2323 
2324  const SwAttrSet& rNewSet = *static_cast<const SwAttrSetChg*>(pNew)->GetChgSet();
2325  const SfxPoolItem* pItem = nullptr;
2326  int nClear = 0;
2327  sal_uInt16 nCount = rNewSet.Count();
2328 
2329  if( SfxItemState::SET == rNewSet.GetItemState( RES_TXTATR_FTN, false, &pItem ))
2330  {
2331  nPos = MapModelToView(&rNode,
2332  static_cast<const SwFormatFootnote*>(pItem)->GetTextFootnote()->GetStart());
2333  if (IsIdxInside(nPos, TextFrameIndex(1)))
2335  nClear = 0x01;
2336  --nCount;
2337  }
2338 
2339  if( SfxItemState::SET == rNewSet.GetItemState( RES_TXTATR_FIELD, false, &pItem ))
2340  {
2341  nPos = MapModelToView(&rNode,
2342  static_cast<const SwFormatField*>(pItem)->GetTextField()->GetStart());
2343  if (IsIdxInside(nPos, TextFrameIndex(1)))
2344  {
2345  const SfxPoolItem* pOldItem = pOld ?
2346  &(static_cast<const SwAttrSetChg*>(pOld)->GetChgSet()->Get(RES_TXTATR_FIELD)) : nullptr;
2347  if( pItem == pOldItem )
2348  {
2349  InvalidatePage();
2350  SetCompletePaint();
2351  }
2352  else
2354  }
2355  nClear |= 0x02;
2356  --nCount;
2357  }
2358  bool bLineSpace = SfxItemState::SET == rNewSet.GetItemState(
2359  RES_PARATR_LINESPACING, false ),
2360  bRegister = SfxItemState::SET == rNewSet.GetItemState(
2361  RES_PARATR_REGISTER, false );
2362  if ( bLineSpace || bRegister )
2363  {
2364  if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2365  {
2367  CalcLineSpace();
2368  InvalidateSize();
2369  InvalidatePrt_();
2370 
2371  // i#11859
2372  // (1) Also invalidate next frame on next page/column.
2373  // (2) Skip empty sections and hidden paragraphs
2374  // Thus, use method <InvalidateNextPrtArea()>
2376 
2377  SetCompletePaint();
2378  }
2379  nClear |= 0x04;
2380  if ( bLineSpace )
2381  {
2382  --nCount;
2383  if ((!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2384  && IsInSct() && !GetPrev())
2385  {
2386  SwSectionFrame *pSect = FindSctFrame();
2387  if( pSect->ContainsAny() == this )
2388  pSect->InvalidatePrt();
2389  }
2390  }
2391  if ( bRegister )
2392  --nCount;
2393  }
2394  if ( SfxItemState::SET == rNewSet.GetItemState( RES_PARATR_SPLIT,
2395  false ))
2396  {
2397  if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2398  {
2399  if (GetPrev())
2400  CheckKeep();
2401  Prepare();
2402  InvalidateSize();
2403  }
2404  nClear |= 0x08;
2405  --nCount;
2406  }
2407 
2408  if( SfxItemState::SET == rNewSet.GetItemState( RES_BACKGROUND, false)
2409  && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2410  && !IsFollow() && GetDrawObjs() )
2411  {
2412  SwSortedObjs *pObjs = GetDrawObjs();
2413  for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i )
2414  {
2415  SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
2416  if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
2417  {
2418  if( !pFly->IsFlyInContentFrame() )
2419  {
2420  const SvxBrushItem &rBack =
2421  pFly->GetAttrSet()->GetBackground();
2422  // #GetTransChg#
2423  // following condition determines, if the fly frame
2424  // "inherites" the background color of text frame.
2425  // This is the case, if fly frame background
2426  // color is "no fill"/"auto fill" and if the fly frame
2427  // has no background graphic.
2428  // Thus, check complete fly frame background
2429  // color and *not* only its transparency value
2430  if ( (rBack.GetColor() == COL_TRANSPARENT) &&
2431  rBack.GetGraphicPos() == GPOS_NONE )
2432  {
2433  pFly->SetCompletePaint();
2434  pFly->InvalidatePage();
2435  }
2436  }
2437  }
2438  }
2439  }
2440 
2441  if ( SfxItemState::SET ==
2442  rNewSet.GetItemState( RES_TXTATR_CHARFMT, false ) )
2443  {
2444  lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
2445  lcl_SetScriptInval( *this, TextFrameIndex(0) );
2446  }
2447  else if ( SfxItemState::SET ==
2448  rNewSet.GetItemState( RES_CHRATR_LANGUAGE, false ) ||
2449  SfxItemState::SET ==
2450  rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, false ) ||
2451  SfxItemState::SET ==
2452  rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, false ) )
2453  lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
2454  else if ( SfxItemState::SET ==
2455  rNewSet.GetItemState( RES_CHRATR_FONT, false ) ||
2456  SfxItemState::SET ==
2457  rNewSet.GetItemState( RES_CHRATR_CJK_FONT, false ) ||
2458  SfxItemState::SET ==
2459  rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) )
2460  lcl_SetScriptInval( *this, TextFrameIndex(0) );
2461  else if ( SfxItemState::SET ==
2462  rNewSet.GetItemState( RES_FRAMEDIR, false )
2463  && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify))
2464  {
2465  SetDerivedR2L( false );
2466  CheckDirChange();
2467  // Force complete paint due to existing indents.
2468  SetCompletePaint();
2469  }
2470 
2471  if( nCount )
2472  {
2473  if( getRootFrame()->GetCurrShell() )
2474  {
2475  Prepare();
2476  InvalidatePrt_();
2477  }
2478 
2479  if (nClear || (m_pMergedPara &&
2480  (m_pMergedPara->pParaPropsNode != &rModify ||
2481  m_pMergedPara->pFirstNode != &rModify)))
2482  {
2483  assert(pOld);
2484  SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
2485  SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
2486 
2487  if (m_pMergedPara && m_pMergedPara->pParaPropsNode != &rModify)
2488  {
2489  for (sal_uInt16 i = RES_PARATR_BEGIN; i != RES_FRMATR_END; ++i)
2490  {
2491  if (i != RES_BREAK && i != RES_PAGEDESC)
2492  {
2493  aOldSet.ClearItem(i);
2494  aNewSet.ClearItem(i);
2495  }
2496  }
2497  for (sal_uInt16 i = XATTR_FILL_FIRST; i <= XATTR_FILL_LAST; ++i)
2498  {
2499  aOldSet.ClearItem(i);
2500  aNewSet.ClearItem(i);
2501  }
2502  }
2503  if (m_pMergedPara && m_pMergedPara->pFirstNode != &rModify)
2504  {
2505  aOldSet.ClearItem(RES_BREAK);
2506  aNewSet.ClearItem(RES_BREAK);
2507  aOldSet.ClearItem(RES_PAGEDESC);
2508  aNewSet.ClearItem(RES_PAGEDESC);
2509  }
2510 
2511  if( 0x01 & nClear )
2512  {
2513  aOldSet.ClearItem( RES_TXTATR_FTN );
2514  aNewSet.ClearItem( RES_TXTATR_FTN );
2515  }
2516  if( 0x02 & nClear )
2517  {
2518  aOldSet.ClearItem( RES_TXTATR_FIELD );
2519  aNewSet.ClearItem( RES_TXTATR_FIELD );
2520  }
2521  if ( 0x04 & nClear )
2522  {
2523  if ( bLineSpace )
2524  {
2525  aOldSet.ClearItem( RES_PARATR_LINESPACING );
2526  aNewSet.ClearItem( RES_PARATR_LINESPACING );
2527  }
2528  if ( bRegister )
2529  {
2530  aOldSet.ClearItem( RES_PARATR_REGISTER );
2531  aNewSet.ClearItem( RES_PARATR_REGISTER );
2532  }
2533  }
2534  if ( 0x08 & nClear )
2535  {
2536  aOldSet.ClearItem( RES_PARATR_SPLIT );
2537  aNewSet.ClearItem( RES_PARATR_SPLIT );
2538  }
2539  if (aOldSet.Count() || aNewSet.Count())
2540  {
2541  SwContentFrame::SwClientNotify(rModify, sw::LegacyModifyHint(&aOldSet, &aNewSet));
2542  }
2543  }
2544  else
2546  }
2547 
2548  if (isA11yRelevantAttribute(nWhich))
2549  {
2550  SwViewShell* pViewSh = getRootFrame() ? getRootFrame()->GetCurrShell() : nullptr;
2551  if ( pViewSh )
2552  {
2553  pViewSh->InvalidateAccessibleParaAttrs( *this );
2554  }
2555  }
2556  }
2557  break;
2558 
2559  // Process SwDocPosUpdate
2560  case RES_DOCPOS_UPDATE:
2561  {
2562  if( pOld && pNew )
2563  {
2564  const SwDocPosUpdate *pDocPos = static_cast<const SwDocPosUpdate*>(pOld);
2565  if( pDocPos->nDocPos <= getFrameArea().Top() )
2566  {
2567  const SwFormatField *pField = static_cast<const SwFormatField *>(pNew);
2568  TextFrameIndex const nIndex(MapModelToView(&rNode,
2569  pField->GetTextField()->GetStart()));
2571  }
2572  }
2573  break;
2574  }
2575  case RES_PARATR_SPLIT:
2576  if ( GetPrev() )
2577  CheckKeep();
2578  Prepare();
2579  bSetFieldsDirty = true;
2580  break;
2581  case RES_FRAMEDIR :
2582  assert(false); // should have been forwarded to SwContentFrame
2583  SetDerivedR2L( false );
2584  CheckDirChange();
2585  break;
2586  default:
2587  {
2588  Prepare();
2589  InvalidatePrt_();
2590  if ( !nWhich )
2591  {
2592  // is called by e. g. HiddenPara with 0
2593  SwFrame *pNxt = FindNext();
2594  if ( nullptr != pNxt )
2595  pNxt->InvalidatePrt();
2596  }
2597  }
2598  } // switch
2599 
2600  if( bSetFieldsDirty )
2601  GetDoc().getIDocumentFieldsAccess().SetFieldsDirty( true, &rNode, 1 );
2602 
2603  if ( bRecalcFootnoteFlag )
2604  CalcFootnoteFlag();
2605 }
2606 
2607 bool SwTextFrame::GetInfo( SfxPoolItem &rHint ) const
2608 {
2609  if ( RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && ! IsFollow() )
2610  {
2611  SwVirtPageNumInfo &rInfo = static_cast<SwVirtPageNumInfo&>(rHint);
2612  const SwPageFrame *pPage = FindPageFrame();
2613  if ( pPage )
2614  {
2615  if ( pPage == rInfo.GetOrigPage() && !GetPrev() )
2616  {
2617  // this should be the one
2618  // (could only differ temporarily; is that disturbing?)
2619  rInfo.SetInfo( pPage, this );
2620  return false;
2621  }
2622  if ( pPage->GetPhyPageNum() < rInfo.GetOrigPage()->GetPhyPageNum() &&
2623  (!rInfo.GetPage() || pPage->GetPhyPageNum() > rInfo.GetPage()->GetPhyPageNum()))
2624  {
2625  // this could be the one
2626  rInfo.SetInfo( pPage, this );
2627  }
2628  }
2629  }
2630  return true;
2631 }
2632 
2633 void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
2634 {
2635  OSL_ENSURE(GetFollow() && nNeed, "+SwTextFrame::Prepare: lost all friends");
2636 
2637  SwParaPortion *pPara = GetPara();
2638  if ( !pPara )
2639  return;
2640  pPara->SetPrepWidows();
2641 
2642  sal_uInt16 nHave = nNeed;
2643 
2644  // We yield a few lines and shrink in CalcPreps()
2645  SwSwapIfNotSwapped swap( this );
2646 
2647  SwTextSizeInfo aInf( this );
2648  SwTextMargin aLine( this, &aInf );
2649  aLine.Bottom();
2650  TextFrameIndex nTmpLen = aLine.GetCurr()->GetLen();
2651  while( nHave && aLine.PrevLine() )
2652  {
2653  if( nTmpLen )
2654  --nHave;
2655  nTmpLen = aLine.GetCurr()->GetLen();
2656  }
2657 
2658  // If it's certain that we can yield lines, the Master needs
2659  // to check the widow rule
2660  if( !nHave )
2661  {
2662  bool bSplit = true;
2663  if( !IsFollow() ) // only a master decides about orphans
2664  {
2665  const WidowsAndOrphans aWidOrp( this );
2666  bSplit = ( aLine.GetLineNr() >= aWidOrp.GetOrphansLines() &&
2667  aLine.GetLineNr() >= aLine.GetDropLines() );
2668  }
2669 
2670  if( bSplit )
2671  {
2672  GetFollow()->SetOffset( aLine.GetEnd() );
2673  aLine.TruncLines( true );
2674  if( pPara->IsFollowField() )
2675  GetFollow()->SetFieldFollow( true );
2676  }
2677  }
2678  if ( bNotify )
2679  {
2680  InvalidateSize_();
2681  InvalidatePage();
2682  }
2683 }
2684 
2685 static bool lcl_ErgoVadis(SwTextFrame* pFrame, TextFrameIndex & rPos, const PrepareHint ePrep)
2686 {
2687  const SwFootnoteInfo &rFootnoteInfo = pFrame->GetDoc().GetFootnoteInfo();
2688  if( ePrep == PrepareHint::ErgoSum )
2689  {
2690  if( rFootnoteInfo.m_aErgoSum.isEmpty() )
2691  return false;
2692  rPos = pFrame->GetOffset();
2693  }
2694  else
2695  {
2696  if( rFootnoteInfo.m_aQuoVadis.isEmpty() )
2697  return false;
2698  if( pFrame->HasFollow() )
2699  rPos = pFrame->GetFollow()->GetOffset();
2700  else
2701  rPos = TextFrameIndex(pFrame->GetText().getLength());
2702  if( rPos )
2703  --rPos; // our last character
2704  }
2705  return true;
2706 }
2707 
2708 // Silence over-eager warning emitted at least by GCC 5.3.1
2709 #if defined __GNUC__ && !defined __clang__
2710 # pragma GCC diagnostic push
2711 # pragma GCC diagnostic ignored "-Wstrict-overflow"
2712 #endif
2713 bool SwTextFrame::Prepare( const PrepareHint ePrep, const void* pVoid,
2714  bool bNotify )
2715 {
2716  bool bParaPossiblyInvalid = false;
2717 
2718  SwFrameSwapper aSwapper( this, false );
2719 
2720  if ( IsEmpty() )
2721  {
2722  switch ( ePrep )
2723  {
2725  SetInvalidVert( true ); // Test
2726  [[fallthrough]];
2728  case PrepareHint::Widows:
2729  case PrepareHint::FootnoteInvalidationGone : return bParaPossiblyInvalid;
2730 
2732  {
2733  // We also need an InvalidateSize for Areas (with and without columns),
2734  // so that we format and bUndersized is set (if needed)
2735  if( IsInFly() || IsInSct() )
2736  {
2737  SwTwips nTmpBottom = GetUpper()->getFrameArea().Top() +
2739  if( nTmpBottom < getFrameArea().Bottom() )
2740  break;
2741  }
2742  // Are there any free-flying frames on this page?
2743  SwTextFly aTextFly( this );
2744  if( aTextFly.IsOn() )
2745  {
2746  // Does any free-flying frame overlap?
2747  if ( aTextFly.Relax() || IsUndersized() )
2748  break;
2749  }
2751  break;
2752 
2753  SwTextGridItem const*const pGrid(GetGridItem(FindPageFrame()));
2754  if (pGrid && GetTextNodeForParaProps()->GetSwAttrSet().GetParaGrid().GetValue())
2755  break;
2756 
2757  // i#28701 - consider anchored objects
2758  if ( GetDrawObjs() )
2759  break;
2760 
2761  return bParaPossiblyInvalid;
2762  }
2763  default:
2764  break;
2765  }
2766  }
2767 
2768  if( !HasPara() && PrepareHint::MustFit != ePrep )
2769  {
2770  SetInvalidVert( true ); // Test
2771  OSL_ENSURE( !IsLocked(), "SwTextFrame::Prepare: three of a perfect pair" );
2772  if ( bNotify )
2773  InvalidateSize();
2774  else
2775  InvalidateSize_();
2776  return bParaPossiblyInvalid;
2777  }
2778 
2779  // Get object from cache while locking
2780  SwTextLineAccess aAccess( this );
2781  SwParaPortion *pPara = aAccess.GetPara();
2782 
2783  switch( ePrep )
2784  {
2786  {
2788  aFrm.Height(0);
2789  }
2790 
2791  {
2793  aPrt.Height(0);
2794  }
2795 
2796  InvalidatePrt_();
2797  InvalidateSize_();
2798  [[fallthrough]];
2800  pPara->SetPrepAdjust();
2801  if( IsFootnoteNumFrame() != pPara->IsFootnoteNum() ||
2802  IsUndersized() )
2803  {
2805  if( GetOffset() && !IsFollow() )
2807  }
2808  break;
2809  case PrepareHint::MustFit :
2810  pPara->SetPrepMustFit(true);
2811  [[fallthrough]];
2813  pPara->SetPrepAdjust();
2814  break;
2815  case PrepareHint::Widows :
2816  // MustFit is stronger than anything else
2817  if( pPara->IsPrepMustFit() )
2818  return bParaPossiblyInvalid;
2819  // see comment in WidowsAndOrphans::FindOrphans and CalcPreps()
2820  PrepWidows( *static_cast<const sal_uInt16 *>(pVoid), bNotify );
2821  break;
2822 
2824  {
2825  SwTextFootnote const *pFootnote = static_cast<SwTextFootnote const *>(pVoid);
2826  if( IsInFootnote() )
2827  {
2828  // Am I the first TextFrame of a footnote?
2829  if( !GetPrev() )
2830  // So we're a TextFrame of the footnote, which has
2831  // to display the footnote number or the ErgoSum text
2833 
2834  if( !GetNext() )
2835  {
2836  // We're the last Footnote; we need to update the
2837  // QuoVadis texts now
2838  const SwFootnoteInfo &rFootnoteInfo = GetDoc().GetFootnoteInfo();
2839  if( !pPara->UpdateQuoVadis( rFootnoteInfo.m_aQuoVadis ) )
2840  {
2841  TextFrameIndex nPos = pPara->GetParLen();
2842  if( nPos )
2843  --nPos;
2845  }
2846  }
2847  }
2848  else
2849  {
2850  // We are the TextFrame _with_ the footnote
2851  TextFrameIndex const nPos = MapModelToView(
2852  &pFootnote->GetTextNode(), pFootnote->GetStart());
2854  }
2855  break;
2856  }
2858  {
2859  // Test
2860  {
2861  SetInvalidVert( false );
2862  bool bOld = IsVertical();
2863  SetInvalidVert( true );
2864  if( bOld != IsVertical() )
2866  }
2867 
2868  if( HasFollow() )
2869  {
2870  TextFrameIndex nNxtOfst = GetFollow()->GetOffset();
2871  if( nNxtOfst )
2872  --nNxtOfst;
2873  InvalidateRange(SwCharRange( nNxtOfst, TextFrameIndex(1)), 1);
2874  }
2875  if( IsInFootnote() )
2876  {
2877  TextFrameIndex nPos;
2878  if( lcl_ErgoVadis( this, nPos, PrepareHint::QuoVadis ) )
2880  if( lcl_ErgoVadis( this, nPos, PrepareHint::ErgoSum ) )
2882  }
2883  // If we have a page number field, we must invalidate those spots
2884  SwTextNode const* pNode(nullptr);
2885  sw::MergedAttrIter iter(*this);
2886  TextFrameIndex const nEnd = GetFollow()
2888  for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
2889  {
2890  TextFrameIndex const nStart(MapModelToView(pNode, pHt->GetStart()));
2891  if (nStart >= GetOffset())
2892  {
2893  if (nStart >= nEnd)
2894  break;
2895 
2896  // If we're flowing back and own a Footnote, the Footnote also flows
2897  // with us. So that it doesn't obstruct us, we send ourselves
2898  // an ADJUST_FRM.
2899  // pVoid != 0 means MoveBwd()
2900  const sal_uInt16 nWhich = pHt->Which();
2901  if (RES_TXTATR_FIELD == nWhich ||
2902  (HasFootnote() && pVoid && RES_TXTATR_FTN == nWhich))
2903  InvalidateRange(SwCharRange(nStart, TextFrameIndex(1)), 1);
2904  }
2905  }
2906  // A new boss, a new chance for growing
2907  if( IsUndersized() )
2908  {
2909  InvalidateSize_();
2911  }
2912  break;
2913  }
2914 
2916  {
2917  if ( isFramePrintAreaValid() )
2918  {
2919  SwTextGridItem const*const pGrid(GetGridItem(FindPageFrame()));
2920  if (pGrid && GetTextNodeForParaProps()->GetSwAttrSet().GetParaGrid().GetValue())
2921  InvalidatePrt();
2922  }
2923 
2924  // If we don't overlap with anybody:
2925  // did any free-flying frame overlapped _before_ the position change?
2926  bool bFormat = pPara->HasFly();
2927  if( !bFormat )
2928  {
2929  if( IsInFly() )
2930  {
2931  SwTwips nTmpBottom = GetUpper()->getFrameArea().Top() +
2933  if( nTmpBottom < getFrameArea().Bottom() )
2934  bFormat = true;
2935  }
2936  if( !bFormat )
2937  {
2938  if ( GetDrawObjs() )
2939  {
2940  const size_t nCnt = GetDrawObjs()->size();
2941  for ( size_t i = 0; i < nCnt; ++i )
2942  {
2943  SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
2944  // i#28701 - consider all
2945  // to-character anchored objects
2946  if ( pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId()
2947  == RndStdIds::FLY_AT_CHAR )
2948  {
2949  bFormat = true;
2950  break;
2951  }
2952  }
2953  }
2954  if( !bFormat )
2955  {
2956  // Are there any free-flying frames on this page?
2957  SwTextFly aTextFly( this );
2958  if( aTextFly.IsOn() )
2959  {
2960  // Does any free-flying frame overlap?
2961  bFormat = aTextFly.Relax() || IsUndersized();
2962  }
2963  }
2964  }
2965  }
2966 
2967  if( bFormat )
2968  {
2969  if( !IsLocked() )
2970  {
2971  if( pPara->GetRepaint().HasArea() )
2972  SetCompletePaint();
2973  Init();
2974  pPara = nullptr;
2975  InvalidateSize_();
2976  }
2977  }
2978  else
2979  {
2980  if (GetTextNodeForParaProps()->GetSwAttrSet().GetRegister().GetValue())
2981  bParaPossiblyInvalid = Prepare( PrepareHint::Register, nullptr, bNotify );
2982  // The Frames need to be readjusted, which caused by changes
2983  // in position
2984  else if( HasFootnote() )
2985  {
2986  bParaPossiblyInvalid = Prepare( PrepareHint::AdjustSizeWithoutFormatting, nullptr, bNotify );
2987  InvalidateSize_();
2988  }
2989  else
2990  return bParaPossiblyInvalid; // So that there's no SetPrep()
2991 
2992  if (bParaPossiblyInvalid)
2993  {
2994  // It's possible that pPara was deleted above; retrieve it again
2995  pPara = aAccess.GetPara();
2996  }
2997 
2998  }
2999  break;
3000  }
3001  case PrepareHint::Register:
3002  if (GetTextNodeForParaProps()->GetSwAttrSet().GetRegister().GetValue())
3003  {
3004  pPara->SetPrepAdjust();
3005  CalcLineSpace();
3006 
3007  // It's possible that pPara was deleted above; retrieve it again
3008  bParaPossiblyInvalid = true;
3009  pPara = aAccess.GetPara();
3010 
3011  InvalidateSize();
3012  InvalidatePrt_();
3013  SwFrame* pNxt = GetIndNext();
3014  if ( nullptr != pNxt )
3015  {
3016  pNxt->InvalidatePrt_();
3017  if ( pNxt->IsLayoutFrame() )
3018  pNxt->InvalidatePage();
3019  }
3020  SetCompletePaint();
3021  }
3022  break;
3024  {
3025  // If a Follow is calling us, because a footnote is being deleted, our last
3026  // line has to be formatted, so that the first line of the Follow can flow up.
3027  // Which had flowed to the next page to be together with the footnote (this is
3028  // especially true for areas with columns)
3029  OSL_ENSURE( GetFollow(), "PrepareHint::FootnoteInvalidationGone may only be called by Follow" );
3030  TextFrameIndex nPos = GetFollow()->GetOffset();
3031  if( IsFollow() && GetOffset() == nPos ) // If we don't have a mass of text, we call our
3032  FindMaster()->Prepare( PrepareHint::FootnoteInvalidationGone ); // Master's Prepare
3033  if( nPos )
3034  --nPos; // The char preceding our Follow
3036  return bParaPossiblyInvalid;
3037  }
3038  case PrepareHint::ErgoSum:
3039  case PrepareHint::QuoVadis:
3040  {
3041  TextFrameIndex nPos;
3042  if( lcl_ErgoVadis( this, nPos, ePrep ) )
3044  }
3045  break;
3047  {
3048  if( pVoid )
3049  {
3050  TextFrameIndex const nWhere = CalcFlyPos( static_cast<SwFrameFormat const *>(pVoid) );
3051  OSL_ENSURE( TextFrameIndex(COMPLETE_STRING) != nWhere, "Prepare: Why me?" );
3053  return bParaPossiblyInvalid;
3054  }
3055  [[fallthrough]]; // else: continue with default case block
3056  }
3057  case PrepareHint::Clear:
3058  default:
3059  {
3060  if( IsLocked() )
3061  {
3062  if( PrepareHint::FlyFrameArrive == ePrep || PrepareHint::FlyFrameLeave == ePrep )
3063  {
3064  TextFrameIndex const nLen = (GetFollow()
3065  ? GetFollow()->GetOffset()
3067  - GetOffset();
3068  InvalidateRange( SwCharRange( GetOffset(), nLen ) );
3069  }
3070  }
3071  else
3072  {
3073  if( pPara->GetRepaint().HasArea() )
3074  SetCompletePaint();
3075  Init();
3076  pPara = nullptr;
3077  if( GetOffset() && !IsFollow() )
3078  SetOffset_( TextFrameIndex(0) );
3079  if ( bNotify )
3080  InvalidateSize();
3081  else
3082  InvalidateSize_();
3083  }
3084  return bParaPossiblyInvalid; // no SetPrep() happened
3085  }
3086  }
3087  if( pPara )
3088  {
3089  pPara->SetPrep();
3090  }
3091 
3092  return bParaPossiblyInvalid;
3093 }
3094 #if defined __GNUC__ && !defined __clang__
3095 # pragma GCC diagnostic pop
3096 #endif
3097 
3107 {
3111 public:
3112  SwTestFormat( SwTextFrame* pTextFrame, const SwFrame* pPrv, SwTwips nMaxHeight );
3113  ~SwTestFormat();
3114 };
3115 
3116 SwTestFormat::SwTestFormat( SwTextFrame* pTextFrame, const SwFrame* pPre, SwTwips nMaxHeight )
3117  : pFrame( pTextFrame )
3118 {
3121 
3122  SwRectFnSet aRectFnSet(pFrame);
3123  SwTwips nLower = aRectFnSet.GetBottomMargin(*pFrame);
3124 
3125  {
3126  // indeed, here the GetUpper()->getFramePrintArea() gets copied and manipulated
3129  aFrm += pFrame->GetUpper()->getFrameArea().Pos();
3130  aRectFnSet.SetHeight( aFrm, nMaxHeight );
3131 
3132  if( pFrame->GetPrev() )
3133  {
3134  aRectFnSet.SetPosY(
3135  aFrm,
3136  aRectFnSet.GetBottom(pFrame->GetPrev()->getFrameArea()) - ( aRectFnSet.IsVert() ? nMaxHeight + 1 : 0 ) );
3137  }
3138  }
3139 
3141  const SwBorderAttrs &rAttrs = *aAccess.Get();
3142 
3143  {
3145  aRectFnSet.SetPosX(aPrt, rAttrs.CalcLeft( pFrame ) );
3146  }
3147 
3148  if( pPre )
3149  {
3150  SwTwips nUpper = pFrame->CalcUpperSpace( &rAttrs, pPre );
3152  aRectFnSet.SetPosY(aPrt, nUpper );
3153  }
3154 
3155  {
3157  aRectFnSet.SetHeight( aPrt, std::max( tools::Long(0) , aRectFnSet.GetHeight(pFrame->getFrameArea()) - aRectFnSet.GetTop(aPrt) - nLower ) );
3158  aRectFnSet.SetWidth( aPrt, aRectFnSet.GetWidth(pFrame->getFrameArea()) - ( rAttrs.CalcLeft( pFrame ) + rAttrs.CalcRight( pFrame ) ) );
3159  }
3160 
3161  pOldPara = pFrame->HasPara() ? pFrame->GetPara() : nullptr;
3162  pFrame->SetPara( new SwParaPortion(), false );
3163  OSL_ENSURE( ! pFrame->IsSwapped(), "A frame is swapped before Format_" );
3164 
3165  if ( pFrame->IsVertical() )
3167 
3168  SwTextFormatInfo aInf( pFrame->getRootFrame()->GetCurrShell()->GetOut(), pFrame, false, true, true );
3169  SwTextFormatter aLine( pFrame, &aInf );
3170 
3171  pFrame->Format_( aLine, aInf );
3172 
3173  if ( pFrame->IsVertical() )
3175 
3176  OSL_ENSURE( ! pFrame->IsSwapped(), "A frame is swapped after Format_" );
3177 }
3178 
3180 {
3181  {
3183  aFrm.setSwRect(aOldFrame);
3184  }
3185 
3186  {
3188  aPrt.setSwRect(aOldPrt);
3189  }
3190 
3191  pFrame->SetPara( pOldPara );
3192 }
3193 
3194 bool SwTextFrame::TestFormat( const SwFrame* pPrv, SwTwips &rMaxHeight, bool &bSplit )
3195 {
3197 
3198  if( IsLocked() && GetUpper()->getFramePrintArea().Width() <= 0 )
3199  return false;
3200 
3201  SwTestFormat aSave( this, pPrv, rMaxHeight );
3202 
3203  return SwTextFrame::WouldFit( rMaxHeight, bSplit, true );
3204 }
3205 
3218 bool SwTextFrame::WouldFit( SwTwips &rMaxHeight, bool &bSplit, bool bTst )
3219 {
3220  OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
3221  "SwTextFrame::WouldFit with swapped frame" );
3222  SwRectFnSet aRectFnSet(this);
3223 
3224  if( IsLocked() )
3225  return false;
3226 
3227  // it can happen that the IdleCollector removed the cached information
3228  if( !IsEmpty() )
3229  GetFormatted();
3230 
3231  // i#27801 - correction: 'short cut' for empty paragraph
3232  // can *not* be applied, if test format is in progress. The test format doesn't
3233  // adjust the frame and the printing area - see method <SwTextFrame::Format_(..)>,
3234  // which is called in <SwTextFrame::TestFormat(..)>
3235  if ( IsEmpty() && !bTst )
3236  {
3237  bSplit = false;
3238  SwTwips nHeight = aRectFnSet.IsVert() ? getFramePrintArea().SSize().Width() : getFramePrintArea().SSize().Height();
3239  if( rMaxHeight < nHeight )
3240  return false;
3241  else
3242  {
3243  rMaxHeight -= nHeight;
3244  return true;
3245  }
3246  }
3247 
3248  // GetPara can still be 0 in edge cases
3249  // We return true in order to be reformatted on the new Page
3250  OSL_ENSURE( HasPara() || IsHiddenNow(), "WouldFit: GetFormatted() and then !HasPara()" );
3251  if( !HasPara() || ( !aRectFnSet.GetHeight(getFrameArea()) && IsHiddenNow() ) )
3252  return true;
3253 
3254  // Because the Orphan flag only exists for a short moment, we also check
3255  // whether the Framesize is set to very huge by CalcPreps, in order to
3256  // force a MoveFwd
3257  if (IsWidow() || (aRectFnSet.IsVert()
3258  ? (0 == getFrameArea().Left())
3259  : (sw::WIDOW_MAGIC - 20000 < getFrameArea().Bottom())))
3260  {
3261  SetWidow(false);
3262  if ( GetFollow() )
3263  {
3264  // If we've ended up here due to a Widow request by our Follow, we check
3265  // whether there's a Follow with a real height at all.
3266  // Else (e.g. for newly created SctFrames) we ignore the IsWidow() and
3267  // still check if we can find enough room
3268  if (((!aRectFnSet.IsVert() && getFrameArea().Bottom() <= sw::WIDOW_MAGIC - 20000) ||
3269  ( aRectFnSet.IsVert() && 0 < getFrameArea().Left() ) ) &&
3270  ( GetFollow()->IsVertical() ?
3271  !GetFollow()->getFrameArea().Width() :
3272  !GetFollow()->getFrameArea().Height() ) )
3273  {
3274  SwTextFrame* pFoll = GetFollow()->GetFollow();
3275  while( pFoll &&
3276  ( pFoll->IsVertical() ?
3277  !pFoll->getFrameArea().Width() :
3278  !pFoll->getFrameArea().Height() ) )
3279  pFoll = pFoll->GetFollow();
3280  if( pFoll )
3281  return false;
3282  }
3283  else
3284  return false;
3285  }
3286  }
3287 
3288  SwSwapIfNotSwapped swap( this );
3289 
3290  SwTextSizeInfo aInf( this );
3291  SwTextMargin aLine( this, &aInf );
3292 
3293  WidowsAndOrphans aFrameBreak( this, rMaxHeight, bSplit );
3294 
3295  bool bRet = true;
3296 
3297  aLine.Bottom();
3298  // is breaking necessary?
3299  bSplit = !aFrameBreak.IsInside( aLine );
3300  if ( bSplit )
3301  bRet = !aFrameBreak.IsKeepAlways() && aFrameBreak.WouldFit( aLine, rMaxHeight, bTst );
3302  else
3303  {
3304  // we need the total height including the current line
3305  aLine.Top();
3306  do
3307  {
3308  rMaxHeight -= aLine.GetLineHeight();
3309  } while ( aLine.Next() );
3310  }
3311 
3312  return bRet;
3313 }
3314 
3315 sal_uInt16 SwTextFrame::GetParHeight() const
3316 {
3317  OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
3318  "SwTextFrame::GetParHeight with swapped frame" );
3319 
3320  if( !HasPara() )
3321  { // For non-empty paragraphs this is a special case
3322  // For UnderSized we can simply just ask 1 Twip more
3323  sal_uInt16 nRet = static_cast<sal_uInt16>(getFramePrintArea().SSize().Height());
3324  if( IsUndersized() )
3325  {
3326  if( IsEmpty() || GetText().isEmpty() )
3327  nRet = static_cast<sal_uInt16>(EmptyHeight());
3328  else
3329  ++nRet;
3330  }
3331  return nRet;
3332  }
3333 
3334  // TODO: Refactor and improve code
3335  const SwLineLayout* pLineLayout = GetPara();
3336  sal_uInt16 nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0;
3337 
3338  // Is this paragraph scrolled? Our height until now is at least
3339  // one line height too low then
3340  if( GetOffset() && !IsFollow() )
3341  nHeight *= 2;
3342 
3343  while ( pLineLayout && pLineLayout->GetNext() )
3344  {
3345  pLineLayout = pLineLayout->GetNext();
3346  nHeight = nHeight + pLineLayout->GetRealHeight();
3347  }
3348 
3349  return nHeight;
3350 }
3351 
3355 SwTextFrame* SwTextFrame::GetFormatted( bool bForceQuickFormat )
3356 {
3357  vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
3358  SwSwapIfSwapped swap( this );
3359 
3360  // In case the SwLineLayout was cleared out of the s_pTextCache, recreate it
3361  // Not for empty paragraphs
3362  if( !HasPara() && !(isFrameAreaDefinitionValid() && IsEmpty()) )
3363  {
3364  // Calc() must be called, because frame position can be wrong
3365  const bool bFormat = isFrameAreaSizeValid();
3366  Calc(pRenderContext); // calls Format() if invalid
3367 
3368  // If the flags were valid (hence bFormat=true), Calc did nothing,
3369  // so Format() must be called manually in order to recreate
3370  // the SwLineLayout that has been deleted from the
3371  // SwTextFrame::s_pTextCache (hence !HasPara() above).
3372  // Optimization with FormatQuick()
3373  if( bFormat && !FormatQuick( bForceQuickFormat ) )
3374  Format(getRootFrame()->GetCurrShell()->GetOut());
3375  }
3376 
3377  return this;
3378 }
3379 
3381 {
3382  // i#31490
3383  // If we are currently locked, we better return with a
3384  // fairly reasonable value:
3385  if ( IsLocked() )
3386  return getFramePrintArea().Width();
3387 
3388  SwParaPortion* pOldPara = GetPara();
3389  SwParaPortion *pDummy = new SwParaPortion();
3390  SetPara( pDummy, false );
3391  const SwPageFrame* pPage = FindPageFrame();
3392 
3393  const Point aOldFramePos = getFrameArea().Pos();
3394  const SwTwips nOldFrameWidth = getFrameArea().Width();
3395  const SwTwips nOldPrtWidth = getFramePrintArea().Width();
3396  const SwTwips nPageWidth = GetUpper()->IsVertical() ?
3397  pPage->getFramePrintArea().Height() :
3398  pPage->getFramePrintArea().Width();
3399 
3400  {
3402  aFrm.Width( nPageWidth );
3403  }
3404 
3405  {
3407  aPrt.Width( nPageWidth );
3408  }
3409 
3410  // i#25422 objects anchored as character in RTL
3411  if ( IsRightToLeft() )
3412  {
3414  aFrm.Pos().AdjustX(nOldFrameWidth - nPageWidth );
3415  }
3416 
3417  TextFrameLockGuard aLock( this );
3418 
3419  SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true, true );
3420  aInf.SetIgnoreFly( true );
3421  SwTextFormatter aLine( this, &aInf );
3422  SwHookOut aHook( aInf );
3423 
3424  // i#54031 - assure minimum of MINLAY twips.
3425  const SwTwips nMax = std::max( SwTwips(MINLAY), aLine.CalcFitToContent_() + 1 );
3426 
3427  {
3429  aFrm.Width( nOldFrameWidth );
3430 
3431  // i#25422 objects anchored as character in RTL
3432  if ( IsRightToLeft() )
3433  {
3434  aFrm.Pos() = aOldFramePos;
3435  }
3436  }
3437 
3438  {
3440  aPrt.Width( nOldPrtWidth );
3441  }
3442 
3443  SetPara( pOldPara );
3444 
3445  return nMax;
3446 }
3447 
3455 {
3456  if ( IsLocked() )
3457  return;
3458 
3459  // reset additional first line offset
3461 
3462  const SwTextNode* pTextNode( GetTextNodeForParaProps() );
3463  // sw_redlinehide: check that pParaPropsNode is the correct one
3464  assert(pTextNode->IsNumbered(getRootFrame()) == pTextNode->IsNumbered(nullptr));
3465  if (!(pTextNode->IsNumbered(getRootFrame()) &&
3466  pTextNode->IsCountedInList() && pTextNode->GetNumRule()))
3467  return;
3468 
3469  int nListLevel = pTextNode->GetActualListLevel();
3470 
3471  if (nListLevel < 0)
3472  nListLevel = 0;
3473 
3474  if (nListLevel >= MAXLEVEL)
3475  nListLevel = MAXLEVEL - 1;
3476 
3477  const SwNumFormat& rNumFormat =
3478  pTextNode->GetNumRule()->Get( static_cast<sal_uInt16>(nListLevel) );
3480  return;
3481 
3482  // keep current paragraph portion and apply dummy paragraph portion
3483  SwParaPortion* pOldPara = GetPara();
3484  SwParaPortion *pDummy = new SwParaPortion();
3485  SetPara( pDummy, false );
3486 
3487  // lock paragraph
3488  TextFrameLockGuard aLock( this );
3489 
3490  // simulate text formatting
3491  SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true, true );
3492  aInf.SetIgnoreFly( true );
3493  SwTextFormatter aLine( this, &aInf );
3494  SwHookOut aHook( aInf );
3495  aLine.CalcFitToContent_();
3496 
3497  // determine additional first line offset
3498  const SwLinePortion* pFirstPortion = aLine.GetCurr()->GetFirstPortion();
3499  if ( pFirstPortion->InNumberGrp() && !pFirstPortion->IsFootnoteNumPortion() )
3500  {
3501  SwTwips nNumberPortionWidth( pFirstPortion->Width() );
3502 
3503  const SwLinePortion* pPortion = pFirstPortion->GetNextPortion();
3504  while ( pPortion &&
3505  pPortion->InNumberGrp() && !pPortion->IsFootnoteNumPortion())
3506  {
3507  nNumberPortionWidth += pPortion->Width();
3508  pPortion = pPortion->GetNextPortion();
3509  }
3510 
3511  if ( ( IsRightToLeft() &&
3512  rNumFormat.GetNumAdjust() == SvxAdjust::Left ) ||
3513  ( !IsRightToLeft() &&
3514  rNumFormat.GetNumAdjust() == SvxAdjust::Right ) )
3515  {
3516  mnAdditionalFirstLineOffset = -nNumberPortionWidth;
3517  }
3518  else if ( rNumFormat.GetNumAdjust() == SvxAdjust::Center )
3519  {
3520  mnAdditionalFirstLineOffset = -(nNumberPortionWidth/2);
3521  }
3522  }
3523 
3524  // restore paragraph portion
3525  SetPara( pOldPara );
3526 }
3527 
3540 void SwTextFrame::CalcHeightOfLastLine( const bool _bUseFont )
3541 {
3542  // i#71281
3543  // Invalidate printing area, if height of last line changes
3544  const SwTwips nOldHeightOfLastLine( mnHeightOfLastLine );
3545 
3546  // determine output device
3547  SwViewShell* pVsh = getRootFrame()->GetCurrShell();
3548  OSL_ENSURE( pVsh, "<SwTextFrame::_GetHeightOfLastLineForPropLineSpacing()> - no SwViewShell" );
3549 
3550  // i#78921
3551  // There could be no <SwViewShell> instance in the case of loading a binary
3552  // StarOffice file format containing an embedded Writer document.
3553  if ( !pVsh )
3554  {
3555  return;
3556  }
3557  OutputDevice* pOut = pVsh->GetOut();
3558  const IDocumentSettingAccess *const pIDSA = &GetDoc().getIDocumentSettingAccess();
3559  if ( !pVsh->GetViewOptions()->getBrowseMode() ||
3560  pVsh->GetViewOptions()->IsPrtFormat() )
3561  {
3563  }
3564  OSL_ENSURE( pOut, "<SwTextFrame::_GetHeightOfLastLineForPropLineSpacing()> - no OutputDevice" );
3565 
3566  if ( !pOut )
3567  {
3568  return;
3569  }
3570 
3571  // determine height of last line
3572  if ( _bUseFont || pIDSA->get(DocumentSettingId::OLD_LINE_SPACING ) )
3573  {
3574  // former determination of last line height for proportional line
3575  // spacing - take height of font set at the paragraph
3576  // FIXME actually... must the font match across all nodes?
3577  SwFont aFont( &GetTextNodeForParaProps()->GetSwAttrSet(), pIDSA );
3578 
3579  // we must ensure that the font is restored correctly on the OutputDevice
3580  // otherwise Last!=Owner could occur
3581  if ( pLastFont )
3582  {
3583  SwFntObj *pOldFont = pLastFont;
3584  pLastFont = nullptr;
3585  aFont.SetFntChg( true );
3586  aFont.ChgPhysFnt( pVsh, *pOut );
3587  mnHeightOfLastLine = aFont.GetHeight( pVsh, *pOut );
3588  assert(pLastFont && "coverity[var_deref_model] - pLastFont should be set in SwSubFont::ChgFnt");
3589  pLastFont->Unlock();
3590  pLastFont = pOldFont;
3591  pLastFont->SetDevFont( pVsh, *pOut );
3592  }
3593  else
3594  {
3595  vcl::Font aOldFont = pOut->GetFont();
3596  aFont.SetFntChg( true );
3597  aFont.ChgPhysFnt( pVsh, *pOut );
3598  mnHeightOfLastLine = aFont.GetHeight( pVsh, *pOut );
3599  assert(pLastFont && "coverity[var_deref_model] - pLastFont should be set in SwSubFont::ChgFnt");
3600  pLastFont->Unlock();
3601  pLastFont = nullptr;
3602  pOut->SetFont( aOldFont );
3603  }
3604  }
3605  else
3606  {
3607  // new determination of last line height - take actually height of last line
3608  // i#89000
3609  // assure same results, if paragraph is undersized
3610  if ( IsUndersized() )
3611  {
3612  mnHeightOfLastLine = 0;
3613  }
3614  else
3615  {
3616  bool bCalcHeightOfLastLine = true;
3617  if ( ( !HasPara() && IsEmpty( ) ) || GetText().isEmpty() )
3618  {
3620  bCalcHeightOfLastLine = false;
3621  }
3622 
3623  if ( bCalcHeightOfLastLine )
3624  {
3625  OSL_ENSURE( HasPara(),
3626  "<SwTextFrame::CalcHeightOfLastLine()> - missing paragraph portions." );
3627  const SwLineLayout* pLineLayout = GetPara();
3628  while ( pLineLayout && pLineLayout->GetNext() )
3629  {
3630  // iteration to last line
3631  pLineLayout = pLineLayout->GetNext();
3632  }
3633  if ( pLineLayout )
3634  {
3635  SwTwips nAscent, nDescent, nDummy1, nDummy2;
3636  // i#47162 - suppress consideration of
3637  // fly content portions and the line portion.
3638  pLineLayout->MaxAscentDescent( nAscent, nDescent,
3639  nDummy1, nDummy2,
3640  nullptr, true );
3641  // i#71281
3642  // Suppress wrong invalidation of printing area, if method is
3643  // called recursive.
3644  // Thus, member <mnHeightOfLastLine> is only set directly, if
3645  // no recursive call is needed.
3646  const SwTwips nNewHeightOfLastLine = nAscent + nDescent;
3647  // i#47162 - if last line only contains
3648  // fly content portions, <mnHeightOfLastLine> is zero.
3649  // In this case determine height of last line by the font
3650  if ( nNewHeightOfLastLine == 0 )
3651  {
3652  CalcHeightOfLastLine( true );
3653  }
3654  else
3655  {
3656  mnHeightOfLastLine = nNewHeightOfLastLine;
3657  }
3658  }
3659  }
3660  }
3661  }
3662  // i#71281
3663  // invalidate printing area, if height of last line changes
3664  if ( mnHeightOfLastLine != nOldHeightOfLastLine )
3665  {
3666  InvalidatePrt();
3667  }
3668 }
3669 
3679 tools::Long SwTextFrame::GetLineSpace( const bool _bNoPropLineSpace ) const
3680 {
3681  tools::Long nRet = 0;
3682 
3684 
3685  switch( rSpace.GetInterLineSpaceRule() )
3686  {
3687  case SvxInterLineSpaceRule::Prop:
3688  {
3689  if ( _bNoPropLineSpace )
3690  {
3691  break;
3692  }
3693 
3694  // i#11860 - adjust spacing implementation for object positioning
3695  // - compatibility to MS Word
3696  nRet = GetHeightOfLastLine();
3697 
3698  tools::Long nTmp = nRet;
3699  nTmp *= rSpace.GetPropLineSpace();
3700  nTmp /= 100;
3701  nTmp -= nRet;
3702  if ( nTmp > 0 )
3703  nRet = nTmp;
3704  else
3705  nRet = 0;
3706  }
3707  break;
3708  case SvxInterLineSpaceRule::Fix:
3709  {
3710  if ( rSpace.GetInterLineSpace() > 0 )
3711  nRet = rSpace.GetInterLineSpace();
3712  }
3713  break;
3714  default:
3715  break;
3716  }
3717  return nRet;
3718 }
3719 
3721 {
3722  if ( !HasPara() )
3723  {
3724  if( IsEmpty() && isFrameAreaDefinitionValid() )
3725  return IsVertical() ? static_cast<sal_uInt16>(getFramePrintArea().Width()) : static_cast<sal_uInt16>(getFramePrintArea().Height());
3726  return USHRT_MAX;
3727  }
3728  const SwParaPortion *pPara = GetPara();
3729  if ( !pPara )
3730  return USHRT_MAX;
3731 
3732  return pPara->Height();
3733 }
3734 
3736 {
3737  sal_uInt16 nRet = 0;
3738  SwTextFrame *pFrame = this;
3739  do
3740  {
3741  pFrame->GetFormatted();
3742  if( !pFrame->HasPara() )
3743  break;
3744  SwTextSizeInfo aInf( pFrame );
3745  SwTextMargin aLine( pFrame, &aInf );
3746  if (TextFrameIndex(COMPLETE_STRING) == nPos)
3747  aLine.Bottom();
3748  else
3749  aLine.CharToLine( nPos );
3750  nRet = nRet + aLine.GetLineNr();
3751  pFrame = pFrame->GetFollow();
3752  } while ( pFrame && pFrame->GetOffset() <= nPos );
3753  return nRet;
3754 }
3755 
3757 {
3758  // not necessary to format here (GetFormatted etc.), because we have to come from there!
3759  sal_uLong nNew = 0;
3760  const SwLineNumberInfo &rInf = GetDoc().GetLineNumberInfo();
3761  if ( !GetText().isEmpty() && HasPara() )
3762  {
3763  SwTextSizeInfo aInf( this );
3764  SwTextMargin aLine( this, &aInf );
3765  if ( rInf.IsCountBlankLines() )
3766  {
3767  aLine.Bottom();
3768  nNew = static_cast<sal_uLong>(aLine.GetLineNr());
3769  }
3770  else
3771  {
3772  do
3773  {
3774  if( aLine.GetCurr()->HasContent() )
3775  ++nNew;
3776  } while ( aLine.NextLine() );
3777  }
3778  }
3779  else if ( rInf.IsCountBlankLines() )
3780  nNew = 1;
3781 
3782  if ( nNew == mnThisLines )
3783  return;
3784 
3786  {
3788  mnThisLines = nNew;
3790  SwFrame *pNxt = GetNextContentFrame();
3791  while( pNxt && pNxt->IsInTab() )
3792  {
3793  pNxt = pNxt->FindTabFrame();
3794  if( nullptr != pNxt )
3795  pNxt = pNxt->FindNextCnt();
3796  }
3797  if( pNxt )
3798  pNxt->InvalidateLineNum();
3799 
3800  // Extend repaint to the bottom.
3801  if ( HasPara() )
3802  {
3803  SwRepaint& rRepaint = GetPara()->GetRepaint();
3804  rRepaint.Bottom( std::max( rRepaint.Bottom(),
3806  }
3807  }
3808  else // Paragraphs which are not counted should not manipulate the AllLines.
3809  mnThisLines = nNew;
3810 }
3811 
3813 {
3814  ValidateLineNum();
3815 
3816  if ( IsInTab() )
3817  return;
3818 
3819  const sal_uLong nOld = GetAllLines();
3821  sal_uLong nNewNum;
3822  const bool bRestart = GetDoc().GetLineNumberInfo().IsRestartEachPage();
3823 
3824  if ( !IsFollow() && rLineNum.GetStartValue() && rLineNum.IsCount() )
3825  nNewNum = rLineNum.GetStartValue() - 1;
3826  // If it is a follow or not has not be considered if it is a restart at each page; the
3827  // restart should also take effect at follows.
3828  else if ( bRestart && FindPageFrame()->FindFirstBodyContent() == this )
3829  {
3830  nNewNum = 0;
3831  }
3832  else
3833  {
3835  while ( pPrv &&
3836  (pPrv->IsInTab() || pPrv->IsInDocBody() != IsInDocBody()) )
3837  pPrv = pPrv->GetPrevContentFrame();
3838 
3839  // i#78254 Restart line numbering at page change
3840  // First body content may be in table!
3841  if ( bRestart && pPrv && pPrv->FindPageFrame() != FindPageFrame() )
3842  pPrv = nullptr;
3843 
3844  nNewNum = pPrv ? static_cast<SwTextFrame*>(pPrv)->GetAllLines() : 0;
3845  }
3846  if ( rLineNum.IsCount() )
3847  nNewNum += GetThisLines();
3848 
3849  if ( nOld == nNewNum )
3850  return;
3851 
3852  mnAllLines = nNewNum;
3854  while ( pNxt &&
3855  (pNxt->IsInTab() || pNxt->IsInDocBody() != IsInDocBody()) )
3856  pNxt = pNxt->GetNextContentFrame();
3857  if ( pNxt )
3858  {
3859  if ( pNxt->GetUpper() != GetUpper() )
3860  pNxt->InvalidateLineNum();
3861  else
3862  pNxt->InvalidateLineNum_();
3863  }
3864 }
3865 
3867 {
3868  const SwParaPortion* pPara = isFrameAreaDefinitionValid() ? GetPara() : nullptr;
3869 
3870  if (pPara)
3871  {
3872  if ( IsFollow() )
3873  rPH.Skip( GetOffset() );
3874 
3875  const SwLineLayout* pLine = pPara;
3876  while ( pLine )
3877  {
3878  const SwLinePortion* pPor = pLine->GetFirstPortion();
3879  while ( pPor )
3880  {
3881  pPor->HandlePortion( rPH );
3882  pPor = pPor->GetNextPortion();
3883  }
3884 
3885  rPH.LineBreak(pLine->Width());
3886  pLine = pLine->GetNext();
3887  }
3888  }
3889 
3890  rPH.Finish();
3891 }
3892 
3894 {
3895  const SwParaPortion* pPara = GetPara();
3896  return pPara ? &pPara->GetScriptInfo() : nullptr;
3897 }
3898 
3902 static SwTwips lcl_CalcFlyBasePos( const SwTextFrame& rFrame, SwRect aFlyRect,
3903  SwTextFly const & rTextFly )
3904 {
3905  SwRectFnSet aRectFnSet(&rFrame);
3906  SwTwips nRet = rFrame.IsRightToLeft() ?
3907  aRectFnSet.GetRight(rFrame.getFrameArea()) :
3908  aRectFnSet.GetLeft(rFrame.getFrameArea());
3909 
3910  do
3911  {
3912  SwRect aRect = rTextFly.GetFrame( aFlyRect );
3913  if ( 0 != aRectFnSet.GetWidth(aRect) )
3914  {
3915  if ( rFrame.IsRightToLeft() )
3916  {
3917  if ( aRectFnSet.GetRight(aRect) -
3918  aRectFnSet.GetRight(aFlyRect) >= 0 )
3919  {
3920  aRectFnSet.SetRight(
3921 aFlyRect, aRectFnSet.GetLeft(aRect) );
3922  nRet = aRectFnSet.GetLeft(aRect);
3923  }
3924  else
3925  break;
3926  }
3927  else
3928  {
3929  if ( aRectFnSet.GetLeft(aFlyRect) -
3930  aRectFnSet.GetLeft(aRect) >= 0 )
3931  {
3932  aRectFnSet.SetLeft(
3933 aFlyRect, aRectFnSet.GetRight(aRect) + 1 );
3934  nRet = aRectFnSet.GetRight(aRect);
3935  }
3936  else
3937  break;
3938  }
3939  }
3940  else
3941  break;
3942  }
3943  while ( aRectFnSet.GetWidth(aFlyRect) > 0 );
3944 
3945  return nRet;
3946 }
3947 
3949 {
3950  OSL_ENSURE( !IsVertical() || !IsSwapped(),
3951  "SwTextFrame::CalcBasePosForFly with swapped frame!" );
3952 
3953  if (!GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::ADD_FLY_OFFSETS))
3954  return;
3955 
3956  SwRectFnSet aRectFnSet(this);
3957 
3958  SwRect aFlyRect( getFrameArea().Pos() + getFramePrintArea().Pos(), getFramePrintArea().SSize() );
3959 
3960  // Get first 'real' line and adjust position and height of line rectangle.
3961  // Correct behaviour if no 'real' line exists
3962  // (empty paragraph with and without a dummy portion)
3963  SwTwips nFlyAnchorVertOfstNoWrap = 0;
3964  {
3965  SwTwips nTop = aRectFnSet.GetTop(aFlyRect);
3966  const SwLineLayout* pLay = GetPara();
3967  SwTwips nLineHeight = 200;
3968  while( pLay && pLay->IsDummy() && pLay->GetNext() )
3969  {
3970  nTop += pLay->Height();
3971  nFlyAnchorVertOfstNoWrap += pLay->Height();
3972  pLay = pLay->GetNext();
3973  }
3974  if ( pLay )
3975  {
3976  nLineHeight = pLay->Height();
3977  }
3978  aRectFnSet.SetTopAndHeight( aFlyRect, nTop, nLineHeight );
3979  }
3980 
3981  SwTextFly aTextFly( this );
3982  aTextFly.SetIgnoreCurrentFrame( true );
3983  aTextFly.SetIgnoreContour( true );
3984  // ignore objects in page header|footer for
3985  // text frames not in page header|footer
3986  aTextFly.SetIgnoreObjsInHeaderFooter( true );
3987  SwTwips nRet1 = lcl_CalcFlyBasePos( *this, aFlyRect, aTextFly );
3988  aTextFly.SetIgnoreCurrentFrame( false );
3989  SwTwips nRet2 = lcl_CalcFlyBasePos( *this, aFlyRect, aTextFly );
3990 
3991  // make values relative to frame start position
3992  SwTwips nLeft = IsRightToLeft() ?
3993  aRectFnSet.GetRight(getFrameArea()) :
3994  aRectFnSet.GetLeft(getFrameArea());
3995 
3996  mnFlyAnchorOfst = nRet1 - nLeft;
3997  mnFlyAnchorOfstNoWrap = nRet2 - nLeft;
3998 
3999  if (!GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS))
4000  return;
4001 
4002  if (mnFlyAnchorOfstNoWrap > 0)
4003  mnFlyAnchorVertOfstNoWrap = nFlyAnchorVertOfstNoWrap;
4004 }
4005 
4006 SwTwips SwTextFrame::GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
4007 {
4008  return bIgnoreFlysAnchoredAtThisFrame ? 0 : mnFlyAnchorVertOfstNoWrap;
4009 }
4010 
4015 {
4017  for( const SwTextFrame *pFrame = aIter.First(); pFrame; pFrame = aIter.Next() )
4018  {
4019  SwRect aRec( pFrame->GetPaintArea() );
4020  const SwRootFrame *pRootFrame = pFrame->getRootFrame();
4021  SwViewShell *pCurShell = pRootFrame ? pRootFrame->GetCurrShell() : nullptr;
4022  if( pCurShell )
4023  pCurShell->InvalidateWindows( aRec );
4024  }
4025 }
4026 
4027 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void HideHidden()
Removes Textfrm's attachments, when it's hidden.
Definition: txtfrm.cxx:1435
void SetWordCountDirty(bool bNew) const
Definition: txtedt.cxx:2239
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:338
void SetHasRotatedPortions(bool bHasRotatedPortions)
Definition: txtftn.cxx:90
bool GetValue() const
sal_uInt16 GetParHeight() const
Returns the sum of line height in pLine.
Definition: txtfrm.cxx:3315
SwFntObj * pLastFont
Definition: fntcache.cxx:66
void CalcAdditionalFirstLineOffset()
Simulate format for a list item paragraph, whose list level attributes are in LABEL_ALIGNMENT mode...
Definition: txtfrm.cxx:3454
void Init()
This is public, as it needs to be called by some methods in order to save the Prepare USE WITH CAUTIO...
Definition: txtfrm.cxx:748
bool HasContent() const
Definition: porlay.hxx:133
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:313
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:157
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
void SwitchVerticalToHorizontal(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from vertical to horizontal layout...
Definition: txtfrm.cxx:578
LanguageType nOldLanguageType
Definition: txtfrm.hxx:941
tools::Long GetRight(const SwRect &rRect) const
Definition: frame.hxx:1376
bool IsFootnoteNum() const
Definition: porlay.hxx:316
SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
Definition: txtfrm.cxx:4006
sal_uLong GetIndex() const
Definition: node.hxx:291
void Right(const tools::Long nRight)
Definition: swrect.hxx:200
sal_Int32 nIndex
void Add(SwClient *pDepend)
Definition: calbck.cxx:171
bool IsFollow() const
Definition: flowfrm.hxx:166
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:563
sal_uInt16 GetPropLineSpace() const
void SetIgnoreCurrentFrame(bool bNew)
Definition: txtfly.hxx:361
SwTwips EmptyHeight() const
Definition: porrst.cxx:261
sal_uInt16 GetLineNr() const
Definition: itrtxt.hxx:87
Marks a position in the document model.
Definition: pam.hxx:35
SwTextNode const & GetAttrMerged(SfxItemSet &rFormatSet, SwTextNode const &rNode, SwRootFrame const *pLayout)
Definition: txtfrm.cxx:367
void SetPrepAdjust()
Definition: porlay.hxx:308
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
const SwField * GetField() const
Definition: fmtfld.hxx:110
static SwTwips lcl_CalcFlyBasePos(const SwTextFrame &rFrame, SwRect aFlyRect, SwTextFly const &rTextFly)
Helper function for SwTextFrame::CalcBasePosForFly()
Definition: txtfrm.cxx:3902
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:823
bool IsInDocBody() const
Definition: frame.hxx:939
const SwPageFrame * GetOrigPage() const
Definition: hints.hxx:307
bool IsInFly() const
Definition: frame.hxx:957
sal_Int32 nSourceStart
Definition: hints.hxx:109
void SetPosY(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1397
#define LANGUAGE_ARABIC_SAUDI_ARABIA
SwRect aOldPrt
Definition: txtfrm.cxx:3110
bool IsInSct() const
Definition: frame.hxx:963
LanguageType GetLangOfChar(TextFrameIndex nIndex, sal_uInt16 nScript, bool bNoChar=false) const
Definition: txtfrm.cxx:1335
const SwTwips WIDOW_MAGIC
Definition: txtfrm.hxx:1024
SwDigitModeModifier(const OutputDevice &rOutp, LanguageType eCurLang)
Definition: txtfrm.cxx:722
const OutputDevice & rOut
Definition: txtfrm.hxx:940
const SwLineNumberInfo & GetLineNumberInfo() const
Definition: lineinfo.cxx:49
#define LANGUAGE_ENGLISH_US
SwLineLayout * GetNext()
Definition: porlay.hxx:159
const OUString & GetText() const
Definition: ndtxt.hxx:210
bool IsSwapped() const
Definition: txtfrm.hxx:532
bool IsWrongDirty() const
Definition: txtedt.cxx:2265
const SwLineLayout * NextLine()
Definition: itrtxt.cxx:124
bool InNumberGrp() const
Definition: porlin.hxx:101
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:218
std::string GetValue
bool HasPara() const
Definition: txtfrm.hxx:816
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:238
void CalcBaseOfstForFly()
Definition: txtfrm.cxx:3948
void InvalidateAccessibleParaAttrs(const SwTextFrame &rTextFrame)
invalidate attributes for paragraphs and paragraph's characters
Definition: viewsh.cxx:2508
void Move(sal_Int32 nPos, sal_Int32 nDiff)
Change all values after the given position.
Definition: wrong.cxx:266
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
SwNodeIndex nNode
Definition: pam.hxx:37
GPOS_NONE
virtual SwGrammarMarkUp * getGrammarCheck(SwTextNode &rTextNode, bool bCreate)=0
getGrammarCheck checks if the given text node is blocked by the current cursor if not...
void SetCompletePaint() const
Definition: frame.hxx:990
SwParaPortion * GetPara()
Definition: txtcache.cxx:50
bool IsInFootnote() const
Definition: frame.hxx:945
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout...
Definition: txtfrm.cxx:471
static void repaintTextFrames(const SwTextNode &rNode)
Repaint all text frames of the given text node.
Definition: txtfrm.cxx:4014
void SetNeedGrammarCheck(bool bVal)
Definition: rootfrm.hxx:264
void setSwRect(const SwRect &rNew)
Definition: frame.hxx:197
void SetDerivedR2L(bool bNew)
Definition: frame.hxx:630
SwTwips CalcFitToContent()
Simulates a formatting as if there were not right margin or Flys or other obstacles and returns the w...
Definition: txtfrm.cxx:3380
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:276
sal_uIntPtr sal_uLong
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true) override
SwContentFrame: the shortcut for the Frames If the void* casts wrongly, it's its own fault! The void*...
Definition: txtfrm.cxx:2713
virtual bool GetInfo(SfxPoolItem &) const override
Definition: txtfrm.cxx:2607
void InvalidateLineNum_()
Definition: frame.hxx:793
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
#define MINLAY
Definition: swtypes.hxx:66
void SetInvalidityA(const TextFrameIndex nPos)
Definition: scriptinfo.hxx:113
SwRect aOldFrame
Definition: txtfrm.cxx:3110
SwTextFrame(SwTextNode *const, SwFrame *, sw::FrameMode eMode)
Definition: txtfrm.cxx:762
static SwCache & GetCache()
Definition: frame.hxx:520
SwTextNode const * GetTextNodeForFirstText() const
Definition: txtfrm.cxx:1309
constexpr TypedWhichId< SwRegisterItem > RES_PARATR_REGISTER(71)
tools::Long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2243
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:447
The purpose of this class is to be the universal interface between formatting/text output and the pos...
Definition: txtfly.hxx:119
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1212
void InvalidateSize_()
Definition: frame.hxx:769
Definition: doc.hxx:187
constexpr sal_uInt16 RES_FRMATR_END(133)
TElementType * Next()
Definition: calbck.hxx:333
bool HasFollow() const
Definition: flowfrm.hxx:165
SwParaPortion * GetPara()
Definition: txtcache.cxx:90
SwTextAttr const * PrevAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:222
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
void SetIgnoreFly(const bool bNew)
Definition: inftxt.hxx:570
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
SwNode & GetNode() const
Definition: ndindex.hxx:119
void CharToLine(TextFrameIndex)
Definition: itrtxt.cxx:193
void Format_(vcl::RenderContext *pRenderContext, SwParaPortion *pPara)
Definition: frmform.cxx:1690
bool IsVert() const
Definition: frame.hxx:1363
sal_Int32 nStart
Definition: hints.hxx:129
const SwLineLayout * Next()
Definition: itrtxt.cxx:107
bool IsSmartTagDirty() const
Definition: txtedt.cxx:2291
void HideAndShowObjects()
Hides respectively shows objects, which are anchored at paragraph, at/as a character of the paragraph...
Definition: txtfrm.cxx:1541
void Pos(const Point &rNew)
Definition: swrect.hxx:169
constexpr TypedWhichId< SwInsText > RES_INS_TXT(164)
bool WouldFit(SwTextMargin &rLine, SwTwips &rMaxHeight, bool bTest)
Definition: widorp.cxx:486
Dialog to specify the properties of date form field.
SwFrame * FindNext()
Definition: frame.hxx:1137
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
void MaxAscentDescent(SwTwips &_orAscent, SwTwips &_orDescent, SwTwips &_orObjAscent, SwTwips &_orObjDescent, const SwLinePortion *_pDontConsiderPortion=nullptr, const bool _bNoFlyCntPorAndLinePor=false) const
determine ascent and descent for positioning of as-character anchored object
Definition: porlay.cxx:630
bool IsKeepAlways() const
Definition: widorp.hxx:38
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1285
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1377
bool IsShowHiddenPara() const
Definition: viewopt.hxx:397
bool IsCountBlankLines() const
Definition: lineinfo.hxx:83
void SetSmartTags(SwWrongList *pNew, bool bDelete=true)
Definition: txtedt.cxx:2214
SwTwips Y() const
Definition: itrtxt.hxx:90
void SetGrammarCheckDirty(bool bNew) const
Definition: txtedt.cxx:2270
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(59)
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwTextNode * pNode
Definition: txtfrm.hxx:85
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Definition: porlay.hxx:247
sal_uInt16 GetOrphansLines() const
Definition: widorp.hxx:61
void SetPara(SwParaPortion *pNew, bool bDelete=true)
Definition: txtcache.cxx:129
const SwTwips nDocPos
Definition: hints.hxx:228
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4106
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
void ValidateLineNum()
Definition: frame.hxx:758
bool TestFormat(const SwFrame *pPrv, SwTwips &nMaxHeight, bool &bSplit)
The WouldFit equivalent for temporarily rewired TextFrames nMaxHeight returns the required size here ...
Definition: txtfrm.cxx:3194
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:170
TextFrameIndex & Start()
Definition: porlay.hxx:45
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: wsfrm.cxx:2335
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
SwTextAttr const * NextAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:85
void CalcFootnoteFlag(TextFrameIndex nStop=TextFrameIndex(COMPLETE_STRING))
Does the Frame have a local footnote (in this Frame or Follow)?
Definition: txtftn.cxx:96
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:192
bool IsVertLRBT() const
Definition: frame.hxx:979
virtual void Finish()=0
end of paragraph.
bool FormatQuick(bool bForceQuickFormat)
Definition: frmform.cxx:1978
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:188
bool IsHiddenNow() const
Hidden.
Definition: txtfrm.cxx:1352
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1373
void CalcLineSpace()
Definition: txtfrm.cxx:1719
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
#define CH_TXTATR_BREAKWORD
Definition: hintids.hxx:169
sal_Int32 nDestStart
Definition: hints.hxx:108
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:356
const SwRegisterItem & GetRegister(bool=true) const
Definition: paratr.hxx:199
bool IsFieldName() const
Definition: viewopt.hxx:269
SwTwips CalcUpperSpace(const SwBorderAttrs *pAttrs=nullptr, const SwFrame *pPr=nullptr, const bool _bConsiderGrid=true) const
method to determine the upper space hold by the frame
Definition: flowfrm.cxx:1446
IGrammarContact * getGrammarContact(const SwTextNode &rTextNode)
getGrammarContact() delivers the grammar contact of the document (for a given textnode) ...
Definition: docnew.cxx:804
sal_uInt16 sal_Unicode
void InvalidateNextPrtArea()
method to invalidate printing area of next frame #i11859#
Definition: findfrm.cxx:1280
wrapper class for the positioning of Writer fly frames and drawing objects
std::vector< std::pair< SwTextNode const *, SwTextAttr const * > > m_Hints
Definition: txtfrm.hxx:1006
bool IsRestartEachPage() const
Definition: lineinfo.hxx:89
sal_uLong mnAllLines
Definition: txtfrm.hxx:174
sal_Int32 getEnd() const
Definition: hints.hxx:192
const SwScriptInfo * GetScriptInfo() const
Returns the script info stored at the paraportion.
Definition: txtfrm.cxx:3893
SvxGraphicPosition GetGraphicPos() const
void RemoveFromListRLHidden()
Definition: ndtxt.cxx:4336
void SortIfNeedBe() const
Trigger the sorting if necessary.
Definition: ndhints.hxx:176
const SwPageFrame * GetPage() const
Definition: hints.hxx:306
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
new delete redline is created
Definition: hints.hxx:116
constexpr TypedWhichId< SwDocPosUpdate > RES_DOCPOS_UPDATE(169)
SwIndex nContent
Definition: pam.hxx:38
const SwRect & getFrameArea() const
Definition: frame.hxx:178
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:128
bool getBrowseMode() const
Definition: viewopt.hxx:472
size_t pos
const vcl::Font & GetFont() const
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
sal_uLong GetThisLines() const
Definition: txtfrm.hxx:665
bool IsInTab() const
Definition: frame.hxx:951
std::unique_ptr< sw::MergedPara > CheckParaRedlineMerge(SwTextFrame &rFrame, SwTextNode &rTextNode, FrameMode eMode)
Definition: redlnitr.cxx:205
void SetInfo(const SwPageFrame *pPg, const SwFrame *pF)
Definition: hints.hxx:309
sal_Int32 nEnd
Definition: txtfrm.hxx:87
static bool IsFuzzing()
SwTestFormat(SwTextFrame *pTextFrame, const SwFrame *pPrv, SwTwips nMaxHeight)
Definition: txtfrm.cxx:3116
int nCount
bool IsTextFrame() const
Definition: frame.hxx:1230
sal_uInt16 GetCacheIdx() const
Definition: txtfrm.hxx:610
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
void SetFntChg(const bool bNew)
Definition: swfont.hxx:207
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
TextFrameIndex UpdateMergedParaForDelete(MergedPara &rMerged, bool isRealDelete, SwTextNode const &rNode, sal_Int32 nIndex, sal_Int32 nLen)
Definition: txtfrm.cxx:1024
oslFileHandle & pOut
void InitScriptInfo(const SwTextNode &rNode, sw::MergedPara const *pMerged, bool bRTL)
Definition: porlay.cxx:936
bool HasFly() const
Definition: porlay.hxx:299
void Width(tools::Long nNew)
Definition: swrect.hxx:187
const SwTextFrame * pFrame
Definition: txtfrm.hxx:920
const OutputDevice & m_rOut
Definition: txtfrm.hxx:929
virtual bool SetFieldsDirty(bool b, const SwNode *pChk, sal_uLong nLen)=0
bool IsInRange(const sal_uInt16 *pRange, const sal_uInt16 nId)
check if ID is in range of attribute set IDs
Definition: swatrset.cxx:473
sal_uLong mnThisLines
Definition: txtfrm.hxx:175
virtual ~SwTextFrame() override
Definition: txtfrm.cxx:884
virtual void LineBreak(sal_Int32 nWidth)=0
line break.
sal_uLong GetStartValue() const
Definition: fmtline.hxx:57
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:953
SwContentFrame * GetPrevContentFrame() const
Definition: cntfrm.hxx:106
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
void ChgPhysFnt(SwViewShell const *pSh, OutputDevice &rOut)
Definition: swfont.cxx:942
tools::Long GetLeft(const SwRect &rRect) const
Definition: frame.hxx:1375
void SetWrongDirty(WrongState eNew) const
Definition: txtedt.cxx:2252
size_type size() const
sal_Int32 getStart() const
Definition: hints.hxx:187
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:209
static void lcl_ModifyOfst(SwTextFrame &rFrame, TextFrameIndex const nPos, TextFrameIndex const nLen, TextFrameIndex(*op)(TextFrameIndex const &, TextFrameIndex const &))
Definition: txtfrm.cxx:1862
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:852
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:435
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
FrameMode
Definition: txtfrm.hxx:102
void SetIgnoreObjsInHeaderFooter(const bool bNew)
Definition: txtfly.hxx:371
std::vector< Extent > extents
Definition: txtfrm.hxx:956
tools::Long & GetDelta()
Definition: porlay.hxx:286
bool IsFollowField() const
Definition: porlay.hxx:311
static bool isA11yRelevantAttribute(sal_uInt16 nWhich)
Related: fdo#56031 filter out attribute changes that don't matter for humans/a11y to stop flooding th...
Definition: txtfrm.cxx:1943
void MoveGrammar(sal_Int32 nPos, sal_Int32 nDiff)
void PrepWidows(const sal_uInt16 nNeed, bool bNotify)
Definition: txtfrm.cxx:2633
exports com.sun.star. text
const Color & GetColor() const
bool IsEmpty() const
Definition: txtfrm.hxx:518
void ResetPreps()
Definition: txtfrm.cxx:1343
Describes a part of a single text node, which will be part of a text frame, even when redlines are hi...
Definition: txtfrm.hxx:83
void swap(cow_wrapper< T, P > &a, cow_wrapper< T, P > &b)
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:454
void SetInvalidVert(bool bNew)
Definition: frame.hxx:628
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:284
bool IsInDtor() const
Definition: frame.hxx:888
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1295
void InvalidateAutoCompleteWords() const
Definition: pagefrm.hxx:377
SwTwips mnFlyAnchorOfst
Definition: txtfrm.hxx:179
delete redline is removed
Definition: hints.hxx:126
void SetIgnoreContour(bool bNew)
Definition: txtfly.hxx:366
SwTextFootnote * SeekEntry(const SwNodeIndex &rIdx, size_t *pPos=nullptr) const
Definition: ftnidx.cxx:409
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
bool IsFootnoteNumPortion() const
Definition: porlin.hxx:120
virtual void Height(const sal_uInt16 nNew, const bool bText=true) override
Definition: porlay.cxx:200
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:58
bool IsWidow() const
Definition: txtfrm.hxx:516
SwTwips CalcFitToContent_()
Definition: itrform2.cxx:2004
PrepareHint
Definition: swtypes.hxx:198
void Bottom()
Definition: itrtxt.cxx:185
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1259
#define SW_MOD()
Definition: swmodule.hxx:255
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(167)
void InvalidateLineNum()
Definition: frame.hxx:1046
bool IsDummy() const
Definition: porlay.hxx:151
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void InvalidatePrt()
Definition: frame.hxx:1032
void InvalidateSpelling() const
Definition: pagefrm.hxx:368
sw::BroadcastingModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:475
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
void SetSmartTagDirty(bool bNew) const
Definition: txtedt.cxx:2283
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:78
SwDoc & GetDoc()
Definition: node.hxx:212
bool IsInside(SwTextMargin const &rLine) const
BP 18.6.93: Widows.
Definition: widorp.cxx:102
void Top()
Definition: itrtxt.hxx:99
SwFrame * GetIndNext()
Definition: frame.hxx:725
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
static SwSmartTagMgr & Get()
size_t size() const
Definition: sortedobjs.cxx:43
SwTextFly & GetTextFly()
Definition: inftxt.hxx:383
ComplexTextLayoutFlags
Mutex aLock
tools::Long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2305
SwPageFrame * FindPageFrame()
Definition: frame.hxx:678
sal_uLong GetAllLines() const
For displaying the line numbers.
Definition: txtfrm.hxx:664
Helper class which can be used instead of the macros if a function has too many returns.
Definition: txtfrm.hxx:918
SwCharRange & GetReformat()
Definition: porlay.hxx:284
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
void RecalcRealHeight()
Definition: itrform2.cxx:1765
Count
TextFrameIndex MapModelToView(MergedPara const &, SwTextNode const *pNode, sal_Int32 nIndex)
Definition: txtfrm.cxx:1175
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:191
TElementType * First()
Definition: calbck.hxx:325
SwTextGridItem const * GetGridItem(SwPageFrame const *const)
Definition: pagechg.cxx:2573
void ManipOfst(TextFrameIndex const nNewOfst)
Definition: txtfrm.hxx:438
SwContentNode * GetContentNode()
Definition: node.hxx:619
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:609
SwLinePortion * GetFirstPortion() const
Definition: porlay.cxx:699
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1378
sal_uInt16 Count() const
void InvalidateRange(const SwCharRange &, const tools::Long=0)
Definition: txtfrm.cxx:1679
iterate SwTextAttr in potentially merged text frame
Definition: txtfrm.hxx:980
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(MergedPara const &, TextFrameIndex nIndex)
Definition: txtfrm.cxx:1156
constexpr TypedWhichId< SwVirtPageNumInfo > RES_VIRTPAGENUM_INFO(180)
void SetAutoCompleteWordDirty(bool bNew) const
Definition: txtedt.cxx:2296
void SetRight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1385
SwLayoutFrame * GetUpper()
Definition: frame.hxx:676
bool HasArea() const
Definition: swrect.hxx:288
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
bool Relax(const SwRect &rRect)
If there is no flying object frame standing in rRect (usually the current row), then we are turning o...
Definition: txtfly.hxx:318
void SetOffset_(TextFrameIndex nNewOfst)
Definition: frmform.cxx:759
void InvalidateSmartTags() const
Definition: pagefrm.hxx:373
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
bool isFramePrintAreaValid() const
Definition: frame.hxx:167
SwGrammarMarkUp * GetGrammarCheck()
Definition: txtedt.cxx:2204
bool IsUndersized() const
Definition: flowfrm.hxx:158
SwTextNode * pParaPropsNode
most paragraph properties are taken from the first non-empty node
Definition: txtfrm.hxx:961
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2813
virtual void HandlePortion(SwPortionHandler &rPH) const
Definition: porlin.cxx:315
void Invalidate(sal_Int32 nBegin, sal_Int32 nEnd)
Definition: wrong.cxx:425
Provides access to settings of a document.
bool IsNoTextNode() const
Definition: node.hxx:652
SvxInterLineSpaceRule GetInterLineSpaceRule() const
SwFrame * GetPrev()
Definition: frame.hxx:675
SwTextFrame * GetFormatted(bool bForceQuickFormat=false)
In case the SwLineLayout was cleared out of the s_pTextCache, recreate it.
Definition: txtfrm.cxx:3355
constexpr TypedWhichId< SvxLineSpacingItem > RES_PARATR_LINESPACING(RES_PARATR_BEGIN)
void RemoveFootnotesForNode(SwRootFrame const &rLayout, SwTextNode const &rTextNode, std::vector< std::pair< sal_Int32, sal_Int32 >> const *const pExtents)
Definition: txtfrm.cxx:802
void Modify(bool bChgToRTL)
Definition: txtfrm.cxx:709
sal_uInt16 GetLineHeight() const
Definition: itrtxt.hxx:116
SwWrongList * GetSmartTags()
Definition: txtedt.cxx:2229
Marks a node in the document model.
Definition: ndindex.hxx:31
SvxAdjust GetNumAdjust() const
sal_Int32 nLen
Definition: hints.hxx:110
void RecalcAllLines()
Definition: txtfrm.cxx:3812
void RemoveFromCache()
Removes this frame completely from the Cache.
Definition: txtcache.cxx:120
const SvxLineSpacingItem & GetLineSpacing(bool=true) const
Definition: paratr.hxx:193
text is moved into pDestNode
Definition: hints.hxx:104
void TruncLines(bool bNoteFollow=false)
Definition: itrtxt.cxx:323
OUString mergedText
note: cannot be const currently to avoid UB because SwTextGuess::Guess const_casts it and modifies it...
Definition: txtfrm.hxx:959
SwTextNode * pDestNode
Definition: hints.hxx:107
void SSize(const Size &rNew)
Definition: swrect.hxx:178
bool IsLocked() const
Definition: txtfrm.hxx:514
int FieldCanHideParaWeight(SwFieldIds eFieldId) const
Definition: doc.cxx:1337
TextFrameIndex GetParLen() const
Definition: porlay.cxx:2409
bool isFrameAreaSizeValid() const
Definition: frame.hxx:166
static void lcl_SetScriptInval(SwTextFrame &rFrame, TextFrameIndex const nPos)
Definition: txtfrm.cxx:1855
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
TextFrameIndex GetLen() const
Definition: porlin.hxx:73
void CalcHeightOfLastLine(const bool _bUseFont=false)
method to determine height of last line, needed for proportional line spacing
Definition: txtfrm.cxx:3540
A page of the document layout.
Definition: pagefrm.hxx:41
SfxItemPool * GetPool() const
SwTextFrame * MakeTextFrame(SwTextNode &rNode, SwFrame *, sw::FrameMode eMode)
Definition: txtfrm.cxx:796
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
Definition: txtfrm.cxx:1223
tools::Long SwTwips
Definition: swtypes.hxx:49
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:544
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
Definition: frmform.cxx:1749
short GetInterLineSpace() const
sal_Int32 nStart
Definition: hints.hxx:119
< purpose of derivation from SwClient: character style for displaying the numbers.
Definition: lineinfo.hxx:37
SwBorderAttrs * Get()
Definition: frmtool.cxx:2615
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNodeIndex const &rNode)
Definition: txtfrm.cxx:324
bool isPARATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:487
SwFieldType * GetTyp() const
Definition: fldbas.hxx:392
void InvalidateSize()
Definition: frame.hxx:1025
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1111
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
MergedAttrIterByEnd(SwTextFrame const &rFrame)
Definition: txtfrm.cxx:145
constexpr TypedWhichId< SvxRsidItem > RES_CHRATR_RSID(39)
sal_uInt16 const aFrameFormatSetRange[]
Definition: init.cxx:233
SwPosition GetParaPropsPos(SwRootFrame const &rLayout, SwPosition const &rPos)
Definition: txtfrm.cxx:338
bool RemoveFootnote(const SwContentFrame *, const SwTextFootnote *, bool bPrep=true)
Definition: ftnfrm.cxx:1722
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:681
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:49
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:79
bool IsFootnoteNumFrame() const
Am I a FootnoteFrame, with a number at the start of the paragraph?
Definition: txtfrm.hxx:619
void SetTopAndHeight(SwRect &rRect, tools::Long nTop, tools::Long nHeight) const
Definition: frame.hxx:1424
sal_uInt16 Count() const
Definition: hints.hxx:287
void SetPosX(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1396
bool IsLayoutFrame() const
Definition: frame.hxx:1166
bool IsPrepMustFit() const
Definition: porlay.hxx:307
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:209
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void Broadcast(const SfxHint &rHint)
sal_uInt16 GetLineCount(TextFrameIndex nPos)
Determines the line count.
Definition: txtfrm.cxx:3735
void SetDevFont(const SwViewShell *pSh, OutputDevice &rOut)
Definition: fntcache.cxx:678
bool IsBreakNow(SwTextMargin &rLine)
Definition: widorp.cxx:176
#define LANGUAGE_ENGLISH
void SetWidth(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1386
bool IsVertLR() const
Definition: frame.hxx:975
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:67
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
tools::Long GetBottomMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1400
SwTwips mnAdditionalFirstLineOffset
Definition: txtfrm.hxx:192
bool UpdateQuoVadis(std::u16string_view rQuo)
Is called in SwTextFrame::Prepare()
Definition: txtftn.cxx:1534
void CheckKeep()
Definition: flowfrm.cxx:147
void SetOffset(TextFrameIndex nNewOfst)
Definition: txtfrm.hxx:862
constexpr TypedWhichId< SvxFormatSplitItem > RES_PARATR_SPLIT(65)
virtual SwFrameFormat & GetFrameFormat()=0
#define SAL_WARN_IF(condition, area, stream)
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:738
constexpr tools::Long Height() const
bool IsNumbered(SwRootFrame const *pLayout=nullptr) const
Returns is this text node is numbered.
Definition: ndtxt.cxx:2881
SwRepaint & GetRepaint()
Definition: porlay.hxx:282
void ClearPara()
Removes the Line information from the Cache but retains the entry itself.
Definition: txtcache.cxx:104
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
vcl::Window * GetWin() const
Definition: viewsh.hxx:337
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:126
void SetFont(const vcl::Font &rNewFont)
tools::Long GetLineSpace(const bool _bNoPropLineSpacing=false) const
Returns the additional line spacing for the next paragraph.
Definition: txtfrm.cxx:3679
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
SwTextNode const *const m_pNode
Definition: txtfrm.hxx:1007
MergedAttrIterBase(SwTextFrame const &rFrame)
Definition: txtfrm.cxx:77
static TextFrameIndex UpdateMergedParaForInsert(MergedPara &rMerged, bool const isRealInsert, SwTextNode const &rNode, sal_Int32 const nIndex, sal_Int32 const nLen)
Definition: txtfrm.cxx:893
void SetFieldFollow(const bool bNew)
Definition: txtfrm.hxx:247
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1244
sal_Int32 GetIndex() const
Definition: index.hxx:91
bool IsCountedInList() const
Definition: ndtxt.cxx:4244
void SetHeight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1387
bool IsNoTextFrame() const
Definition: frame.hxx:1234
SwTwips GetHeightOfLastLine() const
Definition: txtfrm.hxx:764
void SetMergedPara(std::unique_ptr< sw::MergedPara > p)
Definition: txtfrm.cxx:1266
void SwapWidthAndHeight()
Swaps width and height of the text frame.
Definition: txtfrm.cxx:418
LanguageType GetAppLanguage()
Definition: init.cxx:732
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:176
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
sw::MergedPara const * m_pMerged
Definition: txtfrm.hxx:984
SwTwips mnFlyAnchorOfstNoWrap
Definition: txtfrm.hxx:181
bool IsRightToLeft() const
Definition: frame.hxx:983
std::unique_ptr< sw::MergedPara > m_pMergedPara
redline merge data
Definition: txtfrm.hxx:195
void Top(const tools::Long nTop)
Definition: swrect.hxx:204
void SetWrong(SwWrongList *pNew, bool bDelete=true)
Definition: txtedt.cxx:2169
bool FieldHidesPara(const SwField &rField) const
Definition: doc.cxx:1352
static TextFrameIndex FindBrk(const OUString &rText, TextFrameIndex nStart, TextFrameIndex nEnd)
Returns the first possible break point in the current line.
Definition: txtfrm.cxx:1625
sal_Int32 nLen
Definition: hints.hxx:120
Organizer of the contact between SwTextNodes and grammar checker.
SwFrameType mnFrameType
Definition: frame.hxx:413
sal_Int32 nStart
Definition: txtfrm.hxx:86
TextFrameIndex CalcFlyPos(SwFrameFormat const *pSearch)
Calculates the position of FlyInContentFrames.
Definition: porfly.cxx:182
SwWrongList * GetWrong()
Definition: txtedt.cxx:2181
virtual OutputDevice * getReferenceDevice(bool bCreate) const =0
Returns the current reference device.
sal_uInt16 Width() const
Definition: possiz.hxx:51
MergedAttrIterReverse(SwTextFrame const &rFrame)
Definition: txtfrm.cxx:197
const SwLineLayout * PrevLine()
Definition: itrtxt.cxx:170
bool IsPrtFormat() const
Definition: viewopt.hxx:541
bool sw_HideObj(const SwTextFrame &_rFrame, const RndStdIds _eAnchorType, SwPosition const &rAnchorPos, SwAnchoredObject *_pAnchoredObj)
as-character anchored graphics, which are used for a graphic bullet list.
Definition: txtfrm.cxx:1478
SwScriptInfo & GetScriptInfo()
Definition: porlay.hxx:288
double getLength(const B2DPolygon &rCandidate)
const std::vector< sal_uInt16 > & getFmtAttrs() const
Definition: hints.hxx:202
void SetPrep()
Definition: porlay.hxx:302
bool IsParaPropsNode(SwRootFrame const &rLayout, SwTextNode const &rNode)
Definition: txtfrm.cxx:307
sal_Int32 nLen
Definition: hints.hxx:130
virtual void Skip(TextFrameIndex nLength)=0
skip characters.
virtual void MoveObjToInvisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding invisible layer
Definition: dcontact.cxx:236
void SetWidow(const bool bNew)
Definition: txtfrm.hxx:244
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
void DelFrames(const SwRootFrame *)
Definition: atrftn.cxx:469
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:718
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
static void lcl_SetWrong(SwTextFrame &rFrame, SwTextNode const &rNode, sal_Int32 const nPos, sal_Int32 const nCnt, bool const bMove)
Definition: txtfrm.cxx:1790
SwParaPortion * pOldPara
Definition: txtfrm.cxx:3109
bool IsFixLineHeight() const
Definition: porlay.hxx:313
void Unlock()
Definition: swcache.cxx:481
static bool GetBoundsOfHiddenRange(const SwTextNode &rNode, sal_Int32 nPos, sal_Int32 &rnStartPos, sal_Int32 &rnEndPos, std::vector< sal_Int32 > *pList=nullptr)
Hidden text range information - static and non-version.
Definition: porlay.cxx:1792
void SetPrepMustFit(const bool bNew)
Definition: porlay.hxx:306
void SetPrepWidows()
Definition: porlay.hxx:304
sal_uInt16 GetRealHeight() const
Definition: porlay.hxx:169
static bool lcl_ErgoVadis(SwTextFrame *pFrame, TextFrameIndex &rPos, const PrepareHint ePrep)
Definition: txtfrm.cxx:2685
void setHeight(tools::Long nHeight)
OUString m_aQuoVadis
Definition: ftninfo.hxx:95
const SwLineLayout * GetCurr() const
Definition: itrtxt.hxx:83
SwTextNode const * pLastNode
mainly for sanity checks
Definition: txtfrm.hxx:965
bool IsVertical() const
Definition: frame.hxx:969
tools::Long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1374
SwTextAttr const * NextAttr(SwTextNode const *&rpNode)
Definition: txtfrm.cxx:160
SwDocPosUpdate is sent to signal that only the frames from or to a specified document-global position...
Definition: hints.hxx:225
virtual void DestroyImpl() override
Definition: txtfrm.cxx:848
void InvalidatePrt_()
Definition: frame.hxx:777
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:633
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:128
void AddToListRLHidden()
Definition: ndtxt.cxx:4305
void SetLeft(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1384
RndStdIds
SwDoc & GetDoc()
Definition: txtfrm.hxx:457
SwTwips mnHeightOfLastLine
Definition: txtfrm.hxx:187
virtual bool WouldFit(SwTwips &nMaxHeight, bool &bSplit, bool bTst) override
nMaxHeight is the required height bSplit indicates, that the paragraph has to be split bTst indicates...
Definition: txtfrm.cxx:3218
constexpr TypedWhichId< SwFormatLineNumber > RES_LINENUMBER(116)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
Small Helper class: Prepares a test format.
Definition: txtfrm.cxx:3106
bool HasMergedParas() const
Definition: rootfrm.hxx:424
bool IsOn() const
Definition: txtfly.hxx:313
static bool hasA11yRelevantAttribute(const std::vector< sal_uInt16 > &rWhichFmtAttr)
Definition: txtfrm.cxx:1948
Left
SwTextNode *const pFirstNode
except break attributes, those are taken from the first node
Definition: txtfrm.hxx:963
bool IsShowHiddenChar(bool bHard=false) const
Definition: viewopt.hxx:321
sal_uInt16 getWhichAttr() const
Definition: hints.hxx:197
SwTwips mnFlyAnchorVertOfstNoWrap
The y position for wrap-through flys anchored at this paragraph.
Definition: txtfrm.hxx:183
constexpr TypedWhichId< SwDelChr > RES_DEL_CHR(165)
bool IsCount() const
Definition: fmtline.hxx:58
tuple m
TextFrameIndex GetEnd() const
Definition: itrtxt.hxx:89
sal_uInt16 GetDropLines() const
Definition: itrtxt.hxx:202
sal_uInt16 FirstLineHeight() const
Returns the first line height.
Definition: txtfrm.cxx:3720
void VisitPortions(SwPortionHandler &rPH) const
Visit all portions for Accessibility.
Definition: txtfrm.cxx:3866
SwLinePortion * GetNextPortion() const
Definition: porlin.hxx:71
void InvalidateWordCount() const
Definition: pagefrm.hxx:381
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:208
void InvalidateRange_(const SwCharRange &, const tools::Long=0)
Definition: txtfrm.cxx:1685
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
class for collecting anchored objects
Definition: sortedobjs.hxx:48
ComplexTextLayoutFlags m_nOldLayoutMode
Definition: txtfrm.hxx:930
void Height(tools::Long nNew)
Definition: swrect.hxx:191
constexpr TypedWhichId< SwDelText > RES_DEL_TXT(166)
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1238
TextFrameIndex & Len()
Definition: porlay.hxx:49
SwFieldIds Which() const
Definition: fldbas.hxx:272
SdrObjUserCall * GetUserCall() const
bool IsIdxInside(TextFrameIndex nPos, TextFrameIndex nLen) const
Definition: txtfrm.cxx:1650
Merge GetRedlineMergeFlag() const
Definition: node.hxx:98
const SwPosition & GetContentAnchor() const
Definition: dcontact.hxx:152
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:70
tools::Long GetHeight() const
Definition: swfont.hxx:280
const SwFootnoteInfo & GetFootnoteInfo() const
Definition: doc.hxx:629
const sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:61
sal_uInt16 Which() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:677
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
bool mbIsSwapped
Definition: txtfrm.hxx:233
OUString m_aErgoSum
Definition: ftninfo.hxx:96
void SetInvalid(sal_Int32 nBegin, sal_Int32 nEnd)
Definition: wrong.cxx:253
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_MSG_BEGIN)
void HideFootnotes(TextFrameIndex nStart, TextFrameIndex nEnd)
Definition: txtfrm.cxx:1447
sal_uInt16 nPos
virtual void SwClientNotify(SwModify const &rModify, SfxHint const &rHint) override
Definition: txtfrm.cxx:1963
std::pair< SwTextNode *, SwTextNode * > GetFirstAndLastNode(SwRootFrame const &rLayout, SwNodeIndex const &rPos)
Definition: txtfrm.cxx:351
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:845
virtual void DestroyImpl() override
Definition: ssfrm.cxx:422
bool isPARATR_LIST(const sal_uInt16 nWhich)
Definition: hintids.hxx:491
void ChgThisLines()
Definition: txtfrm.cxx:3756
#define PROTOCOL_ENTER(pFrame, nFunc, nAct, pPar)
Definition: dbg_lay.hxx:92
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1095
SwTextFrame * pFrame
Definition: txtfrm.cxx:3108
SwFrameSwapper(const SwTextFrame *pFrame, bool bSwapIfNotSwapped)
Definition: txtfrm.cxx:665
SwFrame * GetNext()
Definition: frame.hxx:674
const SwFormatLineNumber & GetLineNumber(bool=true) const
Definition: fmtline.hxx:64
SwLayoutModeModifier(const OutputDevice &rOutp)
Definition: txtfrm.cxx:699
SwTextNode const * m_pNode
Definition: txtfrm.hxx:985
bool HasFootnote() const
Definition: txtfrm.hxx:519