LibreOffice Module sw (master)  1
sectfrm.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 #include <sal/log.hxx>
22 
23 #include <o3tl/safeint.hxx>
24 #include <svl/itemiter.hxx>
25 #include <txtftn.hxx>
26 #include <fmtftn.hxx>
27 #include <fmtclbl.hxx>
28 #include <sectfrm.hxx>
29 #include <cellfrm.hxx>
30 #include <section.hxx>
32 #include <rootfrm.hxx>
33 #include <pagefrm.hxx>
34 #include <txtfrm.hxx>
35 #include <fmtclds.hxx>
36 #include <colfrm.hxx>
37 #include <tabfrm.hxx>
38 #include <ftnfrm.hxx>
39 #include <layouter.hxx>
40 #include <dbg_lay.hxx>
41 #include <viewopt.hxx>
42 #include <viewimp.hxx>
43 #include <editeng/brushitem.hxx>
44 #include <fmtftntx.hxx>
45 #include <flyfrm.hxx>
46 #include <sortedobjs.hxx>
47 #include <hints.hxx>
48 #include <frmatr.hxx>
49 #include <frmtool.hxx>
50 
51 namespace
52 {
57 void InvalidateFramePos(SwFrame* pFrame, bool bInCalcContent)
58 {
59  if (bInCalcContent)
60  pFrame->InvalidatePos_();
61  else
62  pFrame->InvalidatePos();
63 }
64 }
65 
67  : SwLayoutFrame( rSect.GetFormat(), pSib )
68  , SwFlowFrame( static_cast<SwFrame&>(*this) )
69  , m_pSection( &rSect )
70  , m_bFootnoteAtEnd(false)
71  , m_bEndnAtEnd(false)
72  , m_bContentLock(false)
73  , m_bOwnFootnoteNum(false)
74  , m_bFootnoteLock(false)
75 {
77 
80 }
81 
83  SwLayoutFrame( rSect.GetFormat(), rSect.getRootFrame() ),
84  SwFlowFrame( static_cast<SwFrame&>(*this) ),
85  m_pSection( rSect.GetSection() ),
86  m_bFootnoteAtEnd( rSect.IsFootnoteAtEnd() ),
87  m_bEndnAtEnd( rSect.IsEndnAtEnd() ),
88  m_bContentLock( false ),
89  m_bOwnFootnoteNum( false ),
90  m_bFootnoteLock( false )
91 {
93 
95 
96  if( bMaster )
97  {
98  SwSectionFrame* pMaster = rSect.IsFollow() ? rSect.FindMaster() : nullptr;
99  if (pMaster)
100  pMaster->SetFollow( this );
101  SetFollow( &rSect );
102  }
103  else
104  {
105  SetFollow( rSect.GetFollow() );
106  rSect.SetFollow( this );
107  if( !GetFollow() )
108  rSect.SimpleFormat();
109  if( !rSect.IsColLocked() )
110  rSect.InvalidateSize();
111  }
112 }
113 
114 // NOTE: call <SwSectionFrame::Init()> directly after creation of a new section
115 // frame and its insert in the layout.
117 {
118  assert(GetUpper() && "SwSectionFrame::Init before insertion?!");
119  SwRectFnSet aRectFnSet(this);
120  long nWidth = aRectFnSet.GetWidth(GetUpper()->getFramePrintArea());
121 
122  {
124  aRectFnSet.SetWidth( aFrm, nWidth );
125  aRectFnSet.SetHeight( aFrm, 0 );
126  }
127 
128  // #109700# LRSpace for sections
129  const SvxLRSpaceItem& rLRSpace = GetFormat()->GetLRSpace();
130 
131  {
133  aRectFnSet.SetLeft( aPrt, rLRSpace.GetLeft() );
134  aRectFnSet.SetWidth( aPrt, nWidth - rLRSpace.GetLeft() - rLRSpace.GetRight() );
135  aRectFnSet.SetHeight( aPrt, 0 );
136  }
137 
138  const SwFormatCol &rCol = GetFormat()->GetCol();
139  if( ( rCol.GetNumCols() > 1 || IsAnyNoteAtEnd() ) && !IsInFootnote() )
140  {
141  const SwFormatCol *pOld = Lower() ? &rCol : new SwFormatCol;
142  ChgColumns( *pOld, rCol, IsAnyNoteAtEnd() );
143  if( pOld != &rCol )
144  delete pOld;
145  }
146 }
147 
149 {
150  if( GetFormat() && !GetFormat()->GetDoc()->IsInDtor() )
151  {
152  SwRootFrame *pRootFrame = getRootFrame();
153  if( pRootFrame )
154  pRootFrame->RemoveFromList( this );
155  if( IsFollow() )
156  {
157  SwSectionFrame *pMaster = FindMaster();
158  if( pMaster )
159  {
160  PROTOCOL( this, PROT::Section, DbgAction::DelFollow, pMaster )
161  pMaster->SetFollow( GetFollow() );
162  // A Master always grabs the space until the lower edge of his
163  // Upper. If he doesn't have a Follow anymore, he can
164  // release it, which is why the Size of the Master is
165  // invalidated.
166  if( !GetFollow() )
167  pMaster->InvalidateSize();
168  }
169  }
170 #if defined DBG_UTIL
171  else if( HasFollow() )
172  {
174  }
175 #endif
176  }
177 
179 }
180 
182 {
183 }
184 
185 void SwSectionFrame::DelEmpty( bool bRemove )
186 {
187  if( IsColLocked() )
188  {
189  OSL_ENSURE( !bRemove, "Don't delete locked SectionFrames" );
190  return;
191  }
192  SwFrame* pUp = GetUpper();
193  if( pUp )
194  {
195  // #i27138#
196  // notify accessibility paragraphs objects about changed
197  // CONTENT_FLOWS_FROM/_TO relation.
198  // Relation CONTENT_FLOWS_FROM for current next paragraph will change
199  // and relation CONTENT_FLOWS_TO for current previous paragraph will change.
200  {
201  SwViewShell* pViewShell( getRootFrame()->GetCurrShell() );
202  if ( pViewShell && pViewShell->GetLayout() &&
203  pViewShell->GetLayout()->IsAnyShellAccessible() )
204  {
206  dynamic_cast<SwTextFrame*>(FindNextCnt( true )),
207  dynamic_cast<SwTextFrame*>(FindPrevCnt()) );
208  }
209  }
210  Cut_( bRemove );
211  }
212  SwSectionFrame *pMaster = IsFollow() ? FindMaster() : nullptr;
213  if (pMaster)
214  {
215  pMaster->SetFollow( GetFollow() );
216  // A Master always grabs the space until the lower edge of his
217  // Upper. If he doesn't have a Follow anymore, he can
218  // release it, which is why the Size of the Master is
219  // invalidated.
220  if( !GetFollow() && !pMaster->IsColLocked() )
221  pMaster->InvalidateSize();
222  }
223  SetFollow(nullptr);
224  if( pUp )
225  {
226  {
228  aFrm.Height( 0 );
229  }
230 
231  // If we are destroyed immediately anyway, we don't need
232  // to put us into the list
233  if( bRemove )
234  { // If we already were half dead before this DelEmpty,
235  // we are likely in the list and have to remove us from
236  // it
237  if( !m_pSection && getRootFrame() )
238  getRootFrame()->RemoveFromList( this );
239  }
240  else if( getRootFrame() )
241  {
242  getRootFrame()->InsertEmptySct( this );
243  }
244 
245  m_pSection = nullptr; // like this a reanimation is virtually impossible though
246  }
247 }
248 
250 {
251  Cut_( true );
252 }
253 
254 void SwSectionFrame::Cut_( bool bRemove )
255 {
256  OSL_ENSURE( GetUpper(), "Cut without Upper()." );
257 
259 
260  SwPageFrame *pPage = FindPageFrame();
261  InvalidatePage( pPage );
262  SwFrame *pFrame = GetNext();
263  SwFrame* pPrepFrame = nullptr;
264  while( pFrame && pFrame->IsSctFrame() && !static_cast<SwSectionFrame*>(pFrame)->GetSection() )
265  pFrame = pFrame->GetNext();
266  if( pFrame )
267  { // The former successor might have calculated a gap to the predecessor
268  // which is now obsolete since he becomes the first
269  pFrame->InvalidatePrt_();
270  pFrame->InvalidatePos_();
271  if( pFrame->IsSctFrame() )
272  pFrame = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
273  if ( pFrame && pFrame->IsContentFrame() )
274  {
275  pFrame->InvalidatePage( pPage );
276  if( IsInFootnote() && !GetIndPrev() )
277  pPrepFrame = pFrame;
278  }
279  }
280  else
281  {
283  // Someone has to take over the retouching: predecessor or Upper
284  if ( nullptr != (pFrame = GetPrev()) )
285  { pFrame->SetRetouche();
287  if ( pFrame->IsContentFrame() )
288  pFrame->InvalidatePage( pPage );
289  }
290  // If I am (was) the only FlowFrame in my Upper, then he has to take over
291  // the retouching.
292  // Furthermore a blank page could have emerged
293  else
294  { SwRootFrame *pRoot = static_cast<SwRootFrame*>(pPage->GetUpper());
295  pRoot->SetSuperfluous();
297  }
298  }
299  // First remove, then shrink Upper
300  SwLayoutFrame *pUp = GetUpper();
301  if( bRemove )
302  {
304  if( pUp && !pUp->Lower() && pUp->IsFootnoteFrame() && !pUp->IsColLocked() &&
305  pUp->GetUpper() )
306  {
307  pUp->Cut();
309  pUp = nullptr;
310  }
311  }
312  if( pPrepFrame )
314  if ( pUp )
315  {
316  SwRectFnSet aRectFnSet(this);
317  SwTwips nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
318  if( nFrameHeight > 0 )
319  {
320  if( !bRemove )
321  {
323  aRectFnSet.SetHeight( aFrm, 0 );
324 
326  aRectFnSet.SetHeight( aPrt, 0 );
327  }
328 
329  pUp->Shrink( nFrameHeight );
330  }
331  }
332 }
333 
334 void SwSectionFrame::Paste( SwFrame* pParent, SwFrame* pSibling )
335 {
336  OSL_ENSURE( pParent, "No parent for Paste()." );
337  OSL_ENSURE( pParent->IsLayoutFrame(), "Parent is ContentFrame." );
338  OSL_ENSURE( pParent != this, "I'm my own parent." );
339  OSL_ENSURE( pSibling != this, "I'm my own neighbour." );
340  OSL_ENSURE( !GetPrev() && !GetUpper(),
341  "I am still registered somewhere." );
342 
344 
345  // Add to the tree
346  SwSectionFrame* pSect = pParent->FindSctFrame();
347  // Assure that parent is not inside a table frame, which is inside the found section frame.
348  if ( pSect )
349  {
350  SwTabFrame* pTableFrame = pParent->FindTabFrame();
351  if ( pTableFrame &&
352  pSect->IsAnLower( pTableFrame ) )
353  {
354  pSect = nullptr;
355  }
356  }
357 
358  SwRectFnSet aRectFnSet(pParent);
359  if( pSect && HasToBreak( pSect ) )
360  {
361  if( pParent->IsColBodyFrame() ) // dealing with a single-column area
362  {
363  // If we are coincidentally at the end of a column, pSibling
364  // has to point to the first frame of the next column in order
365  // for the content of the next column to be moved correctly to the
366  // newly created pSect by the InsertGroup
367  SwColumnFrame *pCol = static_cast<SwColumnFrame*>(pParent->GetUpper());
368  while( !pSibling && nullptr != ( pCol = static_cast<SwColumnFrame*>(pCol->GetNext()) ) )
369  pSibling = static_cast<SwLayoutFrame*>(pCol->Lower())->Lower();
370  if( pSibling )
371  {
372  // Even worse: every following column content has to
373  // be attached to the pSibling-chain in order to be
374  // taken along
375  SwFrame *pTmp = pSibling;
376  while ( nullptr != ( pCol = static_cast<SwColumnFrame*>(pCol->GetNext()) ) )
377  {
378  while ( pTmp->GetNext() )
379  pTmp = pTmp->GetNext();
380  SwFrame* pSave = ::SaveContent( pCol );
381  if (pSave)
382  ::RestoreContent( pSave, pSibling->GetUpper(), pTmp );
383  }
384  }
385  }
386  pParent = pSect;
387  pSect = new SwSectionFrame( *static_cast<SwSectionFrame*>(pParent)->GetSection(), pParent );
388  // if pParent is decomposed into two parts, its Follow has to be attached
389  // to the new second part
390  pSect->SetFollow( static_cast<SwSectionFrame*>(pParent)->GetFollow() );
391  static_cast<SwSectionFrame*>(pParent)->SetFollow( nullptr );
392  if( pSect->GetFollow() )
393  pParent->InvalidateSize_();
394 
395  const bool bInserted = InsertGroupBefore( pParent, pSibling, pSect );
396  if (bInserted)
397  {
398  pSect->Init();
399  aRectFnSet.MakePos( *pSect, pSect->GetUpper(), pSect->GetPrev(), true);
400  }
401  if( !static_cast<SwLayoutFrame*>(pParent)->Lower() )
402  {
403  SwSectionFrame::MoveContentAndDelete( static_cast<SwSectionFrame*>(pParent), false );
404  pParent = this;
405  }
406  }
407  else
408  InsertGroupBefore( pParent, pSibling, nullptr );
409 
410  InvalidateAll_();
411  SwPageFrame *pPage = FindPageFrame();
412  InvalidatePage( pPage );
413 
414  if ( pSibling )
415  {
416  pSibling->InvalidatePos_();
417  pSibling->InvalidatePrt_();
418  if ( pSibling->IsContentFrame() )
419  pSibling->InvalidatePage( pPage );
420  }
421 
422  SwTwips nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
423  if( nFrameHeight )
424  pParent->Grow( nFrameHeight );
425 
426  if ( GetPrev() && !IsFollow() )
427  {
428  GetPrev()->InvalidateSize();
429  if ( GetPrev()->IsContentFrame() )
430  GetPrev()->InvalidatePage( pPage );
431  }
432 }
433 
440 bool SwSectionFrame::HasToBreak( const SwFrame* pFrame ) const
441 {
442  if( !pFrame->IsSctFrame() )
443  return false;
444 
445  const SwSectionFormat *pTmp = static_cast<const SwSectionFormat*>(GetFormat());
446 
447  const SwFrameFormat *pOtherFormat = static_cast<const SwSectionFrame*>(pFrame)->GetFormat();
448  do
449  {
450  pTmp = pTmp->GetParent();
451  if( !pTmp )
452  return false;
453  if( pTmp == pOtherFormat )
454  return true;
455  } while( true ); // ( pTmp->GetSect().GetValue() );
456 }
457 
464 {
465  if (pNxt->IsDeleteForbidden())
466  return;
467 
468  if (!pNxt->IsJoinLocked() && GetSection() == pNxt->GetSection())
469  {
470  PROTOCOL( this, PROT::Section, DbgAction::Merge, pNxt )
471 
472  SwFrame* pTmp = ::SaveContent( pNxt );
473  if( pTmp )
474  {
475  SwFrame* pLast = Lower();
476  SwLayoutFrame* pLay = this;
477  if( pLast )
478  {
479  while( pLast->GetNext() )
480  pLast = pLast->GetNext();
481  if( pLast->IsColumnFrame() )
482  { // Columns now with BodyFrame
483  pLay = static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(pLast)->Lower());
484  pLast = pLay->Lower();
485  if( pLast )
486  while( pLast->GetNext() )
487  pLast = pLast->GetNext();
488  }
489  }
490  ::RestoreContent( pTmp, pLay, pLast );
491  }
492  SetFollow( pNxt->GetFollow() );
493  pNxt->SetFollow( nullptr );
494  pNxt->Cut();
495  SwFrame::DestroyFrame(pNxt);
496  InvalidateSize();
497  }
498 }
499 
506 bool SwSectionFrame::SplitSect( SwFrame* pFrame, bool bApres )
507 {
508  assert(pFrame && "SplitSect: Why?");
509  SwFrame* pOther = bApres ? pFrame->FindNext() : pFrame->FindPrev();
510  if( !pOther )
511  return false;
512  SwSectionFrame* pSect = pOther->FindSctFrame();
513  if( pSect != this )
514  return false;
515  // Put the content aside
516  SwFrame* pSav = ::SaveContent( this, bApres ? pOther : pFrame );
517  OSL_ENSURE( pSav, "SplitSect: What's on?" );
518  if( pSav ) // be robust
519  { // Create a new SctFrame, not as a Follower/master
520  SwSectionFrame* pNew = new SwSectionFrame( *pSect->GetSection(), pSect );
521  pNew->InsertBehind( pSect->GetUpper(), pSect );
522  pNew->Init();
523  SwRectFnSet aRectFnSet(this);
524  aRectFnSet.MakePos( *pNew, nullptr, pSect, true );
525  // OD 25.03.2003 #108339# - restore content:
526  // determine layout frame for restoring content after the initialization
527  // of the section frame. In the section initialization the columns are
528  // created.
529  {
530  SwLayoutFrame* pLay = pNew;
531  // Search for last layout frame, e.g. for columned sections.
532  while( pLay->Lower() && pLay->Lower()->IsLayoutFrame() )
533  pLay = static_cast<SwLayoutFrame*>(pLay->Lower());
534  ::RestoreContent( pSav, pLay, nullptr );
535  }
536  InvalidateSize_();
537  if( HasFollow() )
538  {
539  pNew->SetFollow( GetFollow() );
540  SetFollow( nullptr );
541  }
542  return true;
543  }
544  return false;
545 }
546 
554 // If a multi-column section is cancelled, the ContentFrames have to be
555 // invalidated
556 static void lcl_InvalidateInfFlags( SwFrame* pFrame, bool bInva )
557 {
558  while ( pFrame )
559  {
560  pFrame->InvalidateInfFlags();
561  if( bInva )
562  {
563  pFrame->InvalidatePos_();
564  pFrame->InvalidateSize_();
565  pFrame->InvalidatePrt_();
566  }
567  if( pFrame->IsLayoutFrame() )
568  lcl_InvalidateInfFlags( static_cast<SwLayoutFrame*>(pFrame)->GetLower(), false );
569  pFrame = pFrame->GetNext();
570  }
571 }
572 
573 // Works like SwContentFrame::ImplGetNextContentFrame, but starts with a LayoutFrame
574 static SwContentFrame* lcl_GetNextContentFrame( const SwLayoutFrame* pLay, bool bFwd )
575 {
576  if ( bFwd )
577  {
578  if ( pLay->GetNext() && pLay->GetNext()->IsContentFrame() )
579  return const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(pLay->GetNext()));
580  }
581  else
582  {
583  if ( pLay->GetPrev() && pLay->GetPrev()->IsContentFrame() )
584  return const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(pLay->GetPrev()));
585  }
586 
587  const SwFrame* pFrame = pLay;
588  SwContentFrame *pContentFrame = nullptr;
589  bool bGoingUp = true;
590  do {
591  const SwFrame *p = nullptr;
592  bool bGoingFwdOrBwd = false;
593 
594  bool bGoingDown = !bGoingUp && pFrame->IsLayoutFrame();
595  if (bGoingDown)
596  {
597  p = static_cast<const SwLayoutFrame*>(pFrame)->Lower();
598  bGoingDown = nullptr != p;
599  }
600  if ( !bGoingDown )
601  {
602  p = pFrame->IsFlyFrame() ?
603  ( bFwd ? static_cast<const SwFlyFrame*>(pFrame)->GetNextLink() : static_cast<const SwFlyFrame*>(pFrame)->GetPrevLink() ) :
604  ( bFwd ? pFrame->GetNext() :pFrame->GetPrev() );
605  bGoingFwdOrBwd = nullptr != p;
606  if ( !bGoingFwdOrBwd )
607  {
608  p = pFrame->GetUpper();
609  bGoingUp = nullptr != p;
610  if ( !bGoingUp )
611  return nullptr;
612  }
613  }
614 
615  bGoingUp = !( bGoingFwdOrBwd || bGoingDown );
616  assert(p);
617  if (!bFwd && bGoingDown)
618  while ( p->GetNext() )
619  p = p->GetNext();
620 
621  pFrame = p;
622  } while ( nullptr == (pContentFrame = (pFrame->IsContentFrame() ? const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(pFrame)) : nullptr) ));
623 
624  return pContentFrame;
625 }
626 
627 namespace
628 {
629  SwLayoutFrame* FirstLeaf(SwSectionFrame* pLayFrame)
630  {
631  if (pLayFrame->Lower() && pLayFrame->Lower()->IsColumnFrame())
632  return pLayFrame->GetNextLayoutLeaf();
633  return pLayFrame;
634  }
635 
637  bool CanContainSplitSection(const SwFrame* pFrame)
638  {
639  if (!pFrame->IsInTab())
640  return true;
641 
642  // The frame is in a table, see if the table is in a section.
643  bool bRet = !pFrame->FindTabFrame()->IsInSct();
644 
645  if (bRet)
646  {
647  // Don't try to split if the frame itself is a section frame with
648  // multiple columns.
649  if (pFrame->IsSctFrame())
650  {
651  const SwFrame* pLower = pFrame->GetLower();
652  if (pLower && pLower->IsColumnFrame())
653  bRet = false;
654  }
655  }
656 
657  return bRet;
658  }
659 }
660 
662 {
663  bool bSize = pDel->Lower() && pDel->Lower()->IsColumnFrame();
664  SwFrame* pPrv = pDel->GetPrev();
665  SwLayoutFrame* pUp = pDel->GetUpper();
666  // OD 27.03.2003 #i12711# - initialize local pointer variables.
667  SwSectionFrame* pPrvSct = nullptr;
668  SwSectionFrame* pNxtSct = nullptr;
669  SwSectionFormat* pParent = static_cast<SwSectionFormat*>(pDel->GetFormat())->GetParent();
670  if( pDel->IsInTab() && pParent )
671  {
672  SwTabFrame *pTab = pDel->FindTabFrame();
673  // If we are within a table, we can only have broken up sections that
674  // are inside as well, but not a section that contains the whole table.
675  if( pTab->IsInSct() && pParent == pTab->FindSctFrame()->GetFormat() )
676  pParent = nullptr;
677  }
678  // If our Format has a parent, we have probably broken up another
679  // SectionFrame, which has to be checked. To do so we first acquire the
680  // succeeding and the preceding ContentFrame, let's see if they
681  // lay in the SectionFrames.
682  // OD 27.03.2003 #i12711# - check, if previous and next section belonging
683  // together and can be joined, *not* only if deleted section contains content.
684  if ( pParent )
685  {
686  SwFrame* pPrvContent = lcl_GetNextContentFrame( pDel, false );
687  pPrvSct = pPrvContent ? pPrvContent->FindSctFrame() : nullptr;
688  SwFrame* pNxtContent = lcl_GetNextContentFrame( pDel, true );
689  pNxtSct = pNxtContent ? pNxtContent->FindSctFrame() : nullptr;
690  }
691  else
692  {
693  pParent = nullptr;
694  pPrvSct = pNxtSct = nullptr;
695  }
696 
697  // Now the content is put aside and the frame is destroyed
698  SwFrame *pSave = bSave ? ::SaveContent( pDel ) : nullptr;
699  bool bOldFootnote = true;
700  if( pSave && pUp->IsFootnoteFrame() )
701  {
702  bOldFootnote = static_cast<SwFootnoteFrame*>(pUp)->IsColLocked();
703  static_cast<SwFootnoteFrame*>(pUp)->ColLock();
704  }
705  pDel->DelEmpty( true );
706  SwFrame::DestroyFrame(pDel);
707  if( pParent )
708  { // Search for the appropriate insert position
709  if( pNxtSct && pNxtSct->GetFormat() == pParent )
710  { // Here we can insert ourselves at the beginning
711  pUp = FirstLeaf( pNxtSct );
712  pPrv = nullptr;
713  if( pPrvSct && ( pPrvSct->GetFormat() != pParent ) )
714  pPrvSct = nullptr; // In order that nothing is merged
715  }
716  else if( pPrvSct && pPrvSct->GetFormat() == pParent )
717  { // Wonderful, here we can insert ourselves at the end
718  pUp = pPrvSct;
719  if( pUp->Lower() && pUp->Lower()->IsColumnFrame() )
720  {
721  pUp = static_cast<SwLayoutFrame*>(pUp->GetLastLower());
722  // The body of the last column
723  pUp = static_cast<SwLayoutFrame*>(pUp->Lower());
724  }
725  // In order to perform the insertion after the last one
726  pPrv = pUp->GetLastLower();
727  pPrvSct = nullptr; // Such that nothing is merged
728  }
729  else
730  {
731  if( pSave )
732  { // Following situations: before and after the section-to-be
733  // deleted there is the section boundary of the enclosing
734  // section, or another (sibling) section connects subsequently,
735  // that derives from the same Parent.
736  // In that case, there's not (yet) a part of our parent available
737  // that can store the content, so we create it here.
738  pPrvSct = new SwSectionFrame( *pParent->GetSection(), pUp );
739  pPrvSct->InsertBehind( pUp, pPrv );
740  pPrvSct->Init();
741  SwRectFnSet aRectFnSet(pUp);
742  aRectFnSet.MakePos( *pPrvSct, pUp, pPrv, true );
743  pUp = FirstLeaf( pPrvSct );
744  pPrv = nullptr;
745  }
746  pPrvSct = nullptr; // Such that nothing will be merged
747  }
748  }
749  // The content is going to be inserted...
750  if( pSave )
751  {
752  lcl_InvalidateInfFlags( pSave, bSize );
753  ::RestoreContent( pSave, pUp, pPrv );
755  if( !bOldFootnote )
756  static_cast<SwFootnoteFrame*>(pUp)->ColUnlock();
757  }
758  // Now two parts of the superior section could possibly be merged
759  if( pPrvSct && !pPrvSct->IsJoinLocked() )
760  {
761  OSL_ENSURE( pNxtSct, "MoveContent: No Merge" );
762  pPrvSct->MergeNext( pNxtSct );
763  }
764 }
765 
767 {
768  if ( IsJoinLocked() || IsColLocked() || StackHack::IsLocked() || StackHack::Count() > 50 )
769  return;
770  if( !m_pSection ) // Via DelEmpty
771  {
772 #ifdef DBG_UTIL
773  OSL_ENSURE( getRootFrame()->IsInDelList( this ), "SectionFrame without Section" );
774 #endif
775  if( !isFrameAreaPositionValid() )
776  {
777  if( GetUpper() )
778  {
779  SwRectFnSet aRectFnSet(GetUpper());
780  aRectFnSet.MakePos( *this, GetUpper(), GetPrev(), false );
781  }
782 
783  if (getFrameArea().Height() == 0)
784  {
785  // SwLayoutFrame::MakeAll() is not called for to-be-deleted
786  // section frames (which would invalidate the position of the
787  // next frame via the SwLayNotify dtor), so call it manually.
788  if (SwFrame* pNext = GetNext())
789  pNext->InvalidatePos();
790  }
791  }
792 
794  setFrameAreaSizeValid(true);
796  return;
797  }
798  LockJoin(); // I don't let myself to be destroyed on the way
799 
800  while( GetNext() && GetNext() == GetFollow() )
801  {
802  const SwFrame* pFoll = GetFollow();
803  MergeNext( static_cast<SwSectionFrame*>(GetNext()) );
804  if( pFoll == GetFollow() )
805  break;
806  }
807 
808  // OD 2004-03-15 #116561# - In online layout join the follows, if section
809  // can grow.
810  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
811 
812  // Split sections inside table cells: need to merge all follows of the
813  // section here, as later we won't attempt doing so.
814  bool bCanContainSplitSection = false;
815  if (IsInTab() && GetUpper())
816  bCanContainSplitSection = CanContainSplitSection(GetUpper());
817 
818  if( pSh && (pSh->GetViewOptions()->getBrowseMode() || bCanContainSplitSection) &&
819  ( Grow( LONG_MAX, true ) > 0 ) )
820  {
821  while( GetFollow() )
822  {
823  const SwFrame* pFoll = GetFollow();
824  MergeNext( GetFollow() );
825  if( pFoll == GetFollow() )
826  break;
827  }
828  }
829 
830  // A section with Follow uses all the space until the lower edge of the
831  // Upper. If it moves, its size can grow or decrease...
832  if( !isFrameAreaPositionValid() && ToMaximize( false ) )
833  {
834  setFrameAreaSizeValid(false);
835  }
836 
837  SwLayoutFrame::MakeAll(getRootFrame()->GetCurrShell()->GetOut());
838 
839  if (IsInTab())
840  {
841  // In case the section is in a table, then calculate the lower right
842  // now. Just setting the valid size flag of the lower to false may not
843  // be enough, as lcl_RecalcRow() can call
844  // SwFrame::ValidateThisAndAllLowers(), and then we don't attempt
845  // calculating the proper position of the lower.
846  SwFrame* pLower = Lower();
847  if (pLower && !pLower->isFrameAreaPositionValid())
848  pLower->Calc(pRenderContext);
849  }
850 
851  UnlockJoin();
852  if( m_pSection && IsSuperfluous() )
853  DelEmpty( false );
854 }
855 
857 {
858  OSL_FAIL( "Oops, where is my tinfoil hat?" );
859  return false;
860 }
861 
863 {
864  const SwSectionFormat *pFormat = m_pSection->GetFormat();
865  while( !pFormat->GetEndAtTextEnd().IsAtEnd() )
866  {
867  if( dynamic_cast< const SwSectionFormat *>( pFormat->GetRegisteredIn()) != nullptr )
868  pFormat = static_cast<const SwSectionFormat*>(pFormat->GetRegisteredIn());
869  else
870  return nullptr;
871  }
872  return pFormat;
873 }
874 
875 static void lcl_FindContentFrame( SwContentFrame* &rpContentFrame, SwFootnoteFrame* &rpFootnoteFrame,
876  SwFrame* pFrame, bool &rbChkFootnote )
877 {
878  if( pFrame )
879  {
880  while( pFrame->GetNext() )
881  pFrame = pFrame->GetNext();
882  while( !rpContentFrame && pFrame )
883  {
884  if( pFrame->IsContentFrame() )
885  rpContentFrame = static_cast<SwContentFrame*>(pFrame);
886  else if( pFrame->IsLayoutFrame() )
887  {
888  if( pFrame->IsFootnoteFrame() )
889  {
890  if( rbChkFootnote )
891  {
892  rpFootnoteFrame = static_cast<SwFootnoteFrame*>(pFrame);
893  rbChkFootnote = rpFootnoteFrame->GetAttr()->GetFootnote().IsEndNote();
894  }
895  }
896  else
897  lcl_FindContentFrame( rpContentFrame, rpFootnoteFrame,
898  static_cast<SwLayoutFrame*>(pFrame)->Lower(), rbChkFootnote );
899  }
900  pFrame = pFrame->GetPrev();
901  }
902  }
903 }
904 
906 {
907  SwContentFrame *pRet = nullptr;
908  SwFootnoteFrame *pFootnoteFrame = nullptr;
909  SwSectionFrame *pSect = this;
910  if( nMode != SwFindMode::None )
911  {
912  const SwSectionFormat *pFormat = IsEndnAtEnd() ? GetEndSectFormat() :
914  do {
915  while( pSect->HasFollow() )
916  pSect = pSect->GetFollow();
917  SwFrame* pTmp = pSect->FindNext();
918  while( pTmp && pTmp->IsSctFrame() &&
919  !static_cast<SwSectionFrame*>(pTmp)->GetSection() )
920  pTmp = pTmp->FindNext();
921  if( pTmp && pTmp->IsSctFrame() &&
922  static_cast<SwSectionFrame*>(pTmp)->IsDescendantFrom( pFormat ) )
923  pSect = static_cast<SwSectionFrame*>(pTmp);
924  else
925  break;
926  } while( true );
927  }
928  bool bFootnoteFound = nMode == SwFindMode::EndNote;
929  do
930  {
931  lcl_FindContentFrame( pRet, pFootnoteFrame, pSect->Lower(), bFootnoteFound );
932  if( pRet || !pSect->IsFollow() || nMode == SwFindMode::None ||
933  ( SwFindMode::MyLast == nMode && this == pSect ) )
934  break;
935  pSect = pSect->FindMaster();
936  } while( pSect );
937  if( ( nMode == SwFindMode::EndNote ) && pFootnoteFrame )
938  pRet = pFootnoteFrame->ContainsContent();
939  return pRet;
940 }
941 
942 bool SwSectionFrame::CalcMinDiff( SwTwips& rMinDiff ) const
943 {
944  if( ToMaximize( true ) )
945  {
946  SwRectFnSet aRectFnSet(this);
947  rMinDiff = aRectFnSet.GetPrtBottom(*GetUpper());
948  rMinDiff = aRectFnSet.BottomDist( getFrameArea(), rMinDiff );
949  return true;
950  }
951  return false;
952 }
953 
960 static SwFootnoteFrame* lcl_FindEndnote( SwSectionFrame* &rpSect, bool &rbEmpty,
961  SwLayouter *pLayouter )
962 {
963  // if rEmpty is set, the rpSect is already searched
964  SwSectionFrame* pSect = rbEmpty ? rpSect->GetFollow() : rpSect;
965  while( pSect )
966  {
967  OSL_ENSURE( (pSect->Lower() && pSect->Lower()->IsColumnFrame()) || pSect->GetUpper()->IsFootnoteFrame(),
968  "InsertEndnotes: Where's my column?" );
969 
970  // i73332: Columned section in endnote
971  SwColumnFrame* pCol = nullptr;
972  if(pSect->Lower() && pSect->Lower()->IsColumnFrame())
973  pCol = static_cast<SwColumnFrame*>(pSect->Lower());
974 
975  while( pCol ) // check all columns
976  {
977  SwFootnoteContFrame* pFootnoteCont = pCol->FindFootnoteCont();
978  if( pFootnoteCont )
979  {
980  SwFootnoteFrame* pRet = static_cast<SwFootnoteFrame*>(pFootnoteCont->Lower());
981  while( pRet ) // look for endnotes
982  {
983  /* CollectEndNode can destroy pRet so we need to get the
984  next early
985  */
986  SwFootnoteFrame* pRetNext = static_cast<SwFootnoteFrame*>(pRet->GetNext());
987  if( pRet->GetAttr()->GetFootnote().IsEndNote() )
988  {
989  if( pRet->GetMaster() )
990  {
991  if( pLayouter )
992  pLayouter->CollectEndnote( pRet );
993  else
994  return nullptr;
995  }
996  else
997  return pRet; // Found
998  }
999  pRet = pRetNext;
1000  }
1001  }
1002  pCol = static_cast<SwColumnFrame*>(pCol->GetNext());
1003  }
1004  rpSect = pSect;
1005  pSect = pLayouter ? pSect->GetFollow() : nullptr;
1006  rbEmpty = true;
1007  }
1008  return nullptr;
1009 }
1010 
1011 static void lcl_ColumnRefresh( SwSectionFrame* pSect, bool bFollow )
1012 {
1013  vcl::RenderContext* pRenderContext = pSect->getRootFrame()->GetCurrShell()->GetOut();
1014  while( pSect )
1015  {
1016  bool bOldLock = pSect->IsColLocked();
1017  pSect->ColLock();
1018  if( pSect->Lower() && pSect->Lower()->IsColumnFrame() )
1019  {
1020  SwColumnFrame *pCol = static_cast<SwColumnFrame*>(pSect->Lower());
1021  do
1022  { pCol->InvalidateSize_();
1023  pCol->InvalidatePos_();
1024  static_cast<SwLayoutFrame*>(pCol)->Lower()->InvalidateSize_();
1025  pCol->Calc(pRenderContext); // calculation of column and
1026  static_cast<SwLayoutFrame*>(pCol)->Lower()->Calc(pRenderContext); // body
1027  pCol = static_cast<SwColumnFrame*>(pCol->GetNext());
1028  } while ( pCol );
1029  }
1030  if( !bOldLock )
1031  pSect->ColUnlock();
1032  if( bFollow )
1033  pSect = pSect->GetFollow();
1034  else
1035  pSect = nullptr;
1036  }
1037 }
1038 
1040 {
1041  OSL_ENSURE( IsColLocked(), "CollectEndnotes: You love the risk?" );
1042  // i73332: Section in footnode does not have columns!
1043  OSL_ENSURE( (Lower() && Lower()->IsColumnFrame()) || GetUpper()->IsFootnoteFrame(), "Where's my column?" );
1044 
1045  SwSectionFrame* pSect = this;
1046  SwFootnoteFrame* pFootnote;
1047  bool bEmpty = false;
1048  // pSect is the last sectionfrm without endnotes or the this-pointer
1049  // the first sectionfrm with endnotes may be destroyed, when the endnotes
1050  // is cutted
1051  while( nullptr != (pFootnote = lcl_FindEndnote( pSect, bEmpty, pLayouter )) )
1052  pLayouter->CollectEndnote( pFootnote );
1053  if( pLayouter->HasEndnotes() )
1054  lcl_ColumnRefresh( this, true );
1055 }
1056 
1067 void SwSectionFrame::CheckClipping( bool bGrow, bool bMaximize )
1068 {
1069  SwRectFnSet aRectFnSet(this);
1070  long nDiff;
1071  SwTwips nDeadLine = aRectFnSet.GetPrtBottom(*GetUpper());
1072  if( bGrow && ( !IsInFly() || !GetUpper()->IsColBodyFrame() ||
1073  !FindFlyFrame()->IsLocked() ) )
1074  {
1075  nDiff = -aRectFnSet.BottomDist( getFrameArea(), nDeadLine );
1076  if( !bMaximize )
1077  nDiff += Undersize();
1078  if( nDiff > 0 )
1079  {
1080  long nAdd = GetUpper()->Grow( nDiff );
1081  if( aRectFnSet.IsVert() )
1082  nDeadLine -= nAdd;
1083  else
1084  nDeadLine += nAdd;
1085  }
1086  }
1087  nDiff = -aRectFnSet.BottomDist( getFrameArea(), nDeadLine );
1088  SetUndersized( !bMaximize && nDiff >= 0 );
1089  const bool bCalc = ( IsUndersized() || bMaximize ) &&
1090  ( nDiff ||
1091  aRectFnSet.GetTop(getFramePrintArea()) > aRectFnSet.GetHeight(getFrameArea()) );
1092  // OD 03.11.2003 #i19737# - introduce local variable <bExtraCalc> to indicate
1093  // that a calculation has to be done beside the value of <bCalc>.
1094  bool bExtraCalc = false;
1095  if( !bCalc && !bGrow && IsAnyNoteAtEnd() && !IsInFootnote() )
1096  {
1097  SwSectionFrame *pSect = this;
1098  bool bEmpty = false;
1099  SwLayoutFrame* pFootnote = IsEndnAtEnd() ?
1100  lcl_FindEndnote( pSect, bEmpty, nullptr ) : nullptr;
1101  if( pFootnote )
1102  {
1103  pFootnote = pFootnote->FindFootnoteBossFrame();
1105  // OD 08.11.2002 #104840# - use <SwLayoutFrame::IsBefore(..)>
1106  if ( pTmp && pFootnote->IsBefore( pTmp->FindFootnoteBossFrame() ) )
1107  bExtraCalc = true;
1108  }
1109  else if( GetFollow() && !GetFollow()->ContainsAny() )
1110  bExtraCalc = true;
1111  }
1112  if ( bCalc || bExtraCalc )
1113  {
1114  nDiff = aRectFnSet.YDiff( nDeadLine, aRectFnSet.GetTop(getFrameArea()) );
1115  if( nDiff < 0 )
1116  nDeadLine = aRectFnSet.GetTop(getFrameArea());
1117  const Size aOldSz( getFramePrintArea().SSize() );
1118  long nTop = aRectFnSet.GetTopMargin(*this);
1119 
1120  {
1122  aRectFnSet.SetBottom( aFrm, nDeadLine );
1123  }
1124 
1125  nDiff = aRectFnSet.GetHeight(getFrameArea());
1126  if( nTop > nDiff )
1127  nTop = nDiff;
1128  aRectFnSet.SetYMargins( *this, nTop, 0 );
1129 
1130  // OD 18.09.2002 #100522#
1131  // Determine, if height has changed.
1132  // Note: In vertical layout the height equals the width value.
1133  bool bHeightChanged = aRectFnSet.IsVert() ?
1134  (aOldSz.Width() != getFramePrintArea().Width()) :
1135  (aOldSz.Height() != getFramePrintArea().Height());
1136  // Last but not least we have changed the height again, thus the inner
1137  // layout (columns) is calculated and the content as well.
1138  // OD 18.09.2002 #100522#
1139  // calculate content, only if height has changed.
1140  // OD 03.11.2003 #i19737# - restriction of content calculation too strong.
1141  // If an endnote has an incorrect position or a follow section contains
1142  // no content except footnotes/endnotes, the content has also been calculated.
1143  if ( ( bHeightChanged || bExtraCalc ) && Lower() )
1144  {
1145  if( Lower()->IsColumnFrame() )
1146  {
1147  lcl_ColumnRefresh( this, false );
1148  ::CalcContent( this );
1149  }
1150  else
1151  {
1152  ChgLowersProp( aOldSz );
1153  if( !bMaximize && !IsContentLocked() )
1154  ::CalcContent( this );
1155  }
1156  }
1157  }
1158 }
1159 
1161 {
1162  if ( IsJoinLocked() || IsColLocked() )
1163  return;
1164  LockJoin();
1165  SwRectFnSet aRectFnSet(this);
1166  if( GetPrev() || GetUpper() )
1167  {
1168  // assure notifications on position changes.
1169  const SwLayNotify aNotify( this );
1170  aRectFnSet.MakePos( *this, GetUpper(), GetPrev(), false );
1172  }
1173  SwTwips nDeadLine = aRectFnSet.GetPrtBottom(*GetUpper());
1174  // OD 22.10.2002 #97265# - call always method <lcl_ColumnRefresh(..)>, in
1175  // order to get calculated lowers, not only if there space left in its upper.
1176  if( aRectFnSet.BottomDist( getFrameArea(), nDeadLine ) >= 0 )
1177  {
1178  {
1180  aRectFnSet.SetBottom( aFrm, nDeadLine );
1181  }
1182 
1183  long nHeight = aRectFnSet.GetHeight(getFrameArea());
1184  long nTop = CalcUpperSpace();
1185  if( nTop > nHeight )
1186  nTop = nHeight;
1187  aRectFnSet.SetYMargins( *this, nTop, 0 );
1188  }
1189  lcl_ColumnRefresh( this, false );
1190  UnlockJoin();
1191 }
1192 
1193 namespace {
1194 
1195 // #i40147# - helper class to perform extra section format
1196 // to position anchored objects and to keep the position of whose objects locked.
1197 class ExtraFormatToPositionObjs
1198 {
1199  private:
1200  SwSectionFrame* mpSectFrame;
1201  bool mbExtraFormatPerformed;
1202 
1203  public:
1204  explicit ExtraFormatToPositionObjs( SwSectionFrame& _rSectFrame)
1205  : mpSectFrame( &_rSectFrame ),
1206  mbExtraFormatPerformed( false )
1207  {}
1208 
1209  ~ExtraFormatToPositionObjs()
1210  {
1211  if ( mbExtraFormatPerformed )
1212  {
1213  // release keep locked position of lower floating screen objects
1214  SwPageFrame* pPageFrame = mpSectFrame->FindPageFrame();
1215  SwSortedObjs* pObjs = pPageFrame ? pPageFrame->GetSortedObjs() : nullptr;
1216  if ( pObjs )
1217  {
1218  for (SwAnchoredObject* pAnchoredObj : *pObjs)
1219  {
1220  if ( mpSectFrame->IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
1221  {
1222  pAnchoredObj->SetKeepPosLocked( false );
1223  }
1224  }
1225  }
1226  }
1227  }
1228 
1229  // #i81555#
1230  void InitObjs( SwFrame& rFrame )
1231  {
1232  SwSortedObjs* pObjs = rFrame.GetDrawObjs();
1233  if ( pObjs )
1234  {
1235  for (SwAnchoredObject* pAnchoredObj : *pObjs)
1236  {
1237  pAnchoredObj->UnlockPosition();
1238  pAnchoredObj->SetClearedEnvironment( false );
1239  }
1240  }
1241  SwLayoutFrame* pLayoutFrame = dynamic_cast<SwLayoutFrame*>(&rFrame);
1242  if ( pLayoutFrame != nullptr )
1243  {
1244  SwFrame* pLowerFrame = pLayoutFrame->GetLower();
1245  while ( pLowerFrame != nullptr )
1246  {
1247  InitObjs( *pLowerFrame );
1248 
1249  pLowerFrame = pLowerFrame->GetNext();
1250  }
1251  }
1252  }
1253 
1254  void FormatSectionToPositionObjs()
1255  {
1256  vcl::RenderContext* pRenderContext = mpSectFrame->getRootFrame()->GetCurrShell()->GetOut();
1257  // perform extra format for multi-columned section.
1258  if ( !(mpSectFrame->Lower() && mpSectFrame->Lower()->IsColumnFrame() &&
1259  mpSectFrame->Lower()->GetNext()) )
1260  return;
1261 
1262  // grow section till bottom of printing area of upper frame
1263  SwRectFnSet aRectFnSet(mpSectFrame);
1264  SwTwips nTopMargin = aRectFnSet.GetTopMargin(*mpSectFrame);
1265  Size aOldSectPrtSize( mpSectFrame->getFramePrintArea().SSize() );
1266  SwTwips nDiff = aRectFnSet.BottomDist( mpSectFrame->getFrameArea(), aRectFnSet.GetPrtBottom(*mpSectFrame->GetUpper()) );
1267 
1268  {
1270  aRectFnSet.AddBottom( aFrm, nDiff );
1271  }
1272 
1273  aRectFnSet.SetYMargins( *mpSectFrame, nTopMargin, 0 );
1274  // #i59789#
1275  // suppress formatting, if printing area of section is too narrow
1276  if ( aRectFnSet.GetHeight(mpSectFrame->getFramePrintArea()) <= 0 )
1277  {
1278  return;
1279  }
1280  mpSectFrame->ChgLowersProp( aOldSectPrtSize );
1281 
1282  // format column frames and its body and footnote container
1283  SwColumnFrame* pColFrame = static_cast<SwColumnFrame*>(mpSectFrame->Lower());
1284  while ( pColFrame )
1285  {
1286  pColFrame->Calc(pRenderContext);
1287  pColFrame->Lower()->Calc(pRenderContext);
1288  if ( pColFrame->Lower()->GetNext() )
1289  {
1290  pColFrame->Lower()->GetNext()->Calc(pRenderContext);
1291  }
1292 
1293  pColFrame = static_cast<SwColumnFrame*>(pColFrame->GetNext());
1294  }
1295 
1296  // unlock position of lower floating screen objects for the extra format
1297  // #i81555#
1298  // Section frame can already have changed the page and its content
1299  // can still be on the former page.
1300  // Thus, initialize objects via lower-relationship
1301  InitObjs( *mpSectFrame );
1302 
1303  // format content - first with collecting its foot-/endnotes before content
1304  // format, second without collecting its foot-/endnotes.
1305  ::CalcContent( mpSectFrame );
1306  ::CalcContent( mpSectFrame, true );
1307 
1308  // keep locked position of lower floating screen objects
1309  SwPageFrame* pPageFrame = mpSectFrame->FindPageFrame();
1310  SwSortedObjs* pObjs = pPageFrame ? pPageFrame->GetSortedObjs() : nullptr;
1311  if ( pObjs )
1312  {
1313  for (SwAnchoredObject* pAnchoredObj : *pObjs)
1314  {
1315  if ( mpSectFrame->IsAnLower( pAnchoredObj->GetAnchorFrame() ) )
1316  {
1317  pAnchoredObj->SetKeepPosLocked( true );
1318  }
1319  }
1320  }
1321 
1322  mbExtraFormatPerformed = true;
1323 
1324  }
1325 };
1326 
1327 }
1328 
1330 void SwSectionFrame::Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttr )
1331 {
1332  if( !m_pSection ) // via DelEmpty
1333  {
1334 #ifdef DBG_UTIL
1335  OSL_ENSURE( getRootFrame()->IsInDelList( this ), "SectionFrame without Section" );
1336 #endif
1338  setFrameAreaSizeValid(true);
1339  setFramePrintAreaValid(true);
1340  return;
1341  }
1342 
1343  SwRectFnSet aRectFnSet(this);
1344 
1345  if ( !isFramePrintAreaValid() )
1346  {
1347  PROTOCOL( this, PROT::PrintArea, DbgAction::NONE, nullptr )
1348  setFramePrintAreaValid(true);
1349  SwTwips nUpper = CalcUpperSpace();
1350 
1351  // #109700# LRSpace for sections
1352  const SvxLRSpaceItem& rLRSpace = GetFormat()->GetLRSpace();
1353  aRectFnSet.SetXMargins( *this, rLRSpace.GetLeft(), rLRSpace.GetRight() );
1354 
1355  if( nUpper != aRectFnSet.GetTopMargin(*this) )
1356  {
1357  setFrameAreaSizeValid(false);
1358  SwFrame* pOwn = ContainsAny();
1359  if( pOwn )
1360  pOwn->InvalidatePos_();
1361  }
1362  aRectFnSet.SetYMargins( *this, nUpper, 0 );
1363  }
1364 
1365  if ( isFrameAreaSizeValid() )
1366  return;
1367 
1368  PROTOCOL_ENTER( this, PROT::Size, DbgAction::NONE, nullptr )
1369  const long nOldHeight = aRectFnSet.GetHeight(getFrameArea());
1370  bool bOldLock = IsColLocked();
1371  ColLock();
1372 
1373  setFrameAreaSizeValid(true);
1374 
1375  // The size is only determined by the content, if the SectFrame does not have a
1376  // Follow. Otherwise it fills (occupies) the Upper down to the lower edge.
1377  // It is not responsible for the text flow, but the content is.
1378  bool bMaximize = ToMaximize( false );
1379 
1380  // OD 2004-05-17 #i28701# - If the wrapping style has to be considered
1381  // on object positioning, an extra formatting has to be performed
1382  // to determine the correct positions the floating screen objects.
1383  // #i40147#
1384  // use new helper class <ExtraFormatToPositionObjs>.
1385  // This class additionally keep the locked position of the objects
1386  // and releases this position lock keeping on destruction.
1387  ExtraFormatToPositionObjs aExtraFormatToPosObjs( *this );
1388  if ( !bMaximize &&
1389  GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
1390  !GetFormat()->GetBalancedColumns().GetValue() )
1391  {
1392  aExtraFormatToPosObjs.FormatSectionToPositionObjs();
1393  }
1394 
1395  // Column widths have to be adjusted before calling CheckClipping.
1396  // CheckClipping can cause the formatting of the lower frames
1397  // which still have a width of 0.
1398  const bool bHasColumns = Lower() && Lower()->IsColumnFrame();
1399  if ( bHasColumns && Lower()->GetNext() )
1400  AdjustColumns( nullptr, false );
1401 
1402  if( GetUpper() )
1403  {
1404  const long nWidth = aRectFnSet.GetWidth(GetUpper()->getFramePrintArea());
1405 
1406  {
1408  aRectFnSet.SetWidth( aFrm, nWidth );
1409  }
1410 
1411  // #109700# LRSpace for sections
1412  {
1413  const SvxLRSpaceItem& rLRSpace = GetFormat()->GetLRSpace();
1415  aRectFnSet.SetWidth( aPrt, nWidth - rLRSpace.GetLeft() - rLRSpace.GetRight() );
1416  }
1417 
1418  // OD 15.10.2002 #103517# - allow grow in online layout
1419  // Thus, set <..IsBrowseMode()> as parameter <bGrow> on calling
1420  // method <CheckClipping(..)>.
1421  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
1422  CheckClipping( pSh && pSh->GetViewOptions()->getBrowseMode(), bMaximize );
1423  bMaximize = ToMaximize( false );
1424  setFrameAreaSizeValid(true);
1425  }
1426 
1427  // Check the width of the columns and adjust if necessary
1428  if ( bHasColumns && ! Lower()->GetNext() && bMaximize )
1429  static_cast<SwColumnFrame*>(Lower())->Lower()->Calc(pRenderContext);
1430 
1431  if ( !bMaximize )
1432  {
1433  SwTwips nRemaining = aRectFnSet.GetTopMargin(*this);
1434  SwFrame *pFrame = m_pLower;
1435  if( pFrame )
1436  {
1437  if( pFrame->IsColumnFrame() && pFrame->GetNext() )
1438  {
1439  // #i61435#
1440  // suppress formatting, if upper frame has height <= 0
1441  if ( aRectFnSet.GetHeight(GetUpper()->getFrameArea()) > 0 )
1442  {
1443  FormatWidthCols( *pAttr, nRemaining, MINLAY );
1444  }
1445  // #126020# - adjust check for empty section
1446  // #130797# - correct fix #126020#
1447  while( HasFollow() && !GetFollow()->ContainsContent() &&
1448  !GetFollow()->ContainsAny( true ) )
1449  {
1450  SwFrame* pOld = GetFollow();
1451  GetFollow()->DelEmpty( false );
1452  if( pOld == GetFollow() )
1453  break;
1454  }
1455  bMaximize = ToMaximize( false );
1456  nRemaining += aRectFnSet.GetHeight(pFrame->getFrameArea());
1457  }
1458  else
1459  {
1460  if( pFrame->IsColumnFrame() )
1461  {
1462  pFrame->Calc(pRenderContext);
1463  pFrame = static_cast<SwColumnFrame*>(pFrame)->Lower();
1464  pFrame->Calc(pRenderContext);
1465  pFrame = static_cast<SwLayoutFrame*>(pFrame)->Lower();
1467  }
1468  // If we are in a columned frame which calls a CalcContent
1469  // in the FormatWidthCols, the content might need calculating
1470  if( pFrame && !pFrame->isFrameAreaDefinitionValid() && IsInFly() &&
1471  FindFlyFrame()->IsColLocked() )
1472  ::CalcContent( this );
1473  nRemaining += InnerHeight();
1474  bMaximize = HasFollow();
1475  }
1476  }
1477 
1478  SwTwips nDiff = aRectFnSet.GetHeight(getFrameArea()) - nRemaining;
1479  if( nDiff < 0)
1480  {
1481  SwTwips nDeadLine = aRectFnSet.GetPrtBottom(*GetUpper());
1482  {
1483  long nBottom = aRectFnSet.GetBottom(getFrameArea());
1484  nBottom = aRectFnSet.YInc( nBottom, -nDiff );
1485  long nTmpDiff = aRectFnSet.YDiff( nBottom, nDeadLine );
1486  if( nTmpDiff > 0 )
1487  {
1488  nTmpDiff = GetUpper()->Grow( nTmpDiff, true );
1489  nDeadLine = aRectFnSet.YInc( nDeadLine, nTmpDiff );
1490  nTmpDiff = aRectFnSet.YDiff( nBottom, nDeadLine );
1491  if( nTmpDiff > 0 )
1492  nDiff += nTmpDiff;
1493  if( nDiff > 0 )
1494  nDiff = 0;
1495  }
1496  }
1497  }
1498  if( nDiff )
1499  {
1500  long nTmp = nRemaining - aRectFnSet.GetHeight(getFrameArea());
1501  long nTop = aRectFnSet.GetTopMargin(*this);
1502 
1503  {
1505  aRectFnSet.AddBottom( aFrm, nTmp );
1506  }
1507 
1508  aRectFnSet.SetYMargins( *this, nTop, 0 );
1510 
1511  if (m_pLower && (!m_pLower->IsColumnFrame() || !m_pLower->GetNext()))
1512  {
1513  // If a single-column section just created the space that
1514  // was requested by the "undersized" paragraphs, then they
1515  // have to be invalidated and calculated, so they fully cover it
1516  pFrame = m_pLower;
1517  if( pFrame->IsColumnFrame() )
1518  {
1519  pFrame->InvalidateSize_();
1520  pFrame->InvalidatePos_();
1521  pFrame->Calc(pRenderContext);
1522  pFrame = static_cast<SwColumnFrame*>(pFrame)->Lower();
1523  pFrame->Calc(pRenderContext);
1524  pFrame = static_cast<SwLayoutFrame*>(pFrame)->Lower();
1526  }
1527  bool bUnderSz = false;
1528  while( pFrame )
1529  {
1530  if( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsUndersized() )
1531  {
1533  bUnderSz = true;
1534  }
1535  pFrame = pFrame->GetNext();
1536  }
1537  if( bUnderSz && !IsContentLocked() )
1538  ::CalcContent( this );
1539  }
1540  }
1541  }
1542 
1543  // Do not exceed the lower edge of the Upper.
1544  // Do not extend below the lower edge with Sections with Follows
1545  if ( GetUpper() )
1546  CheckClipping( true, bMaximize );
1547  if( !bOldLock )
1548  ColUnlock();
1549  long nDiff = nOldHeight - aRectFnSet.GetHeight(getFrameArea());
1550 
1551  if( nDiff > 0 )
1552  {
1553  if( !GetNext() )
1554  SetRetouche(); // Take over the retouching ourselves
1555  if( GetUpper() && !GetUpper()->IsFooterFrame() )
1556  GetUpper()->Shrink( nDiff );
1557  }
1558 
1559  if( IsUndersized() )
1560  {
1561  setFramePrintAreaValid(true);
1562  }
1563 
1564 }
1565 
1569 {
1570  // Attention: Nested sections are currently not supported
1571 
1573 
1574  // Shortcuts for "columned" sections, if we're not in the last column
1575  // Can we slide to the next column of the section?
1576  if( IsColBodyFrame() && GetUpper()->GetNext() )
1577  return static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(GetUpper()->GetNext())->Lower());
1578  if( GetUpper()->IsColBodyFrame() && GetUpper()->GetUpper()->GetNext() )
1579  return static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(GetUpper()->GetUpper()->GetNext())->Lower());
1580  // Inside a table-in-section, or sections of headers/footers, there can be only
1581  // one column shift be made, one of the above shortcuts should have applied!
1582  if( !CanContainSplitSection(GetUpper()) || FindFooterOrHeader() )
1583  return nullptr;
1584 
1585  SwSectionFrame *pSect = FindSctFrame();
1586  bool bWrongPage = false;
1587  assert(pSect && "GetNextSctLeaf: Missing SectionFrame");
1588 
1589  // Shortcut for sections with Follows. That's ok,
1590  // if no columns or pages (except dummy pages) lie in between.
1591  // In case of linked frames and in footnotes the shortcut would get
1592  // even more costly
1593  if( pSect->HasFollow() && pSect->IsInDocBody() && !pSect->IsInTab() )
1594  {
1595  if( pSect->GetFollow() == pSect->GetNext() )
1596  {
1597  SwPageFrame *pPg = pSect->GetFollow()->FindPageFrame();
1598  if( WrongPageDesc( pPg ) )
1599  bWrongPage = true;
1600  else
1601  return FirstLeaf( pSect->GetFollow() );
1602  }
1603  else
1604  {
1605  SwFrame* pTmp;
1606  if( !pSect->GetUpper()->IsColBodyFrame() ||
1607  nullptr == ( pTmp = pSect->GetUpper()->GetUpper()->GetNext() ) )
1608  pTmp = pSect->FindPageFrame()->GetNext();
1609  if( pTmp ) // is now the next column or page
1610  {
1611  SwFrame* pTmpX = pTmp;
1612  if( pTmp->IsPageFrame() && static_cast<SwPageFrame*>(pTmp)->IsEmptyPage() )
1613  pTmp = pTmp->GetNext(); // skip dummy pages
1614  SwFrame *pUp = pSect->GetFollow()->GetUpper();
1615  // pUp becomes the next column if the Follow lies in a column
1616  // that is not a "not first" one, otherwise the page
1617  if( !pUp->IsColBodyFrame() ||
1618  !( pUp = pUp->GetUpper() )->GetPrev() )
1619  pUp = pUp->FindPageFrame();
1620  // Now pUp and pTmp have to be the same page/column, otherwise
1621  // pages or columns lie between Master and Follow
1622  if( pUp == pTmp || pUp->GetNext() == pTmpX )
1623  {
1624  SwPageFrame* pNxtPg = pUp->IsPageFrame() ?
1625  static_cast<SwPageFrame*>(pUp) : pUp->FindPageFrame();
1626  if( WrongPageDesc( pNxtPg ) )
1627  bWrongPage = true;
1628  else
1629  return FirstLeaf( pSect->GetFollow() );
1630  }
1631  }
1632  }
1633  }
1634 
1635 #ifndef NDEBUG
1636  std::vector<SwFrame *> parents;
1637  for (SwFrame * pTmp = GetUpper(); pTmp && !pTmp->IsPageFrame(); pTmp = pTmp->GetUpper())
1638  {
1639  parents.push_back(pTmp);
1640  }
1641 #endif
1642 
1643  // Always end up in the same section: Body again inside Body etc.
1644  const bool bBody = IsInDocBody();
1645  const bool bFootnotePage = FindPageFrame()->IsFootnotePage();
1646 
1647  // The "pLayLeaf is in a table" case is rejected by default, so that it
1648  // can't happen that we try to move a table to one of its own cells.
1649  bool bLayLeafTableAllowed = false;
1650  SwLayoutFrame *pLayLeaf;
1651 
1652  SwLayoutFrame* pCellLeaf = nullptr;
1653  if (GetUpper()->IsInTab())
1654  {
1655  if (IsTabFrame())
1656  {
1657  return nullptr; // table in section in table: split disabled for now
1658  }
1659  // We are *in* a table (not an outermost SwTabFrame), see if there
1660  // is a follow cell frame created already.
1661  pCellLeaf = GetNextCellLeaf();
1662  if (!pCellLeaf)
1663  {
1664  SAL_WARN("sw.layout", "section is in table, but the table is not split");
1665  return nullptr;
1666  }
1667  }
1668 
1669  // A shortcut for TabFrames such that not all cells need to be visited
1670  if( bWrongPage )
1671  pLayLeaf = nullptr;
1672  else if( IsTabFrame() )
1673  {
1674  SwFrame *const pTmpCnt = static_cast<SwTabFrame*>(this)->FindLastContentOrTable();
1675  pLayLeaf = pTmpCnt ? pTmpCnt->GetUpper() : nullptr;
1676  }
1677  else if (pCellLeaf && CanContainSplitSection(this))
1678  {
1679  // This frame is in a table-not-in-section, its follow should be
1680  // inserted under the follow of the frame's cell.
1681  pLayLeaf = pCellLeaf;
1682  if (pLayLeaf->FindTabFrame() == FindTabFrame())
1683  SAL_WARN("sw.layout", "my table frame and my follow's table frame is the same");
1684  // In this case pLayLeaf pointing to an in-table frame is OK.
1685  bLayLeafTableAllowed = true;
1686  }
1687  else
1688  {
1689  pLayLeaf = GetNextLayoutLeaf();
1690  if( IsColumnFrame() )
1691  {
1692  while( pLayLeaf && static_cast<SwColumnFrame*>(this)->IsAnLower( pLayLeaf ) )
1693  pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
1694  }
1695  }
1696 
1697  SwLayoutFrame *pOldLayLeaf = nullptr; // Such that in case of newly
1698  // created pages, the search is
1699  // not started over at the beginning
1700 
1701  while( true )
1702  {
1703  if( pLayLeaf )
1704  {
1705  // A layout leaf was found, let's see whether it can store me or
1706  // another SectionFrame can be inserted here, or we have to continue
1707  // searching
1708  SwPageFrame* pNxtPg = pLayLeaf->FindPageFrame();
1709  if ( !bFootnotePage && pNxtPg->IsFootnotePage() )
1710  { // If I reached the end note pages it's over
1711  pLayLeaf = nullptr;
1712  continue;
1713  }
1714  // Once inBody always inBody, don't step into tables-in-sections and not into other sections
1715  if ( (bBody && !pLayLeaf->IsInDocBody()) ||
1716  (IsInFootnote() != pLayLeaf->IsInFootnote() ) ||
1717  (pLayLeaf->IsInTab() && !bLayLeafTableAllowed) ||
1718  ( pLayLeaf->IsInSct() && ( !pSect->HasFollow()
1719  || pSect->GetFollow() != pLayLeaf->FindSctFrame() ) ) )
1720  {
1721  // Rejected - try again.
1722  pOldLayLeaf = pLayLeaf;
1723  pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
1724  continue;
1725  }
1726  // Page desc is never wrong in case of sections-in-tables: in that
1727  // case pLayLeaf points to our section's cell's follow, which is
1728  // fine to be on the same page. New page creation is handled when
1729  // creating / moving the cell frame.
1730  if( WrongPageDesc( pNxtPg ) && !bLayLeafTableAllowed )
1731  {
1732  if( bWrongPage )
1733  break; // there's a column between me and my right page
1734  pLayLeaf = nullptr;
1735  bWrongPage = true;
1736  pOldLayLeaf = nullptr;
1737  continue;
1738  }
1739  }
1740  // There is no further LayoutFrame that fits, so a new page
1741  // has to be created, although new pages are worthless within a frame
1742  else if( !pSect->IsInFly() &&
1743  ( eMakePage == MAKEPAGE_APPEND || eMakePage == MAKEPAGE_INSERT ) )
1744  {
1745  InsertPage(pOldLayLeaf ? pOldLayLeaf->FindPageFrame() : FindPageFrame(),
1746  false );
1747  // and again the whole thing
1748  if (pCellLeaf && CanContainSplitSection(this))
1749  // GetNextLayoutLeaf() would refer to the next cell in the same
1750  // row, avoid that. pCellLeaf points to the correct cell in the
1751  // follow table, and in the next round it'll be used, as we now
1752  // have a next page.
1753  pLayLeaf = pCellLeaf;
1754  else
1755  pLayLeaf = pOldLayLeaf ? pOldLayLeaf : GetNextLayoutLeaf();
1756  continue;
1757  }
1758  break;
1759  }
1760 
1761  if( pLayLeaf )
1762  {
1763  // We have found the suitable layout sheet. If there (in the sheet) is
1764  // already a Follow of our section, we take its first layout sheet,
1765  // otherwise it is time to create a section follow
1766  SwSectionFrame* pNew = nullptr;
1767 
1768  // This can be omitted if existing Follows were cut short
1769  SwFrame* pFirst = pLayLeaf->Lower();
1770  // Here SectionFrames that are to be deleted must be ignored
1771  while( pFirst && pFirst->IsSctFrame() && !static_cast<SwSectionFrame*>(pFirst)->GetSection() )
1772  pFirst = pFirst->GetNext();
1773  if( pFirst && pFirst->IsSctFrame() && pSect->GetFollow() == pFirst )
1774  pNew = pSect->GetFollow();
1775  else if( MAKEPAGE_NOSECTION == eMakePage )
1776  return pLayLeaf;
1777  else if (pSect->GetSection())
1778  {
1779  pNew = new SwSectionFrame( *pSect, false );
1780  pNew->InsertBefore( pLayLeaf, pLayLeaf->Lower() );
1781  pNew->Init();
1782  SwRectFnSet aRectFnSet(pNew);
1783  aRectFnSet.MakePos( *pNew, pLayLeaf, nullptr, true );
1784 
1785 #ifndef NDEBUG
1786  { // sanity check the parents of the new frame vs. the old frame
1787  SwFrame * pTmp = pNew;
1788  auto iter(parents.begin());
1789  if (parents.size() >= 2 &&
1790  parents[0]->IsBodyFrame() && parents[1]->IsColumnFrame())
1791  { // this only inserts section frame - remove column
1792  assert(parents[2]->IsSctFrame() || IsSctFrame());
1793  if (parents[2]->IsSctFrame())
1794  std::advance(iter, +2);
1795  else
1796  pTmp = pTmp->GetUpper();
1797  }
1798  else if (IsBodyFrame() && parents.size() >= 1
1799  && parents[0]->IsColumnFrame())
1800  { // same as above, special case: "this" is the body frame
1801  assert(parents[1]->IsSctFrame());
1802  std::advance(iter, +1);
1803  }
1804  else if (IsSctFrame()) // special case: "this" is the section
1805  {
1806  pTmp = pTmp->GetUpper();
1807  }
1808 
1809  for ( ; iter != parents.end(); ++iter)
1810  {
1811  if (pTmp->IsPageFrame())
1812  {
1813  if ((*iter)->IsColumnFrame() &&
1814  (iter + 1) != parents.end() && (*(iter + 1))->IsBodyFrame())
1815  { // page style has columns - evidently these are
1816  break; // added later?
1817  }
1818  assert(!pTmp->IsPageFrame());
1819  }
1820  assert(pTmp->GetType() == (*iter)->GetType());
1821  // for cell frames and table frames:
1822  // 1) there may be multiple follow frames of the old one
1823  // 2) the new frame may be identical to the old one
1824  // (not sure if this is allowed, but it happens now
1825  // for the outer table of a nested table)
1826  if (pTmp->IsCellFrame())
1827  {
1828  SwCellFrame const*const pNewF(static_cast<SwCellFrame*>(pTmp));
1829  SwCellFrame const*const pOldF(static_cast<SwCellFrame*>(*iter));
1830  bool bFollowFound(false);
1831  for (SwCellFrame const* pOldIter = pOldF;
1832  pOldIter; pOldIter = pOldIter->GetFollowCell())
1833  {
1834  if (pOldIter == pNewF)
1835  {
1836  bFollowFound = true;
1837  break;
1838  }
1839  }
1840  assert(bFollowFound);
1841  }
1842  else if (pTmp->IsFlowFrame())
1843  {
1844  SwFlowFrame const*const pNewF(SwFlowFrame::CastFlowFrame(pTmp));
1845  SwFlowFrame const*const pOldF(SwFlowFrame::CastFlowFrame(*iter));
1846  bool bFollowFound(false);
1847  for (SwFlowFrame const* pOldIter = pOldF;
1848  pOldIter; pOldIter = pOldIter->GetFollow())
1849  {
1850  if (pOldIter == pNewF)
1851  {
1852  bFollowFound = true;
1853  break;
1854  }
1855  }
1856  assert(bFollowFound);
1857  }
1858  pTmp = pTmp->GetUpper();
1859  }
1860  assert(pTmp == nullptr /* SwFlyAtContentFrame case */
1861  || pTmp->IsPageFrame() // usual case
1862  // the new page has columns, but the old page did not
1863  || (pTmp->IsColumnFrame() && pTmp->GetUpper()->IsBodyFrame()
1864  && pTmp->GetUpper()->GetUpper()->IsPageFrame()));
1865  }
1866 #endif
1867 
1868  // If our section frame has a successor then that has to be
1869  // moved behind the new Follow of the section frames
1870  SwFrame* pTmp = pSect->GetNext();
1871  if( pTmp && pTmp != pSect->GetFollow() )
1872  {
1873  SwFlowFrame* pNxt;
1874  SwContentFrame* pNxtContent = nullptr;
1875  if( pTmp->IsContentFrame() )
1876  {
1877  pNxt = static_cast<SwContentFrame*>(pTmp);
1878  pNxtContent = static_cast<SwContentFrame*>(pTmp);
1879  }
1880  else
1881  {
1882  pNxtContent = static_cast<SwLayoutFrame*>(pTmp)->ContainsContent();
1883  if( pTmp->IsSctFrame() )
1884  pNxt = static_cast<SwSectionFrame*>(pTmp);
1885  else
1886  {
1887  assert(pTmp->IsTabFrame());
1888  pNxt = static_cast<SwTabFrame*>(pTmp);
1889  }
1890  while( !pNxtContent && nullptr != ( pTmp = pTmp->GetNext() ) )
1891  {
1892  if( pTmp->IsContentFrame() )
1893  pNxtContent = static_cast<SwContentFrame*>(pTmp);
1894  else
1895  pNxtContent = static_cast<SwLayoutFrame*>(pTmp)->ContainsContent();
1896  }
1897  }
1898  if( pNxtContent )
1899  {
1900  SwFootnoteBossFrame* pOldBoss = pSect->FindFootnoteBossFrame( true );
1901  if( pOldBoss == pNxtContent->FindFootnoteBossFrame( true ) )
1902  {
1903  SwSaveFootnoteHeight aHeight( pOldBoss,
1904  pOldBoss->getFrameArea().Top() + pOldBoss->getFrameArea().Height() );
1905  pSect->GetUpper()->MoveLowerFootnotes( pNxtContent, pOldBoss,
1906  pLayLeaf->FindFootnoteBossFrame( true ), false );
1907  }
1908  }
1909  pNxt->MoveSubTree( pLayLeaf, pNew->GetNext() );
1910  }
1911  if( pNew->GetFollow() )
1912  pNew->SimpleFormat();
1913  }
1914  // The wanted layout sheet is now the first of the determined SctFrames:
1915  pLayLeaf = pNew ? FirstLeaf(pNew) : nullptr;
1916  }
1917  return pLayLeaf;
1918 }
1919 
1922 {
1924 
1925  SwLayoutFrame* pCol;
1926  // ColumnFrame always contain a BodyFrame now
1927  if( IsColBodyFrame() )
1928  pCol = GetUpper();
1929  else if( GetUpper()->IsColBodyFrame() )
1930  pCol = GetUpper()->GetUpper();
1931  else
1932  pCol = nullptr;
1933  bool bJump = false;
1934  if( pCol )
1935  {
1936  if( pCol->GetPrev() )
1937  {
1938  do
1939  {
1940  pCol = static_cast<SwLayoutFrame*>(pCol->GetPrev());
1941  // Is there any content?
1942  if( static_cast<SwLayoutFrame*>(pCol->Lower())->Lower() )
1943  {
1944  if( bJump ) // Did we skip a blank page?
1946  return static_cast<SwLayoutFrame*>(pCol->Lower()); // The columnm body
1947  }
1948  bJump = true;
1949  } while( pCol->GetPrev() );
1950 
1951  // We get here when all columns are empty, pCol is now the
1952  // first column, we need the body though
1953  pCol = static_cast<SwLayoutFrame*>(pCol->Lower());
1954  }
1955  else
1956  pCol = nullptr;
1957  }
1958 
1959  if( bJump ) // Did we skip a blank page?
1961 
1962  SwSectionFrame *pSect = FindSctFrame();
1963  if (!pCol && pSect && IsInTab() && CanContainSplitSection(this))
1964  {
1965  // We don't have a previous section yet, and we're in a
1966  // section-in-table.
1967  if (SwFlowFrame* pPrecede = pSect->GetPrecede())
1968  {
1969  // Our section has a precede, work with that.
1970  if (pPrecede->GetFrame().IsLayoutFrame())
1971  pCol = static_cast<SwLayoutFrame*>(&pPrecede->GetFrame());
1972  }
1973  }
1974 
1975  // Within sections in tables or section in headers/footers there can
1976  // be only one column change be made, one of the above shortcuts should
1977  // have applied, also when the section has a pPrev.
1978  // Now we even consider an empty column...
1979  OSL_ENSURE( pSect, "GetNextSctLeaf: Missing SectionFrame" );
1980  if (!pSect || (IsInTab() && !IsTabFrame()) || FindFooterOrHeader())
1981  return pCol;
1982 
1983  // === IMPORTANT ===
1984  // Precondition, which needs to be hold, is that the <this> frame can be
1985  // inside a table, but then the found section frame <pSect> is also inside
1986  // this table.
1987 
1988  // #i95698#
1989  // A table cell containing directly a section does not break - see lcl_FindSectionsInRow(..)
1990  // Thus, a table inside a section, which is inside another table can only
1991  // flow backward in the columns of its section.
1992  // Note: The table cell, which contains the section, can not have a master table cell.
1993  if ( IsTabFrame() && pSect->IsInTab() )
1994  {
1995  return pCol;
1996  }
1997 
1998  {
1999  if (SwFrame *pPrv = pSect->GetIndPrev())
2000  {
2001  // Mooching, half dead SectionFrames shouldn't confuse us
2002  while( pPrv && pPrv->IsSctFrame() && !static_cast<SwSectionFrame*>(pPrv)->GetSection() )
2003  pPrv = pPrv->GetPrev();
2004  if( pPrv )
2005  return pCol;
2006  }
2007  }
2008 
2009  const bool bBody = IsInDocBody();
2010  const bool bFly = IsInFly();
2011 
2012  SwLayoutFrame *pLayLeaf = GetPrevLayoutLeaf();
2013  SwLayoutFrame *pPrevLeaf = nullptr;
2014 
2015  while ( pLayLeaf )
2016  {
2017  // Never step into tables or sections
2018  if ( pLayLeaf->IsInTab() || pLayLeaf->IsInSct() )
2019  {
2020  pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
2021  }
2022  else if ( bBody && pLayLeaf->IsInDocBody() )
2023  {
2024  // If there is a pLayLeaf has a lower pLayLeaf is the frame we are looking for.
2025  // Exception: pLayLeaf->Lower() is a zombie section frame
2026  const SwFrame* pTmp = pLayLeaf->Lower();
2027  // OD 11.04.2003 #108824# - consider, that the zombie section frame
2028  // can have frame below it in the found layout leaf.
2029  // Thus, skipping zombie section frame, if possible.
2030  while ( pTmp && pTmp->IsSctFrame() &&
2031  !( static_cast<const SwSectionFrame*>(pTmp)->GetSection() ) &&
2032  pTmp->GetNext()
2033  )
2034  {
2035  pTmp = pTmp->GetNext();
2036  }
2037  if ( pTmp &&
2038  ( !pTmp->IsSctFrame() ||
2039  ( static_cast<const SwSectionFrame*>(pTmp)->GetSection() )
2040  )
2041  )
2042  {
2043  break;
2044  }
2045  pPrevLeaf = pLayLeaf;
2046  pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
2047  if ( pLayLeaf )
2049  }
2050  else if ( bFly )
2051  break; // Contents in Flys every layout sheet should be right. Why?
2052  else
2053  pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
2054  }
2055  if( !pLayLeaf )
2056  {
2057  if( !pPrevLeaf )
2058  return pCol;
2059  pLayLeaf = pPrevLeaf;
2060  }
2061 
2062  SwSectionFrame* pNew = nullptr;
2063  // At first go to the end of the layout sheet
2064  SwFrame *pTmp = pLayLeaf->Lower();
2065  if( pTmp )
2066  {
2067  while( pTmp->GetNext() )
2068  pTmp = pTmp->GetNext();
2069  if( pTmp->IsSctFrame() )
2070  {
2071  // Half dead ones only interfere here
2072  while( !static_cast<SwSectionFrame*>(pTmp)->GetSection() && pTmp->GetPrev() &&
2073  pTmp->GetPrev()->IsSctFrame() )
2074  pTmp = pTmp->GetPrev();
2075  if( static_cast<SwSectionFrame*>(pTmp)->GetFollow() == pSect )
2076  pNew = static_cast<SwSectionFrame*>(pTmp);
2077  }
2078  }
2079  if( !pNew )
2080  {
2081  pNew = new SwSectionFrame( *pSect, true );
2082  pNew->InsertBefore( pLayLeaf, nullptr );
2083  pNew->Init();
2084  SwRectFnSet aRectFnSet(pNew);
2085  aRectFnSet.MakePos( *pNew, pLayLeaf, pNew->GetPrev(), true );
2086 
2087  pLayLeaf = FirstLeaf( pNew );
2088  if( !pNew->Lower() ) // Format single column sections
2089  {
2090  pNew->MakePos();
2091  pLayLeaf->Format(getRootFrame()->GetCurrShell()->GetOut()); // In order that the PrtArea is correct for the MoveBwd
2092  }
2093  else
2094  pNew->SimpleFormat();
2095  }
2096  else
2097  {
2098  pLayLeaf = FirstLeaf( pNew );
2099  if( pLayLeaf->IsColBodyFrame() )
2100  {
2101  // In existent section columns we're looking for the last not empty
2102  // column.
2103  SwLayoutFrame *pTmpLay = pLayLeaf;
2104  while( pLayLeaf->GetUpper()->GetNext() )
2105  {
2106  pLayLeaf = static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(pLayLeaf->GetUpper()->GetNext())->Lower());
2107  if( pLayLeaf->Lower() )
2108  pTmpLay = pLayLeaf;
2109  }
2110  // If we skipped an empty column, we've to set the jump-flag
2111  if( pLayLeaf != pTmpLay )
2112  {
2113  pLayLeaf = pTmpLay;
2115  }
2116  }
2117  }
2118  return pLayLeaf;
2119 }
2120 
2121 static SwTwips lcl_DeadLine( const SwFrame* pFrame )
2122 {
2123  const SwLayoutFrame* pUp = pFrame->GetUpper();
2124  while( pUp && pUp->IsInSct() )
2125  {
2126  if( pUp->IsSctFrame() )
2127  pUp = pUp->GetUpper();
2128  // Columns now with BodyFrame
2129  else if( pUp->IsColBodyFrame() && pUp->GetUpper()->GetUpper()->IsSctFrame() )
2130  pUp = pUp->GetUpper()->GetUpper();
2131  else
2132  break;
2133  }
2134  SwRectFnSet aRectFnSet(pFrame);
2135  return pUp ? aRectFnSet.GetPrtBottom(*pUp) :
2136  aRectFnSet.GetBottom(pFrame->getFrameArea());
2137 }
2138 
2141 {
2142  SwRectFnSet aRectFnSet(this);
2143  if( aRectFnSet.YDiff( lcl_DeadLine( this ),
2144  aRectFnSet.GetBottom(getFrameArea()) ) > 0 )
2145  return true;
2146 
2147  return ( GetUpper() && const_cast<SwFrame*>(static_cast<SwFrame const *>(GetUpper()))->Grow( LONG_MAX, true ) );
2148 }
2149 
2151 {
2152  if ( !IsColLocked() && !HasFixSize() )
2153  {
2154  SwRectFnSet aRectFnSet(this);
2155  long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
2156  if( nFrameHeight > 0 && nDist > (LONG_MAX - nFrameHeight) )
2157  nDist = LONG_MAX - nFrameHeight;
2158 
2159  if ( nDist <= 0 )
2160  return 0;
2161 
2162  bool bInCalcContent = GetUpper() && IsInFly() && FindFlyFrame()->IsLocked();
2163  // OD 2004-03-15 #116561# - allow grow in online layout
2164  bool bGrow = !Lower() || !Lower()->IsColumnFrame() || !Lower()->GetNext();
2165  if (!bGrow)
2166  {
2167  SwSection* pSection = GetSection();
2168  bGrow = pSection && pSection->GetFormat()->GetBalancedColumns().GetValue();
2169  }
2170  if( !bGrow )
2171  {
2172  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
2173  bGrow = pSh && pSh->GetViewOptions()->getBrowseMode();
2174  }
2175  if( bGrow )
2176  {
2177  SwTwips nGrow;
2178  if( IsInFootnote() )
2179  nGrow = 0;
2180  else
2181  {
2182  nGrow = lcl_DeadLine( this );
2183  nGrow = aRectFnSet.YDiff( nGrow, aRectFnSet.GetBottom(getFrameArea()) );
2184  }
2185  SwTwips nSpace = nGrow;
2186  if( !bInCalcContent && nGrow < nDist && GetUpper() )
2187  nGrow = o3tl::saturating_add(
2188  nGrow, GetUpper()->Grow( LONG_MAX, true ));
2189 
2190  if( nGrow > nDist )
2191  nGrow = nDist;
2192  if( nGrow <= 0 )
2193  {
2194  nGrow = 0;
2195  if (!bTst)
2196  {
2197  if( bInCalcContent )
2198  InvalidateSize_();
2199  else
2200  InvalidateSize();
2201  }
2202  }
2203  else if( !bTst )
2204  {
2205  if( bInCalcContent )
2206  InvalidateSize_();
2207  else if( nSpace < nGrow && nDist != nSpace + GetUpper()->
2208  Grow( nGrow - nSpace ) )
2209  InvalidateSize();
2210  else
2211  {
2212  const SvxGraphicPosition ePos =
2214  if ( GPOS_RT < ePos && GPOS_TILED != ePos )
2215  {
2216  SetCompletePaint();
2217  InvalidatePage();
2218  }
2219  if( GetUpper() && GetUpper()->IsHeaderFrame() )
2220  GetUpper()->InvalidateSize();
2221  }
2222 
2223  {
2225  aRectFnSet.AddBottom( aFrm, nGrow );
2226  }
2227 
2228  {
2229  const long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea()) + nGrow;
2231  aRectFnSet.SetHeight( aPrt, nPrtHeight );
2232  }
2233 
2234  if( Lower() && Lower()->IsColumnFrame() && Lower()->GetNext() )
2235  {
2236  SwFrame* pTmp = Lower();
2237  do
2238  {
2239  pTmp->InvalidateSize_();
2240  pTmp = pTmp->GetNext();
2241  } while ( pTmp );
2242  InvalidateSize_();
2243  }
2244  if( GetNext() )
2245  {
2246  // Own height changed, need to invalidate the position of
2247  // next frames.
2248  SwFrame *pFrame = GetNext();
2249  while( pFrame && pFrame->IsSctFrame() && !static_cast<SwSectionFrame*>(pFrame)->GetSection() )
2250  {
2251  // Invalidate all in-between frames, otherwise position
2252  // calculation (which only looks back to one relative
2253  // frame) will have an incorrect result.
2254  InvalidateFramePos(pFrame, bInCalcContent);
2255  pFrame = pFrame->GetNext();
2256  }
2257  if( pFrame )
2258  {
2259  InvalidateFramePos(pFrame, bInCalcContent);
2260  }
2261  }
2262  // #i28701# - Due to the new object positioning
2263  // the frame on the next page/column can flow backward (e.g. it
2264  // was moved forward due to the positioning of its objects ).
2265  // Thus, invalivate this next frame, if document compatibility
2266  // option 'Consider wrapping style influence on object positioning' is ON.
2267  else if ( GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) )
2268  {
2270  }
2271  }
2272  return nGrow;
2273  }
2274  if ( !bTst )
2275  {
2276  if( bInCalcContent )
2277  InvalidateSize_();
2278  else
2279  InvalidateSize();
2280  }
2281  }
2282  return 0;
2283 }
2284 
2286 {
2287  if ( Lower() && !IsColLocked() && !HasFixSize() )
2288  {
2289  if( ToMaximize( false ) )
2290  {
2291  if( !bTst )
2292  InvalidateSize();
2293  }
2294  else
2295  {
2296  SwRectFnSet aRectFnSet(this);
2297  long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
2298  if ( nDist > nFrameHeight )
2299  nDist = nFrameHeight;
2300 
2301  if ( Lower()->IsColumnFrame() && Lower()->GetNext() && // FootnoteAtEnd
2302  !GetSection()->GetFormat()->GetBalancedColumns().GetValue() )
2303  { // With column bases the format takes over the control of the
2304  // growth (because of the balance)
2305  if ( !bTst )
2306  InvalidateSize();
2307  return nDist;
2308  }
2309  else if( !bTst )
2310  {
2311  const SvxGraphicPosition ePos =
2313  if ( GPOS_RT < ePos && GPOS_TILED != ePos )
2314  {
2315  SetCompletePaint();
2316  InvalidatePage();
2317  }
2318 
2319  {
2321  aRectFnSet.AddBottom( aFrm, -nDist );
2322  }
2323 
2324  {
2325  const long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea()) - nDist;
2327  aRectFnSet.SetHeight( aPrt, nPrtHeight );
2328  }
2329 
2330  // We do not allow a section frame to shrink the its upper
2331  // footer frame. This is because in the calculation of a
2332  // footer frame, the content of the section frame is _not_
2333  // calculated. If there is a fly frame overlapping with the
2334  // footer frame, the section frame is not affected by this
2335  // during the calculation of the footer frame size.
2336  // The footer frame does not grow in its FormatSize function
2337  // but during the calculation of the content of the section
2338  // frame. The section frame grows until some of its text is
2339  // located on top of the fly frame. The next call of CalcContent
2340  // tries to shrink the section and here it would also shrink
2341  // the footer. This may not happen, because shrinking the footer
2342  // would cause the top of the section frame to overlap with the
2343  // fly frame again, this would result in a perfect loop.
2344  if( GetUpper() && !GetUpper()->IsFooterFrame() )
2345  GetUpper()->Shrink( nDist, bTst );
2346 
2347  if( Lower() && Lower()->IsColumnFrame() && Lower()->GetNext() )
2348  {
2349  SwFrame* pTmp = Lower();
2350  do
2351  {
2352  pTmp->InvalidateSize_();
2353  pTmp = pTmp->GetNext();
2354  } while ( pTmp );
2355  }
2356  if( GetNext() )
2357  {
2358  SwFrame* pFrame = GetNext();
2359  while( pFrame && pFrame->IsSctFrame() && !static_cast<SwSectionFrame*>(pFrame)->GetSection() )
2360  pFrame = pFrame->GetNext();
2361  if( pFrame )
2362  pFrame->InvalidatePos();
2363  else
2364  SetRetouche();
2365  }
2366  else
2367  SetRetouche();
2368  return nDist;
2369  }
2370  }
2371  }
2372  return 0;
2373 }
2374 
2375 /*
2376 |* When are Frames within a SectionFrames moveable?
2377 |* If they are not in the last column of a SectionFrames yet,
2378 |* if there is no Follow,
2379 |* if the SectionFrame cannot grow anymore, then it gets more complicated,
2380 |* in that case it depends on whether the SectionFrame can find a next
2381 |* layout sheet. In (column based/chained) Flys this is checked via
2382 |* GetNextLayout, in tables and headers/footers there is none, however in the
2383 |* DocBody and in foot notes there is always one.
2384 |*
2385 |* This routine is used in the TextFormatter to decided whether it's allowed to
2386 |* create a (paragraph-)Follow or whether the paragraph has to stick together
2387 |*/
2388 bool SwSectionFrame::MoveAllowed( const SwFrame* pFrame) const
2389 {
2390  // Is there a Follow or is the Frame not in the last column?
2391  if( HasFollow() || ( pFrame->GetUpper()->IsColBodyFrame() &&
2392  pFrame->GetUpper()->GetUpper()->GetNext() ) )
2393  return true;
2394  if( pFrame->IsInFootnote() )
2395  {
2396  if( IsInFootnote() )
2397  {
2398  if( GetUpper()->IsInSct() )
2399  {
2400  if( Growable() )
2401  return false;
2402  return GetUpper()->FindSctFrame()->MoveAllowed( this );
2403  }
2404  else
2405  return true;
2406  }
2407  // The content of footnote inside a columned sectionfrm is moveable
2408  // except in the last column
2409  const SwLayoutFrame *pLay = pFrame->FindFootnoteFrame()->GetUpper()->GetUpper();
2410  if( pLay->IsColumnFrame() && pLay->GetNext() )
2411  {
2412  // The first paragraph in the first footnote in the first column
2413  // in the sectionfrm at the top of the page is not moveable,
2414  // if the columnbody is empty.
2415  bool bRet = false;
2416  if( pLay->GetIndPrev() || pFrame->GetIndPrev() ||
2417  pFrame->FindFootnoteFrame()->GetPrev() )
2418  bRet = true;
2419  else
2420  {
2421  const SwLayoutFrame* pBody = static_cast<const SwColumnFrame*>(pLay)->FindBodyCont();
2422  if( pBody && pBody->Lower() )
2423  bRet = true;
2424  }
2425  if( bRet && ( IsFootnoteAtEnd() || !Growable() ) )
2426  return true;
2427  }
2428  }
2429  // Or can the section still grow?
2430  if( !IsColLocked() && Growable() )
2431  return false;
2432  // Now it has to be examined whether there is a layout sheet wherein
2433  // a section Follow can be created
2434  if( !CanContainSplitSection(this) || ( !IsInDocBody() && FindFooterOrHeader() ) )
2435  return false; // It doesn't work in table-in-sections/nested tables/headers/footers
2436  if( IsInFly() ) // In column based or chained frames
2437  return nullptr != const_cast<SwFrame*>(static_cast<SwFrame const *>(GetUpper()))->GetNextLeaf( MAKEPAGE_NONE );
2438  return true;
2439 }
2440 
2449 {
2450  SwFrame *pRet = nullptr;
2451  // #i79774#
2452  // Do not assert, if the frame has a direct previous frame, because it
2453  // could be an empty section frame. The caller has to assure, that the
2454  // frame has no direct previous frame or only empty section frames as
2455  // previous frames.
2456  OSL_ENSURE( IsInSct(), "Why?" );
2457  const SwFrame* pSct = GetUpper();
2458  if( !pSct )
2459  return nullptr;
2460  if( pSct->IsSctFrame() )
2461  pRet = pSct->GetIndPrev();
2462  else if( pSct->IsColBodyFrame() && (pSct = pSct->GetUpper()->GetUpper())->IsSctFrame() )
2463  {
2464  // Do not return the previous frame of the outer section, if in one
2465  // of the previous columns is content.
2466  const SwFrame* pCol = GetUpper()->GetUpper()->GetPrev();
2467  while( pCol )
2468  {
2469  OSL_ENSURE( pCol->IsColumnFrame(), "GetIndPrev(): ColumnFrame expected" );
2470  OSL_ENSURE( pCol->GetLower() && pCol->GetLower()->IsBodyFrame(),
2471  "GetIndPrev(): Where's the body?");
2472  if( static_cast<const SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(pCol)->Lower())->Lower() )
2473  return nullptr;
2474  pCol = pCol->GetPrev();
2475  }
2476  pRet = pSct->GetIndPrev();
2477  }
2478 
2479  // skip empty section frames
2480  while( pRet && pRet->IsSctFrame() && !static_cast<SwSectionFrame*>(pRet)->GetSection() )
2481  pRet = pRet->GetIndPrev();
2482  return pRet;
2483 }
2484 
2486 {
2487  OSL_ENSURE( !mpNext && IsInSct(), "Why?" );
2488  SwFrame* pSct = GetUpper();
2489  if( !pSct )
2490  return nullptr;
2491  if( pSct->IsSctFrame() )
2492  return pSct->GetIndNext();
2493  if( pSct->IsColBodyFrame() && (pSct = pSct->GetUpper()->GetUpper())->IsSctFrame() )
2494  { // We can only return the successor of the SectionFrames if there is no
2495  // content in the successive columns
2496  SwFrame* pCol = GetUpper()->GetUpper()->GetNext();
2497  while( pCol )
2498  {
2499  OSL_ENSURE( pCol->IsColumnFrame(), "GetIndNext(): ColumnFrame expected" );
2500  OSL_ENSURE( pCol->GetLower() && pCol->GetLower()->IsBodyFrame(),
2501  "GetIndNext(): Where's the body?");
2502  if( static_cast<SwLayoutFrame*>(static_cast<SwLayoutFrame*>(pCol)->Lower())->Lower() )
2503  return nullptr;
2504  pCol = pCol->GetNext();
2505  }
2506  return pSct->GetIndNext();
2507  }
2508  return nullptr;
2509 }
2510 
2512 {
2513  if( !m_pSection || !pFormat )
2514  return false;
2515  const SwSectionFormat *pMyFormat = m_pSection->GetFormat();
2516  while( pFormat != pMyFormat )
2517  {
2518  if( dynamic_cast< const SwSectionFormat *>( pMyFormat->GetRegisteredIn()) != nullptr )
2519  pMyFormat = static_cast<const SwSectionFormat*>(pMyFormat->GetRegisteredIn());
2520  else
2521  return false;
2522  }
2523  return true;
2524 }
2525 
2527 {
2528  SwSectionFormat *pFormat = GetSection()->GetFormat();
2529  sal_uInt16 nVal = pFormat->GetFootnoteAtTextEnd( false ).GetValue();
2533  while( !m_bFootnoteAtEnd && !m_bOwnFootnoteNum )
2534  {
2535  if( dynamic_cast< const SwSectionFormat *>( pFormat->GetRegisteredIn()) != nullptr )
2536  pFormat = static_cast<SwSectionFormat*>(pFormat->GetRegisteredIn());
2537  else
2538  break;
2539  nVal = pFormat->GetFootnoteAtTextEnd( false ).GetValue();
2540  if( FTNEND_ATPGORDOCEND != nVal )
2541  {
2542  m_bFootnoteAtEnd = true;
2545  }
2546  }
2547 }
2548 
2550 {
2551  return m_pSection->GetFormat()->GetEndAtTextEnd( false ).IsAtEnd();
2552 }
2553 
2555 {
2556  SwSectionFormat *pFormat = GetSection()->GetFormat();
2557  m_bEndnAtEnd = pFormat->GetEndAtTextEnd( false ).IsAtEnd();
2558  while( !m_bEndnAtEnd )
2559  {
2560  if( dynamic_cast< const SwSectionFormat *>( pFormat->GetRegisteredIn()) != nullptr )
2561  pFormat = static_cast<SwSectionFormat*>(pFormat->GetRegisteredIn());
2562  else
2563  break;
2564  m_bEndnAtEnd = pFormat->GetEndAtTextEnd( false ).IsAtEnd();
2565  }
2566 }
2567 
2568 void SwSectionFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
2569 {
2570  sal_uInt8 nInvFlags = 0;
2571 
2572  if( pNew && RES_ATTRSET_CHG == pNew->Which() )
2573  {
2574  SfxItemIter aNIter( *static_cast<const SwAttrSetChg*>(pNew)->GetChgSet() );
2575  SfxItemIter aOIter( *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet() );
2576  const SfxPoolItem* pNItem = aNIter.GetCurItem();
2577  const SfxPoolItem* pOItem = aOIter.GetCurItem();
2578  SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
2579  SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
2580  do
2581  {
2582  UpdateAttr_(pOItem, pNItem, nInvFlags, &aOldSet, &aNewSet);
2583  pNItem = aNIter.NextItem();
2584  pOItem = aOIter.NextItem();
2585  } while (pNItem);
2586  if ( aOldSet.Count() || aNewSet.Count() )
2587  SwLayoutFrame::Modify( &aOldSet, &aNewSet );
2588  }
2589  else
2590  UpdateAttr_( pOld, pNew, nInvFlags );
2591 
2592  if ( nInvFlags != 0 )
2593  {
2594  if ( nInvFlags & 0x01 )
2595  InvalidateSize();
2596  if ( nInvFlags & 0x10 )
2597  SetCompletePaint();
2598  }
2599 }
2600 
2601 void SwSectionFrame::SwClientNotify( const SwModify& rMod, const SfxHint& rHint )
2602 {
2603  SwFrame::SwClientNotify(rMod, rHint);
2604  // #i117863#
2605  if(&rMod != GetDep())
2606  return;
2607  const auto pHint = dynamic_cast<const SwSectionFrameMoveAndDeleteHint*>(&rHint);
2608  if(!pHint)
2609  return;
2610  SwSectionFrame::MoveContentAndDelete( this, pHint->IsSaveContent() );
2611 }
2612 
2613 void SwSectionFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
2614  sal_uInt8 &rInvFlags,
2615  SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
2616 {
2617  bool bClear = true;
2618  const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
2619  switch( nWhich )
2620  { // Suppress multi columns in foot notes
2621  case RES_FMT_CHG:
2622  {
2623  const SwFormatCol& rNewCol = GetFormat()->GetCol();
2624  if( !IsInFootnote() )
2625  {
2626  // Nasty case. When allocating a template we can not count
2627  // on the old column attribute. We're left with creating a
2628  // temporary attribute here.
2629  SwFormatCol aCol;
2630  if ( Lower() && Lower()->IsColumnFrame() )
2631  {
2632  sal_uInt16 nCol = 0;
2633  SwFrame *pTmp = Lower();
2634  do
2635  { ++nCol;
2636  pTmp = pTmp->GetNext();
2637  } while ( pTmp );
2638  aCol.Init( nCol, 0, 1000 );
2639  }
2640  bool bChgFootnote = IsFootnoteAtEnd();
2641  bool const bChgEndn = IsEndnAtEnd();
2642  bool const bChgMyEndn = IsEndnoteAtMyEnd();
2644  CalcEndAtEndFlag();
2645  bChgFootnote = ( bChgFootnote != IsFootnoteAtEnd() ) ||
2646  ( bChgEndn != IsEndnAtEnd() ) ||
2647  ( bChgMyEndn != IsEndnoteAtMyEnd() );
2648  ChgColumns( aCol, rNewCol, bChgFootnote );
2649  rInvFlags |= 0x10;
2650  }
2651  rInvFlags |= 0x01;
2652  bClear = false;
2653  }
2654  break;
2655 
2656  case RES_COL:
2657  if( !IsInFootnote() )
2658  {
2659  assert(pOld && pNew);
2660  if (pOld && pNew)
2661  {
2662  ChgColumns( *static_cast<const SwFormatCol*>(pOld), *static_cast<const SwFormatCol*>(pNew) );
2663  rInvFlags |= 0x11;
2664  }
2665  }
2666  break;
2667 
2668  case RES_FTN_AT_TXTEND:
2669  if( !IsInFootnote() )
2670  {
2671  bool const bOld = IsFootnoteAtEnd();
2673  if (bOld != IsFootnoteAtEnd())
2674  {
2675  const SwFormatCol& rNewCol = GetFormat()->GetCol();
2676  ChgColumns( rNewCol, rNewCol, true );
2677  rInvFlags |= 0x01;
2678  }
2679  }
2680  break;
2681 
2682  case RES_END_AT_TXTEND:
2683  if( !IsInFootnote() )
2684  {
2685  bool const bOld = IsEndnAtEnd();
2686  bool const bMyOld = IsEndnoteAtMyEnd();
2687  CalcEndAtEndFlag();
2688  if (bOld != IsEndnAtEnd() || bMyOld != IsEndnoteAtMyEnd())
2689  {
2690  const SwFormatCol& rNewCol = GetFormat()->GetCol();
2691  ChgColumns( rNewCol, rNewCol, true );
2692  rInvFlags |= 0x01;
2693  }
2694  }
2695  break;
2696  case RES_COLUMNBALANCE:
2697  rInvFlags |= 0x01;
2698  break;
2699 
2700  case RES_FRAMEDIR :
2701  SetDerivedR2L( false );
2702  CheckDirChange();
2703  break;
2704 
2705  case RES_PROTECT:
2706  {
2708  if( pSh && pSh->GetLayout()->IsAnyShellAccessible() )
2709  pSh->Imp()->InvalidateAccessibleEditableState( true, this );
2710  }
2711  break;
2712 
2713  default:
2714  bClear = false;
2715  }
2716  if ( bClear )
2717  {
2718  if ( pOldSet || pNewSet )
2719  {
2720  if ( pOldSet )
2721  pOldSet->ClearItem( nWhich );
2722  if ( pNewSet )
2723  pNewSet->ClearItem( nWhich );
2724  }
2725  else
2726  SwLayoutFrame::Modify( pOld, pNew );
2727  }
2728 }
2729 
2731 bool SwSectionFrame::ToMaximize( bool bCheckFollow ) const
2732 {
2733  if( HasFollow() )
2734  {
2735  if( !bCheckFollow ) // Don't check superfluous follows
2736  return true;
2737  const SwSectionFrame* pFoll = GetFollow();
2738  while( pFoll && pFoll->IsSuperfluous() )
2739  pFoll = pFoll->GetFollow();
2740  if( pFoll )
2741  return true;
2742  }
2743  if( IsFootnoteAtEnd() )
2744  return false;
2745  const SwFootnoteContFrame* pCont = ContainsFootnoteCont();
2746  if( !IsEndnAtEnd() )
2747  return nullptr != pCont;
2748  bool bRet = false;
2749  while( pCont && !bRet )
2750  {
2751  if( pCont->FindFootNote() )
2752  bRet = true;
2753  else
2754  pCont = ContainsFootnoteCont( pCont );
2755  }
2756  return bRet;
2757 }
2758 
2761 {
2762  SwFootnoteContFrame* pRet = nullptr;
2763  const SwLayoutFrame* pLay;
2764  if( pCont )
2765  {
2766  pLay = pCont->FindFootnoteBossFrame();
2767  OSL_ENSURE( IsAnLower( pLay ), "ConatainsFootnoteCont: Wrong FootnoteContainer" );
2768  pLay = static_cast<const SwLayoutFrame*>(pLay->GetNext());
2769  }
2770  else if( Lower() && Lower()->IsColumnFrame() )
2771  pLay = static_cast<const SwLayoutFrame*>(Lower());
2772  else
2773  pLay = nullptr;
2774  while ( !pRet && pLay )
2775  {
2776  if( pLay->Lower() && pLay->Lower()->GetNext() )
2777  {
2778  OSL_ENSURE( pLay->Lower()->GetNext()->IsFootnoteContFrame(),
2779  "ToMaximize: Unexpected Frame" );
2780  pRet = const_cast<SwFootnoteContFrame*>(static_cast<const SwFootnoteContFrame*>(pLay->Lower()->GetNext()));
2781  }
2782  OSL_ENSURE( !pLay->GetNext() || pLay->GetNext()->IsLayoutFrame(),
2783  "ToMaximize: ColFrame expected" );
2784  pLay = static_cast<const SwLayoutFrame*>(pLay->GetNext());
2785  }
2786  return pRet;
2787 }
2788 
2790 {
2792  if( pCont )
2793  {
2794  SwFrame *pTmp = pCont->ContainsContent();
2795  if( pTmp )
2796  pTmp->InvalidatePos_();
2797  }
2798 }
2799 
2801 {
2802  SwRectFnSet aRectFnSet(this);
2803  return InnerHeight() - aRectFnSet.GetHeight(getFramePrintArea());
2804 }
2805 
2807 {
2808  const auto nRet = CalcUndersize();
2809  m_bUndersized = (nRet > 0);
2810  return nRet <= 0 ? 0 : nRet;
2811 }
2812 
2814 {
2815  vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
2817  if( pCont )
2818  {
2819  SwFrame* pFrame = pCont->ContainsAny();
2820  if( pFrame )
2821  pCont->Calc(pRenderContext);
2822  while( pFrame && IsAnLower( pFrame ) )
2823  {
2824  SwFootnoteFrame* pFootnote = pFrame->FindFootnoteFrame();
2825  if( pFootnote )
2826  pFootnote->Calc(pRenderContext);
2827  pFrame->Calc(pRenderContext);
2828  if( pFrame->IsSctFrame() )
2829  {
2830  SwFrame *pTmp = static_cast<SwSectionFrame*>(pFrame)->ContainsAny();
2831  if( pTmp )
2832  {
2833  pFrame = pTmp;
2834  continue;
2835  }
2836  }
2837  pFrame = pFrame->FindNext();
2838  }
2839  }
2840 }
2841 
2842 /*
2843  * If a SectionFrame gets empty, e.g. because its content changes the page/column,
2844  * it is not destroyed immediately (there could be a pointer left to it on the
2845  * stack), instead it puts itself in a list at the RootFrame, which is processed
2846  * later on (in Layaction::Action among others). Its size is set to Null and
2847  * the pointer to its page as well. Such SectionFrames that are to be deleted
2848  * must be ignored by the layout/during formatting.
2849  *
2850  * With InsertEmptySct the RootFrame stores a SectionFrame in the list,
2851  * with RemoveFromList it can be removed from the list (Dtor),
2852  * with DeleteEmptySct the list is processed and the SectionFrames are destroyed.
2853  */
2855 {
2856  if( !mpDestroy )
2857  mpDestroy.reset( new SwDestroyList );
2858  mpDestroy->insert( pDel );
2859 }
2860 
2862 {
2863  assert(mpDestroy);
2864  while( !mpDestroy->empty() )
2865  {
2866  SwSectionFrame* pSect = *mpDestroy->begin();
2867  mpDestroy->erase( mpDestroy->begin() );
2868  OSL_ENSURE( !pSect->IsColLocked() && !pSect->IsJoinLocked(),
2869  "DeleteEmptySct: Locked SectionFrame" );
2870  if( !pSect->getFrameArea().HasArea() && !pSect->ContainsContent() )
2871  {
2872  SwLayoutFrame* pUp = pSect->GetUpper();
2873  pSect->RemoveFromLayout();
2874  SwFrame::DestroyFrame(pSect);
2875  if( pUp && !pUp->Lower() )
2876  {
2877  if( pUp->IsPageBodyFrame() )
2878  pUp->getRootFrame()->SetSuperfluous();
2879  else if( pUp->IsFootnoteFrame() && !pUp->IsColLocked() &&
2880  pUp->GetUpper() )
2881  {
2882  pUp->Cut();
2883  SwFrame::DestroyFrame(pUp);
2884  }
2885  }
2886  }
2887  else {
2888  OSL_ENSURE( pSect->GetSection(), "DeleteEmptySct: Half-dead SectionFrame?!" );
2889  }
2890  }
2891 }
2892 
2894 {
2895  assert(mpDestroy && "Where's my list?");
2896  mpDestroy->erase( pSct );
2897 }
2898 
2899 #ifdef DBG_UTIL
2901 {
2902  return mpDestroy && mpDestroy->find( pSct ) != mpDestroy->end();
2903 }
2904 #endif
2905 
2907 {
2908  bool bRet = false;
2909  if ( GetSection() && Lower() && Lower()->IsColumnFrame() && Lower()->GetNext() )
2910  {
2911  bRet = !GetSection()->GetFormat()->GetBalancedColumns().GetValue();
2912  }
2913  return bRet;
2914 }
2915 
2916 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InsertBefore(SwLayoutFrame *pParent, SwFrame *pBehind)
Insert SwFrame into existing structure.
Definition: wsfrm.cxx:820
long GetLeft() const
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:206
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:341
bool GetValue() const
long Width() const
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:547
SwSectionFrame * FindMaster() const
Definition: flowfrm.cxx:695
constexpr TypedWhichId< SvxProtectItem > RES_PROTECT(100)
Base class of the Writer layout elements.
Definition: frame.hxx:297
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:151
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SwFormatEndAtTextEnd > RES_END_AT_TXTEND(118)
void InvalidateInfFlags()
Definition: frame.hxx:588
static void lcl_InvalidateInfFlags(SwFrame *pFrame, bool bInva)
|* MoveContent is called for destroying a SectionFrames, due to |* the cancellation or hiding of a se...
Definition: sectfrm.cxx:556
long BottomDist(const SwRect &rRect, long nPos) const
Definition: frame.hxx:1392
void CalcFootnoteAtEndFlag()
Definition: sectfrm.cxx:2526
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: sectfrm.cxx:2601
bool MoveAllowed(const SwFrame *) const
Definition: sectfrm.cxx:2388
bool IsFollow() const
Definition: flowfrm.hxx:166
SwTwips Shrink_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2285
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:545
void RemoveFromList(SwSectionFrame *pSct)
Definition: rootfrm.hxx:376
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
SwFrame * mpNext
Definition: frame.hxx:321
bool IsEndnAtEnd() const
Definition: sectfrm.hxx:148
bool IsInDocBody() const
Definition: frame.hxx:921
bool IsInFly() const
Definition: frame.hxx:939
virtual ~SwSectionFrame() override
Definition: sectfrm.cxx:181
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1462
long YInc(long n1, long n2) const
Definition: frame.hxx:1403
SwFindMode
Definition: sectfrm.hxx:31
bool IsInSct() const
Definition: frame.hxx:945
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"Formats" the Frame; Frame and PrtArea.
Definition: wsfrm.cxx:3353
static void SetMoveBwdJump(bool bNew)
Definition: flowfrm.hxx:155
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:384
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
void DelEmpty(bool bRemove)
Definition: sectfrm.cxx:185
const SvxBrushItem & GetBackground(bool=true) const
Definition: frmatr.hxx:58
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"formats" the frame; Frame and PrtArea
Definition: sectfrm.cxx:1330
void ColLock()
Definition: sectfrm.hxx:86
std::string GetValue
bool IsColLocked() const
Definition: frame.hxx:864
bool SplitSect(SwFrame *pFrame, bool bApres)
Splits the SectionFrame surrounding the pFrame up in two parts: pFrame and the start of the 2nd part...
Definition: sectfrm.cxx:506
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
bool IsBefore(const SwLayoutFrame *_pCheckRefLayFrame) const
method to check relative position of layout frame to a given layout frame.
Definition: findfrm.cxx:233
long Height() const
void InvalidateFootnotePos()
Definition: sectfrm.cxx:2789
void SetCompletePaint() const
Definition: frame.hxx:972
bool IsInFootnote() const
Definition: frame.hxx:927
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:587
SwModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:459
void FormatWidthCols(const SwBorderAttrs &, const SwTwips nBorder, const SwTwips nMinHeight)
Called by Format for Frames and Areas with columns.
Definition: wsfrm.cxx:3618
SwFrameType GetType() const
Definition: frame.hxx:500
void SetDerivedR2L(bool bNew)
Definition: frame.hxx:612
#define PROTOCOL(pFrame, nFunc, nAct, pPar)
Definition: dbg_lay.hxx:88
-""- and with own numberformat
Definition: fmtftntx.hxx:33
const SwRect & getFramePrintArea() const
Definition: frame.hxx:178
#define MINLAY
Definition: swtypes.hxx:66
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: wsfrm.cxx:474
void InvalidateSize_()
Definition: frame.hxx:751
SwFrame * FindPrev()
Definition: frame.hxx:1133
bool HasFollow() const
Definition: flowfrm.hxx:165
void Height(long nNew)
Definition: swrect.hxx:191
void InvalidatePos()
Definition: frame.hxx:1021
long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1356
void Cut_(bool bRemove)
Definition: sectfrm.cxx:254
bool IsSuperfluous() const
Definition: sectfrm.hxx:50
SwTwips Undersize()
Returns the size delta that the section would like to be greater if it has undersized TextFrames in i...
Definition: sectfrm.cxx:2806
long SwTwips
Definition: swtypes.hxx:49
bool IsVert() const
Definition: frame.hxx:1345
SwSectionFormat * GetFormat()
Definition: section.hxx:337
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:382
virtual void DestroyImpl() override
Definition: sectfrm.cxx:148
bool IsEndNote() const
Definition: fmtftn.hxx:74
SwFrame * FindNext()
Definition: frame.hxx:1119
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1785
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:108
void UpdateAttr_(const SfxPoolItem *, const SfxPoolItem *, sal_uInt8 &, SwAttrSetChg *pa=nullptr, SwAttrSetChg *pb=nullptr)
Definition: sectfrm.cxx:2613
bool IsCellFrame() const
Definition: frame.hxx:1204
bool IsFootnotePage() const
Foot note interface.
Definition: pagefrm.hxx:185
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2609
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
bool HasToBreak(const SwFrame *pFrame) const
|* Here it's decided whether the this-SectionFrame should break up |* the passed (Section)frm (or not...
Definition: sectfrm.cxx:440
css::chart::ChartAxisLabelPosition ePos
bool IsFootnoteFrame() const
Definition: frame.hxx:1180
bool ToMaximize(bool bCheckFollow) const
A sectionfrm has to maximize, if he has a follow or a ftncontainer at the end of the page...
Definition: sectfrm.cxx:2731
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:169
SwLayoutFrame * GetPrevSctLeaf()
Returns the preceding layout sheet where the frame can be moved into.
Definition: sectfrm.cxx:1921
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:190
long YDiff(long n1, long n2) const
Definition: frame.hxx:1401
void SetRetouche() const
Definition: frame.hxx:981
GPOS_TILED
SwTwips CalcUpperSpace(const SwBorderAttrs *pAttrs=nullptr, const SwFrame *pPr=nullptr, const bool _bConsiderGrid=true) const
method to determine the upper space hold by the frame
Definition: flowfrm.cxx:1387
bool IsFlyFrame() const
Definition: frame.hxx:1188
const SfxPoolItem * NextItem()
void ChgLowersProp(const Size &rOldSize)
Change size of lowers proportionally.
Definition: wsfrm.cxx:2954
wrapper class for the positioning of Writer fly frames and drawing objects
friend SwFrame * SaveContent(SwLayoutFrame *, SwFrame *)
Definition: frmtool.cxx:2668
SvxGraphicPosition GetGraphicPos() const
long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1388
SwSection * m_pSection
Definition: sectfrm.hxx:38
void Top(const long nTop)
Definition: swrect.hxx:204
SwTwips Grow_(SwTwips, bool bTst)
Definition: sectfrm.cxx:2150
const SwFormatNoBalancedColumns & GetBalancedColumns(bool=true) const
Definition: fmtclbl.hxx:42
const SwLayoutFrame * GetPrevLayoutLeaf() const
Definition: frame.hxx:1002
const SwRect & getFrameArea() const
Definition: frame.hxx:177
bool getBrowseMode() const
Definition: viewopt.hxx:445
SwLayoutFrame * GetNextLeaf(MakePageType eMakePage)
Returns the next layout leaf in which we can move the frame.
Definition: flowfrm.cxx:901
void CollectEndnote(SwFootnoteFrame *pFootnote)
Definition: layouter.cxx:224
bool IsInTab() const
Definition: frame.hxx:933
bool m_bUndersized
Definition: flowfrm.hxx:121
at page or document end
Definition: fmtftntx.hxx:30
static SwTwips lcl_DeadLine(const SwFrame *pFrame)
Definition: sectfrm.cxx:2121
void RemoveFromList_(SwSectionFrame *pSct)
Definition: sectfrm.cxx:2893
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool &rReformat) override
Definition: sectfrm.cxx:856
const SwContentFrame * FindLastContent() const
Definition: sectfrm.hxx:168
static SwFootnoteFrame * lcl_FindEndnote(SwSectionFrame *&rpSect, bool &rbEmpty, SwLayouter *pLayouter)
CollectEndnotes looks for endnotes in the sectionfrm and his follows, the endnotes will cut off the l...
Definition: sectfrm.cxx:960
bool IsTextFrame() const
Definition: frame.hxx:1212
void SetSuperfluous()
Remove superfluous Pages.
Definition: rootfrm.hxx:296
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(161)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(160)
static void lcl_FindContentFrame(SwContentFrame *&rpContentFrame, SwFootnoteFrame *&rpFootnoteFrame, SwFrame *pFrame, bool &rbChkFootnote)
Definition: sectfrm.cxx:875
void setFramePrintAreaValid(bool bNew)
Definition: wsfrm.cxx:97
const SwFormatFootnoteAtTextEnd & GetFootnoteAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:111
bool IsPageBodyFrame() const
Definition: layfrm.hxx:214
bool IsSctFrame() const
Definition: frame.hxx:1192
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1089
virtual void DestroyImpl() override
Definition: ssfrm.cxx:473
SwFrame * GetIndPrev_() const
Called for a frame inside a section with no direct previous frame (or only previous empty section fra...
Definition: sectfrm.cxx:2448
SwTwips CalcUndersize() const
Definition: sectfrm.cxx:2800
bool IsFlowFrame() const
Definition: frame.hxx:1220
static void MoveContentAndDelete(SwSectionFrame *pDel, bool bSave)
Definition: sectfrm.cxx:661
void SetBottom(SwRect &rRect, long nNew) const
Definition: frame.hxx:1365
SwLayoutFrame * GetNextCellLeaf()
Definition: findfrm.cxx:1511
SwLayoutFrame * GetNextSctLeaf(MakePageType eMakePage)
Returns the next layout sheet where the frame can be moved in.
Definition: sectfrm.cxx:1568
bool IsDescendantFrom(const SwSectionFormat *pSect) const
Definition: sectfrm.cxx:2511
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
void InvalidateContent() const
Definition: pagefrm.hxx:363
void SetUndersized(const bool bNew)
Definition: flowfrm.hxx:157
long const nTopMargin
bool IsColumnFrame() const
Definition: frame.hxx:1160
void SetHeight(SwRect &rRect, long nNew) const
Definition: frame.hxx:1369
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1085
bool IsInDtor() const
Definition: frame.hxx:870
void CalcContent(SwLayoutFrame *pLay, bool bNoColl=false)
Definition: fly.cxx:1353
static SwContentFrame * lcl_GetNextContentFrame(const SwLayoutFrame *pLay, bool bFwd)
Definition: sectfrm.cxx:574
Style of a layout element.
Definition: frmfmt.hxx:57
bool IsBalancedSection() const
Definition: sectfrm.cxx:2906
void SetWidth(SwRect &rRect, long nNew) const
Definition: frame.hxx:1368
bool IsContentFrame() const
Definition: frame.hxx:1208
bool m_bFootnoteAtEnd
Definition: sectfrm.hxx:39
SwFrame * GetIndPrev() const
Definition: frame.hxx:704
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:118
const SwFrame * GetLastLower() const
Definition: findfrm.cxx:1817
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: sectfrm.cxx:334
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:2534
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: sectfrm.cxx:766
SwFrame * GetIndNext()
Definition: frame.hxx:707
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:160
SwPageFrame * FindPageFrame()
Definition: frame.hxx:660
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:865
SwFrame * m_pLower
Definition: layfrm.hxx:53
virtual void Cut() override
Definition: wsfrm.cxx:1393
const SwFrame * Lower() const
Definition: layfrm.hxx:101
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:190
std::enable_if< std::is_signed< T >::value, T >::type saturating_add(T a, T b)
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:597
SwSection * GetSection()
Definition: sectfrm.hxx:84
bool IsJoinLocked() const
Definition: flowfrm.hxx:175
void ChgColumns(const SwFormatCol &rOld, const SwFormatCol &rNew, const bool bChgFootnote=false)
add or remove columns from a layoutframe.
Definition: colfrm.cxx:184
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:91
SwLayoutFrame * GetUpper()
Definition: frame.hxx:658
void InsertEmptySct(SwSectionFrame *pDel)
Empty SwSectionFrames are registered here for deletion and destroyed later on or deregistered.
Definition: sectfrm.cxx:2854
bool HasArea() const
Definition: swrect.hxx:288
SvxGraphicPosition
bool isFramePrintAreaValid() const
Definition: frame.hxx:166
bool IsUndersized() const
Definition: flowfrm.hxx:158
static sal_uInt8 Count()
Definition: frmtool.hxx:468
void LockJoin()
Definition: flowfrm.hxx:139
long GetTopMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1381
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: sectfrm.cxx:2568
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
Definition: findfrm.cxx:435
friend void RestoreContent(SwFrame *, SwLayoutFrame *, SwFrame *pSibling)
Definition: frmtool.cxx:2831
SwFrame * GetPrev()
Definition: frame.hxx:657
bool isFrameAreaPositionValid() const
Definition: frame.hxx:164
void CalcEndAtEndFlag()
Definition: sectfrm.cxx:2554
void SetYMargins(SwFrame &rFrame, long nTop, long nBottom) const
Definition: frame.hxx:1386
void SSize(const Size &rNew)
Definition: swrect.hxx:178
const SwFormatEndAtTextEnd & GetEndAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:113
bool HasFixSize() const
Definition: frame.hxx:650
bool isFrameAreaSizeValid() const
Definition: frame.hxx:165
bool InsertGroupBefore(SwFrame *pParent, SwFrame *pWhere, SwFrame *pSct)
Insert a chain of SwFrames into an existing structure.
Definition: wsfrm.cxx:893
void AddBottom(SwRect &rRect, long nNew) const
Definition: frame.hxx:1372
void InvalidatePos_()
Definition: frame.hxx:767
SwCellFrame * GetFollowCell() const
Definition: findfrm.cxx:1579
A page of the document layout.
Definition: pagefrm.hxx:40
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:200
const long LONG_MAX
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1507
void InvalidateSize()
Definition: frame.hxx:1007
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1093
SwSectionFormat * GetParent() const
Definition: section.hxx:356
const SwFootnoteFrame * GetMaster() const
Definition: ftnfrm.hxx:119
void SetLeft(SwRect &rRect, long nNew) const
Definition: frame.hxx:1366
void InvalidateAccessibleParaFlowRelation(const SwTextFrame *_pFromTextFrame, const SwTextFrame *_pToTextFrame)
invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
Definition: viewsh.cxx:2424
void CollectEndnotes(SwLayouter *pLayouter)
Definition: sectfrm.cxx:1039
const SwFootnoteFrame * FindFootNote() const
Definition: findfrm.cxx:564
void setFrameAreaPositionValid(bool bNew)
Definition: wsfrm.cxx:81
static void lcl_ColumnRefresh(SwSectionFrame *pSect, bool bFollow)
Definition: sectfrm.cxx:1011
long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1359
sal_uInt16 Count() const
Definition: hints.hxx:245
bool IsLayoutFrame() const
Definition: frame.hxx:1148
bool Growable() const
checks whether the SectionFrame is still able to grow, as case may be the environment has to be asked...
Definition: sectfrm.cxx:2140
const SwFlowFrame * GetPrecede() const
Definition: flowfrm.hxx:172
void SetXMargins(SwFrame &rFrame, long nLeft, long nRight) const
Definition: frame.hxx:1385
void MoveSubTree(SwLayoutFrame *pParent, SwFrame *pSibling=nullptr)
hook tree onto new parent with minimal operations and notifications
Definition: flowfrm.cxx:576
MakePageType
Definition: frame.hxx:110
bool IsTabFrame() const
Definition: frame.hxx:1196
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
void UnlockJoin()
Definition: flowfrm.hxx:140
bool m_bEndnAtEnd
Definition: sectfrm.hxx:40
void SimpleFormat()
Definition: sectfrm.cxx:1160
bool IsLocked() const
Definition: flyfrm.hxx:191
void ColUnlock()
Definition: sectfrm.hxx:87
unsigned char sal_uInt8
bool MoveLowerFootnotes(SwContentFrame *pStart, SwFootnoteBossFrame *pOldBoss, SwFootnoteBossFrame *pNewBoss, const bool bFootnoteNums)
Moving the Footnotes of all Lowers - starting from StartContent.
Definition: ftnfrm.cxx:2629
const SwSectionFormat * GetEndSectFormat_() const
Definition: sectfrm.cxx:862
friend void CalcContent(SwLayoutFrame *pLay, bool bNoColl)
Definition: fly.cxx:1353
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:426
void Width(long nNew)
Definition: swrect.hxx:187
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:125
constexpr TypedWhichId< SwFormatNoBalancedColumns > RES_COLUMNBALANCE(119)
void InvalidateAll_()
Definition: frame.hxx:783
void InsertBehind(SwLayoutFrame *pParent, SwFrame *pBefore)
Insert SwFrame into existing structure.
Definition: wsfrm.cxx:855
const SwSectionFormat * GetEndSectFormat() const
Definition: sectfrm.hxx:136
void DeleteEmptySct_()
Definition: sectfrm.cxx:2861
void RemoveFromLayout()
Definition: wsfrm.cxx:994
bool m_bOwnFootnoteNum
Definition: sectfrm.hxx:42
bool IsAnyNoteAtEnd() const
Definition: sectfrm.hxx:149
void InvalidateNextPos(bool bNoFootnote=false)
Definition: frame.hxx:1050
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
bool IsColBodyFrame() const
These SwFrame inlines are here, so that frame.hxx does not need to include layfrm.hxx.
Definition: layfrm.hxx:209
void setFrameAreaSizeValid(bool bNew)
Definition: wsfrm.cxx:89
void CheckClipping(bool bGrow, bool bMaximize)
Adapt size to surroundings.
Definition: sectfrm.cxx:1067
SwFrame * GetLower()
Definition: findfrm.cxx:169
SwFrameType mnFrameType
Definition: frame.hxx:397
bool IsPageFrame() const
Definition: frame.hxx:1156
void * p
const SwTextFootnote * GetAttr() const
Definition: ftnfrm.hxx:122
virtual void Cut() override
Definition: sectfrm.cxx:249
long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1360
static bool IsLocked()
Definition: frmtool.hxx:467
long GetRight() const
-""- and with own number sequence
Definition: fmtftntx.hxx:32
void CalcFootnoteContent()
Definition: sectfrm.cxx:2813
bool IsContentLocked() const
Definition: sectfrm.hxx:152
void MakePos(SwFrame &rFrame, const SwFrame *pUp, const SwFrame *pPrv, bool bNotify) const
Definition: frame.hxx:1399
void InvalidateAccessibleEditableState(bool bAllShells, const SwFrame *pFrame=nullptr)
Invalidate editable state for all accessible frames.
Definition: viewimp.cxx:348
sal_uInt16 GetNumCols() const
Definition: fmtclds.hxx:114
SwFootnoteContFrame * ContainsFootnoteCont(const SwFootnoteContFrame *pCont=nullptr) const
Check every Column for FootnoteContFrames.
Definition: sectfrm.cxx:2760
long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1355
void InvalidatePrt_()
Definition: frame.hxx:759
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:128
#define SAL_WARN(area, stream)
bool IsFootnoteAtEnd() const
Definition: sectfrm.hxx:147
bool IsInDelList(SwSectionFrame *pSct) const
Definition: sectfrm.cxx:2900
void AdjustColumns(const SwFormatCol *pCol, bool bAdjustAttributes)
Definition: colfrm.cxx:294
SwContentFrame * FindPrevCnt()
Definition: findfrm.cxx:174
SwFrame * GetIndNext_()
Definition: sectfrm.cxx:2485
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
void MergeNext(SwSectionFrame *pNxt)
|* Merges two SectionFrames, in case it's about the same section.
Definition: sectfrm.cxx:463
const SwLayoutFrame * GetNextLayoutLeaf() const
Definition: frame.hxx:998
bool IsEndnoteAtMyEnd() const
Definition: sectfrm.cxx:2549
virtual void MakePos()
Definition: calcmove.cxx:534
SwPageFrame * InsertPage(SwPageFrame *pSibling, bool bFootnote)
Definition: pagechg.cxx:1288
SwSection * GetSection() const
Definition: section.cxx:671
bool CalcMinDiff(SwTwips &rMinDiff) const
Definition: sectfrm.cxx:942
bool IsFootnoteContFrame() const
Definition: frame.hxx:1176
void Init(sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct)
This function allows to (repeatedly) initialize the columns.
Definition: atrfrm.cxx:946
bool WrongPageDesc(SwPageFrame *pNew)
Definition: flowfrm.cxx:825
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:66
SwSectionFrame(SwSection &, SwFrame *)
Definition: sectfrm.cxx:66
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2069
const SwFlowFrame * GetFollow() const
Definition: flowfrm.hxx:168
bool IsBodyFrame() const
Definition: frame.hxx:1184
GPOS_RT
virtual void MakeAll(vcl::RenderContext *pRenderContext) override
Definition: calcmove.cxx:951
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
class for collecting anchored objects
Definition: sortedobjs.hxx:48
bool HasEndnotes() const
Definition: layouter.cxx:219
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(117)
bool IsFooterFrame() const
Definition: frame.hxx:1172
sal_uInt16 Which() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:659
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:30
const SfxPoolItem * GetCurItem() const
std::unique_ptr< SwDestroyList > mpDestroy
Definition: rootfrm.hxx:166
bool IsHeaderFrame() const
Definition: frame.hxx:1168
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:393
#define PROTOCOL_ENTER(pFrame, nFunc, nAct, pPar)
Definition: dbg_lay.hxx:92
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1077
SwFrame * GetNext()
Definition: frame.hxx:656
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
EnumT GetValue() const