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