LibreOffice Module sw (master)  1
frmform.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 <sal/config.h>
21 #include <sal/log.hxx>
22 
24 #include <anchoredobject.hxx>
25 #include <bodyfrm.hxx>
26 #include <hintids.hxx>
27 #include <editeng/keepitem.hxx>
29 #include <pagefrm.hxx>
30 #include <ndtxt.hxx>
31 #include <ftnfrm.hxx>
32 #include <txtftn.hxx>
33 #include <fmtftn.hxx>
34 #include <paratr.hxx>
35 #include <viewopt.hxx>
36 #include <viewsh.hxx>
37 #include <frmatr.hxx>
38 #include <pam.hxx>
39 #include <fmtanchr.hxx>
40 #include "itrform2.hxx"
41 #include "widorp.hxx"
42 #include "txtcache.hxx"
43 #include <sectfrm.hxx>
44 #include <rootfrm.hxx>
45 #include <frmfmt.hxx>
46 #include <sortedobjs.hxx>
47 #include <editeng/tstpitem.hxx>
48 #include <redline.hxx>
49 #include <comphelper/lok.hxx>
50 
51 // Tolerance in formatting and text output
52 #define SLOPPY_TWIPS 5
53 
54 namespace {
55 
56 class FormatLevel
57 {
58  static sal_uInt16 s_nLevel;
59 public:
60  FormatLevel() { ++s_nLevel; }
61  ~FormatLevel() { --s_nLevel; }
62  static sal_uInt16 GetLevel() { return s_nLevel; }
63  static bool LastLevel() { return 10 < s_nLevel; }
64 };
65 
66 }
67 
68 sal_uInt16 FormatLevel::s_nLevel = 0;
69 
70 void ValidateText( SwFrame *pFrame ) // Friend of frame
71 {
72  if ( ( ! pFrame->IsVertical() &&
73  pFrame->getFrameArea().Width() == pFrame->GetUpper()->getFramePrintArea().Width() ) ||
74  ( pFrame->IsVertical() &&
75  pFrame->getFrameArea().Height() == pFrame->GetUpper()->getFramePrintArea().Height() ) )
76  {
77  pFrame->setFrameAreaSizeValid(true);
78  }
79 }
80 
82 {
83  vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
84  // Validate surroundings to avoid oscillation
85  SwSwapIfSwapped swap( this );
86 
87  if ( !IsInFly() && !IsInTab() )
88  { // Only validate 'this' when inside a fly, the rest should actually only be
89  // needed for footnotes, which do not exist in flys.
90  SwSectionFrame* pSct = FindSctFrame();
91  if( pSct )
92  {
93  if( !pSct->IsColLocked() )
94  pSct->ColLock();
95  else
96  pSct = nullptr;
97  }
98 
99  SwFrame *pUp = GetUpper();
100  pUp->Calc(pRenderContext);
101  if( pSct )
102  pSct->ColUnlock();
103  }
104  ValidateText( this );
105 
106  // We at least have to save the MustFit flag!
107  assert(HasPara() && "ResetPreps(), missing ParaPortion, SwCache bug?");
108  SwParaPortion *pPara = GetPara();
109  const bool bMustFit = pPara->IsPrepMustFit();
110  ResetPreps();
111  pPara->SetPrepMustFit( bMustFit );
112 }
113 
114 // After a RemoveFootnote the BodyFrame and all Frames contained within it, need to be
115 // recalculated, so that the DeadLine is right.
116 // First we search outwards, on the way back we calculate everything.
117 static void ValidateBodyFrame_( SwFrame *pFrame )
118 {
119  vcl::RenderContext* pRenderContext = pFrame ? pFrame->getRootFrame()->GetCurrShell()->GetOut() : nullptr;
120  if( !pFrame || pFrame->IsCellFrame() )
121  return;
122 
123  if( !pFrame->IsBodyFrame() && pFrame->GetUpper() )
124  ValidateBodyFrame_( pFrame->GetUpper() );
125  if( !pFrame->IsSctFrame() )
126  pFrame->Calc(pRenderContext);
127  else
128  {
129  const bool bOld = static_cast<SwSectionFrame*>(pFrame)->IsContentLocked();
130  static_cast<SwSectionFrame*>(pFrame)->SetContentLock( true );
131  pFrame->Calc(pRenderContext);
132  if( !bOld )
133  static_cast<SwSectionFrame*>(pFrame)->SetContentLock( false );
134  }
135 }
136 
138 {
139  SwSwapIfSwapped swap( this );
140 
141  // See comment in ValidateFrame()
142  if ( !IsInFly() && !IsInTab() &&
143  !( IsInSct() && FindSctFrame()->Lower()->IsColumnFrame() ) )
145 }
146 
147 bool SwTextFrame::GetDropRect_( SwRect &rRect ) const
148 {
149  SwSwapIfNotSwapped swap(const_cast<SwTextFrame *>(this));
150 
151  OSL_ENSURE( HasPara(), "SwTextFrame::GetDropRect_: try again next year." );
152  SwTextSizeInfo aInf( const_cast<SwTextFrame*>(this) );
153  SwTextMargin aLine( const_cast<SwTextFrame*>(this), &aInf );
154  if( aLine.GetDropLines() )
155  {
156  rRect.Top( aLine.Y() );
157  rRect.Left( aLine.GetLineStart() );
158  rRect.Height( aLine.GetDropHeight() );
159  rRect.Width( aLine.GetDropLeft() );
160 
161  if ( IsRightToLeft() )
162  SwitchLTRtoRTL( rRect );
163 
164  if ( IsVertical() )
166  return true;
167  }
168 
169  return false;
170 }
171 
173 {
174  vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
175  SwSwapIfSwapped swap( this );
176 
177  OSL_ENSURE( HasFollow(), "CalcFollow: missing Follow." );
178 
179  SwTextFrame* pMyFollow = GetFollow();
180 
181  SwParaPortion *pPara = GetPara();
182  const bool bFollowField = pPara && pPara->IsFollowField();
183 
184  if( !pMyFollow->GetOffset() || pMyFollow->GetOffset() != nTextOfst ||
185  bFollowField || pMyFollow->IsFieldFollow() ||
186  ( pMyFollow->IsVertical() && !pMyFollow->getFramePrintArea().Width() ) ||
187  ( ! pMyFollow->IsVertical() && !pMyFollow->getFramePrintArea().Height() ) )
188  {
189 #if OSL_DEBUG_LEVEL > 0
190  const SwFrame *pOldUp = GetUpper();
191 #endif
192 
193  SwRectFnSet aRectFnSet(this);
194  SwTwips nOldBottom = aRectFnSet.GetBottom(GetUpper()->getFrameArea());
195  SwTwips nMyPos = aRectFnSet.GetTop(getFrameArea());
196 
197  const SwPageFrame *pPage = nullptr;
198  bool bOldInvaContent = true;
199  if ( !IsInFly() && GetNext() )
200  {
201  pPage = FindPageFrame();
202  // Minimize (reset if possible) invalidations: see below
203  bOldInvaContent = pPage->IsInvalidContent();
204  }
205 
206  pMyFollow->SetOffset_( nTextOfst );
207  pMyFollow->SetFieldFollow( bFollowField );
208  if( HasFootnote() || pMyFollow->HasFootnote() )
209  {
210  ValidateFrame();
212  if( pPara )
213  {
214  pPara->GetReformat() = SwCharRange();
215  pPara->GetDelta() = 0;
216  }
217  }
218 
219  // The footnote area must not get larger
221 
222  pMyFollow->CalcFootnoteFlag();
223  if ( !pMyFollow->GetNext() && !pMyFollow->HasFootnote() )
224  nOldBottom = aRectFnSet.IsVert() ? 0 : LONG_MAX;
225 
226  // tdf#122892 check flag:
227  // 1. WidowsAndOrphans::FindWidows() determines follow is a widow
228  // 2. SwTextFrame::PrepWidows() calls SetPrepWidows() on master;
229  // if it can spare lines, master truncates one line
230  // 3. SwTextFrame::CalcPreps() on master (below);
231  // unless IsPrepMustFit(), if master hasn't shrunk via 2., it will SetWidow()
232  // 4. loop must exit then, because the follow didn't grow so nothing will ever change
233  while (!IsWidow())
234  {
235  if( !FormatLevel::LastLevel() )
236  {
237  // If the follow is contained within a column section or column
238  // frame, we need to calculate that first. This is because the
239  // FormatWidthCols() does not work if it is called from MakeAll
240  // of the _locked_ follow.
241  SwSectionFrame* pSct = pMyFollow->FindSctFrame();
242  if( pSct && !pSct->IsAnLower( this ) )
243  {
244  if( pSct->GetFollow() )
245  pSct->SimpleFormat();
246  else if( ( pSct->IsVertical() && !pSct->getFrameArea().Width() ) ||
247  ( ! pSct->IsVertical() && !pSct->getFrameArea().Height() ) )
248  break;
249  }
250  // i#11760 - Intrinsic format of follow is controlled.
251  if ( FollowFormatAllowed() )
252  {
253  // i#11760 - No nested format of follows, if
254  // text frame is contained in a column frame.
255  // Thus, forbid intrinsic format of follow.
256  {
257  bool bIsFollowInColumn = false;
258  SwFrame* pFollowUpper = pMyFollow->GetUpper();
259  while ( pFollowUpper )
260  {
261  if ( pFollowUpper->IsColumnFrame() )
262  {
263  bIsFollowInColumn = true;
264  break;
265  }
266  if ( pFollowUpper->IsPageFrame() ||
267  pFollowUpper->IsFlyFrame() )
268  {
269  break;
270  }
271  pFollowUpper = pFollowUpper->GetUpper();
272  }
273  if ( bIsFollowInColumn )
274  {
275  pMyFollow->ForbidFollowFormat();
276  }
277  }
278 
279  pMyFollow->Calc(pRenderContext);
280  // The Follow can tell from its getFrameArea().Height() that something went wrong
281  OSL_ENSURE( !pMyFollow->GetPrev(), "SwTextFrame::CalcFollow: cheesy follow" );
282  if( pMyFollow->GetPrev() )
283  {
284  pMyFollow->Prepare();
285  pMyFollow->Calc(pRenderContext);
286  OSL_ENSURE( !pMyFollow->GetPrev(), "SwTextFrame::CalcFollow: very cheesy follow" );
287  }
288 
289  // i#11760 - Reset control flag for follow format.
290  pMyFollow->AllowFollowFormat();
291  }
292 
293  // Make sure that the Follow gets painted
294  pMyFollow->SetCompletePaint();
295  }
296 
297  pPara = GetPara();
298  // As long as the Follow requests lines due to Orphans, it is
299  // passed these and is formatted again if possible
300  if( pPara && pPara->IsPrepWidows() )
301  CalcPreps();
302  else
303  break;
304  }
305 
306  if( HasFootnote() || pMyFollow->HasFootnote() )
307  {
309  ValidateFrame();
310  if( pPara )
311  {
312  pPara->GetReformat() = SwCharRange();
313  pPara->GetDelta() = 0;
314  }
315  }
316 
317  if ( pPage && !bOldInvaContent )
318  pPage->ValidateContent();
319 
320 #if OSL_DEBUG_LEVEL > 0
321  OSL_ENSURE( pOldUp == GetUpper(), "SwTextFrame::CalcFollow: heavy follow" );
322 #endif
323 
324  const tools::Long nRemaining =
325  - aRectFnSet.BottomDist( GetUpper()->getFrameArea(), nOldBottom );
326  if ( nRemaining > 0 &&
327  nRemaining != ( aRectFnSet.IsVert() ?
328  nMyPos - getFrameArea().Right() :
329  getFrameArea().Top() - nMyPos ) )
330  {
331  return true;
332  }
333  }
334 
335  return false;
336 }
337 
339 {
341  // Inform LOK clients about change in position of redlines (if any)
343  return;
344 
345  SwTextNode const* pTextNode = GetTextNodeFirst();
346  const SwRedlineTable& rTable = pTextNode->getIDocumentRedlineAccess().GetRedlineTable();
347  for (SwRedlineTable::size_type nRedlnPos = 0; nRedlnPos < rTable.size(); ++nRedlnPos)
348  {
349  SwRangeRedline* pRedln = rTable[nRedlnPos];
350  if (pTextNode->GetIndex() == pRedln->GetPoint()->nNode.GetNode().GetIndex())
351  {
353  if (GetMergedPara()
354  && pRedln->GetType() == RedlineType::Delete
355  && pRedln->GetPoint()->nNode != pRedln->GetMark()->nNode)
356  {
357  pTextNode = pRedln->End()->nNode.GetNode().GetTextNode();
358  }
359  }
360  }
361 }
362 
363 void SwTextFrame::AdjustFrame( const SwTwips nChgHght, bool bHasToFit )
364 {
365  vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
366  if( IsUndersized() )
367  {
368  if( GetOffset() && !IsFollow() ) // A scrolled paragraph (undersized)
369  return;
370  SetUndersized( nChgHght == 0 || bHasToFit );
371  }
372 
373  // AdjustFrame is called with a swapped frame during
374  // formatting but the frame is not swapped during FormatEmpty
375  SwSwapIfSwapped swap( this );
376  SwRectFnSet aRectFnSet(this);
377 
378  // The Frame's size variable is incremented by Grow or decremented by Shrink.
379  // If the size cannot change, nothing should happen!
380  if( nChgHght >= 0)
381  {
382  SwTwips nChgHeight = nChgHght;
383  if( nChgHght && !bHasToFit )
384  {
385  if( IsInFootnote() && !IsInSct() )
386  {
387  SwTwips nReal = Grow( nChgHght, true );
388  if( nReal < nChgHght )
389  {
390  SwTwips nBot = aRectFnSet.YInc( aRectFnSet.GetBottom(getFrameArea()),
391  nChgHght - nReal );
392  SwFrame* pCont = FindFootnoteFrame()->GetUpper();
393 
394  if( aRectFnSet.BottomDist( pCont->getFrameArea(), nBot ) > 0 )
395  {
397  aRectFnSet.AddBottom( aFrm, nChgHght );
398 
400 
401  if( aRectFnSet.IsVert() )
402  {
403  aPrt.AddWidth(nChgHght );
404  }
405  else
406  {
407  aPrt.AddHeight(nChgHght );
408  }
409 
410  return;
411  }
412  }
413  }
414 
415  Grow( nChgHght );
416 
417  if ( IsInFly() )
418  {
419  // If one of the Upper is a Fly, it's very likely that this fly changes its
420  // position by the Grow. Therefore, my position has to be corrected also or
421  // the check further down is not meaningful.
422  // The predecessors need to be calculated, so that the position can be
423  // calculated correctly.
424  if ( GetPrev() )
425  {
426  SwFrame *pPre = GetUpper()->Lower();
427  do
428  { pPre->Calc(pRenderContext);
429  pPre = pPre->GetNext();
430  } while ( pPre && pPre != this );
431  }
432  const Point aOldPos( getFrameArea().Pos() );
433  MakePos();
434  if ( aOldPos != getFrameArea().Pos() )
435  {
436  InvalidateObjs(false);
437  }
438  }
439  nChgHeight = 0;
440  }
441  // A Grow() is always accepted by the Layout, even if the
442  // FixSize of the surrounding layout frame should not allow it.
443  // We text for this case and correct the values.
444  // The Frame must NOT be shrunk further than its size permits
445  // even in the case of an emergency.
446  SwTwips nRstHeight;
447  if ( IsVertical() )
448  {
449  OSL_ENSURE( ! IsSwapped(),"Swapped frame while calculating nRstHeight" );
450 
451  if ( IsVertLR() )
452  nRstHeight = GetUpper()->getFrameArea().Left()
455  - getFrameArea().Left();
456  else
457  nRstHeight = getFrameArea().Left() + getFrameArea().Width() -
459  }
460  else
461  nRstHeight = GetUpper()->getFrameArea().Top()
464  - getFrameArea().Top();
465 
466  // We can get a bit of space in table cells, because there could be some
467  // left through a vertical alignment to the top.
468  // Assure that first lower in upper is the current one or is valid.
469  if ( IsInTab() &&
470  ( GetUpper()->Lower() == this ||
472  {
473  tools::Long nAdd = aRectFnSet.YDiff( aRectFnSet.GetTop(GetUpper()->Lower()->getFrameArea()),
474  aRectFnSet.GetPrtTop(*GetUpper()) );
475  OSL_ENSURE( nAdd >= 0, "Ey" );
476  nRstHeight += nAdd;
477  }
478 
479  // nRstHeight < 0 means that the TextFrame is located completely outside of its Upper.
480  // This can happen, if it's located within a FlyAtContentFrame, which changed sides by a
481  // Grow(). In such a case, it's wrong to execute the following Grow().
482  // In the case of a bug, we end up with an infinite loop.
483  SwTwips nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
484  SwTwips nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
485 
486  if( nRstHeight < nFrameHeight )
487  {
488  // It can be that I have the right size, but the Upper is too small and can get me some room
489  if( ( nRstHeight >= 0 || ( IsInFootnote() && IsInSct() ) ) && !bHasToFit )
490  nRstHeight += GetUpper()->Grow( nFrameHeight - nRstHeight );
491  // In column sections we do not want to get too big or else more areas are created by
492  // GetNextSctLeaf. Instead, we shrink and remember bUndersized, so that FormatWidthCols
493  // can calculate the right column size.
494  if ( nRstHeight < nFrameHeight )
495  {
496  if( bHasToFit || !IsMoveable() ||
497  ( IsInSct() && !FindSctFrame()->MoveAllowed(this) ) )
498  {
499  SetUndersized( true );
500  Shrink( std::min( ( nFrameHeight - nRstHeight), nPrtHeight ) );
501  }
502  else
503  SetUndersized( false );
504  }
505  }
506  else if( nChgHeight )
507  {
508  if( nRstHeight - nFrameHeight < nChgHeight )
509  nChgHeight = nRstHeight - nFrameHeight;
510  if( nChgHeight )
511  Grow( nChgHeight );
512  }
513  }
514  else
515  Shrink( -nChgHght );
516 }
517 
518 css::uno::Sequence< css::style::TabStop > SwTextFrame::GetTabStopInfo( SwTwips CurrentPos )
519 {
520  SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this );
521  SwTextFormatter aLine( this, &aInf );
522  SwTextCursor TextCursor( this, &aInf );
523  const Point aCharPos( TextCursor.GetTopLeft() );
524 
525  SwTwips nRight = aLine.Right();
526  CurrentPos -= aCharPos.X();
527 
528  // get current tab stop information stored in the Frame
529  const SvxTabStop *pTS = aLine.GetLineInfo().GetTabStop( CurrentPos, nRight );
530 
531  if( !pTS )
532  {
533  return {};
534  }
535 
536  // copy tab stop information into a Sequence, which only contains one element.
537  css::style::TabStop ts;
538  ts.Position = pTS->GetTabPos();
539  ts.DecimalChar = pTS->GetDecimal();
540  ts.FillChar = pTS->GetFill();
541  switch( pTS->GetAdjustment() )
542  {
543  case SvxTabAdjust::Left : ts.Alignment = css::style::TabAlign_LEFT; break;
544  case SvxTabAdjust::Center : ts.Alignment = css::style::TabAlign_CENTER; break;
545  case SvxTabAdjust::Right : ts.Alignment = css::style::TabAlign_RIGHT; break;
546  case SvxTabAdjust::Decimal: ts.Alignment = css::style::TabAlign_DECIMAL; break;
547  case SvxTabAdjust::Default: ts.Alignment = css::style::TabAlign_DEFAULT; break;
548  default: break; // prevent warning
549  }
550 
551  return { ts };
552 }
553 
554 // AdjustFollow expects the following situation:
555 // The SwTextIter points to the lower end of the Master, the Offset is set in the Follow.
556 // nOffset holds the Offset in the text string, from which the Master closes
557 // and the Follow starts.
558 // If it's 0, the FollowFrame is deleted.
560  const TextFrameIndex nOffset, const TextFrameIndex nEnd,
561  const sal_uInt8 nMode )
562 {
563  SwFrameSwapper aSwapper( this, false );
564 
565  // We got the rest of the text mass: Delete all Follows
566  // DummyPortions() are a special case.
567  // Special cases are controlled by parameter <nMode>.
568  if( HasFollow() && !(nMode & 1) && nOffset == nEnd )
569  {
570  while( GetFollow() )
571  {
572  if( GetFollow()->IsLocked() )
573  {
574  OSL_FAIL( "+SwTextFrame::JoinFrame: Follow is locked." );
575  return;
576  }
577  if (GetFollow()->IsDeleteForbidden())
578  return;
579  JoinFrame();
580  }
581 
582  return;
583  }
584 
585  // Dancing on the volcano: We'll just format the last line quickly
586  // for the QuoVadis stuff.
587  // The Offset can move of course:
588  const TextFrameIndex nNewOfst = (IsInFootnote() && (!GetIndNext() || HasFollow()))
589  ? rLine.FormatQuoVadis(nOffset) : nOffset;
590 
591  if( !(nMode & 1) )
592  {
593  // We steal text mass from our Follows
594  // It can happen that we have to join some of them
595  while( GetFollow() && GetFollow()->GetFollow() &&
596  nNewOfst >= GetFollow()->GetFollow()->GetOffset() )
597  {
598  JoinFrame();
599  }
600  }
601 
602  // The Offset moved
603  if( GetFollow() )
604  {
605  if ( nMode )
607 
608  if ( CalcFollow( nNewOfst ) ) // CalcFollow only at the end, we do a SetOffset there
609  rLine.SetOnceMore( true );
610  }
611 }
612 
614 {
615  OSL_ENSURE( GetFollow(), "+SwTextFrame::JoinFrame: no follow" );
616  SwTextFrame *pFoll = GetFollow();
617 
618  SwTextFrame *pNxt = pFoll->GetFollow();
619 
620  // All footnotes of the to-be-destroyed Follow are relocated to us
621  TextFrameIndex nStart = pFoll->GetOffset();
622  if ( pFoll->HasFootnote() )
623  {
624  SwFootnoteBossFrame *pFootnoteBoss = nullptr;
625  SwFootnoteBossFrame *pEndBoss = nullptr;
626  SwTextNode const* pNode(nullptr);
627  sw::MergedAttrIter iter(*pFoll);
628  for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
629  {
630  if (RES_TXTATR_FTN == pHt->Which()
631  && nStart <= pFoll->MapModelToView(pNode, pHt->GetStart()))
632  {
633  if (pHt->GetFootnote().IsEndNote())
634  {
635  if (!pEndBoss)
636  pEndBoss = pFoll->FindFootnoteBossFrame();
637  SwFootnoteBossFrame::ChangeFootnoteRef( pFoll, static_cast<const SwTextFootnote*>(pHt), this );
638  }
639  else
640  {
641  if (!pFootnoteBoss)
642  pFootnoteBoss = pFoll->FindFootnoteBossFrame( true );
643  SwFootnoteBossFrame::ChangeFootnoteRef( pFoll, static_cast<const SwTextFootnote*>(pHt), this );
644  }
645  SetFootnote( true );
646  }
647  }
648  }
649 
650 #ifdef DBG_UTIL
651  else if ( pFoll->isFramePrintAreaValid() ||
652  pFoll->isFrameAreaSizeValid() )
653  {
654  pFoll->CalcFootnoteFlag();
655  OSL_ENSURE( !pFoll->HasFootnote(), "Missing FootnoteFlag." );
656  }
657 #endif
658 
659  pFoll->MoveFlyInCnt( this, nStart, TextFrameIndex(COMPLETE_STRING) );
660  pFoll->SetFootnote( false );
661  // i#27138
662  // Notify accessibility paragraphs objects about changed CONTENT_FLOWS_FROM/_TO relation.
663  // Relation CONTENT_FLOWS_FROM for current next paragraph will change
664  // and relation CONTENT_FLOWS_TO for current previous paragraph, which
665  // is <this>, will change.
666  {
667  SwViewShell* pViewShell( pFoll->getRootFrame()->GetCurrShell() );
668  if ( pViewShell && pViewShell->GetLayout() &&
669  pViewShell->GetLayout()->IsAnyShellAccessible() )
670  {
672  dynamic_cast<SwTextFrame*>(pFoll->FindNextCnt( true )),
673  this );
674  }
675  }
676  pFoll->Cut();
677  SetFollow(pNxt);
678  SwFrame::DestroyFrame(pFoll);
679  return pNxt;
680 }
681 
683 {
684  SwSwapIfSwapped swap( this );
685 
686  // The Paste sends a Modify() to me
687  // I lock myself, so that my data does not disappear
688  TextFrameLockGuard aLock( this );
689  SwTextFrame *const pNew = static_cast<SwTextFrame *>(GetTextNodeFirst()->MakeFrame(this));
690 
691  pNew->SetFollow( GetFollow() );
692  SetFollow( pNew );
693 
694  pNew->Paste( GetUpper(), GetNext() );
695  // i#27138
696  // notify accessibility paragraphs objects about changed CONTENT_FLOWS_FROM/_TO relation.
697  // Relation CONTENT_FLOWS_FROM for current next paragraph will change
698  // and relation CONTENT_FLOWS_TO for current previous paragraph, which
699  // is <this>, will change.
700  {
701  SwViewShell* pViewShell( pNew->getRootFrame()->GetCurrShell() );
702  if ( pViewShell && pViewShell->GetLayout() &&
703  pViewShell->GetLayout()->IsAnyShellAccessible() )
704  {
706  dynamic_cast<SwTextFrame*>(pNew->FindNextCnt( true )),
707  this );
708  }
709  }
710 
711  // If footnotes end up in pNew bz our actions, we need
712  // to re-register them
713  if ( HasFootnote() )
714  {
715  SwFootnoteBossFrame *pFootnoteBoss = nullptr;
716  SwFootnoteBossFrame *pEndBoss = nullptr;
717  SwTextNode const* pNode(nullptr);
718  sw::MergedAttrIter iter(*this);
719  for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
720  {
721  if (RES_TXTATR_FTN == pHt->Which()
722  && nTextPos <= MapModelToView(pNode, pHt->GetStart()))
723  {
724  if (pHt->GetFootnote().IsEndNote())
725  {
726  if (!pEndBoss)
727  pEndBoss = FindFootnoteBossFrame();
728  SwFootnoteBossFrame::ChangeFootnoteRef( this, static_cast<const SwTextFootnote*>(pHt), pNew );
729  }
730  else
731  {
732  if (!pFootnoteBoss)
733  pFootnoteBoss = FindFootnoteBossFrame( true );
734  SwFootnoteBossFrame::ChangeFootnoteRef( this, static_cast<const SwTextFootnote*>(pHt), pNew );
735  }
736  pNew->SetFootnote( true );
737  }
738  }
739  }
740 
741 #ifdef DBG_UTIL
742  else
743  {
744  CalcFootnoteFlag( nTextPos - TextFrameIndex(1) );
745  OSL_ENSURE( !HasFootnote(), "Missing FootnoteFlag." );
746  }
747 #endif
748 
749  MoveFlyInCnt( pNew, nTextPos, TextFrameIndex(COMPLETE_STRING) );
750 
751  // No SetOffset or CalcFollow, because an AdjustFollow follows immediately anyways
752 
753  pNew->ManipOfst( nTextPos );
754 }
755 
757 {
758  // We do not need to invalidate out Follow.
759  // We are a Follow, get formatted right away and call
760  // SetOffset() from there
761  mnOffset = nNewOfst;
762  SwParaPortion *pPara = GetPara();
763  if( pPara )
764  {
765  SwCharRange &rReformat = pPara->GetReformat();
766  rReformat.Start() = TextFrameIndex(0);
767  rReformat.Len() = TextFrameIndex(GetText().getLength());
768  pPara->GetDelta() = sal_Int32(rReformat.Len());
769  }
770  InvalidateSize();
771 }
772 
774 {
775  OSL_ENSURE( ! IsVertical() || ! IsSwapped(), "SwTextFrame::CalcPreps with swapped frame" );
776  SwRectFnSet aRectFnSet(this);
777 
778  SwParaPortion *pPara = GetPara();
779  if ( !pPara )
780  return false;
781  const bool bPrep = pPara->IsPrep();
782  const bool bPrepWidows = pPara->IsPrepWidows();
783  const bool bPrepAdjust = pPara->IsPrepAdjust();
784  const bool bPrepMustFit = pPara->IsPrepMustFit();
785  ResetPreps();
786 
787  bool bRet = false;
788  if( bPrep && !pPara->GetReformat().Len() )
789  {
790  // PrepareHint::Widows means that the orphans rule got activated in the Follow.
791  // In unfortunate cases we could also have a PrepAdjust!
792  if( bPrepWidows )
793  {
794  if( !GetFollow() )
795  {
796  OSL_ENSURE( GetFollow(), "+SwTextFrame::CalcPreps: no credits" );
797  return false;
798  }
799 
800  // We need to prepare for two cases:
801  // We were able to hand over a few lines to the Follow
802  // -> we need to shrink
803  // or we need to go on the next page
804  // -> we let our Frame become too big
805 
806  SwTwips nChgHeight = GetParHeight();
807  if( nChgHeight >= aRectFnSet.GetHeight(getFramePrintArea()) )
808  {
809  if( bPrepMustFit )
810  {
811  GetFollow()->SetJustWidow( true );
812  GetFollow()->Prepare();
813  }
814  else if ( aRectFnSet.IsVert() )
815  {
816  {
818  aFrm.Width( aFrm.Width() + aFrm.Left() );
819  aFrm.Left( 0 );
820  }
821 
822  {
824  aPrt.Width( aPrt.Width() + getFrameArea().Left() );
825  }
826 
827  SetWidow( true );
828  }
829  else
830  {
831  // nTmp should be very large, but not so large as to cause overflow later (e.g.,
832  // GetFrameOfModify in sw/source/core/layout/frmtool.cxx calculates nCurrentDist
833  // from, among others, the square of aDiff.getY(), which can be close to nTmp);
834  // the previously used value TWIPS_MAX/2 (i.e., (LONG_MAX - 1)/2) depended on
835  // the range of 'long', while the value (SAL_MAX_INT32 - 1)/2 (which matches the
836  // old value on platforms where 'long' is 'sal_Int32') is empirically shown to
837  // be large enough in practice even on platforms where 'long' is 'sal_Int64':
838  SwTwips const nTmp = sw::WIDOW_MAGIC - (getFrameArea().Top()+10000);
839  SwTwips nDiff = nTmp - getFrameArea().Height();
840 
841  {
843  aFrm.Height( nTmp );
844  }
845 
846  {
848  aPrt.Height( aPrt.Height() + nDiff );
849  }
850 
851  SetWidow( true );
852  }
853  }
854  else
855  {
856  OSL_ENSURE( nChgHeight < aRectFnSet.GetHeight(getFramePrintArea()),
857  "+SwTextFrame::CalcPrep: want to shrink" );
858 
859  nChgHeight = aRectFnSet.GetHeight(getFramePrintArea()) - nChgHeight;
860 
861  GetFollow()->SetJustWidow( true );
862  GetFollow()->Prepare();
863  Shrink( nChgHeight );
864  SwRect &rRepaint = pPara->GetRepaint();
865 
866  if ( aRectFnSet.IsVert() )
867  {
869  SwitchVerticalToHorizontal( aRepaint );
870  rRepaint.Chg( aRepaint.Pos(), aRepaint.SSize() );
871  }
872  else
873  rRepaint.Chg( getFrameArea().Pos() + getFramePrintArea().Pos(), getFramePrintArea().SSize() );
874 
875  if( 0 >= rRepaint.Width() )
876  rRepaint.Width(1);
877  }
878  bRet = true;
879  }
880  else if ( bPrepAdjust )
881  {
882  if ( HasFootnote() )
883  {
884  if( !CalcPrepFootnoteAdjust() )
885  {
886  if( bPrepMustFit )
887  {
888  SwTextLineAccess aAccess( this );
889  aAccess.GetPara()->SetPrepMustFit(true);
890  }
891  return false;
892  }
893  }
894 
895  {
896  SwSwapIfNotSwapped swap( this );
897 
898  SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this );
899  SwTextFormatter aLine( this, &aInf );
900 
901  WidowsAndOrphans aFrameBreak( this );
902  // Whatever the attributes say: we split the paragraph in
903  // MustFit case if necessary
904  if( bPrepMustFit )
905  {
906  aFrameBreak.SetKeep( false );
907  aFrameBreak.ClrOrphLines();
908  }
909  // Before calling FormatAdjust, we need to make sure
910  // that the lines protruding at the bottom get indeed
911  // truncated
912  bool bBreak = aFrameBreak.IsBreakNowWidAndOrp( aLine );
913  bRet = true;
914  while( !bBreak && aLine.Next() )
915  {
916  bBreak = aFrameBreak.IsBreakNowWidAndOrp( aLine );
917  }
918  if( bBreak )
919  {
920  // We run into troubles: when TruncLines is called, the
921  // conditions in IsInside change immediately such that
922  // IsBreakNow can return different results.
923  // For this reason, we tell rFrameBreak that the
924  // end is reached at the location of rLine.
925  // Let's see if it works ...
926  aLine.TruncLines();
927  aFrameBreak.SetRstHeight( aLine );
928  FormatAdjust( aLine, aFrameBreak, TextFrameIndex(aInf.GetText().getLength()), aInf.IsStop() );
929  }
930  else
931  {
932  if( !GetFollow() )
933  {
934  FormatAdjust( aLine, aFrameBreak,
935  TextFrameIndex(aInf.GetText().getLength()), aInf.IsStop() );
936  }
937  else if ( !aFrameBreak.IsKeepAlways() )
938  {
939  // We delete a line before the Master, because the Follow
940  // could hand over a line
941  const SwCharRange aFollowRg(GetFollow()->GetOffset(), TextFrameIndex(1));
942  pPara->GetReformat() += aFollowRg;
943  // We should continue!
944  bRet = false;
945  }
946  }
947  }
948 
949  // A final check, if FormatAdjust() didn't help we need to
950  // truncate
951  if( bPrepMustFit )
952  {
953  const SwTwips nMust = aRectFnSet.GetPrtBottom(*GetUpper());
954  const SwTwips nIs = aRectFnSet.GetBottom(getFrameArea());
955 
956  if( aRectFnSet.IsVert() && nIs < nMust )
957  {
958  Shrink( nMust - nIs );
959 
960  if( getFramePrintArea().Width() < 0 )
961  {
963  aPrt.Width( 0 );
964  }
965 
966  SetUndersized( true );
967  }
968  else if ( ! aRectFnSet.IsVert() && nIs > nMust )
969  {
970  Shrink( nIs - nMust );
971 
972  if( getFramePrintArea().Height() < 0 )
973  {
975  aPrt.Height( 0 );
976  }
977 
978  SetUndersized( true );
979  }
980  }
981  }
982  }
983  pPara->SetPrepMustFit( bPrepMustFit );
984  return bRet;
985 }
986 
987 // Move the as-character objects - footnotes must be moved by RemoveFootnote!
989 {
990  if( pFrame->GetOffset() < nNew )
991  pFrame->MoveFlyInCnt( this, TextFrameIndex(0), nNew );
992  else if( pFrame->GetOffset() > nNew )
993  MoveFlyInCnt( pFrame, nNew, TextFrameIndex(COMPLETE_STRING) );
994 }
995 
997  WidowsAndOrphans &rFrameBreak,
998  TextFrameIndex const nStrLen,
999  const bool bDummy )
1000 {
1001  SwSwapIfNotSwapped swap( this );
1002 
1003  SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1004 
1005  TextFrameIndex nEnd = rLine.GetStart();
1006 
1007  const bool bHasToFit = pPara->IsPrepMustFit();
1008 
1009  // The StopFlag is set by footnotes which want to go onto the next page
1010  // Call base class method <SwTextFrameBreak::IsBreakNow(..)>
1011  // instead of method <WidowsAndOrphans::IsBreakNow(..)> to get a break,
1012  // even if due to widow rule no enough lines exists.
1013  sal_uInt8 nNew = ( !GetFollow() &&
1014  nEnd < nStrLen &&
1015  ( rLine.IsStop() ||
1016  ( bHasToFit
1017  ? ( rLine.GetLineNr() > 1 &&
1018  !rFrameBreak.IsInside( rLine ) )
1019  : rFrameBreak.IsBreakNow( rLine ) ) ) )
1020  ? 1 : 0;
1021  // i#84870
1022  // no split of text frame, which only contains an as-character anchored object
1023  bool bOnlyContainsAsCharAnchoredObj =
1024  !IsFollow() && nStrLen == TextFrameIndex(1) &&
1025  GetDrawObjs() && GetDrawObjs()->size() == 1 &&
1026  (*GetDrawObjs())[0]->GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR;
1027 
1028  // Still try split text frame if we have columns.
1029  if (FindColFrame())
1030  bOnlyContainsAsCharAnchoredObj = false;
1031 
1032  if ( nNew && bOnlyContainsAsCharAnchoredObj )
1033  {
1034  nNew = 0;
1035  }
1036 
1037  if ( nNew )
1038  {
1039  SplitFrame( nEnd );
1040  }
1041 
1042  const SwFrame *pBodyFrame = FindBodyFrame();
1043 
1044  const tools::Long nBodyHeight = pBodyFrame ? ( IsVertical() ?
1045  pBodyFrame->getFrameArea().Width() :
1046  pBodyFrame->getFrameArea().Height() ) : 0;
1047 
1048  // If the current values have been calculated, show that they
1049  // are valid now
1050  pPara->GetReformat() = SwCharRange();
1051  bool bDelta = pPara->GetDelta() != 0;
1052  pPara->GetDelta() = 0;
1053 
1054  if( rLine.IsStop() )
1055  {
1056  rLine.TruncLines( true );
1057  nNew = 1;
1058  }
1059 
1060  // FindBreak truncates the last line
1061  if( !rFrameBreak.FindBreak( this, rLine, bHasToFit ) )
1062  {
1063  // If we're done formatting, we set nEnd to the end.
1064  // AdjustFollow might execute JoinFrame() because of this.
1065  // Else, nEnd is the end of the last line in the Master.
1066  TextFrameIndex nOld = nEnd;
1067  nEnd = rLine.GetEnd();
1068  if( GetFollow() )
1069  {
1070  if( nNew && nOld < nEnd )
1071  RemoveFootnote( nOld, nEnd - nOld );
1072  ChangeOffset( GetFollow(), nEnd );
1073  if( !bDelta )
1074  GetFollow()->ManipOfst( nEnd );
1075  }
1076  }
1077  else
1078  { // If we pass over lines, we must not call Join in Follows, instead we even
1079  // need to create a Follow.
1080  // We also need to do this if the whole mass of text remains in the Master,
1081  // because a hard line break could necessitate another line (without text mass)!
1082  TextFrameIndex const nOld(nEnd);
1083  nEnd = rLine.GetEnd();
1084  if( GetFollow() )
1085  {
1086  // Another case for not joining the follow:
1087  // Text frame has no content, but a numbering. Then, do *not* join.
1088  // Example of this case: When an empty, but numbered paragraph
1089  // at the end of page is completely displaced by a fly frame.
1090  // Thus, the text frame introduced a follow by a
1091  // <SwTextFrame::SplitFrame(..)> - see below. The follow then shows
1092  // the numbering and must stay.
1093  if ( GetFollow()->GetOffset() != nEnd ||
1094  GetFollow()->IsFieldFollow() ||
1095  (nStrLen == TextFrameIndex(0) && GetTextNodeForParaProps()->GetNumRule()))
1096  {
1097  nNew |= 3;
1098  }
1099  else if (FindTabFrame() && nEnd > TextFrameIndex(0) &&
1100  rLine.GetInfo().GetChar(nEnd - TextFrameIndex(1)) == CH_BREAK)
1101  {
1102  // We are in a table, the paragraph has a follow and the text
1103  // ends with a hard line break. Don't join the follow just
1104  // because the follow would have no content, we may still need it
1105  // for the paragraph mark.
1106  nNew |= 1;
1107  }
1108  // move footnotes if the follow is kept - if RemoveFootnote() is
1109  // called in next format iteration, it will be with the *new*
1110  // offset so no effect!
1111  if (nNew && nOld < nEnd)
1112  {
1113  RemoveFootnote(nOld, nEnd - nOld);
1114  }
1115  ChangeOffset( GetFollow(), nEnd );
1116  GetFollow()->ManipOfst( nEnd );
1117  }
1118  else
1119  {
1120  // Only split frame, if the frame contains
1121  // content or contains no content, but has a numbering.
1122  // i#84870 - No split, if text frame only contains one
1123  // as-character anchored object.
1124  if ( !bOnlyContainsAsCharAnchoredObj &&
1125  (nStrLen > TextFrameIndex(0) ||
1126  (nStrLen == TextFrameIndex(0) && GetTextNodeForParaProps()->GetNumRule()))
1127  )
1128  {
1129  SplitFrame( nEnd );
1130  nNew |= 3;
1131  }
1132  }
1133  // If the remaining height changed e.g by RemoveFootnote() we need to
1134  // fill up in order to avoid oscillation.
1135  if( bDummy && pBodyFrame &&
1136  nBodyHeight < ( IsVertical() ?
1137  pBodyFrame->getFrameArea().Width() :
1138  pBodyFrame->getFrameArea().Height() ) )
1139  rLine.MakeDummyLine();
1140  }
1141 
1142  // In AdjustFrame() we set ourselves via Grow/Shrink
1143  // In AdjustFollow() we set our FollowFrame
1144 
1145  const SwTwips nDocPrtTop = getFrameArea().Top() + getFramePrintArea().Top();
1146  const SwTwips nOldHeight = getFramePrintArea().SSize().Height();
1147  SwTwips nChg = rLine.CalcBottomLine() - nDocPrtTop - nOldHeight;
1148 
1149  //#i84870# - no shrink of text frame, if it only contains one as-character anchored object.
1150  if ( nChg < 0 && !bDelta && bOnlyContainsAsCharAnchoredObj )
1151  {
1152  nChg = 0;
1153  }
1154 
1155  // Vertical Formatting:
1156  // The (rotated) repaint rectangle's x coordinate refers to the frame.
1157  // If the frame grows (or shirks) the repaint rectangle cannot simply
1158  // be rotated back after formatting, because we use the upper left point
1159  // of the frame for rotation. This point changes when growing/shrinking.
1160 
1161  if ( IsVertical() && !IsVertLR() && nChg )
1162  {
1163  SwRect &rRepaint = pPara->GetRepaint();
1164  rRepaint.Left( rRepaint.Left() - nChg );
1165  rRepaint.Width( rRepaint.Width() - nChg );
1166  }
1167 
1168  AdjustFrame( nChg, bHasToFit );
1169 
1170  if( HasFollow() || IsInFootnote() )
1171  AdjustFollow_( rLine, nEnd, nStrLen, nNew );
1172 
1173  pPara->SetPrepMustFit( false );
1174 }
1175 
1176 // bPrev is set whether Reformat.Start() was called because of Prev().
1177 // Else, wo don't know whether we can limit the repaint or not.
1178 bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev )
1179 {
1180  OSL_ENSURE( ! IsVertical() || IsSwapped(),
1181  "SwTextFrame::FormatLine( rLine, bPrev) with unswapped frame" );
1182  SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1183  const SwLineLayout *pOldCur = rLine.GetCurr();
1184  const TextFrameIndex nOldLen = pOldCur->GetLen();
1185  const sal_uInt32 nOldAscent = pOldCur->GetAscent();
1186  const sal_uInt32 nOldHeight = pOldCur->Height();
1187  const SwTwips nOldWidth = pOldCur->Width() + pOldCur->GetHangingMargin();
1188  const bool bOldHyph = pOldCur->IsEndHyph();
1189  SwTwips nOldTop = 0;
1190  SwTwips nOldBottom = 0;
1191  if( rLine.GetCurr()->IsClipping() )
1192  rLine.CalcUnclipped( nOldTop, nOldBottom );
1193 
1194  TextFrameIndex const nNewStart = rLine.FormatLine( rLine.GetStart() );
1195 
1196  OSL_ENSURE( getFrameArea().Pos().Y() + getFramePrintArea().Pos().Y() == rLine.GetFirstPos(),
1197  "SwTextFrame::FormatLine: frame leaves orbit." );
1198  OSL_ENSURE( rLine.GetCurr()->Height(),
1199  "SwTextFrame::FormatLine: line height is zero" );
1200 
1201  // The current line break object
1202  const SwLineLayout *pNew = rLine.GetCurr();
1203 
1204  bool bUnChg = nOldLen == pNew->GetLen() &&
1205  bOldHyph == pNew->IsEndHyph();
1206  if ( bUnChg && !bPrev )
1207  {
1208  const tools::Long nWidthDiff = nOldWidth > o3tl::narrowing<SwTwips>(pNew->Width())
1209  ? nOldWidth - pNew->Width()
1210  : pNew->Width() - nOldWidth;
1211 
1212  // we only declare a line as unchanged, if its main values have not
1213  // changed and it is not the last line (!paragraph end symbol!)
1214  bUnChg = nOldHeight == pNew->Height() &&
1215  nOldAscent == pNew->GetAscent() &&
1216  nWidthDiff <= SLOPPY_TWIPS &&
1217  pOldCur->GetNext();
1218  }
1219 
1220  // Calculate rRepaint
1221  const SwTwips nBottom = rLine.Y() + rLine.GetLineHeight();
1222  SwRepaint &rRepaint = pPara->GetRepaint();
1223  if( bUnChg && rRepaint.Top() == rLine.Y()
1224  && (bPrev || nNewStart <= pPara->GetReformat().Start())
1225  && (nNewStart < TextFrameIndex(GetText().getLength())))
1226  {
1227  rRepaint.Top( nBottom );
1228  rRepaint.Height( 0 );
1229  }
1230  else
1231  {
1232  if( nOldTop )
1233  {
1234  if( nOldTop < rRepaint.Top() )
1235  rRepaint.Top( nOldTop );
1236  if( !rLine.IsUnclipped() || nOldBottom > rRepaint.Bottom() )
1237  {
1238  rRepaint.Bottom( nOldBottom - 1 );
1239  rLine.SetUnclipped( true );
1240  }
1241  }
1242  if( rLine.GetCurr()->IsClipping() && rLine.IsFlyInCntBase() )
1243  {
1244  SwTwips nTmpTop, nTmpBottom;
1245  rLine.CalcUnclipped( nTmpTop, nTmpBottom );
1246  if( nTmpTop < rRepaint.Top() )
1247  rRepaint.Top( nTmpTop );
1248  if( !rLine.IsUnclipped() || nTmpBottom > rRepaint.Bottom() )
1249  {
1250  rRepaint.Bottom( nTmpBottom - 1 );
1251  rLine.SetUnclipped( true );
1252  }
1253  }
1254  else
1255  {
1256  if( !rLine.IsUnclipped() || nBottom > rRepaint.Bottom() )
1257  {
1258  rRepaint.Bottom( nBottom - 1 );
1259  rLine.SetUnclipped( false );
1260  }
1261  }
1262  SwTwips nRght = std::max( nOldWidth, o3tl::narrowing<SwTwips>(pNew->Width()) +
1263  pNew->GetHangingMargin() );
1265  const SwViewOption *pOpt = pSh ? pSh->GetViewOptions() : nullptr;
1266  if( pOpt && (pOpt->IsParagraph() || pOpt->IsLineBreak()) )
1267  nRght += ( std::max( nOldAscent, pNew->GetAscent() ) );
1268  else
1269  nRght += ( std::max( nOldAscent, pNew->GetAscent() ) / 4);
1270  nRght += rLine.GetLeftMargin();
1271  if( rRepaint.GetOffset() || rRepaint.GetRightOfst() < nRght )
1272  rRepaint.SetRightOfst( nRght );
1273 
1274  // Finally we enlarge the repaint rectangle if we found an underscore
1275  // within our line. 40 Twips should be enough
1276  const bool bHasUnderscore =
1277  ( rLine.GetInfo().GetUnderScorePos() < nNewStart );
1278  if ( bHasUnderscore || rLine.GetCurr()->HasUnderscore() )
1279  rRepaint.Bottom( rRepaint.Bottom() + 40 );
1280 
1281  const_cast<SwLineLayout*>(rLine.GetCurr())->SetUnderscore( bHasUnderscore );
1282  }
1283 
1284  // Calculating the good ol' nDelta
1285  pPara->GetDelta() -= sal_Int32(pNew->GetLen()) - sal_Int32(nOldLen);
1286 
1287  // Stop!
1288  if( rLine.IsStop() )
1289  return false;
1290 
1291  // Absolutely another line
1292  if( rLine.IsNewLine() )
1293  return true;
1294 
1295  // Until the String's end?
1296  if (nNewStart >= TextFrameIndex(GetText().getLength()))
1297  return false;
1298 
1299  if( rLine.GetInfo().IsShift() )
1300  return true;
1301 
1302  // Reached the Reformat's end?
1303  const TextFrameIndex nEnd = pPara->GetReformat().Start() +
1304  pPara->GetReformat().Len();
1305 
1306  if( nNewStart <= nEnd )
1307  return true;
1308 
1309  return 0 != pPara->GetDelta();
1310 }
1311 
1313  const bool bAdjust )
1314 {
1315  OSL_ENSURE( ! IsVertical() || IsSwapped(),"SwTextFrame::Format_ with unswapped frame" );
1316 
1317  SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1318  rLine.SetUnclipped( false );
1319 
1320  const OUString & rString = GetText();
1321  const TextFrameIndex nStrLen(rString.getLength());
1322 
1323  SwCharRange &rReformat = pPara->GetReformat();
1324  SwRepaint &rRepaint = pPara->GetRepaint();
1325  std::unique_ptr<SwRepaint> pFreeze;
1326 
1327  // Due to performance reasons we set rReformat to COMPLETE_STRING in Init()
1328  // In this case we adjust rReformat
1329  if( rReformat.Len() > nStrLen )
1330  rReformat.Len() = nStrLen;
1331 
1332  if( rReformat.Start() + rReformat.Len() > nStrLen )
1333  rReformat.Len() = nStrLen - rReformat.Start();
1334 
1335  SwTwips nOldBottom;
1336  if( GetOffset() && !IsFollow() )
1337  {
1338  rLine.Bottom();
1339  nOldBottom = rLine.Y();
1340  rLine.Top();
1341  }
1342  else
1343  nOldBottom = 0;
1344  rLine.CharToLine( rReformat.Start() );
1345 
1346  // When inserting or removing a Space, words can be moved out of the edited
1347  // line and into the preceding line, hence the preceding line must be
1348  // formatted as well.
1349  // Optimization: If rReformat starts after the first word of the line,
1350  // this line cannot possibly influence the previous one.
1351  // ...Turns out that unfortunately it can: Text size changes + FlyFrames;
1352  // the feedback can affect multiple lines (Frames!)!
1353 
1354  // i#46560
1355  // FME: Yes, consider this case: "(word )" has to go to the next line
1356  // because ")" is a forbidden character at the beginning of a line although
1357  // "(word" would still fit on the previous line. Adding text right in front
1358  // of ")" would not trigger a reformatting of the previous line. Adding 1
1359  // to the result of FindBrk() does not solve the problem in all cases,
1360  // nevertheless it should be sufficient.
1361  bool bPrev = rLine.GetPrev() &&
1362  (FindBrk(rString, rLine.GetStart(), rReformat.Start() + TextFrameIndex(1))
1363  // i#46560
1364  + TextFrameIndex(1)
1365  >= rReformat.Start() ||
1366  rLine.GetCurr()->IsRest() );
1367  if( bPrev )
1368  {
1369  while( rLine.Prev() )
1370  if( rLine.GetCurr()->GetLen() && !rLine.GetCurr()->IsRest() )
1371  {
1372  if( !rLine.GetStart() )
1373  rLine.Top(); // So that NumDone doesn't get confused
1374  break;
1375  }
1376  TextFrameIndex nNew = rLine.GetStart() + rLine.GetLength();
1377  if( nNew )
1378  {
1379  --nNew;
1380  if (CH_BREAK == rString[sal_Int32(nNew)])
1381  {
1382  ++nNew;
1383  rLine.Next();
1384  bPrev = false;
1385  }
1386  }
1387  rReformat.Len() += rReformat.Start() - nNew;
1388  rReformat.Start() = nNew;
1389  }
1390 
1391  rRepaint.SetOffset( 0 );
1392  rRepaint.SetRightOfst( 0 );
1393  rRepaint.Chg( getFrameArea().Pos() + getFramePrintArea().Pos(), getFramePrintArea().SSize() );
1394  if( pPara->IsMargin() )
1395  rRepaint.Width( rRepaint.Width() + pPara->GetHangingMargin() );
1396  rRepaint.Top( rLine.Y() );
1397  if( 0 >= rRepaint.Width() )
1398  rRepaint.Width(1);
1399  WidowsAndOrphans aFrameBreak( this, rInf.IsTest() ? 1 : 0 );
1400 
1401  // rLine is now set to the first line which needs formatting.
1402  // The bFirst flag makes sure that Next() is not called.
1403  // The whole thing looks weird, but we need to make sure that
1404  // rLine stops at the last non-fitting line when calling IsBreakNow.
1405  bool bFirst = true;
1406  bool bFormat = true;
1407 
1408  // The CharToLine() can also get us into the danger zone.
1409  // In that case we need to walk back until rLine is set
1410  // to the non-fitting line. Or else the mass of text is lost,
1411  // because the Ofst was set wrongly in the Follow.
1412 
1413  bool bBreak = ( !pPara->IsPrepMustFit() || rLine.GetLineNr() > 1 )
1414  && aFrameBreak.IsBreakNowWidAndOrp( rLine );
1415  if( bBreak )
1416  {
1417  bool bPrevDone = nullptr != rLine.Prev();
1418  while( bPrevDone && aFrameBreak.IsBreakNowWidAndOrp(rLine) )
1419  bPrevDone = nullptr != rLine.Prev();
1420  if( bPrevDone )
1421  {
1422  aFrameBreak.SetKeep( false );
1423  rLine.Next();
1424  }
1425  rLine.TruncLines();
1426 
1427  // Play it safe
1428  aFrameBreak.IsBreakNowWidAndOrp(rLine);
1429  }
1430 
1431  /* Meaning if the following flags are set:
1432 
1433  Watch(End/Mid)Hyph: we need to format if we have a break at
1434  the line end/Fly, as long as MaxHyph is reached
1435 
1436  Jump(End/Mid)Flag: the next line which has no break (line end/Fly),
1437  needs to be formatted, because we could wrap now. This might have been
1438  forbidden earlier by MaxHyph
1439 
1440  Watch(End/Mid)Hyph: if the last formatted line got a cutoff point, but
1441  didn't have one before
1442 
1443  Jump(End/Mid)Hyph: if a cutoff point disappears
1444  */
1445  bool bJumpEndHyph = false;
1446  bool bWatchEndHyph = false;
1447  bool bJumpMidHyph = false;
1448  bool bWatchMidHyph = false;
1449 
1450  const SwAttrSet& rAttrSet = GetTextNodeForParaProps()->GetSwAttrSet();
1451  rInf.MaxHyph() = rAttrSet.GetHyphenZone().GetMaxHyphens();
1452  bool bMaxHyph = 0 != rInf.MaxHyph();
1453  if ( bMaxHyph )
1454  rLine.InitCntHyph();
1455 
1456  if( IsFollow() && IsFieldFollow() && rLine.GetStart() == GetOffset() )
1457  {
1458  SwTextFrame *pMaster = FindMaster();
1459  OSL_ENSURE( pMaster, "SwTextFrame::Format: homeless follow" );
1460  const SwLineLayout* pLine=nullptr;
1461  if (pMaster)
1462  {
1463  if (!pMaster->HasPara())
1464  { // master could be locked because it's being formatted upstack
1465  SAL_WARN("sw", "SwTextFrame::Format_: master not formatted!");
1466  }
1467  else
1468  {
1469  SwTextSizeInfo aInf( pMaster );
1470  SwTextIter aMasterLine( pMaster, &aInf );
1471  aMasterLine.Bottom();
1472  pLine = aMasterLine.GetCurr();
1473  assert(aMasterLine.GetEnd() == GetOffset());
1474  }
1475  }
1476  SwLinePortion* pRest = pLine ?
1477  rLine.MakeRestPortion(pLine, GetOffset()) : nullptr;
1478  if( pRest )
1479  rInf.SetRest( pRest );
1480  else
1481  SetFieldFollow( false );
1482  }
1483 
1484  /* Ad cancel criterion:
1485  * In order to recognize, whether a line does not fit onto the page
1486  * anymore, we need to format it. This overflow is removed again in
1487  * e.g. AdjustFollow.
1488  * Another complication: if we are the Master, we need to traverse
1489  * the lines, because it could happen that one line can overflow
1490  * from the Follow to the Master.
1491  */
1492  do
1493  {
1494  if( bFirst )
1495  bFirst = false;
1496  else
1497  {
1498  if ( bMaxHyph )
1499  {
1500  if ( rLine.GetCurr()->IsEndHyph() )
1501  rLine.CntEndHyph()++;
1502  else
1503  rLine.CntEndHyph() = 0;
1504  if ( rLine.GetCurr()->IsMidHyph() )
1505  rLine.CntMidHyph()++;
1506  else
1507  rLine.CntMidHyph() = 0;
1508  }
1509  if( !rLine.Next() )
1510  {
1511  if( !bFormat )
1512  {
1513  SwLinePortion* pRest =
1514  rLine.MakeRestPortion( rLine.GetCurr(), rLine.GetEnd() );
1515  if( pRest )
1516  rInf.SetRest( pRest );
1517  }
1518  rLine.Insert( new SwLineLayout() );
1519  rLine.Next();
1520  bFormat = true;
1521  }
1522  }
1523  if ( !bFormat && bMaxHyph &&
1524  (bWatchEndHyph || bJumpEndHyph || bWatchMidHyph || bJumpMidHyph) )
1525  {
1526  if ( rLine.GetCurr()->IsEndHyph() )
1527  {
1528  if ( bWatchEndHyph )
1529  bFormat = ( rLine.CntEndHyph() == rInf.MaxHyph() );
1530  }
1531  else
1532  {
1533  bFormat = bJumpEndHyph;
1534  bWatchEndHyph = false;
1535  bJumpEndHyph = false;
1536  }
1537  if ( rLine.GetCurr()->IsMidHyph() )
1538  {
1539  if ( bWatchMidHyph && !bFormat )
1540  bFormat = ( rLine.CntEndHyph() == rInf.MaxHyph() );
1541  }
1542  else
1543  {
1544  bFormat |= bJumpMidHyph;
1545  bWatchMidHyph = false;
1546  bJumpMidHyph = false;
1547  }
1548  }
1549  if( bFormat )
1550  {
1551  const bool bOldEndHyph = rLine.GetCurr()->IsEndHyph();
1552  const bool bOldMidHyph = rLine.GetCurr()->IsMidHyph();
1553  bFormat = FormatLine( rLine, bPrev );
1554  // There can only be one bPrev ... (???)
1555  bPrev = false;
1556  if ( bMaxHyph )
1557  {
1558  if ( rLine.GetCurr()->IsEndHyph() != bOldEndHyph )
1559  {
1560  bWatchEndHyph = !bOldEndHyph;
1561  bJumpEndHyph = bOldEndHyph;
1562  }
1563  if ( rLine.GetCurr()->IsMidHyph() != bOldMidHyph )
1564  {
1565  bWatchMidHyph = !bOldMidHyph;
1566  bJumpMidHyph = bOldMidHyph;
1567  }
1568  }
1569  }
1570 
1571  if( !rInf.IsNewLine() )
1572  {
1573  if( !bFormat )
1574  bFormat = nullptr != rInf.GetRest();
1575  if( rInf.IsStop() || rInf.GetIdx() >= nStrLen )
1576  break;
1577  if( !bFormat && ( !bMaxHyph || ( !bWatchEndHyph &&
1578  !bJumpEndHyph && !bWatchMidHyph && !bJumpMidHyph ) ) )
1579  {
1580  if( GetFollow() )
1581  {
1582  while( rLine.Next() )
1583  ; //Nothing
1584  pFreeze.reset(new SwRepaint( rRepaint )); // to minimize painting
1585  }
1586  else
1587  break;
1588  }
1589  }
1590  bBreak = aFrameBreak.IsBreakNowWidAndOrp(rLine);
1591  }while( !bBreak );
1592 
1593  if( pFreeze )
1594  {
1595  rRepaint = *pFreeze;
1596  pFreeze.reset();
1597  }
1598 
1599  if( !rLine.IsStop() )
1600  {
1601  // If we're finished formatting the text and we still
1602  // have other line objects left, these are superfluous
1603  // now because the text has gotten shorter.
1604  if( rLine.GetStart() + rLine.GetLength() >= nStrLen &&
1605  rLine.GetCurr()->GetNext() )
1606  {
1607  rLine.TruncLines();
1608  rLine.SetTruncLines( true );
1609  }
1610  }
1611 
1612  if( rInf.IsTest() )
1613  return;
1614 
1615  // FormatAdjust does not pay off at OnceMore
1616  if( bAdjust || !rLine.GetDropFormat() || !rLine.CalcOnceMore() )
1617  {
1618  FormatAdjust( rLine, aFrameBreak, nStrLen, rInf.IsStop() );
1619  }
1620  if( rRepaint.HasArea() )
1621  SetRepaint();
1622  rLine.SetTruncLines( false );
1623  if( nOldBottom ) // We check whether paragraphs that need scrolling can
1624  // be shrunk, so that they don't need scrolling anymore
1625  {
1626  rLine.Bottom();
1627  SwTwips nNewBottom = rLine.Y();
1628  if( nNewBottom < nOldBottom )
1630  }
1631 }
1632 
1634 {
1635  OSL_ENSURE( ! IsVertical() || IsSwapped(),
1636  "A frame is not swapped in SwTextFrame::FormatOnceMore" );
1637 
1638  SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1639  if( !pPara )
1640  return;
1641 
1642  // If necessary the pPara
1643  sal_uInt16 nOld = static_cast<const SwTextMargin&>(rLine).GetDropHeight();
1644  bool bShrink = false;
1645  bool bGrow = false;
1646  bool bGoOn = rLine.IsOnceMore();
1647  sal_uInt8 nGo = 0;
1648  while( bGoOn )
1649  {
1650  ++nGo;
1651  rInf.Init();
1652  rLine.Top();
1653  if( !rLine.GetDropFormat() )
1654  rLine.SetOnceMore( false );
1655  SwCharRange aRange(TextFrameIndex(0), TextFrameIndex(rInf.GetText().getLength()));
1656  pPara->GetReformat() = aRange;
1657  Format_( rLine, rInf );
1658 
1659  bGoOn = rLine.IsOnceMore();
1660  if( bGoOn )
1661  {
1662  const sal_uInt16 nNew = static_cast<const SwTextMargin&>(rLine).GetDropHeight();
1663  if( nOld == nNew )
1664  bGoOn = false;
1665  else
1666  {
1667  if( nOld > nNew )
1668  bShrink = true;
1669  else
1670  bGrow = true;
1671 
1672  if( bShrink == bGrow || 5 < nGo )
1673  bGoOn = false;
1674 
1675  nOld = nNew;
1676  }
1677 
1678  // If something went wrong, we need to reformat again
1679  if( !bGoOn )
1680  {
1681  rInf.CtorInitTextFormatInfo( getRootFrame()->GetCurrShell()->GetOut(), this );
1682  rLine.CtorInitTextFormatter( this, &rInf );
1683  rLine.SetDropLines( 1 );
1684  rLine.CalcDropHeight( 1 );
1685  SwCharRange aTmpRange(TextFrameIndex(0), TextFrameIndex(rInf.GetText().getLength()));
1686  pPara->GetReformat() = aTmpRange;
1687  Format_( rLine, rInf, true );
1688  // We paint everything ...
1689  SetCompletePaint();
1690  }
1691  }
1692  }
1693 }
1694 
1696 {
1697  const bool bIsEmpty = GetText().isEmpty();
1698 
1699  if ( bIsEmpty )
1700  {
1701  // Empty lines do not get tortured for very long:
1702  // pPara is cleared, which is the same as:
1703  // *pPara = SwParaPortion;
1704  const bool bMustFit = pPara->IsPrepMustFit();
1705  pPara->Truncate();
1706  pPara->FormatReset();
1707 
1708  // delete pSpaceAdd and pKanaComp
1709  pPara->FinishSpaceAdd();
1710  pPara->FinishKanaComp();
1711  pPara->ResetFlags();
1712  pPara->SetPrepMustFit( bMustFit );
1713  }
1714 
1715  OSL_ENSURE( ! IsSwapped(), "A frame is swapped before Format_" );
1716 
1717  if ( IsVertical() )
1719 
1720  SwTextFormatInfo aInf( pRenderContext, this );
1721  SwTextFormatter aLine( this, &aInf );
1722 
1724 
1725  Format_( aLine, aInf );
1726 
1727  if( aLine.IsOnceMore() )
1728  FormatOnceMore( aLine, aInf );
1729 
1730  if ( IsVertical() )
1732 
1733  OSL_ENSURE( ! IsSwapped(), "A frame is swapped after Format_" );
1734 
1735  if( 1 >= aLine.GetDropLines() )
1736  return;
1737 
1738  if( SvxAdjust::Left != aLine.GetAdjust() &&
1739  SvxAdjust::Block != aLine.GetAdjust() )
1740  {
1741  aLine.CalcDropAdjust();
1742  aLine.SetPaintDrop( true );
1743  }
1744 
1745  if( aLine.IsPaintDrop() )
1746  {
1747  aLine.CalcDropRepaint();
1748  aLine.SetPaintDrop( false );
1749  }
1750 }
1751 
1752 // We calculate the text frame's size and send a notification.
1753 // Shrink() or Grow() to adjust the frame's size to the changed required space.
1754 void SwTextFrame::Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs * )
1755 {
1756  SwRectFnSet aRectFnSet(this);
1757 
1759 
1760  // The range autopilot or the BASIC interface pass us TextFrames with
1761  // a width <= 0 from time to time
1762  if( aRectFnSet.GetWidth(getFramePrintArea()) <= 0 )
1763  {
1764  // If MustFit is set, we shrink to the Upper's bottom edge if needed.
1765  // Else we just take a standard size of 12 Pt. (240 twip).
1766  SwTextLineAccess aAccess( this );
1767  tools::Long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
1768 
1769  if( aAccess.GetPara()->IsPrepMustFit() )
1770  {
1771  const SwTwips nLimit = aRectFnSet.GetPrtBottom(*GetUpper());
1772  const SwTwips nDiff = - aRectFnSet.BottomDist( getFrameArea(), nLimit );
1773  if( nDiff > 0 )
1774  Shrink( nDiff );
1775  }
1776  else if( 240 < nFrameHeight )
1777  {
1778  Shrink( nFrameHeight - 240 );
1779  }
1780  else if( 240 > nFrameHeight )
1781  {
1782  Grow( 240 - nFrameHeight );
1783  }
1784 
1785  nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
1786  const tools::Long nTop = aRectFnSet.GetTopMargin(*this);
1787 
1788  if( nTop > nFrameHeight )
1789  {
1790  aRectFnSet.SetYMargins( *this, nFrameHeight, 0 );
1791  }
1792  else if( aRectFnSet.GetHeight(getFramePrintArea()) < 0 )
1793  {
1795  aRectFnSet.SetHeight( aPrt, 0 );
1796  }
1797 
1798  return;
1799  }
1800 
1801  const TextFrameIndex nStrLen(GetText().getLength());
1802  if ( nStrLen || !FormatEmpty() )
1803  {
1804 
1805  SetEmpty( false );
1806  // In order to not get confused by nested Formats
1807  FormatLevel aLevel;
1808  if( 12 == FormatLevel::GetLevel() )
1809  return;
1810 
1811  // We could be possibly not allowed to alter the format information
1812  if( IsLocked() )
1813  return;
1814 
1815  // Attention: Format() could be triggered by GetFormatted()
1816  if( IsHiddenNow() )
1817  {
1818  tools::Long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
1819  if( nPrtHeight )
1820  {
1821  HideHidden();
1822  Shrink( nPrtHeight );
1823  }
1824  else
1825  {
1826  // Assure that objects anchored
1827  // at paragraph resp. at/as character inside paragraph
1828  // are hidden.
1830  }
1831  ChgThisLines();
1832  return;
1833  }
1834 
1835  // We do not want to be interrupted during formatting
1836  TextFrameLockGuard aLock(this);
1837 
1838  // this is to ensure that the similar code in SwTextFrame::Format_
1839  // finds the master formatted in case it's needed
1840  if (IsFollow() && IsFieldFollow())
1841  {
1842  SwTextFrame *pMaster = FindMaster();
1843  assert(pMaster);
1844  if (!pMaster->HasPara())
1845  {
1846  pMaster->GetFormatted();
1847  }
1848  if (!pMaster->HasPara())
1849  { // master could be locked because it's being formatted upstack
1850  SAL_WARN("sw", "SwTextFrame::Format: failed to format master!");
1851  }
1852  else
1853  {
1854  SwTextSizeInfo aInf( pMaster );
1855  SwTextIter aMasterLine( pMaster, &aInf );
1856  aMasterLine.Bottom();
1857  SetOffset(aMasterLine.GetEnd());
1858  }
1859  }
1860 
1861  SwTextLineAccess aAccess( this );
1862  const bool bNew = !aAccess.IsAvailable();
1863  const bool bSetOffset =
1865 
1866  if( CalcPreps() )
1867  ; // nothing
1868  // We return if already formatted, but if the TextFrame was just created
1869  // and does not have any format information
1870  else if( !bNew && !aAccess.GetPara()->GetReformat().Len() )
1871  {
1873  {
1874  aAccess.GetPara()->SetPrepAdjust();
1875  aAccess.GetPara()->SetPrep();
1876  CalcPreps();
1877  }
1878  SetWidow( false );
1879  }
1880  else if( bSetOffset && IsFollow() )
1881  {
1882  SwTextFrame *pMaster = FindMaster();
1883  OSL_ENSURE( pMaster, "SwTextFrame::Format: homeless follow" );
1884  if( pMaster )
1885  pMaster->Prepare( PrepareHint::FollowFollows );
1886  SwTwips nMaxY = aRectFnSet.GetPrtBottom(*GetUpper());
1887 
1888  if( aRectFnSet.OverStep( getFrameArea(), nMaxY ) )
1889  {
1890  aRectFnSet.SetLimit( *this, nMaxY );
1891  }
1892  else if( aRectFnSet.BottomDist( getFrameArea(), nMaxY ) < 0 )
1893  {
1895  aRectFnSet.AddBottom( aFrm, -aRectFnSet.GetHeight(aFrm) );
1896  }
1897  }
1898  else
1899  {
1900  // bSetOffset here means that we have the "red arrow situation"
1901  if ( bSetOffset )
1903 
1904  const bool bOrphan = IsWidow();
1905  const SwFootnoteBossFrame* pFootnoteBoss = HasFootnote() ? FindFootnoteBossFrame() : nullptr;
1906  SwTwips nFootnoteHeight = 0;
1907  if( pFootnoteBoss )
1908  {
1909  const SwFootnoteContFrame* pCont = pFootnoteBoss->FindFootnoteCont();
1910  nFootnoteHeight = pCont ? aRectFnSet.GetHeight(pCont->getFrameArea()) : 0;
1911  }
1912  do
1913  {
1914  Format_( pRenderContext, aAccess.GetPara() );
1915  if( pFootnoteBoss && nFootnoteHeight )
1916  {
1917  const SwFootnoteContFrame* pCont = pFootnoteBoss->FindFootnoteCont();
1918  SwTwips nNewHeight = pCont ? aRectFnSet.GetHeight(pCont->getFrameArea()) : 0;
1919  // If we lost some footnotes, we may have more space
1920  // for our main text, so we have to format again ...
1921  if( nNewHeight < nFootnoteHeight )
1922  nFootnoteHeight = nNewHeight;
1923  else
1924  break;
1925  }
1926  else
1927  break;
1928  } while ( pFootnoteBoss );
1929  if( bOrphan )
1930  {
1931  ValidateFrame();
1932  SetWidow( false );
1933  }
1934  }
1935  if( IsEmptyMaster() )
1936  {
1937  SwFrame* pPre = GetPrev();
1938  if( pPre &&
1939  // i#10826 It's the first, it cannot keep!
1940  pPre->GetIndPrev() &&
1941  pPre->GetAttrSet()->GetKeep().GetValue() )
1942  {
1943  pPre->InvalidatePos();
1944  }
1945  }
1946  }
1947 
1948  ChgThisLines();
1949 
1950  // the PrepMustFit should not survive a Format operation
1951  SwParaPortion *pPara = GetPara();
1952  if ( pPara )
1953  pPara->SetPrepMustFit( false );
1954 
1956  CalcHeightOfLastLine(); // i#11860 - Adjust spacing implementation for
1957  // object positioning - Compatibility to MS Word
1958  // tdf#117982 -- Fix cell spacing hides content
1959  // Check if the cell's content has greater size than the row height
1961  || (getFramePrintArea().Height() <= 0)))
1962  {
1963  SAL_INFO("sw.core", "Warn: Cell content has greater size than cell height!");
1964  //get font size...
1965  SwTwips aTmpHeight = getFrameArea().Height();
1966  //...and push it into the text frame
1968  //if only bottom margin what we have:
1969  if (GetTopMargin() == 0)
1970  //set the frame to its original location
1971  aPrt.SetTopAndHeight(0, aTmpHeight);
1972  }
1973 }
1974 
1975 // bForceQuickFormat is set if GetFormatted() has been called during the
1976 // painting process. Actually I cannot imagine a situation which requires
1977 // a full formatting of the paragraph during painting, on the other hand
1978 // a full formatting can cause the invalidation of other layout frames,
1979 // e.g., if there are footnotes in this paragraph, and invalid layout
1980 // frames will not calculated during the painting. So I actually want to
1981 // avoid a formatting during painting, but since I'm a coward, I'll only
1982 // force the quick formatting in the situation of issue i29062.
1983 bool SwTextFrame::FormatQuick( bool bForceQuickFormat )
1984 {
1985  OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
1986  "SwTextFrame::FormatQuick with swapped frame" );
1987 
1988  if( IsEmpty() && FormatEmpty() )
1989  return true;
1990 
1991  // We're very picky:
1992  if( HasPara() || IsWidow() || IsLocked()
1993  || !isFrameAreaSizeValid() ||
1995  return false;
1996 
1997  SwTextLineAccess aAccess( this );
1998  SwParaPortion *pPara = aAccess.GetPara();
1999  if( !pPara )
2000  return false;
2001 
2002  SwFrameSwapper aSwapper( this, true );
2003 
2004  TextFrameLockGuard aLock(this);
2005  SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true );
2006  if( 0 != aInf.MaxHyph() ) // Respect MaxHyphen!
2007  return false;
2008 
2009  SwTextFormatter aLine( this, &aInf );
2010 
2011  // DropCaps are too complicated ...
2012  if( aLine.GetDropFormat() )
2013  return false;
2014 
2015  TextFrameIndex nStart = GetOffset();
2016  const TextFrameIndex nEnd = GetFollow()
2017  ? GetFollow()->GetOffset()
2018  : TextFrameIndex(aInf.GetText().getLength());
2019 
2020  int nLoopProtection = 0;
2021  do
2022  {
2023  TextFrameIndex nNewStart = aLine.FormatLine(nStart);
2024  if (nNewStart == nStart)
2025  ++nLoopProtection;
2026  else
2027  nLoopProtection = 0;
2028  nStart = nNewStart;
2029  const bool bWillEndlessInsert = nLoopProtection > 250;
2030  SAL_WARN_IF(bWillEndlessInsert, "sw", "loop detection triggered");
2031  if ((!bWillEndlessInsert) // Check for special case: line is invisible,
2032  // like in too thin table cell: tdf#66141
2033  && (aInf.IsNewLine() || (!aInf.IsStop() && nStart < nEnd)))
2034  aLine.Insert( new SwLineLayout() );
2035  } while( aLine.Next() );
2036 
2037  // Last exit: the heights need to match
2038  Point aTopLeft( getFrameArea().Pos() );
2039  aTopLeft += getFramePrintArea().Pos();
2040  const SwTwips nNewHeight = aLine.Y() + aLine.GetLineHeight();
2041  const SwTwips nOldHeight = aTopLeft.Y() + getFramePrintArea().Height();
2042 
2043  if( !bForceQuickFormat && nNewHeight != nOldHeight && !IsUndersized() )
2044  {
2045  // Attention: This situation can occur due to FormatLevel==12. Don't panic!
2046  TextFrameIndex const nStrt = GetOffset();
2047  InvalidateRange_( SwCharRange( nStrt, nEnd - nStrt) );
2048  return false;
2049  }
2050 
2051  if (m_pFollow && nStart != static_cast<SwTextFrame*>(m_pFollow)->GetOffset())
2052  return false; // can be caused by e.g. Orphans
2053 
2054  // We made it!
2055 
2056  // Set repaint
2057  pPara->GetRepaint().Pos( aTopLeft );
2058  pPara->GetRepaint().SSize( getFramePrintArea().SSize() );
2059 
2060  // Delete reformat
2061  pPara->GetReformat() = SwCharRange();
2062  pPara->GetDelta() = 0;
2063 
2064  return true;
2065 }
2066 
2067 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void HideHidden()
Removes Textfrm's attachments, when it's hidden.
Definition: txtfrm.cxx:1445
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:207
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:338
bool GetValue() const
void CalcAdditionalFirstLineOffset()
Simulate format for a list item paragraph, whose list level attributes are in LABEL_ALIGNMENT mode...
Definition: txtfrm.cxx:3465
Base class of the Writer layout elements.
Definition: frame.hxx:313
sal_uInt8 & GetMaxHyphens()
const sal_Unicode CH_BREAK
Definition: swfont.hxx:43
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:158
bool FindBreak(SwTextFrame *pFrame, SwTextMargin &rLine, bool bHasToFit)
The Find*-Methods do not only search, but adjust the SwTextMargin to the line where the paragraph sho...
Definition: widorp.cxx:311
TextFrameIndex FormatQuoVadis(TextFrameIndex nStart)
Definition: txtftn.cxx:1034
void SwitchVerticalToHorizontal(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from vertical to horizontal layout...
Definition: txtfrm.cxx:582
const SvxHyphenZoneItem & GetHyphenZone(bool=true) const
Definition: paratr.hxx:206
sal_uLong GetIndex() const
Definition: node.hxx:291
void AllowFollowFormat()
Definition: txtfrm.hxx:748
void Right(const tools::Long nRight)
Definition: swrect.hxx:199
bool IsFollow() const
Definition: flowfrm.hxx:166
void SetRstHeight(const SwTextMargin &rLine)
Definition: widorp.cxx:214
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:563
void Right(const SwTwips nNew)
Definition: itrtxt.hxx:157
void CalcDropRepaint()
Definition: itradj.cxx:828
bool IsPrepAdjust() const
Definition: porlay.hxx:309
sal_uInt16 GetLineNr() const
Definition: itrtxt.hxx:87
bool IsClipping() const
Definition: porlay.hxx:154
void SetPrepAdjust()
Definition: porlay.hxx:308
sal_uInt32 GetParHeight() const
Returns the sum of line height in pLine.
Definition: txtfrm.cxx:3326
bool IsInFly() const
Definition: frame.hxx:958
virtual void Height(const sal_uInt32 nNew, const bool bText=true) override
Definition: porlay.cxx:202
bool FollowFormatAllowed() const
Definition: txtfrm.hxx:743
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1506
bool IsInSct() const
Definition: frame.hxx:964
const SwTwips WIDOW_MAGIC
Definition: txtfrm.hxx:1027
tools::Long BottomDist(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1411
bool IsRest() const
Definition: porlay.hxx:129
void MakeDummyLine()
This function creates a Line that reaches to the other Page Margin.
Definition: txtftn.cxx:1238
void ChangeOffset(SwTextFrame *pFrame, TextFrameIndex nNew)
Definition: frmform.cxx:988
SwLineLayout * GetNext()
Definition: porlay.hxx:159
bool IsSwapped() const
Definition: txtfrm.hxx:535
const SwFormatDrop * GetDropFormat() const
Definition: itrform2.hxx:196
void ColLock()
Definition: sectfrm.hxx:95
bool IsColLocked() const
Definition: frame.hxx:883
bool HasPara() const
Definition: txtfrm.hxx:819
void CalcBaseOfstForFly()
Definition: txtfrm.cxx:3959
TextFrameIndex GetStart() const
Definition: itrtxt.hxx:88
void MaybeNotifyRedlinePositionModification(tools::Long nTop)
Definition: docredln.cxx:1064
bool IsNewLine() const
Definition: itrform2.hxx:177
void ClrOrphLines()
Definition: widorp.hxx:63
void Left(const tools::Long nLeft)
Definition: swrect.hxx:194
SwNodeIndex nNode
Definition: pam.hxx:37
void SetCompletePaint() const
Definition: frame.hxx:991
SwParaPortion * GetPara()
Definition: txtcache.cxx:50
bool IsInFootnote() const
Definition: frame.hxx:946
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout...
Definition: txtfrm.cxx:475
void ValidateText(SwFrame *pFrame)
Definition: frmform.cxx:70
long Long
SwTwips GetHangingMargin() const
Definition: porlay.hxx:176
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:2724
bool IsStop() const
Definition: itrform2.hxx:174
TextFrameIndex mnOffset
Definition: txtfrm.hxx:198
const SwPosition * GetMark() const
Definition: pam.hxx:209
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:450
bool IsEmptyMaster() const
If there's a Follow and we don't contain text ourselves.
Definition: txtfrm.hxx:446
TextFrameIndex GetUnderScorePos() const
Definition: inftxt.hxx:640
void ValidateContent() const
Definition: pagefrm.hxx:417
sal_uInt16 GetDropHeight() const
Definition: itrtxt.hxx:205
bool HasFollow() const
Definition: flowfrm.hxx:165
void MoveFlyInCnt(SwTextFrame *pNew, TextFrameIndex nStart, TextFrameIndex nEnd)
Rewires FlyInContentFrame, if nEnd > Index >= nStart.
Definition: porfly.cxx:150
SwParaPortion * GetPara()
Definition: txtcache.cxx:90
void InvalidatePos()
Definition: frame.hxx:1040
const SwBodyFrame * FindBodyFrame() const
Definition: frame.hxx:1117
SwNode & GetNode() const
Definition: ndindex.hxx:119
void CharToLine(TextFrameIndex)
Definition: itrtxt.cxx:193
static void ChangeFootnoteRef(const SwContentFrame *pOld, const SwTextFootnote *, SwContentFrame *pNew)
Definition: ftnfrm.cxx:1752
void Format_(vcl::RenderContext *pRenderContext, SwParaPortion *pPara)
Definition: frmform.cxx:1695
void CalcDropAdjust()
Definition: itradj.cxx:745
bool IsVert() const
Definition: frame.hxx:1364
bool GetDropRect_(SwRect &rRect) const
Definition: frmform.cxx:147
const SwLineLayout * Next()
Definition: itrtxt.cxx:107
bool FormatLine(SwTextFormatter &rLine, const bool bPrev)
Definition: frmform.cxx:1178
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:384
void HideAndShowObjects()
Hides respectively shows objects, which are anchored at paragraph, at/as a character of the paragraph...
Definition: txtfrm.cxx:1551
void Pos(const Point &rNew)
Definition: swrect.hxx:168
bool IsPrep() const
Definition: porlay.hxx:303
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
bool IsKeepAlways() const
Definition: widorp.hxx:38
bool IsCellFrame() const
Definition: frame.hxx:1223
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1295
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1378
SwTwips Y() const
Definition: itrtxt.hxx:90
void AddBottom(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1391
bool IsEndHyph() const
Definition: porlay.hxx:123
sal_uInt8 & MaxHyph()
Definition: inftxt.hxx:553
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Definition: porlay.hxx:247
void SetTopAndHeight(tools::Long nTop, tools::Long nNew)
Definition: swrect.cxx:199
sal_uInt32 GetLineHeight() const
Definition: itrtxt.hxx:116
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:170
TextFrameIndex & Start()
Definition: porlay.hxx:45
SwTextAttr const * NextAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:89
void SetJustWidow(const bool bNew)
Definition: txtfrm.hxx:246
void CalcFootnoteFlag(TextFrameIndex nStop=TextFrameIndex(COMPLETE_STRING))
Does the Frame have a local footnote (in this Frame or Follow)?
Definition: txtftn.cxx:96
bool IsBreakNowWidAndOrp(SwTextMargin &rLine)
Definition: widorp.hxx:69
bool FormatQuick(bool bForceQuickFormat)
Definition: frmform.cxx:1983
size_type size() const
Definition: docary.hxx:261
void InitCntHyph()
Definition: itrform2.hxx:218
SwTextFormatInfo & GetInfo()
Definition: itrform2.hxx:213
bool IsHiddenNow() const
Hidden.
Definition: txtfrm.cxx:1362
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1374
void CalcUnclipped(SwTwips &rTop, SwTwips &rBottom)
Definition: itrform2.cxx:2124
void ValidateBodyFrame()
Definition: frmform.cxx:137
const SwRegisterItem & GetRegister(bool=true) const
Definition: paratr.hxx:198
void InvalidateObjs(const bool _bNoInvaOfAsCharAnchoredObjs=true)
Definition: fly.cxx:2345
bool IsFlyFrame() const
Definition: frame.hxx:1207
bool IsMoveable(const SwLayoutFrame *_pLayoutFrame=nullptr) const
determine, if frame is moveable in given environment
Definition: findfrm.cxx:1362
const SwRect & getFrameArea() const
Definition: frame.hxx:178
SwFootnoteContFrame * FindFootnoteCont()
Definition: ftnfrm.cxx:1026
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
SwFlowFrame * m_pFollow
Definition: flowfrm.hxx:117
sal_Unicode GetChar(TextFrameIndex const nPos) const
Definition: inftxt.hxx:240
bool IsInTab() const
Definition: frame.hxx:952
sal_Int32 & GetTabPos()
bool IsPaintDrop() const
Definition: itrpaint.hxx:56
void FormatReset()
Definition: porlay.hxx:331
void Width(tools::Long nNew)
Definition: swrect.hxx:186
sal_Unicode & GetDecimal()
void ResetFlags()
Definition: porlay.cxx:753
void CtorInitTextFormatInfo(OutputDevice *pRenderContext, SwTextFrame *pFrame, const bool bInterHyph=false, const bool bQuick=false, const bool bTst=false)
Definition: inftxt.cxx:1435
bool IsSctFrame() const
Definition: frame.hxx:1211
bool IsNewLine() const
Definition: inftxt.hxx:577
void SetRepaint() const
Definition: txtfrm.hxx:871
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
void SetLimit(SwFrame &rFrame, tools::Long nNew) const
Definition: frame.hxx:1414
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:56
void SetTruncLines(bool bNew)
Definition: itrform2.hxx:205
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:855
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:438
const SwAttrSet * GetAttrSet() const
WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for SwTextFrame, use GetBreakItem()/GetPageDescItem() instead.
Definition: findfrm.cxx:677
SvxTabAdjust & GetAdjustment()
bool IsInvalidContent() const
Definition: pagefrm.hxx:235
void SetUndersized(const bool bNew)
Definition: flowfrm.hxx:157
bool CalcFollow(TextFrameIndex nTextOfst)
Definition: frmform.cxx:172
tools::Long & GetDelta()
Definition: porlay.hxx:286
bool IsFollowField() const
Definition: porlay.hxx:311
bool IsColumnFrame() const
Definition: frame.hxx:1179
bool IsEmpty() const
Definition: txtfrm.hxx:521
void ResetPreps()
Definition: txtfrm.cxx:1353
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1104
void swap(cow_wrapper< T, P > &a, cow_wrapper< T, P > &b)
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:457
void SetDropLines(const sal_uInt16 nNew)
Definition: itrtxt.hxx:203
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1305
bool IsWidow() const
Definition: txtfrm.hxx:519
void Bottom()
Definition: itrtxt.cxx:185
SwTwips GetFirstPos() const
Definition: itrtxt.hxx:129
bool IsShift() const
Definition: inftxt.hxx:579
SwFrame * GetIndPrev() const
Definition: frame.hxx:723
void AdjustFollow_(SwTextFormatter &rLine, TextFrameIndex nOffset, TextFrameIndex nStrEnd, const sal_uInt8 nMode)
Definition: frmform.cxx:559
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
Definition: node.cxx:2095
SwTwips GetLineStart() const
Definition: itrcrsr.cxx:376
tools::Long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1407
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:78
const SwPosition * GetPoint() const
Definition: pam.hxx:207
bool IsInside(SwTextMargin const &rLine) const
BP 18.6.93: Widows.
Definition: widorp.cxx:102
void Top()
Definition: itrtxt.hxx:99
const SwLineInfo & GetLineInfo() const
Definition: itrtxt.hxx:128
SwFrame * GetIndNext()
Definition: frame.hxx:726
void SplitFrame(TextFrameIndex nTextPos)
Methods to manage the FollowFrame.
Definition: frmform.cxx:682
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:169
size_t size() const
Definition: sortedobjs.cxx:43
Mutex aLock
SwPageFrame * FindPageFrame()
Definition: frame.hxx:679
SwParaPortion * GetParaPortion()
Definition: inftxt.hxx:121
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:884
Helper class which can be used instead of the macros if a function has too many returns.
Definition: txtfrm.hxx:921
SwCharRange & GetReformat()
Definition: porlay.hxx:284
tools::Long YInc(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1422
const SwFrame * Lower() const
Definition: layfrm.hxx:101
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:191
void ManipOfst(TextFrameIndex const nNewOfst)
Definition: txtfrm.hxx:441
vector_type::size_type size_type
Definition: docary.hxx:223
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1379
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:88
void FinishKanaComp()
Definition: porlay.hxx:201
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:92
bool IsParagraph(bool bHard=false) const
Definition: viewopt.hxx:236
SwLayoutFrame * GetUpper()
Definition: frame.hxx:677
bool HasArea() const
Definition: swrect.hxx:287
void SetOffset_(TextFrameIndex nNewOfst)
Definition: frmform.cxx:756
void AddHeight(const tools::Long nAdd)
Definition: swrect.cxx:161
bool isFramePrintAreaValid() const
Definition: frame.hxx:167
bool IsPrepWidows() const
Definition: porlay.hxx:305
SwTwips GetLeftMargin() const
Definition: itrtxt.hxx:328
bool IsUndersized() const
Definition: flowfrm.hxx:158
void FinishSpaceAdd()
Definition: porlay.hxx:186
const SwLineLayout * GetPrev()
Definition: itrtxt.cxx:82
tools::Long GetPrtTop(const SwFrame &rFrame) const
Definition: frame.hxx:1406
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
Definition: findfrm.cxx:436
SwFrame * GetPrev()
Definition: frame.hxx:676
SwTextFrame * GetFormatted(bool bForceQuickFormat=false)
In case the SwLineLayout was cleared out of the s_pTextCache, recreate it.
Definition: txtfrm.cxx:3366
tools::Long GetTopMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1400
void AddWidth(const tools::Long nAdd)
Definition: swrect.cxx:160
TextFrameIndex GetIdx() const
Definition: inftxt.hxx:271
bool IsLineBreak(bool bHard=false) const
Definition: viewopt.hxx:252
css::uno::Sequence< css::style::TabStop > GetTabStopInfo(SwTwips CurrentPos) override
Definition: frmform.cxx:518
void TruncLines(bool bNoteFollow=false)
Definition: itrtxt.cxx:323
tools::Long YDiff(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1420
void SSize(const Size &rNew)
Definition: swrect.hxx:177
bool IsLocked() const
Definition: txtfrm.hxx:517
const sal_uInt8 & CntMidHyph() const
Definition: itrform2.hxx:220
bool isFrameAreaSizeValid() const
Definition: frame.hxx:166
bool IsUnclipped() const
Definition: itrform2.hxx:207
TextFrameIndex GetLen() const
Definition: porlin.hxx:73
void CalcHeightOfLastLine(const bool _bUseFont=false)
method to determine height of last line, needed for proportional line spacing
Definition: txtfrm.cxx:3551
A page of the document layout.
Definition: pagefrm.hxx:57
#define SLOPPY_TWIPS
Definition: frmform.cxx:52
SwTwips GetRightOfst() const
Definition: porlay.hxx:72
Point GetTopLeft() const
Definition: itrtxt.hxx:186
tools::Long SwTwips
Definition: swtypes.hxx:50
bool IsMargin() const
Definition: porlay.hxx:318
const long LONG_MAX
#define Y
const OUString & GetText() const
Definition: inftxt.hxx:239
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
Definition: frmform.cxx:1754
bool IsStop() const
Definition: inftxt.hxx:573
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1550
void InvalidateSize()
Definition: frame.hxx:1026
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1112
void ValidateFrame()
Definition: frmform.cxx:81
SwFrame * FindColFrame()
Definition: findfrm.cxx:530
void SetUnclipped(bool bNew)
Definition: itrform2.hxx:208
void Truncate()
Definition: porlin.hxx:197
void InvalidateAccessibleParaFlowRelation(const SwTextFrame *_pFromTextFrame, const SwTextFrame *_pToTextFrame)
invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
Definition: viewsh.cxx:2486
static void ValidateBodyFrame_(SwFrame *pFrame)
Definition: frmform.cxx:117
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:685
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:49
const SwLineLayout * Prev()
Definition: itrtxt.cxx:89
bool IsPrepMustFit() const
Definition: porlay.hxx:307
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:208
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool OverStep(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1415
void FormatAdjust(SwTextFormatter &rLine, WidowsAndOrphans &rFrameBreak, TextFrameIndex nStrLen, const bool bDummy)
Definition: frmform.cxx:996
bool CalcPreps()
Definition: frmform.cxx:773
bool IsBreakNow(SwTextMargin &rLine)
Definition: widorp.cxx:176
void SetYMargins(SwFrame &rFrame, tools::Long nTop, tools::Long nBottom) const
Definition: frame.hxx:1405
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1617
bool IsVertLR() const
Definition: frame.hxx:976
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:2036
bool IsMidHyph() const
Definition: porlay.hxx:125
sal_uInt16 GetDropLeft() const
Definition: itrtxt.hxx:204
sal_Unicode & GetFill()
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:483
void SetOffset(TextFrameIndex nNewOfst)
Definition: txtfrm.hxx:865
void SimpleFormat()
Definition: sectfrm.cxx:1163
TextFrameIndex GetLength() const
Definition: itrtxt.hxx:86
#define SAL_WARN_IF(condition, area, stream)
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:738
void ColUnlock()
Definition: sectfrm.hxx:96
unsigned char sal_uInt8
SwRepaint & GetRepaint()
Definition: porlay.hxx:282
void SetFootnote(const bool bNew)
Will be moved soon.
Definition: txtfrm.hxx:599
SwLinePortion * GetRest()
Definition: inftxt.hxx:575
void ForbidFollowFormat()
Definition: txtfrm.hxx:753
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1254
void SetFieldFollow(const bool bNew)
Definition: txtfrm.hxx:248
#define SAL_INFO(area, stream)
void SetOnceMore(bool bNew)
Definition: itrform2.hxx:202
void AdjustFrame(const SwTwips nChgHeight, bool bHasToFit=false)
Definition: frmform.cxx:363
void SetHeight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1388
void SwapWidthAndHeight()
Swaps width and height of the text frame.
Definition: txtfrm.cxx:422
void SetRightOfst(const SwTwips nNew)
Definition: porlay.hxx:73
SvxAdjust GetAdjust() const
Definition: itrtxt.hxx:190
bool CalcPrepFootnoteAdjust()
Definition: txtftn.cxx:131
const SwPosition * End() const
Definition: pam.hxx:217
const sal_uInt8 & CntEndHyph() const
Definition: itrform2.hxx:219
virtual void MakePos() override
Definition: frmform.cxx:338
bool IsRightToLeft() const
Definition: frame.hxx:984
void SetKeep(const bool bNew)
Definition: widorp.hxx:40
void Top(const tools::Long nTop)
Definition: swrect.hxx:203
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1810
void setFrameAreaSizeValid(bool bNew)
Definition: wsfrm.cxx:92
static TextFrameIndex FindBrk(const OUString &rText, TextFrameIndex nStart, TextFrameIndex nEnd)
Returns the first possible break point in the current line.
Definition: txtfrm.cxx:1635
bool FormatEmpty()
Definition: porrst.cxx:334
bool IsPageFrame() const
Definition: frame.hxx:1175
void SetPaintDrop(const bool bNew)
Definition: itrpaint.hxx:55
double getLength(const B2DPolygon &rCandidate)
void SetPrep()
Definition: porlay.hxx:302
void FormatOnceMore(SwTextFormatter &rLine, SwTextFormatInfo &rInf)
Definition: frmform.cxx:1633
void SetWidow(const bool bNew)
Definition: txtfrm.hxx:245
virtual void Cut() override
Definition: wsfrm.cxx:1133
tools::Long GetTopMargin() const
Definition: ssfrm.cxx:41
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:715
const SvxTabStop * GetTabStop(const SwTwips nSearchPos, SwTwips &nRight) const
#i24363# tab stops relative to indent
Definition: txttab.cxx:43
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:56
void SetPrepMustFit(const bool bNew)
Definition: porlay.hxx:306
const SwLineLayout * GetCurr() const
Definition: itrtxt.hxx:83
SwLinePortion * MakeRestPortion(const SwLineLayout *pLine, TextFrameIndex nPos)
Definition: pormulti.cxx:2374
bool IsVertical() const
Definition: frame.hxx:970
tools::Long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1375
virtual SwContentFrame * MakeFrame(SwFrame *) override
Virtual methods from ContentNode.
Definition: ndtxt.cxx:270
void Insert(SwLineLayout *pLine)
Definition: itrform2.cxx:124
#define SAL_WARN(area, stream)
SwTwips GetOffset() const
Definition: porlay.hxx:70
bool IsTest() const
Definition: inftxt.hxx:587
sal_uInt32 & GetAscent()
Definition: porlin.hxx:76
bool IsFlyInCntBase() const
Definition: itrform2.hxx:210
virtual void MakePos()
Definition: calcmove.cxx:539
void SetOffset(const SwTwips nNew)
Definition: porlay.hxx:71
TextFrameIndex GetEnd() const
Definition: itrtxt.hxx:89
virtual const SwRedlineTable & GetRedlineTable() const =0
bool IsOnceMore() const
Definition: itrform2.hxx:201
sal_uInt16 GetDropLines() const
Definition: itrtxt.hxx:202
friend void ValidateText(SwFrame *pFrame)
Definition: frmform.cxx:70
sal_uInt32 Width() const
Definition: possiz.hxx:51
bool IsFieldFollow() const
Definition: txtfrm.hxx:524
bool IsBodyFrame() const
Definition: frame.hxx:1203
void SetEmpty(const bool bNew)
Definition: txtfrm.hxx:247
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:207
void InvalidateRange_(const SwCharRange &, const tools::Long=0)
Definition: txtfrm.cxx:1695
void Chg(const Point &rNP, const Size &rNS)
Definition: swrect.hxx:163
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...
void SetRest(SwLinePortion *pNewRest)
Definition: inftxt.hxx:576
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:76
void Height(tools::Long nNew)
Definition: swrect.hxx:190
void RemoveFootnote(TextFrameIndex nStart, TextFrameIndex nLen=TextFrameIndex(COMPLETE_STRING))
Footnote.
Definition: txtftn.cxx:400
TextFrameIndex & Len()
Definition: porlay.hxx:49
SwContentFrame * JoinFrame()
Definition: frmform.cxx:613
SwRootFrame * getRootFrame()
Definition: frame.hxx:678
bool HasUnderscore() const
Definition: porlay.hxx:147
bool IsAvailable() const
Definition: txtcache.cxx:70
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:850
bool CalcOnceMore()
Definition: itrform2.cxx:2023
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1030
void ChgThisLines()
Definition: txtfrm.cxx:3767
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1096
SwFrame * GetNext()
Definition: frame.hxx:675
bool HasFootnote() const
Definition: txtfrm.hxx:522