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