LibreOffice Module sw (master)  1
wsfrm.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 <hints.hxx>
21 #include <svl/itemiter.hxx>
22 #include <editeng/brushitem.hxx>
23 #include <fmtornt.hxx>
24 #include <pagefrm.hxx>
25 #include <section.hxx>
26 #include <rootfrm.hxx>
27 #include <anchoreddrawobject.hxx>
28 #include <fmtanchr.hxx>
29 #include <viewimp.hxx>
30 #include <viewopt.hxx>
34 #include <redline.hxx>
35 #include <fesh.hxx>
36 #include <docsh.hxx>
37 #include <ftninfo.hxx>
38 #include <ftnidx.hxx>
39 #include <fmtclbl.hxx>
40 #include <fmtfsize.hxx>
41 #include <fmtpdsc.hxx>
42 #include <txtftn.hxx>
43 #include <fmtftn.hxx>
44 #include <fmtsrnd.hxx>
45 #include <fmtcntnt.hxx>
46 #include <ftnfrm.hxx>
47 #include <tabfrm.hxx>
48 #include <flyfrms.hxx>
49 #include <sectfrm.hxx>
50 #include <fmtclds.hxx>
51 #include <txtfrm.hxx>
52 #include <bodyfrm.hxx>
53 #include <cellfrm.hxx>
54 #include <dbg_lay.hxx>
55 #include <editeng/frmdiritem.hxx>
56 #include <sortedobjs.hxx>
57 #include <frmatr.hxx>
58 #include <frmtool.hxx>
59 #include <ndtxt.hxx>
60 
61 // RotateFlyFrame3
63 
64 using namespace ::com::sun::star;
65 
67 : maFrameArea(),
68  maFramePrintArea(),
69  mbFrameAreaPositionValid(false),
70  mbFrameAreaSizeValid(false),
71  mbFramePrintAreaValid(false),
72  mnFrameId(SwFrameAreaDefinition::mnLastFrameId++)
73 {
74 }
75 
77 {
78 }
79 
81 {
82  if(mbFrameAreaPositionValid != bNew)
83  {
85  }
86 }
87 
89 {
90  if(mbFrameAreaSizeValid != bNew)
91  {
92  mbFrameAreaSizeValid = bNew;
93  }
94 }
95 
97 {
98  if(mbFramePrintAreaValid != bNew)
99  {
100  mbFramePrintAreaValid = bNew;
101  }
102 }
103 
105 {
106  if(mrTarget.maFrameArea != *this)
107  {
108  mrTarget.maFrameArea = *this;
109  }
110 }
111 
113 {
114  if(mrTarget.maFramePrintArea != *this)
115  {
116  mrTarget.maFramePrintArea = *this;
117  }
118 }
119 
120 // RotateFlyFrame3 - Support for Transformations
122 {
123  // default implementation hands out FrameArea (outer frame)
124  const SwRect& rFrameArea(getFrameArea());
125 
127  rFrameArea.Width(), rFrameArea.Height(),
128  rFrameArea.Left(), rFrameArea.Top());
129 }
130 
132 {
133  // default implementation hands out FramePrintArea (outer frame)
134  // Take into account that FramePrintArea is relative to FrameArea
135  const SwRect& rFrameArea(getFrameArea());
136  const SwRect& rFramePrintArea(getFramePrintArea());
137 
139  rFramePrintArea.Width(), rFramePrintArea.Height(),
140  rFramePrintArea.Left() + rFrameArea.Left(),
141  rFramePrintArea.Top() + rFrameArea.Top());
142 }
143 
145 {
146  // RotateFlyFrame3: default is to change the FrameArea, FramePrintArea needs no
147  // change since it is relative to FrameArea
149 
150  if (aFrm.Pos().X() != FAR_AWAY)
151  {
152  aFrm.Pos().AdjustX(rOffset.X() );
153  }
154 
155  if (aFrm.Pos().Y() != FAR_AWAY)
156  {
157  aFrm.Pos().AdjustY(rOffset.Y() );
158  }
159 }
160 
162 {
163  const basegfx::B2DHomMatrix& rSource(getLocalFrameAreaTransformation());
164 
165  if(rSource.isIdentity())
166  {
167  return mrSwFrameAreaDefinition.getFrameArea();
168  }
169  else
170  {
171  basegfx::B2DVector aScale, aTranslate;
172  double fRotate, fShearX;
173  rSource.decompose(aScale, aTranslate, fRotate, fShearX);
174  const basegfx::B2DPoint aCenter(rSource * basegfx::B2DPoint(0.5, 0.5));
175  const basegfx::B2DVector aAbsScale(basegfx::absolute(aScale));
176 
177  return SwRect(
178  basegfx::fround(aCenter.getX() - (0.5 * aAbsScale.getX())),
179  basegfx::fround(aCenter.getY() - (0.5 * aAbsScale.getY())),
180  basegfx::fround(aAbsScale.getX()),
181  basegfx::fround(aAbsScale.getY()));
182  }
183 }
184 
186 {
187  const basegfx::B2DHomMatrix& rSource(getLocalFramePrintAreaTransformation());
188 
189  if(rSource.isIdentity())
190  {
191  return mrSwFrameAreaDefinition.getFramePrintArea();
192  }
193  else
194  {
195  basegfx::B2DVector aScale, aTranslate;
196  double fRotate, fShearX;
197  rSource.decompose(aScale, aTranslate, fRotate, fShearX);
198  const basegfx::B2DPoint aCenter(rSource * basegfx::B2DPoint(0.5, 0.5));
199  const basegfx::B2DVector aAbsScale(basegfx::absolute(aScale));
200  const SwRect aUntransformedFrameArea(getUntransformedFrameArea());
201 
202  return SwRect(
203  basegfx::fround(aCenter.getX() - (0.5 * aAbsScale.getX())) - aUntransformedFrameArea.Left(),
204  basegfx::fround(aCenter.getY() - (0.5 * aAbsScale.getY())) - aUntransformedFrameArea.Top(),
205  basegfx::fround(aAbsScale.getX()),
206  basegfx::fround(aAbsScale.getY()));
207  }
208 }
209 
211  double fRotation,
212  const basegfx::B2DPoint& rCenter)
213 {
214  const basegfx::B2DHomMatrix aRotateAroundCenter(
216  rCenter.getX(),
217  rCenter.getY(),
218  fRotation));
219  const SwRect& rFrameArea(mrSwFrameAreaDefinition.getFrameArea());
220  const SwRect& rFramePrintArea(mrSwFrameAreaDefinition.getFramePrintArea());
221 
222  maFrameAreaTransformation = aRotateAroundCenter * basegfx::utils::createScaleTranslateB2DHomMatrix(
223  rFrameArea.Width(), rFrameArea.Height(),
224  rFrameArea.Left(), rFrameArea.Top());
225  maFramePrintAreaTransformation = aRotateAroundCenter * basegfx::utils::createScaleTranslateB2DHomMatrix(
226  rFramePrintArea.Width(), rFramePrintArea.Height(),
227  rFramePrintArea.Left() + rFrameArea.Left(), rFramePrintArea.Top() + rFrameArea.Top());
228 }
229 
231 {
232  if(!getLocalFrameAreaTransformation().isIdentity())
233  {
234  basegfx::B2DRange aRangeFrameArea(0.0, 0.0, 1.0, 1.0);
235  aRangeFrameArea.transform(getLocalFrameAreaTransformation());
236  const SwRect aNewFrm(
237  basegfx::fround(aRangeFrameArea.getMinX()), basegfx::fround(aRangeFrameArea.getMinY()),
238  basegfx::fround(aRangeFrameArea.getWidth()), basegfx::fround(aRangeFrameArea.getHeight()));
239 
240  if(aNewFrm != mrSwFrameAreaDefinition.getFrameArea())
241  {
242  SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(mrSwFrameAreaDefinition);
243  aFrm.setSwRect(aNewFrm);
244  }
245  }
246 
247  if(!getLocalFramePrintAreaTransformation().isIdentity())
248  {
249  basegfx::B2DRange aRangeFramePrintArea(0.0, 0.0, 1.0, 1.0);
250  aRangeFramePrintArea.transform(getLocalFramePrintAreaTransformation());
251  const SwRect aNewPrt(
252  basegfx::fround(aRangeFramePrintArea.getMinX()) - mrSwFrameAreaDefinition.getFrameArea().Left(),
253  basegfx::fround(aRangeFramePrintArea.getMinY()) - mrSwFrameAreaDefinition.getFrameArea().Top(),
254  basegfx::fround(aRangeFramePrintArea.getWidth()),
255  basegfx::fround(aRangeFramePrintArea.getHeight()));
256 
257  if(aNewPrt != mrSwFrameAreaDefinition.getFramePrintArea())
258  {
259  SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(mrSwFrameAreaDefinition);
260  aPrt.setSwRect(aNewPrt);
261  }
262  }
263 }
264 
266 {
267  // This can be done fully based on the Transformations currently
268  // set, so use this. Only needed when transformation *is* used
269  if(!getLocalFrameAreaTransformation().isIdentity())
270  {
271  SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(mrSwFrameAreaDefinition);
272  aFrm.setSwRect(getUntransformedFrameArea());
273  }
274 
275  if(!getLocalFramePrintAreaTransformation().isIdentity())
276  {
277  SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(mrSwFrameAreaDefinition);
278  aPrt.setSwRect(getUntransformedFramePrintArea());
279  }
280 }
281 
282 // transform by given B2DHomMatrix
284 {
285  maFrameAreaTransformation *= aTransform;
286  maFramePrintAreaTransformation *= aTransform;
287 }
288 
291  SwClient( pMod ),
292  SfxBroadcaster(),
293  mpRoot( pSib ? pSib->getRootFrame() : nullptr ),
294  mpUpper(nullptr),
295  mpNext(nullptr),
296  mpPrev(nullptr),
297  mnFrameType(SwFrameType::None),
298  mbInDtor(false),
299  mbInvalidR2L(true),
300  mbDerivedR2L(false),
301  mbRightToLeft(false),
302  mbInvalidVert(true),
303  mbDerivedVert(false),
304  mbVertical(false),
305  mbVertLR(false),
306  mbVertLRBT(false),
307  mbValidLineNum(false),
308  mbFixSize(false),
309  mbCompletePaint(true),
310  mbRetouche(false),
311  mbInfInvalid(true),
312  mbInfBody( false ),
313  mbInfTab ( false ),
314  mbInfFly ( false ),
315  mbInfFootnote ( false ),
316  mbInfSct ( false ),
317  mbColLocked(false),
318  m_isInDestroy(false),
319  mbForbidDelete(false)
320 {
321  OSL_ENSURE( pMod, "No frame format given." );
322 }
323 
325 {
327 }
328 
329 bool SwFrame::KnowsFormat( const SwFormat& rFormat ) const
330 {
331  return GetRegisteredIn() == &rFormat;
332 }
333 
335 {
336  rFormat.Add( this );
337 }
338 
339 void SwFrame::CheckDir( SvxFrameDirection nDir, bool bVert, bool bOnlyBiDi, bool bBrowse )
340 {
341  if( SvxFrameDirection::Environment == nDir || ( bVert && bOnlyBiDi ) )
342  {
343  mbDerivedVert = true;
344  if( SvxFrameDirection::Environment == nDir )
345  mbDerivedR2L = true;
346  SetDirFlags( bVert );
347  }
348  else if( bVert )
349  {
350  mbInvalidVert = false;
351  if( SvxFrameDirection::Horizontal_LR_TB == nDir || SvxFrameDirection::Horizontal_RL_TB == nDir
352  || bBrowse )
353  {
354  mbVertical = false;
355  mbVertLR = false;
356  mbVertLRBT = false;
357  }
358  else
359  {
360  mbVertical = true;
361  if(SvxFrameDirection::Vertical_RL_TB == nDir)
362  {
363  mbVertLR = false;
364  mbVertLRBT = false;
365  }
366  else if(SvxFrameDirection::Vertical_LR_TB==nDir)
367  {
368  mbVertLR = true;
369  mbVertLRBT = false;
370  }
371  else if (nDir == SvxFrameDirection::Vertical_LR_BT)
372  {
373  mbVertLR = true;
374  mbVertLRBT = true;
375  }
376  }
377  }
378  else
379  {
380  mbInvalidR2L = false;
381  if( SvxFrameDirection::Horizontal_RL_TB == nDir )
382  mbRightToLeft = true;
383  else
384  mbRightToLeft = false;
385  }
386 }
387 
388 void SwFrame::CheckDirection( bool bVert )
389 {
390  if( bVert )
391  {
392  if( !IsHeaderFrame() && !IsFooterFrame() )
393  {
394  mbDerivedVert = true;
395  SetDirFlags( bVert );
396  }
397  }
398  else
399  {
400  mbDerivedR2L = true;
401  SetDirFlags( bVert );
402  }
403 }
404 
406 {
407  const SwFrameFormat* pFormat = GetFormat();
408  if( pFormat )
409  {
410  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
411  const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
412  CheckDir(pFormat->GetFormatAttr(RES_FRAMEDIR).GetValue(),
413  bVert, true, bBrowseMode );
414  }
415  else
416  SwFrame::CheckDirection( bVert );
417 }
418 
419 void SwFlyFrame::CheckDirection( bool bVert )
420 {
421  const SwFrameFormat* pFormat = GetFormat();
422  if( pFormat )
423  {
424  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
425  const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
426  CheckDir(pFormat->GetFormatAttr(RES_FRAMEDIR).GetValue(),
427  bVert, false, bBrowseMode );
428  }
429  else
430  SwFrame::CheckDirection( bVert );
431 }
432 
433 void SwTabFrame::CheckDirection( bool bVert )
434 {
435  const SwFrameFormat* pFormat = GetFormat();
436  if( pFormat )
437  {
438  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
439  const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
440  CheckDir(pFormat->GetFormatAttr(RES_FRAMEDIR).GetValue(),
441  bVert, true, bBrowseMode );
442  }
443  else
444  SwFrame::CheckDirection( bVert );
445 }
446 
447 void SwCellFrame::CheckDirection( bool bVert )
448 {
449  const SwFrameFormat* pFormat = GetFormat();
450  const SfxPoolItem* pItem;
451  // Check if the item is set, before actually
452  // using it. Otherwise the dynamic pool default is used, which may be set
453  // to LTR in case of OOo 1.0 documents.
454  if( pFormat && SfxItemState::SET == pFormat->GetItemState( RES_FRAMEDIR, true, &pItem ) )
455  {
456  const SvxFrameDirectionItem* pFrameDirItem = static_cast<const SvxFrameDirectionItem*>(pItem);
457  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
458  const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
459  CheckDir( pFrameDirItem->GetValue(), bVert, false, bBrowseMode );
460  }
461  else
462  SwFrame::CheckDirection( bVert );
463 }
464 
465 void SwTextFrame::CheckDirection( bool bVert )
466 {
467  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
468  const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
469  CheckDir(GetTextNodeForParaProps()->GetSwAttrSet().GetFrameDir().GetValue(),
470  bVert, true, bBrowseMode);
471 }
472 
473 void SwFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
474 {
475  sal_uInt8 nInvFlags = 0;
476 
477  if( pOld && pNew && RES_ATTRSET_CHG == pNew->Which() )
478  {
479  SfxItemIter aNIter( *static_cast<const SwAttrSetChg*>(pNew)->GetChgSet() );
480  SfxItemIter aOIter( *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet() );
481  while( true )
482  {
483  UpdateAttrFrame( aOIter.GetCurItem(),
484  aNIter.GetCurItem(), nInvFlags );
485  if( aNIter.IsAtEnd() )
486  break;
487  aNIter.NextItem();
488  aOIter.NextItem();
489  }
490  }
491  else
492  UpdateAttrFrame( pOld, pNew, nInvFlags );
493 
494  if ( nInvFlags != 0 )
495  {
496  SwPageFrame *pPage = FindPageFrame();
497  InvalidatePage( pPage );
498  if ( nInvFlags & 0x01 )
499  {
500  InvalidatePrt_();
501  if( !GetPrev() && IsTabFrame() && IsInSct() )
503  }
504  if ( nInvFlags & 0x02 )
505  InvalidateSize_();
506  if ( nInvFlags & 0x04 )
507  InvalidatePos_();
508  if ( nInvFlags & 0x08 )
510  SwFrame *pNxt;
511  if ( nInvFlags & 0x30 && nullptr != (pNxt = GetNext()) )
512  {
513  pNxt->InvalidatePage( pPage );
514  if ( nInvFlags & 0x10 )
515  pNxt->InvalidatePos_();
516  if ( nInvFlags & 0x20 )
517  pNxt->SetCompletePaint();
518  }
519  }
520 }
521 
522 void SwFrame::UpdateAttrFrame( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
523  sal_uInt8 &rInvFlags )
524 {
525  sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
526  switch( nWhich )
527  {
528  case RES_BOX:
529  case RES_SHADOW:
531  [[fallthrough]];
532  case RES_LR_SPACE:
533  case RES_UL_SPACE:
534  rInvFlags |= 0x0B;
535  break;
536 
538  rInvFlags |= 0x03;
539  break;
540 
541  case RES_BACKGROUND:
542  rInvFlags |= 0x28;
543  break;
544 
545  case RES_KEEP:
546  rInvFlags |= 0x04;
547  break;
548 
549  case RES_FRM_SIZE:
551  rInvFlags |= 0x13;
552  break;
553 
554  case RES_FMT_CHG:
555  rInvFlags |= 0x0F;
556  break;
557 
558  case RES_ROW_SPLIT:
559  {
560  if ( IsRowFrame() )
561  {
562  bool bInFollowFlowRow = nullptr != IsInFollowFlowRow();
563  if ( bInFollowFlowRow || nullptr != IsInSplitTableRow() )
564  {
565  SwTabFrame* pTab = FindTabFrame();
566  if ( bInFollowFlowRow )
567  pTab = pTab->FindMaster();
568  pTab->SetRemoveFollowFlowLinePending( true );
569  }
570  }
571  break;
572  }
573  case RES_COL:
574  OSL_FAIL( "Columns for new FrameType?" );
575  break;
576 
577  default:
578  // the new FillStyle has to do the same as previous RES_BACKGROUND
579  if(nWhich >= XATTR_FILL_FIRST && nWhich <= XATTR_FILL_LAST)
580  {
581  rInvFlags |= 0x28;
582  }
583  /* do Nothing */;
584  }
585 }
586 
587 bool SwFrame::Prepare( const PrepareHint, const void *, bool )
588 {
589  /* Do nothing */
590  return false;
591 }
592 
597 void SwFrame::InvalidatePage( const SwPageFrame *pPage ) const
598 {
599  if ( !pPage )
600  {
601  pPage = FindPageFrame();
602  // #i28701# - for at-character and as-character
603  // anchored Writer fly frames additionally invalidate also page frame
604  // its 'anchor character' is on.
605  if ( pPage && pPage->GetUpper() && IsFlyFrame() )
606  {
607  const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(this);
608  if ( pFlyFrame->IsAutoPos() || pFlyFrame->IsFlyInContentFrame() )
609  {
610  // #i33751#, #i34060# - method <GetPageFrameOfAnchor()>
611  // is replaced by method <FindPageFrameOfAnchor()>. It's return value
612  // have to be checked.
613  SwPageFrame* pPageFrameOfAnchor =
614  const_cast<SwFlyFrame*>(pFlyFrame)->FindPageFrameOfAnchor();
615  if ( pPageFrameOfAnchor && pPageFrameOfAnchor != pPage )
616  {
617  InvalidatePage( pPageFrameOfAnchor );
618  }
619  }
620  }
621  }
622 
623  if ( pPage && pPage->GetUpper() )
624  {
625  if ( pPage->GetFormat()->GetDoc()->IsInDtor() )
626  return;
627 
628  SwRootFrame *pRoot = const_cast<SwRootFrame*>(static_cast<const SwRootFrame*>(pPage->GetUpper()));
629  const SwFlyFrame *pFly = FindFlyFrame();
630  if ( IsContentFrame() )
631  {
632  if ( pRoot->IsTurboAllowed() )
633  {
634  // If a ContentFrame wants to register for a second time, make it a TurboAction.
635  if ( !pRoot->GetTurbo() || this == pRoot->GetTurbo() )
636  pRoot->SetTurbo( static_cast<const SwContentFrame*>(this) );
637  else
638  {
639  pRoot->DisallowTurbo();
640  //The page of the Turbo could be a different one then mine,
641  //therefore we have to invalidate it.
642  const SwFrame *pTmp = pRoot->GetTurbo();
643  pRoot->ResetTurbo();
644  pTmp->InvalidatePage();
645  }
646  }
647  if ( !pRoot->GetTurbo() )
648  {
649  if ( pFly )
650  { if( !pFly->IsLocked() )
651  {
652  if ( pFly->IsFlyInContentFrame() )
653  { pPage->InvalidateFlyInCnt();
654  pFly->GetAnchorFrame()->InvalidatePage();
655  }
656  else
657  pPage->InvalidateFlyContent();
658  }
659  }
660  else
661  pPage->InvalidateContent();
662  }
663  }
664  else
665  {
666  pRoot->DisallowTurbo();
667  if ( pFly )
668  {
669  if ( !pFly->IsLocked() )
670  {
671  if ( pFly->IsFlyInContentFrame() )
672  {
673  pPage->InvalidateFlyInCnt();
674  pFly->GetAnchorFrame()->InvalidatePage();
675  }
676  else
677  pPage->InvalidateFlyLayout();
678  }
679  }
680  else
681  pPage->InvalidateLayout();
682 
683  if ( pRoot->GetTurbo() )
684  { const SwFrame *pTmp = pRoot->GetTurbo();
685  pRoot->ResetTurbo();
686  pTmp->InvalidatePage();
687  }
688  }
689  pRoot->SetIdleFlags();
690 
691  if (IsTextFrame())
692  {
693  SwTextFrame const*const pText(static_cast<SwTextFrame const*>(this));
694  if (sw::MergedPara const*const pMergedPara = pText->GetMergedPara())
695  {
696  SwTextNode const* pNode(nullptr);
697  for (auto const& e : pMergedPara->extents)
698  {
699  if (e.pNode != pNode)
700  {
701  pNode = e.pNode;
702  if (pNode->IsGrammarCheckDirty())
703  {
704  pRoot->SetNeedGrammarCheck( true );
705  break;
706  }
707  }
708  }
709  }
710  else
711  {
712  if (pText->GetTextNodeFirst()->IsGrammarCheckDirty())
713  {
714  pRoot->SetNeedGrammarCheck( true );
715  }
716  }
717  }
718  }
719 }
720 
721 Size SwFrame::ChgSize( const Size& aNewSize )
722 {
723  mbFixSize = true;
724  const Size aOldSize( getFrameArea().SSize() );
725  if ( aNewSize == aOldSize )
726  return aOldSize;
727 
728  if ( GetUpper() )
729  {
730  bool bNeighb = IsNeighbourFrame();
731  SwRectFn fnRect = IsVertical() == bNeighb ? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert );
732  SwRect aNew( Point(0,0), aNewSize );
733 
734  {
736  (aFrm.*fnRect->fnSetWidth)( (aNew.*fnRect->fnGetWidth)() );
737  }
738 
739  long nNew = (aNew.*fnRect->fnGetHeight)();
740  long nDiff = nNew - (getFrameArea().*fnRect->fnGetHeight)();
741 
742  if( nDiff )
743  {
744  if ( GetUpper()->IsFootnoteBossFrame() && HasFixSize() &&
746  static_cast<SwFootnoteBossFrame*>(GetUpper())->NeighbourhoodAdjustment() )
747  {
748  {
750  (aFrm.*fnRect->fnSetHeight)( nNew );
751  }
752 
753  SwTwips nReal = static_cast<SwLayoutFrame*>(this)->AdjustNeighbourhood(nDiff);
754 
755  if ( nReal != nDiff )
756  {
758  (aFrm.*fnRect->fnSetHeight)( nNew - nDiff + nReal );
759  }
760  }
761  else
762  {
763  // OD 24.10.2002 #97265# - grow/shrink not for neighbour frames
764  // NOTE: neighbour frames are cell and column frames.
765  if ( !bNeighb )
766  {
767  if ( nDiff > 0 )
768  Grow( nDiff );
769  else
770  Shrink( -nDiff );
771 
772  if ( GetUpper() && (getFrameArea().*fnRect->fnGetHeight)() != nNew )
773  {
775  }
776  }
777 
778  // Even if grow/shrink did not yet set the desired width, for
779  // example when called by ChgColumns to set the column width, we
780  // set the right width now.
782  (aFrm.*fnRect->fnSetHeight)( nNew );
783  }
784  }
785  }
786  else
787  {
789  aFrm.SSize( aNewSize );
790  }
791 
792  if ( getFrameArea().SSize() != aOldSize )
793  {
794  SwPageFrame *pPage = FindPageFrame();
795  if ( GetNext() )
796  {
797  GetNext()->InvalidatePos_();
798  GetNext()->InvalidatePage( pPage );
799  }
800  if( IsLayoutFrame() )
801  {
802  if( IsRightToLeft() )
803  InvalidatePos_();
804  if( static_cast<SwLayoutFrame*>(this)->Lower() )
805  static_cast<SwLayoutFrame*>(this)->Lower()->InvalidateSize_();
806  }
807  InvalidatePrt_();
808  InvalidateSize_();
809  InvalidatePage( pPage );
810  }
811 
812  return getFrameArea().SSize();
813 }
814 
820 void SwFrame::InsertBefore( SwLayoutFrame* pParent, SwFrame* pBehind )
821 {
822  OSL_ENSURE( pParent, "No parent for insert." );
823  OSL_ENSURE( (!pBehind || pParent == pBehind->GetUpper()),
824  "Frame tree is inconsistent." );
825 
826  mpUpper = pParent;
827  mpNext = pBehind;
828  if( pBehind )
829  { //Insert before pBehind.
830  if( nullptr != (mpPrev = pBehind->mpPrev) )
831  mpPrev->mpNext = this;
832  else
833  mpUpper->m_pLower = this;
834  pBehind->mpPrev = this;
835  }
836  else
837  { //Insert at the end, or as first node in the sub tree
838  mpPrev = mpUpper->Lower();
839  if ( mpPrev )
840  {
841  while( mpPrev->mpNext )
842  mpPrev = mpPrev->mpNext;
843  mpPrev->mpNext = this;
844  }
845  else
846  mpUpper->m_pLower = this;
847  }
848 }
849 
855 void SwFrame::InsertBehind( SwLayoutFrame *pParent, SwFrame *pBefore )
856 {
857  OSL_ENSURE( pParent, "No Parent for Insert." );
858  OSL_ENSURE( (!pBefore || pParent == pBefore->GetUpper()),
859  "Frame tree is inconsistent." );
860 
861  mpUpper = pParent;
862  mpPrev = pBefore;
863  if ( pBefore )
864  {
865  //Insert after pBefore
866  if ( nullptr != (mpNext = pBefore->mpNext) )
867  mpNext->mpPrev = this;
868  pBefore->mpNext = this;
869  }
870  else
871  {
872  //Insert at the beginning of the chain
873  mpNext = pParent->Lower();
874  if ( pParent->Lower() )
875  pParent->Lower()->mpPrev = this;
876  pParent->m_pLower = this;
877  }
878 }
879 
893 bool SwFrame::InsertGroupBefore( SwFrame* pParent, SwFrame* pBehind, SwFrame* pSct )
894 {
895  OSL_ENSURE( pParent, "No parent for insert." );
896  OSL_ENSURE( (!pBehind || ( (pBehind && (pParent == pBehind->GetUpper()))
897  || ((pParent->IsSctFrame() && pBehind->GetUpper()->IsColBodyFrame())) ) ),
898  "Frame tree inconsistent." );
899  if( pSct )
900  {
901  mpUpper = pParent->GetUpper();
902  SwFrame *pLast = this;
903  while( pLast->GetNext() )
904  {
905  pLast = pLast->GetNext();
906  pLast->mpUpper = GetUpper();
907  }
908  if( pBehind )
909  {
910  pLast->mpNext = pSct;
911  pSct->mpPrev = pLast;
912  pSct->mpNext = pParent->GetNext();
913  }
914  else
915  {
916  pLast->mpNext = pParent->GetNext();
917  if( pLast->GetNext() )
918  pLast->GetNext()->mpPrev = pLast;
919  }
920  pParent->mpNext = this;
921  mpPrev = pParent;
922  if( pSct->GetNext() )
923  pSct->GetNext()->mpPrev = pSct;
924  while( pLast->GetNext() )
925  {
926  pLast = pLast->GetNext();
927  pLast->mpUpper = GetUpper();
928  }
929  if( pBehind )
930  { // Insert before pBehind.
931  if( pBehind->GetPrev() )
932  pBehind->GetPrev()->mpNext = nullptr;
933  else
934  pBehind->GetUpper()->m_pLower = nullptr;
935  pBehind->mpPrev = nullptr;
936  SwLayoutFrame* pTmp = static_cast<SwLayoutFrame*>(pSct);
937  if( pTmp->Lower() )
938  {
939  OSL_ENSURE( pTmp->Lower()->IsColumnFrame(), "InsertGrp: Used SectionFrame" );
940  pTmp = static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(pTmp->Lower())->Lower());
941  OSL_ENSURE( pTmp, "InsertGrp: Missing ColBody" );
942  }
943  pBehind->mpUpper = pTmp;
944  pBehind->GetUpper()->m_pLower = pBehind;
945  pLast = pBehind->GetNext();
946  while ( pLast )
947  {
948  pLast->mpUpper = pBehind->GetUpper();
949  pLast = pLast->GetNext();
950  }
951  }
952  else
953  {
954  OSL_ENSURE( pSct->IsSctFrame(), "InsertGroup: For SectionFrames only" );
955  SwFrame::DestroyFrame(pSct);
956  return false;
957  }
958  }
959  else
960  {
961  mpUpper = static_cast<SwLayoutFrame*>(pParent);
962  SwFrame *pLast = this;
963  while( pLast->GetNext() )
964  {
965  pLast = pLast->GetNext();
966  pLast->mpUpper = GetUpper();
967  }
968  pLast->mpNext = pBehind;
969  if( pBehind )
970  { // Insert before pBehind.
971  if( nullptr != (mpPrev = pBehind->mpPrev) )
972  mpPrev->mpNext = this;
973  else
974  mpUpper->m_pLower = this;
975  pBehind->mpPrev = pLast;
976  }
977  else
978  {
979  //Insert at the end, or ... the first node in the subtree
980  mpPrev = mpUpper->Lower();
981  if ( mpPrev )
982  {
983  while( mpPrev->mpNext )
984  mpPrev = mpPrev->mpNext;
985  mpPrev->mpNext = this;
986  }
987  else
988  mpUpper->m_pLower = this;
989  }
990  }
991  return true;
992 }
993 
995 {
996  OSL_ENSURE( mpUpper, "Remove without upper?" );
997 
998  if (mpPrev)
999  // one out of the middle is removed
1000  mpPrev->mpNext = mpNext;
1001  else if (mpUpper)
1002  { // the first in a list is removed //TODO
1003  OSL_ENSURE( mpUpper->m_pLower == this, "Layout is inconsistent." );
1004  mpUpper->m_pLower = mpNext;
1005  }
1006  if( mpNext )
1007  mpNext->mpPrev = mpPrev;
1008 
1009  // Remove link
1010  mpNext = mpPrev = nullptr;
1011  mpUpper = nullptr;
1012 }
1013 
1014 void SwContentFrame::Paste( SwFrame* pParent, SwFrame* pSibling)
1015 {
1016  OSL_ENSURE( pParent, "No parent for pasting." );
1017  OSL_ENSURE( pParent->IsLayoutFrame(), "Parent is ContentFrame." );
1018  OSL_ENSURE( pParent != this, "I'm the parent." );
1019  OSL_ENSURE( pSibling != this, "I'm my own neighbour." );
1020  OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
1021  "I'm still registered somewhere" );
1022  OSL_ENSURE( !pSibling || pSibling->IsFlowFrame(),
1023  "<SwContentFrame::Paste(..)> - sibling not of expected type." );
1024 
1025  //Insert in the tree.
1026  InsertBefore( static_cast<SwLayoutFrame*>(pParent), pSibling );
1027 
1028  SwPageFrame *pPage = FindPageFrame();
1029  InvalidateAll_();
1030  InvalidatePage( pPage );
1031 
1032  if( pPage )
1033  {
1034  pPage->InvalidateSpelling();
1035  pPage->InvalidateSmartTags();
1036  pPage->InvalidateAutoCompleteWords();
1037  pPage->InvalidateWordCount();
1038  }
1039 
1040  if ( GetNext() )
1041  {
1042  SwFrame* pNxt = GetNext();
1043  pNxt->InvalidatePrt_();
1044  pNxt->InvalidatePos_();
1045  pNxt->InvalidatePage( pPage );
1046  if( pNxt->IsSctFrame() )
1047  pNxt = static_cast<SwSectionFrame*>(pNxt)->ContainsContent();
1048  if( pNxt && pNxt->IsTextFrame() && pNxt->IsInFootnote() )
1049  pNxt->Prepare( PREP_FTN, nullptr, false );
1050  }
1051 
1052  if ( getFrameArea().Height() )
1053  pParent->Grow( getFrameArea().Height() );
1054 
1055  if ( getFrameArea().Width() != pParent->getFramePrintArea().Width() )
1057 
1058  if ( GetPrev() )
1059  {
1060  if ( IsFollow() )
1061  //I'm a direct follower of my master now
1062  static_cast<SwContentFrame*>(GetPrev())->Prepare( PREP_FOLLOW_FOLLOWS );
1063  else
1064  {
1065  if ( GetPrev()->getFrameArea().Height() !=
1067  {
1068  // Take the border into account?
1069  GetPrev()->InvalidatePrt_();
1070  }
1071  // OD 18.02.2003 #104989# - force complete paint of previous frame,
1072  // if frame is inserted at the end of a section frame, in order to
1073  // get subsidiary lines repainted for the section.
1074  if ( pParent->IsSctFrame() && !GetNext() )
1075  {
1076  // force complete paint of previous frame, if new inserted frame
1077  // in the section is the last one.
1079  }
1080  GetPrev()->InvalidatePage( pPage );
1081  }
1082  }
1083  if ( IsInFootnote() )
1084  {
1085  SwFrame* pFrame = GetIndPrev();
1086  if( pFrame && pFrame->IsSctFrame() )
1087  pFrame = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
1088  if( pFrame )
1089  pFrame->Prepare( PREP_QUOVADIS, nullptr, false );
1090  if( !GetNext() )
1091  {
1092  pFrame = FindFootnoteFrame()->GetNext();
1093  if( pFrame && nullptr != (pFrame=static_cast<SwLayoutFrame*>(pFrame)->ContainsAny()) )
1094  pFrame->InvalidatePrt_();
1095  }
1096  }
1097 
1099  SwFrame *pNxt = FindNextCnt();
1100  if ( pNxt )
1101  {
1102  while ( pNxt && pNxt->IsInTab() )
1103  {
1104  if( nullptr != (pNxt = pNxt->FindTabFrame()) )
1105  pNxt = pNxt->FindNextCnt();
1106  }
1107  if ( pNxt )
1108  {
1109  pNxt->InvalidateLineNum_();
1110  if ( pNxt != GetNext() )
1111  pNxt->InvalidatePage();
1112  }
1113  }
1114 }
1115 
1117 {
1118  OSL_ENSURE( GetUpper(), "Cut without Upper()." );
1119 
1120  SwPageFrame *pPage = FindPageFrame();
1121  InvalidatePage( pPage );
1122  SwFrame *pFrame = GetIndPrev();
1123  if( pFrame )
1124  {
1125  if( pFrame->IsSctFrame() )
1126  pFrame = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
1127  if ( pFrame && pFrame->IsContentFrame() )
1128  {
1129  pFrame->InvalidatePrt_();
1130  if( IsInFootnote() )
1131  pFrame->Prepare( PREP_QUOVADIS, nullptr, false );
1132  }
1133  // #i26250# - invalidate printing area of previous
1134  // table frame.
1135  else if ( pFrame && pFrame->IsTabFrame() )
1136  {
1137  pFrame->InvalidatePrt();
1138  }
1139  }
1140 
1141  SwFrame *pNxt = FindNextCnt();
1142  if ( pNxt )
1143  {
1144  while ( pNxt && pNxt->IsInTab() )
1145  {
1146  if( nullptr != (pNxt = pNxt->FindTabFrame()) )
1147  pNxt = pNxt->FindNextCnt();
1148  }
1149  if ( pNxt )
1150  {
1151  pNxt->InvalidateLineNum_();
1152  if ( pNxt != GetNext() )
1153  pNxt->InvalidatePage();
1154  }
1155  }
1156 
1157  if( nullptr != (pFrame = GetIndNext()) )
1158  {
1159  // The old follow may have calculated a gap to the predecessor which
1160  // now becomes obsolete or different as it becomes the first one itself
1161  pFrame->InvalidatePrt_();
1162  pFrame->InvalidatePos_();
1163  pFrame->InvalidatePage( pPage );
1164  if( pFrame->IsSctFrame() )
1165  {
1166  pFrame = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
1167  if( pFrame )
1168  {
1169  pFrame->InvalidatePrt_();
1170  pFrame->InvalidatePos_();
1171  pFrame->InvalidatePage( pPage );
1172  }
1173  }
1174  if( pFrame && IsInFootnote() )
1175  pFrame->Prepare( PREP_ERGOSUM, nullptr, false );
1176  if( IsInSct() && !GetPrev() )
1177  {
1178  SwSectionFrame* pSct = FindSctFrame();
1179  if( !pSct->IsFollow() )
1180  {
1181  pSct->InvalidatePrt_();
1182  pSct->InvalidatePage( pPage );
1183  }
1184  }
1185  }
1186  else
1187  {
1189  //Someone needs to do the retouching: predecessor or upper
1190  if ( nullptr != (pFrame = GetPrev()) )
1191  { pFrame->SetRetouche();
1192  pFrame->Prepare( PREP_WIDOWS_ORPHANS );
1193  pFrame->InvalidatePos_();
1194  pFrame->InvalidatePage( pPage );
1195  }
1196  // If I'm (was) the only ContentFrame in my upper, it has to do the
1197  // retouching. Also, perhaps a page became empty.
1198  else
1199  { SwRootFrame *pRoot = getRootFrame();
1200  if ( pRoot )
1201  {
1202  pRoot->SetSuperfluous();
1204  GetUpper()->InvalidatePage( pPage );
1205  }
1206  if( IsInSct() )
1207  {
1208  SwSectionFrame* pSct = FindSctFrame();
1209  if( !pSct->IsFollow() )
1210  {
1211  pSct->InvalidatePrt_();
1212  pSct->InvalidatePage( pPage );
1213  }
1214  }
1215  // #i52253# The master table should take care
1216  // of removing the follow flow line.
1217  if ( IsInTab() )
1218  {
1219  SwTabFrame* pThisTab = FindTabFrame();
1220  SwTabFrame* pMasterTab = pThisTab && pThisTab->IsFollow() ? pThisTab->FindMaster() : nullptr;
1221  if ( pMasterTab )
1222  {
1223  pMasterTab->InvalidatePos_();
1224  pMasterTab->SetRemoveFollowFlowLinePending( true );
1225  }
1226  }
1227  }
1228  }
1229  //Remove first, then shrink the upper.
1230  SwLayoutFrame *pUp = GetUpper();
1231  RemoveFromLayout();
1232  if ( pUp )
1233  {
1234  SwSectionFrame *pSct = nullptr;
1235  if ( !pUp->Lower() &&
1236  ( ( pUp->IsFootnoteFrame() && !pUp->IsColLocked() ) ||
1237  ( pUp->IsInSct() &&
1238  // #i29438#
1239  // We have to consider the case that the section may be "empty"
1240  // except from a temporary empty table frame.
1241  // This can happen due to the new cell split feature.
1242  !pUp->IsCellFrame() &&
1243  // #126020# - adjust check for empty section
1244  // #130797# - correct fix #126020#
1245  !(pSct = pUp->FindSctFrame())->ContainsContent() &&
1246  !pSct->ContainsAny( true ) ) ) )
1247  {
1248  if ( pUp->GetUpper() )
1249  {
1250 
1251  // prevent delete of <ColLocked> footnote frame
1252  if ( pUp->IsFootnoteFrame() && !pUp->IsColLocked())
1253  {
1254  if( pUp->GetNext() && !pUp->GetPrev() )
1255  {
1256  SwFrame* pTmp = static_cast<SwLayoutFrame*>(pUp->GetNext())->ContainsAny();
1257  if( pTmp )
1258  pTmp->InvalidatePrt_();
1259  }
1260  if (!pUp->IsDeleteForbidden())
1261  {
1262  pUp->Cut();
1263  SwFrame::DestroyFrame(pUp);
1264  }
1265  }
1266  else
1267  {
1268 
1269  if ( pSct->IsColLocked() || !pSct->IsInFootnote() ||
1270  ( pUp->IsFootnoteFrame() && pUp->IsColLocked() ) )
1271  {
1272  pSct->DelEmpty( false );
1273  // If a locked section may not be deleted then at least
1274  // its size became invalid after removing its last
1275  // content.
1276  pSct->InvalidateSize_();
1277  }
1278  else
1279  {
1280  pSct->DelEmpty( true );
1281  SwFrame::DestroyFrame(pSct);
1282  }
1283  }
1284  }
1285  }
1286  else
1287  {
1288  SwRectFnSet aRectFnSet(this);
1289  long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
1290  if( nFrameHeight )
1291  pUp->Shrink( nFrameHeight );
1292  }
1293  }
1294 }
1295 
1296 void SwLayoutFrame::Paste( SwFrame* pParent, SwFrame* pSibling)
1297 {
1298  OSL_ENSURE( pParent, "No parent for pasting." );
1299  OSL_ENSURE( pParent->IsLayoutFrame(), "Parent is ContentFrame." );
1300  OSL_ENSURE( pParent != this, "I'm the parent oneself." );
1301  OSL_ENSURE( pSibling != this, "I'm my own neighbour." );
1302  OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
1303  "I'm still registered somewhere." );
1304 
1305  //Insert in the tree.
1306  InsertBefore( static_cast<SwLayoutFrame*>(pParent), pSibling );
1307 
1308  // OD 24.10.2002 #103517# - correct setting of variable <fnRect>
1309  // <fnRect> is used for the following:
1310  // (1) To invalidate the frame's size, if its size, which has to be the
1311  // same as its upper/parent, differs from its upper's/parent's.
1312  // (2) To adjust/grow the frame's upper/parent, if it has a dimension in its
1313  // size, which is not determined by its upper/parent.
1314  // Which size is which depends on the frame type and the layout direction
1315  // (vertical or horizontal).
1316  // There are the following cases:
1317  // (A) Header and footer frames both in vertical and in horizontal layout
1318  // have to size the width to the upper/parent. A dimension in the height
1319  // has to cause a adjustment/grow of the upper/parent.
1320  // --> <fnRect> = fnRectHori
1321  // (B) Cell and column frames in vertical layout, the width has to be the
1322  // same as upper/parent and a dimension in height causes adjustment/grow
1323  // of the upper/parent.
1324  // --> <fnRect> = fnRectHori
1325  // in horizontal layout the other way around
1326  // --> <fnRect> = fnRectVert
1327  // (C) Other frames in vertical layout, the height has to be the
1328  // same as upper/parent and a dimension in width causes adjustment/grow
1329  // of the upper/parent.
1330  // --> <fnRect> = fnRectVert
1331  // in horizontal layout the other way around
1332  // --> <fnRect> = fnRectHori
1333  //SwRectFn fnRect = IsVertical() ? fnRectHori : fnRectVert;
1334  SwRectFn fnRect;
1335  if ( IsHeaderFrame() || IsFooterFrame() )
1336  fnRect = fnRectHori;
1337  else if ( IsCellFrame() || IsColumnFrame() )
1339  else
1341 
1342  if( (getFrameArea().*fnRect->fnGetWidth)() != (pParent->getFramePrintArea().*fnRect->fnGetWidth)())
1343  InvalidateSize_();
1344  InvalidatePos_();
1345  const SwPageFrame *pPage = FindPageFrame();
1346  InvalidatePage( pPage );
1347  if( !IsColumnFrame() )
1348  {
1349  SwFrame *pFrame = GetIndNext();
1350  if( nullptr != pFrame )
1351  {
1352  pFrame->InvalidatePos_();
1353  if( IsInFootnote() )
1354  {
1355  if( pFrame->IsSctFrame() )
1356  pFrame = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
1357  if( pFrame )
1358  pFrame->Prepare( PREP_ERGOSUM, nullptr, false );
1359  }
1360  }
1361  if ( IsInFootnote() && nullptr != ( pFrame = GetIndPrev() ) )
1362  {
1363  if( pFrame->IsSctFrame() )
1364  pFrame = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
1365  if( pFrame )
1366  pFrame->Prepare( PREP_QUOVADIS, nullptr, false );
1367  }
1368  }
1369 
1370  if( (getFrameArea().*fnRect->fnGetHeight)() )
1371  {
1372  // AdjustNeighbourhood is now also called in columns which are not
1373  // placed inside a frame
1375  static_cast<SwFootnoteBossFrame*>(GetUpper())->NeighbourhoodAdjustment()
1377  SwTwips nGrow = (getFrameArea().*fnRect->fnGetHeight)();
1378  if( SwNeighbourAdjust::OnlyAdjust == nAdjust )
1379  AdjustNeighbourhood( nGrow );
1380  else
1381  {
1382  SwTwips nReal = 0;
1383  if( SwNeighbourAdjust::AdjustGrow == nAdjust )
1384  nReal = AdjustNeighbourhood( nGrow );
1385  if( nReal < nGrow )
1386  nReal += pParent->Grow( nGrow - nReal );
1387  if( SwNeighbourAdjust::GrowAdjust == nAdjust && nReal < nGrow )
1388  AdjustNeighbourhood( nGrow - nReal );
1389  }
1390  }
1391 }
1392 
1394 {
1395  if ( GetNext() )
1396  GetNext()->InvalidatePos_();
1397 
1398  SwRectFnSet aRectFnSet(this);
1399  SwTwips nShrink = aRectFnSet.GetHeight(getFrameArea());
1400 
1401  // Remove first, then shrink upper.
1402  SwLayoutFrame *pUp = GetUpper();
1403 
1404  // AdjustNeighbourhood is now also called in columns which are not
1405  // placed inside a frame.
1406 
1407  // Remove must not be called before an AdjustNeighbourhood, but it has to
1408  // be called before the upper-shrink-call, if the upper-shrink takes care
1409  // of its content.
1410  if ( pUp && nShrink )
1411  {
1412  if( pUp->IsFootnoteBossFrame() )
1413  {
1414  SwNeighbourAdjust nAdjust= static_cast<SwFootnoteBossFrame*>(pUp)->NeighbourhoodAdjustment();
1415  if( SwNeighbourAdjust::OnlyAdjust == nAdjust )
1416  AdjustNeighbourhood( -nShrink );
1417  else
1418  {
1419  SwTwips nReal = 0;
1420  if( SwNeighbourAdjust::AdjustGrow == nAdjust )
1421  nReal = -AdjustNeighbourhood( -nShrink );
1422  if( nReal < nShrink )
1423  {
1424  const SwTwips nOldHeight = aRectFnSet.GetHeight(getFrameArea());
1425 
1426  // seems as if this needs to be forwarded to the SwFrame already here,
1427  // changing to zero seems temporary anyways
1428  {
1430  aRectFnSet.SetHeight( aFrm, 0 );
1431  }
1432 
1433  nReal += pUp->Shrink( nShrink - nReal );
1434 
1435  {
1437  aRectFnSet.SetHeight( aFrm, nOldHeight );
1438  }
1439  }
1440 
1441  if( SwNeighbourAdjust::GrowAdjust == nAdjust && nReal < nShrink )
1442  AdjustNeighbourhood( nReal - nShrink );
1443  }
1444  RemoveFromLayout();
1445  }
1446  else
1447  {
1448  RemoveFromLayout();
1449  pUp->Shrink( nShrink );
1450  }
1451  }
1452  else
1453  RemoveFromLayout();
1454 
1455  if( pUp && !pUp->Lower() )
1456  {
1457  pUp->SetCompletePaint();
1458  pUp->InvalidatePage();
1459  }
1460 }
1461 
1462 SwTwips SwFrame::Grow( SwTwips nDist, bool bTst, bool bInfo )
1463 {
1464  OSL_ENSURE( nDist >= 0, "Negative growth?" );
1465 
1466  PROTOCOL_ENTER( this, bTst ? PROT::GrowTest : PROT::Grow, DbgAction::NONE, &nDist )
1467 
1468  if ( nDist )
1469  {
1470  SwRectFnSet aRectFnSet(this);
1471 
1472  SwTwips nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
1473  if( nPrtHeight > 0 && nDist > (LONG_MAX - nPrtHeight) )
1474  nDist = LONG_MAX - nPrtHeight;
1475 
1476  if ( IsFlyFrame() )
1477  return static_cast<SwFlyFrame*>(this)->Grow_( nDist, bTst );
1478  else if( IsSctFrame() )
1479  return static_cast<SwSectionFrame*>(this)->Grow_( nDist, bTst );
1480  else
1481  {
1482  const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this);
1483  if ( pThisCell )
1484  {
1485  const SwTabFrame* pTab = FindTabFrame();
1486 
1487  // NEW TABLES
1488  if ( pTab->IsVertical() != IsVertical() ||
1489  pThisCell->GetLayoutRowSpan() < 1 )
1490  return 0;
1491  }
1492 
1493  const SwTwips nReal = GrowFrame( nDist, bTst, bInfo );
1494  if( !bTst )
1495  {
1496  nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
1497 
1499  aRectFnSet.SetHeight( aPrt, nPrtHeight + ( IsContentFrame() ? nDist : nReal ) );
1500  }
1501  return nReal;
1502  }
1503  }
1504  return 0;
1505 }
1506 
1507 SwTwips SwFrame::Shrink( SwTwips nDist, bool bTst, bool bInfo )
1508 {
1509  OSL_ENSURE( nDist >= 0, "Negative reduction?" );
1510 
1511  PROTOCOL_ENTER( this, bTst ? PROT::ShrinkTest : PROT::Shrink, DbgAction::NONE, &nDist )
1512 
1513  if ( nDist )
1514  {
1515  if ( IsFlyFrame() )
1516  return static_cast<SwFlyFrame*>(this)->Shrink_( nDist, bTst );
1517  else if( IsSctFrame() )
1518  return static_cast<SwSectionFrame*>(this)->Shrink_( nDist, bTst );
1519  else
1520  {
1521  const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this);
1522  if ( pThisCell )
1523  {
1524  const SwTabFrame* pTab = FindTabFrame();
1525 
1526  // NEW TABLES
1527  if ( (pTab && pTab->IsVertical() != IsVertical()) ||
1528  pThisCell->GetLayoutRowSpan() < 1 )
1529  return 0;
1530  }
1531 
1532  SwRectFnSet aRectFnSet(this);
1533  SwTwips nReal = aRectFnSet.GetHeight(getFrameArea());
1534  ShrinkFrame( nDist, bTst, bInfo );
1535  nReal -= aRectFnSet.GetHeight(getFrameArea());
1536  if( !bTst )
1537  {
1538  const SwTwips nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
1540  aRectFnSet.SetHeight( aPrt, nPrtHeight - ( IsContentFrame() ? nDist : nReal ) );
1541  }
1542  return nReal;
1543  }
1544  }
1545  return 0;
1546 }
1547 
1569 {
1570  PROTOCOL_ENTER( this, PROT::AdjustN, DbgAction::NONE, &nDiff );
1571 
1572  if ( !nDiff || !GetUpper()->IsFootnoteBossFrame() ) // only inside pages/columns
1573  return 0;
1574 
1575  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
1576  const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
1577 
1578  //The (Page-)Body only changes in BrowseMode, but only if it does not
1579  //contain columns.
1580  if ( IsPageBodyFrame() && (!bBrowse ||
1581  (static_cast<SwLayoutFrame*>(this)->Lower() &&
1582  static_cast<SwLayoutFrame*>(this)->Lower()->IsColumnFrame())) )
1583  return 0;
1584 
1585  //In BrowseView mode the PageFrame can handle some of the requests.
1586  long nBrowseAdd = 0;
1587  if ( bBrowse && GetUpper()->IsPageFrame() ) // only (Page-)BodyFrames
1588  {
1589  SwViewShell *pViewShell = getRootFrame()->GetCurrShell();
1590  SwLayoutFrame *pUp = GetUpper();
1591  long nChg;
1592  const long nUpPrtBottom = pUp->getFrameArea().Height() -
1593  pUp->getFramePrintArea().Height() - pUp->getFramePrintArea().Top();
1594  SwRect aInva( pUp->getFrameArea() );
1595  if ( pViewShell )
1596  {
1597  aInva.Pos().setX( pViewShell->VisArea().Left() );
1598  aInva.Width( pViewShell->VisArea().Width() );
1599  }
1600  if ( nDiff > 0 )
1601  {
1602  nChg = BROWSE_HEIGHT - pUp->getFrameArea().Height();
1603  nChg = std::min( nDiff, nChg );
1604 
1605  if ( !IsBodyFrame() )
1606  {
1607  SetCompletePaint();
1608  if ( !pViewShell || pViewShell->VisArea().Height() >= pUp->getFrameArea().Height() )
1609  {
1610  //First minimize Body, it will grow again later.
1611  SwFrame *pBody = static_cast<SwFootnoteBossFrame*>(pUp)->FindBodyCont();
1612  const long nTmp = nChg - pBody->getFramePrintArea().Height();
1613  if ( !bTst )
1614  {
1615  {
1617  aFrm.Height(std::max( 0L, aFrm.Height() - nChg ));
1618  }
1619 
1620  pBody->InvalidatePrt_();
1621  pBody->InvalidateSize_();
1622  if ( pBody->GetNext() )
1623  pBody->GetNext()->InvalidatePos_();
1624  if ( !IsHeaderFrame() )
1625  pBody->SetCompletePaint();
1626  }
1627  nChg = nTmp <= 0 ? 0 : nTmp;
1628  }
1629  }
1630 
1631  const long nTmp = nUpPrtBottom + 20;
1632  aInva.Top( aInva.Bottom() - nTmp );
1633  aInva.Height( nChg + nTmp );
1634  }
1635  else
1636  {
1637  //The page can shrink to 0. The first page keeps the same size like
1638  //VisArea.
1639  nChg = nDiff;
1640  long nInvaAdd = 0;
1641  if ( pViewShell && !pUp->GetPrev() &&
1642  pUp->getFrameArea().Height() + nDiff < pViewShell->VisArea().Height() )
1643  {
1644  // This means that we have to invalidate adequately.
1645  nChg = pViewShell->VisArea().Height() - pUp->getFrameArea().Height();
1646  nInvaAdd = -(nDiff - nChg);
1647  }
1648 
1649  //Invalidate including bottom border.
1650  long nBorder = nUpPrtBottom + 20;
1651  nBorder -= nChg;
1652  aInva.Top( aInva.Bottom() - (nBorder+nInvaAdd) );
1653  if ( !IsBodyFrame() )
1654  {
1655  SetCompletePaint();
1656  if ( !IsHeaderFrame() )
1657  static_cast<SwFootnoteBossFrame*>(pUp)->FindBodyCont()->SetCompletePaint();
1658  }
1659  //Invalidate the page because of the frames. Thereby the page becomes
1660  //the right size again if a frame didn't fit. This only works
1661  //randomly for paragraph bound frames otherwise (NotifyFlys).
1662  pUp->InvalidateSize();
1663  }
1664  if ( !bTst )
1665  {
1666  //Independent from nChg
1667  if ( pViewShell && aInva.HasArea() && pUp->GetUpper() )
1668  pViewShell->InvalidateWindows( aInva );
1669  }
1670  if ( !bTst && nChg )
1671  {
1672  {
1674  aFrm.SSize().AdjustHeight(nChg );
1675  }
1676 
1677  {
1679  aPrt.SSize().AdjustHeight(nChg );
1680  }
1681 
1682  if ( pViewShell )
1683  pViewShell->Imp()->SetFirstVisPageInvalid();
1684 
1685  if ( GetNext() )
1686  GetNext()->InvalidatePos_();
1687 
1688  //Trigger a repaint if necessary.
1689  std::shared_ptr<SvxBrushItem> aBack(pUp->GetFormat()->makeBackgroundBrushItem());
1690  const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : GPOS_NONE;
1691  if ( ePos != GPOS_NONE && ePos != GPOS_TILED )
1692  pViewShell->InvalidateWindows( pUp->getFrameArea() );
1693 
1694  if ( pUp->GetUpper() )
1695  {
1696  if ( pUp->GetNext() )
1697  pUp->GetNext()->InvalidatePos();
1698 
1699  //Sad but true: during notify on ViewImp a Calc on the page and
1700  //its Lower may be called. The values should not be changed
1701  //because the caller takes care of the adjustment of Frame and
1702  //Prt.
1703  const long nOldFrameHeight = getFrameArea().Height();
1704  const long nOldPrtHeight = getFramePrintArea().Height();
1705  const bool bOldComplete = IsCompletePaint();
1706 
1707  if ( IsBodyFrame() )
1708  {
1710  aPrt.SSize().setHeight( nOldFrameHeight );
1711  }
1712 
1713  if ( pUp->GetUpper() )
1714  {
1715  static_cast<SwRootFrame*>(pUp->GetUpper())->CheckViewLayout( nullptr, nullptr );
1716  }
1717 
1719  aFrm.SSize().setHeight( nOldFrameHeight );
1720 
1722  aPrt.SSize().setHeight( nOldPrtHeight );
1723 
1724  mbCompletePaint = bOldComplete;
1725  }
1726  if ( !IsBodyFrame() )
1727  pUp->InvalidateSize_();
1728  InvalidatePage( static_cast<SwPageFrame*>(pUp) );
1729  }
1730  nDiff -= nChg;
1731  if ( !nDiff )
1732  return nChg;
1733  else
1734  nBrowseAdd = nChg;
1735  }
1736 
1737  const SwFootnoteBossFrame *pBoss = static_cast<SwFootnoteBossFrame*>(GetUpper());
1738 
1739  SwTwips nReal = 0,
1740  nAdd = 0;
1741  SwFrame *pFrame = nullptr;
1742  SwRectFnSet aRectFnSet(this);
1743 
1744  if( IsBodyFrame() )
1745  {
1746  if( IsInSct() )
1747  {
1748  SwSectionFrame *pSect = FindSctFrame();
1749  if( nDiff > 0 && pSect->IsEndnAtEnd() && GetNext() &&
1751  {
1752  SwFootnoteContFrame* pCont = static_cast<SwFootnoteContFrame*>(GetNext());
1753  SwTwips nMinH = 0;
1754  SwFootnoteFrame* pFootnote = static_cast<SwFootnoteFrame*>(pCont->Lower());
1755  bool bFootnote = false;
1756  while( pFootnote )
1757  {
1758  if( !pFootnote->GetAttr()->GetFootnote().IsEndNote() )
1759  {
1760  nMinH += aRectFnSet.GetHeight(pFootnote->getFrameArea());
1761  bFootnote = true;
1762  }
1763  pFootnote = static_cast<SwFootnoteFrame*>(pFootnote->GetNext());
1764  }
1765  if( bFootnote )
1766  nMinH += aRectFnSet.GetTop(pCont->getFramePrintArea());
1767  nReal = aRectFnSet.GetHeight(pCont->getFrameArea()) - nMinH;
1768  if( nReal > nDiff )
1769  nReal = nDiff;
1770  if( nReal > 0 )
1771  pFrame = GetNext();
1772  else
1773  nReal = 0;
1774  }
1775  if( !bTst && !pSect->IsColLocked() )
1776  pSect->InvalidateSize();
1777  }
1778  if( !pFrame )
1779  return nBrowseAdd;
1780  }
1781  else
1782  {
1783  const bool bFootnotePage = pBoss->IsPageFrame() && static_cast<const SwPageFrame*>(pBoss)->IsFootnotePage();
1784  if ( bFootnotePage && !IsFootnoteContFrame() )
1785  pFrame = const_cast<SwFrame*>(static_cast<SwFrame const *>(pBoss->FindFootnoteCont()));
1786  if ( !pFrame )
1787  pFrame = const_cast<SwFrame*>(static_cast<SwFrame const *>(pBoss->FindBodyCont()));
1788 
1789  if ( !pFrame )
1790  return 0;
1791 
1792  //If not one is found, everything else is solved.
1793  nReal = aRectFnSet.GetHeight(pFrame->getFrameArea());
1794  if( nReal > nDiff )
1795  nReal = nDiff;
1796  if( !bFootnotePage )
1797  {
1798  //Respect the minimal boundary!
1799  if( nReal )
1800  {
1801  const SwTwips nMax = pBoss->GetVarSpace();
1802  if ( nReal > nMax )
1803  nReal = nMax;
1804  }
1805  if( !IsFootnoteContFrame() && nDiff > nReal &&
1806  pFrame->GetNext() && pFrame->GetNext()->IsFootnoteContFrame()
1807  && ( pFrame->GetNext()->IsVertical() == IsVertical() )
1808  )
1809  {
1810  //If the Body doesn't return enough, we look for a footnote, if
1811  //there is one, we steal there accordingly.
1812  const SwTwips nAddMax = aRectFnSet.GetHeight(pFrame->GetNext()->getFrameArea());
1813  nAdd = nDiff - nReal;
1814  if ( nAdd > nAddMax )
1815  nAdd = nAddMax;
1816  if ( !bTst )
1817  {
1818  {
1820  aRectFnSet.SetHeight(aFrm, nAddMax-nAdd);
1821 
1822  if( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
1823  {
1824  aFrm.Pos().AdjustX(nAdd );
1825  }
1826  }
1827 
1828  pFrame->GetNext()->InvalidatePrt();
1829 
1830  if ( pFrame->GetNext()->GetNext() )
1831  {
1832  pFrame->GetNext()->GetNext()->InvalidatePos_();
1833  }
1834  }
1835  }
1836  }
1837  }
1838 
1839  if ( !bTst && nReal )
1840  {
1841  SwTwips nTmp = aRectFnSet.GetHeight(pFrame->getFrameArea());
1842 
1843  {
1845  aRectFnSet.SetHeight( aFrm, nTmp - nReal );
1846 
1847  if( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
1848  {
1849  aFrm.Pos().AdjustX(nReal );
1850  }
1851  }
1852 
1853  pFrame->InvalidatePrt();
1854 
1855  if ( pFrame->GetNext() )
1856  pFrame->GetNext()->InvalidatePos_();
1857 
1858  if( nReal < 0 && pFrame->IsInSct() )
1859  {
1860  SwLayoutFrame* pUp = pFrame->GetUpper();
1861  if( pUp && nullptr != ( pUp = pUp->GetUpper() ) && pUp->IsSctFrame() &&
1862  !pUp->IsColLocked() )
1863  pUp->InvalidateSize();
1864  }
1865  if( ( IsHeaderFrame() || IsFooterFrame() ) && pBoss->GetDrawObjs() )
1866  {
1867  const SwSortedObjs &rObjs = *pBoss->GetDrawObjs();
1868  OSL_ENSURE( pBoss->IsPageFrame(), "Header/Footer out of page?" );
1869  for (SwAnchoredObject* pAnchoredObj : rObjs)
1870  {
1871  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
1872  {
1873  SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
1874  OSL_ENSURE( !pFly->IsFlyInContentFrame(), "FlyInCnt at Page?" );
1875  const SwFormatVertOrient &rVert =
1876  pFly->GetFormat()->GetVertOrient();
1877  // When do we have to invalidate?
1878  // If a frame is aligned on a PageTextArea and the header
1879  // changes a TOP, MIDDLE or NONE aligned frame needs to
1880  // recalculate it's position; if the footer changes a BOTTOM
1881  // or MIDDLE aligned frame needs to recalculate it's
1882  // position.
1883  if( ( rVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ||
1884  rVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA ) &&
1885  ((IsHeaderFrame() && rVert.GetVertOrient()!=text::VertOrientation::BOTTOM) ||
1886  (IsFooterFrame() && rVert.GetVertOrient()!=text::VertOrientation::NONE &&
1887  rVert.GetVertOrient() != text::VertOrientation::TOP)) )
1888  {
1889  pFly->InvalidatePos_();
1890  pFly->Invalidate_();
1891  }
1892  }
1893  }
1894  }
1895  }
1896  return (nBrowseAdd + nReal + nAdd);
1897 }
1898 
1901 {
1902  // default behaviour is to perform no additional action
1903 }
1904 
1907 {
1908  // default behaviour is to allow invalidation
1909  return true;
1910 }
1911 
1913 {
1915  {
1916  setFrameAreaSizeValid(false);
1917 
1918  if ( IsFlyFrame() )
1919  static_cast<SwFlyFrame*>(this)->Invalidate_();
1920  else
1921  InvalidatePage();
1922 
1923  // OD 2004-05-19 #i28701#
1925  }
1926 }
1927 
1929 {
1931  {
1932  setFramePrintAreaValid(false);
1933 
1934  if ( IsFlyFrame() )
1935  static_cast<SwFlyFrame*>(this)->Invalidate_();
1936  else
1937  InvalidatePage();
1938 
1939  // OD 2004-05-19 #i28701#
1941  }
1942 }
1943 
1945 {
1947  {
1949 
1950  if ( IsFlyFrame() )
1951  {
1952  static_cast<SwFlyFrame*>(this)->Invalidate_();
1953  }
1954  else
1955  {
1956  InvalidatePage();
1957  }
1958 
1959  // OD 2004-05-19 #i28701#
1961  }
1962 }
1963 
1965 {
1967  {
1968  mbValidLineNum = false;
1969  OSL_ENSURE( IsTextFrame(), "line numbers are implemented for text only" );
1970  InvalidatePage();
1971 
1972  // OD 2004-05-19 #i28701#
1974  }
1975 }
1976 
1978 {
1979  const SwFormatFrameSize &rFormatSize = GetAttrSet()->GetFrameSize();
1980  if ( ATT_VAR_SIZE == rFormatSize.GetHeightSizeType() ||
1981  ATT_MIN_SIZE == rFormatSize.GetHeightSizeType())
1982  {
1983  mbFixSize = false;
1985  {
1986  SwFrame *pFrame = static_cast<SwLayoutFrame*>(this)->Lower();
1987  while ( pFrame )
1988  { pFrame->InvalidateSize_();
1989  pFrame->InvalidatePrt_();
1990  pFrame = pFrame->GetNext();
1991  }
1992  SwContentFrame *pCnt = static_cast<SwLayoutFrame*>(this)->ContainsContent();
1993  // #i36991# - be save.
1994  // E.g., a row can contain *no* content.
1995  if ( pCnt )
1996  {
1997  pCnt->InvalidatePage();
1998  do
1999  {
2000  pCnt->Prepare( PREP_ADJUST_FRM );
2001  pCnt->InvalidateSize_();
2002  pCnt = pCnt->GetNextContentFrame();
2003  } while ( static_cast<SwLayoutFrame*>(this)->IsAnLower( pCnt ) );
2004  }
2005  }
2006  }
2007  else if ( rFormatSize.GetHeightSizeType() == ATT_FIX_SIZE )
2008  {
2009  if( IsVertical() )
2010  ChgSize( Size( rFormatSize.GetWidth(), getFrameArea().Height()));
2011  else
2012  ChgSize( Size( getFrameArea().Width(), rFormatSize.GetHeight()));
2013  }
2014 }
2015 
2016 void SwFrame::ValidateThisAndAllLowers( const sal_uInt16 nStage )
2017 {
2018  // Stage 0: Only validate frames. Do not process any objects.
2019  // Stage 1: Only validate fly frames and all of their contents.
2020  // Stage 2: Validate all.
2021 
2022  const bool bOnlyObject = 1 == nStage;
2023  const bool bIncludeObjects = 1 <= nStage;
2024 
2025  if ( !bOnlyObject || dynamic_cast< const SwFlyFrame *>( this ) != nullptr )
2026  {
2027  setFrameAreaSizeValid(true);
2028  setFramePrintAreaValid(true);
2030  }
2031 
2032  if ( bIncludeObjects )
2033  {
2034  const SwSortedObjs* pObjs = GetDrawObjs();
2035  if ( pObjs )
2036  {
2037  const size_t nCnt = pObjs->size();
2038  for ( size_t i = 0; i < nCnt; ++i )
2039  {
2040  SwAnchoredObject* pAnchObj = (*pObjs)[i];
2041  if ( dynamic_cast< const SwFlyFrame *>( pAnchObj ) != nullptr )
2042  static_cast<SwFlyFrame*>(pAnchObj)->ValidateThisAndAllLowers( 2 );
2043  else if ( dynamic_cast< const SwAnchoredDrawObject *>( pAnchObj ) != nullptr )
2044  static_cast<SwAnchoredDrawObject*>(pAnchObj)->ValidateThis();
2045  }
2046  }
2047  }
2048 
2049  if ( IsLayoutFrame() )
2050  {
2051  SwFrame* pLower = static_cast<SwLayoutFrame*>(this)->Lower();
2052  while ( pLower )
2053  {
2054  pLower->ValidateThisAndAllLowers( nStage );
2055  pLower = pLower->GetNext();
2056  }
2057  }
2058 }
2059 
2060 SwTwips SwContentFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo )
2061 {
2062  SwRectFnSet aRectFnSet(this);
2063 
2064  SwTwips nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
2065  if( nFrameHeight > 0 &&
2066  nDist > (LONG_MAX - nFrameHeight ) )
2067  nDist = LONG_MAX - nFrameHeight;
2068 
2069  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
2070  const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
2072  if (bBrowse)
2073  nTmpType |= SwFrameType::Body;
2074  if( !(GetUpper()->GetType() & nTmpType) && GetUpper()->HasFixSize() )
2075  {
2076  if ( !bTst )
2077  {
2078  {
2080  aRectFnSet.SetHeight( aFrm, nFrameHeight + nDist );
2081 
2082  if( IsVertical() && !IsVertLR() )
2083  {
2084  aFrm.Pos().AdjustX( -nDist );
2085  }
2086  }
2087 
2088  if ( GetNext() )
2089  {
2090  GetNext()->InvalidatePos();
2091  }
2092  // #i28701# - Due to the new object positioning the
2093  // frame on the next page/column can flow backward (e.g. it was moved forward
2094  // due to the positioning of its objects ). Thus, invalivate this next frame,
2095  // if document compatibility option 'Consider wrapping style influence on
2096  // object positioning' is ON.
2097  else if ( GetUpper()->GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) )
2098  {
2100  }
2101  }
2102  return 0;
2103  }
2104 
2105  SwTwips nReal = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea());
2106  SwFrame *pFrame = GetUpper()->Lower();
2107  while( pFrame && nReal > 0 )
2108  { nReal -= aRectFnSet.GetHeight(pFrame->getFrameArea());
2109  pFrame = pFrame->GetNext();
2110  }
2111 
2112  if ( !bTst )
2113  {
2114  //Contents are always resized to the wished value.
2115  long nOld = aRectFnSet.GetHeight(getFrameArea());
2116 
2117  {
2119 
2120  aRectFnSet.SetHeight( aFrm, nOld + nDist );
2121 
2122  if( IsVertical()&& !IsVertLR() )
2123  {
2124  aFrm.Pos().AdjustX( -nDist );
2125  }
2126  }
2127 
2128  SwTabFrame *pTab = (nOld && IsInTab()) ? FindTabFrame() : nullptr;
2129  if (pTab)
2130  {
2131  if ( pTab->GetTable()->GetHTMLTableLayout() &&
2132  !pTab->IsJoinLocked() &&
2133  !pTab->GetFormat()->GetDoc()->GetDocShell()->IsReadOnly() )
2134  {
2135  pTab->InvalidatePos();
2136  pTab->SetResizeHTMLTable();
2137  }
2138  }
2139  }
2140 
2141  //Only grow Upper if necessary.
2142  if ( nReal < nDist )
2143  {
2144  if( GetUpper() )
2145  {
2146  if( bTst || !GetUpper()->IsFooterFrame() )
2147  nReal = GetUpper()->Grow( nDist - std::max<long>(nReal, 0),
2148  bTst, bInfo );
2149  else
2150  {
2151  nReal = 0;
2152  GetUpper()->InvalidateSize();
2153  }
2154  }
2155  else
2156  nReal = 0;
2157  }
2158  else
2159  nReal = nDist;
2160 
2161  // #i28701# - Due to the new object positioning the
2162  // frame on the next page/column can flow backward (e.g. it was moved forward
2163  // due to the positioning of its objects ). Thus, invalivate this next frame,
2164  // if document compatibility option 'Consider wrapping style influence on
2165  // object positioning' is ON.
2166  if ( !bTst )
2167  {
2168  if ( GetNext() )
2169  {
2170  GetNext()->InvalidatePos();
2171  }
2172  else if ( GetUpper()->GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) )
2173  {
2175  }
2176  }
2177 
2178  return nReal;
2179 }
2180 
2181 SwTwips SwContentFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo )
2182 {
2183  SwRectFnSet aRectFnSet(this);
2184  OSL_ENSURE( nDist >= 0, "nDist < 0" );
2185  OSL_ENSURE( nDist <= aRectFnSet.GetHeight(getFrameArea()),
2186  "nDist > than current size." );
2187 
2188  if ( !bTst )
2189  {
2190  SwTwips nRstHeight;
2191  if( GetUpper() )
2192  nRstHeight = aRectFnSet.BottomDist( getFrameArea(), aRectFnSet.GetPrtBottom(*GetUpper()) );
2193  else
2194  nRstHeight = 0;
2195  if( nRstHeight < 0 )
2196  {
2197  SwTwips nNextHeight = 0;
2198  if( GetUpper()->IsSctFrame() && nDist > LONG_MAX/2 )
2199  {
2200  SwFrame *pNxt = GetNext();
2201  while( pNxt )
2202  {
2203  nNextHeight += aRectFnSet.GetHeight(pNxt->getFrameArea());
2204  pNxt = pNxt->GetNext();
2205  }
2206  }
2207  nRstHeight = nDist + nRstHeight - nNextHeight;
2208  }
2209  else
2210  {
2211  nRstHeight = nDist;
2212  }
2213 
2214  {
2216  aRectFnSet.SetHeight( aFrm, aRectFnSet.GetHeight(aFrm) - nDist );
2217 
2218  if( IsVertical() && !IsVertLR() )
2219  {
2220  aFrm.Pos().AdjustX(nDist );
2221  }
2222  }
2223 
2224  nDist = nRstHeight;
2225  SwTabFrame *pTab = IsInTab() ? FindTabFrame() : nullptr;
2226  if (pTab)
2227  {
2228  if ( pTab->GetTable()->GetHTMLTableLayout() &&
2229  !pTab->IsJoinLocked() &&
2230  !pTab->GetFormat()->GetDoc()->GetDocShell()->IsReadOnly() )
2231  {
2232  pTab->InvalidatePos();
2233  pTab->SetResizeHTMLTable();
2234  }
2235  }
2236  }
2237 
2238  SwTwips nReal;
2239  if( GetUpper() && nDist > 0 )
2240  {
2241  if( bTst || !GetUpper()->IsFooterFrame() )
2242  nReal = GetUpper()->Shrink( nDist, bTst, bInfo );
2243  else
2244  {
2245  nReal = 0;
2246 
2247  // #108745# Sorry, dear old footer friend, I'm not gonna invalidate you,
2248  // if there are any objects anchored inside your content, which
2249  // overlap with the shrinking frame.
2250  // This may lead to a footer frame that is too big, but this is better
2251  // than looping.
2252  // #109722# : The fix for #108745# was too strict.
2253 
2254  bool bInvalidate = true;
2255  const SwRect aRect( getFrameArea() );
2256  const SwPageFrame* pPage = FindPageFrame();
2257  const SwSortedObjs* pSorted = pPage ? pPage->GetSortedObjs() : nullptr;
2258  if( pSorted )
2259  {
2260  for (SwAnchoredObject* pAnchoredObj : *pSorted)
2261  {
2262  const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
2263 
2264  if( aBound.Left() > aRect.Right() )
2265  continue;
2266 
2267  if( aBound.IsOver( aRect ) )
2268  {
2269  const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
2270  if( css::text::WrapTextMode_THROUGH != rFormat.GetSurround().GetSurround() )
2271  {
2272  const SwFrame* pAnchor = pAnchoredObj->GetAnchorFrame();
2273  if ( pAnchor && pAnchor->FindFooterOrHeader() == GetUpper() )
2274  {
2275  bInvalidate = false;
2276  break;
2277  }
2278  }
2279  }
2280  }
2281  }
2282 
2283  if ( bInvalidate )
2284  GetUpper()->InvalidateSize();
2285  }
2286  }
2287  else
2288  nReal = 0;
2289 
2290  if ( !bTst )
2291  {
2292  //The position of the next Frame changes for sure.
2294 
2295  //If I don't have a successor I have to do the retouch by myself.
2296  if ( !GetNext() )
2297  SetRetouche();
2298  }
2299  return nReal;
2300 }
2301 
2302 void SwContentFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
2303 {
2304  sal_uInt8 nInvFlags = 0;
2305 
2306  if( pNew && RES_ATTRSET_CHG == pNew->Which() && pOld )
2307  {
2308  SfxItemIter aNIter( *static_cast<const SwAttrSetChg*>(pNew)->GetChgSet() );
2309  SfxItemIter aOIter( *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet() );
2310  SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
2311  SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
2312  while( true )
2313  {
2314  UpdateAttr_( aOIter.GetCurItem(),
2315  aNIter.GetCurItem(), nInvFlags,
2316  &aOldSet, &aNewSet );
2317  if( aNIter.IsAtEnd() )
2318  break;
2319  aNIter.NextItem();
2320  aOIter.NextItem();
2321  }
2322  if ( aOldSet.Count() || aNewSet.Count() )
2323  SwFrame::Modify( &aOldSet, &aNewSet );
2324  }
2325  else
2326  UpdateAttr_( pOld, pNew, nInvFlags );
2327 
2328  if ( nInvFlags == 0 )
2329  return;
2330 
2331  SwPageFrame *pPage = FindPageFrame();
2332  InvalidatePage( pPage );
2333  if ( nInvFlags & 0x01 )
2334  SetCompletePaint();
2335  if ( nInvFlags & 0x02 )
2336  InvalidatePos_();
2337  if ( nInvFlags & 0x04 )
2338  InvalidateSize_();
2339  if ( nInvFlags & 0x88 )
2340  {
2341  if( IsInSct() && !GetPrev() )
2342  {
2343  SwSectionFrame *pSect = FindSctFrame();
2344  if( pSect->ContainsAny() == this )
2345  {
2346  pSect->InvalidatePrt_();
2347  pSect->InvalidatePage( pPage );
2348  }
2349  }
2350  InvalidatePrt_();
2351  }
2352  SwFrame* pNextFrame = GetIndNext();
2353  if ( pNextFrame && nInvFlags & 0x10)
2354  {
2355  pNextFrame->InvalidatePrt_();
2356  pNextFrame->InvalidatePage( pPage );
2357  }
2358  if ( pNextFrame && nInvFlags & 0x80 )
2359  {
2360  pNextFrame->SetCompletePaint();
2361  }
2362  if ( nInvFlags & 0x20 )
2363  {
2364  SwFrame* pPrevFrame = GetPrev();
2365  if ( pPrevFrame )
2366  {
2367  pPrevFrame->InvalidatePrt_();
2368  pPrevFrame->InvalidatePage( pPage );
2369  }
2370  }
2371  if ( nInvFlags & 0x40 )
2373 
2374 }
2375 
2376 void SwContentFrame::UpdateAttr_( const SfxPoolItem* pOld, const SfxPoolItem* pNew,
2377  sal_uInt8 &rInvFlags,
2378  SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
2379 {
2380  bool bClear = true;
2381  sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
2382  switch ( nWhich )
2383  {
2384  case RES_FMT_CHG:
2385  rInvFlags = 0xFF;
2386  [[fallthrough]];
2387 
2388  case RES_PAGEDESC: //attribute changes (on/off)
2389  if ( IsInDocBody() && !IsInTab() )
2390  {
2391  rInvFlags |= 0x02;
2392  SwPageFrame *pPage = FindPageFrame();
2393  if ( !GetPrev() )
2394  CheckPageDescs( pPage );
2395  if (GetPageDescItem().GetNumOffset())
2396  static_cast<SwRootFrame*>(pPage->GetUpper())->SetVirtPageNum( true );
2397  SwDocPosUpdate aMsgHint( pPage->getFrameArea().Top() );
2398  pPage->GetFormat()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFields( &aMsgHint );
2399  }
2400  break;
2401 
2402  case RES_UL_SPACE:
2403  {
2404  // OD 2004-02-18 #106629# - correction
2405  // Invalidation of the printing area of next frame, not only
2406  // for footnote content.
2407  if ( !GetIndNext() )
2408  {
2409  SwFrame* pNxt = FindNext();
2410  if ( pNxt )
2411  {
2412  SwPageFrame* pPg = pNxt->FindPageFrame();
2413  pNxt->InvalidatePage( pPg );
2414  pNxt->InvalidatePrt_();
2415  if( pNxt->IsSctFrame() )
2416  {
2417  SwFrame* pCnt = static_cast<SwSectionFrame*>(pNxt)->ContainsAny();
2418  if( pCnt )
2419  {
2420  pCnt->InvalidatePrt_();
2421  pCnt->InvalidatePage( pPg );
2422  }
2423  }
2424  pNxt->SetCompletePaint();
2425  }
2426  }
2427  // OD 2004-03-17 #i11860#
2428  if ( GetIndNext() &&
2429  !GetUpper()->GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::USE_FORMER_OBJECT_POS) )
2430  {
2431  // OD 2004-07-01 #i28701# - use new method <InvalidateObjs(..)>
2433  }
2434  Prepare( PREP_UL_SPACE ); //TextFrame has to correct line spacing.
2435  rInvFlags |= 0x80;
2436  [[fallthrough]];
2437  }
2438  case RES_LR_SPACE:
2439  case RES_BOX:
2440  case RES_SHADOW:
2442  SwFrame::Modify( pOld, pNew );
2443  rInvFlags |= 0x30;
2444  break;
2445 
2446  case RES_BREAK:
2447  {
2448  rInvFlags |= 0x42;
2452  {
2453  rInvFlags |= 0x1;
2454  SwFrame* pNxt = FindNext();
2455  if( pNxt )
2456  {
2457  SwPageFrame* pPg = pNxt->FindPageFrame();
2458  pNxt->InvalidatePage( pPg );
2459  pNxt->InvalidatePrt_();
2460  if( pNxt->IsSctFrame() )
2461  {
2462  SwFrame* pCnt = static_cast<SwSectionFrame*>(pNxt)->ContainsAny();
2463  if( pCnt )
2464  {
2465  pCnt->InvalidatePrt_();
2466  pCnt->InvalidatePage( pPg );
2467  }
2468  }
2469  pNxt->SetCompletePaint();
2470  }
2471  }
2472  }
2473  break;
2474 
2475  // OD 2004-02-26 #i25029#
2477  {
2478  rInvFlags |= 0x01;
2479  if ( IsTextFrame() )
2480  {
2482  }
2483  if ( !GetIndNext() && IsInTab() && IsInSplitTableRow() )
2484  {
2486  }
2487  }
2488  break;
2489 
2490  case RES_PARATR_TABSTOP:
2491  case RES_CHRATR_SHADOWED:
2492  case RES_CHRATR_AUTOKERN:
2493  case RES_CHRATR_UNDERLINE:
2494  case RES_CHRATR_OVERLINE:
2495  case RES_CHRATR_KERNING:
2496  case RES_CHRATR_FONT:
2497  case RES_CHRATR_FONTSIZE:
2498  case RES_CHRATR_ESCAPEMENT:
2499  case RES_CHRATR_CONTOUR:
2500  case RES_PARATR_NUMRULE:
2501  rInvFlags |= 0x01;
2502  break;
2503 
2504  case RES_FRM_SIZE:
2505  rInvFlags |= 0x01;
2506  [[fallthrough]];
2507 
2508  default:
2509  bClear = false;
2510  }
2511  if ( bClear )
2512  {
2513  if ( pOldSet || pNewSet )
2514  {
2515  if ( pOldSet )
2516  pOldSet->ClearItem( nWhich );
2517  if ( pNewSet )
2518  pNewSet->ClearItem( nWhich );
2519  }
2520  else
2521  SwFrame::Modify( pOld, pNew );
2522  }
2523 }
2524 
2526  : SwFrame(pFormat, pSib)
2527  , m_pLower(nullptr)
2528 {
2529  const SwFormatFrameSize &rFormatSize = pFormat->GetFrameSize();
2530  if ( rFormatSize.GetHeightSizeType() == ATT_FIX_SIZE )
2531  mbFixSize = true;
2532 }
2533 
2534 // #i28701#
2535 
2537 {
2538  const SwFrame* pCnt = Lower();
2539  if (!pCnt)
2540  return 0;
2541 
2542  SwRectFnSet aRectFnSet(this);
2543  SwTwips nRet = 0;
2544  if( pCnt->IsColumnFrame() || pCnt->IsCellFrame() )
2545  {
2546  do
2547  {
2548  SwTwips nTmp = static_cast<const SwLayoutFrame*>(pCnt)->InnerHeight();
2549  if( pCnt->isFramePrintAreaValid() )
2550  nTmp += aRectFnSet.GetHeight(pCnt->getFrameArea()) -
2551  aRectFnSet.GetHeight(pCnt->getFramePrintArea());
2552  if( nRet < nTmp )
2553  nRet = nTmp;
2554  pCnt = pCnt->GetNext();
2555  } while ( pCnt );
2556  }
2557  else
2558  {
2559  do
2560  {
2561  nRet += aRectFnSet.GetHeight(pCnt->getFrameArea());
2562  if( pCnt->IsContentFrame() && static_cast<const SwTextFrame*>(pCnt)->IsUndersized() )
2563  nRet += static_cast<const SwTextFrame*>(pCnt)->GetParHeight() -
2564  aRectFnSet.GetHeight(pCnt->getFramePrintArea());
2565  if( pCnt->IsLayoutFrame() && !pCnt->IsTabFrame() )
2566  nRet += static_cast<const SwLayoutFrame*>(pCnt)->InnerHeight() -
2567  aRectFnSet.GetHeight(pCnt->getFramePrintArea());
2568  pCnt = pCnt->GetNext();
2569  } while( pCnt );
2570 
2571  }
2572  return nRet;
2573 }
2574 
2575 SwTwips SwLayoutFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo )
2576 {
2577  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
2578  const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
2580  if (bBrowse)
2581  nTmpType |= SwFrameType::Body;
2582  if( !(GetType() & nTmpType) && HasFixSize() )
2583  return 0;
2584 
2585  SwRectFnSet aRectFnSet(this);
2586  const SwTwips nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
2587  const SwTwips nFramePos = getFrameArea().Pos().X();
2588 
2589  if ( nFrameHeight > 0 && nDist > (LONG_MAX - nFrameHeight) )
2590  nDist = LONG_MAX - nFrameHeight;
2591 
2592  SwTwips nMin = 0;
2593  if ( GetUpper() && !IsCellFrame() )
2594  {
2595  SwFrame *pFrame = GetUpper()->Lower();
2596  while( pFrame )
2597  { nMin += aRectFnSet.GetHeight(pFrame->getFrameArea());
2598  pFrame = pFrame->GetNext();
2599  }
2600  nMin = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()) - nMin;
2601  if ( nMin < 0 )
2602  nMin = 0;
2603  }
2604 
2605  SwRect aOldFrame( getFrameArea() );
2606  bool bMoveAccFrame = false;
2607 
2608  bool bChgPos = IsVertical();
2609  if ( !bTst )
2610  {
2612  aRectFnSet.SetHeight( aFrm, nFrameHeight + nDist );
2613 
2614  if( bChgPos && !IsVertLR() )
2615  {
2616  aFrm.Pos().AdjustX( -nDist );
2617  }
2618 
2619  bMoveAccFrame = true;
2620  }
2621 
2622  SwTwips nReal = nDist - nMin;
2623  if ( nReal > 0 )
2624  {
2625  if ( GetUpper() )
2626  { // AdjustNeighbourhood now only for the columns (but not in frames)
2628  static_cast<SwFootnoteBossFrame*>(GetUpper())->NeighbourhoodAdjustment()
2630  if( SwNeighbourAdjust::OnlyAdjust == nAdjust )
2631  nReal = AdjustNeighbourhood( nReal, bTst );
2632  else
2633  {
2634  if( SwNeighbourAdjust::AdjustGrow == nAdjust )
2635  nReal += AdjustNeighbourhood( nReal, bTst );
2636 
2637  SwTwips nGrow = 0;
2638  if( 0 < nReal )
2639  {
2640  SwFrame* pToGrow = GetUpper();
2641  // NEW TABLES
2642  // A cell with a row span of > 1 is allowed to grow the
2643  // line containing the end of the row span if it is
2644  // located in the same table frame:
2645  const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this);
2646  if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 )
2647  {
2648  SwCellFrame& rEndCell = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( false ));
2649  if ( -1 == rEndCell.GetTabBox()->getRowSpan() )
2650  pToGrow = rEndCell.GetUpper();
2651  else
2652  pToGrow = nullptr;
2653  }
2654 
2655  nGrow = pToGrow ? pToGrow->Grow( nReal, bTst, bInfo ) : 0;
2656  }
2657 
2658  if( SwNeighbourAdjust::GrowAdjust == nAdjust && nGrow < nReal )
2659  nReal += AdjustNeighbourhood( nReal - nGrow, bTst );
2660 
2661  if ( IsFootnoteFrame() && (nGrow != nReal) && GetNext() )
2662  {
2663  //Footnotes can replace their successor.
2664  SwTwips nSpace = bTst ? 0 : -nDist;
2665  const SwFrame *pFrame = GetUpper()->Lower();
2666  do
2667  { nSpace += aRectFnSet.GetHeight(pFrame->getFrameArea());
2668  pFrame = pFrame->GetNext();
2669  } while ( pFrame != GetNext() );
2670  nSpace = aRectFnSet.GetHeight(GetUpper()->getFramePrintArea()) -nSpace;
2671  if ( nSpace < 0 )
2672  nSpace = 0;
2673  nSpace += nGrow;
2674  if ( nReal > nSpace )
2675  nReal = nSpace;
2676  if ( nReal && !bTst )
2677  static_cast<SwFootnoteFrame*>(this)->InvalidateNxtFootnoteCnts( FindPageFrame() );
2678  }
2679  else
2680  nReal = nGrow;
2681  }
2682  }
2683  else
2684  nReal = 0;
2685 
2686  nReal += nMin;
2687  }
2688  else
2689  nReal = nDist;
2690 
2691  if ( !bTst )
2692  {
2693  if( nReal != nDist &&
2694  // NEW TABLES
2695  ( !IsCellFrame() || static_cast<SwCellFrame*>(this)->GetLayoutRowSpan() > 1 ) )
2696  {
2698  aRectFnSet.SetHeight( aFrm, nFrameHeight + nReal );
2699 
2700  if( bChgPos && !IsVertLR() )
2701  {
2702  aFrm.Pos().setX( nFramePos - nReal );
2703  }
2704 
2705  bMoveAccFrame = true;
2706  }
2707 
2708  if ( nReal )
2709  {
2710  SwPageFrame *pPage = FindPageFrame();
2711  if ( GetNext() )
2712  {
2713  GetNext()->InvalidatePos_();
2714  if ( GetNext()->IsContentFrame() )
2715  GetNext()->InvalidatePage( pPage );
2716  }
2717  if ( !IsPageBodyFrame() )
2718  {
2719  InvalidateAll_();
2720  InvalidatePage( pPage );
2721  }
2723  NotifyLowerObjs();
2724 
2725  if( IsCellFrame() )
2726  InvaPercentLowers( nReal );
2727 
2728  std::shared_ptr<SvxBrushItem> aBack(GetFormat()->makeBackgroundBrushItem());
2729  const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : GPOS_NONE;
2730  if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
2731  SetCompletePaint();
2732  }
2733  }
2734 
2735  if( bMoveAccFrame && IsAccessibleFrame() )
2736  {
2737  SwRootFrame *pRootFrame = getRootFrame();
2738  if( pRootFrame && pRootFrame->IsAnyShellAccessible() &&
2739  pRootFrame->GetCurrShell() )
2740  {
2741  pRootFrame->GetCurrShell()->Imp()->MoveAccessibleFrame( this, aOldFrame );
2742  }
2743  }
2744  return nReal;
2745 }
2746 
2747 SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo )
2748 {
2749  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
2750  const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
2752  if (bBrowse)
2753  nTmpType |= SwFrameType::Body;
2754 
2755  if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden())
2756  {
2757  if (IsBodyFrame())
2758  {
2759  // Whitespace is hidden and this body frame will not shrink, as it
2760  // has a fix size.
2761  // Invalidate the page frame size, so in case the reason for the
2762  // shrink was that there is more whitespace on this page, the size
2763  // without whitespace will be recalculated correctly.
2764  SwPageFrame* pPageFrame = FindPageFrame();
2765  pPageFrame->InvalidateSize();
2766  }
2767  }
2768 
2769  if( !(GetType() & nTmpType) && HasFixSize() )
2770  return 0;
2771 
2772  OSL_ENSURE( nDist >= 0, "nDist < 0" );
2773  SwRectFnSet aRectFnSet(this);
2774  SwTwips nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
2775  if ( nDist > nFrameHeight )
2776  nDist = nFrameHeight;
2777 
2778  SwTwips nMin = 0;
2779  bool bChgPos = IsVertical();
2780  if ( Lower() )
2781  {
2782  if( !Lower()->IsNeighbourFrame() )
2783  { const SwFrame *pFrame = Lower();
2784  const long nTmp = aRectFnSet.GetHeight(getFramePrintArea());
2785  while( pFrame && nMin < nTmp )
2786  { nMin += aRectFnSet.GetHeight(pFrame->getFrameArea());
2787  pFrame = pFrame->GetNext();
2788  }
2789  }
2790  }
2791  SwTwips nReal = nDist;
2792  SwTwips nMinDiff = aRectFnSet.GetHeight(getFramePrintArea()) - nMin;
2793  if( nReal > nMinDiff )
2794  nReal = nMinDiff;
2795  if( nReal <= 0 )
2796  return nDist;
2797 
2798  SwRect aOldFrame( getFrameArea() );
2799  bool bMoveAccFrame = false;
2800 
2801  SwTwips nRealDist = nReal;
2802  if ( !bTst )
2803  {
2805  aRectFnSet.SetHeight( aFrm, nFrameHeight - nReal );
2806 
2807  if( bChgPos && !IsVertLR() )
2808  {
2809  aFrm.Pos().AdjustX(nReal );
2810  }
2811 
2812  bMoveAccFrame = true;
2813  }
2814 
2816  static_cast<SwFootnoteBossFrame*>(GetUpper())->NeighbourhoodAdjustment()
2818 
2819  // AdjustNeighbourhood also in columns (but not in frames)
2820  if( SwNeighbourAdjust::OnlyAdjust == nAdjust )
2821  {
2822  if ( IsPageBodyFrame() && !bBrowse )
2823  nReal = nDist;
2824  else
2825  { nReal = AdjustNeighbourhood( -nReal, bTst );
2826  nReal *= -1;
2827  if ( !bTst && IsBodyFrame() && nReal < nRealDist )
2828  {
2830  aRectFnSet.SetHeight( aFrm, aRectFnSet.GetHeight(aFrm) + nRealDist - nReal );
2831 
2832  if( bChgPos && !IsVertLR() )
2833  {
2834  aFrm.Pos().AdjustX(nRealDist - nReal );
2835  }
2836 
2837  OSL_ENSURE( !IsAccessibleFrame(), "bMoveAccFrame has to be set!" );
2838  }
2839  }
2840  }
2841  else if( IsColumnFrame() || IsColBodyFrame() )
2842  {
2843  SwTwips nTmp = GetUpper()->Shrink( nReal, bTst, bInfo );
2844  if ( nTmp != nReal )
2845  {
2847  aRectFnSet.SetHeight( aFrm, aRectFnSet.GetHeight(aFrm) + nReal - nTmp );
2848 
2849  if( bChgPos && !IsVertLR() )
2850  {
2851  aFrm.Pos().AdjustX(nTmp - nReal );
2852  }
2853 
2854  OSL_ENSURE( !IsAccessibleFrame(), "bMoveAccFrame has to be set!" );
2855  nReal = nTmp;
2856  }
2857  }
2858  else
2859  {
2860  SwTwips nShrink = nReal;
2861  SwFrame* pToShrink = GetUpper();
2862  const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this);
2863  // NEW TABLES
2864  if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 )
2865  {
2866  SwCellFrame& rEndCell = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( false ));
2867  pToShrink = rEndCell.GetUpper();
2868  }
2869 
2870  nReal = pToShrink ? pToShrink->Shrink( nShrink, bTst, bInfo ) : 0;
2871  if( ( SwNeighbourAdjust::GrowAdjust == nAdjust || SwNeighbourAdjust::AdjustGrow == nAdjust )
2872  && nReal < nShrink )
2873  AdjustNeighbourhood( nReal - nShrink );
2874  }
2875 
2876  if( bMoveAccFrame && IsAccessibleFrame() )
2877  {
2878  SwRootFrame *pRootFrame = getRootFrame();
2879  if( pRootFrame && pRootFrame->IsAnyShellAccessible() &&
2880  pRootFrame->GetCurrShell() )
2881  {
2882  pRootFrame->GetCurrShell()->Imp()->MoveAccessibleFrame( this, aOldFrame );
2883  }
2884  }
2885  if ( !bTst && (IsCellFrame() || IsColumnFrame() ? nReal : nRealDist) )
2886  {
2887  SwPageFrame *pPage = FindPageFrame();
2888  if ( GetNext() )
2889  {
2890  GetNext()->InvalidatePos_();
2891  if ( GetNext()->IsContentFrame() )
2892  GetNext()->InvalidatePage( pPage );
2893  if ( IsTabFrame() )
2894  static_cast<SwTabFrame*>(this)->SetComplete();
2895  }
2896  else
2897  { if ( IsRetoucheFrame() )
2898  SetRetouche();
2899  if ( IsTabFrame() )
2900  {
2901  static_cast<SwTabFrame*>(this)->SetComplete();
2902  if ( Lower() ) // Can also be in the Join and be empty!
2904  }
2905  }
2906  if ( !IsBodyFrame() )
2907  {
2908  InvalidateAll_();
2909  InvalidatePage( pPage );
2910  bool bCompletePaint = true;
2911  const SwFrameFormat* pFormat = GetFormat();
2912  if (pFormat)
2913  {
2914  std::shared_ptr<SvxBrushItem> aBack(pFormat->makeBackgroundBrushItem());
2915  const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : GPOS_NONE;
2916  if ( GPOS_NONE == ePos || GPOS_TILED == ePos )
2917  bCompletePaint = false;
2918  }
2919  if (bCompletePaint)
2920  SetCompletePaint();
2921  }
2922 
2924  NotifyLowerObjs();
2925 
2926  if( IsCellFrame() )
2927  InvaPercentLowers( nReal );
2928 
2929  SwContentFrame *pCnt;
2930  if( IsFootnoteFrame() && !static_cast<SwFootnoteFrame*>(this)->GetAttr()->GetFootnote().IsEndNote() &&
2931  ( GetFormat()->GetDoc()->GetFootnoteInfo().ePos != FTNPOS_CHAPTER ||
2932  ( IsInSct() && FindSctFrame()->IsFootnoteAtEnd() ) ) &&
2933  nullptr != (pCnt = static_cast<SwFootnoteFrame*>(this)->GetRefFromAttr() ) )
2934  {
2935  if ( pCnt->IsFollow() )
2936  { // If we are in another column/page than the frame with the
2937  // reference, we don't need to invalidate its master.
2938  SwFrame *pTmp = pCnt->FindFootnoteBossFrame(true) == FindFootnoteBossFrame(true)
2939  ? &pCnt->FindMaster()->GetFrame() : pCnt;
2940  pTmp->Prepare( PREP_ADJUST_FRM );
2941  pTmp->InvalidateSize();
2942  }
2943  else
2944  pCnt->InvalidatePos();
2945  }
2946  }
2947  return nReal;
2948 }
2949 
2956 void SwLayoutFrame::ChgLowersProp( const Size& rOldSize )
2957 {
2958  // no change of lower properties for root frame or if no lower exists.
2959  if ( IsRootFrame() || !Lower() )
2960  return;
2961 
2962  // declare and init <SwFrame* pLowerFrame> with first lower
2963  SwFrame *pLowerFrame = Lower();
2964 
2965  // declare and init const booleans <bHeightChgd> and <bWidthChg>
2966  const bool bHeightChgd = rOldSize.Height() != getFramePrintArea().Height();
2967  const bool bWidthChgd = rOldSize.Width() != getFramePrintArea().Width();
2968 
2969  SwRectFnSet aRectFnSet(this);
2970 
2971  // This shortcut basically tries to handle only lower frames that
2972  // are affected by the size change. Otherwise much more lower frames
2973  // are invalidated.
2974  if ( !( aRectFnSet.IsVert() ? bHeightChgd : bWidthChgd ) &&
2975  ! Lower()->IsColumnFrame() &&
2976  ( ( IsBodyFrame() && IsInDocBody() && ( !IsInSct() || !FindSctFrame()->IsColLocked() ) ) ||
2977  // #i10826# Section frames without columns should not
2978  // invalidate all lowers!
2979  IsSctFrame() ) )
2980  {
2981  // Determine page frame the body frame resp. the section frame belongs to.
2982  SwPageFrame *pPage = FindPageFrame();
2983  // Determine last lower by traveling through them using <GetNext()>.
2984  // During travel check each section frame, if it will be sized to
2985  // maximum. If Yes, invalidate size of section frame and set
2986  // corresponding flags at the page.
2987  do
2988  {
2989  if( pLowerFrame->IsSctFrame() && static_cast<SwSectionFrame*>(pLowerFrame)->ToMaximize_() )
2990  {
2991  pLowerFrame->InvalidateSize_();
2992  pLowerFrame->InvalidatePage( pPage );
2993  }
2994  if( pLowerFrame->GetNext() )
2995  pLowerFrame = pLowerFrame->GetNext();
2996  else
2997  break;
2998  } while( true );
2999  // If found last lower is a section frame containing no section
3000  // (section frame isn't valid and will be deleted in the future),
3001  // travel backwards.
3002  while( pLowerFrame->IsSctFrame() && !static_cast<SwSectionFrame*>(pLowerFrame)->GetSection() &&
3003  pLowerFrame->GetPrev() )
3004  pLowerFrame = pLowerFrame->GetPrev();
3005  // If found last lower is a section frame, set <pLowerFrame> to its last
3006  // content, if the section frame is valid and is not sized to maximum.
3007  // Otherwise set <pLowerFrame> to NULL - In this case body frame only
3008  // contains invalid section frames.
3009  if( pLowerFrame->IsSctFrame() )
3010  pLowerFrame = static_cast<SwSectionFrame*>(pLowerFrame)->GetSection() &&
3011  !static_cast<SwSectionFrame*>(pLowerFrame)->ToMaximize( false ) ?
3012  static_cast<SwSectionFrame*>(pLowerFrame)->FindLastContent() : nullptr;
3013 
3014  // continue with found last lower, probably the last content of a section
3015  if ( pLowerFrame )
3016  {
3017  // If <pLowerFrame> is in a table frame, set <pLowerFrame> to this table
3018  // frame and continue.
3019  if ( pLowerFrame->IsInTab() )
3020  {
3021  // OD 28.10.2002 #97265# - safeguard for setting <pLowerFrame> to
3022  // its table frame - check, if the table frame is also a lower
3023  // of the body frame, in order to assure that <pLowerFrame> is not
3024  // set to a frame, which is an *upper* of the body frame.
3025  SwFrame* pTableFrame = pLowerFrame->FindTabFrame();
3026  if ( IsAnLower( pTableFrame ) )
3027  {
3028  pLowerFrame = pTableFrame;
3029  }
3030  }
3031  // Check, if variable size of body frame resp. section frame has grown
3032  // OD 28.10.2002 #97265# - correct check, if variable size has grown.
3033  SwTwips nOldHeight = aRectFnSet.IsVert() ? rOldSize.Width() : rOldSize.Height();
3034  if( nOldHeight < aRectFnSet.GetHeight(getFramePrintArea()) )
3035  {
3036  // If variable size of body|section frame has grown, only found
3037  // last lower and the position of the its next have to be invalidated.
3038  pLowerFrame->InvalidateAll_();
3039  pLowerFrame->InvalidatePage( pPage );
3040  if( !pLowerFrame->IsFlowFrame() ||
3041  !SwFlowFrame::CastFlowFrame( pLowerFrame )->HasFollow() )
3042  pLowerFrame->InvalidateNextPos( true );
3043  if ( pLowerFrame->IsTextFrame() )
3044  static_cast<SwContentFrame*>(pLowerFrame)->Prepare( PREP_ADJUST_FRM );
3045  }
3046  else
3047  {
3048  // variable size of body|section frame has shrunk. Thus,
3049  // invalidate all lowers not matching the new body|section size
3050  // and the dedicated new last lower.
3051  if( aRectFnSet.IsVert() )
3052  {
3053  SwTwips nBot = getFrameArea().Left() + getFramePrintArea().Left();
3054  while ( pLowerFrame && pLowerFrame->GetPrev() && pLowerFrame->getFrameArea().Left() < nBot )
3055  {
3056  pLowerFrame->InvalidateAll_();
3057  pLowerFrame->InvalidatePage( pPage );
3058  pLowerFrame = pLowerFrame->GetPrev();
3059  }
3060  }
3061  else
3062  {
3063  SwTwips nBot = getFrameArea().Top() + getFramePrintArea().Bottom();
3064  while ( pLowerFrame && pLowerFrame->GetPrev() && pLowerFrame->getFrameArea().Top() > nBot )
3065  {
3066  pLowerFrame->InvalidateAll_();
3067  pLowerFrame->InvalidatePage( pPage );
3068  pLowerFrame = pLowerFrame->GetPrev();
3069  }
3070  }
3071  if ( pLowerFrame )
3072  {
3073  pLowerFrame->InvalidateSize_();
3074  pLowerFrame->InvalidatePage( pPage );
3075  if ( pLowerFrame->IsTextFrame() )
3076  static_cast<SwContentFrame*>(pLowerFrame)->Prepare( PREP_ADJUST_FRM );
3077  }
3078  }
3079  // #i41694# - improvement by removing duplicates
3080  if ( pLowerFrame )
3081  {
3082  if ( pLowerFrame->IsInSct() )
3083  {
3084  // #i41694# - follow-up of issue #i10826#
3085  // No invalidation of section frame, if it's the this.
3086  SwFrame* pSectFrame = pLowerFrame->FindSctFrame();
3087  if( pSectFrame != this && IsAnLower( pSectFrame ) )
3088  {
3089  pSectFrame->InvalidateSize_();
3090  pSectFrame->InvalidatePage( pPage );
3091  }
3092  }
3093  }
3094  }
3095  return;
3096  } // end of { special case }
3097 
3098  // Invalidate page for content only once.
3099  bool bInvaPageForContent = true;
3100 
3101  // Declare booleans <bFixChgd> and <bVarChgd>, indicating for text frame
3102  // adjustment, if fixed/variable size has changed.
3103  bool bFixChgd, bVarChgd;
3104  if( aRectFnSet.IsVert() == pLowerFrame->IsNeighbourFrame() )
3105  {
3106  bFixChgd = bWidthChgd;
3107  bVarChgd = bHeightChgd;
3108  }
3109  else
3110  {
3111  bFixChgd = bHeightChgd;
3112  bVarChgd = bWidthChgd;
3113  }
3114 
3115  // Declare const unsigned short <nFixWidth> and init it this frame types
3116  // which has fixed width in vertical respectively horizontal layout.
3117  // In vertical layout these are neighbour frames (cell and column frames),
3118  // header frames and footer frames.
3119  // In horizontal layout these are all frames, which aren't neighbour frames.
3120  const SwFrameType nFixWidth = aRectFnSet.IsVert() ? (FRM_NEIGHBOUR | FRM_HEADFOOT)
3122 
3123  // Declare const unsigned short <nFixHeight> and init it this frame types
3124  // which has fixed height in vertical respectively horizontal layout.
3125  // In vertical layout these are all frames, which aren't neighbour frames,
3126  // header frames, footer frames, body frames or foot note container frames.
3127  // In horizontal layout these are neighbour frames.
3128  const SwFrameType nFixHeight = aRectFnSet.IsVert() ? ~SwFrameType(FRM_NEIGHBOUR | FRM_HEADFOOT | FRM_BODYFTNC)
3129  : FRM_NEIGHBOUR;
3130 
3131  // Travel through all lowers using <GetNext()>
3132  while ( pLowerFrame )
3133  {
3134  if ( pLowerFrame->IsTextFrame() )
3135  {
3136  // Text frames will only be invalidated - prepare invalidation
3137  if ( bFixChgd )
3138  static_cast<SwContentFrame*>(pLowerFrame)->Prepare( PREP_FIXSIZE_CHG );
3139  if ( bVarChgd )
3140  static_cast<SwContentFrame*>(pLowerFrame)->Prepare( PREP_ADJUST_FRM );
3141  }
3142  else
3143  {
3144  // If lower isn't a table, row, cell or section frame, adjust its
3145  // frame size.
3146  const SwFrameType nLowerType = pLowerFrame->GetType();
3148  {
3149  if ( bWidthChgd )
3150  {
3151  if( nLowerType & nFixWidth )
3152  {
3153  // Considering previous conditions:
3154  // In vertical layout set width of column, header and
3155  // footer frames to its upper width.
3156  // In horizontal layout set width of header, footer,
3157  // foot note container, foot note, body and no-text
3158  // frames to its upper width.
3160  aFrm.Width( getFramePrintArea().Width() );
3161  }
3162  else if( rOldSize.Width() && !pLowerFrame->IsFootnoteFrame() )
3163  {
3164  // Adjust frame width proportional, if lower isn't a
3165  // foot note frame and condition <nLowerType & nFixWidth>
3166  // isn't true.
3167  // Considering previous conditions:
3168  // In vertical layout these are foot note container,
3169  // body and no-text frames.
3170  // In horizontal layout these are column and no-text frames.
3171  // OD 24.10.2002 #97265# - <double> calculation
3172  // Perform <double> calculation of new width, if
3173  // one of the coefficients is greater than 50000
3174  SwTwips nNewWidth;
3175  if ( (pLowerFrame->getFrameArea().Width() > 50000) ||
3176  (getFramePrintArea().Width() > 50000) )
3177  {
3178  double nNewWidthTmp =
3179  ( double(pLowerFrame->getFrameArea().Width())
3180  * double(getFramePrintArea().Width()) )
3181  / double(rOldSize.Width());
3182  nNewWidth = SwTwips(nNewWidthTmp);
3183  }
3184  else
3185  {
3186  nNewWidth =
3187  (pLowerFrame->getFrameArea().Width() * getFramePrintArea().Width()) / rOldSize.Width();
3188  }
3189 
3191  aFrm.Width( nNewWidth );
3192  }
3193  }
3194  if ( bHeightChgd )
3195  {
3196  if( nLowerType & nFixHeight )
3197  {
3198  // Considering previous conditions:
3199  // In vertical layout set height of foot note and
3200  // no-text frames to its upper height.
3201  // In horizontal layout set height of column frames
3202  // to its upper height.
3204  aFrm.Height( getFramePrintArea().Height() );
3205  }
3206  // OD 01.10.2002 #102211#
3207  // add conditions <!pLowerFrame->IsHeaderFrame()> and
3208  // <!pLowerFrame->IsFooterFrame()> in order to avoid that
3209  // the <Grow> of header or footer are overwritten.
3210  // NOTE: Height of header/footer frame is determined by contents.
3211  else if ( rOldSize.Height() &&
3212  !pLowerFrame->IsFootnoteFrame() &&
3213  !pLowerFrame->IsHeaderFrame() &&
3214  !pLowerFrame->IsFooterFrame()
3215  )
3216  {
3217  // Adjust frame height proportional, if lower isn't a
3218  // foot note, a header or a footer frame and
3219  // condition <nLowerType & nFixHeight> isn't true.
3220  // Considering previous conditions:
3221  // In vertical layout these are column, foot note container,
3222  // body and no-text frames.
3223  // In horizontal layout these are column, foot note
3224  // container, body and no-text frames.
3225 
3226  // OD 29.10.2002 #97265# - special case for page lowers
3227  // The page lowers that have to be adjusted on page height
3228  // change are the body frame and the foot note container
3229  // frame.
3230  // In vertical layout the height of both is directly
3231  // adjusted to the page height change.
3232  // In horizontal layout the height of the body frame is
3233  // directly adjusted to the page height change and the
3234  // foot note frame height isn't touched, because its
3235  // determined by its content.
3236  // OD 31.03.2003 #108446# - apply special case for page
3237  // lowers - see description above - also for section columns.
3238  if ( IsPageFrame() ||
3239  ( IsColumnFrame() && IsInSct() )
3240  )
3241  {
3242  OSL_ENSURE( pLowerFrame->IsBodyFrame() || pLowerFrame->IsFootnoteContFrame(),
3243  "ChgLowersProp - only for body or foot note container" );
3244  if ( pLowerFrame->IsBodyFrame() || pLowerFrame->IsFootnoteContFrame() )
3245  {
3246  if ( IsVertical() || pLowerFrame->IsBodyFrame() )
3247  {
3248  SwTwips nNewHeight =
3249  pLowerFrame->getFrameArea().Height() +
3250  ( getFramePrintArea().Height() - rOldSize.Height() );
3251  if ( nNewHeight < 0)
3252  {
3253  // OD 01.04.2003 #108446# - adjust assertion condition and text
3254  OSL_ENSURE( !( IsPageFrame() &&
3255  (pLowerFrame->getFrameArea().Height()>0) &&
3256  (pLowerFrame->isFrameAreaDefinitionValid()) ),
3257  "ChgLowersProg - negative height for lower.");
3258  nNewHeight = 0;
3259  }
3260 
3262  aFrm.Height( nNewHeight );
3263  }
3264  }
3265  }
3266  else
3267  {
3268  SwTwips nNewHeight;
3269  // OD 24.10.2002 #97265# - <double> calculation
3270  // Perform <double> calculation of new height, if
3271  // one of the coefficients is greater than 50000
3272  if ( (pLowerFrame->getFrameArea().Height() > 50000) ||
3273  (getFramePrintArea().Height() > 50000) )
3274  {
3275  double nNewHeightTmp =
3276  ( double(pLowerFrame->getFrameArea().Height())
3277  * double(getFramePrintArea().Height()) )
3278  / double(rOldSize.Height());
3279  nNewHeight = SwTwips(nNewHeightTmp);
3280  }
3281  else
3282  {
3283  nNewHeight = ( pLowerFrame->getFrameArea().Height()
3284  * getFramePrintArea().Height() ) / rOldSize.Height();
3285  }
3286  if( !pLowerFrame->GetNext() )
3287  {
3288  SwTwips nSum = getFramePrintArea().Height();
3289  SwFrame* pTmp = Lower();
3290  while( pTmp->GetNext() )
3291  {
3292  if( !pTmp->IsFootnoteContFrame() || !pTmp->IsVertical() )
3293  nSum -= pTmp->getFrameArea().Height();
3294  pTmp = pTmp->GetNext();
3295  }
3296  if( nSum - nNewHeight == 1 &&
3297  nSum == pLowerFrame->getFrameArea().Height() )
3298  nNewHeight = nSum;
3299  }
3300 
3302  aFrm.Height( nNewHeight );
3303  }
3304  }
3305  }
3306  }
3307  } // end of else { NOT text frame }
3308 
3309  pLowerFrame->InvalidateAll_();
3310  if ( bInvaPageForContent && pLowerFrame->IsContentFrame() )
3311  {
3312  pLowerFrame->InvalidatePage();
3313  bInvaPageForContent = false;
3314  }
3315 
3316  if ( !pLowerFrame->GetNext() && pLowerFrame->IsRetoucheFrame() )
3317  {
3318  //If a growth took place and the subordinate elements can retouch
3319  //itself (currently Tabs, Sections and Content) we trigger it.
3320  if ( rOldSize.Height() < getFramePrintArea().SSize().Height() ||
3321  rOldSize.Width() < getFramePrintArea().SSize().Width() )
3322  pLowerFrame->SetRetouche();
3323  }
3324  pLowerFrame = pLowerFrame->GetNext();
3325  }
3326 
3327  // Finally adjust the columns if width is set to auto
3328  // Possible optimization: execute this code earlier in this function and
3329  // return???
3330  if ( ( (aRectFnSet.IsVert() && bHeightChgd) || (! aRectFnSet.IsVert() && bWidthChgd) ) &&
3331  Lower()->IsColumnFrame() )
3332  {
3333  // get column attribute
3334  const SwFormatCol* pColAttr = nullptr;
3335  if ( IsPageBodyFrame() )
3336  {
3337  OSL_ENSURE( GetUpper()->IsPageFrame(), "Upper is not page frame" );
3338  pColAttr = &GetUpper()->GetFormat()->GetCol();
3339  }
3340  else
3341  {
3342  OSL_ENSURE( IsFlyFrame() || IsSctFrame(), "Columns not in fly or section" );
3343  pColAttr = &GetFormat()->GetCol();
3344  }
3345 
3346  if ( pColAttr->IsOrtho() && pColAttr->GetNumCols() > 1 )
3347  AdjustColumns( pColAttr, false );
3348  }
3349 }
3350 
3355 void SwLayoutFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderAttrs *pAttrs )
3356 {
3357  OSL_ENSURE( pAttrs, "LayoutFrame::Format, pAttrs is 0." );
3358 
3360  return;
3361 
3362  bool bHideWhitespace = false;
3363  if (IsPageFrame())
3364  {
3365  SwViewShell* pShell = getRootFrame()->GetCurrShell();
3366  if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden())
3367  {
3368  // This is needed so that no space is reserved for the margin on
3369  // the last page of the document. Other pages would have no margin
3370  // set even without this, as their frame height is the content
3371  // height already.
3372  bHideWhitespace = true;
3373  }
3374  }
3375 
3376  const sal_uInt16 nLeft = static_cast<sal_uInt16>(pAttrs->CalcLeft(this));
3377  const sal_uInt16 nUpper = bHideWhitespace ? 0 : pAttrs->CalcTop();
3378 
3379  const sal_uInt16 nRight = static_cast<sal_uInt16>(pAttrs->CalcRight(this));
3380  const sal_uInt16 nLower = bHideWhitespace ? 0 : pAttrs->CalcBottom();
3381 
3382  const bool bVert = IsVertical() && !IsPageFrame();
3383  SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
3384  if ( !isFramePrintAreaValid() )
3385  {
3386  setFramePrintAreaValid(true);
3387  (this->*fnRect->fnSetXMargins)( nLeft, nRight );
3388  (this->*fnRect->fnSetYMargins)( nUpper, nLower );
3389  }
3390 
3391  if ( !isFrameAreaSizeValid() )
3392  {
3393  if ( !HasFixSize() )
3394  {
3395  const SwTwips nBorder = nUpper + nLower;
3396  const SwFormatFrameSize &rSz = GetFormat()->GetFrameSize();
3397  SwTwips nMinHeight = rSz.GetHeightSizeType() == ATT_MIN_SIZE ? rSz.GetHeight() : 0;
3398  do
3399  {
3400  setFrameAreaSizeValid(true);
3401 
3402  //The size in VarSize is calculated using the content plus the
3403  // borders.
3404  SwTwips nRemaining = 0;
3405  SwFrame *pFrame = Lower();
3406  while ( pFrame )
3407  { nRemaining += (pFrame->getFrameArea().*fnRect->fnGetHeight)();
3408  if( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsUndersized() )
3409  // This TextFrame would like to be a bit bigger
3410  nRemaining += static_cast<SwTextFrame*>(pFrame)->GetParHeight()
3411  - (pFrame->getFramePrintArea().*fnRect->fnGetHeight)();
3412  else if( pFrame->IsSctFrame() && static_cast<SwSectionFrame*>(pFrame)->IsUndersized() )
3413  nRemaining += static_cast<SwSectionFrame*>(pFrame)->Undersize();
3414  pFrame = pFrame->GetNext();
3415  }
3416  nRemaining += nBorder;
3417  nRemaining = std::max( nRemaining, nMinHeight );
3418  const SwTwips nDiff = nRemaining-(getFrameArea().*fnRect->fnGetHeight)();
3419  const long nOldLeft = (getFrameArea().*fnRect->fnGetLeft)();
3420  const long nOldTop = (getFrameArea().*fnRect->fnGetTop)();
3421  if ( nDiff )
3422  {
3423  if ( nDiff > 0 )
3424  Grow( nDiff );
3425  else
3426  Shrink( -nDiff );
3427  //Updates the positions using the fast channel.
3428  MakePos();
3429  }
3430  //Don't exceed the bottom edge of the Upper.
3431  if ( GetUpper() && (getFrameArea().*fnRect->fnGetHeight)() )
3432  {
3433  const SwTwips nLimit = (GetUpper()->*fnRect->fnGetPrtBottom)();
3434  if( (this->*fnRect->fnSetLimit)( nLimit ) &&
3435  nOldLeft == (getFrameArea().*fnRect->fnGetLeft)() &&
3436  nOldTop == (getFrameArea().*fnRect->fnGetTop)() )
3437  {
3438  setFrameAreaSizeValid(true);
3439  setFramePrintAreaValid(true);
3440  }
3441  }
3442  } while ( !isFrameAreaSizeValid() );
3443  }
3444  else if (GetType() & FRM_HEADFOOT)
3445  {
3446  do
3447  { if ( getFrameArea().Height() != pAttrs->GetSize().Height() )
3448  {
3449  ChgSize( Size( getFrameArea().Width(), pAttrs->GetSize().Height()));
3450  }
3451 
3452  setFrameAreaSizeValid(true);
3453  MakePos();
3454  } while ( !isFrameAreaSizeValid() );
3455  }
3456  else
3457  {
3458  setFrameAreaSizeValid(true);
3459  }
3460 
3461  // While updating the size, PrtArea might be invalidated.
3462  if (!isFramePrintAreaValid())
3463  {
3464  setFramePrintAreaValid(true);
3465  (this->*fnRect->fnSetXMargins)(nLeft, nRight);
3466  (this->*fnRect->fnSetYMargins)(nUpper, nLower);
3467  }
3468  }
3469 }
3470 
3471 static void InvaPercentFlys( SwFrame *pFrame, SwTwips nDiff )
3472 {
3473  OSL_ENSURE( pFrame->GetDrawObjs(), "Can't find any Objects" );
3474  for (SwAnchoredObject* pAnchoredObj : *pFrame->GetDrawObjs())
3475  {
3476  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
3477  {
3478  SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
3479  const SwFormatFrameSize &rSz = pFly->GetFormat()->GetFrameSize();
3480  if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
3481  {
3482  bool bNotify = true;
3483  // If we've a fly with more than 90% relative height...
3484  if( rSz.GetHeightPercent() > 90 && pFly->GetAnchorFrame() &&
3485  rSz.GetHeightPercent() != SwFormatFrameSize::SYNCED && nDiff )
3486  {
3487  const SwFrame *pRel = pFly->IsFlyLayFrame() ? pFly->GetAnchorFrame():
3488  pFly->GetAnchorFrame()->GetUpper();
3489  // ... and we have already more than 90% height and we
3490  // not allow the text to go through...
3491  // then a notification could cause an endless loop, e.g.
3492  // 100% height and no text wrap inside a cell of a table.
3493  if( pFly->getFrameArea().Height()*10 >
3494  ( nDiff + pRel->getFramePrintArea().Height() )*9 &&
3495  pFly->GetFormat()->GetSurround().GetSurround() !=
3496  css::text::WrapTextMode_THROUGH )
3497  bNotify = false;
3498  }
3499  if( bNotify )
3500  pFly->InvalidateSize();
3501  }
3502  }
3503  }
3504 }
3505 
3507 {
3508  if ( GetDrawObjs() )
3509  ::InvaPercentFlys( this, nDiff );
3510 
3511  SwFrame *pFrame = ContainsContent();
3512  if ( pFrame )
3513  do
3514  {
3515  if ( pFrame->IsInTab() && !IsTabFrame() )
3516  {
3517  SwFrame *pTmp = pFrame->FindTabFrame();
3518  OSL_ENSURE( pTmp, "Where's my TabFrame?" );
3519  if( IsAnLower( pTmp ) )
3520  pFrame = pTmp;
3521  }
3522 
3523  if ( pFrame->IsTabFrame() )
3524  {
3525  const SwFormatFrameSize &rSz = static_cast<SwLayoutFrame*>(pFrame)->GetFormat()->GetFrameSize();
3526  if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
3527  pFrame->InvalidatePrt();
3528  }
3529  else if ( pFrame->GetDrawObjs() )
3530  ::InvaPercentFlys( pFrame, nDiff );
3531  pFrame = pFrame->FindNextCnt();
3532  } while ( pFrame && IsAnLower( pFrame ) ) ;
3533 }
3534 
3536 {
3537  long nRet = rSz.GetWidth(),
3538  nPercent = rSz.GetWidthPercent();
3539 
3540  if ( nPercent )
3541  {
3542  const SwFrame *pRel = GetUpper();
3543  long nRel = LONG_MAX;
3544  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
3545  const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
3546  if( pRel->IsPageBodyFrame() && pSh && bBrowseMode && pSh->VisArea().Width() )
3547  {
3548  nRel = pSh->GetBrowseWidth();
3549  long nDiff = nRel - pRel->getFramePrintArea().Width();
3550  if ( nDiff > 0 )
3551  nRel -= nDiff;
3552  }
3553  nRel = std::min( nRel, pRel->getFramePrintArea().Width() );
3554  nRet = nRel * nPercent / 100;
3555  }
3556  return nRet;
3557 }
3558 
3559 // Local helpers for SwLayoutFrame::FormatWidthCols()
3560 
3561 static long lcl_CalcMinColDiff( SwLayoutFrame *pLayFrame )
3562 {
3563  long nDiff = 0, nFirstDiff = 0;
3564  SwLayoutFrame *pCol = static_cast<SwLayoutFrame*>(pLayFrame->Lower());
3565  OSL_ENSURE( pCol, "Where's the columnframe?" );
3566  SwFrame *pFrame = pCol->Lower();
3567  do
3568  {
3569  if( pFrame && pFrame->IsBodyFrame() )
3570  pFrame = static_cast<SwBodyFrame*>(pFrame)->Lower();
3571  if ( pFrame && pFrame->IsTextFrame() )
3572  {
3573  const long nTmp = static_cast<SwTextFrame*>(pFrame)->FirstLineHeight();
3574  if ( nTmp != USHRT_MAX )
3575  {
3576  if ( pCol == pLayFrame->Lower() )
3577  nFirstDiff = nTmp;
3578  else
3579  nDiff = nDiff ? std::min( nDiff, nTmp ) : nTmp;
3580  }
3581  }
3582  //Skip empty columns!
3583  pCol = static_cast<SwLayoutFrame*>(pCol->GetNext());
3584  while ( pCol && nullptr == (pFrame = pCol->Lower()) )
3585  pCol = static_cast<SwLayoutFrame*>(pCol->GetNext());
3586 
3587  } while ( pFrame && pCol );
3588 
3589  return nDiff ? nDiff : nFirstDiff ? nFirstDiff : 240;
3590 }
3591 
3593 {
3594  SwFrame *pFrame = pLay->ContainsContent();
3595  while ( pFrame )
3596  {
3597  if ( pFrame->IsInTab() )
3598  pFrame = pFrame->FindTabFrame();
3599 
3600  if ( pFrame->GetDrawObjs() )
3601  {
3602  const size_t nCnt = pFrame->GetDrawObjs()->size();
3603  for ( size_t i = 0; i < nCnt; ++i )
3604  {
3605  SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
3606  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
3607  {
3608  SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
3609  if ( pFly->IsHeightClipped() &&
3610  ( !pFly->IsFlyFreeFrame() || pFly->GetPageFrame() ) )
3611  return true;
3612  }
3613  }
3614  }
3615  pFrame = pFrame->FindNextCnt();
3616  }
3617  return false;
3618 }
3619 
3621  const SwTwips nBorder, const SwTwips nMinHeight )
3622 {
3623  //If there are columns involved, the size is adjusted using the last column.
3624  //1. Format content.
3625  //2. Calculate height of the last column: if it's too big, the Fly has to
3626  // grow. The amount by which the Fly grows is not the amount of the
3627  // overhang because we have to act on the assumption that some text flows
3628  // back which will generate some more space.
3629  // The amount which we grow by equals the overhang
3630  // divided by the amount of columns or the overhang itself if it's smaller
3631  // than the amount of columns.
3632  //3. Go back to 1. until everything is stable.
3633 
3634  const SwFormatCol &rCol = rAttrs.GetAttrSet().GetCol();
3635  const sal_uInt16 nNumCols = rCol.GetNumCols();
3636 
3637  bool bEnd = false;
3638  bool bBackLock = false;
3640  SwViewShellImp *pImp = pSh ? pSh->Imp() : nullptr;
3641  vcl::RenderContext* pRenderContext = pSh ? pSh->GetOut() : nullptr;
3642  {
3643  // Underlying algorithm
3644  // We try to find the optimal height for the column.
3645  // nMinimum starts with the passed minimum height and is then remembered
3646  // as the maximum height on which column content still juts out of a
3647  // column.
3648  // nMaximum starts with LONG_MAX and is then remembered as the minimum
3649  // width on which the content fitted.
3650  // In column based sections nMaximum starts at the maximum value which
3651  // the surrounding defines, this can certainly be a value on which
3652  // content still juts out.
3653  // The columns are formatted. If content still juts out, nMinimum is
3654  // adjusted accordingly, then we grow, at least by uMinDiff but not
3655  // over a certain nMaximum. If no content juts out but there is still
3656  // some space left in the column, shrinking is done accordingly, at
3657  // least by nMindIff but not below the nMinimum.
3658  // Cancel as soon as no content juts out and the difference from minimum
3659  // to maximum is less than MinDiff or the maximum which was defined by
3660  // the surrounding is reached even if some content still juts out.
3661 
3662  // Criticism of this implementation
3663  // 1. Theoretically situations are possible in which the content fits in
3664  // a lower height but not in a higher height. To ensure that the code
3665  // handles such situations the code contains a few checks concerning
3666  // minimum and maximum which probably are never triggered.
3667  // 2. We use the same nMinDiff for shrinking and growing, but nMinDiff
3668  // is more or less the smallest first line height and doesn't seem ideal
3669  // as minimum value.
3670 
3671  long nMinimum = nMinHeight;
3672  long nMaximum;
3673  bool bNoBalance = false;
3674  SwRectFnSet aRectFnSet(this);
3675  if( IsSctFrame() )
3676  {
3677  nMaximum = aRectFnSet.GetHeight(getFrameArea()) - nBorder +
3678  aRectFnSet.BottomDist(getFrameArea(), aRectFnSet.GetPrtBottom(*GetUpper()));
3679  nMaximum += GetUpper()->Grow( LONG_MAX, true );
3680  if( nMaximum < nMinimum )
3681  {
3682  if( nMaximum < 0 )
3683  nMinimum = nMaximum = 0;
3684  else
3685  nMinimum = nMaximum;
3686  }
3687  if( nMaximum > BROWSE_HEIGHT )
3688  nMaximum = BROWSE_HEIGHT;
3689 
3690  bNoBalance = static_cast<SwSectionFrame*>(this)->GetSection()->GetFormat()->
3691  GetBalancedColumns().GetValue();
3692  SwFrame* pAny = ContainsAny();
3693  if( bNoBalance ||
3694  ( !aRectFnSet.GetHeight(getFrameArea()) && pAny ) )
3695  {
3696  long nTop = aRectFnSet.GetTopMargin(*this);
3697  // #i23129# - correction
3698  // to the calculated maximum height.
3699  {
3701  aRectFnSet.AddBottom( aFrm, nMaximum - aRectFnSet.GetHeight(getFrameArea()) );
3702  }
3703 
3704  if( nTop > nMaximum )
3705  nTop = nMaximum;
3706  aRectFnSet.SetYMargins( *this, nTop, 0 );
3707  }
3708  if( !pAny && !static_cast<SwSectionFrame*>(this)->IsFootnoteLock() )
3709  {
3710  SwFootnoteContFrame* pFootnoteCont = static_cast<SwSectionFrame*>(this)->ContainsFootnoteCont();
3711  if( pFootnoteCont )
3712  {
3713  SwFrame* pFootnoteAny = pFootnoteCont->ContainsAny();
3714  if( pFootnoteAny && pFootnoteAny->isFrameAreaDefinitionValid() )
3715  {
3716  bBackLock = true;
3717  static_cast<SwSectionFrame*>(this)->SetFootnoteLock( true );
3718  }
3719  }
3720  }
3721  }
3722  else
3723  nMaximum = LONG_MAX;
3724 
3725  // #i3317# - reset temporarily consideration
3726  // of wrapping style influence
3727  SwPageFrame* pPageFrame = FindPageFrame();
3728  SwSortedObjs* pObjs = pPageFrame ? pPageFrame->GetSortedObjs() : nullptr;
3729  if ( pObjs )
3730  {
3731  for (SwAnchoredObject* pAnchoredObj : *pObjs)
3732  {
3733  if ( IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
3734  {
3735  pAnchoredObj->SetTmpConsiderWrapInfluence( false );
3736  }
3737  }
3738  }
3739  do
3740  {
3741  //Could take a while therefore check for Waitcrsr here.
3742  if ( pImp )
3743  pImp->CheckWaitCursor();
3744 
3745  setFrameAreaSizeValid(true);
3746  //First format the column as this will relieve the stack a bit.
3747  //Also set width and height of the column (if they are wrong)
3748  //while we are at it.
3749  SwLayoutFrame *pCol = static_cast<SwLayoutFrame*>(Lower());
3750 
3751  // #i27399#
3752  // Simply setting the column width based on the values returned by
3753  // CalcColWidth does not work for automatic column width.
3754  AdjustColumns( &rCol, false );
3755 
3756  for ( sal_uInt16 i = 0; i < nNumCols; ++i )
3757  {
3758  pCol->Calc(pRenderContext);
3759  // ColumnFrames have a BodyFrame now, which needs to be calculated
3760  pCol->Lower()->Calc(pRenderContext);
3761  if( pCol->Lower()->GetNext() )
3762  pCol->Lower()->GetNext()->Calc(pRenderContext); // SwFootnoteCont
3763  pCol = static_cast<SwLayoutFrame*>(pCol->GetNext());
3764  }
3765 
3766  ::CalcContent( this );
3767 
3768  pCol = static_cast<SwLayoutFrame*>(Lower());
3769  OSL_ENSURE( pCol && pCol->GetNext(), ":-( column making holidays?");
3770  // set bMinDiff if no empty columns exist
3771  bool bMinDiff = true;
3772  // OD 28.03.2003 #108446# - check for all column content and all columns
3773  while ( bMinDiff && pCol )
3774  {
3775  bMinDiff = nullptr != pCol->ContainsContent();
3776  pCol = static_cast<SwLayoutFrame*>(pCol->GetNext());
3777  }
3778  pCol = static_cast<SwLayoutFrame*>(Lower());
3779  // OD 28.03.2003 #108446# - initialize local variable
3780  SwTwips nDiff = 0;
3781  SwTwips nMaxFree = 0;
3782  SwTwips nAllFree = LONG_MAX;
3783  // set bFoundLower if there is at least one non-empty column
3784  bool bFoundLower = false;
3785  while( pCol )
3786  {
3787  SwLayoutFrame* pLay = static_cast<SwLayoutFrame*>(pCol->Lower());
3788  SwTwips nInnerHeight = aRectFnSet.GetHeight(pLay->getFrameArea()) -
3789  aRectFnSet.GetHeight(pLay->getFramePrintArea());
3790  if( pLay->Lower() )
3791  {
3792  bFoundLower = true;
3793  nInnerHeight += pLay->InnerHeight();
3794  }
3795  else if( nInnerHeight < 0 )
3796  nInnerHeight = 0;
3797 
3798  if( pLay->GetNext() )
3799  {
3800  bFoundLower = true;
3801  pLay = static_cast<SwLayoutFrame*>(pLay->GetNext());
3802  OSL_ENSURE( pLay->IsFootnoteContFrame(),"FootnoteContainer expected" );
3803  nInnerHeight += pLay->InnerHeight();
3804  nInnerHeight += aRectFnSet.GetHeight(pLay->getFrameArea()) -
3805  aRectFnSet.GetHeight(pLay->getFramePrintArea());
3806  }
3807  nInnerHeight -= aRectFnSet.GetHeight(pCol->getFramePrintArea());
3808  if( nInnerHeight > nDiff )
3809  {
3810  nDiff = nInnerHeight;
3811  nAllFree = 0;
3812  }
3813  else
3814  {
3815  if( nMaxFree < -nInnerHeight )
3816  nMaxFree = -nInnerHeight;
3817  if( nAllFree > -nInnerHeight )
3818  nAllFree = -nInnerHeight;
3819  }
3820  pCol = static_cast<SwLayoutFrame*>(pCol->GetNext());
3821  }
3822 
3823  if ( bFoundLower || ( IsSctFrame() && static_cast<SwSectionFrame*>(this)->HasFollow() ) )
3824  {
3825  SwTwips nMinDiff = ::lcl_CalcMinColDiff( this );
3826  // Here we decide if growing is needed - this is the case, if
3827  // column content (nDiff) or a Fly juts over.
3828  // In sections with columns we take into account to set the size
3829  // when having a non-empty Follow.
3830  if ( nDiff || ::lcl_IsFlyHeightClipped( this ) ||
3831  ( IsSctFrame() && static_cast<SwSectionFrame*>(this)->CalcMinDiff( nMinDiff ) ) )
3832  {
3833  long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
3834  // The minimum must not be smaller than our PrtHeight as
3835  // long as something juts over.
3836  if( nMinimum < nPrtHeight )
3837  nMinimum = nPrtHeight;
3838  // The maximum must not be smaller than PrtHeight if
3839  // something still juts over.
3840  if( nMaximum < nPrtHeight )
3841  nMaximum = nPrtHeight; // Robust, but will this ever happen?
3842  if( !nDiff ) // If only Flys jut over, we grow by nMinDiff
3843  nDiff = nMinDiff;
3844  // If we should grow more than by nMinDiff we split it over
3845  // the columns
3846  if ( std::abs(nDiff - nMinDiff) > nNumCols && nDiff > static_cast<long>(nNumCols) )
3847  nDiff /= nNumCols;
3848 
3849  if ( bMinDiff )
3850  { // If no empty column exists, we want to grow at least
3851  // by nMinDiff. Special case: If we are smaller than the
3852  // minimal FrameHeight and PrtHeight is smaller than
3853  // nMindiff we grow in a way that PrtHeight is exactly
3854  // nMinDiff afterwards.
3855  long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
3856  if ( nFrameHeight > nMinHeight || nPrtHeight >= nMinDiff )
3857  nDiff = std::max( nDiff, nMinDiff );
3858  else if( nDiff < nMinDiff )
3859  nDiff = nMinDiff - nPrtHeight + 1;
3860  }
3861  // nMaximum has a size which fits the content or the
3862  // requested value from the surrounding therefore we don't
3863  // need to exceed this value.
3864  if( nDiff + nPrtHeight > nMaximum )
3865  nDiff = nMaximum - nPrtHeight;
3866  }
3867  else if( nMaximum > nMinimum ) // We fit, do we still have some margin?
3868  {
3869  long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
3870  if ( nMaximum < nPrtHeight )
3871  nDiff = nMaximum - nPrtHeight; // We grew over a working
3872  // height and shrink back to it, but will this ever
3873  // happen?
3874  else
3875  { // We have a new maximum, a size which fits for the content.
3876  nMaximum = nPrtHeight;
3877  // If the margin in the column is bigger than nMinDiff
3878  // and we therefore drop under the minimum, we deflate
3879  // a bit.
3880  if ( !bNoBalance &&
3881  // #i23129# - <nMinDiff> can be
3882  // big, because of an object at the beginning of
3883  // a column. Thus, decrease optimization here.
3884  //nMaxFree >= nMinDiff &&
3885  nMaxFree > 0 &&
3886  ( !nAllFree ||
3887  nMinimum < nPrtHeight - nMinDiff ) )
3888  {
3889  nMaxFree /= nNumCols; // disperse over the columns
3890  nDiff = nMaxFree < nMinDiff ? -nMinDiff : -nMaxFree; // min nMinDiff
3891  if( nPrtHeight + nDiff <= nMinimum ) // below the minimum?
3892  nDiff = ( nMinimum - nMaximum ) / 2; // Take the center
3893  }
3894  else if( nAllFree )
3895  {
3896  nDiff = -nAllFree;
3897  if( nPrtHeight + nDiff <= nMinimum ) // Less than minimum?
3898  nDiff = ( nMinimum - nMaximum ) / 2; // Take the center
3899  }
3900  }
3901  }
3902  if( nDiff ) // now we shrink or grow...
3903  {
3904  Size aOldSz( getFramePrintArea().SSize() );
3905  long nTop = aRectFnSet.GetTopMargin(*this);
3906  nDiff = aRectFnSet.GetHeight(getFramePrintArea()) + nDiff + nBorder - aRectFnSet.GetHeight(getFrameArea());
3907 
3908  {
3910  aRectFnSet.AddBottom( aFrm, nDiff );
3911  }
3912 
3913  // #i68520#
3914  SwFlyFrame *pFlyFrame = dynamic_cast<SwFlyFrame*>(this);
3915  if (pFlyFrame)
3916  {
3917  pFlyFrame->InvalidateObjRectWithSpaces();
3918  }
3919  aRectFnSet.SetYMargins( *this, nTop, nBorder - nTop );
3920  ChgLowersProp( aOldSz );
3921  NotifyLowerObjs();
3922 
3923  // #i3317# - reset temporarily consideration
3924  // of wrapping style influence
3925  SwPageFrame* pTmpPageFrame = FindPageFrame();
3926  SwSortedObjs* pTmpObjs = pTmpPageFrame ? pTmpPageFrame->GetSortedObjs() : nullptr;
3927  if ( pTmpObjs )
3928  {
3929  for (SwAnchoredObject* pAnchoredObj : *pTmpObjs)
3930  {
3931  if ( IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
3932  {
3933  pAnchoredObj->SetTmpConsiderWrapInfluence( false );
3934  }
3935  }
3936  }
3937  //Invalidate suitable to nicely balance the Frames.
3938  //- Every first one after the second column gets a
3939  // InvalidatePos();
3940  pCol = static_cast<SwLayoutFrame*>(Lower()->GetNext());
3941  while ( pCol )
3942  {
3943  SwFrame *pLow = pCol->Lower();
3944  if ( pLow )
3945  pLow->InvalidatePos_();
3946  pCol = static_cast<SwLayoutFrame*>(pCol->GetNext());
3947  }
3948  if( IsSctFrame() && static_cast<SwSectionFrame*>(this)->HasFollow() )
3949  {
3950  // If we created a Follow, we need to give its content
3951  // the opportunity to flow back inside the CalcContent
3952  SwContentFrame* pTmpContent =
3953  static_cast<SwSectionFrame*>(this)->GetFollow()->ContainsContent();
3954  if( pTmpContent )
3955  pTmpContent->InvalidatePos_();
3956  }
3957  }
3958  else
3959  bEnd = true;
3960  }
3961  else
3962  bEnd = true;
3963 
3964  } while ( !bEnd || !isFrameAreaSizeValid() );
3965  }
3966  // OD 01.04.2003 #108446# - Don't collect endnotes for sections. Thus, set
3967  // 2nd parameter to <true>.
3968  ::CalcContent( this, true );
3969  if( IsSctFrame() )
3970  {
3971  // OD 14.03.2003 #i11760# - adjust 2nd parameter - sal_True --> true
3972  ::CalcContent( this, true );
3973  if( bBackLock )
3974  static_cast<SwSectionFrame*>(this)->SetFootnoteLock( false );
3975  }
3976 }
3977 
3979 {
3980  SwSectionFrame* pSect = pCnt->FindSctFrame();
3981  // If our ContentFrame is placed inside a table or a footnote, only sections
3982  // which are also placed inside are meant.
3983  // Exception: If a table is directly passed.
3984  if( ( ( pCnt->IsInTab() && !pSect->IsInTab() ) ||
3985  ( pCnt->IsInFootnote() && !pSect->IsInFootnote() ) ) && !pCnt->IsTabFrame() )
3986  return nullptr;
3987  if( nInv & SwInvalidateFlags::Size )
3988  pSect->InvalidateSize_();
3989  if( nInv & SwInvalidateFlags::Pos )
3990  pSect->InvalidatePos_();
3991  if( nInv & SwInvalidateFlags::PrtArea )
3992  pSect->InvalidatePrt_();
3993  SwFlowFrame *pFoll = pSect->GetFollow();
3994  // Temporary separation from follow
3995  pSect->SetFollow( nullptr );
3996  SwContentFrame* pRet = pSect->FindLastContent();
3997  pSect->SetFollow( pFoll );
3998  return pRet;
3999 }
4000 
4002 {
4003  if( ( nInv & SwInvalidateFlags::Section ) && pTable->IsInSct() )
4004  lcl_InvalidateSection( pTable, nInv );
4005  if( nInv & SwInvalidateFlags::Size )
4006  pTable->InvalidateSize_();
4007  if( nInv & SwInvalidateFlags::Pos )
4008  pTable->InvalidatePos_();
4009  if( nInv & SwInvalidateFlags::PrtArea )
4010  pTable->InvalidatePrt_();
4011  return pTable->FindLastContent();
4012 }
4013 
4014 static void lcl_InvalidateAllContent( SwContentFrame *pCnt, SwInvalidateFlags nInv );
4015 
4017 {
4018  SwContentFrame *pLastTabCnt = nullptr;
4019  SwContentFrame *pLastSctCnt = nullptr;
4020  while ( pCnt )
4021  {
4022  if( nInv & SwInvalidateFlags::Section )
4023  {
4024  if( pCnt->IsInSct() )
4025  {
4026  // See above at tables
4027  if( !pLastSctCnt )
4028  pLastSctCnt = lcl_InvalidateSection( pCnt, nInv );
4029  if( pLastSctCnt == pCnt )
4030  pLastSctCnt = nullptr;
4031  }
4032 #if OSL_DEBUG_LEVEL > 0
4033  else
4034  OSL_ENSURE( !pLastSctCnt, "Where's the last SctContent?" );
4035 #endif
4036  }
4037  if( nInv & SwInvalidateFlags::Table )
4038  {
4039  if( pCnt->IsInTab() )
4040  {
4041  // To not call FindTabFrame() for each ContentFrame of a table and
4042  // then invalidate the table, we remember the last ContentFrame of
4043  // the table and ignore IsInTab() until we are past it.
4044  // When entering the table, LastSctCnt is set to null, so
4045  // sections inside the table are correctly invalidated.
4046  // If the table itself is in a section the
4047  // invalidation is done three times, which is acceptable.
4048  if( !pLastTabCnt )
4049  {
4050  pLastTabCnt = lcl_InvalidateTable( pCnt->FindTabFrame(), nInv );
4051  pLastSctCnt = nullptr;
4052  }
4053  if( pLastTabCnt == pCnt )
4054  {
4055  pLastTabCnt = nullptr;
4056  pLastSctCnt = nullptr;
4057  }
4058  }
4059 #if OSL_DEBUG_LEVEL > 0
4060  else
4061  OSL_ENSURE( !pLastTabCnt, "Where's the last TabContent?" );
4062 #endif
4063  }
4064 
4065  if( nInv & SwInvalidateFlags::Size )
4066  pCnt->Prepare( PREP_CLEAR, nullptr, false );
4067  if( nInv & SwInvalidateFlags::Pos )
4068  pCnt->InvalidatePos_();
4069  if( nInv & SwInvalidateFlags::PrtArea )
4070  pCnt->InvalidatePrt_();
4071  if ( nInv & SwInvalidateFlags::LineNum )
4072  pCnt->InvalidateLineNum();
4073  if ( pCnt->GetDrawObjs() )
4074  lcl_InvalidateAllContent( pCnt, nInv );
4075  pCnt = pCnt->GetNextContentFrame();
4076  }
4077 }
4078 
4080 {
4081  SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
4082  for (SwAnchoredObject* pAnchoredObj : rObjs)
4083  {
4084  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
4085  {
4086  SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
4087  if ( pFly->IsFlyInContentFrame() )
4088  {
4089  ::lcl_InvalidateContent( pFly->ContainsContent(), nInv );
4090  if( nInv & SwInvalidateFlags::Direction )
4091  pFly->CheckDirChange();
4092  }
4093  }
4094  }
4095 }
4096 
4098 {
4099  // First process all page bound FlyFrames.
4100  SwPageFrame *pPage = static_cast<SwPageFrame*>(Lower());
4101  while( pPage )
4102  {
4103  pPage->InvalidateFlyLayout();
4104  pPage->InvalidateFlyContent();
4105  pPage->InvalidateFlyInCnt();
4106  pPage->InvalidateLayout();
4107  pPage->InvalidateContent();
4108  pPage->InvalidatePage( pPage ); // So even the Turbo disappears if applicable
4109 
4110  if ( pPage->GetSortedObjs() )
4111  {
4112  const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
4113  for (SwAnchoredObject* pAnchoredObj : rObjs)
4114  {
4115  if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
4116  {
4117  SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
4118  ::lcl_InvalidateContent( pFly->ContainsContent(), nInv );
4119  if ( nInv & SwInvalidateFlags::Direction )
4120  pFly->CheckDirChange();
4121  }
4122  }
4123  }
4124  if( nInv & SwInvalidateFlags::Direction )
4125  pPage->CheckDirChange();
4126  pPage = static_cast<SwPageFrame*>(pPage->GetNext());
4127  }
4128 
4129  //Invalidate the whole document content and the character bound Flys here.
4131 
4132  if( nInv & SwInvalidateFlags::PrtArea )
4133  {
4135  if( pSh )
4136  pSh->InvalidateWindows( getFrameArea() );
4137  }
4138 }
4139 
4145 {
4146  const SwPageFrame* pPageFrame = static_cast<const SwPageFrame*>(Lower());
4147  while( pPageFrame )
4148  {
4149  pPageFrame->InvalidateFlyLayout();
4150 
4151  if ( pPageFrame->GetSortedObjs() )
4152  {
4153  const SwSortedObjs& rObjs = *(pPageFrame->GetSortedObjs());
4154  for (SwAnchoredObject* pAnchoredObj : rObjs)
4155  {
4156  const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat().GetAnchor();
4157  if ((rAnch.GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
4158  (rAnch.GetAnchorId() != RndStdIds::FLY_AT_CHAR))
4159  {
4160  // only to paragraph and to character anchored objects are considered.
4161  continue;
4162  }
4163  // #i28701# - special invalidation for anchored
4164  // objects, whose wrapping style influence has to be considered.
4165  if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
4166  pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence();
4167  else
4168  pAnchoredObj->InvalidateObjPos();
4169  }
4170  }
4171 
4172  pPageFrame = static_cast<const SwPageFrame*>(pPageFrame->GetNext());
4173  }
4174 }
4175 
4177  SwTextFrame & rFrame, SwTextNode & rTextNode,
4178  std::set<sal_uLong> *const pSkipped,
4179  SwFrameFormats & rTable,
4180  SwPageFrame *const pPage,
4181  SwTextNode const*const pNode,
4182  std::vector<sw::Extent>::const_iterator & rIterFirst,
4183  std::vector<sw::Extent>::const_iterator const& rIterEnd)
4184 {
4185  if (pNode == &rTextNode)
4186  { // remove existing hidden at-char anchored flys
4187  RemoveHiddenObjsOfNode(rTextNode, &rIterFirst, &rIterEnd);
4188  }
4189  else if (rTextNode.GetIndex() < pNode->GetIndex())
4190  {
4191  // pNode's frame has been deleted by CheckParaRedlineMerge()
4192  AppendObjsOfNode(&rTable,
4193  pNode->GetIndex(), &rFrame, pPage, rTextNode.GetDoc(),
4194  &rIterFirst, &rIterEnd);
4195  if (pSkipped)
4196  {
4197  // if a fly has been added by AppendObjsOfNode, it must be skipped; if not, then it doesn't matter if it's skipped or not because it has no frames and because of that it would be skipped anyway
4198  if (auto const pFlys = pNode->GetAnchoredFlys())
4199  {
4200  for (auto const pFly : *pFlys)
4201  {
4202  if (pFly->Which() != RES_DRAWFRMFMT)
4203  {
4204  pSkipped->insert(pFly->GetContent().GetContentIdx()->GetIndex());
4205  }
4206  }
4207  }
4208  }
4209  }
4210 }
4211 
4212 namespace sw {
4213 
4218  SwTextFrame & rFrame, SwTextNode & rTextNode,
4219  std::set<sal_uLong> *const pSkipped)
4220 {
4221  auto const pMerged(rFrame.GetMergedPara());
4222  if (pMerged
4223  // do this only *once*, for the *last* frame
4224  // otherwise AppendObj would create multiple frames for fly-frames!
4225  && !rFrame.GetFollow())
4226  {
4227  assert(pMerged->pFirstNode->GetIndex() <= rTextNode.GetIndex()
4228  && rTextNode.GetIndex() <= pMerged->pLastNode->GetIndex());
4229  // add visible flys in non-first node to merged frame
4230  // (hidden flys remain and are deleted via DelFrames())
4231  SwFrameFormats& rTable(*rTextNode.GetDoc()->GetSpzFrameFormats());
4232  SwPageFrame *const pPage(rFrame.FindPageFrame());
4233  std::vector<sw::Extent>::const_iterator iterFirst(pMerged->extents.begin());
4234  std::vector<sw::Extent>::const_iterator iter(iterFirst);
4235  SwTextNode const* pNode(pMerged->pFirstNode);
4236  for ( ; ; ++iter)
4237  {
4238  if (iter == pMerged->extents.end()
4239  || iter->pNode != pNode)
4240  {
4241  AddRemoveFlysForNode(rFrame, rTextNode, pSkipped, rTable, pPage,
4242  pNode, iterFirst, iter);
4243  sal_uLong const until = iter == pMerged->extents.end()
4244  ? pMerged->pLastNode->GetIndex() + 1
4245  : iter->pNode->GetIndex();
4246  for (sal_uLong i = pNode->GetIndex() + 1; i < until; ++i)
4247  {
4248  // let's show at-para flys on nodes that contain start/end of
4249  // redline too, even if there's no text there
4250  SwNode const*const pTmp(pNode->GetNodes()[i]);
4251  if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst)
4252  {
4253  AddRemoveFlysForNode(rFrame, rTextNode, pSkipped,
4254  rTable, pPage, pTmp->GetTextNode(), iter, iter);
4255  }
4256  }
4257  if (iter == pMerged->extents.end())
4258  {
4259  break;
4260  }
4261  pNode = iter->pNode;
4262  iterFirst = iter;
4263  }
4264  }
4265  }
4266 }
4267 
4268 } // namespace sw
4269 
4270 static void UnHideRedlines(SwRootFrame & rLayout,
4271  SwNodes & rNodes, SwNode const& rEndOfSectionNode,
4272  std::set<sal_uLong> *const pSkipped)
4273 {
4274  assert(rEndOfSectionNode.IsEndNode());
4275  assert(rNodes[rEndOfSectionNode.StartOfSectionNode()->GetIndex() + 1]->IsCreateFrameWhenHidingRedlines()); // first node is never hidden
4276  for (sal_uLong i = rEndOfSectionNode.StartOfSectionNode()->GetIndex() + 1;
4277  i < rEndOfSectionNode.GetIndex(); ++i)
4278  {
4279  SwNode & rNode(*rNodes[i]);
4280  if (rNode.IsTextNode()) // only text nodes are 1st node of a merge
4281  {
4282  SwTextNode & rTextNode(*rNode.GetTextNode());
4284  std::vector<SwTextFrame*> frames;
4285  for (SwTextFrame * pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
4286  {
4287  if (pFrame->getRootFrame() == &rLayout)
4288  {
4289  if (pFrame->IsFollow())
4290  {
4291  frames.push_back(pFrame);
4292  } // when hiding, the loop must remove the anchored flys
4293  else // *before* resetting SetMergedPara anywhere - else
4294  { // the fly deletion code will access multiple of the
4295  // frames with inconsistent MergedPara and assert
4296  frames.insert(frames.begin(), pFrame);
4297  }
4298  }
4299  }
4300  // this messes with pRegisteredIn so do it outside SwIterator
4301  auto eMode(sw::FrameMode::Existing);
4302  for (SwTextFrame * pFrame : frames)
4303  {
4304  if (rLayout.IsHideRedlines())
4305  {
4306  assert(!pFrame->GetMergedPara() ||
4308  if (rNode.IsCreateFrameWhenHidingRedlines())
4309  {
4310  {
4311  auto pMerged(CheckParaRedlineMerge(*pFrame,
4312  rTextNode, eMode));
4313  pFrame->SetMergedPara(std::move(pMerged));
4314  }
4315  auto const pMerged(pFrame->GetMergedPara());
4316  if (pMerged)
4317  {
4318  // invalidate SwInvalidateFlags::Size
4319  pFrame->Prepare(PREP_CLEAR, nullptr, false);
4320  pFrame->InvalidatePage();
4321  if (auto const pObjs = pFrame->GetDrawObjs())
4322  { // also invalidate position of existing flys
4323  // because they may need to be moved
4324  for (auto const pObject : *pObjs)
4325  {
4326  pObject->InvalidateObjPos();
4327  }
4328  }
4329  }
4330  sw::AddRemoveFlysAnchoredToFrameStartingAtNode(*pFrame, rTextNode, pSkipped);
4331  // only *first* frame of node gets Existing because it
4332  eMode = sw::FrameMode::New; // is not idempotent!
4333  }
4334  }
4335  else
4336  {
4337  if (auto const& pMergedPara = pFrame->GetMergedPara())
4338  {
4339  // invalidate SwInvalidateFlags::Size
4340  pFrame->Prepare(PREP_CLEAR, nullptr, false);
4341  pFrame->InvalidatePage();
4342  if (auto const pObjs = pFrame->GetDrawObjs())
4343  { // also invalidate position of existing flys
4344  for (auto const pObject : *pObjs)
4345  {
4346  pObject->InvalidateObjPos();
4347  }
4348  }
4349  // SwFlyAtContentFrame::Modify() always appends to
4350  // the master frame, so do the same here.
4351  // (RemoveFootnotesForNode must be called at least once)
4352  if (!pFrame->IsFollow())
4353  {
4354  // the new text frames don't exist yet, so at this point
4355  // we can only delete the footnote frames so they don't
4356  // point to the merged SwTextFrame any more...
4357  assert(&rTextNode == pMergedPara->pFirstNode);
4358  // iterate over nodes, not extents: if a node has
4359  // no extents now but did have extents initially,
4360  // its flys need their frames deleted too!
4361  for (sal_uLong j = rTextNode.GetIndex() + 1;
4362  j <= pMergedPara->pLastNode->GetIndex(); ++j)
4363  {
4364  SwNode *const pNode(rTextNode.GetNodes()[j]);
4365  assert(!pNode->IsEndNode());
4366  if (pNode->IsStartNode())
4367  {
4368  j = pNode->EndOfSectionIndex();
4369  }
4370  else if (pNode->IsTextNode())
4371  {
4372  sw::RemoveFootnotesForNode(rLayout, *pNode->GetTextNode(), nullptr);
4373  // similarly, remove the anchored flys
4374  if (auto const pFlys = pNode->GetAnchoredFlys())
4375  {
4376  for (SwFrameFormat * pFormat : *pFlys)
4377  {
4378  pFormat->DelFrames(/*&rLayout*/);
4379  }
4380  }
4381  }
4382  }
4383  // rely on AppendAllObjs call at the end to add
4384  // all flys in first node that are hidden
4385  }
4386  pFrame->SetMergedPara(nullptr);
4387  }
4388  }
4389  pFrame->Broadcast(SfxHint()); // notify SwAccessibleParagraph
4390  }
4391  // all nodes, not just merged ones! it may be in the same list as
4392  if (rTextNode.IsNumbered(nullptr)) // a preceding merged one...
4393  { // notify frames so they reformat numbering portions
4394  rTextNode.NumRuleChgd();
4395  }
4396  }
4397  else if (rNode.IsTableNode() && rLayout.IsHideRedlines())
4398  {
4399  SwPosition const tmp(rNode);
4400  SwRangeRedline const*const pRedline(
4401  rLayout.GetFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedline(tmp, nullptr));
4402  // pathology: redline that starts on a TableNode; cannot
4403  // be created in UI but by import filters...
4404  if (pRedline
4405  && pRedline->GetType() == RedlineType::Delete
4406  && &pRedline->Start()->nNode.GetNode() == &rNode)
4407  {
4408  for (sal_uLong j = rNode.GetIndex(); j <= rNode.EndOfSectionIndex(); ++j)
4409  {
4410  rNode.GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::Hidden);
4411  }
4412  rNode.GetTableNode()->DelFrames(&rLayout);
4413  }
4414  }
4415  if (!rNode.IsCreateFrameWhenHidingRedlines())
4416  {
4417  if (rLayout.IsHideRedlines())
4418  {
4419  if (rNode.IsContentNode())
4420  {
4421  // note: nothing to do here, already done
4422 #ifndef NDEBUG
4423  auto const pFrame(static_cast<SwContentNode&>(rNode).getLayoutFrame(&rLayout));
4424  assert(!pFrame || static_cast<SwTextFrame*>(pFrame)->GetMergedPara()->pFirstNode != &rNode);
4425 #endif
4426  }
4427  }
4428  else
4429  {
4430  assert(!rNode.IsContentNode() || !rNode.GetContentNode()->getLayoutFrame(&rLayout));
4431  sal_uLong j = i + 1;
4432  for ( ; j < rEndOfSectionNode.GetIndex(); ++j)
4433  {
4434  if (rNodes[j]->IsCreateFrameWhenHidingRedlines())
4435  {
4436  break;
4437  }
4438  }
4439  // call MakeFrames once, because sections/tables
4440  // InsertCnt_ also checks for hidden sections
4441  SwNodeIndex const start(rNodes, i);
4442  SwNodeIndex const end(rNodes, j);
4443  assert(!bDontCreateObjects);
4444  bDontCreateObjects = true; // suppress here, to be called once
4445  ::MakeFrames(rLayout.GetFormat()->GetDoc(), start, end);
4446  bDontCreateObjects = false;
4447  i = j - 1; // will be incremented again
4448  }
4449  }
4450  }
4451 }
4452 
4453 static void UnHideRedlinesExtras(SwRootFrame & rLayout,
4454  SwNodes & rNodes, SwNode const& rEndOfExtraSectionNode,
4455  std::set<sal_uLong> *const pSkipped)
4456 {
4457  assert(rEndOfExtraSectionNode.IsEndNode());
4458  for (sal_uLong i = rEndOfExtraSectionNode.StartOfSectionNode()->GetIndex()
4459  + 1; i < rEndOfExtraSectionNode.GetIndex(); ++i)
4460  {
4461  SwNode const& rStartNode(*rNodes[i]);
4462  assert(rStartNode.IsStartNode());
4463  assert(rStartNode.GetRedlineMergeFlag() == SwNode::Merge::None);
4464  SwNode const& rEndNode(*rStartNode.EndOfSectionNode());
4465  bool bSkip(pSkipped && pSkipped->find(i) != pSkipped->end());
4466  i = rEndNode.GetIndex();
4467  for (sal_uLong j = rStartNode.GetIndex() + 1; j < i; ++j)
4468  {
4469  // note: SwStartNode has no way to access the frames, so check
4470  // whether the first content-node inside the section has frames
4471  SwNode const& rNode(*rNodes[j]);
4472  if (rNode.IsSectionNode() &&
4473  static_cast<SwSectionNode const&>(rNode).GetSection().IsHiddenFlag())
4474  { // skip hidden sections - they can be inserted in fly-frames :(
4475  j = rNode.EndOfSectionNode()->GetIndex();
4476  continue;
4477  }
4478  if (rNode.IsContentNode())
4479  {
4480  SwContentNode const& rCNode(static_cast<SwContentNode const&>(rNode));
4481  if (!rCNode.getLayoutFrame(&rLayout))
4482  { // ignore footnote/fly/header/footer with no layout frame
4483  bSkip = true; // they will be created from scratch later if needed
4484  }
4485  break;
4486  }
4487  }
4488  if (!bSkip)
4489  {
4490  UnHideRedlines(rLayout, rNodes, rEndNode, pSkipped);
4491  }
4492  }
4493 }
4494 
4495 void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
4496 {
4497  if (bHideRedlines == mbHideRedlines)
4498  {
4499  return;
4500  }
4501  mbHideRedlines = bHideRedlines;
4502  SwDoc & rDoc(*GetFormat()->GetDoc());
4503  // don't do early return if there are no redlines:
4504  // Show->Hide must init hidden number trees
4505  // Hide->Show may be called after all redlines have been deleted but there
4506  // may still be MergedParas because those aren't deleted yet...
4507 #if 0
4508  if (!bHideRedlines
4510  {
4511  return;
4512  }
4513 #endif
4514  // Hide->Show: clear MergedPara, create frames
4515  // Show->Hide: call CheckParaRedlineMerge, delete frames
4516  // Traverse the document via the nodes-array; traversing via the layout
4517  // wouldn't find the nodes that don't have frames in the ->Show case.
4518  // In-order traversal of each nodes array section should init the flags
4519  // in nodes before they are iterated.
4520  // Actual creation of frames should be done with existing functions
4521  // if possible, particularly InsertCnt_() or its wrapper ::MakeFrames().
4522  SwNodes /*const*/& rNodes(rDoc.GetNodes());
4523  // Flys/footnotes: must iterate and find all the ones that already exist
4524  // with frames and have redlines inside them; if any don't have frames at
4525  // all, they will be created (if necessary) from scratch and completely by
4526  // MakeFrames().
4527  //
4528  // Flys before footnotes: because footnotes may contain flys but not
4529  // vice-versa; alas flys may contain flys, so we skip some of them
4530  // if they have already been created from scratch via their anchor flys.
4531  std::set<sal_uLong> skippedFlys;
4532  UnHideRedlinesExtras(*this, rNodes, rNodes.GetEndOfAutotext(),
4533  // when un-hiding, delay all fly frame creation to AppendAllObjs below
4534  IsHideRedlines() ? &skippedFlys : nullptr);
4535  // Footnotes are created automatically (after invalidation etc.) by
4536  // ConnectFootnote(), but need to be deleted manually. Footnotes do not
4537  // occur in flys or headers/footers.
4538  UnHideRedlinesExtras(*this, rNodes, rNodes.GetEndOfInserts(), nullptr);
4539  UnHideRedlines(*this, rNodes, rNodes.GetEndOfContent(), nullptr);
4540 
4541  if (!IsHideRedlines())
4542  { // create all previously hidden flys at once:
4543  // * Flys on first node of pre-existing merged frames that are hidden
4544  // (in delete redline), to be added to the existing frame
4545  // * Flys on non-first (hidden/merged) nodes of pre-existing merged
4546  // frames, to be added to the new frame of their node
4547  // * Flys anchored in other flys that are hidden
4548  AppendAllObjs(rDoc.GetSpzFrameFormats(), this);
4549  }
4550 
4551  for (auto const pRedline : rDoc.getIDocumentRedlineAccess().GetRedlineTable())
4552  { // DELETE are handled by the code above; for other types, need to
4553  // trigger repaint of text frames to add/remove the redline color font
4554  if (pRedline->GetType() != RedlineType::Delete)
4555  {
4556  pRedline->InvalidateRange(SwRangeRedline::Invalidation::Add);
4557  }
4558  }
4559 
4560  SwFootnoteIdxs & rFootnotes(rDoc.GetFootnoteIdxs());
4561  if (rDoc.GetFootnoteInfo().eNum == FTNNUM_CHAPTER)
4562  {
4563  // sadly determining which node is outline node requires hidden layout
4564  rFootnotes.UpdateAllFootnote();
4565  }
4566  // invalidate all footnotes to reformat their numbers
4567  for (SwTextFootnote *const pFootnote : rFootnotes)
4568  {
4569  SwFormatFootnote const& rFootnote(pFootnote->GetFootnote());
4570  if (rFootnote.GetNumber() != rFootnote.GetNumberRLHidden()
4571  && rFootnote.GetNumStr().isEmpty())
4572  {
4573  pFootnote->InvalidateNumberInLayout();
4574  }
4575  }
4576  // update various fields to re-expand them with the new layout
4578  auto const pAuthType(rIDFA.GetFieldType(
4579  SwFieldIds::TableOfAuthorities, OUString(), false));
4580  if (pAuthType) // created on demand...
4581  { // calling DelSequenceArray() should be unnecessary here since the
4582  // sequence doesn't depend on frames
4583  pAuthType->UpdateFields();
4584  }
4585  rIDFA.GetFieldType(SwFieldIds::RefPageGet, OUString(), false)->UpdateFields();
4586  rIDFA.GetSysFieldType(SwFieldIds::Chapter)->UpdateFields();
4587  rIDFA.UpdateExpFields(nullptr, false);
4588  rIDFA.UpdateRefFields();
4589 
4590  // update SwPostItMgr / notes in the margin
4591  // note: as long as all shells share layout, broadcast to all shells!
4592  rDoc.GetDocShell()->Broadcast( SwFormatFieldHint(nullptr, bHideRedlines
4595 
4596 
4597 // InvalidateAllContent(SwInvalidateFlags::Size); // ??? TODO what to invalidate? this is the big hammer
4598 }
4599 
4600 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InsertBefore(SwLayoutFrame *pParent, SwFrame *pBehind)
Insert SwFrame into existing structure.
Definition: wsfrm.cxx:820
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:206
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:341
long Width() const
#define FRM_NEIGHBOUR
Definition: frame.hxx:104
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:547
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
void transform(const basegfx::B2DHomMatrix &aTransform)
Definition: wsfrm.cxx:283
virtual void CheckDirection(bool bVert) override
Definition: wsfrm.cxx:405
Base class of the Writer layout elements.
Definition: frame.hxx:295
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:58
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
long BottomDist(const SwRect &rRect, long nPos) const
Definition: frame.hxx:1375
SwFrameGet fnGetPrtBottom
Definition: frame.hxx:1285
sal_uLong GetIndex() const
Definition: node.hxx:282
#define RES_FRM_SIZE
Definition: hintids.hxx:194
#define RES_COL
Definition: hintids.hxx:214
bool IsFlyLayFrame() const
Definition: flyfrm.hxx:195
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
bool IsFollow() const
Definition: flowfrm.hxx:166
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2814
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:543
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
Marks a position in the document model.
Definition: pam.hxx:35
void RegisterToFormat(SwFormat &rFormat)
Definition: wsfrm.cxx:334
SwFrame * mpNext
Definition: frame.hxx:319
SwFrame * mpPrev
Definition: frame.hxx:320
bool IsSectionNode() const
Definition: node.hxx:644
bool IsEndnAtEnd() const
Definition: sectfrm.hxx:148
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:97
bool IsInDocBody() const
Definition: frame.hxx:919
bool IsRootFrame() const
Definition: frame.hxx:1150
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1462
bool mbValidLineNum
Definition: frame.hxx:408
bool IsInSct() const
Definition: frame.hxx:943
bool IsOrtho() const
Definition: fmtclds.hxx:121
double getHeight() const
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"Formats" the Frame; Frame and PrtArea.
Definition: wsfrm.cxx:3355
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:76
SwRect getUntransformedFramePrintArea() const
Definition: wsfrm.cxx:185
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:384
#define RES_ATTRSET_CHG
Definition: hintids.hxx:285
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
Definition: ndtbl.cxx:2415
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
void DelEmpty(bool bRemove)
Definition: sectfrm.cxx:185
bool mbInvalidVert
Definition: frame.hxx:401
B2DTuple absolute(const B2DTuple &rTup)
static void CheckPageDescs(SwPageFrame *pStart, bool bNotifyFields=true, SwPageFrame **ppPrev=nullptr)
Check all pages (starting from the given one) if they use the right frame format. ...
Definition: pagechg.cxx:1004
SwDocShell * GetDocShell()
Definition: doc.hxx:1340
std::string GetValue
bool IsColLocked() const
Definition: frame.hxx:862
void InvalidateAllContent(SwInvalidateFlags nInvalidate)
Invalidate all Content, Size or PrtArea.
Definition: wsfrm.cxx:4097
bool mbFrameAreaPositionValid
Definition: frame.hxx:142
long Height() const
virtual void UpdatePageFields(SfxPoolItem *)=0
bool bDontCreateObjects
Definition: frmtool.cxx:80
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
const SwTable * GetTable() const
Definition: tabfrm.hxx:142
GPOS_NONE
void SetCompletePaint() const
Definition: frame.hxx:970
void ImplInvalidateSize()
Definition: wsfrm.cxx:1912
bool IsInFootnote() const
Definition: frame.hxx:925
long GetWidth() const
void FormatWidthCols(const SwBorderAttrs &, const SwTwips nBorder, const SwTwips nMinHeight)
Called by Format for Frames and Areas with columns.
Definition: wsfrm.cxx:3620
SwFrameType GetType() const
Definition: frame.hxx:498
#define RES_SHADOW
Definition: hintids.hxx:212
virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const
Definition: wsfrm.cxx:131
void SetNeedGrammarCheck(bool bVal)
Definition: rootfrm.hxx:260
void setSwRect(const SwRect &rNew)
Definition: frame.hxx:194
sal_uIntPtr sal_uLong
#define RES_FRAMEDIR
Definition: hintids.hxx:225
const SwRect & getFramePrintArea() const
Definition: frame.hxx:176
void InvalidateLineNum_()
Definition: frame.hxx:773
virtual void CheckDirection(bool bVert) override
Definition: wsfrm.cxx:447
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:438
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: wsfrm.cxx:473
double getX() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1150
void InvalidateSize_()
Definition: frame.hxx:749
Definition: doc.hxx:185
bool HasFollow() const
Definition: flowfrm.hxx:165
bool KnowsFormat(const SwFormat &rFormat) const
Definition: wsfrm.cxx:329
void Height(long nNew)
Definition: swrect.hxx:189
virtual bool InvalidationAllowed(const InvalidationType _nInvalid) const
method to determine, if an invalidation is allowed.
Definition: wsfrm.cxx:1906
void InvalidatePos()
Definition: frame.hxx:1019
SwRectGet fnGetHeight
Definition: frame.hxx:1257
void Invalidate_(SwPageFrame const *pPage=nullptr)
Definition: fly.cxx:1039
void RemoveHiddenObjsOfNode(SwTextNode const &rNode, std::vector< sw::Extent >::const_iterator const *pIter, std::vector< sw::Extent >::const_iterator const *pEnd)
Definition: frmtool.cxx:1086
#define FRM_BODYFTNC
Definition: frame.hxx:107
#define RES_CHRATR_FONT
Definition: hintids.hxx:75
double getY() const
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1296
bool IsAtEnd() const
long SwTwips
Definition: swtypes.hxx:49
void SetTurbo(const SwContentFrame *pContent)
Definition: rootfrm.hxx:345
SvxFrameDirection
bool IsVert() const
Definition: frame.hxx:1328
SwRectGet fnGetWidth
Definition: frame.hxx:1256
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:382
void Pos(const Point &rNew)
Definition: swrect.hxx:167
SwFrameAreaDefinition & mrTarget
Definition: frame.hxx:186
bool IsEndNote() const
Definition: fmtftn.hxx:73
const SwCellFrame & FindStartEndOfRowSpanCell(bool bStart) const
Definition: findfrm.cxx:1670
Dialog to specify the properties of drop-down form field.
Definition: accfrmobj.cxx:40
SwFrame * FindNext()
Definition: frame.hxx:1117
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1787
bool IsCellFrame() const
Definition: frame.hxx:1202
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwLayoutFrame(SwFrameFormat *, SwFrame *)
Definition: wsfrm.cxx:2525
void ImplInvalidatePrt()
Definition: wsfrm.cxx:1928
long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2042
virtual const SwFormatPageDesc & GetPageDescItem() const
Definition: findfrm.cxx:659
SwFrame(SwModify *, SwFrame *)
Definition: wsfrm.cxx:289
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2579
Frame cannot be moved in Var-direction.
Definition: fmtfsize.hxx:38
static long lcl_CalcMinColDiff(SwLayoutFrame *pLayFrame)
Definition: wsfrm.cxx:3561
bool mbVertLR
Definition: frame.hxx:405
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const
Definition: wsfrm.cxx:121
void SetResizeHTMLTable()
Definition: tabfrm.hxx:153
css::chart::ChartAxisLabelPosition ePos
void InvalidateFlyInCnt() const
Definition: pagefrm.hxx:354
bool IsFootnoteFrame() const
Definition: frame.hxx:1178
None
sal_Int32 GetBrowseWidth() const
Definition: viewsh.cxx:2001
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:738
void AppendObjsOfNode(SwFrameFormats const *pTable, sal_uLong nIndex, SwFrame *pFrame, SwPageFrame *pPage, SwDoc *pDoc, std::vector< sw::Extent >::const_iterator const *pIter, std::vector< sw::Extent >::const_iterator const *pEnd)
Definition: frmtool.cxx:1111
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:167
static bool bFootnote
Definition: insfnote.cxx:40
static SwContentFrame * lcl_InvalidateTable(SwTabFrame *pTable, SwInvalidateFlags nInv)
Definition: wsfrm.cxx:4001
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:190
bool IsVertLRBT() const
Definition: frame.hxx:959
bool IsTurboAllowed() const
Definition: rootfrm.hxx:344
bool mbVertLRBT
Definition: frame.hxx:406
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:389
void SetRetouche() const
Definition: frame.hxx:979
long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2090
#define RES_PARATR_CONNECT_BORDER
Definition: hintids.hxx:176
GPOS_TILED
void InvalidateObjs(const bool _bNoInvaOfAsCharAnchoredObjs=true)
Definition: fly.cxx:2297
bool IsFlyFrame() const
Definition: frame.hxx:1186
void InvalidateNextPrtArea()
method to invalidate printing area of next frame #i11859#
Definition: findfrm.cxx:1279
void ChgLowersProp(const Size &rOldSize)
Change size of lowers proportionally.
Definition: wsfrm.cxx:2956
wrapper class for the positioning of Writer fly frames and drawing objects
void SetFirstVisPageInvalid()
Definition: viewimp.hxx:148
SwTwips Shrink_(SwTwips, bool bTst)
Definition: fly.cxx:1962
long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1371
SwTableNode * GetTableNode()
Definition: node.hxx:599
Value in Var-direction gives minimum (can be exceeded but not be less).
Definition: fmtfsize.hxx:39
double getWidth() const
void Top(const long nTop)
Definition: swrect.hxx:202
#define XATTR_FILL_LAST
const SwTableBox * GetTabBox() const
Definition: cellfrm.hxx:52
void restoreFrameAreas()
Definition: wsfrm.cxx:265
bool empty() const
Definition: docary.hxx:367
const SwRect & getFrameArea() const
Definition: frame.hxx:175
SwFootnoteContFrame * FindFootnoteCont()
Definition: ftnfrm.cxx:964
bool getBrowseMode() const
Definition: viewopt.hxx:426
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:721
#define XATTR_FILL_FIRST
EdgeEntry * mpNext
bool IsInTab() const
Definition: frame.hxx:931
std::unique_ptr< sw::MergedPara > CheckParaRedlineMerge(SwTextFrame &rFrame, SwTextNode &rTextNode, FrameMode eMode)
Definition: redlnitr.cxx:54
#define RES_PARATR_TABSTOP
Definition: hintids.hxx:166
const SwRowFrame * IsInSplitTableRow() const
Definition: findfrm.cxx:1741
bool IsTextFrame() const
Definition: frame.hxx:1210
void InvalidateFlyContent() const
Definition: pagefrm.hxx:350
SwRectFn fnRectVertL2R
Definition: newfrm.cxx:290
void SetSuperfluous()
Remove superfluous Pages.
Definition: rootfrm.hxx:296
bool IsStartNode() const
Definition: node.hxx:624
SwInvalidateFlags
Definition: rootfrm.hxx:50
std::vector< SwFrameFormat * > const * GetAnchoredFlys() const
Definition: node.hxx:288
void setFramePrintAreaValid(bool bNew)
Definition: wsfrm.cxx:96
#define RES_UL_SPACE
Definition: hintids.hxx:197
void AddRemoveFlysAnchoredToFrameStartingAtNode(SwTextFrame &rFrame, SwTextNode &rTextNode, std::set< sal_uLong > *pSkipped)
rTextNode is the first one of the "new" merge - if rTextNode isn't the same as MergedPara::pFirstNode...
Definition: wsfrm.cxx:4217
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
bool IsPageBodyFrame() const
Definition: layfrm.hxx:213
virtual void CheckDirection(bool bVert) override
Definition: wsfrm.cxx:465
#define RES_PARATR_NUMRULE
Definition: hintids.hxx:170
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:952
bool IsSctFrame() const
Definition: frame.hxx:1190
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1087
void Right(const long nRight)
Definition: swrect.hxx:198
void CheckWaitCursor()
If an Action is running we ask it to check whether it's time to enable the WaitCursor.
Definition: viewimp.cxx:145
SwFrameSet fnSetXMargins
Definition: frame.hxx:1282
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:193
bool IsFlowFrame() const
Definition: frame.hxx:1218
void SetIdleFlags()
Definition: rootfrm.hxx:246
SwRectFn fnRectHori
Definition: newfrm.cxx:288
B2IRange fround(const B2DRange &rRange)
void InvalidateLayout() const
Definition: pagefrm.hxx:358
virtual ~SwFrameAreaDefinition()
Definition: wsfrm.cxx:76
void MakeFrames(SwDoc *pDoc, const SwNodeIndex &rSttIdx, const SwNodeIndex &rEndIdx)
Definition: frmtool.cxx:1767
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:842
Specific frame formats (frames, DrawObjects).
Definition: docary.hxx:201
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
static sal_uInt8 nFramePos
Definition: basesh.cxx:124
void InvalidateContent() const
Definition: pagefrm.hxx:362
const SwFrame & GetFrame() const
Definition: flowfrm.hxx:151
Base class for various Writer styles.
Definition: format.hxx:43
#define RES_ROW_SPLIT
Definition: hintids.hxx:227
void SetHideRedlines(bool)
Definition: wsfrm.cxx:4495
#define RES_BACKGROUND
Definition: hintids.hxx:210
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false) override
Definition: wsfrm.cxx:2060
bool IsColumnFrame() const
Definition: frame.hxx:1158
SwRectFn fnRectVertL2RB2T
Definition: newfrm.cxx:291
void SetHeight(SwRect &rRect, long nNew) const
Definition: frame.hxx:1352
void ResetTurbo()
Definition: rootfrm.hxx:346
SwContentFrame * FindLastContent()
Definition: tabfrm.cxx:3329
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1083
bool IsContentNode() const
Definition: node.hxx:628
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:445
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1288
void InvalidateAutoCompleteWords() const
Definition: pagefrm.hxx:375
void CalcContent(SwLayoutFrame *pLay, bool bNoColl=false)
Definition: fly.cxx:1366
virtual SwTwips GrowFrame(SwTwips, bool bTst=false, bool bInfo=false)=0
SwTwips Grow_(SwTwips, bool bTst)
Definition: fly.cxx:1882
void SetDirFlags(bool bVert)
Updates the vertical or the righttoleft-flags.
Definition: findfrm.cxx:1464
Style of a layout element.
Definition: frmfmt.hxx:57
#define RES_CHRATR_OVERLINE
Definition: hintids.hxx:106
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:165
PrepareHint
Definition: swtypes.hxx:204
bool IsContentFrame() const
Definition: frame.hxx:1206
SwTabFrame * FindMaster(bool bFirstMaster=false) const
Definition: flowfrm.cxx:713
void InvalidateLineNum()
Definition: frame.hxx:1026
SwFrame * GetIndPrev() const
Definition: frame.hxx:702
void InvalidatePrt()
Definition: frame.hxx:1012
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:117
void InvalidateSpelling() const
Definition: pagefrm.hxx:366
void SetRemoveFollowFlowLinePending(bool bNew)
Definition: tabfrm.hxx:168
void MoveAccessibleFrame(const SwFrame *pFrame, const SwRect &rOldFrame)
Definition: viewimp.hxx:290
const SwRect & VisArea() const
Definition: viewsh.cxx:570
#define FRM_HEADFOOT
Definition: frame.hxx:106
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
SwTwips InnerHeight() const
InnerHeight returns the height of the content and may be bigger or less than the PrtArea-Height of th...
Definition: wsfrm.cxx:2536
SwFrameType
Definition: frame.hxx:72
SwFrame * GetIndNext()
Definition: frame.hxx:705
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
static void lcl_InvalidateAllContent(SwContentFrame *pCnt, SwInvalidateFlags nInv)
Definition: wsfrm.cxx:4079
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:160
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
size_t size() const
Definition: sortedobjs.cxx:42
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
static bool lcl_IsFlyHeightClipped(SwLayoutFrame *pLay)
Definition: wsfrm.cxx:3592
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:863
SwFrame * m_pLower
Definition: layfrm.hxx:52
Document fields related interfaces.
virtual void Cut() override
Definition: wsfrm.cxx:1393
static void InvaPercentFlys(SwFrame *pFrame, SwTwips nDiff)
Definition: wsfrm.cxx:3471
bool IsCompletePaint() const
Definition: frame.hxx:579
const SwFrame * Lower() const
Definition: layfrm.hxx:100
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:190
int i
SwTwips AdjustNeighbourhood(SwTwips nDiff, bool bTst=false)
Adjust surrounding neighbourhood after insertion.
Definition: wsfrm.cxx:1568
SwContentNode * GetContentNode()
Definition: node.hxx:615
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:597
FlyAnchors.
Definition: fmtanchr.hxx:34
static void AddRemoveFlysForNode(SwTextFrame &rFrame, SwTextNode &rTextNode, std::set< sal_uLong > *const pSkipped, SwFrameFormats &rTable, SwPageFrame *const pPage, SwTextNode const *const pNode, std::vector< sw::Extent >::const_iterator &rIterFirst, std::vector< sw::Extent >::const_iterator const &rIterEnd)
Definition: wsfrm.cxx:4176
bool IsJoinLocked() const
Definition: flowfrm.hxx:175
const SfxPoolItem * NextItem()
virtual SwTwips ShrinkFrame(SwTwips, bool bTst=false, bool bInfo=false)=0
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:88
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
SwDoc * GetDoc()
Definition: node.hxx:702
bool mbInvalidR2L
Definition: frame.hxx:398
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
bool mbVertical
Definition: frame.hxx:403
void InvalidateSmartTags() const
Definition: pagefrm.hxx:371
SvxGraphicPosition
bool isFramePrintAreaValid() const
Definition: frame.hxx:164
std::shared_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:784
long CalcRel(const SwFormatFrameSize &rSz) const
Definition: wsfrm.cxx:3535
long GetTopMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1364
bool IsRowFrame() const
Definition: frame.hxx:1198
long const nBorder
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
Definition: findfrm.cxx:435
Provides access to settings of a document.
#define RES_CHRATR_UNDERLINE
Definition: hintids.hxx:82
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
bool IsRetoucheFrame() const
Definition: frame.hxx:1222
SwFrame * GetPrev()
Definition: frame.hxx:655
SwLayoutFrame * mpUpper
Definition: frame.hxx:318
const SwRowFrame * IsInFollowFlowRow() const
Definition: findfrm.cxx:1774
const SwAttrSet & GetAttrSet() const
Definition: frmtool.hxx:360
void RemoveFootnotesForNode(SwRootFrame const &rLayout, SwTextNode const &rTextNode, std::vector< std::pair< sal_Int32, sal_Int32 >> const *const pExtents)
Definition: txtfrm.cxx:800
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:398
#define RES_CHRATR_ESCAPEMENT
Definition: hintids.hxx:74
bool mbDerivedR2L
Definition: frame.hxx:399
Marks a node in the document model.
Definition: ndindex.hxx:31
bool IsEndNode() const
Definition: node.hxx:632
bool isIdentity() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
SwFrameSet fnSetYMargins
Definition: frame.hxx:1283
void SetYMargins(SwFrame &rFrame, long nTop, long nBottom) const
Definition: frame.hxx:1369
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:759
void SSize(const Size &rNew)
Definition: swrect.hxx:176
bool HasFixSize() const
Definition: frame.hxx:648
bool isFrameAreaSizeValid() const
Definition: frame.hxx:163
bool InsertGroupBefore(SwFrame *pParent, SwFrame *pWhere, SwFrame *pSct)
Insert a chain of SwFrames into an existing structure.
Definition: wsfrm.cxx:893
void InvalidateFlyLayout() const
Validate, invalidate and query the Page status Layout/Content and Fly/non-Fly respectively are inspec...
Definition: pagefrm.hxx:346
void AddBottom(SwRect &rRect, long nNew) const
Definition: frame.hxx:1355
SwContentFrame * FindLastContent(SwFindMode nMode=SwFindMode::None)
Definition: sectfrm.cxx:905
void InvalidatePos_()
Definition: frame.hxx:765
#define RES_FMT_CHG
Definition: hintids.hxx:284
A page of the document layout.
Definition: pagefrm.hxx:40
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:194
long X() const
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:551
enumrange< T >::Iterator end(enumrange< T >)
const long LONG_MAX
#define RES_CHRATR_CONTOUR
Definition: hintids.hxx:72
sal_uInt16 CalcTop() const
Definition: frmtool.hxx:499
void InvalidateAllObjPos()
Invalidate/re-calculate the position of all floating screen objects (Writer fly frames and drawing ob...
Definition: wsfrm.cxx:4144
bool IsReadOnly() const
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1507
void InvalidateSize()
Definition: frame.hxx:1005
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1091
#define RES_CHRATR_KERNING
Definition: hintids.hxx:77
#define RES_LR_SPACE
Definition: hintids.hxx:196
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:42
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
virtual void CheckDirection(bool bVert) override
Definition: wsfrm.cxx:419
virtual void CheckDirection(bool bVert)
Definition: wsfrm.cxx:388
SwRectGet fnGetLeft
Definition: frame.hxx:1254
void setFrameAreaPositionValid(bool bNew)
Definition: wsfrm.cxx:80
sal_uInt16 Count() const
Definition: hints.hxx:245
bool IsLayoutFrame() const
Definition: frame.hxx:1146
void Left(const long nLeft)
Definition: swrect.hxx:193
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void Bottom(const long nBottom)
Definition: swrect.hxx:207
SwNeighbourAdjust
Definition: ftnboss.hxx:42
bool mbDerivedVert
Definition: frame.hxx:402
const SwContentFrame * GetTurbo()
Definition: rootfrm.hxx:347
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:367
double getMinY() const
bool IsVertLR() const
Definition: frame.hxx:955
SwTwips GetVarSpace() const
Definition: ftnfrm.cxx:24