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