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