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