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