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  {
671  auto pNext = pFoll->FindNextCnt( true );
672  pViewShell->InvalidateAccessibleParaFlowRelation(
673  pNext ? pNext->DynCastTextFrame() : nullptr,
674  this );
675  }
676  }
677  pFoll->Cut();
678  SetFollow(pNxt);
679  SwFrame::DestroyFrame(pFoll);
680  return pNxt;
681 }
682 
684 {
685  SwSwapIfSwapped swap( this );
686 
687  // The Paste sends a Modify() to me
688  // I lock myself, so that my data does not disappear
689  TextFrameLockGuard aLock( this );
690  SwTextFrame *const pNew = static_cast<SwTextFrame *>(GetTextNodeFirst()->MakeFrame(this));
691 
692  pNew->SetFollow( GetFollow() );
693  SetFollow( pNew );
694 
695  pNew->Paste( GetUpper(), GetNext() );
696  // i#27138
697  // notify accessibility paragraphs objects about changed CONTENT_FLOWS_FROM/_TO relation.
698  // Relation CONTENT_FLOWS_FROM for current next paragraph will change
699  // and relation CONTENT_FLOWS_TO for current previous paragraph, which
700  // is <this>, will change.
701  {
702  SwViewShell* pViewShell( pNew->getRootFrame()->GetCurrShell() );
703  if ( pViewShell && pViewShell->GetLayout() &&
704  pViewShell->GetLayout()->IsAnyShellAccessible() )
705  {
706  auto pNext = pNew->FindNextCnt( true );
707  pViewShell->InvalidateAccessibleParaFlowRelation(
708  pNext ? pNext->DynCastTextFrame() : nullptr,
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 // Move the as-character objects - footnotes must be moved by RemoveFootnote!
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 tools::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  TextFrameIndex const nOld(nEnd);
1085  nEnd = rLine.GetEnd();
1086  if( GetFollow() )
1087  {
1088  // Another case for not joining the follow:
1089  // Text frame has no content, but a numbering. Then, do *not* join.
1090  // Example of this case: When an empty, but numbered paragraph
1091  // at the end of page is completely displaced by a fly frame.
1092  // Thus, the text frame introduced a follow by a
1093  // <SwTextFrame::SplitFrame(..)> - see below. The follow then shows
1094  // the numbering and must stay.
1095  if ( GetFollow()->GetOffset() != nEnd ||
1096  GetFollow()->IsFieldFollow() ||
1097  (nStrLen == TextFrameIndex(0) && GetTextNodeForParaProps()->GetNumRule()))
1098  {
1099  nNew |= 3;
1100  }
1101  else if (FindTabFrame() && nEnd > TextFrameIndex(0) &&
1102  rLine.GetInfo().GetChar(nEnd - TextFrameIndex(1)) == CH_BREAK)
1103  {
1104  // We are in a table, the paragraph has a follow and the text
1105  // ends with a hard line break. Don't join the follow just
1106  // because the follow would have no content, we may still need it
1107  // for the paragraph mark.
1108  nNew |= 1;
1109  }
1110  // move footnotes if the follow is kept - if RemoveFootnote() is
1111  // called in next format iteration, it will be with the *new*
1112  // offset so no effect!
1113  if (nNew && nOld < nEnd)
1114  {
1115  RemoveFootnote(nOld, nEnd - nOld);
1116  }
1117  ChangeOffset( GetFollow(), nEnd );
1118  GetFollow()->ManipOfst( nEnd );
1119  }
1120  else
1121  {
1122  // Only split frame, if the frame contains
1123  // content or contains no content, but has a numbering.
1124  // i#84870 - No split, if text frame only contains one
1125  // as-character anchored object.
1126  if ( !bOnlyContainsAsCharAnchoredObj &&
1127  (nStrLen > TextFrameIndex(0) ||
1128  (nStrLen == TextFrameIndex(0) && GetTextNodeForParaProps()->GetNumRule()))
1129  )
1130  {
1131  SplitFrame( nEnd );
1132  nNew |= 3;
1133  }
1134  }
1135  // If the remaining height changed e.g by RemoveFootnote() we need to
1136  // fill up in order to avoid oscillation.
1137  if( bDummy && pBodyFrame &&
1138  nBodyHeight < ( IsVertical() ?
1139  pBodyFrame->getFrameArea().Width() :
1140  pBodyFrame->getFrameArea().Height() ) )
1141  rLine.MakeDummyLine();
1142  }
1143 
1144  // In AdjustFrame() we set ourselves via Grow/Shrink
1145  // In AdjustFollow() we set our FollowFrame
1146 
1147  const SwTwips nDocPrtTop = getFrameArea().Top() + getFramePrintArea().Top();
1148  const SwTwips nOldHeight = getFramePrintArea().SSize().Height();
1149  SwTwips nChg = rLine.CalcBottomLine() - nDocPrtTop - nOldHeight;
1150 
1151  //#i84870# - no shrink of text frame, if it only contains one as-character anchored object.
1152  if ( nChg < 0 && !bDelta && bOnlyContainsAsCharAnchoredObj )
1153  {
1154  nChg = 0;
1155  }
1156 
1157  // Vertical Formatting:
1158  // The (rotated) repaint rectangle's x coordinate refers to the frame.
1159  // If the frame grows (or shirks) the repaint rectangle cannot simply
1160  // be rotated back after formatting, because we use the upper left point
1161  // of the frame for rotation. This point changes when growing/shrinking.
1162 
1163  if ( IsVertical() && !IsVertLR() && nChg )
1164  {
1165  SwRect &rRepaint = pPara->GetRepaint();
1166  rRepaint.Left( rRepaint.Left() - nChg );
1167  rRepaint.Width( rRepaint.Width() - nChg );
1168  }
1169 
1170  AdjustFrame( nChg, bHasToFit );
1171 
1172  if( HasFollow() || IsInFootnote() )
1173  AdjustFollow_( rLine, nEnd, nStrLen, nNew );
1174 
1175  pPara->SetPrepMustFit( false );
1176 }
1177 
1178 // bPrev is set whether Reformat.Start() was called because of Prev().
1179 // Else, wo don't know whether we can limit the repaint or not.
1180 bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev )
1181 {
1182  OSL_ENSURE( ! IsVertical() || IsSwapped(),
1183  "SwTextFrame::FormatLine( rLine, bPrev) with unswapped frame" );
1184  SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1185  const SwLineLayout *pOldCur = rLine.GetCurr();
1186  const TextFrameIndex nOldLen = pOldCur->GetLen();
1187  const SwTwips nOldAscent = pOldCur->GetAscent();
1188  const SwTwips nOldHeight = pOldCur->Height();
1189  const SwTwips nOldWidth = pOldCur->Width() + pOldCur->GetHangingMargin();
1190  const bool bOldHyph = pOldCur->IsEndHyph();
1191  SwTwips nOldTop = 0;
1192  SwTwips nOldBottom = 0;
1193  if( rLine.GetCurr()->IsClipping() )
1194  rLine.CalcUnclipped( nOldTop, nOldBottom );
1195 
1196  TextFrameIndex const nNewStart = rLine.FormatLine( rLine.GetStart() );
1197 
1198  OSL_ENSURE( getFrameArea().Pos().Y() + getFramePrintArea().Pos().Y() == rLine.GetFirstPos(),
1199  "SwTextFrame::FormatLine: frame leaves orbit." );
1200  OSL_ENSURE( rLine.GetCurr()->Height(),
1201  "SwTextFrame::FormatLine: line height is zero" );
1202 
1203  // The current line break object
1204  const SwLineLayout *pNew = rLine.GetCurr();
1205 
1206  bool bUnChg = nOldLen == pNew->GetLen() &&
1207  bOldHyph == pNew->IsEndHyph();
1208  if ( bUnChg && !bPrev )
1209  {
1210  const tools::Long nWidthDiff = nOldWidth > pNew->Width()
1211  ? nOldWidth - pNew->Width()
1212  : pNew->Width() - nOldWidth;
1213 
1214  // we only declare a line as unchanged, if its main values have not
1215  // changed and it is not the last line (!paragraph end symbol!)
1216  bUnChg = nOldHeight == pNew->Height() &&
1217  nOldAscent == pNew->GetAscent() &&
1218  nWidthDiff <= SLOPPY_TWIPS &&
1219  pOldCur->GetNext();
1220  }
1221 
1222  // Calculate rRepaint
1223  const SwTwips nBottom = rLine.Y() + rLine.GetLineHeight();
1224  SwRepaint &rRepaint = pPara->GetRepaint();
1225  if( bUnChg && rRepaint.Top() == rLine.Y()
1226  && (bPrev || nNewStart <= pPara->GetReformat().Start())
1227  && (nNewStart < TextFrameIndex(GetText().getLength())))
1228  {
1229  rRepaint.Top( nBottom );
1230  rRepaint.Height( 0 );
1231  }
1232  else
1233  {
1234  if( nOldTop )
1235  {
1236  if( nOldTop < rRepaint.Top() )
1237  rRepaint.Top( nOldTop );
1238  if( !rLine.IsUnclipped() || nOldBottom > rRepaint.Bottom() )
1239  {
1240  rRepaint.Bottom( nOldBottom - 1 );
1241  rLine.SetUnclipped( true );
1242  }
1243  }
1244  if( rLine.GetCurr()->IsClipping() && rLine.IsFlyInCntBase() )
1245  {
1246  SwTwips nTmpTop, nTmpBottom;
1247  rLine.CalcUnclipped( nTmpTop, nTmpBottom );
1248  if( nTmpTop < rRepaint.Top() )
1249  rRepaint.Top( nTmpTop );
1250  if( !rLine.IsUnclipped() || nTmpBottom > rRepaint.Bottom() )
1251  {
1252  rRepaint.Bottom( nTmpBottom - 1 );
1253  rLine.SetUnclipped( true );
1254  }
1255  }
1256  else
1257  {
1258  if( !rLine.IsUnclipped() || nBottom > rRepaint.Bottom() )
1259  {
1260  rRepaint.Bottom( nBottom - 1 );
1261  rLine.SetUnclipped( false );
1262  }
1263  }
1264  SwTwips nRght = std::max( nOldWidth, pNew->Width() +
1265  pNew->GetHangingMargin() );
1267  const SwViewOption *pOpt = pSh ? pSh->GetViewOptions() : nullptr;
1268  if( pOpt && (pOpt->IsParagraph() || pOpt->IsLineBreak()) )
1269  nRght += ( std::max( nOldAscent, pNew->GetAscent() ) );
1270  else
1271  nRght += ( std::max( nOldAscent, pNew->GetAscent() ) / 4);
1272  nRght += rLine.GetLeftMargin();
1273  if( rRepaint.GetOffset() || rRepaint.GetRightOfst() < nRght )
1274  rRepaint.SetRightOfst( nRght );
1275 
1276  // Finally we enlarge the repaint rectangle if we found an underscore
1277  // within our line. 40 Twips should be enough
1278  const bool bHasUnderscore =
1279  ( rLine.GetInfo().GetUnderScorePos() < nNewStart );
1280  if ( bHasUnderscore || rLine.GetCurr()->HasUnderscore() )
1281  rRepaint.Bottom( rRepaint.Bottom() + 40 );
1282 
1283  const_cast<SwLineLayout*>(rLine.GetCurr())->SetUnderscore( bHasUnderscore );
1284  }
1285 
1286  // Calculating the good ol' nDelta
1287  pPara->GetDelta() -= sal_Int32(pNew->GetLen()) - sal_Int32(nOldLen);
1288 
1289  // Stop!
1290  if( rLine.IsStop() )
1291  return false;
1292 
1293  // Absolutely another line
1294  if( rLine.IsNewLine() )
1295  return true;
1296 
1297  // Until the String's end?
1298  if (nNewStart >= TextFrameIndex(GetText().getLength()))
1299  return false;
1300 
1301  if( rLine.GetInfo().IsShift() )
1302  return true;
1303 
1304  // Reached the Reformat's end?
1305  const TextFrameIndex nEnd = pPara->GetReformat().Start() +
1306  pPara->GetReformat().Len();
1307 
1308  if( nNewStart <= nEnd )
1309  return true;
1310 
1311  return 0 != pPara->GetDelta();
1312 }
1313 
1315  const bool bAdjust )
1316 {
1317  OSL_ENSURE( ! IsVertical() || IsSwapped(),"SwTextFrame::Format_ with unswapped frame" );
1318 
1319  SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1320  rLine.SetUnclipped( false );
1321 
1322  const OUString & rString = GetText();
1323  const TextFrameIndex nStrLen(rString.getLength());
1324 
1325  SwCharRange &rReformat = pPara->GetReformat();
1326  SwRepaint &rRepaint = pPara->GetRepaint();
1327  std::unique_ptr<SwRepaint> pFreeze;
1328 
1329  // Due to performance reasons we set rReformat to COMPLETE_STRING in Init()
1330  // In this case we adjust rReformat
1331  if( rReformat.Len() > nStrLen )
1332  rReformat.Len() = nStrLen;
1333 
1334  if( rReformat.Start() + rReformat.Len() > nStrLen )
1335  rReformat.Len() = nStrLen - rReformat.Start();
1336 
1337  SwTwips nOldBottom;
1338  if( GetOffset() && !IsFollow() )
1339  {
1340  rLine.Bottom();
1341  nOldBottom = rLine.Y();
1342  rLine.Top();
1343  }
1344  else
1345  nOldBottom = 0;
1346  rLine.CharToLine( rReformat.Start() );
1347 
1348  // When inserting or removing a Space, words can be moved out of the edited
1349  // line and into the preceding line, hence the preceding line must be
1350  // formatted as well.
1351  // Optimization: If rReformat starts after the first word of the line,
1352  // this line cannot possibly influence the previous one.
1353  // ...Turns out that unfortunately it can: Text size changes + FlyFrames;
1354  // the feedback can affect multiple lines (Frames!)!
1355 
1356  // i#46560
1357  // FME: Yes, consider this case: "(word )" has to go to the next line
1358  // because ")" is a forbidden character at the beginning of a line although
1359  // "(word" would still fit on the previous line. Adding text right in front
1360  // of ")" would not trigger a reformatting of the previous line. Adding 1
1361  // to the result of FindBrk() does not solve the problem in all cases,
1362  // nevertheless it should be sufficient.
1363  bool bPrev = rLine.GetPrev() &&
1364  (FindBrk(rString, rLine.GetStart(), rReformat.Start() + TextFrameIndex(1))
1365  // i#46560
1366  + TextFrameIndex(1)
1367  >= rReformat.Start() ||
1368  rLine.GetCurr()->IsRest() );
1369  if( bPrev )
1370  {
1371  while( rLine.Prev() )
1372  if( rLine.GetCurr()->GetLen() && !rLine.GetCurr()->IsRest() )
1373  {
1374  if( !rLine.GetStart() )
1375  rLine.Top(); // So that NumDone doesn't get confused
1376  break;
1377  }
1378  TextFrameIndex nNew = rLine.GetStart() + rLine.GetLength();
1379  if( nNew )
1380  {
1381  --nNew;
1382  if (CH_BREAK == rString[sal_Int32(nNew)])
1383  {
1384  ++nNew;
1385  rLine.Next();
1386  bPrev = false;
1387  }
1388  }
1389  rReformat.Len() += rReformat.Start() - nNew;
1390  rReformat.Start() = nNew;
1391  }
1392 
1393  rRepaint.SetOffset( 0 );
1394  rRepaint.SetRightOfst( 0 );
1395  rRepaint.Chg( getFrameArea().Pos() + getFramePrintArea().Pos(), getFramePrintArea().SSize() );
1396  if( pPara->IsMargin() )
1397  rRepaint.Width( rRepaint.Width() + pPara->GetHangingMargin() );
1398  rRepaint.Top( rLine.Y() );
1399  if( 0 >= rRepaint.Width() )
1400  rRepaint.Width(1);
1401  WidowsAndOrphans aFrameBreak( this, rInf.IsTest() ? 1 : 0 );
1402 
1403  // rLine is now set to the first line which needs formatting.
1404  // The bFirst flag makes sure that Next() is not called.
1405  // The whole thing looks weird, but we need to make sure that
1406  // rLine stops at the last non-fitting line when calling IsBreakNow.
1407  bool bFirst = true;
1408  bool bFormat = true;
1409 
1410  // The CharToLine() can also get us into the danger zone.
1411  // In that case we need to walk back until rLine is set
1412  // to the non-fitting line. Or else the mass of text is lost,
1413  // because the Ofst was set wrongly in the Follow.
1414 
1415  bool bBreak = ( !pPara->IsPrepMustFit() || rLine.GetLineNr() > 1 )
1416  && aFrameBreak.IsBreakNowWidAndOrp( rLine );
1417  if( bBreak )
1418  {
1419  bool bPrevDone = nullptr != rLine.Prev();
1420  while( bPrevDone && aFrameBreak.IsBreakNowWidAndOrp(rLine) )
1421  bPrevDone = nullptr != rLine.Prev();
1422  if( bPrevDone )
1423  {
1424  aFrameBreak.SetKeep( false );
1425  rLine.Next();
1426  }
1427  rLine.TruncLines();
1428 
1429  // Play it safe
1430  aFrameBreak.IsBreakNowWidAndOrp(rLine);
1431  }
1432 
1433  /* Meaning if the following flags are set:
1434 
1435  Watch(End/Mid)Hyph: we need to format if we have a break at
1436  the line end/Fly, as long as MaxHyph is reached
1437 
1438  Jump(End/Mid)Flag: the next line which has no break (line end/Fly),
1439  needs to be formatted, because we could wrap now. This might have been
1440  forbidden earlier by MaxHyph
1441 
1442  Watch(End/Mid)Hyph: if the last formatted line got a cutoff point, but
1443  didn't have one before
1444 
1445  Jump(End/Mid)Hyph: if a cutoff point disappears
1446  */
1447  bool bJumpEndHyph = false;
1448  bool bWatchEndHyph = false;
1449  bool bJumpMidHyph = false;
1450  bool bWatchMidHyph = false;
1451 
1452  const SwAttrSet& rAttrSet = GetTextNodeForParaProps()->GetSwAttrSet();
1453  rInf.MaxHyph() = rAttrSet.GetHyphenZone().GetMaxHyphens();
1454  bool bMaxHyph = 0 != rInf.MaxHyph();
1455  if ( bMaxHyph )
1456  rLine.InitCntHyph();
1457 
1458  if( IsFollow() && IsFieldFollow() && rLine.GetStart() == GetOffset() )
1459  {
1460  SwTextFrame *pMaster = FindMaster();
1461  OSL_ENSURE( pMaster, "SwTextFrame::Format: homeless follow" );
1462  const SwLineLayout* pLine=nullptr;
1463  if (pMaster)
1464  {
1465  if (!pMaster->HasPara())
1466  { // master could be locked because it's being formatted upstack
1467  SAL_WARN("sw", "SwTextFrame::Format_: master not formatted!");
1468  }
1469  else
1470  {
1471  SwTextSizeInfo aInf( pMaster );
1472  SwTextIter aMasterLine( pMaster, &aInf );
1473  aMasterLine.Bottom();
1474  pLine = aMasterLine.GetCurr();
1475  assert(aMasterLine.GetEnd() == GetOffset());
1476  }
1477  }
1478  SwLinePortion* pRest = pLine ?
1479  rLine.MakeRestPortion(pLine, GetOffset()) : nullptr;
1480  if( pRest )
1481  rInf.SetRest( pRest );
1482  else
1483  SetFieldFollow( false );
1484  }
1485 
1486  /* Ad cancel criterion:
1487  * In order to recognize, whether a line does not fit onto the page
1488  * anymore, we need to format it. This overflow is removed again in
1489  * e.g. AdjustFollow.
1490  * Another complication: if we are the Master, we need to traverse
1491  * the lines, because it could happen that one line can overflow
1492  * from the Follow to the Master.
1493  */
1494  do
1495  {
1496  if( bFirst )
1497  bFirst = false;
1498  else
1499  {
1500  if ( bMaxHyph )
1501  {
1502  if ( rLine.GetCurr()->IsEndHyph() )
1503  rLine.CntEndHyph()++;
1504  else
1505  rLine.CntEndHyph() = 0;
1506  if ( rLine.GetCurr()->IsMidHyph() )
1507  rLine.CntMidHyph()++;
1508  else
1509  rLine.CntMidHyph() = 0;
1510  }
1511  if( !rLine.Next() )
1512  {
1513  if( !bFormat )
1514  {
1515  SwLinePortion* pRest =
1516  rLine.MakeRestPortion( rLine.GetCurr(), rLine.GetEnd() );
1517  if( pRest )
1518  rInf.SetRest( pRest );
1519  }
1520  rLine.Insert( new SwLineLayout() );
1521  rLine.Next();
1522  bFormat = true;
1523  }
1524  }
1525  if ( !bFormat && bMaxHyph &&
1526  (bWatchEndHyph || bJumpEndHyph || bWatchMidHyph || bJumpMidHyph) )
1527  {
1528  if ( rLine.GetCurr()->IsEndHyph() )
1529  {
1530  if ( bWatchEndHyph )
1531  bFormat = ( rLine.CntEndHyph() == rInf.MaxHyph() );
1532  }
1533  else
1534  {
1535  bFormat = bJumpEndHyph;
1536  bWatchEndHyph = false;
1537  bJumpEndHyph = false;
1538  }
1539  if ( rLine.GetCurr()->IsMidHyph() )
1540  {
1541  if ( bWatchMidHyph && !bFormat )
1542  bFormat = ( rLine.CntEndHyph() == rInf.MaxHyph() );
1543  }
1544  else
1545  {
1546  bFormat |= bJumpMidHyph;
1547  bWatchMidHyph = false;
1548  bJumpMidHyph = false;
1549  }
1550  }
1551  if( bFormat )
1552  {
1553  const bool bOldEndHyph = rLine.GetCurr()->IsEndHyph();
1554  const bool bOldMidHyph = rLine.GetCurr()->IsMidHyph();
1555  bFormat = FormatLine( rLine, bPrev );
1556  // There can only be one bPrev ... (???)
1557  bPrev = false;
1558  if ( bMaxHyph )
1559  {
1560  if ( rLine.GetCurr()->IsEndHyph() != bOldEndHyph )
1561  {
1562  bWatchEndHyph = !bOldEndHyph;
1563  bJumpEndHyph = bOldEndHyph;
1564  }
1565  if ( rLine.GetCurr()->IsMidHyph() != bOldMidHyph )
1566  {
1567  bWatchMidHyph = !bOldMidHyph;
1568  bJumpMidHyph = bOldMidHyph;
1569  }
1570  }
1571  }
1572 
1573  if( !rInf.IsNewLine() )
1574  {
1575  if( !bFormat )
1576  bFormat = nullptr != rInf.GetRest();
1577  if( rInf.IsStop() || rInf.GetIdx() >= nStrLen )
1578  break;
1579  if( !bFormat && ( !bMaxHyph || ( !bWatchEndHyph &&
1580  !bJumpEndHyph && !bWatchMidHyph && !bJumpMidHyph ) ) )
1581  {
1582  if( GetFollow() )
1583  {
1584  while( rLine.Next() )
1585  ; //Nothing
1586  pFreeze.reset(new SwRepaint( rRepaint )); // to minimize painting
1587  }
1588  else
1589  break;
1590  }
1591  }
1592  bBreak = aFrameBreak.IsBreakNowWidAndOrp(rLine);
1593  }while( !bBreak );
1594 
1595  if( pFreeze )
1596  {
1597  rRepaint = *pFreeze;
1598  pFreeze.reset();
1599  }
1600 
1601  if( !rLine.IsStop() )
1602  {
1603  // If we're finished formatting the text and we still
1604  // have other line objects left, these are superfluous
1605  // now because the text has gotten shorter.
1606  if( rLine.GetStart() + rLine.GetLength() >= nStrLen &&
1607  rLine.GetCurr()->GetNext() )
1608  {
1609  rLine.TruncLines();
1610  rLine.SetTruncLines( true );
1611  }
1612  }
1613 
1614  if( rInf.IsTest() )
1615  return;
1616 
1617  // FormatAdjust does not pay off at OnceMore
1618  if( bAdjust || !rLine.GetDropFormat() || !rLine.CalcOnceMore() )
1619  {
1620  FormatAdjust( rLine, aFrameBreak, nStrLen, rInf.IsStop() );
1621  }
1622  if( rRepaint.HasArea() )
1623  SetRepaint();
1624  rLine.SetTruncLines( false );
1625  if( nOldBottom ) // We check whether paragraphs that need scrolling can
1626  // be shrunk, so that they don't need scrolling anymore
1627  {
1628  rLine.Bottom();
1629  SwTwips nNewBottom = rLine.Y();
1630  if( nNewBottom < nOldBottom )
1632  }
1633 }
1634 
1636 {
1637  OSL_ENSURE( ! IsVertical() || IsSwapped(),
1638  "A frame is not swapped in SwTextFrame::FormatOnceMore" );
1639 
1640  SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1641  if( !pPara )
1642  return;
1643 
1644  // If necessary the pPara
1645  sal_uInt16 nOld = static_cast<const SwTextMargin&>(rLine).GetDropHeight();
1646  bool bShrink = false;
1647  bool bGrow = false;
1648  bool bGoOn = rLine.IsOnceMore();
1649  sal_uInt8 nGo = 0;
1650  while( bGoOn )
1651  {
1652  ++nGo;
1653  rInf.Init();
1654  rLine.Top();
1655  if( !rLine.GetDropFormat() )
1656  rLine.SetOnceMore( false );
1657  SwCharRange aRange(TextFrameIndex(0), TextFrameIndex(rInf.GetText().getLength()));
1658  pPara->GetReformat() = aRange;
1659  Format_( rLine, rInf );
1660 
1661  bGoOn = rLine.IsOnceMore();
1662  if( bGoOn )
1663  {
1664  const sal_uInt16 nNew = static_cast<const SwTextMargin&>(rLine).GetDropHeight();
1665  if( nOld == nNew )
1666  bGoOn = false;
1667  else
1668  {
1669  if( nOld > nNew )
1670  bShrink = true;
1671  else
1672  bGrow = true;
1673 
1674  if( bShrink == bGrow || 5 < nGo )
1675  bGoOn = false;
1676 
1677  nOld = nNew;
1678  }
1679 
1680  // If something went wrong, we need to reformat again
1681  if( !bGoOn )
1682  {
1683  rInf.CtorInitTextFormatInfo( getRootFrame()->GetCurrShell()->GetOut(), this );
1684  rLine.CtorInitTextFormatter( this, &rInf );
1685  rLine.SetDropLines( 1 );
1686  rLine.CalcDropHeight( 1 );
1687  SwCharRange aTmpRange(TextFrameIndex(0), TextFrameIndex(rInf.GetText().getLength()));
1688  pPara->GetReformat() = aTmpRange;
1689  Format_( rLine, rInf, true );
1690  // We paint everything ...
1691  SetCompletePaint();
1692  }
1693  }
1694  }
1695 }
1696 
1698 {
1699  const bool bIsEmpty = GetText().isEmpty();
1700 
1701  if ( bIsEmpty )
1702  {
1703  // Empty lines do not get tortured for very long:
1704  // pPara is cleared, which is the same as:
1705  // *pPara = SwParaPortion;
1706  const bool bMustFit = pPara->IsPrepMustFit();
1707  pPara->Truncate();
1708  pPara->FormatReset();
1709 
1710  // delete pSpaceAdd and pKanaComp
1711  pPara->FinishSpaceAdd();
1712  pPara->FinishKanaComp();
1713  pPara->ResetFlags();
1714  pPara->SetPrepMustFit( bMustFit );
1715  }
1716 
1717  OSL_ENSURE( ! IsSwapped(), "A frame is swapped before Format_" );
1718 
1719  if ( IsVertical() )
1721 
1722  SwTextFormatInfo aInf( pRenderContext, this );
1723  SwTextFormatter aLine( this, &aInf );
1724 
1726 
1727  Format_( aLine, aInf );
1728 
1729  if( aLine.IsOnceMore() )
1730  FormatOnceMore( aLine, aInf );
1731 
1732  if ( IsVertical() )
1734 
1735  OSL_ENSURE( ! IsSwapped(), "A frame is swapped after Format_" );
1736 
1737  if( 1 >= aLine.GetDropLines() )
1738  return;
1739 
1740  if( SvxAdjust::Left != aLine.GetAdjust() &&
1741  SvxAdjust::Block != aLine.GetAdjust() )
1742  {
1743  aLine.CalcDropAdjust();
1744  aLine.SetPaintDrop( true );
1745  }
1746 
1747  if( aLine.IsPaintDrop() )
1748  {
1749  aLine.CalcDropRepaint();
1750  aLine.SetPaintDrop( false );
1751  }
1752 }
1753 
1754 // We calculate the text frame's size and send a notification.
1755 // Shrink() or Grow() to adjust the frame's size to the changed required space.
1756 void SwTextFrame::Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs * )
1757 {
1758  SwRectFnSet aRectFnSet(this);
1759 
1761 
1762  // The range autopilot or the BASIC interface pass us TextFrames with
1763  // a width <= 0 from time to time
1764  if( aRectFnSet.GetWidth(getFramePrintArea()) <= 0 )
1765  {
1766  // If MustFit is set, we shrink to the Upper's bottom edge if needed.
1767  // Else we just take a standard size of 12 Pt. (240 twip).
1768  SwTextLineAccess aAccess( this );
1769  tools::Long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
1770 
1771  if( aAccess.GetPara()->IsPrepMustFit() )
1772  {
1773  const SwTwips nLimit = aRectFnSet.GetPrtBottom(*GetUpper());
1774  const SwTwips nDiff = - aRectFnSet.BottomDist( getFrameArea(), nLimit );
1775  if( nDiff > 0 )
1776  Shrink( nDiff );
1777  }
1778  else if( 240 < nFrameHeight )
1779  {
1780  Shrink( nFrameHeight - 240 );
1781  }
1782  else if( 240 > nFrameHeight )
1783  {
1784  Grow( 240 - nFrameHeight );
1785  }
1786 
1787  nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
1788  const tools::Long nTop = aRectFnSet.GetTopMargin(*this);
1789 
1790  if( nTop > nFrameHeight )
1791  {
1792  aRectFnSet.SetYMargins( *this, nFrameHeight, 0 );
1793  }
1794  else if( aRectFnSet.GetHeight(getFramePrintArea()) < 0 )
1795  {
1797  aRectFnSet.SetHeight( aPrt, 0 );
1798  }
1799 
1800  return;
1801  }
1802 
1803  const TextFrameIndex nStrLen(GetText().getLength());
1804  if ( nStrLen || !FormatEmpty() )
1805  {
1806 
1807  SetEmpty( false );
1808  // In order to not get confused by nested Formats
1809  FormatLevel aLevel;
1810  if( 12 == FormatLevel::GetLevel() )
1811  return;
1812 
1813  // We could be possibly not allowed to alter the format information
1814  if( IsLocked() )
1815  return;
1816 
1817  // Attention: Format() could be triggered by GetFormatted()
1818  if( IsHiddenNow() )
1819  {
1820  tools::Long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
1821  if( nPrtHeight )
1822  {
1823  HideHidden();
1824  Shrink( nPrtHeight );
1825  }
1826  else
1827  {
1828  // Assure that objects anchored
1829  // at paragraph resp. at/as character inside paragraph
1830  // are hidden.
1832  }
1833  ChgThisLines();
1834  return;
1835  }
1836 
1837  // We do not want to be interrupted during formatting
1838  TextFrameLockGuard aLock(this);
1839 
1840  // this is to ensure that the similar code in SwTextFrame::Format_
1841  // finds the master formatted in case it's needed
1842  if (IsFollow() && IsFieldFollow())
1843  {
1844  SwTextFrame *pMaster = FindMaster();
1845  assert(pMaster);
1846  if (!pMaster->HasPara())
1847  {
1848  pMaster->GetFormatted();
1849  }
1850  if (!pMaster->HasPara())
1851  { // master could be locked because it's being formatted upstack
1852  SAL_WARN("sw", "SwTextFrame::Format: failed to format master!");
1853  }
1854  else
1855  {
1856  SwTextSizeInfo aInf( pMaster );
1857  SwTextIter aMasterLine( pMaster, &aInf );
1858  aMasterLine.Bottom();
1859  SetOffset(aMasterLine.GetEnd());
1860  }
1861  }
1862 
1863  SwTextLineAccess aAccess( this );
1864  const bool bNew = !aAccess.IsAvailable();
1865  const bool bSetOffset =
1867 
1868  if( CalcPreps() )
1869  ; // nothing
1870  // We return if already formatted, but if the TextFrame was just created
1871  // and does not have any format information
1872  else if( !bNew && !aAccess.GetPara()->GetReformat().Len() )
1873  {
1875  {
1876  aAccess.GetPara()->SetPrepAdjust();
1877  aAccess.GetPara()->SetPrep();
1878  CalcPreps();
1879  }
1880  SetWidow( false );
1881  }
1882  else if( bSetOffset && IsFollow() )
1883  {
1884  SwTextFrame *pMaster = FindMaster();
1885  OSL_ENSURE( pMaster, "SwTextFrame::Format: homeless follow" );
1886  if( pMaster )
1887  pMaster->Prepare( PrepareHint::FollowFollows );
1888  SwTwips nMaxY = aRectFnSet.GetPrtBottom(*GetUpper());
1889 
1890  if( aRectFnSet.OverStep( getFrameArea(), nMaxY ) )
1891  {
1892  aRectFnSet.SetLimit( *this, nMaxY );
1893  }
1894  else if( aRectFnSet.BottomDist( getFrameArea(), nMaxY ) < 0 )
1895  {
1897  aRectFnSet.AddBottom( aFrm, -aRectFnSet.GetHeight(aFrm) );
1898  }
1899  }
1900  else
1901  {
1902  // bSetOffset here means that we have the "red arrow situation"
1903  if ( bSetOffset )
1905 
1906  const bool bOrphan = IsWidow();
1907  const SwFootnoteBossFrame* pFootnoteBoss = HasFootnote() ? FindFootnoteBossFrame() : nullptr;
1908  SwTwips nFootnoteHeight = 0;
1909  if( pFootnoteBoss )
1910  {
1911  const SwFootnoteContFrame* pCont = pFootnoteBoss->FindFootnoteCont();
1912  nFootnoteHeight = pCont ? aRectFnSet.GetHeight(pCont->getFrameArea()) : 0;
1913  }
1914  do
1915  {
1916  Format_( pRenderContext, aAccess.GetPara() );
1917  if( pFootnoteBoss && nFootnoteHeight )
1918  {
1919  const SwFootnoteContFrame* pCont = pFootnoteBoss->FindFootnoteCont();
1920  SwTwips nNewHeight = pCont ? aRectFnSet.GetHeight(pCont->getFrameArea()) : 0;
1921  // If we lost some footnotes, we may have more space
1922  // for our main text, so we have to format again ...
1923  if( nNewHeight < nFootnoteHeight )
1924  nFootnoteHeight = nNewHeight;
1925  else
1926  break;
1927  }
1928  else
1929  break;
1930  } while ( pFootnoteBoss );
1931  if( bOrphan )
1932  {
1933  ValidateFrame();
1934  SetWidow( false );
1935  }
1936  }
1937  if( IsEmptyMaster() )
1938  {
1939  SwFrame* pPre = GetPrev();
1940  if( pPre &&
1941  // i#10826 It's the first, it cannot keep!
1942  pPre->GetIndPrev() &&
1943  pPre->GetAttrSet()->GetKeep().GetValue() )
1944  {
1945  pPre->InvalidatePos();
1946  }
1947  }
1948  }
1949 
1950  ChgThisLines();
1951 
1952  // the PrepMustFit should not survive a Format operation
1953  SwParaPortion *pPara = GetPara();
1954  if ( pPara )
1955  pPara->SetPrepMustFit( false );
1956 
1958  CalcHeightOfLastLine(); // i#11860 - Adjust spacing implementation for
1959  // object positioning - Compatibility to MS Word
1960  // tdf#117982 -- Fix cell spacing hides content
1961  // Check if the cell's content has greater size than the row height
1963  || (getFramePrintArea().Height() <= 0)))
1964  {
1965  SAL_INFO("sw.core", "Warn: Cell content has greater size than cell height!");
1966  //get font size...
1967  SwTwips aTmpHeight = getFrameArea().Height();
1968  //...and push it into the text frame
1970  //if only bottom margin what we have:
1971  if (GetTopMargin() == 0)
1972  //set the frame to its original location
1973  aPrt.SetTopAndHeight(0, aTmpHeight);
1974  }
1975 }
1976 
1977 // bForceQuickFormat is set if GetFormatted() has been called during the
1978 // painting process. Actually I cannot imagine a situation which requires
1979 // a full formatting of the paragraph during painting, on the other hand
1980 // a full formatting can cause the invalidation of other layout frames,
1981 // e.g., if there are footnotes in this paragraph, and invalid layout
1982 // frames will not calculated during the painting. So I actually want to
1983 // avoid a formatting during painting, but since I'm a coward, I'll only
1984 // force the quick formatting in the situation of issue i29062.
1985 bool SwTextFrame::FormatQuick( bool bForceQuickFormat )
1986 {
1987  OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
1988  "SwTextFrame::FormatQuick with swapped frame" );
1989 
1990  if( IsEmpty() && FormatEmpty() )
1991  return true;
1992 
1993  // We're very picky:
1994  if( HasPara() || IsWidow() || IsLocked()
1995  || !isFrameAreaSizeValid() ||
1997  return false;
1998 
1999  SwTextLineAccess aAccess( this );
2000  SwParaPortion *pPara = aAccess.GetPara();
2001  if( !pPara )
2002  return false;
2003 
2004  SwFrameSwapper aSwapper( this, true );
2005 
2006  TextFrameLockGuard aLock(this);
2007  SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true );
2008  if( 0 != aInf.MaxHyph() ) // Respect MaxHyphen!
2009  return false;
2010 
2011  SwTextFormatter aLine( this, &aInf );
2012 
2013  // DropCaps are too complicated ...
2014  if( aLine.GetDropFormat() )
2015  return false;
2016 
2017  TextFrameIndex nStart = GetOffset();
2018  const TextFrameIndex nEnd = GetFollow()
2019  ? GetFollow()->GetOffset()
2020  : TextFrameIndex(aInf.GetText().getLength());
2021 
2022  int nLoopProtection = 0;
2023  do
2024  {
2025  TextFrameIndex nNewStart = aLine.FormatLine(nStart);
2026  if (nNewStart == nStart)
2027  ++nLoopProtection;
2028  else
2029  nLoopProtection = 0;
2030  nStart = nNewStart;
2031  const bool bWillEndlessInsert = nLoopProtection > 250;
2032  SAL_WARN_IF(bWillEndlessInsert, "sw", "loop detection triggered");
2033  if ((!bWillEndlessInsert) // Check for special case: line is invisible,
2034  // like in too thin table cell: tdf#66141
2035  && (aInf.IsNewLine() || (!aInf.IsStop() && nStart < nEnd)))
2036  aLine.Insert( new SwLineLayout() );
2037  } while( aLine.Next() );
2038 
2039  // Last exit: the heights need to match
2040  Point aTopLeft( getFrameArea().Pos() );
2041  aTopLeft += getFramePrintArea().Pos();
2042  const SwTwips nNewHeight = aLine.Y() + aLine.GetLineHeight();
2043  const SwTwips nOldHeight = aTopLeft.Y() + getFramePrintArea().Height();
2044 
2045  if( !bForceQuickFormat && nNewHeight != nOldHeight && !IsUndersized() )
2046  {
2047  // Attention: This situation can occur due to FormatLevel==12. Don't panic!
2048  TextFrameIndex const nStrt = GetOffset();
2049  InvalidateRange_( SwCharRange( nStrt, nEnd - nStrt) );
2050  return false;
2051  }
2052 
2053  if (m_pFollow && nStart != static_cast<SwTextFrame*>(m_pFollow)->GetOffset())
2054  return false; // can be caused by e.g. Orphans
2055 
2056  // We made it!
2057 
2058  // Set repaint
2059  pPara->GetRepaint().Pos( aTopLeft );
2060  pPara->GetRepaint().SSize( getFramePrintArea().SSize() );
2061 
2062  // Delete reformat
2063  pPara->GetReformat() = SwCharRange();
2064  pPara->GetDelta() = 0;
2065 
2066  return true;
2067 }
2068 
2069 /* 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
virtual void Height(const SwTwips nNew, const bool bText=true) override
Definition: porlay.cxx:199
Base class of the Writer layout elements.
Definition: frame.hxx:315
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
SwTwips GetParHeight() const
Returns the sum of line height in pLine.
Definition: txtfrm.cxx:3326
sal_uLong GetIndex() const
Definition: node.hxx:291
void AllowFollowFormat()
Definition: txtfrm.hxx:748
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
bool IsFollow() const
Definition: flowfrm.hxx:166
void SetRstHeight(const SwTextMargin &rLine)
Definition: widorp.cxx:214
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:565
void Right(const SwTwips nNew)
Definition: itrtxt.hxx:157
void CalcDropRepaint()
Definition: itradj.cxx:828
bool IsPrepAdjust() const
Definition: porlay.hxx:313
sal_uInt16 GetLineNr() const
Definition: itrtxt.hxx:87
bool IsClipping() const
Definition: porlay.hxx:156
void SetPrepAdjust()
Definition: porlay.hxx:312
bool IsInFly() const
Definition: frame.hxx:962
bool FollowFormatAllowed() const
Definition: txtfrm.hxx:743
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1503
bool IsInSct() const
Definition: frame.hxx:968
const SwTwips WIDOW_MAGIC
Definition: txtfrm.hxx:1027
tools::Long BottomDist(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1415
bool IsRest() const
Definition: porlay.hxx:131
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:990
SwLineLayout * GetNext()
Definition: porlay.hxx:161
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:887
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:1094
bool IsNewLine() const
Definition: itrform2.hxx:177
void ClrOrphLines()
Definition: widorp.hxx:63
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
SwNodeIndex nNode
Definition: pam.hxx:37
void SetCompletePaint() const
Definition: frame.hxx:995
SwParaPortion * GetPara()
Definition: txtcache.cxx:50
bool IsInFootnote() const
Definition: frame.hxx:950
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:178
const SwRect & getFramePrintArea() const
Definition: frame.hxx:181
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:151
SwParaPortion * GetPara()
Definition: txtcache.cxx:90
void InvalidatePos()
Definition: frame.hxx:1044
const SwBodyFrame * FindBodyFrame() const
Definition: frame.hxx:1121
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:1697
void CalcDropAdjust()
Definition: itradj.cxx:745
bool IsVert() const
Definition: frame.hxx:1368
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:1180
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:171
bool IsPrep() const
Definition: porlay.hxx:307
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
bool IsKeepAlways() const
Definition: widorp.hxx:38
bool IsCellFrame() const
Definition: frame.hxx:1227
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:1382
SwTwips Y() const
Definition: itrtxt.hxx:90
void AddBottom(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1395
bool IsEndHyph() const
Definition: porlay.hxx:125
sal_uInt8 & MaxHyph()
Definition: inftxt.hxx:553
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Definition: porlay.hxx:251
void SetTopAndHeight(tools::Long nTop, tools::Long nNew)
Definition: swrect.cxx:156
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:172
TextFrameIndex & Start()
Definition: porlay.hxx:47
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:1985
size_type size() const
Definition: docary.hxx:265
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:1378
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:1211
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:180
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:956
sal_Int32 & GetTabPos()
bool IsPaintDrop() const
Definition: itrpaint.hxx:56
void FormatReset()
Definition: porlay.hxx:337
void Width(tools::Long nNew)
Definition: swrect.hxx:189
sal_Unicode & GetDecimal()
void ResetFlags()
Definition: porlay.cxx:765
void CtorInitTextFormatInfo(OutputDevice *pRenderContext, SwTextFrame *pFrame, const bool bInterHyph=false, const bool bQuick=false, const bool bTst=false)
Definition: inftxt.cxx:1394
bool IsSctFrame() const
Definition: frame.hxx:1215
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:1418
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:290
bool IsFollowField() const
Definition: porlay.hxx:315
bool IsColumnFrame() const
Definition: frame.hxx:1183
bool IsEmpty() const
Definition: txtfrm.hxx:521
void ResetPreps()
Definition: txtfrm.cxx:1353
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1108
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:725
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:2099
SwTwips GetLineStart() const
Definition: itrcrsr.cxx:376
tools::Long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1411
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:80
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:728
void SplitFrame(TextFrameIndex nTextPos)
Methods to manage the FollowFrame.
Definition: frmform.cxx:683
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:169
size_t size() const
Definition: sortedobjs.cxx:43
Mutex aLock
SwPageFrame * FindPageFrame()
Definition: frame.hxx:681
SwParaPortion * GetParaPortion()
Definition: inftxt.hxx:121
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:888
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:288
tools::Long YInc(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1426
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:1383
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:88
void FinishKanaComp()
Definition: porlay.hxx:203
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:92
bool IsParagraph(bool bHard=false) const
Definition: viewopt.hxx:236
SwLayoutFrame * GetUpper()
Definition: frame.hxx:679
bool HasArea() const
Definition: swrect.hxx:300
void SetOffset_(TextFrameIndex nNewOfst)
Definition: frmform.cxx:758
void AddHeight(const tools::Long nAdd)
Definition: swrect.cxx:124
bool isFramePrintAreaValid() const
Definition: frame.hxx:169
bool IsPrepWidows() const
Definition: porlay.hxx:309
SwTwips GetLeftMargin() const
Definition: itrtxt.hxx:328
bool IsUndersized() const
Definition: flowfrm.hxx:158
void FinishSpaceAdd()
Definition: porlay.hxx:188
const SwLineLayout * GetPrev()
Definition: itrtxt.cxx:82
tools::Long GetPrtTop(const SwFrame &rFrame) const
Definition: frame.hxx:1410
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
Definition: findfrm.cxx:436
SwFrame * GetPrev()
Definition: frame.hxx:678
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:1404
void AddWidth(const tools::Long nAdd)
Definition: swrect.cxx:123
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:1424
void SSize(const Size &rNew)
Definition: swrect.hxx:180
bool IsLocked() const
Definition: txtfrm.hxx:517
const sal_uInt8 & CntMidHyph() const
Definition: itrform2.hxx:220
bool isFrameAreaSizeValid() const
Definition: frame.hxx:168
bool IsUnclipped() const
Definition: itrform2.hxx:207
TextFrameIndex GetLen() const
Definition: porlin.hxx:75
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:74
Point GetTopLeft() const
Definition: itrtxt.hxx:186
tools::Long SwTwips
Definition: swtypes.hxx:52
bool IsMargin() const
Definition: porlay.hxx:322
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:1756
bool IsStop() const
Definition: inftxt.hxx:573
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1547
void InvalidateSize()
Definition: frame.hxx:1030
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1116
void ValidateFrame()
Definition: frmform.cxx:81
SwFrame * FindColFrame()
Definition: findfrm.cxx:530
void SetUnclipped(bool bNew)
Definition: itrform2.hxx:208
SwTwips & GetAscent()
Definition: porlin.hxx:78
void Truncate()
Definition: porlin.hxx:201
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:51
const SwLineLayout * Prev()
Definition: itrtxt.cxx:89
bool IsPrepMustFit() const
Definition: porlay.hxx:311
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool OverStep(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1419
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
void SetYMargins(SwFrame &rFrame, tools::Long nTop, tools::Long nBottom) const
Definition: frame.hxx:1409
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1617
bool IsVertLR() const
Definition: frame.hxx:980
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:2036
bool IsMidHyph() const
Definition: porlay.hxx:127
SwTwips Width() const
Definition: possiz.hxx:52
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:1165
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:286
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:1392
void SwapWidthAndHeight()
Swaps width and height of the text frame.
Definition: txtfrm.cxx:422
void SetRightOfst(const SwTwips nNew)
Definition: porlay.hxx:75
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:988
void SetKeep(const bool bNew)
Definition: widorp.hxx:40
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1840
void setFrameAreaSizeValid(bool bNew)
Definition: wsfrm.cxx:91
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:1179
void SetPaintDrop(const bool bNew)
Definition: itrpaint.hxx:55
double getLength(const B2DPolygon &rCandidate)
void SetPrep()
Definition: porlay.hxx:306
void FormatOnceMore(SwTextFormatter &rLine, SwTextFormatInfo &rInf)
Definition: frmform.cxx:1635
void SetWidow(const bool bNew)
Definition: txtfrm.hxx:245
virtual void Cut() override
Definition: wsfrm.cxx:1130
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:58
void SetPrepMustFit(const bool bNew)
Definition: porlay.hxx:310
const SwLineLayout * GetCurr() const
Definition: itrtxt.hxx:83
SwLinePortion * MakeRestPortion(const SwLineLayout *pLine, TextFrameIndex nPos)
Definition: pormulti.cxx:2388
bool IsVertical() const
Definition: frame.hxx:974
tools::Long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1379
virtual SwContentFrame * MakeFrame(SwFrame *) override
Virtual methods from ContentNode.
Definition: ndtxt.cxx:272
void Insert(SwLineLayout *pLine)
Definition: itrform2.cxx:124
#define SAL_WARN(area, stream)
SwTwips GetOffset() const
Definition: porlay.hxx:72
bool IsTest() const
Definition: inftxt.hxx:587
bool IsFlyInCntBase() const
Definition: itrform2.hxx:210
SwTwips GetLineHeight() const
Definition: itrtxt.hxx:116
virtual void MakePos()
Definition: calcmove.cxx:539
void SetOffset(const SwTwips nNew)
Definition: porlay.hxx:73
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
bool IsFieldFollow() const
Definition: txtfrm.hxx:524
bool IsBodyFrame() const
Definition: frame.hxx:1207
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:166
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:193
void RemoveFootnote(TextFrameIndex nStart, TextFrameIndex nLen=TextFrameIndex(COMPLETE_STRING))
Footnote.
Definition: txtftn.cxx:400
TextFrameIndex & Len()
Definition: porlay.hxx:51
SwContentFrame * JoinFrame()
Definition: frmform.cxx:613
SwRootFrame * getRootFrame()
Definition: frame.hxx:680
bool HasUnderscore() const
Definition: porlay.hxx:149
bool IsAvailable() const
Definition: txtcache.cxx:70
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:856
bool CalcOnceMore()
Definition: itrform2.cxx:2023
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1027
void ChgThisLines()
Definition: txtfrm.cxx:3767
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1100
SwFrame * GetNext()
Definition: frame.hxx:677
bool HasFootnote() const
Definition: txtfrm.hxx:522