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