22#include <osl/diagnose.h>
57#include <lineinfo.hxx>
69bool SwFlowFrame::s_bMoveBwdJump =
false;
71SwFlowFrame::SwFlowFrame(
SwFrame &rFrame ) :
74 m_pPrecede( nullptr ),
76 m_bUndersized( false ),
80SwFlowFrame::~SwFlowFrame()
84 m_pFollow->m_pPrecede =
nullptr;
88 m_pPrecede->m_pFollow =
nullptr;
92void SwFlowFrame::SetFollow(SwFlowFrame *
const pFollow)
96 assert(
this == m_pFollow->m_pPrecede);
97 m_pFollow->m_pPrecede =
nullptr;
100 if (m_pFollow !=
nullptr)
102 if (m_pFollow->m_pPrecede)
104 assert(m_pFollow == m_pFollow->m_pPrecede->m_pFollow);
105 m_pFollow->m_pPrecede->m_pFollow =
nullptr;
107 m_pFollow->m_pPrecede =
this;
112bool SwFlowFrame::HasLockedFollow()
const
114 const SwFlowFrame* pFrame = GetFollow();
117 if( pFrame->IsJoinLocked() )
119 pFrame = pFrame->GetFollow();
124bool SwFlowFrame::IsKeepFwdMoveAllowed(
bool bIgnoreMyOwnKeepValue )
131 if ( bIgnoreMyOwnKeepValue && pFrame->
GetIndPrev() )
147void SwFlowFrame::CheckKeep()
186bool IsNextContentFullPage(
const SwFrame& rThis)
195 if (!pNextDrawObjs || !pNextDrawObjs->
size())
200 for (
const auto& pDrawObj : *pNextDrawObjs)
207 SwTwips nDrawObjHeight = pDrawObj->GetObjRectWithSpaces().Height();
208 const SwPageFrame* pPageFrame = pDrawObj->GetPageFrame();
215 if (nDrawObjHeight < nBodyHeight)
221 if (rSurround.
GetSurround() != text::WrapTextMode_NONE)
237 bool const bCheckIfLastRowShouldKeep)
const
246 bool bKeep = bCheckIfLastRowShouldKeep ||
247 ( !m_rThis.IsInFootnote() &&
248 ( !m_rThis.IsInTab() || m_rThis.IsTabFrame() ) &&
249 rKeep.GetValue() && !IsNextContentFullPage(m_rThis));
251 if (bKeep && m_rThis.IsTextFrame())
253 auto& rTextFrame =
static_cast<SwTextFrame&
>(m_rThis);
254 if (rTextFrame.HasNonLastSplitFlyDrawObj())
262 OSL_ENSURE( !bCheckIfLastRowShouldKeep || m_rThis.IsTabFrame(),
263 "IsKeep with bCheckIfLastRowShouldKeep should only be used for tabfrms" );
270 case SvxBreak::ColumnAfter:
271 case SvxBreak::ColumnBoth:
272 case SvxBreak::PageAfter:
273 case SvxBreak::PageBoth:
283 if(
nullptr != (pNxt = m_rThis.FindNextCnt()) &&
284 (!m_pFollow || pNxt != &m_pFollow->GetFrame()))
288 if ( bCheckIfLastRowShouldKeep )
295 if ( pThisSectionFrame )
296 pThisSection = pThisSectionFrame->
GetSection();
298 if ( pNextSectionFrame )
299 pNextSection = pNextSectionFrame->
GetSection();
301 if ( pThisSection != pNextSection )
310 if (pTab && (!m_rThis.IsInTab() || m_rThis.FindTabFrame() != pTab))
326 case SvxBreak::ColumnBefore:
327 case SvxBreak::ColumnBoth:
328 case SvxBreak::PageBefore:
329 case SvxBreak::PageBoth:
362 SwFlowFrame *pTmp =
this;
368 if( pTmp->GetFrame().GetDrawObjs() )
370 pTmp = pTmp->GetFollow();
371 }
while ( !nRet && pTmp );
378 for (
size_t i = 0; nRet < 3 &&
i < rObjs.
size(); ++
i )
384 if ( aRect.Overlaps( rRect ) &&
387 if( m_rThis.IsLayoutFrame() &&
392 if ( pFly->IsAnLower( &m_rThis ) )
397 if ( pAnchor == &m_rThis )
419 if (m_rThis.IsTextFrame())
420 pNode =
static_cast<SwTextFrame&
>(m_rThis).GetTextNodeFirst();
421 else if (m_rThis.IsNoTextFrame())
423 else if( m_rThis.IsSctFrame() )
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();
435 if (nIndex < nTmpIndex &&
436 (!m_rThis.IsTextFrame() ||
504 bool bUnlock = !
static_cast<SwFootnoteFrame*
>(pLay)->IsBackMoveLocked();
509 while ( pCnt && pLay->
IsAnLower( pCnt ) )
514 OSL_ENSURE( pCnt->
IsTextFrame(),
"The Graphic has landed." );
515 if (
static_cast<SwTextFrame*
>(pCnt)->IsLocked() ||
516 static_cast<SwTextFrame*
>(pCnt)->GetFollow() == pStart )
546 if (
nullptr != pStart->
mpPrev )
606 if (
static_cast<SwTextFrame*
>(pFloat)->GetCacheIdx() != USHRT_MAX )
612 nGrowVal += aRectFnSet.GetHeight(pFloat->
getFrameArea());
637 pOldParent->
Shrink( nGrowVal );
638 pParent->
Grow( nGrowVal );
648 OSL_ENSURE( pParent,
"No parent given." );
649 OSL_ENSURE( m_rThis.GetUpper(),
"Where are we coming from?" );
652 SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
672 m_rThis.GetUpper()->SetCompletePaint();
673 m_rThis.GetUpper()->InvalidatePage();
688 pOldParent = CutTree( &m_rThis );
689 bInvaLay = PasteTree( &m_rThis, pParent, pSibling, pOldParent );
697 if ( pOldParent && !pOldParent->
Lower() &&
699 !(pSct = pOldParent->
FindSctFrame())->ContainsContent() &&
704 else if (pOldParent && !pOldParent->
Lower()
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() )
726 pTmpSct->
Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
732 if ( pOldPage != pPage )
735 if ( m_rThis.IsLayoutFrame() )
744 m_rThis.InvalidateLineNum_();
748 m_rThis.GetUpper()->InvalidatePage( pPage );
751bool SwFlowFrame::IsAnFollow(
const SwFlowFrame *pAssumed )
const
753 const SwFlowFrame *pFoll =
this;
755 {
if ( pAssumed == pFoll )
757 pFoll = pFoll->GetFollow();
764 OSL_ENSURE( IsFollow(),
"SwContentFrame::FindMaster(): !IsFollow" );
768 if ( pPrec && pPrec->HasFollow() && pPrec->
GetFollow() == this )
770 OSL_ENSURE( pPrec->
IsTextFrame(),
"NoTextFrame with follow found" );
774 OSL_FAIL(
"Follow is lost in Space." );
780 OSL_ENSURE( IsFollow(),
"SwSectionFrame::FindMaster(): !IsFollow" );
791 pSect = aIter.
Next();
794 OSL_FAIL(
"Follow is lost in Space." );
800 OSL_ENSURE( IsFollow(),
"SwTabFrame::FindMaster(): !IsFollow" );
812 if ( !pTab->IsFollow() )
832 OSL_FAIL(
"Follow is lost in Space." );
851 { pLeaf =
const_cast<SwFrame*
>(pLeaf)->
GetLeaf( eMakePage, bFwd );
862 }
while ( !bFound && pLeaf );
877 if ( bInTab && bInSct )
880 while ( pUpperFrame )
895 pUpperFrame = pUpperFrame->
GetUpper();
966 std::optional<sal_uInt16> oTmp;
967 SwFlowFrame *pFlow = SwFlowFrame::CastFlowFrame(
this );
968 if ( !pFlow || !pFlow->IsFollow() )
994 if( pNewFlow == pFlow )
996 if ( pNewFlow && pNewFlow->GetFrame().IsInTab() )
998 const SwPageDesc *pNewDesc= ( pNewFlow && !pNewFlow->IsFollow() )
999 ? pNewFlow->GetFrame().GetPageDescItem().GetPageDesc()
1004 SAL_INFO(
"sw.pageframe",
"WrongPageDesc right: " << isRightPage
1005 <<
" first: " << bFirst <<
" " << pNew->
GetFormat() <<
" == "
1012 || (pNewDesc && pNewDesc == pDesc);
1018 OSL_ENSURE( !
IsInFootnote(),
"GetNextLeaf(), don't call me for Footnote." );
1019 OSL_ENSURE( !
IsInSct(),
"GetNextLeaf(), don't call me for Sections." );
1044 bool bNewPg =
false;
1063 pOldLayLeaf = pLayLeaf;
1094 if( pFootnote && pFootnote->
GetRef() )
1113 if ( !pPg || pPg == pNew )
1118 pOldLayLeaf =
nullptr;
1150 OSL_ENSURE( !
IsInFootnote(),
"GetPrevLeaf(), don't call me for Footnote." );
1166 if ( pLayLeaf->
Lower() )
1168 pPrevLeaf = pLayLeaf;
1171 SwFlowFrame::SetMoveBwdJump(
true );
1178 return pLayLeaf ? pLayLeaf : pPrevLeaf;
1181bool SwFlowFrame::IsPrevObjMove()
const
1187 const SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
1195 OSL_ENSURE( SwFlowFrame::CastFlowFrame( pPre ),
"new flowfrm?" );
1196 if( SwFlowFrame::CastFlowFrame( pPre )->IsAnFollow(
this ) )
1198 if (SwFlowFrame::CastFlowFrame(pPre)->IsJoinLocked())
1202 if (SwFlowFrame::CastFlowFrame(pPre)->IsKeep(rAttrs.GetAttrSet().GetKeep(), pPre->
GetBreakItem()))
1236 if ( pVertPosOrientFrame &&
1237 pPreUp != pVertPosOrientFrame &&
1238 !pPreUp->
IsAnLower( pVertPosOrientFrame ) )
1263bool SwFlowFrame::IsPageBreak(
bool bAct )
const
1265 if ( !IsFollow() && m_rThis.IsInDocBody() &&
1266 ( !m_rThis.IsInTab() || ( m_rThis.IsTabFrame() && !m_rThis.GetUpper()->IsInTab() ) ) )
1268 const SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
1280 OSL_ENSURE( pPrev->
IsInDocBody(),
"IsPageBreak: Not in DocBody?" );
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() ))
1301 if ( ePrB == SvxBreak::PageAfter ||
1302 ePrB == SvxBreak::PageBoth ||
1303 m_rThis.GetPageDescItem().GetPageDesc())
1326bool SwFlowFrame::IsColBreak(
bool bAct )
const
1328 if ( !IsFollow() && (m_rThis.IsMoveable() || bAct) )
1335 while( pPrev && ( ( !pPrev->
IsInDocBody() && !m_rThis.IsInFly() && !m_rThis.FindFooterOrHeader() ) ||
1351 if ( eBreak == SvxBreak::ColumnBefore ||
1352 eBreak == SvxBreak::ColumnBoth )
1357 if ( ePrB == SvxBreak::ColumnAfter ||
1358 ePrB == SvxBreak::ColumnBoth )
1367bool SwFlowFrame::HasParaSpaceAtPages(
bool bSct )
const
1369 if( m_rThis.IsInSct() )
1379 return !pTmp->
GetPrev() || IsPageBreak(
true);
1381 return IsColBreak(
true );
1386 OSL_FAIL(
"HasParaSpaceAtPages: Where's my page?" );
1389 if( !m_rThis.IsInDocBody() || ( m_rThis.IsInTab() && !m_rThis.IsTabFrame()) ||
1390 IsPageBreak(
true ) || ( m_rThis.FindColFrame() && IsColBreak(
true ) ) )
1401 return pTmp && !pTmp->
GetPrev();
1409const SwFrame* SwFlowFrame::GetPrevFrameForUpperSpaceCalc_(
const SwFrame* _pProposedPrevFrame )
const
1411 const SwFrame* pPrevFrame = _pProposedPrevFrame
1412 ? _pProposedPrevFrame
1416 while ( pPrevFrame &&
1422 pPrevFrame = pPrevFrame->
GetPrev();
1428 if ( !pPrevFrame && m_rThis.IsInFootnote() &&
1429 ( m_rThis.IsSctFrame() ||
1430 !m_rThis.IsInSct() || !m_rThis.FindSctFrame()->IsInFootnote() ) )
1433 static_cast<const SwFootnoteFrame*
>(m_rThis.FindFootnoteFrame()->GetPrev());
1434 if ( pPrevFootnoteFrame )
1439 while ( pPrevFrame &&
1445 pPrevFrame = pPrevFrame->
GetPrev();
1460 if ( pPrevFrame && pPrevFrame->
IsInTab() )
1463 if ( pPrevSectFrame->
IsAnLower( pTableFrame ) )
1465 pPrevFrame = pTableFrame;
1469 while ( pPrevFrame &&
1471 static_cast<const SwTextFrame*
>(pPrevFrame)->IsHiddenNow() )
1473 pPrevFrame = pPrevFrame->
GetPrev();
1502 return pPrevFormatColl == pFormatColl;
1519 const bool _bConsiderGrid )
const
1521 const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_( pPr );
1523 std::optional<SwBorderAttrAccess> oAccess;
1527 if( m_rThis.IsSctFrame() )
1532 while( !pOwn &&
nullptr != ( pFoll = pFoll->
GetFollow() ) );
1539 pAttrs = oAccess->Get();
1556 const bool bContextualSpacing = bContextualSpacingThis
1557 && bContextualSpacingPrev
1558 && bIdenticalStyles;
1562 const bool bHalfContextualSpacing = !bContextualSpacing
1563 && bContextualSpacingThis
1564 && !bContextualSpacingPrev
1565 && bIdenticalStyles;
1569 const bool bHalfContextualSpacingPrev = !bContextualSpacing
1570 && !bContextualSpacingThis
1571 && bContextualSpacingPrev
1572 && bIdenticalStyles;
1579 bool bPrevLineSpacingProportional =
false;
1581 nPrevLowerSpace, nPrevLineSpacing,
1582 bPrevLineSpacingProportional,
1588 SwTwips nAdd = nPrevLineSpacing;
1591 if ( bUseFormerLineSpacing )
1616 if ( bPrevLineSpacingProportional )
1618 nAdd +=
static_cast<SwTextFrame*
>(pOwn)->GetLineSpace(
true );
1622 nAdd = std::max( nAdd,
SwTwips(
static_cast<SwTextFrame*
>(pOwn)->GetLineSpace(
true )) );
1630 nUpper = bContextualSpacing ? 0 : std::max(
1631 bHalfContextualSpacingPrev ? 0 :
static_cast<tools::Long>(nPrevLowerSpace),
1636 if ( bUseFormerLineSpacing )
1640 nUpper = std::max( nUpper,
SwTwips(
static_cast<SwTextFrame*
>(pOwn)->GetLineSpace()) );
1641 if ( nPrevLineSpacing != 0 )
1643 nUpper = std::max( nUpper, nPrevLineSpacing );
1654 SwTwips nAdd = nPrevLineSpacing;
1664 if ( bPrevLineSpacingProportional )
1666 nAdd +=
static_cast<SwTextFrame*
>(pOwn)->GetLineSpace(
true );
1670 nAdd = std::max( nAdd,
SwTwips(
static_cast<SwTextFrame*
>(pOwn)->GetLineSpace(
true )) );
1678 CastFlowFrame( pOwn )->HasParaSpaceAtPages( m_rThis.IsSctFrame() ) )
1687 nUpper += pAttrs->
GetTopLine( m_rThis, (pPr ? pPrevFrame :
nullptr) );
1693 if ( _bConsiderGrid && m_rThis.GetUpper()->GetFormat()->GetDoc()->IsSquaredPageMode() )
1695 nUpper += GetUpperSpaceAmountConsideredForPageGrid_( nUpper );
1706SwTwips SwFlowFrame::GetUpperSpaceAmountConsideredForPageGrid_(
1707 const SwTwips _nUpperSpaceWithoutGrid )
const
1709 SwTwips nUpperSpaceAmountConsideredForPageGrid = 0;
1711 if ( m_rThis.IsInDocBody() && m_rThis.GetAttrSet()->GetParaGrid().GetValue() )
1721 pGrid->GetBaseHeight() + pGrid->GetRubyHeight();
1724 const SwTwips nBodyPrtTop = aRectFnSet.GetPrtTop(*pBodyFrame);
1725 const SwTwips nProposedPrtTop =
1726 aRectFnSet.YInc( aRectFnSet.GetTop(m_rThis.getFrameArea()),
1727 _nUpperSpaceWithoutGrid );
1729 const SwTwips nSpaceAbovePrtTop =
1730 aRectFnSet.YDiff( nProposedPrtTop, nBodyPrtTop );
1731 const SwTwips nSpaceOfCompleteLinesAbove =
1732 nGridLineHeight * ( nSpaceAbovePrtTop / nGridLineHeight );
1734 aRectFnSet.YInc( nBodyPrtTop, nSpaceOfCompleteLinesAbove );
1735 if ( aRectFnSet.YDiff( nProposedPrtTop, nNewPrtTop ) > 0 )
1737 nNewPrtTop = aRectFnSet.YInc( nNewPrtTop, nGridLineHeight );
1740 const SwTwips nNewUpperSpace =
1741 aRectFnSet.YDiff( nNewPrtTop,
1742 aRectFnSet.GetTop(m_rThis.getFrameArea()) );
1744 nUpperSpaceAmountConsideredForPageGrid =
1745 nNewUpperSpace - _nUpperSpaceWithoutGrid;
1747 OSL_ENSURE( nUpperSpaceAmountConsideredForPageGrid >= 0,
1748 "<SwFlowFrame::GetUpperSpaceAmountConsideredForPageGrid(..)> - negative space considered for page grid!" );
1752 return nUpperSpaceAmountConsideredForPageGrid;
1760SwTwips SwFlowFrame::GetUpperSpaceAmountConsideredForPrevFrame()
const
1762 SwTwips nUpperSpaceAmountOfPrevFrame = 0;
1764 const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_();
1770 bool bDummy =
false;
1772 if ( nPrevLowerSpace > 0 || nPrevLineSpacing > 0 )
1778 nUpperSpaceAmountOfPrevFrame = nPrevLowerSpace + nPrevLineSpacing;
1782 nUpperSpaceAmountOfPrevFrame = std::max( nPrevLowerSpace, nPrevLineSpacing );
1787 return nUpperSpaceAmountOfPrevFrame;
1796SwTwips SwFlowFrame::GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid()
const
1798 SwTwips nUpperSpaceAmountConsideredForPrevFrameAndPageGrid = 0;
1800 if (!m_rThis.GetUpper() || !m_rThis.GetUpper()->GetFormat())
1802 return nUpperSpaceAmountConsideredForPrevFrameAndPageGrid;
1807 nUpperSpaceAmountConsideredForPrevFrameAndPageGrid =
1808 GetUpperSpaceAmountConsideredForPrevFrame() +
1809 ( m_rThis.GetUpper()->GetFormat()->GetDoc()->IsSquaredPageMode()
1810 ? GetUpperSpaceAmountConsideredForPageGrid_( CalcUpperSpace(
nullptr,
nullptr,
false ) )
1814 return nUpperSpaceAmountConsideredForPrevFrameAndPageGrid;
1823 std::optional<SwBorderAttrAccess> oAttrAccess;
1827 _pAttrs = oAttrAccess->Get();
1830 bool bCommonBorder =
true;
1831 if ( m_rThis.IsInSct() && m_rThis.GetUpper()->IsColBodyFrame() )
1836 nLowerSpace = bCommonBorder ?
1843 if ( ( ( m_rThis.IsTabFrame() && m_rThis.GetUpper()->IsInTab() ) ||
1845 ( m_rThis.IsInTab() && !GetFollow() ) ) &&
1846 !m_rThis.GetIndNext() )
1848 nLowerSpace += CalcAddLowerSpaceAsLastInTableCell( _pAttrs );
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())
1868SwTwips SwFlowFrame::CalcAddLowerSpaceAsLastInTableCell(
1871 SwTwips nAdditionalLowerSpace = 0;
1876 const SwFrame* pFrame = &m_rThis;
1881 if ( pFrame && pFrame->
IsInTab() )
1884 if ( pSectFrame->
IsAnLower( pTableFrame ) )
1886 pFrame = pTableFrame;
1891 std::optional<SwBorderAttrAccess> oAttrAccess;
1892 if (pFrame && (!_pAttrs || pFrame != &m_rThis))
1895 _pAttrs = oAttrAccess->Get();
1909 return nAdditionalLowerSpace;
1913bool SwFlowFrame::CheckMoveFwd(
bool& rbMakePage,
bool bKeep,
bool bIgnoreMyOwnKeepValue )
1919 (
nullptr != (pNxt = m_rThis.FindNext()) ) && IsKeepFwdMoveAllowed(bIgnoreMyOwnKeepValue) )
1923 const SwFrame* pTmp =
nullptr;
1941 if( pNxtSct && pSct->IsAnFollow( pNxtSct ) )
1955 bool bMovedFwd =
false;
1957 if ( m_rThis.GetIndPrev() )
1959 if ( IsPrevObjMove() )
1962 if ( !
MoveFwd( rbMakePage,
false ) )
1967 if ( IsPageBreak(
false ) )
1969 while (
MoveFwd( rbMakePage,
true ) )
1974 else if ( IsColBreak (
false ) )
1979 {
MoveFwd( rbMakePage,
false );
1988 }
while ( IsColBreak(
false ) );
1989 if ( pPage != m_rThis.FindPageFrame() )
1997bool SwFlowFrame::ForbiddenForFootnoteCntFwd()
const
1999 return m_rThis.
IsTabFrame() || m_rThis.IsInTab();
2005bool SwFlowFrame::MoveFwd(
bool bMakePage,
bool bPageBreak,
bool bMoveAlways )
2009 if (m_rThis.IsInFootnote())
2011 assert(!ForbiddenForFootnoteCntFwd());
2012 if (!m_rThis.IsContentFrame() || !pOldBoss)
2014 SAL_WARN(
"sw.core",
"Tables in footnotes are not truly supported");
2017 return static_cast<SwContentFrame&
>(m_rThis).MoveFootnoteCntFwd( bMakePage, pOldBoss );
2020 if( !IsFwdMoveAllowed() && !bMoveAlways )
2023 if( m_rThis.IsInSct() )
2031 if ( m_rThis.IsInTab() &&
2032 ( !m_rThis.IsTabFrame() ||
2033 m_rThis.GetUpper()->IsInTab() ) &&
2034 nullptr != m_rThis.GetNextCellLeaf() )
2047 if ( !pCol || !pCol->
GetPrev() )
2053#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 13
2054#pragma GCC diagnostic push
2055#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
2057 std::optional<SwFrameDeleteGuard> oDeleteGuard;
2058#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 13
2059#pragma GCC diagnostic pop
2062 oDeleteGuard.emplace(pOldBoss);
2064 bool bSamePage =
true;
2083 if( pSect != m_rThis.FindSctFrame() )
2087 pNewUpper->
Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
2094 pNewUpper->
Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
2097 bool bBossChg = pNewBoss != pOldBoss;
2102 oDeleteGuard.reset();
2105 bool bFootnoteMoved =
false;
2114 const bool bForceSimpleFormat = pSect && pSect->HasFollow() &&
2117 if ( pNewBoss != pOldBoss )
2120 bSamePage = pNewPage == pOldPage;
2128 OSL_ENSURE( pStart || ( m_rThis.IsTabFrame() && !
static_cast<SwTabFrame&
>(m_rThis).
Lower() ),
2129 "MoveFwd: Missing Content" );
2140 if( pNewUpper != m_rThis.GetUpper() )
2144 if ( m_rThis.GetUpper()->IsSctFrame() )
2149 MoveSubTree( pNewUpper, pNewUpper->
Lower() );
2167 if ( bForceSimpleFormat )
2172 if ( bFootnoteMoved && !bSamePage )
2183 SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
2195 const SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
2202 ((!IsFollow() && m_rThis.GetPageDescItem().GetPageDesc()) ||
2218bool SwFlowFrame::MoveBwd(
bool &rbReformat )
2220 SwFlowFrame::SetMoveBwdJump(
false );
2228 if ( m_rThis.IsTextFrame() && m_rThis.IsInTab() )
2231 while ( pUpperFrame )
2239 bool bIsFollowSection = pUpperFrame->
IsSctFrame() &&
static_cast<const SwSectionFrame*
>(pUpperFrame)->GetPrecede();
2243 bool bIsFollow =
const_cast<SwLayoutFrame*
>(pUpperFrame)->GetPrevCellLeaf();
2245 if ( ( pUpperFrame->
IsColumnFrame() && pUpperFrame->
IsInSct() ) || bIsFollowSection || bIsFollow )
2249 pUpperFrame = pUpperFrame->
GetUpper();
2259 bool bCheckPageDescs =
false;
2260 bool bCheckPageDescOfNextPage =
false;
2273 if( bEndnote && pFootnote->
IsInSct() )
2288 pRef = pFootnote->
GetRef();
2290 OSL_ENSURE( pRef,
"MoveBwd: Endnote for an empty section?" );
2295 if ( pOldBoss != pRefBoss &&
2302 else if ( IsPageBreak(
true ) )
2308 const SwFrame *pFlow = &m_rThis;
2347 if (pNewUpper && pNewUpper->
Lower())
2350 if ( pNewNextUpper &&
2351 pNewNextUpper != m_rThis.GetUpper() &&
2359 pNewUpper = pNewNextUpper;
2360 bCheckPageDescOfNextPage =
true;
2364 bCheckPageDescs =
true;
2369 else if ( IsColBreak(
true ) )
2374 if( m_rThis.IsInSct() )
2377 if( pNewUpper && !SwFlowFrame::IsMoveBwdJump() &&
2383 pNewUpper =
nullptr;
2388 else if ( pNewUpper && !SwFlowFrame::IsMoveBwdJump() )
2401 if ( pNewNextUpper &&
2409 pNewUpper = pNewNextUpper;
2438 if( SwFlowFrame::IsMoveBwdJump() )
2440 pNewUpper = pColBody;
2456 if ( pNewNextUpper &&
2457 pNewNextUpper != m_rThis.GetUpper() &&
2465 pNewUpper = pNewNextUpper;
2473 pNewUpper = pColBody;
2479 SwFlowFrame::SetMoveBwdJump(
true );
2494 m_rThis.IsTextFrame() && !IsFollow() )
2496 sal_uInt32 nToPageNum( 0 );
2501 if ( bMoveFwdByObjPos &&
2504 pNewUpper =
nullptr;
2508 else if ( m_rThis.GetDrawObjs() )
2513 if ( pAnchoredObj->RestartLayoutProcess() &&
2514 !pAnchoredObj->IsTmpConsiderWrapInfluence() )
2516 pNewUpper =
nullptr;
2526 if ( pNewUpper && IsFollow() && pNewUpper->
Lower() )
2530 bool bProposedNewUpperContainsOnlyEmptySections(
true );
2535 if ( pLower->IsSctFrame() &&
2538 pLower = pLower->GetNext();
2543 bProposedNewUpperContainsOnlyEmptySections =
false;
2548 if ( !bProposedNewUpperContainsOnlyEmptySections )
2550 if ( SwFlowFrame::IsMoveBwdJump() )
2557 if( pNewUpper == m_rThis.GetUpper() )
2558 pNewUpper =
nullptr;
2561 pNewUpper =
nullptr;
2564 if ( pNewUpper && !ShouldBwdMoved( pNewUpper, rbReformat ) )
2566 if( !pNewUpper->
Lower() )
2582 m_rThis.setFrameAreaPositionValid(
true);
2586 pNewUpper =
nullptr;
2593 if ( pNewUpper && !IsFollow() &&
2594 m_rThis.GetAttrSet()->GetKeep().GetValue() && m_rThis.GetIndNext() )
2614 OSL_ENSURE( !pIndNext ||
dynamic_cast<const SwTextFrame*
>( pIndNext) !=
nullptr,
2615 "<SwFlowFrame::MovedBwd(..)> - incorrect next found." );
2617 SwFlowFrame::CastFlowFrame(pIndNext)->IsJoinLocked() )
2619 pNewUpper =
nullptr;
2627 if ( pNewUpper && !IsFollow() &&
2628 pNewUpper != m_rThis.GetUpper() &&
2630 *
this, *pNewUpper ) )
2633 ( !m_rThis.IsSctFrame() && m_rThis.IsInSct() )
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() ) )
2649 pNewUpper =
nullptr;
2650 OSL_FAIL(
"<SwFlowFrame::MoveBwd(..)> - layout loop control for layout action <Move Backward> applied!" );
2654 OSL_ENSURE( pNewUpper != m_rThis.GetUpper(),
2655 "<SwFlowFrame::MoveBwd(..)> - moving backward to the current upper frame!?" );
2663 pNew->
Paste( pNewUpper );
2687 pSct->
Paste( pNewUpper );
2694 bool bUnlock =
false;
2695 bool bFollow =
false;
2703 bFollow = pSect->HasFollow();
2707 auto const pOld = m_rThis.
GetUpper();
2708 ::std::optional<SwFrameDeleteGuard> g;
2709 if (m_rThis.GetUpper()->IsCellFrame())
2712 SwTabFrame const*
const pTabFrame(m_rThis.FindTabFrame());
2713 if ( pTabFrame->IsFollow()
2715 && pTabFrame->GetFirstNonHeadlineRow() == m_rThis.GetUpper()->GetUpper())
2718 g.emplace(m_rThis.GetUpper()->GetUpper());
2719 assert(m_rThis.GetUpper()->GetUpper()->IsDeleteForbidden());
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?");
2731 bool bFormatSect(
false );
2735 if( pSect->HasFollow() != bFollow )
2739 if ( pSect == pNewUpper )
2744 m_rThis.Paste( pNewUpper );
2747 pSect->
Calc(m_rThis.getRootFrame()->GetCurrShell()->GetOut());
2750 if( pNewPage != pOldPage )
2753 SwViewShell *pSh = m_rThis.getRootFrame()->GetCurrShell();
2765 if ( bCheckPageDescs && pNewPage->
GetNext() )
2767 SwPageFrame* pStartPage = bCheckPageDescOfNextPage ?
2772 else if (m_rThis.GetPageDescItem().GetPageDesc())
2781 return pNewUpper !=
nullptr;
2784SwFlowFrame *SwFlowFrame::CastFlowFrame(
SwFrame *pFrame )
2795const SwFlowFrame *SwFlowFrame::CastFlowFrame(
const SwFrame *pFrame )
2800 return static_cast<const SwTabFrame*
>(pFrame);
@ TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK
@ HEADER_SPACING_BELOW_LAST_PARA
@ PARA_SPACE_MAX_AT_PAGES
@ ADD_PARA_SPACING_TO_TABLE_CELLS
@ 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
sal_uInt16 GetUpper() const
sal_uInt16 GetLower() 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
const SwDoc * GetDoc() const
const SwFormatPageDesc & GetPageDesc(bool=true) const
const SvxFormatKeepItem & GetKeep(bool=true) const
Container of body content (i.e.
const SvxULSpaceItem & GetULSpace() const
sal_uInt16 GetTopLine(const SwFrame &_rFrame, const SwFrame *_pPrevFrame=nullptr) const
sal_uInt16 GetBottomLine(const SwFrame &_rFrame) const
sal_uInt16 CalcBottomLine() const
sal_uInt16 CalcLineSpacing() const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
const SwContentFrame * GetFollow() const
SwContentFrame * GetNextContentFrame() const
SwTextFrame * FindMaster() const
SwFormatColl * GetFormatColl() const
const SwLineNumberInfo & GetLineNumberInfo() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
IDocumentSettingAccess const & getIDocumentSettingAccess() const
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Flys that are anchored to content (at-para, at-char) but not in content (as-char).
void DelEmpty()
Like Cut(), except that follow chaining is maintained.
general base class for all free-flowing frames
bool IsFlySplitAllowed() const
Is this fly allowed to split across pages? (Disabled by default.)
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
SwPageDesc * GetPageDesc()
const ::std::optional< sal_uInt16 > & GetNumOffset() const
const SwRect & getFrameArea() const
bool isFrameAreaPositionValid() const
bool isFrameAreaSizeValid() const
Base class of the Writer layout elements.
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
SwLayoutFrame * GetPrevLeaf()
Returns the previous layout leaf where we can move the frame.
bool IsFootnoteContFrame() const
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true)
SwFrame * GetIndPrev() const
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
SwFlyFrame * FindFlyFrame()
SwSectionFrame * FindSctFrame()
SwTabFrame * FindTabFrame()
SwLayoutFrame * GetNextSctLeaf(MakePageType eMakePage)
Returns the next layout sheet where the frame can be moved in.
bool IsColumnFrame() const
SwLayoutFrame * GetNextFlyLeaf(MakePageType eMakePage)
SwFrameType GetType() const
bool IsInFootnote() const
bool IsHeaderFrame() const
SwPageFrame * InsertPage(SwPageFrame *pSibling, bool bFootnote)
virtual void Calc(vcl::RenderContext *pRenderContext) const
const SwSortedObjs * GetDrawObjs() const
SwLayoutFrame * GetPrevFlyLeaf()
static SwCache & GetCache()
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.
virtual bool IsDeleteForbidden() const
const SwAttrSet * GetAttrSet() const
WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for SwTextFrame,...
void InvalidateNextPrtArea()
method to invalidate printing area of next frame #i11859#
bool WrongPageDesc(SwPageFrame *pNew)
SwLayoutFrame * GetNextCellLeaf()
bool IsFooterFrame() const
SwLayoutFrame * GetPrevFootnoteLeaf(MakePageType eMakeFootnote)
Get the preceding layout leaf in that the frame can be moved.
bool IsFootnoteFrame() const
SwLayoutFrame * GetUpper()
const SwLayoutFrame * GetNextLayoutLeaf() const
SwLayoutFrame * GetLeaf(MakePageType eMakePage, bool bFwd)
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
SwLayoutFrame * GetNextFootnoteLeaf(MakePageType eMakePage)
Return the next layout leaf in that the frame can be moved.
SwLayoutFrame * GetNextLeaf(MakePageType eMakePage)
Returns the next layout leaf in which we can move the frame.
SwRootFrame * getRootFrame()
virtual const SvxFormatBreakItem & GetBreakItem() const
bool IsContentFrame() const
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
const SwLayoutFrame * GetPrevLayoutLeaf() const
SwPageFrame * FindPageFrame()
SwFootnoteFrame * FindFootnoteFrame()
virtual const SwFormatPageDesc & GetPageDescItem() const
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
sal_uInt16 GetPhyPageNum() const
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
bool IsLayoutFrame() const
SwLayoutFrame * GetPrevSctLeaf()
Returns the preceding layout sheet where the frame can be moved into.
bool IsColBodyFrame() const
These SwFrame inlines are here, so that frame.hxx does not need to include layfrm....
SwLayoutFrame * GetPrevCellLeaf()
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
bool IsAnLower(const SwFrame *) const
virtual const SwFrameFormat * GetFormat() const
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method <ContainsAny()> doesn't investigate content of footnotes by default.
bool IsBefore(const SwLayoutFrame *_pCheckRefLayFrame) const
method to check relative position of layout frame to a given layout frame.
const SwFrame * GetLastLower() const
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
bool MoveLowerFootnotes(SwContentFrame *pStart, SwFootnoteBossFrame *pOldBoss, SwFootnoteBossFrame *pNewBoss, const bool bFootnoteNums)
Moving the Footnotes of all Lowers - starting from StartContent.
const SwFrame * Lower() const
virtual void Cut() override
static bool FrameMovedFwdByObjPos(const SwDoc &_rDoc, const SwTextFrame &_rTextFrame, sal_uInt32 &_ornToPageNum)
static bool MoveBwdSuppressed(const SwDoc &p_rDoc, const SwFlowFrame &p_rFlowFrame, const SwLayoutFrame &p_rNewUpperFrame)
bool IsRestartEachPage() const
const SwContentNode * GetNode() const
Base class of the Writer document model elements.
SwNodeOffset GetIndex() const
SwFrameFormat * GetRightFormat(bool const bFirst=false)
Layout uses the following methods to obtain a format in order to be able to create a page.
const SwPageDesc * GetFollow() const
SwFrameFormat * GetLeftFormat(bool const bFirst=false)
A page of the document layout.
SwContentFrame * FindLastBodyContent()
Searches the last ContentFrame in BodyText below the page.
void InvalidateWordCount() const
void InvalidateAutoCompleteWords() const
sal_uInt16 GetPhyPageNum() const
const SwSortedObjs * GetSortedObjs() const
void InvalidateSmartTags() const
SwContentFrame * FindFirstBodyContent()
void InvalidateSpelling() const
SwPageDesc * FindPageDesc()
bool IsFootnotePage() const
Foot note interface.
SwPageDesc * GetPageDesc()
Of course Writer needs its own rectangles.
void Height(tools::Long nNew)
SwViewShell * GetCurrShell() const
const SwPageFrame * GetLastPage() const
void DelEmpty(bool bRemove)
bool IsContentLocked() const
SwContentFrame * FindLastContent(SwFindMode nMode=SwFindMode::None)
void SetContentLock(bool bNew)
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
SwSectionFrame * FindMaster() const
const SwSectionFrame * GetFollow() const
SwSectionFormat * GetFormat()
class for collecting anchored objects
SwTabFrame is one table in the document layout, containing rows (which contain cells).
SwTabFrame * FindMaster(bool bFirstMaster=false) const
const SwTabFrame * GetFollow() const
const SwTable * GetTable() const
bool HasFollowFlowLine() const
const SwFormatFootnote & GetFootnote() const
Represents the style of a paragraph.
Represents the visualization of a paragraph.
bool IsEmptyMaster() const
If there's a Follow and we don't contain text ourselves.
bool IsHiddenNow() const
Hidden.
SwTextNode const * GetTextNodeForParaProps() const
bool getBrowseMode() const
bool IsAction() const
SS for the Lay-/IdleAction and relatives.
SwLayAction & GetLayAction()
vcl::RenderContext * GetOut() const
const SwViewOption * GetViewOptions() const
#define PROTOCOL_ENTER(pFrame, nFunc, nAct, pPar)
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
static bool lcl_getContextualSpacing(const SwFrame *pPrevFrame)
static bool lcl_IdenticalStyles(const SwFrame *pPrevFrame, const SwFrame *pFrame)
Compare styles attached to these text frames.
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
Dialog to specify the properties of date form field.
bool IsRightPageByNumber(SwRootFrame const &rLayout, sal_uInt16 nPageNum)
bool FrameContainsNode(SwContentFrame const &rFrame, SwNodeOffset nNodeIndex)
bool HasPageBreakBefore(SwPageFrame const &rPage)
constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32)
SwTextGridItem const * GetGridItem(SwPageFrame const *const)