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