LibreOffice Module sw (master)  1
flowfrm.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 <memory>
21 #include <sal/config.h>
22 #include <sal/log.hxx>
23 
24 #include <bodyfrm.hxx>
25 #include <swtable.hxx>
26 #include <rootfrm.hxx>
27 #include <pagefrm.hxx>
28 #include <viewimp.hxx>
29 #include <viewopt.hxx>
30 #include <frmatr.hxx>
31 #include <frmtool.hxx>
33 #include <dcontact.hxx>
35 #include <editeng/keepitem.hxx>
36 #include <fmtsrnd.hxx>
37 #include <fmtpdsc.hxx>
38 #include <editeng/ulspitem.hxx>
39 #include <tgrditem.hxx>
40 #include <txtftn.hxx>
41 #include <fmtftn.hxx>
42 #include <editeng/pgrditem.hxx>
43 #include <paratr.hxx>
44 #include <ftnfrm.hxx>
45 #include <txtfrm.hxx>
46 #include <notxtfrm.hxx>
47 #include <tabfrm.hxx>
48 #include <rowfrm.hxx>
49 #include <pagedesc.hxx>
50 #include <layact.hxx>
51 #include <flyfrms.hxx>
52 #include <sectfrm.hxx>
53 #include <section.hxx>
54 #include <dbg_lay.hxx>
55 #include <lineinfo.hxx>
56 #include <fmtclbl.hxx>
57 #include <sortedobjs.hxx>
58 #include <layouter.hxx>
59 #include <fmtfollowtextflow.hxx>
60 #include <calbck.hxx>
63 #include <pam.hxx>
64 #include <ndtxt.hxx>
65 
66 bool SwFlowFrame::m_bMoveBwdJump = false;
67 
69  m_rThis( rFrame ),
70  m_pFollow( nullptr ),
71  m_pPrecede( nullptr ),
72  m_bLockJoin( false ),
73  m_bUndersized( false ),
74  m_bFlyLock( false )
75 {}
76 
78 {
79  if (m_pFollow)
80  {
81  m_pFollow->m_pPrecede = nullptr;
82  }
83  if (m_pPrecede)
84  {
85  m_pPrecede->m_pFollow = nullptr;
86  }
87 }
88 
89 void SwFlowFrame::SetFollow(SwFlowFrame *const pFollow)
90 {
91  if (m_pFollow)
92  {
93  assert(this == m_pFollow->m_pPrecede);
94  m_pFollow->m_pPrecede = nullptr;
95  }
96  m_pFollow = pFollow;
97  if (m_pFollow != nullptr)
98  {
99  if (m_pFollow->m_pPrecede) // re-chaining pFollow?
100  {
102  m_pFollow->m_pPrecede->m_pFollow = nullptr;
103  }
104  m_pFollow->m_pPrecede = this;
105  }
106 }
107 
110 {
111  const SwFlowFrame* pFrame = GetFollow();
112  while( pFrame )
113  {
114  if( pFrame->IsJoinLocked() )
115  return true;
116  pFrame = pFrame->GetFollow();
117  }
118  return false;
119 }
120 
121 bool SwFlowFrame::IsKeepFwdMoveAllowed( bool bIgnoreMyOwnKeepValue )
122 {
123  // If all the predecessors up to the first of the chain have
124  // the 'keep' attribute set, and the first of the chain's
125  // IsFwdMoveAllowed returns false, then we're not allowed to move.
126  SwFrame *pFrame = &m_rThis;
127  if ( !pFrame->IsInFootnote() ) {
128  if ( bIgnoreMyOwnKeepValue && pFrame->GetIndPrev() )
129  pFrame = pFrame->GetIndPrev();
130  do
131  { if ( pFrame->GetAttrSet()->GetKeep().GetValue() )
132  pFrame = pFrame->GetIndPrev();
133  else
134  return true;
135  } while ( pFrame );
136  }
137  //See IsFwdMoveAllowed()
138  bool bRet = false;
139  if ( pFrame && pFrame->GetIndPrev() )
140  bRet = true;
141  return bRet;
142 }
143 
145 {
146  // Kick off the "last" predecessor with a 'keep' attribute, because
147  // it's possible for the whole troop to move back.
148  SwFrame *pPre = m_rThis.GetIndPrev();
149  assert(pPre);
150  if( pPre->IsSctFrame() )
151  {
152  SwFrame *pLast = static_cast<SwSectionFrame*>(pPre)->FindLastContent();
153  if( pLast && pLast->FindSctFrame() == pPre )
154  pPre = pLast;
155  else
156  return;
157  }
158  SwFrame* pTmp;
159  bool bKeep;
160  while ( (bKeep = pPre->GetAttrSet()->GetKeep().GetValue()) &&
161  nullptr != ( pTmp = pPre->GetIndPrev() ) )
162  {
163  if( pTmp->IsSctFrame() )
164  {
165  SwFrame *pLast = static_cast<SwSectionFrame*>(pTmp)->FindLastContent();
166  if( pLast && pLast->FindSctFrame() == pTmp )
167  pTmp = pLast;
168  else
169  break;
170  }
171  pPre = pTmp;
172  }
173  if ( bKeep )
174  pPre->InvalidatePos();
175 }
176 
178  SvxFormatBreakItem const& rBreak,
179  bool const bCheckIfLastRowShouldKeep) const
180 {
181  // 1. The keep attribute is ignored inside footnotes
182  // 2. For compatibility reasons, the keep attribute is
183  // ignored for frames inside table cells
184  // 3. If bBreakCheck is set to true, this function only checks
185  // if there are any break after attributes set at rAttrs
186  // or break before attributes set for the next content (or next table)
187  bool bKeep = bCheckIfLastRowShouldKeep ||
188  ( !m_rThis.IsInFootnote() &&
189  ( !m_rThis.IsInTab() || m_rThis.IsTabFrame() ) &&
190  rKeep.GetValue() );
191 
192  OSL_ENSURE( !bCheckIfLastRowShouldKeep || m_rThis.IsTabFrame(),
193  "IsKeep with bCheckIfLastRowShouldKeep should only be used for tabfrms" );
194 
195  // Ignore keep attribute if there are break situations:
196  if ( bKeep )
197  {
198  switch (rBreak.GetBreak())
199  {
200  case SvxBreak::ColumnAfter:
201  case SvxBreak::ColumnBoth:
202  case SvxBreak::PageAfter:
203  case SvxBreak::PageBoth:
204  {
205  bKeep = false;
206  break;
207  }
208  default: break;
209  }
210  if ( bKeep )
211  {
212  SwFrame *pNxt;
213  if( nullptr != (pNxt = m_rThis.FindNextCnt()) &&
214  (!m_pFollow || pNxt != &m_pFollow->GetFrame()))
215  {
216  // The last row of a table only keeps with the next content
217  // it they are in the same section:
218  if ( bCheckIfLastRowShouldKeep )
219  {
220  const SwSection* pThisSection = nullptr;
221  const SwSection* pNextSection = nullptr;
222  const SwSectionFrame* pThisSectionFrame = m_rThis.FindSctFrame();
223  const SwSectionFrame* pNextSectionFrame = pNxt->FindSctFrame();
224 
225  if ( pThisSectionFrame )
226  pThisSection = pThisSectionFrame->GetSection();
227 
228  if ( pNextSectionFrame )
229  pNextSection = pNextSectionFrame->GetSection();
230 
231  if ( pThisSection != pNextSection )
232  bKeep = false;
233  }
234 
235  if ( bKeep )
236  {
237  SvxFormatBreakItem const* pBreak;
238  SwFormatPageDesc const* pPageDesc;
239  SwTabFrame* pTab = pNxt->IsInTab() ? pNxt->FindTabFrame() : nullptr;
240  if (pTab && (!m_rThis.IsInTab() || m_rThis.FindTabFrame() != pTab))
241  {
242  const SwAttrSet *const pSet = &pTab->GetFormat()->GetAttrSet();
243  pBreak = &pSet->GetBreak();
244  pPageDesc = &pSet->GetPageDesc();
245  }
246  else
247  {
248  pBreak = &pNxt->GetBreakItem();
249  pPageDesc = &pNxt->GetPageDescItem();
250  }
251 
252  if (pPageDesc->GetPageDesc())
253  bKeep = false;
254  else switch (pBreak->GetBreak())
255  {
256  case SvxBreak::ColumnBefore:
257  case SvxBreak::ColumnBoth:
258  case SvxBreak::PageBefore:
259  case SvxBreak::PageBoth:
260  bKeep = false;
261  break;
262  default: break;
263  }
264  }
265  }
266  }
267  }
268  return bKeep;
269 }
270 
272 {
273  // The return value helps deciding whether we need to flow back (3),
274  // or whether we can use the good old WouldFit (0, 1), or if
275  // it's reasonable to relocate and test-format (2).
276 
277  // Bit 1 in this case means that there are objects anchored to myself,
278  // bit 2 means that I have to evade other objects.
279 
280  // If a SurroundObj that desires to be wrapped around overlaps with the
281  // Rect, it's required to flow (because we can't guess the relationships).
282  // However it's possible for a test formatting to happen.
283  // If the SurroundObj is a Fly and I'm a Lower, or the Fly is a Lower of
284  // mine, then it doesn't matter.
285  // If the SurroundObj is anchored in a character bound Fly, and I'm not
286  // a Lower of that character bound Fly myself, then the Fly doesn't matter.
287 
288  // #32639# If the object is anchored with me, i can ignore it, because
289  // it's likely that it will follow me with the flow. A test formatting is
290  // not allowed in that case, however!
291  sal_uInt8 nRet = 0;
292  SwFlowFrame *pTmp = this;
293  do
294  { // If there are objects hanging either on me or on a follow, we can't
295  // do a test formatting, because paragraph bound objects wouldn't
296  // be properly considered, and character bound objects shouldn't
297  // be test formatted at all.
298  if( pTmp->GetFrame().GetDrawObjs() )
299  nRet = 1;
300  pTmp = pTmp->GetFollow();
301  } while ( !nRet && pTmp );
302  const SwSortedObjs *pObjs = pPage ? pPage->GetSortedObjs() : nullptr;
303  if (pObjs)
304  {
305  // #i28701# - new type <SwSortedObjs>
306  const SwSortedObjs &rObjs = *pObjs;
307  sal_uLong nIndex = ULONG_MAX;
308  for ( size_t i = 0; nRet < 3 && i < rObjs.size(); ++i )
309  {
310  // #i28701# - consider changed type of
311  // <SwSortedObjs> entries.
312  SwAnchoredObject* pObj = rObjs[i];
313  const SwFrameFormat& rFormat = pObj->GetFrameFormat();
314  const SwRect aRect( pObj->GetObjRect() );
315  if ( aRect.IsOver( rRect ) &&
316  rFormat.GetSurround().GetSurround() != css::text::WrapTextMode_THROUGH )
317  {
318  if( m_rThis.IsLayoutFrame() && //Fly Lower of This?
319  Is_Lower_Of( &m_rThis, pObj->GetDrawObj() ) )
320  continue;
321  if( auto pFly = dynamic_cast<const SwFlyFrame*>(pObj) )
322  {
323  if ( pFly->IsAnLower( &m_rThis ) )//This Lower of Fly?
324  continue;
325  }
326 
327  const SwFrame* pAnchor = pObj->GetAnchorFrame();
328  if ( pAnchor == &m_rThis )
329  {
330  nRet |= 1;
331  continue;
332  }
333 
334  // Don't do this if the object is anchored behind me in the text
335  // flow, because then I wouldn't evade it.
336  if ( ::IsFrameInSameContext( pAnchor, &m_rThis ) )
337  {
338  if ( rFormat.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PARA )
339  {
340  // The index of the other one can be retrieved using the anchor attribute.
341  sal_uLong nTmpIndex = rFormat.GetAnchor().GetContentAnchor()->nNode.GetIndex();
342  // Now we're going to check whether the current paragraph before
343  // the anchor of the displacing object sits in the text. If this
344  // is the case, we don't try to evade it.
345  // The index is being determined via SwFormatAnchor, because it's
346  // getting quite expensive otherwise.
347  if( ULONG_MAX == nIndex )
348  {
349  const SwNode *pNode;
350  if (m_rThis.IsTextFrame())
351  pNode = static_cast<SwTextFrame&>(m_rThis).GetTextNodeFirst();
352  else if (m_rThis.IsNoTextFrame())
353  pNode = static_cast<SwNoTextFrame&>(m_rThis).GetNode();
354  else if( m_rThis.IsSctFrame() )
355  pNode = static_cast<SwSectionFormat*>(static_cast<SwSectionFrame&>(m_rThis).
356  GetFormat())->GetSectionNode();
357  else
358  {
359  assert(!m_rThis.IsContentFrame());
360  OSL_ENSURE( m_rThis.IsTabFrame(), "new FowFrame?" );
361  pNode = static_cast<SwTabFrame&>(m_rThis).GetTable()->
362  GetTabSortBoxes()[0]->GetSttNd()->FindTableNode();
363  }
364  nIndex = pNode->GetIndex();
365  }
366  if (nIndex < nTmpIndex &&
367  (!m_rThis.IsTextFrame() ||
368  !FrameContainsNode(static_cast<SwTextFrame&>(m_rThis), nTmpIndex)))
369  {
370  continue;
371  }
372  }
373  }
374  else
375  continue;
376 
377  nRet |= 2;
378  }
379  }
380  }
381  return nRet;
382 }
383 
387 {
388  // Cut the Start and all the neighbours; they are chained together and
389  // a handle to the first one is returned. Residuals are invalidated
390  // as appropriate.
391 
392  SwLayoutFrame *pLay = pStart->GetUpper();
393  if ( pLay->IsInFootnote() )
394  pLay = pLay->FindFootnoteFrame();
395 
396  // #i58846#
397  // <pPrepare( PREP_QUOVADIS )> only for frames in footnotes
398  if( pStart->IsInFootnote() )
399  {
400  SwFrame* pTmp = pStart->GetIndPrev();
401  if( pTmp )
402  pTmp->Prepare( PREP_QUOVADIS );
403  }
404 
405  // Just cut quickly and take care that we don't cause problems with the
406  // left-behinds. The pointers of the chain being cut can point who-knows where.
407  if ( pStart == pStart->GetUpper()->Lower() )
408  pStart->GetUpper()->m_pLower = nullptr;
409  if ( pStart->GetPrev() )
410  {
411  pStart->GetPrev()->mpNext = nullptr;
412  pStart->mpPrev = nullptr;
413  }
414 
415  if ( pLay->IsFootnoteFrame() )
416  {
417  if ( !pLay->Lower() && !pLay->IsColLocked() &&
418  !static_cast<SwFootnoteFrame*>(pLay)->IsBackMoveLocked() )
419  {
420  // tdf#101821 don't delete it while iterating over it
421  if (!pLay->IsDeleteForbidden())
422  {
423  pLay->Cut();
424  SwFrame::DestroyFrame(pLay);
425  }
426  // else: assume there is code on the stack to clean up empty
427  // footnote frames
428  // (don't go into the else branch below, it produces a disconnected
429  // footnote with null upper that can be returned by
430  // SwFootnoteBossFrame::FindFootnote() causing null pointer deref
431  // in SwTextFrame::ConnectFootnote()
432  }
433  else
434  {
435  bool bUnlock = !static_cast<SwFootnoteFrame*>(pLay)->IsBackMoveLocked();
436  static_cast<SwFootnoteFrame*>(pLay)->LockBackMove();
437  pLay->InvalidateSize();
438  pLay->Calc(pLay->getRootFrame()->GetCurrShell()->GetOut());
439  SwContentFrame *pCnt = pLay->ContainsContent();
440  while ( pCnt && pLay->IsAnLower( pCnt ) )
441  {
442  // It's possible for the ContentFrame to be locked, and we don't want
443  // to end up in an endless page migration, so we're not even
444  // going to call Calc!
445  OSL_ENSURE( pCnt->IsTextFrame(), "The Graphic has landed." );
446  if ( static_cast<SwTextFrame*>(pCnt)->IsLocked() ||
447  static_cast<SwTextFrame*>(pCnt)->GetFollow() == pStart )
448  break;
449  pCnt->Calc(pCnt->getRootFrame()->GetCurrShell()->GetOut());
450  pCnt = pCnt->GetNextContentFrame();
451  }
452  if( bUnlock )
453  static_cast<SwFootnoteFrame*>(pLay)->UnlockBackMove();
454  }
455  pLay = nullptr;
456  }
457  return pLay;
458 }
459 
462 bool SwFlowFrame::PasteTree( SwFrame *pStart, SwLayoutFrame *pParent, SwFrame *pSibling,
463  SwFrame *pOldParent )
464 {
465  // returns true if there's a LayoutFrame in the chain.
466  bool bRet = false;
467 
468  // The chain beginning with pStart is inserted before pSibling
469  // under the parent. We take care to invalidate as required.
470 
471  // I'm receiving a finished chain. We need to update the pointers for
472  // the beginning of the chain, then all the uppers and finally the end.
473  // On the way there, we invalidate as required.
474  if ( pSibling )
475  {
476  if ( nullptr != (pStart->mpPrev = pSibling->GetPrev()) )
477  pStart->GetPrev()->mpNext = pStart;
478  else
479  pParent->m_pLower = pStart;
480  pSibling->InvalidatePos_();
481  pSibling->InvalidatePrt_();
482  }
483  else
484  {
485  if ( nullptr == (pStart->mpPrev = pParent->Lower()) )
486  pParent->m_pLower = pStart;
487  else
488  //Modified for #i100782#,04/03/2009
489  //If the pParent has more than 1 child nodes, former design will
490  //ignore them directly without any collection work. It will make some
491  //dangling pointers. This lead the crash...
492  //The new design will find the last child of pParent in loop way, and
493  //add the pStart after the last child.
494  // pParent->Lower()->pNext = pStart;
495  {
496  SwFrame* pTemp = pParent->m_pLower;
497  while (pTemp)
498  {
499  if (pTemp->mpNext)
500  pTemp = pTemp->mpNext;
501  else
502  {
503  pStart->mpPrev = pTemp;
504  pTemp->mpNext = pStart;
505  break;
506  }
507  }
508  }
509  //End modification for #i100782#,04/03/2009
510 
511  // #i27145#
512  if ( pParent->IsSctFrame() )
513  {
514  // We have no sibling because pParent is a section frame and
515  // has just been created to contain some content. The printing
516  // area of the frame behind pParent has to be invalidated, so
517  // that the correct distance between pParent and the next frame
518  // can be calculated.
519  pParent->InvalidateNextPrtArea();
520  }
521  }
522  SwFrame *pFloat = pStart;
523  SwFrame *pLst = nullptr;
524  SwRectFnSet aRectFnSet(pParent);
525  SwTwips nGrowVal = 0;
526  do
527  { pFloat->mpUpper = pParent;
528  pFloat->InvalidateAll_();
529  pFloat->CheckDirChange();
530 
531  // I'm a friend of the TextFrame and thus am allowed to do many things.
532  // The CacheIdx idea seems to be a bit risky!
533  if ( pFloat->IsTextFrame() )
534  {
535  if ( static_cast<SwTextFrame*>(pFloat)->GetCacheIdx() != USHRT_MAX )
536  static_cast<SwTextFrame*>(pFloat)->Init(); // I'm his friend.
537  }
538  else
539  bRet = true;
540 
541  nGrowVal += aRectFnSet.GetHeight(pFloat->getFrameArea());
542  if ( pFloat->GetNext() )
543  pFloat = pFloat->GetNext();
544  else
545  {
546  pLst = pFloat;
547  pFloat = nullptr;
548  }
549  } while ( pFloat );
550 
551  if ( pSibling )
552  {
553  pLst->mpNext = pSibling;
554  pSibling->mpPrev = pLst;
555  if( pSibling->IsInFootnote() )
556  {
557  if( pSibling->IsSctFrame() )
558  pSibling = static_cast<SwSectionFrame*>(pSibling)->ContainsAny();
559  if( pSibling )
560  pSibling->Prepare( PREP_ERGOSUM );
561  }
562  }
563  if ( nGrowVal )
564  {
565  if ( pOldParent && pOldParent->IsBodyFrame() ) // For variable page height while browsing
566  pOldParent->Shrink( nGrowVal );
567  pParent->Grow( nGrowVal );
568  }
569 
570  if ( pParent->IsFootnoteFrame() )
571  static_cast<SwFootnoteFrame*>(pParent)->InvalidateNxtFootnoteCnts( pParent->FindPageFrame() );
572  return bRet;
573 }
574 
575 void SwFlowFrame::MoveSubTree( SwLayoutFrame* pParent, SwFrame* pSibling )
576 {
577  OSL_ENSURE( pParent, "No parent given." );
578  OSL_ENSURE( m_rThis.GetUpper(), "Where are we coming from?" );
579 
580  // Be economical with notifications if an action is running.
582  const SwViewShellImp *pImp = pSh ? pSh->Imp() : nullptr;
583  const bool bComplete = pImp && pImp->IsAction() && pImp->GetLayAction().IsComplete();
584 
585  if ( !bComplete )
586  {
587  SwFrame *pPre = m_rThis.GetIndPrev();
588  if ( pPre )
589  {
590  pPre->SetRetouche();
591  // #115759# - follow-up of #i26250#
592  // invalidate printing area of previous frame, if it's in a table
593  if ( pPre->GetUpper()->IsInTab() )
594  {
595  pPre->InvalidatePrt_();
596  }
597  pPre->InvalidatePage();
598  }
599  else
600  {
603  }
604  }
605 
606  SwPageFrame *pOldPage = m_rThis.FindPageFrame();
607 
608  SwLayoutFrame *pOldParent;
609  bool bInvaLay;
610 
611  {
612  //JoinLock pParent for the lifetime of the Cut/Paste call to avoid
613  //SwSectionFrame::MergeNext removing the pParent we're trying to reparent
614  //into
615  FlowFrameJoinLockGuard aJoinGuard(pParent);
616  SwFrameDeleteGuard aDeleteGuard(pParent);
617  pOldParent = CutTree( &m_rThis );
618  bInvaLay = PasteTree( &m_rThis, pParent, pSibling, pOldParent );
619  }
620 
621  // If, by cutting & pasting, an empty SectionFrame came into existence, it should
622  // disappear automatically.
623  SwSectionFrame *pSct;
624  // #126020# - adjust check for empty section
625  // #130797# - correct fix #126020#
626  if ( pOldParent && !pOldParent->Lower() &&
627  ( pOldParent->IsInSct() &&
628  !(pSct = pOldParent->FindSctFrame())->ContainsContent() &&
629  !pSct->ContainsAny( true ) ) )
630  {
631  pSct->DelEmpty( false );
632  }
633 
634  // If we're in a column section, we'd rather not call Calc "from below"
635  if( !m_rThis.IsInSct() &&
636  ( !m_rThis.IsInTab() || ( m_rThis.IsTabFrame() && !m_rThis.GetUpper()->IsInTab() ) ) )
638  else if( m_rThis.GetUpper()->IsSctFrame() )
639  {
640  SwSectionFrame* pTmpSct = static_cast<SwSectionFrame*>(m_rThis.GetUpper());
641  bool bOld = pTmpSct->IsContentLocked();
642  pTmpSct->SetContentLock( true );
643  pTmpSct->Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
644  if( !bOld )
645  pTmpSct->SetContentLock( false );
646  }
647  SwPageFrame *pPage = m_rThis.FindPageFrame();
648 
649  if ( pOldPage != pPage )
650  {
651  m_rThis.InvalidatePage( pPage );
652  if ( m_rThis.IsLayoutFrame() )
653  {
654  SwContentFrame *pCnt = static_cast<SwLayoutFrame*>(&m_rThis)->ContainsContent();
655  if ( pCnt )
656  pCnt->InvalidatePage( pPage );
657  }
658  else if ( pSh && pSh->GetDoc()->GetLineNumberInfo().IsRestartEachPage()
659  && pPage->FindFirstBodyContent() == &m_rThis )
660  {
662  }
663  }
664  if ( bInvaLay || (pSibling && pSibling->IsLayoutFrame()) )
665  m_rThis.GetUpper()->InvalidatePage( pPage );
666 }
667 
668 bool SwFlowFrame::IsAnFollow( const SwFlowFrame *pAssumed ) const
669 {
670  const SwFlowFrame *pFoll = this;
671  do
672  { if ( pAssumed == pFoll )
673  return true;
674  pFoll = pFoll->GetFollow();
675  } while ( pFoll );
676  return false;
677 }
678 
680 {
681  OSL_ENSURE( IsFollow(), "SwContentFrame::FindMaster(): !IsFollow" );
682 
683  const SwContentFrame* pPrec = static_cast<const SwContentFrame*>(SwFlowFrame::GetPrecede());
684 
685  if ( pPrec && pPrec->HasFollow() && pPrec->GetFollow() == this )
686  {
687  OSL_ENSURE( pPrec->IsTextFrame(), "NoTextFrame with follow found" );
688  return const_cast<SwTextFrame*>(static_cast< const SwTextFrame* >(pPrec));
689  }
690 
691  OSL_FAIL( "Follow is lost in Space." );
692  return nullptr;
693 }
694 
696 {
697  OSL_ENSURE( IsFollow(), "SwSectionFrame::FindMaster(): !IsFollow" );
698 
699  if (!m_pSection)
700  return nullptr;
701 
703  SwSectionFrame* pSect = aIter.First();
704  while ( pSect )
705  {
706  if (pSect->GetFollow() == this)
707  return pSect;
708  pSect = aIter.Next();
709  }
710 
711  OSL_FAIL( "Follow is lost in Space." );
712  return nullptr;
713 }
714 
715 SwTabFrame* SwTabFrame::FindMaster( bool bFirstMaster ) const
716 {
717  OSL_ENSURE( IsFollow(), "SwTabFrame::FindMaster(): !IsFollow" );
718 
719  SwIterator<SwTabFrame,SwFormat> aIter( *GetTable()->GetFrameFormat() );
720  SwTabFrame* pTab = aIter.First();
721  while ( pTab )
722  {
723  if ( bFirstMaster )
724  {
725  // Optimization. This makes code like this obsolete:
726  // while ( pTab->IsFollow() )
727  // pTab = pTab->FindMaster();
728 
729  if ( !pTab->IsFollow() )
730  {
731  SwTabFrame* pNxt = pTab;
732  while ( pNxt )
733  {
734  if ( pNxt->GetFollow() == this )
735  return pTab;
736  pNxt = pNxt->GetFollow();
737  }
738  }
739  }
740  else
741  {
742  if ( pTab->GetFollow() == this )
743  return pTab;
744  }
745 
746  pTab = aIter.Next();
747  }
748 
749  OSL_FAIL( "Follow is lost in Space." );
750  return nullptr;
751 }
752 
757 const SwLayoutFrame *SwFrame::GetLeaf( MakePageType eMakePage, bool bFwd,
758  const SwFrame *pAnch ) const
759 {
760  // No flow, no joy...
761  if ( !(IsInDocBody() || IsInFootnote() || IsInFly()) )
762  return nullptr;
763 
764  const SwFrame *pLeaf = this;
765  bool bFound = false;
766 
767  do
768  { pLeaf = const_cast<SwFrame*>(pLeaf)->GetLeaf( eMakePage, bFwd );
769 
770  if ( pLeaf &&
771  (!IsLayoutFrame() || !static_cast<const SwLayoutFrame*>(this)->IsAnLower( pLeaf )))
772  {
773  if ( pAnch->IsInDocBody() == pLeaf->IsInDocBody() &&
774  pAnch->IsInFootnote() == pLeaf->IsInFootnote() )
775  {
776  bFound = true;
777  }
778  }
779  } while ( !bFound && pLeaf );
780 
781  return static_cast<const SwLayoutFrame*>(pLeaf);
782 }
783 
785 {
786  if ( IsInFootnote() )
787  return bFwd ? GetNextFootnoteLeaf( eMakePage ) : GetPrevFootnoteLeaf( eMakePage );
788 
789  // #i53323#
790  // A frame could be inside a table AND inside a section.
791  // Thus, it has to be determined, which is the first parent.
792  bool bInTab( IsInTab() );
793  bool bInSct( IsInSct() );
794  if ( bInTab && bInSct )
795  {
796  const SwFrame* pUpperFrame( GetUpper() );
797  while ( pUpperFrame )
798  {
799  if ( pUpperFrame->IsTabFrame() )
800  {
801  // the table is the first.
802  bInSct = false;
803  break;
804  }
805  else if ( pUpperFrame->IsSctFrame() )
806  {
807  // the section is the first.
808  bInTab = false;
809  break;
810  }
811 
812  pUpperFrame = pUpperFrame->GetUpper();
813  }
814  }
815 
816  if ( bInTab && ( !IsTabFrame() || GetUpper()->IsCellFrame() ) ) // TABLE IN TABLE
817  return bFwd ? GetNextCellLeaf() : GetPrevCellLeaf();
818 
819  if ( bInSct )
820  return bFwd ? GetNextSctLeaf( eMakePage ) : GetPrevSctLeaf();
821 
822  return bFwd ? GetNextLeaf( eMakePage ) : GetPrevLeaf();
823 }
824 
826 {
827  // Now it's getting a bit complicated:
828 
829  // Maybe I'm bringing a Pagedesc myself; in that case,
830  // the pagedesc of the next page needs to correspond.
831  // Otherwise, I'll have to dig a bit deeper to see where
832  // the following Pagedesc is coming from.
833  // If the following page itself tells me that it's pagedesc
834  // is wrong, I can happily exchange it.
835  // If the page however thinks that it's pagedesc is correct,
836  // this doesn't mean it's useful to me:
837  // If the first BodyContent asks for a PageDesc or a PageBreak,
838  // I'll have to insert a new page - except the desired page is
839  // the correct one.
840  // If I inserted a new page, the problems only get started:
841  // because then it's likely for the next page to have been
842  // wrong and having been swapped because of that.
843  // This in turn means that I have a new (and correct) page,
844  // but the conditions to swap still apply.
845  // Way out of the situation: Try to preliminarily insert a
846  // new page once (empty pages are already inserted by InsertPage()
847  // if required)
848 
849  //My Pagedesc doesn't count if I'm a follow!
850  const SwPageDesc *pDesc = nullptr;
851  int nTmp = 0;
852  SwFlowFrame *pFlow = SwFlowFrame::CastFlowFrame( this );
853  if ( !pFlow || !pFlow->IsFollow() )
854  {
855  const SwFormatPageDesc &rFormatDesc = GetPageDescItem();
856  pDesc = rFormatDesc.GetPageDesc();
857  if( pDesc )
858  {
859  if( !pDesc->GetRightFormat() )
860  nTmp = 2;
861  else if( !pDesc->GetLeftFormat() )
862  nTmp = 1;
863  else if( rFormatDesc.GetNumOffset() )
864  nTmp = rFormatDesc.GetNumOffset().get();
865  }
866  }
867 
868  // Does the Content bring a Pagedesc or do we need the
869  // virtual page number of the new layout leaf?
870  // PageDesc isn't allowed with Follows
871  const bool bOdd = nTmp ? (nTmp % 2) !=0 : pNew->OnRightPage();
872  if ( !pDesc )
873  pDesc = pNew->FindPageDesc();
874 
875  bool bFirst = pNew->OnFirstPage();
876 
877  const SwFlowFrame *pNewFlow = pNew->FindFirstBodyContent();
878  // Did we find ourselves?
879  if( pNewFlow == pFlow )
880  pNewFlow = nullptr;
881  if ( pNewFlow && pNewFlow->GetFrame().IsInTab() )
882  pNewFlow = pNewFlow->GetFrame().FindTabFrame();
883  const SwPageDesc *pNewDesc= ( pNewFlow && !pNewFlow->IsFollow() )
884  ? pNewFlow->GetFrame().GetPageDescItem().GetPageDesc()
885  : nullptr;
886 
887  SAL_INFO( "sw.pageframe", "WrongPageDesc p: " << pNew << " phys: " << pNew->GetPhyPageNum() );
888  SAL_INFO( "sw.pageframe", "WrongPageDesc " << pNew->GetPageDesc() << " " << pDesc );
889  SAL_INFO( "sw.pageframe", "WrongPageDesc odd: " << bOdd
890  << " first: " << bFirst << " " << pNew->GetFormat() << " == "
891  << (bOdd ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst)) << " "
892  << (bOdd ? pDesc->GetLeftFormat(bFirst) : pDesc->GetRightFormat(bFirst)) );
893 
894  return (pNew->GetPageDesc() != pDesc) // own desc ?
895  || (pNew->GetFormat() !=
896  (bOdd ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst)))
897  || (pNewDesc && pNewDesc == pDesc);
898 }
899 
902 {
903  OSL_ENSURE( !IsInFootnote(), "GetNextLeaf(), don't call me for Footnote." );
904  OSL_ENSURE( !IsInSct(), "GetNextLeaf(), don't call me for Sections." );
905 
906  const bool bBody = IsInDocBody(); // If I'm coming from the DocBody,
907  // I want to end up in the body.
908 
909  // It doesn't make sense to insert pages, as we only want to search the
910  // chain.
911  if( IsInFly() )
912  eMakePage = MAKEPAGE_NONE;
913 
914  // For tables, we just take the big leap. A simple GetNext would
915  // iterate through the first cells and, in turn, all other cells.
916  SwLayoutFrame *pLayLeaf = nullptr;
917  if ( IsTabFrame() )
918  {
919  SwFrame *const pTmp = static_cast<SwTabFrame*>(this)->FindLastContentOrTable();
920  if ( pTmp )
921  pLayLeaf = pTmp->GetUpper();
922  }
923  if ( !pLayLeaf )
924  pLayLeaf = GetNextLayoutLeaf();
925 
926  SwLayoutFrame *pOldLayLeaf = nullptr; // Make sure that we don't have to
927  // start searching from top when we
928  // have a freshly created page.
929  bool bNewPg = false; // Only insert a new page once.
930 
931  while ( true )
932  {
933  if ( pLayLeaf )
934  {
935  // There's yet another LayoutFrame. Let's see if it's ready to host
936  // me as well.
937  // It only needs to be of the same kind like my starting point
938  // (DocBody or Footnote respectively)
939  if ( pLayLeaf->FindPageFrame()->IsFootnotePage() )
940  { // If I ended up at the end note pages, we're done.
941  pLayLeaf = nullptr;
942  continue;
943  }
944  if ( (bBody && !pLayLeaf->IsInDocBody()) || pLayLeaf->IsInTab()
945  || pLayLeaf->IsInSct() )
946  {
947  // They don't want me! Try again
948  pOldLayLeaf = pLayLeaf;
949  pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
950  continue;
951  }
952 
953  // I'm wanted, therefore I'm done. However, it may still be that,
954  // during a page break, the page type isn't the desired one. In that
955  // case we have to insert a page of the correct type.
956 
957  if( !IsFlowFrame() && ( eMakePage == MAKEPAGE_NONE ||
958  eMakePage==MAKEPAGE_APPEND || eMakePage==MAKEPAGE_NOSECTION ) )
959  return pLayLeaf;
960 
961  SwPageFrame *pNew = pLayLeaf->FindPageFrame();
962  const SwViewShell *pSh = getRootFrame()->GetCurrShell();
963  // #111704# The pagedesc check does not make sense for frames in fly frames
964  if ( pNew != FindPageFrame() && !bNewPg && !IsInFly() &&
965  // #i46683#
966  // Do not consider page descriptions in browse mode (since
967  // MoveBwd ignored them)
968  !(pSh && pSh->GetViewOptions()->getBrowseMode() ) )
969  {
970  if( WrongPageDesc( pNew ) )
971  {
972  SwFootnoteContFrame *pCont = pNew->FindFootnoteCont();
973  if( pCont )
974  {
975  // If the reference of the first footnote of this page
976  // lies before the page, we'd rather not insert a new page.
977  // (Bug #55620#)
978  SwFootnoteFrame *pFootnote = static_cast<SwFootnoteFrame*>(pCont->Lower());
979  if( pFootnote && pFootnote->GetRef() )
980  {
981  const sal_uInt16 nRefNum = pNew->GetPhyPageNum();
982  if( pFootnote->GetRef()->GetPhyPageNum() < nRefNum )
983  break;
984  }
985  }
986  //Gotcha! The following page is wrong, therefore we need to
987  //insert a new one.
988  if ( eMakePage == MAKEPAGE_INSERT )
989  {
990  bNewPg = true;
991 
992  SwPageFrame *pPg = pOldLayLeaf ?
993  pOldLayLeaf->FindPageFrame() : nullptr;
994  if ( pPg && pPg->IsEmptyPage() )
995  // Don't insert behind. Insert before the EmptyPage.
996  pPg = static_cast<SwPageFrame*>(pPg->GetPrev());
997 
998  if ( !pPg || pPg == pNew )
999  pPg = FindPageFrame();
1000 
1001  InsertPage( pPg, false );
1002  pLayLeaf = GetNextLayoutLeaf();
1003  pOldLayLeaf = nullptr;
1004  continue;
1005  }
1006  else
1007  pLayLeaf = nullptr;
1008  }
1009  }
1010  break;
1011  }
1012  else
1013  {
1014  // There's no other matching LayoutFrame, so we have to insert
1015  // a new page.
1016  if ( eMakePage == MAKEPAGE_APPEND || eMakePage == MAKEPAGE_INSERT )
1017  {
1018  InsertPage(
1019  pOldLayLeaf ? pOldLayLeaf->FindPageFrame() : FindPageFrame(),
1020  false );
1021 
1022  // And again from the start.
1023  pLayLeaf = pOldLayLeaf ? pOldLayLeaf : GetNextLayoutLeaf();
1024  }
1025  else
1026  break;
1027  }
1028  }
1029  return pLayLeaf;
1030 }
1031 
1034 {
1035  OSL_ENSURE( !IsInFootnote(), "GetPrevLeaf(), don't call me for Footnote." );
1036 
1037  const bool bBody = IsInDocBody(); // If I'm coming from the DocBody,
1038  // I want to end up in the body.
1039  const bool bFly = IsInFly();
1040 
1041  SwLayoutFrame *pLayLeaf = GetPrevLayoutLeaf();
1042  SwLayoutFrame *pPrevLeaf = nullptr;
1043 
1044  while ( pLayLeaf )
1045  {
1046  if ( pLayLeaf->IsInTab() || // Never go into tables.
1047  pLayLeaf->IsInSct() ) // Same goes for sections!
1048  pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
1049  else if ( bBody && pLayLeaf->IsInDocBody() )
1050  {
1051  if ( pLayLeaf->Lower() )
1052  break;
1053  pPrevLeaf = pLayLeaf;
1054  pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
1055  if ( pLayLeaf )
1057  }
1058  else if ( bFly )
1059  break; //Contents in Flys should accept any layout leaf.
1060  else
1061  pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
1062  }
1063  return pLayLeaf ? pLayLeaf : pPrevLeaf;
1064 }
1065 
1067 {
1068  // true: The FlowFrame must respect the a border of the predecessor, also needs
1069  // to insert a break if required.
1070 
1072  const SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
1073  if( pSh && pSh->GetViewOptions()->getBrowseMode() )
1074  return false;
1075 
1076  SwFrame *pPre = m_rThis.FindPrev();
1077 
1078  if ( pPre && pPre->GetDrawObjs() )
1079  {
1080  OSL_ENSURE( SwFlowFrame::CastFlowFrame( pPre ), "new flowfrm?" );
1081  if( SwFlowFrame::CastFlowFrame( pPre )->IsAnFollow( this ) )
1082  return false;
1083  SwLayoutFrame* pPreUp = pPre->GetUpper();
1084  // If the upper is a SectionFrame, or a column of a SectionFrame, we're
1085  // allowed to protrude out of it. However, we need to respect the
1086  // Upper of the SectionFrame.
1087  if( pPreUp->IsInSct() )
1088  {
1089  if( pPreUp->IsSctFrame() )
1090  pPreUp = pPreUp->GetUpper();
1091  else if( pPreUp->IsColBodyFrame() &&
1092  pPreUp->GetUpper()->GetUpper()->IsSctFrame() )
1093  pPreUp = pPreUp->GetUpper()->GetUpper()->GetUpper();
1094  }
1095  // #i26945# - re-factoring
1096  // use <GetVertPosOrientFrame()> to determine, if object has followed the
1097  // text flow to the next layout frame
1098  for (SwAnchoredObject* pObj : *pPre->GetDrawObjs())
1099  {
1100  // #i28701# - consider changed type of
1101  // <SwSortedObjs> entries.
1102  // OD 2004-01-20 #110582# - do not consider hidden objects
1103  // #i26945# - do not consider object, which
1104  // doesn't follow the text flow.
1105  if ( pObj->GetFrameFormat().GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId(
1106  pObj->GetDrawObj()->GetLayer() ) &&
1107  pObj->GetFrameFormat().GetFollowTextFlow().GetValue() )
1108  {
1109  const SwLayoutFrame* pVertPosOrientFrame = pObj->GetVertPosOrientFrame();
1110  if ( pVertPosOrientFrame &&
1111  pPreUp != pVertPosOrientFrame &&
1112  !pPreUp->IsAnLower( pVertPosOrientFrame ) )
1113  {
1114  return true;
1115  }
1116  }
1117  }
1118  }
1119  return false;
1120 }
1121 
1137 bool SwFlowFrame::IsPageBreak( bool bAct ) const
1138 {
1139  if ( !IsFollow() && m_rThis.IsInDocBody() &&
1140  ( !m_rThis.IsInTab() || ( m_rThis.IsTabFrame() && !m_rThis.GetUpper()->IsInTab() ) ) ) // i66968
1141  {
1142  const SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
1143  if( pSh && pSh->GetViewOptions()->getBrowseMode() )
1144  return false;
1145 
1146  // Determine predecessor
1147  const SwFrame *pPrev = m_rThis.FindPrev();
1148  while ( pPrev && ( !pPrev->IsInDocBody() ||
1149  ( pPrev->IsTextFrame() && static_cast<const SwTextFrame*>(pPrev)->IsHiddenNow() ) ) )
1150  pPrev = pPrev->FindPrev();
1151 
1152  if ( pPrev )
1153  {
1154  OSL_ENSURE( pPrev->IsInDocBody(), "IsPageBreak: Not in DocBody?" );
1155  if ( bAct )
1156  { if ( m_rThis.FindPageFrame() == pPrev->FindPageFrame() )
1157  return false;
1158  }
1159  else
1160  { if ( m_rThis.FindPageFrame() != pPrev->FindPageFrame() )
1161  return false;
1162  }
1163 
1164  //for compatibility, also break at column break if no columns exist
1166  const bool bTreatSingleColumnBreakAsPageBreak = rIDSA.get(DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK);
1167  const SvxBreak eBreak = m_rThis.GetBreakItem().GetBreak();
1168  if ( eBreak == SvxBreak::PageBefore ||
1169  eBreak == SvxBreak::PageBoth ||
1170  ( bTreatSingleColumnBreakAsPageBreak && eBreak == SvxBreak::ColumnBefore && !m_rThis.FindColFrame() ))
1171  return true;
1172  else
1173  {
1174  const SvxBreak &ePrB = pPrev->GetBreakItem().GetBreak();
1175  if ( ePrB == SvxBreak::PageAfter ||
1176  ePrB == SvxBreak::PageBoth ||
1178  {
1179  return true;
1180  }
1181  }
1182  }
1183  }
1184  return false;
1185 }
1186 
1200 bool SwFlowFrame::IsColBreak( bool bAct ) const
1201 {
1202  if ( !IsFollow() && (m_rThis.IsMoveable() || bAct) )
1203  {
1204  const SwFrame *pCol = m_rThis.FindColFrame();
1205  if ( pCol )
1206  {
1207  // Determine predecessor
1208  const SwFrame *pPrev = m_rThis.FindPrev();
1209  while( pPrev && ( ( !pPrev->IsInDocBody() && !m_rThis.IsInFly() && !m_rThis.FindFooterOrHeader() ) ||
1210  ( pPrev->IsTextFrame() && static_cast<const SwTextFrame*>(pPrev)->IsHiddenNow() ) ) )
1211  pPrev = pPrev->FindPrev();
1212 
1213  if ( pPrev )
1214  {
1215  if ( bAct )
1216  { if ( pCol == pPrev->FindColFrame() )
1217  return false;
1218  }
1219  else
1220  { if ( pCol != pPrev->FindColFrame() )
1221  return false;
1222  }
1223 
1224  const SvxBreak eBreak = m_rThis.GetBreakItem().GetBreak();
1225  if ( eBreak == SvxBreak::ColumnBefore ||
1226  eBreak == SvxBreak::ColumnBoth )
1227  return true;
1228  else
1229  {
1230  const SvxBreak &ePrB = pPrev->GetBreakItem().GetBreak();
1231  if ( ePrB == SvxBreak::ColumnAfter ||
1232  ePrB == SvxBreak::ColumnBoth )
1233  return true;
1234  }
1235  }
1236  }
1237  }
1238  return false;
1239 }
1240 
1241 bool SwFlowFrame::HasParaSpaceAtPages( bool bSct ) const
1242 {
1243  if( m_rThis.IsInSct() )
1244  {
1245  const SwFrame* pTmp = m_rThis.GetUpper();
1246  while( pTmp )
1247  {
1248  if( pTmp->IsCellFrame() || pTmp->IsFlyFrame() ||
1249  pTmp->IsFooterFrame() || pTmp->IsHeaderFrame() ||
1250  ( pTmp->IsFootnoteFrame() && !static_cast<const SwFootnoteFrame*>(pTmp)->GetMaster() ) )
1251  return true;
1252  if( pTmp->IsPageFrame() )
1253  return !pTmp->GetPrev() || IsPageBreak(true);
1254  if( pTmp->IsColumnFrame() && pTmp->GetPrev() )
1255  return IsColBreak( true );
1256  if( pTmp->IsSctFrame() && ( !bSct || pTmp->GetPrev() ) )
1257  return false;
1258  pTmp = pTmp->GetUpper();
1259  }
1260  OSL_FAIL( "HasParaSpaceAtPages: Where's my page?" );
1261  return false;
1262  }
1263  if( !m_rThis.IsInDocBody() || ( m_rThis.IsInTab() && !m_rThis.IsTabFrame()) ||
1264  IsPageBreak( true ) || ( m_rThis.FindColFrame() && IsColBreak( true ) ) )
1265  return true;
1266  const SwFrame* pTmp = m_rThis.FindColFrame();
1267  if( pTmp )
1268  {
1269  if( pTmp->GetPrev() )
1270  return false;
1271  }
1272  else
1273  pTmp = &m_rThis;
1274  pTmp = pTmp->FindPageFrame();
1275  return pTmp && !pTmp->GetPrev();
1276 }
1277 
1283 const SwFrame* SwFlowFrame::GetPrevFrameForUpperSpaceCalc_( const SwFrame* _pProposedPrevFrame ) const
1284 {
1285  const SwFrame* pPrevFrame = _pProposedPrevFrame
1286  ? _pProposedPrevFrame
1287  : m_rThis.GetPrev();
1288 
1289  // Skip hidden paragraphs and empty sections
1290  while ( pPrevFrame &&
1291  ( ( pPrevFrame->IsTextFrame() &&
1292  static_cast<const SwTextFrame*>(pPrevFrame)->IsHiddenNow() ) ||
1293  ( pPrevFrame->IsSctFrame() &&
1294  !static_cast<const SwSectionFrame*>(pPrevFrame)->GetSection() ) ) )
1295  {
1296  pPrevFrame = pPrevFrame->GetPrev();
1297  }
1298 
1299  // Special case: no direct previous frame is found but frame is in footnote
1300  // Search for a previous frame in previous footnote,
1301  // if frame isn't in a section, which is also in the footnote
1302  if ( !pPrevFrame && m_rThis.IsInFootnote() &&
1303  ( m_rThis.IsSctFrame() ||
1305  {
1306  const SwFootnoteFrame* pPrevFootnoteFrame =
1307  static_cast<const SwFootnoteFrame*>(m_rThis.FindFootnoteFrame()->GetPrev());
1308  if ( pPrevFootnoteFrame )
1309  {
1310  pPrevFrame = pPrevFootnoteFrame->GetLastLower();
1311 
1312  // Skip hidden paragraphs and empty sections
1313  while ( pPrevFrame &&
1314  ( ( pPrevFrame->IsTextFrame() &&
1315  static_cast<const SwTextFrame*>(pPrevFrame)->IsHiddenNow() ) ||
1316  ( pPrevFrame->IsSctFrame() &&
1317  !static_cast<const SwSectionFrame*>(pPrevFrame)->GetSection() ) ) )
1318  {
1319  pPrevFrame = pPrevFrame->GetPrev();
1320  }
1321  }
1322  }
1323  // Special case: found previous frame is a section
1324  // Search for the last content in the section
1325  if( pPrevFrame && pPrevFrame->IsSctFrame() )
1326  {
1327  const SwSectionFrame* pPrevSectFrame =
1328  static_cast<const SwSectionFrame*>(pPrevFrame);
1329  pPrevFrame = pPrevSectFrame->FindLastContent();
1330  // If the last content is in a table _inside_ the section,
1331  // take the table herself.
1332  // OD 2004-02-18 #106629# - correction:
1333  // Check directly, if table is inside table, instead of indirectly
1334  // by checking, if section isn't inside a table
1335  if ( pPrevFrame && pPrevFrame->IsInTab() )
1336  {
1337  const SwTabFrame* pTableFrame = pPrevFrame->FindTabFrame();
1338  if ( pPrevSectFrame->IsAnLower( pTableFrame ) )
1339  {
1340  pPrevFrame = pTableFrame;
1341  }
1342  }
1343  // OD 2004-02-18 #106629# correction: skip hidden text frames
1344  while ( pPrevFrame &&
1345  pPrevFrame->IsTextFrame() &&
1346  static_cast<const SwTextFrame*>(pPrevFrame)->IsHiddenNow() )
1347  {
1348  pPrevFrame = pPrevFrame->GetPrev();
1349  }
1350  }
1351 
1352  return pPrevFrame;
1353 }
1354 
1356 static bool lcl_IdenticalStyles(const SwFrame* pPrevFrame, const SwFrame* pFrame)
1357 {
1358  SwTextFormatColl *pPrevFormatColl = nullptr;
1359  if (pPrevFrame && pPrevFrame->IsTextFrame())
1360  {
1361  const SwTextFrame *pTextFrame = static_cast< const SwTextFrame * >( pPrevFrame );
1362  pPrevFormatColl = dynamic_cast<SwTextFormatColl*>(
1363  pTextFrame->GetTextNodeForParaProps()->GetFormatColl());
1364  }
1365 
1366  bool bIdenticalStyles = false;
1367  if (pFrame && pFrame->IsTextFrame())
1368  {
1369  const SwTextFrame *pTextFrame = static_cast< const SwTextFrame * >( pFrame );
1370  SwTextFormatColl *const pFormatColl = dynamic_cast<SwTextFormatColl*>(
1371  pTextFrame->GetTextNodeForParaProps()->GetFormatColl());
1372  bIdenticalStyles = pPrevFormatColl == pFormatColl;
1373  }
1374  return bIdenticalStyles;
1375 }
1376 
1377 static bool lcl_getContextualSpacing(const SwFrame* pPrevFrame)
1378 {
1379  bool bRet;
1380  auto pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), pPrevFrame);
1381  const SwBorderAttrs *pAttrs = pAccess->Get();
1382 
1383  bRet = pAttrs->GetULSpace().GetContext();
1384 
1385  return bRet;
1386 }
1387 
1388 // OD 2004-03-12 #i11860# - add 3rd parameter <_bConsiderGrid>
1390  const SwFrame* pPr,
1391  const bool _bConsiderGrid ) const
1392 {
1393  // OD 2004-03-10 #i11860# - use new method <GetPrevFrameForUpperSpaceCalc(..)>
1394  const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_( pPr );
1395 
1396  std::unique_ptr<SwBorderAttrAccess> pAccess;
1397  SwFrame* pOwn;
1398  if( !pAttrs )
1399  {
1400  if( m_rThis.IsSctFrame() )
1401  {
1402  SwSectionFrame* pFoll = &static_cast<SwSectionFrame&>(m_rThis);
1403  do
1404  pOwn = pFoll->ContainsAny();
1405  while( !pOwn && nullptr != ( pFoll = pFoll->GetFollow() ) );
1406  if( !pOwn )
1407  return 0;
1408  }
1409  else
1410  pOwn = &m_rThis;
1411  pAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), pOwn);
1412  pAttrs = pAccess->Get();
1413  }
1414  else
1415  {
1416  pOwn = &m_rThis;
1417  }
1418  SwTwips nUpper = 0;
1419  // OD 06.01.2004 #i11859#
1420  {
1422  if( pPrevFrame )
1423  {
1424  const bool bUseFormerLineSpacing = rIDSA.get(DocumentSettingId::OLD_LINE_SPACING);
1425  const bool bContextualSpacing = pAttrs->GetULSpace().GetContext()
1426  && lcl_getContextualSpacing(pPrevFrame)
1427  && lcl_IdenticalStyles(pPrevFrame, &m_rThis);
1428 
1429  // OD 2004-03-10 #i11860# - use new method to determine needed spacing
1430  // values of found previous frame and use these values.
1431  SwTwips nPrevLowerSpace = 0;
1432  SwTwips nPrevLineSpacing = 0;
1433  // #i102458#
1434  bool bPrevLineSpacingPorportional = false;
1435  GetSpacingValuesOfFrame( (*pPrevFrame),
1436  nPrevLowerSpace, nPrevLineSpacing,
1437  bPrevLineSpacingPorportional );
1439  {
1440  nUpper = bContextualSpacing ? 0 : nPrevLowerSpace + pAttrs->GetULSpace().GetUpper();
1441  SwTwips nAdd = nPrevLineSpacing;
1442  // OD 07.01.2004 #i11859# - consideration of the line spacing
1443  // for the upper spacing of a text frame
1444  if ( bUseFormerLineSpacing )
1445  {
1446  // former consideration
1447  if ( pOwn->IsTextFrame() )
1448  {
1449  nAdd = std::max( nAdd, static_cast<SwTextFrame*>(pOwn)->GetLineSpace() );
1450  }
1451  nUpper += nAdd;
1452  }
1453  else
1454  {
1455  // new consideration:
1456  // Only the proportional line spacing of the previous
1457  // text frame is considered for the upper spacing and
1458  // the line spacing values are add up instead of
1459  // building its maximum.
1460  if ( pOwn->IsTextFrame() )
1461  {
1462  // #i102458#
1463  // Correction:
1464  // A proportional line spacing of the previous text frame
1465  // is added up to an own leading line spacing.
1466  // Otherwise, the maximum of the leading line spacing
1467  // of the previous text frame and the own leading line
1468  // spacing is built.
1469  if ( bPrevLineSpacingPorportional )
1470  {
1471  nAdd += static_cast<SwTextFrame*>(pOwn)->GetLineSpace( true );
1472  }
1473  else
1474  {
1475  nAdd = std::max( nAdd, static_cast<SwTextFrame*>(pOwn)->GetLineSpace( true ) );
1476  }
1477  }
1478  nUpper += nAdd;
1479  }
1480  }
1481  else
1482  {
1483  nUpper = bContextualSpacing ? 0 : std::max(static_cast<long>(nPrevLowerSpace),
1484  static_cast<long>(pAttrs->GetULSpace().GetUpper()) );
1485  // OD 07.01.2004 #i11859# - consideration of the line spacing
1486  // for the upper spacing of a text frame
1487  if ( bUseFormerLineSpacing )
1488  {
1489  // former consideration
1490  if ( pOwn->IsTextFrame() )
1491  nUpper = std::max( nUpper, static_cast<SwTextFrame*>(pOwn)->GetLineSpace() );
1492  if ( nPrevLineSpacing != 0 )
1493  {
1494  nUpper = std::max( nUpper, nPrevLineSpacing );
1495  }
1496  }
1497  else
1498  {
1499  // new consideration:
1500  // Only the proportional line spacing of the previous
1501  // text frame is considered for the upper spacing and
1502  // the line spacing values are add up and added to
1503  // the paragraph spacing instead of building the
1504  // maximum of the line spacings and the paragraph spacing.
1505  SwTwips nAdd = nPrevLineSpacing;
1506  if ( pOwn->IsTextFrame() )
1507  {
1508  // #i102458#
1509  // Correction:
1510  // A proportional line spacing of the previous text frame
1511  // is added up to an own leading line spacing.
1512  // Otherwise, the maximum of the leading line spacing
1513  // of the previous text frame and the own leading line
1514  // spacing is built.
1515  if ( bPrevLineSpacingPorportional )
1516  {
1517  nAdd += static_cast<SwTextFrame*>(pOwn)->GetLineSpace( true );
1518  }
1519  else
1520  {
1521  nAdd = std::max( nAdd, static_cast<SwTextFrame*>(pOwn)->GetLineSpace( true ) );
1522  }
1523  }
1524  nUpper += nAdd;
1525  }
1526  }
1527  }
1530  {
1531  nUpper = pAttrs->GetULSpace().GetUpper();
1532  }
1533  }
1534 
1535  // OD 2004-02-26 #i25029# - pass previous frame <pPrevFrame>
1536  // to method <GetTopLine(..)>, if parameter <pPr> is set.
1537  // Note: parameter <pPr> is set, if method is called from <SwTextFrame::WouldFit(..)>
1538  nUpper += pAttrs->GetTopLine( m_rThis, (pPr ? pPrevFrame : nullptr) );
1539 
1540  // OD 2004-03-12 #i11860# - consider value of new parameter <_bConsiderGrid>
1541  // and use new method <GetUpperSpaceAmountConsideredForPageGrid(..)>
1542 
1543  //consider grid in square page mode
1544  if ( _bConsiderGrid && m_rThis.GetUpper()->GetFormat()->GetDoc()->IsSquaredPageMode() )
1545  {
1546  nUpper += GetUpperSpaceAmountConsideredForPageGrid_( nUpper );
1547  }
1548  return nUpper;
1549 }
1550 
1558  const SwTwips _nUpperSpaceWithoutGrid ) const
1559 {
1560  SwTwips nUpperSpaceAmountConsideredForPageGrid = 0;
1561 
1562  if ( m_rThis.IsInDocBody() && m_rThis.GetAttrSet()->GetParaGrid().GetValue() )
1563  {
1564  const SwPageFrame* pPageFrame = m_rThis.FindPageFrame();
1565  SwTextGridItem const*const pGrid(GetGridItem(pPageFrame));
1566  if( pGrid )
1567  {
1568  const SwFrame* pBodyFrame = pPageFrame->FindBodyCont();
1569  if ( pBodyFrame )
1570  {
1571  const long nGridLineHeight =
1572  pGrid->GetBaseHeight() + pGrid->GetRubyHeight();
1573 
1574  SwRectFnSet aRectFnSet(&m_rThis);
1575  const SwTwips nBodyPrtTop = aRectFnSet.GetPrtTop(*pBodyFrame);
1576  const SwTwips nProposedPrtTop =
1577  aRectFnSet.YInc( aRectFnSet.GetTop(m_rThis.getFrameArea()),
1578  _nUpperSpaceWithoutGrid );
1579 
1580  const SwTwips nSpaceAbovePrtTop =
1581  aRectFnSet.YDiff( nProposedPrtTop, nBodyPrtTop );
1582  const SwTwips nSpaceOfCompleteLinesAbove =
1583  nGridLineHeight * ( nSpaceAbovePrtTop / nGridLineHeight );
1584  SwTwips nNewPrtTop =
1585  aRectFnSet.YInc( nBodyPrtTop, nSpaceOfCompleteLinesAbove );
1586  if ( aRectFnSet.YDiff( nProposedPrtTop, nNewPrtTop ) > 0 )
1587  {
1588  nNewPrtTop = aRectFnSet.YInc( nNewPrtTop, nGridLineHeight );
1589  }
1590 
1591  const SwTwips nNewUpperSpace =
1592  aRectFnSet.YDiff( nNewPrtTop,
1593  aRectFnSet.GetTop(m_rThis.getFrameArea()) );
1594 
1595  nUpperSpaceAmountConsideredForPageGrid =
1596  nNewUpperSpace - _nUpperSpaceWithoutGrid;
1597 
1598  OSL_ENSURE( nUpperSpaceAmountConsideredForPageGrid >= 0,
1599  "<SwFlowFrame::GetUpperSpaceAmountConsideredForPageGrid(..)> - negative space considered for page grid!" );
1600  }
1601  }
1602  }
1603  return nUpperSpaceAmountConsideredForPageGrid;
1604 }
1605 
1612 {
1613  SwTwips nUpperSpaceAmountOfPrevFrame = 0;
1614 
1615  const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_();
1616  if ( pPrevFrame )
1617  {
1618  SwTwips nPrevLowerSpace = 0;
1619  SwTwips nPrevLineSpacing = 0;
1620  // #i102458#
1621  bool bDummy = false;
1622  GetSpacingValuesOfFrame( (*pPrevFrame), nPrevLowerSpace, nPrevLineSpacing, bDummy );
1623  if ( nPrevLowerSpace > 0 || nPrevLineSpacing > 0 )
1624  {
1626  if ( rIDSA.get(DocumentSettingId::PARA_SPACE_MAX) ||
1628  {
1629  nUpperSpaceAmountOfPrevFrame = nPrevLowerSpace + nPrevLineSpacing;
1630  }
1631  else
1632  {
1633  nUpperSpaceAmountOfPrevFrame = std::max( nPrevLowerSpace, nPrevLineSpacing );
1634  }
1635  }
1636  }
1637 
1638  return nUpperSpaceAmountOfPrevFrame;
1639 }
1640 
1648 {
1649  SwTwips nUpperSpaceAmountConsideredForPrevFrameAndPageGrid = 0;
1650 
1652  {
1653  nUpperSpaceAmountConsideredForPrevFrameAndPageGrid =
1656  ? GetUpperSpaceAmountConsideredForPageGrid_( CalcUpperSpace( nullptr, nullptr, false ) )
1657  : 0 );
1658  }
1659 
1660  return nUpperSpaceAmountConsideredForPrevFrameAndPageGrid;
1661 }
1662 
1668 {
1669  SwTwips nLowerSpace = 0;
1670 
1671  std::unique_ptr<SwBorderAttrAccess> pAttrAccess;
1672  if ( !_pAttrs )
1673  {
1674  pAttrAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), &m_rThis);
1675  _pAttrs = pAttrAccess->Get();
1676  }
1677 
1678  bool bCommonBorder = true;
1679  if ( m_rThis.IsInSct() && m_rThis.GetUpper()->IsColBodyFrame() )
1680  {
1681  const SwSectionFrame* pSectFrame = m_rThis.FindSctFrame();
1682  bCommonBorder = pSectFrame->GetFormat()->GetBalancedColumns().GetValue();
1683  }
1684  nLowerSpace = bCommonBorder ?
1685  _pAttrs->GetBottomLine( m_rThis ) :
1686  _pAttrs->CalcBottomLine();
1687 
1688  // #i26250#
1689  // - correct consideration of table frames
1690  // - use new method <CalcAddLowerSpaceAsLastInTableCell(..)>
1691  if ( ( ( m_rThis.IsTabFrame() && m_rThis.GetUpper()->IsInTab() ) ||
1692  // #115759# - no lower spacing, if frame has a follow
1693  ( m_rThis.IsInTab() && !GetFollow() ) ) &&
1694  !m_rThis.GetIndNext() )
1695  {
1696  nLowerSpace += CalcAddLowerSpaceAsLastInTableCell( _pAttrs );
1697  }
1698 
1699  return nLowerSpace;
1700 }
1701 
1708  const SwBorderAttrs* _pAttrs ) const
1709 {
1710  SwTwips nAdditionalLowerSpace = 0;
1711 
1713  {
1714  const SwFrame* pFrame = &m_rThis;
1715  if ( pFrame->IsSctFrame() )
1716  {
1717  const SwSectionFrame* pSectFrame = static_cast<const SwSectionFrame*>(pFrame);
1718  pFrame = pSectFrame->FindLastContent();
1719  if ( pFrame && pFrame->IsInTab() )
1720  {
1721  const SwTabFrame* pTableFrame = pFrame->FindTabFrame();
1722  if ( pSectFrame->IsAnLower( pTableFrame ) )
1723  {
1724  pFrame = pTableFrame;
1725  }
1726  }
1727  }
1728 
1729  std::unique_ptr<SwBorderAttrAccess> pAttrAccess;
1730  if (pFrame && (!_pAttrs || pFrame != &m_rThis))
1731  {
1732  pAttrAccess = std::make_unique<SwBorderAttrAccess>(SwFrame::GetCache(), pFrame);
1733  _pAttrs = pAttrAccess->Get();
1734  }
1735 
1736  if (_pAttrs)
1737  nAdditionalLowerSpace += _pAttrs->GetULSpace().GetLower();
1738  }
1739 
1740  return nAdditionalLowerSpace;
1741 }
1742 
1744 bool SwFlowFrame::CheckMoveFwd( bool& rbMakePage, bool bKeep, bool bIgnoreMyOwnKeepValue )
1745 {
1746  const SwFrame* pNxt = m_rThis.GetIndNext();
1747 
1748  if ( bKeep &&
1749  ( !pNxt || ( pNxt->IsTextFrame() && static_cast<const SwTextFrame*>(pNxt)->IsEmptyMaster() ) ) &&
1750  ( nullptr != (pNxt = m_rThis.FindNext()) ) && IsKeepFwdMoveAllowed(bIgnoreMyOwnKeepValue) )
1751  {
1752  if( pNxt->IsSctFrame() )
1753  { // Don't get fooled by empty SectionFrames
1754  const SwFrame* pTmp = nullptr;
1755  while( pNxt && pNxt->IsSctFrame() &&
1756  ( !static_cast<const SwSectionFrame*>(pNxt)->GetSection() ||
1757  nullptr == ( pTmp = static_cast<const SwSectionFrame*>(pNxt)->ContainsAny() ) ) )
1758  {
1759  pNxt = pNxt->FindNext();
1760  pTmp = nullptr;
1761  }
1762  if( pTmp )
1763  pNxt = pTmp; // the content of the next notempty sectionfrm
1764  }
1765  if( pNxt && pNxt->isFrameAreaPositionValid() )
1766  {
1767  bool bMove = false;
1768  const SwSectionFrame *pSct = m_rThis.FindSctFrame();
1769  if( pSct && !pSct->isFrameAreaSizeValid() )
1770  {
1771  const SwSectionFrame* pNxtSct = pNxt->FindSctFrame();
1772  if( pNxtSct && pSct->IsAnFollow( pNxtSct ) )
1773  bMove = true;
1774  }
1775  else
1776  bMove = true;
1777  if( bMove )
1778  {
1779  //Keep together with the following frame
1780  MoveFwd( rbMakePage, false );
1781  return true;
1782  }
1783  }
1784  }
1785 
1786  bool bMovedFwd = false;
1787 
1788  if ( m_rThis.GetIndPrev() )
1789  {
1790  if ( IsPrevObjMove() ) // Should we care about objects of the Prev?
1791  {
1792  bMovedFwd = true;
1793  if ( !MoveFwd( rbMakePage, false ) )
1794  rbMakePage = false;
1795  }
1796  else
1797  {
1798  if ( IsPageBreak( false ) )
1799  {
1800  while ( MoveFwd( rbMakePage, true ) )
1801  /* do nothing */;
1802  rbMakePage = false;
1803  bMovedFwd = true;
1804  }
1805  else if ( IsColBreak ( false ) )
1806  {
1807  const SwPageFrame *pPage = m_rThis.FindPageFrame();
1808  SwFrame *pCol = m_rThis.FindColFrame();
1809  do
1810  { MoveFwd( rbMakePage, false );
1811  SwFrame *pTmp = m_rThis.FindColFrame();
1812  if( pTmp != pCol )
1813  {
1814  bMovedFwd = true;
1815  pCol = pTmp;
1816  }
1817  else
1818  break;
1819  } while ( IsColBreak( false ) );
1820  if ( pPage != m_rThis.FindPageFrame() )
1821  rbMakePage = false;
1822  }
1823  }
1824  }
1825  return bMovedFwd;
1826 }
1827 
1829 {
1830  return m_rThis.IsTabFrame() || m_rThis.IsInTab();
1831 }
1832 
1834 bool SwFlowFrame::MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways )
1835 {
1838  if (m_rThis.IsInFootnote())
1839  {
1840  assert(!ForbiddenForFootnoteCntFwd()); // prevented by IsMoveable()
1841  if (!m_rThis.IsContentFrame() || !pOldBoss)
1842  {
1843  SAL_WARN("sw.core", "Tables in footnotes are not truly supported");
1844  return false;
1845  }
1846  return static_cast<SwContentFrame&>(m_rThis).MoveFootnoteCntFwd( bMakePage, pOldBoss );
1847  }
1848 
1849  if( !IsFwdMoveAllowed() && !bMoveAlways )
1850  {
1851  bool bNoFwd = true;
1852  if( m_rThis.IsInSct() )
1853  {
1855  bNoFwd = !pBoss->IsInSct() || ( !pBoss->Lower()->GetNext() &&
1856  !pBoss->GetPrev() );
1857  }
1858 
1859  // Allow the MoveFwd even if we do not have an IndPrev in these cases:
1860  if ( m_rThis.IsInTab() &&
1861  ( !m_rThis.IsTabFrame() ||
1862  ( m_rThis.GetUpper()->IsInTab() &&
1864  nullptr != m_rThis.GetNextCellLeaf() )
1865  {
1866  bNoFwd = false;
1867  }
1868 
1869  if( bNoFwd )
1870  {
1871  // It's allowed to move PageBreaks if the Frame isn't the first
1872  // one on the page.
1873  if ( !bPageBreak )
1874  return false;
1875 
1876  const SwFrame *pCol = m_rThis.FindColFrame();
1877  if ( !pCol || !pCol->GetPrev() )
1878  return false;
1879  }
1880  }
1881 
1882  std::unique_ptr<SwFrameDeleteGuard> xDeleteGuard(bMakePage ? new SwFrameDeleteGuard(pOldBoss) : nullptr);
1883 
1884  bool bSamePage = true;
1885  SwLayoutFrame *pNewUpper =
1886  m_rThis.GetLeaf( bMakePage ? MAKEPAGE_INSERT : MAKEPAGE_NONE, true );
1887 
1888  if ( pNewUpper )
1889  {
1891  SwPageFrame *pOldPage = pOldBoss->FindPageFrame();
1892  // We move ourself and all the direct successors before the
1893  // first ContentFrame below the new Upper.
1894 
1895  // If our NewUpper lies in a SectionFrame, we need to make sure
1896  // that it won't destroy itself in Calc.
1897  SwSectionFrame* pSect = pNewUpper->FindSctFrame();
1898  if( pSect )
1899  {
1900  // If we only switch column within our SectionFrame, we better don't
1901  // call Calc, as this would format the SectionFrame, which in turn would
1902  // call us again, etc.
1903  if( pSect != m_rThis.FindSctFrame() )
1904  {
1905  bool bUnlock = !pSect->IsColLocked();
1906  pSect->ColLock();
1907  pNewUpper->Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
1908  if( bUnlock )
1909  pSect->ColUnlock();
1910  }
1911  }
1912  // Do not calculate split cell frames.
1913  else if ( !pNewUpper->IsCellFrame() || pNewUpper->Lower() )
1914  pNewUpper->Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
1915 
1916  SwFootnoteBossFrame *pNewBoss = pNewUpper->FindFootnoteBossFrame();
1917  bool bBossChg = pNewBoss != pOldBoss;
1918  pNewBoss = pNewBoss->FindFootnoteBossFrame( true );
1919  pOldBoss = pOldBoss->FindFootnoteBossFrame( true );
1920  SwPageFrame* pNewPage = pOldPage;
1921 
1922  xDeleteGuard.reset();
1923 
1924  // First, we move the footnotes.
1925  bool bFootnoteMoved = false;
1926 
1927  // #i26831#
1928  // If pSect has just been created, the printing area of pSect has
1929  // been calculated based on the first content of its follow.
1930  // In this case we prefer to call a SimpleFormat for this new
1931  // section after we inserted the contents. Otherwise the section
1932  // frame will invalidate its lowers, if its printing area changes
1933  // in SwSectionFrame::Format, which can cause loops.
1934  const bool bForceSimpleFormat = pSect && pSect->HasFollow() &&
1935  !pSect->ContainsAny();
1936 
1937  if ( pNewBoss != pOldBoss )
1938  {
1939  pNewPage = pNewBoss->FindPageFrame();
1940  bSamePage = pNewPage == pOldPage;
1941  // Set deadline, so the footnotes don't think up
1942  // silly things...
1943  SwRectFnSet aRectFnSet(pOldBoss);
1944  SwSaveFootnoteHeight aHeight( pOldBoss,
1945  aRectFnSet.GetBottom(pOldBoss->getFrameArea()) );
1946  SwContentFrame* pStart = m_rThis.IsContentFrame() ?
1947  static_cast<SwContentFrame*>(&m_rThis) : static_cast<SwLayoutFrame&>(m_rThis).ContainsContent();
1948  OSL_ENSURE( pStart || ( m_rThis.IsTabFrame() && !static_cast<SwTabFrame&>(m_rThis).Lower() ),
1949  "MoveFwd: Missing Content" );
1950  SwLayoutFrame* pBody = pStart ? ( pStart->IsTextFrame() ?
1951  const_cast<SwBodyFrame *>(static_cast<SwTextFrame*>(pStart)->FindBodyFrame()) : nullptr ) : nullptr;
1952  if( pBody )
1953  bFootnoteMoved = pBody->MoveLowerFootnotes( pStart, pOldBoss, pNewBoss,
1954  false);
1955  }
1956  // It's possible when dealing with SectionFrames that we have been moved
1957  // by pNewUpper->Calc(), for instance into the pNewUpper.
1958  // MoveSubTree or PasteTree respectively is not prepared to handle such a
1959  // situation.
1960  if( pNewUpper != m_rThis.GetUpper() )
1961  {
1962  // #i27145#
1963  SwSectionFrame* pOldSct = nullptr;
1964  if ( m_rThis.GetUpper()->IsSctFrame() )
1965  {
1966  pOldSct = static_cast<SwSectionFrame*>(m_rThis.GetUpper());
1967  }
1968 
1969  MoveSubTree( pNewUpper, pNewUpper->Lower() );
1970 
1971  // #i27145#
1972  if ( pOldSct && pOldSct->GetSection() )
1973  {
1974  // Prevent loops by setting the new height at
1975  // the section frame if footnotes have been moved.
1976  // Otherwise the call of SwLayNotify::~SwLayNotify() for
1977  // the (invalid) section frame will invalidate the first
1978  // lower of its follow, because it grows due to the removed
1979  // footnotes.
1980  // Note: If pOldSct has become empty during MoveSubTree, it
1981  // has already been scheduled for removal. No SimpleFormat
1982  // for these.
1983  pOldSct->SimpleFormat();
1984  }
1985 
1986  // #i26831#
1987  if ( bForceSimpleFormat )
1988  {
1989  pSect->SimpleFormat();
1990  }
1991 
1992  if ( bFootnoteMoved && !bSamePage )
1993  {
1994  pOldPage->UpdateFootnoteNum();
1995  pNewPage->UpdateFootnoteNum();
1996  }
1997 
1998  if( bBossChg )
1999  {
2000  m_rThis.Prepare( PREP_BOSS_CHGD, nullptr, false );
2001  if( !bSamePage )
2002  {
2004  if ( pSh && !pSh->Imp()->IsUpdateExpFields() )
2005  pSh->GetDoc()->getIDocumentFieldsAccess().SetNewFieldLst(true); // Will be done by CalcLayout() later on!
2006 
2007  pNewPage->InvalidateSpelling();
2008  pNewPage->InvalidateSmartTags();
2009  pNewPage->InvalidateAutoCompleteWords();
2010  pNewPage->InvalidateWordCount();
2011  }
2012  }
2013  }
2014  // OD 30.10.2002 #97265# - no <CheckPageDesc(..)> in online layout
2015  const SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
2016 
2017  if ( !( pSh && pSh->GetViewOptions()->getBrowseMode() ) )
2018  {
2019  // #i106452#
2020  // check page description not only in situation with sections.
2021  if ( !bSamePage &&
2023  pOldPage->GetPageDesc()->GetFollow() != pNewPage->GetPageDesc() ) )
2024  {
2025  SwFrame::CheckPageDescs( pNewPage, false );
2026  }
2027  }
2028  }
2029  return bSamePage;
2030 }
2031 
2037 bool SwFlowFrame::MoveBwd( bool &rbReformat )
2038 {
2039  SwFlowFrame::SetMoveBwdJump( false );
2040 
2041  SwFootnoteFrame* pFootnote = m_rThis.FindFootnoteFrame();
2042  if ( pFootnote && pFootnote->IsBackMoveLocked() )
2043  return false;
2044 
2045  // #115759# - text frames, which are directly inside
2046  // tables aren't allowed to move backward.
2047  if ( m_rThis.IsTextFrame() && m_rThis.IsInTab() )
2048  {
2049  const SwLayoutFrame* pUpperFrame = m_rThis.GetUpper();
2050  while ( pUpperFrame )
2051  {
2052  if ( pUpperFrame->IsTabFrame() || pUpperFrame->IsRowFrame() )
2053  {
2054  return false;
2055  }
2056  // If the text frame is a follow-section-in-table, that can move
2057  // backward as well.
2058  bool bIsFollowSection = pUpperFrame->IsSctFrame() && static_cast<const SwSectionFrame*>(pUpperFrame)->GetPrecede();
2059 
2060  // If the text frame is a follow-in-table, that can move
2061  // backward as well.
2062  bool bIsFollow = const_cast<SwLayoutFrame*>(pUpperFrame)->GetPrevCellLeaf();
2063 
2064  if ( ( pUpperFrame->IsColumnFrame() && pUpperFrame->IsInSct() ) || bIsFollowSection || bIsFollow )
2065  {
2066  break;
2067  }
2068  pUpperFrame = pUpperFrame->GetUpper();
2069  }
2070  }
2071 
2073  if (!pOldBoss)
2074  return false;
2075 
2076  SwPageFrame * const pOldPage = pOldBoss->FindPageFrame();
2077  SwLayoutFrame *pNewUpper = nullptr;
2078  bool bCheckPageDescs = false;
2079  bool bCheckPageDescOfNextPage = false;
2080 
2081  if ( pFootnote )
2082  {
2083  // If the footnote already sits on the same page/column as the reference,
2084  // we can't flow back. The breaks don't need to be checked for footnotes.
2085 
2086  // #i37084# FindLastContent does not necessarily
2087  // have to have a result != 0
2088  SwFrame* pRef = nullptr;
2089  const bool bEndnote = pFootnote->GetAttr()->GetFootnote().IsEndNote();
2090  if( bEndnote && pFootnote->IsInSct() )
2091  {
2092  SwSectionFrame* pSect = pFootnote->FindSctFrame();
2093  if( pSect->IsEndnAtEnd() )
2094  pRef = pSect->FindLastContent( SwFindMode::LastCnt );
2095  }
2096  if( !pRef )
2097  pRef = pFootnote->GetRef();
2098 
2099  OSL_ENSURE( pRef, "MoveBwd: Endnote for an empty section?" );
2100 
2101  if( !bEndnote )
2102  pOldBoss = pOldBoss->FindFootnoteBossFrame( true );
2103  SwFootnoteBossFrame *pRefBoss = pRef->FindFootnoteBossFrame( !bEndnote );
2104  if ( pOldBoss != pRefBoss &&
2105  // OD 08.11.2002 #104840# - use <SwLayoutFrame::IsBefore(..)>
2106  ( !bEndnote ||
2107  pRefBoss->IsBefore( pOldBoss ) )
2108  )
2109  pNewUpper = m_rThis.GetLeaf( MAKEPAGE_FTN, false );
2110  }
2111  else if ( IsPageBreak( true ) ) // Do we have to respect a PageBreak?
2112  {
2113  // If the previous page doesn't have a Frame in the body,
2114  // flowing back makes sense despite the PageBreak (otherwise,
2115  // we'd get an empty page).
2116  // Of course we need to overlook empty pages!
2117  const SwFrame *pFlow = &m_rThis;
2118  do
2119  {
2120  pFlow = pFlow->FindPrev();
2121  } while ( pFlow &&
2122  ( pFlow->FindPageFrame() == pOldPage ||
2123  !pFlow->IsInDocBody() ) );
2124  if ( pFlow )
2125  {
2126  long nDiff = pOldPage->GetPhyPageNum() - pFlow->GetPhyPageNum();
2127  if ( nDiff > 1 )
2128  {
2129  if ( static_cast<SwPageFrame*>(pOldPage->GetPrev())->IsEmptyPage() )
2130  nDiff -= 1;
2131  if ( nDiff > 1 )
2132  {
2133  pNewUpper = m_rThis.GetLeaf( MAKEPAGE_NONE, false );
2134  // #i53139#
2135  // Now <pNewUpper> is a previous layout frame, which contains
2136  // content. But the new upper layout frame has to be the next one.
2137  // Thus, hack for issue i14206 no longer needed, but fix for issue 114442
2138  // #136024# - correct fix for i53139
2139  // Check for wrong page description before using next new upper.
2140  // #i66051# - further correction of fix for i53139
2141  // Check for correct type of new next upper layout frame
2142  // #136538# - another correction of fix for i53139
2143  // Assumption, that in all cases <pNewUpper> is a previous
2144  // layout frame, which contains content, is wrong.
2145  // #136538# - another correction of fix for i53139
2146  // Beside type check, check also, if proposed new next upper
2147  // frame is inside the same frame types.
2148  // #i73194# - and yet another correction
2149  // of fix for i53139:
2150  // Assure that the new next upper layout frame doesn't
2151  // equal the current one.
2152  // E.g.: content is on page 3, on page 2 is only a 'ghost'
2153  // section and on page 1 is normal content. Method <FindPrev(..)>
2154  // will find the last content of page 1, but <GetLeaf(..)>
2155  // returns new upper on page 2.
2156  if (pNewUpper && pNewUpper->Lower())
2157  {
2158  SwLayoutFrame* pNewNextUpper = pNewUpper->GetLeaf( MAKEPAGE_NONE, true );
2159  if ( pNewNextUpper &&
2160  pNewNextUpper != m_rThis.GetUpper() &&
2161  pNewNextUpper->GetType() == pNewUpper->GetType() &&
2162  pNewNextUpper->IsInDocBody() == pNewUpper->IsInDocBody() &&
2163  pNewNextUpper->IsInFootnote() == pNewUpper->IsInFootnote() &&
2164  pNewNextUpper->IsInTab() == pNewUpper->IsInTab() &&
2165  pNewNextUpper->IsInSct() == pNewUpper->IsInSct() &&
2166  !m_rThis.WrongPageDesc( pNewNextUpper->FindPageFrame() ) )
2167  {
2168  pNewUpper = pNewNextUpper;
2169  bCheckPageDescOfNextPage = true;
2170  }
2171  }
2172 
2173  bCheckPageDescs = true;
2174  }
2175  }
2176  }
2177  }
2178  else if ( IsColBreak( true ) )
2179  {
2180  // If the previous column doesn't contain a ContentFrame, flowing back
2181  // makes sense despite the ColumnBreak, as otherwise we'd get
2182  // an empty column.
2183  if( m_rThis.IsInSct() )
2184  {
2185  pNewUpper = m_rThis.GetLeaf( MAKEPAGE_NONE, false );
2186  if( pNewUpper && !SwFlowFrame::IsMoveBwdJump() &&
2187  ( pNewUpper->ContainsContent() ||
2188  ( ( !pNewUpper->IsColBodyFrame() ||
2189  !pNewUpper->GetUpper()->GetPrev() ) &&
2190  !pNewUpper->FindSctFrame()->GetPrev() ) ) )
2191  {
2192  pNewUpper = nullptr;
2193  }
2194  // #i53139#
2195  // #i69409# - check <pNewUpper>
2196  // #i71065# - check <SwFlowFrame::IsMoveBwdJump()>
2197  else if ( pNewUpper && !SwFlowFrame::IsMoveBwdJump() )
2198  {
2199  // Now <pNewUpper> is a previous layout frame, which
2200  // contains content. But the new upper layout frame
2201  // has to be the next one.
2202  // #136024# - correct fix for i53139
2203  // Check for wrong page description before using next new upper.
2204  // #i66051# - further correction of fix for i53139
2205  // Check for correct type of new next upper layout frame
2206  // #136538# - another correction of fix for i53139
2207  // Beside type check, check also, if proposed new next upper
2208  // frame is inside the same frame types.
2209  SwLayoutFrame* pNewNextUpper = pNewUpper->GetLeaf( MAKEPAGE_NOSECTION, true );
2210  if ( pNewNextUpper &&
2211  pNewNextUpper->GetType() == pNewUpper->GetType() &&
2212  pNewNextUpper->IsInDocBody() == pNewUpper->IsInDocBody() &&
2213  pNewNextUpper->IsInFootnote() == pNewUpper->IsInFootnote() &&
2214  pNewNextUpper->IsInTab() == pNewUpper->IsInTab() &&
2215  pNewNextUpper->IsInSct() == pNewUpper->IsInSct() &&
2216  !m_rThis.WrongPageDesc( pNewNextUpper->FindPageFrame() ) )
2217  {
2218  pNewUpper = pNewNextUpper;
2219  }
2220  }
2221  }
2222  else
2223  {
2224  const SwFrame *pCol = m_rThis.FindColFrame();
2225  bool bGoOn = true;
2226  bool bJump = false;
2227  do
2228  {
2229  if ( pCol->GetPrev() )
2230  pCol = pCol->GetPrev();
2231  else
2232  {
2233  bGoOn = false;
2234  pCol = m_rThis.GetLeaf( MAKEPAGE_NONE, false );
2235  }
2236  if ( pCol )
2237  {
2238  // ColumnFrames now with BodyFrame
2239  SwLayoutFrame* pColBody = pCol->IsColumnFrame() ?
2240  const_cast<SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(pCol)->Lower())) :
2241  const_cast<SwLayoutFrame*>(static_cast<const SwLayoutFrame*>(pCol));
2242  if ( pColBody->ContainsContent() )
2243  {
2244  bGoOn = false; // We have content here! we accept this
2245  // only if GetLeaf() has set the MoveBwdJump.
2247  {
2248  pNewUpper = pColBody;
2249  // #i53139#
2250  // Now <pNewUpper> is a previous layout frame, which
2251  // contains content. But the new upper layout frame
2252  // has to be the next one.
2253  // #136024# - correct fix for i53139
2254  // Check for wrong page description before using next new upper.
2255  // #i66051# - further correction of fix for i53139
2256  // Check for correct type of new next upper layout frame
2257  // #136538# - another correction of fix for i53139
2258  // Beside type check, check also, if proposed new next upper
2259  // frame is inside the same frame types.
2260  // #i71065#
2261  // Check that the proposed new next upper layout
2262  // frame isn't the current one.
2263  SwLayoutFrame* pNewNextUpper = pNewUpper->GetLeaf( MAKEPAGE_NONE, true );
2264  if ( pNewNextUpper &&
2265  pNewNextUpper != m_rThis.GetUpper() &&
2266  pNewNextUpper->GetType() == pNewUpper->GetType() &&
2267  pNewNextUpper->IsInDocBody() == pNewUpper->IsInDocBody() &&
2268  pNewNextUpper->IsInFootnote() == pNewUpper->IsInFootnote() &&
2269  pNewNextUpper->IsInTab() == pNewUpper->IsInTab() &&
2270  pNewNextUpper->IsInSct() == pNewUpper->IsInSct() &&
2271  !m_rThis.WrongPageDesc( pNewNextUpper->FindPageFrame() ) )
2272  {
2273  pNewUpper = pNewNextUpper;
2274  }
2275  }
2276  }
2277  else
2278  {
2279  if( pNewUpper ) // We already had an empty column, in other
2280  bJump = true; // words we skipped one.
2281  pNewUpper = pColBody; // this empty column could be considered,
2282  // but we continue searching nevertheless.
2283  }
2284  }
2285  } while( bGoOn );
2286  if( bJump )
2288  }
2289  }
2290  else // No breaks - we can flow back.
2291  pNewUpper = m_rThis.GetLeaf( MAKEPAGE_NONE, false );
2292 
2293  // #i27801# - no move backward of 'master' text frame,
2294  // if - due to its object positioning - it isn't allowed to be on the new page frame
2295  // #i44049# - add another condition for not moving backward
2296  // If one of its objects has restarted the layout process, moving backward
2297  // isn't sensible either.
2298  // #i47697# - refine condition made for issue i44049
2299  // - allow move backward as long as the anchored object is only temporarily
2300  // positions considering its wrapping style.
2301  if ( pNewUpper &&
2302  m_rThis.IsTextFrame() && !IsFollow() )
2303  {
2304  sal_uInt32 nToPageNum( 0 );
2305  const bool bMoveFwdByObjPos = SwLayouter::FrameMovedFwdByObjPos(
2306  *(pOldPage->GetFormat()->GetDoc()),
2307  static_cast<SwTextFrame&>(m_rThis),
2308  nToPageNum );
2309  if ( bMoveFwdByObjPos &&
2310  pNewUpper->FindPageFrame()->GetPhyPageNum() < nToPageNum )
2311  {
2312  pNewUpper = nullptr;
2313  }
2314  // #i44049# - check, if one of its anchored objects
2315  // has restarted the layout process.
2316  else if ( m_rThis.GetDrawObjs() )
2317  {
2318  for (SwAnchoredObject* pAnchoredObj : *m_rThis.GetDrawObjs())
2319  {
2320  // #i47697# - refine condition - see above
2321  if ( pAnchoredObj->RestartLayoutProcess() &&
2322  !pAnchoredObj->IsTmpConsiderWrapInfluence() )
2323  {
2324  pNewUpper = nullptr;
2325  break;
2326  }
2327  }
2328  }
2329  }
2330 
2331  // With Follows, it's only allowed to flow back if there's no neighbor
2332  // in the new environment (because that would be the Master).
2333  // (6677) If however we skipped empty pages, we still have to move.
2334  if ( pNewUpper && IsFollow() && pNewUpper->Lower() )
2335  {
2336  // #i79774#
2337  // neglect empty sections in proposed new upper frame
2338  bool bProposedNewUpperContainsOnlyEmptySections( true );
2339  {
2340  const SwFrame* pLower( pNewUpper->Lower() );
2341  while ( pLower )
2342  {
2343  if ( pLower->IsSctFrame() &&
2344  !dynamic_cast<const SwSectionFrame*>(pLower)->GetSection() )
2345  {
2346  pLower = pLower->GetNext();
2347  continue;
2348  }
2349  else
2350  {
2351  bProposedNewUpperContainsOnlyEmptySections = false;
2352  break;
2353  }
2354  }
2355  }
2356  if ( !bProposedNewUpperContainsOnlyEmptySections )
2357  {
2359  {
2360  // Don't move after the Master, but into the next empty page.
2361  SwFrame *pFrame = pNewUpper->Lower();
2362  while ( pFrame->GetNext() )
2363  pFrame = pFrame->GetNext();
2364  pNewUpper = pFrame->GetLeaf( MAKEPAGE_INSERT, true );
2365  if( pNewUpper == m_rThis.GetUpper() ) // Did we end up in the same place?
2366  pNewUpper = nullptr; // If so, moving is not needed.
2367  }
2368  else
2369  pNewUpper = nullptr;
2370  }
2371  }
2372  if ( pNewUpper && !ShouldBwdMoved( pNewUpper, true, rbReformat ) )
2373  {
2374  if( !pNewUpper->Lower() )
2375  {
2376  if( pNewUpper->IsFootnoteContFrame() )
2377  {
2378  pNewUpper->Cut();
2379  SwFrame::DestroyFrame(pNewUpper);
2380  }
2381  else
2382  {
2383  SwSectionFrame* pSectFrame = pNewUpper->FindSctFrame();
2384  // #126020# - adjust check for empty section
2385  // #130797# - correct fix #126020#
2386  if ( pSectFrame && !pSectFrame->IsColLocked() &&
2387  !pSectFrame->ContainsContent() && !pSectFrame->ContainsAny( true ) )
2388  {
2389  pSectFrame->DelEmpty( true );
2390  SwFrame::DestroyFrame(pSectFrame);
2392  }
2393  }
2394  }
2395  pNewUpper = nullptr;
2396  }
2397 
2398  // OD 2004-05-26 #i21478# - don't move backward, if flow frame wants to
2399  // keep with next frame and next frame is locked.
2400  // #i38232# - If next frame is a table, do *not* check,
2401  // if it's locked.
2402  if ( pNewUpper && !IsFollow() &&
2403  m_rThis.GetAttrSet()->GetKeep().GetValue() && m_rThis.GetIndNext() )
2404  {
2405  SwFrame* pIndNext = m_rThis.GetIndNext();
2406  // #i38232#
2407  if ( !pIndNext->IsTabFrame() )
2408  {
2409  // get first content of section, while empty sections are skipped
2410  while ( pIndNext && pIndNext->IsSctFrame() )
2411  {
2412  if( static_cast<SwSectionFrame*>(pIndNext)->GetSection() )
2413  {
2414  SwFrame* pTmp = static_cast<SwSectionFrame*>(pIndNext)->ContainsAny();
2415  if ( pTmp )
2416  {
2417  pIndNext = pTmp;
2418  break;
2419  }
2420  }
2421  pIndNext = pIndNext->GetIndNext();
2422  }
2423  OSL_ENSURE( !pIndNext || dynamic_cast<const SwTextFrame*>( pIndNext) != nullptr,
2424  "<SwFlowFrame::MovedBwd(..)> - incorrect next found." );
2425  if ( pIndNext && pIndNext->IsFlowFrame() &&
2427  {
2428  pNewUpper = nullptr;
2429  }
2430  }
2431  }
2432 
2433  // #i65250#
2434  // layout loop control for flowing content again and again moving
2435  // backward under the same layout condition.
2436  if ( pNewUpper && !IsFollow() &&
2437  pNewUpper != m_rThis.GetUpper() &&
2438  SwLayouter::MoveBwdSuppressed( *(pOldPage->GetFormat()->GetDoc()),
2439  *this, *pNewUpper ) )
2440  {
2441  SwLayoutFrame* pNextNewUpper = pNewUpper->GetLeaf(
2442  ( !m_rThis.IsSctFrame() && m_rThis.IsInSct() )
2444  : MAKEPAGE_NONE,
2445  true );
2446  // #i73194# - make code robust
2447  OSL_ENSURE( pNextNewUpper, "<SwFlowFrame::MoveBwd(..)> - missing next new upper" );
2448  if ( pNextNewUpper &&
2449  ( pNextNewUpper == m_rThis.GetUpper() ||
2450  pNextNewUpper->GetType() != m_rThis.GetUpper()->GetType() ) )
2451  {
2452  // tdf#107398 do not leave empty footnote container around
2453  if (!pNewUpper->Lower() && pNewUpper->IsFootnoteContFrame())
2454  {
2455  pNewUpper->Cut();
2456  SwFrame::DestroyFrame(pNewUpper);
2457  }
2458  pNewUpper = nullptr;
2459  OSL_FAIL( "<SwFlowFrame::MoveBwd(..)> - layout loop control for layout action <Move Backward> applied!" );
2460  }
2461  }
2462 
2463  OSL_ENSURE( pNewUpper != m_rThis.GetUpper(),
2464  "<SwFlowFrame::MoveBwd(..)> - moving backward to the current upper frame!?" );
2465  if ( pNewUpper )
2466  {
2468  if ( pNewUpper->IsFootnoteContFrame() )
2469  {
2470  // I may have gotten a Container
2472  SwFootnoteFrame *pNew = new SwFootnoteFrame( pOld->GetFormat(), pOld,
2473  pOld->GetRef(), pOld->GetAttr() );
2474  if ( pOld->GetMaster() )
2475  {
2476  pNew->SetMaster( pOld->GetMaster() );
2477  pOld->GetMaster()->SetFollow( pNew );
2478  }
2479  pNew->SetFollow( pOld );
2480  pOld->SetMaster( pNew );
2481  pNew->Paste( pNewUpper );
2482  pNewUpper = pNew;
2483  }
2484  if( pNewUpper->IsFootnoteFrame() && m_rThis.IsInSct() )
2485  {
2487  // If we're in a section of a footnote, we may need to create
2488  // a SwSectionFrame in the new upper
2489  if( pSct->IsInFootnote() )
2490  {
2491  SwFrame* pTmp = pNewUpper->Lower();
2492  if( pTmp )
2493  {
2494  while( pTmp->GetNext() )
2495  pTmp = pTmp->GetNext();
2496  if( !pTmp->IsSctFrame() ||
2497  static_cast<SwSectionFrame*>(pTmp)->GetFollow() != pSct )
2498  pTmp = nullptr;
2499  }
2500  if( pTmp )
2501  pNewUpper = static_cast<SwSectionFrame*>(pTmp);
2502  else
2503  {
2504  pSct = new SwSectionFrame( *pSct, true );
2505  pSct->Paste( pNewUpper );
2506  pSct->Init();
2507  pNewUpper = pSct;
2508  pSct->SimpleFormat();
2509  }
2510  }
2511  }
2512  bool bUnlock = false;
2513  bool bFollow = false;
2514  // Lock section. Otherwise, it could get destroyed if the only Content
2515  // moves e.g. from the second into the first column.
2516  SwSectionFrame* pSect = pNewUpper->FindSctFrame();
2517  if( pSect )
2518  {
2519  bUnlock = !pSect->IsColLocked();
2520  pSect->ColLock();
2521  bFollow = pSect->HasFollow();
2522  }
2523 
2524  {
2525  auto const pOld = m_rThis.GetUpper();
2526 #if BOOST_VERSION < 105600
2527  std::list<SwFrameDeleteGuard> g;
2528 #else
2530 #endif
2531  if (m_rThis.GetUpper()->IsCellFrame())
2532  {
2533  // note: IsFollowFlowRow() is never set for new-style tables
2534  SwTabFrame const*const pTabFrame(m_rThis.FindTabFrame());
2535  if ( pTabFrame->IsFollow()
2536  && static_cast<SwTabFrame const*>(pTabFrame->GetPrecede())->HasFollowFlowLine()
2537  && pTabFrame->GetFirstNonHeadlineRow() == m_rThis.GetUpper()->GetUpper())
2538  {
2539  // lock follow-flow-row (similar to sections above)
2540 #if BOOST_VERSION < 105600
2541  g.emplace_back(m_rThis.GetUpper()->GetUpper());
2542 #else
2543  g.emplace(m_rThis.GetUpper()->GetUpper());
2544 #endif
2545  assert(m_rThis.GetUpper()->GetUpper()->IsDeleteForbidden());
2546  }
2547  }
2548  pNewUpper->Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
2549  SAL_WARN_IF(pOld != m_rThis.GetUpper(), "sw.core",
2550  "MoveBwd(): pNewUpper->Calc() moved this frame?");
2551  }
2552 
2553  m_rThis.Cut();
2554 
2555  // optimization: format section, if its size is invalidated and if it's
2556  // the new parent of moved backward frame.
2557  bool bFormatSect( false );
2558  if( bUnlock )
2559  {
2560  pSect->ColUnlock();
2561  if( pSect->HasFollow() != bFollow )
2562  {
2563  pSect->InvalidateSize();
2564  // - optimization
2565  if ( pSect == pNewUpper )
2566  bFormatSect = true;
2567  }
2568  }
2569 
2570  m_rThis.Paste( pNewUpper );
2571  // - optimization
2572  if ( bFormatSect )
2573  pSect->Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
2574 
2575  SwPageFrame *pNewPage = m_rThis.FindPageFrame();
2576  if( pNewPage != pOldPage )
2577  {
2578  m_rThis.Prepare( PREP_BOSS_CHGD, static_cast<const void*>(pOldPage), false );
2580  if ( pSh && !pSh->Imp()->IsUpdateExpFields() )
2581  pSh->GetDoc()->getIDocumentFieldsAccess().SetNewFieldLst(true); // Will be done by CalcLayout() later on
2582 
2583  pNewPage->InvalidateSpelling();
2584  pNewPage->InvalidateSmartTags();
2585  pNewPage->InvalidateAutoCompleteWords();
2586  pNewPage->InvalidateWordCount();
2587 
2588  // OD 30.10.2002 #97265# - no <CheckPageDesc(..)> in online layout
2589  if ( !( pSh && pSh->GetViewOptions()->getBrowseMode() ) )
2590  {
2591  if ( bCheckPageDescs && pNewPage->GetNext() )
2592  {
2593  SwPageFrame* pStartPage = bCheckPageDescOfNextPage ?
2594  pNewPage :
2595  static_cast<SwPageFrame*>(pNewPage->GetNext());
2596  SwFrame::CheckPageDescs( pStartPage, false);
2597  }
2598  else if (m_rThis.GetPageDescItem().GetPageDesc())
2599  {
2600  // First page could get empty for example by disabling
2601  // a section
2602  SwFrame::CheckPageDescs( pNewPage, false);
2603  }
2604  }
2605  }
2606  }
2607  return pNewUpper != nullptr;
2608 }
2609 
2611 {
2612  if ( pFrame->IsContentFrame() )
2613  return static_cast<SwContentFrame*>(pFrame);
2614  if ( pFrame->IsTabFrame() )
2615  return static_cast<SwTabFrame*>(pFrame);
2616  if ( pFrame->IsSctFrame() )
2617  return static_cast<SwSectionFrame*>(pFrame);
2618  return nullptr;
2619 }
2620 
2622 {
2623  if ( pFrame->IsContentFrame() )
2624  return static_cast<const SwContentFrame*>(pFrame);
2625  if ( pFrame->IsTabFrame() )
2626  return static_cast<const SwTabFrame*>(pFrame);
2627  if ( pFrame->IsSctFrame() )
2628  return static_cast<const SwSectionFrame*>(pFrame);
2629  return nullptr;
2630 }
2631 
2632 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFollow(SwFootnoteFrame *pNew)
Definition: ftnfrm.hxx:110
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:206
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:341
bool GetValue() const
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:547
SwSectionFrame * FindMaster() const
Definition: flowfrm.cxx:695
bool IsKeepFwdMoveAllowed(bool bIgnoreMyOwnKeepValue=false)
Definition: flowfrm.cxx:121
SvxBreak
sal_uInt16 CalcBottomLine() const
Definition: frmtool.hxx:484
bool IsBackMoveLocked()
Definition: ftnfrm.hxx:118
Base class of the Writer layout elements.
Definition: frame.hxx:295
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:58
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
virtual SwRect GetObjRect() const =0
sal_uLong GetIndex() const
Definition: node.hxx:282
bool IsFollow() const
Definition: flowfrm.hxx:166
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:543
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwFrame * mpNext
Definition: frame.hxx:319
SwFrame * mpPrev
Definition: frame.hxx:320
SwPageDesc * FindPageDesc()
Definition: pagechg.cxx:747
bool IsEndnAtEnd() const
Definition: sectfrm.hxx:148
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
bool IsInDocBody() const
Definition: frame.hxx:919
bool IsInFly() const
Definition: frame.hxx:937
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1463
long YInc(long n1, long n2) const
Definition: frame.hxx:1401
sal_uInt16 GetLower() const
bool IsInSct() const
Definition: frame.hxx:943
static void SetMoveBwdJump(bool bNew)
Definition: flowfrm.hxx:155
bool MoveFwd(bool bMakePage, bool bPageBreak, bool bMoveAlways=false)
Return value tells us whether the Frame has changed the page.
Definition: flowfrm.cxx:1834
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:62
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
void DelEmpty(bool bRemove)
Definition: sectfrm.cxx:185
static void CheckPageDescs(SwPageFrame *pStart, bool bNotifyFields=true, SwPageFrame **ppPrev=nullptr)
Check all pages (starting from the given one) if they use the right frame format. ...
Definition: pagechg.cxx:1004
void ColLock()
Definition: sectfrm.hxx:86
bool IsColLocked() const
Definition: frame.hxx:862
bool IsBefore(const SwLayoutFrame *_pCheckRefLayFrame) const
method to check relative position of layout frame to a given layout frame.
Definition: findfrm.cxx:233
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: ftnfrm.cxx:550
bool IsKeep(SvxFormatKeepItem const &rKeep, SvxFormatBreakItem const &rBreak, bool bBreakCheck=false) const
method to determine if a Keep needs to be considered (Breaks!)
Definition: flowfrm.cxx:177
const SwTable * GetTable() const
Definition: tabfrm.hxx:144
SwNodeIndex nNode
Definition: pam.hxx:37
void SetCompletePaint() const
Definition: frame.hxx:970
void SetMaster(SwFootnoteFrame *pNew)
Definition: ftnfrm.hxx:111
bool IsInFootnote() const
Definition: frame.hxx:925
SwLayoutFrame * GetPrevLeaf()
Returns the previous layout leaf where we can move the frame.
Definition: flowfrm.cxx:1033
SwFrameType GetType() const
Definition: frame.hxx:498
SvxBreak GetBreak() const
bool IsPrevObjMove() const
Definition: flowfrm.cxx:1066
sal_uIntPtr sal_uLong
void InvalidateLineNum_()
Definition: frame.hxx:773
static SwCache & GetCache()
Definition: frame.hxx:500
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
SwFrame * FindPrev()
Definition: frame.hxx:1131
bool IsComplete() const
Definition: layact.hxx:161
static bool m_bMoveBwdJump
indicates that a backward move was done over multiple pages
Definition: flowfrm.hxx:88
TElementType * Next()
Definition: calbck.hxx:376
bool HasFollow() const
Definition: flowfrm.hxx:165
SwTwips GetUpperSpaceAmountConsideredForPageGrid_(const SwTwips _nUpperSpaceWithoutGrid) const
method to determine the upper space amount, which is considered for the page grid ...
Definition: flowfrm.cxx:1557
void UpdateFootnoteNum()
Definition: ftnfrm.cxx:2380
sal_uInt16 sal_Char sal_Char * pDesc
SwTwips CalcLowerSpace(const SwBorderAttrs *_pAttrs=nullptr) const
calculation of lower space
Definition: flowfrm.cxx:1667
void InvalidatePos()
Definition: frame.hxx:1019
long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1354
bool MoveBwd(bool &rbReformat)
Return value tells whether the Frame should change the page.
Definition: flowfrm.cxx:2037
long SwTwips
Definition: swtypes.hxx:49
SwSectionFormat * GetFormat()
Definition: section.hxx:336
static bool lcl_IdenticalStyles(const SwFrame *pPrevFrame, const SwFrame *pFrame)
Compare styles attached to these text frames.
Definition: flowfrm.cxx:1356
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:382
bool IsEndNote() const
Definition: fmtftn.hxx:73
SwFrame * FindNext()
Definition: frame.hxx:1117
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
bool IsCellFrame() const
Definition: frame.hxx:1202
bool IsFootnotePage() const
Foot note interface.
Definition: pagefrm.hxx:185
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
virtual const SvxFormatBreakItem & GetBreakItem() const
Definition: findfrm.cxx:654
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:333
virtual const SwFormatPageDesc & GetPageDescItem() const
Definition: findfrm.cxx:659
long GetPrtTop(const SwFrame &rFrame) const
Definition: frame.hxx:1385
const SwFrame * GetPrevFrameForUpperSpaceCalc_(const SwFrame *_pProposedPrevFrame=nullptr) const
helper method to determine previous frame for calculation of the upper space
Definition: flowfrm.cxx:1283
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2610
bool IsFootnoteFrame() const
Definition: frame.hxx:1178
SwLayoutFrame * GetPrevSctLeaf()
Returns the preceding layout sheet where the frame can be moved into.
Definition: sectfrm.cxx:1917
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:190
SwFrame & m_rThis
Definition: flowfrm.hxx:76
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:190
long YDiff(long n1, long n2) const
Definition: frame.hxx:1399
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:389
void SetRetouche() const
Definition: frame.hxx:979
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:1389
bool IsFlyFrame() const
Definition: frame.hxx:1186
void InvalidateNextPrtArea()
method to invalidate printing area of next frame #i11859#
Definition: findfrm.cxx:1279
wrapper class for the positioning of Writer fly frames and drawing objects
const SvxFormatBreakItem & GetBreak(bool=true) const
Definition: frmatr.hxx:62
SwSection * m_pSection
Definition: sectfrm.hxx:38
void SetContentLock(bool bNew)
Definition: sectfrm.hxx:151
bool IsMoveable(const SwLayoutFrame *_pLayoutFrame=nullptr) const
determine, if frame is moveable in given environment
Definition: findfrm.cxx:1359
const SwFormatNoBalancedColumns & GetBalancedColumns(bool=true) const
Definition: fmtclbl.hxx:42
const SwLayoutFrame * GetPrevLayoutLeaf() const
Definition: frame.hxx:1000
const SwRect & getFrameArea() const
Definition: frame.hxx:175
SwFootnoteContFrame * FindFootnoteCont()
Definition: ftnfrm.cxx:964
bool getBrowseMode() const
Definition: viewopt.hxx:433
SwLayoutFrame * GetNextLeaf(MakePageType eMakePage)
Returns the next layout leaf in which we can move the frame.
Definition: flowfrm.cxx:901
bool IsEmptyPage() const
Definition: pagefrm.hxx:143
SwFlowFrame * m_pFollow
Definition: flowfrm.hxx:117
bool IsInTab() const
Definition: frame.hxx:931
sal_uLong GetIndex() const
Definition: ndindex.hxx:151
bool IsFrameInSameContext(const SwFrame *pInnerFrame, const SwFrame *pFrame)
Definition: frmtool.cxx:3391
bool IsTextFrame() const
Definition: frame.hxx:1210
void GetSpacingValuesOfFrame(const SwFrame &rFrame, SwTwips &onLowerSpacing, SwTwips &onLineSpacing, bool &obIsLineSpacingProportional)
method to determine the spacing values of a frame
Definition: frmtool.cxx:3672
bool OnRightPage() const
Definition: frame.hxx:711
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
bool IsSctFrame() const
Definition: frame.hxx:1190
bool IsFwdMoveAllowed()
Definition: flowfrm.hxx:240
bool IsPageBreak(bool bAct) const
|* If there's a hard page break before the Frame AND there's a |* predecessor on the same page...
Definition: flowfrm.cxx:1137
bool IsFlowFrame() const
Definition: frame.hxx:1218
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:56
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:1564
const SwAttrSet * GetAttrSet() const
WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for SwTextFrame, use GetBreakItem()/GetPageDescItem() instead.
Definition: findfrm.cxx:674
static bool MoveBwdSuppressed(const SwDoc &p_rDoc, const SwFlowFrame &p_rFlowFrame, const SwLayoutFrame &p_rNewUpperFrame)
Definition: layouter.cxx:436
const SwFrame & GetFrame() const
Definition: flowfrm.hxx:151
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr)=0
virtual void Cut()=0
bool IsColumnFrame() const
Definition: frame.hxx:1158
const ::boost::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:65
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1083
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:296
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1300
void InvalidateAutoCompleteWords() const
Definition: pagefrm.hxx:376
Style of a layout element.
Definition: frmfmt.hxx:57
SwTabFrame * FindMaster(bool bFirstMaster=false) const
Definition: flowfrm.cxx:715
bool IsContentFrame() const
Definition: frame.hxx:1206
SwFrame * GetIndPrev() const
Definition: frame.hxx:702
const SwContentFrame * GetFollow() const
Definition: cntfrm.hxx:114
const SdrObject * GetDrawObj() const
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:118
void InvalidateSpelling() const
Definition: pagefrm.hxx:367
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
bool HasParaSpaceAtPages(bool bSct) const
Definition: flowfrm.cxx:1241
const SwFrame * GetLastLower() const
Definition: findfrm.cxx:1817
SwTwips CalcAddLowerSpaceAsLastInTableCell(const SwBorderAttrs *_pAttrs=nullptr) const
calculation of the additional space to be considered, if flow frame is the last inside a table cell ...
Definition: flowfrm.cxx:1707
sal_uInt16 GetBottomLine(const SwFrame &_rFrame) const
Definition: frmtool.hxx:462
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: sectfrm.cxx:334
SwFrame * GetIndNext()
Definition: frame.hxx:705
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:160
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
size_t size() const
Definition: sortedobjs.cxx:42
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:863
SwFrame * m_pLower
Definition: layfrm.hxx:52
virtual void Cut() override
Definition: wsfrm.cxx:1394
SwFrameFormat * GetLeftFormat(bool const bFirst=false)
Definition: pagedesc.cxx:361
const SwFrame * Lower() const
Definition: layfrm.hxx:100
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:190
SwTextGridItem const * GetGridItem(SwPageFrame const *const)
Definition: pagechg.cxx:2516
TElementType * First()
Definition: calbck.hxx:345
int i
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:129
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:598
virtual void SetNewFieldLst(bool bFlag)=0
SwSection * GetSection()
Definition: sectfrm.hxx:84
bool IsJoinLocked() const
Definition: flowfrm.hxx:175
void SetFollow(SwFlowFrame *const pFollow)
Definition: flowfrm.cxx:89
bool IsAction() const
SS for the Lay-/IdleAction and relatives.
Definition: viewimp.hxx:188
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
static bool PasteTree(SwFrame *, SwLayoutFrame *, SwFrame *, SwFrame *)
A specialized form of Paste(), which relocates a whole chain (this and the following, in particular).
Definition: flowfrm.cxx:462
void InvalidateSmartTags() const
Definition: pagefrm.hxx:372
bool IsRowFrame() const
Definition: frame.hxx:1198
SwTwips GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() const
method to determine the upper space amount, which is considered for the previous frame and the page g...
Definition: flowfrm.cxx:1647
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
Definition: findfrm.cxx:435
Provides access to settings of a document.
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
virtual bool ShouldBwdMoved(SwLayoutFrame *pNewUpper, bool bHead, bool &rReformat)=0
SwFrame * GetPrev()
Definition: frame.hxx:655
SwLayoutFrame * mpUpper
Definition: frame.hxx:318
bool HasLockedFollow() const
Definition: flowfrm.cxx:109
sal_uInt16 GetTopLine(const SwFrame &_rFrame, const SwFrame *_pPrevFrame=nullptr) const
Definition: frmtool.hxx:453
SwFlowFrame * m_pPrecede
Definition: flowfrm.hxx:118
bool isFrameAreaPositionValid() const
Definition: frame.hxx:162
bool IsUpdateExpFields()
Definition: viewimp.cxx:157
virtual ~SwFlowFrame()
Definition: flowfrm.cxx:77
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:757
bool isFrameAreaSizeValid() const
Definition: frame.hxx:163
SwContentFrame * FindLastContent(SwFindMode nMode=SwFindMode::None)
Definition: sectfrm.cxx:905
void InvalidatePos_()
Definition: frame.hxx:765
A page of the document layout.
Definition: pagefrm.hxx:40
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:200
sal_uInt8 BwdMoveNecessary(const SwPageFrame *pPage, const SwRect &rRect)
method to determine overlapping of an object that requests floating
Definition: flowfrm.cxx:271
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1508
void InvalidateSize()
Definition: frame.hxx:1005
SwLayoutFrame * GetPrevFootnoteLeaf(MakePageType eMakeFootnote)
Get the preceding layout leaf in that the frame can be moved.
Definition: ftnfrm.cxx:695
bool CheckMoveFwd(bool &rbMakePage, bool bKeep, bool bIgnoreMyOwnKeepValue)
Moves the Frame forward if it seems necessary regarding the current conditions and attributes...
Definition: flowfrm.cxx:1744
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1091
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:42
const SwFootnoteFrame * GetMaster() const
Definition: ftnfrm.hxx:104
const SwPageDesc * GetFollow() const
Definition: pagedesc.hxx:245
SwFrame * FindColFrame()
Definition: findfrm.cxx:529
void setFrameAreaPositionValid(bool bNew)
Definition: wsfrm.cxx:81
bool IsLayoutFrame() const
Definition: frame.hxx:1146
const SwFlowFrame * GetPrecede() const
Definition: flowfrm.hxx:172
SwRowFrame * GetFirstNonHeadlineRow() const
Definition: tabfrm.cxx:5352
void MoveSubTree(SwLayoutFrame *pParent, SwFrame *pSibling=nullptr)
hook tree onto new parent with minimal operations and notifications
Definition: flowfrm.cxx:575
SwLayoutFrame * GetLeaf(MakePageType eMakePage, bool bFwd)
Definition: flowfrm.cxx:784
bool IsSquaredPageMode() const
Definition: docdesc.cxx:920
bool Is_Lower_Of(const SwFrame *pCurrFrame, const SdrObject *pObj)
Definition: frmtool.cxx:3345
MakePageType
Definition: frame.hxx:110
SwLayAction & GetLayAction()
Definition: viewimp.hxx:190
bool IsTabFrame() const
Definition: frame.hxx:1194
void CheckKeep()
Definition: flowfrm.cxx:144
void SimpleFormat()
Definition: sectfrm.cxx:1160
virtual SwFrameFormat & GetFrameFormat()=0
#define SAL_WARN_IF(condition, area, stream)
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:679
void ColUnlock()
Definition: sectfrm.hxx:87
unsigned char sal_uInt8
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1689
bool MoveLowerFootnotes(SwContentFrame *pStart, SwFootnoteBossFrame *pOldBoss, SwFootnoteBossFrame *pNewBoss, const bool bFootnoteNums)
Moving the Footnotes of all Lowers - starting from StartContent.
Definition: ftnfrm.cxx:2610
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:426
bool ForbiddenForFootnoteCntFwd() const
Definition: flowfrm.cxx:1828
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:125
SwTwips GetUpperSpaceAmountConsideredForPrevFrame() const
method to determine the upper space amount, which is considered for the previous frame ...
Definition: flowfrm.cxx:1611
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
void InvalidateAll_()
Definition: frame.hxx:781
const SvxParaGridItem & GetParaGrid(bool=true) const
Definition: paratr.hxx:206
#define SAL_INFO(area, stream)
const SwFormatPageDesc & GetPageDesc(bool=true) const
Definition: fmtpdsc.hxx:76
SwFrameFormat * GetRightFormat(bool const bFirst=false)
Layout uses the following methods to obtain a format in order to be able to create a page...
Definition: pagedesc.cxx:368
bool IsNoTextFrame() const
Definition: frame.hxx:1214
static SwLayoutFrame * CutTree(SwFrame *)
A specialized form of Cut(), which relocates a whole chain (this and the following, in particular).
Definition: flowfrm.cxx:386
SwLayoutFrame * GetPrevCellLeaf()
Definition: findfrm.cxx:1521
bool IsColBodyFrame() const
These SwFrame inlines are here, so that frame.hxx does not need to include layfrm.hxx.
Definition: layfrm.hxx:208
const SwContentFrame * GetRef() const
Definition: ftnfrm.cxx:2863
bool IsPageFrame() const
Definition: frame.hxx:1154
const SwTextFootnote * GetAttr() const
Definition: ftnfrm.hxx:107
bool IsColBreak(bool bAct) const
|* If there's a hard column break before the Frame AND there is |* a predecessor in the same column...
Definition: flowfrm.cxx:1200
long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1358
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
bool IsAnFollow(const SwFlowFrame *pFlow) const
Definition: flowfrm.cxx:668
bool OnFirstPage() const
Definition: trvlfrm.cxx:1760
bool IsContentLocked() const
Definition: sectfrm.hxx:152
const SwTabFrame * GetFollow() const
Definition: tabfrm.hxx:243
SwLayoutFrame * GetNextFootnoteLeaf(MakePageType eMakePage)
Return the next layout leaf in that the frame can be moved.
Definition: ftnfrm.cxx:613
SwFlowFrame(SwFrame &rFrame)
Definition: flowfrm.cxx:68
long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1353
void InvalidatePrt_()
Definition: frame.hxx:757
#define SAL_WARN(area, stream)
SwFormatColl * GetFormatColl() const
Definition: node.hxx:447
const SwFrame * GetAnchorFrame() const
const SwLayoutFrame * GetNextLayoutLeaf() const
Definition: frame.hxx:996
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
SwPageFrame * InsertPage(SwPageFrame *pSibling, bool bFootnote)
Definition: pagechg.cxx:1289
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
Definition: layouter.cxx:341
sal_uInt16 GetBaseHeight() const
Definition: tgrditem.hxx:75
bool IsFootnoteContFrame() const
Definition: frame.hxx:1174
bool WrongPageDesc(SwPageFrame *pNew)
Definition: flowfrm.cxx:825
virtual bool Prepare(const PrepareHint ePrep=PREP_CLEAR, const void *pVoid=nullptr, bool bNotify=true)
Definition: wsfrm.cxx:588
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
void InvalidateWordCount() const
Definition: pagefrm.hxx:380
const SwFlowFrame * GetFollow() const
Definition: flowfrm.hxx:168
bool IsBodyFrame() const
Definition: frame.hxx:1182
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:204
class for collecting anchored objects
Definition: sortedobjs.hxx:48
Container of body content (i.e.
Definition: bodyfrm.hxx:28
sal_uInt16 GetRubyHeight() const
Definition: tgrditem.hxx:78
bool IsFooterFrame() const
Definition: frame.hxx:1170
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
bool GetContext() const
sal_uInt16 GetUpper() const
bool IsHeaderFrame() const
Definition: frame.hxx:1166
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:393
#define PROTOCOL_ENTER(pFrame, nFunc, nAct, pPar)
Definition: dbg_lay.hxx:92
const SvxULSpaceItem & GetULSpace() const
Definition: frmtool.hxx:364
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1075
static bool IsMoveBwdJump()
Definition: flowfrm.hxx:154
static bool lcl_getContextualSpacing(const SwFrame *pPrevFrame)
Definition: flowfrm.cxx:1377
SwFrame * GetNext()
Definition: frame.hxx:654
Base class of the Writer document model elements.
Definition: node.hxx:79