diff options
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r-- | sw/source/core/layout/anchoreddrawobject.cxx | 64 | ||||
-rw-r--r-- | sw/source/core/layout/anchoredobject.cxx | 148 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/calcmove.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/layout/flowfrm.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 52 | ||||
-rw-r--r-- | sw/source/core/layout/flycnt.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/layout/flyincnt.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/flylay.cxx | 117 | ||||
-rw-r--r-- | sw/source/core/layout/frmtool.cxx | 39 | ||||
-rw-r--r-- | sw/source/core/layout/layact.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/objectformattertxtfrm.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/layout/pagechg.cxx | 26 | ||||
-rw-r--r-- | sw/source/core/layout/sortedobjs.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/layout/tabfrm.cxx | 165 | ||||
-rw-r--r-- | sw/source/core/layout/trvlfrm.cxx | 74 | ||||
-rw-r--r-- | sw/source/core/layout/wsfrm.cxx | 6 |
17 files changed, 484 insertions, 286 deletions
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 6dc6cac5d1..5a9e1245af 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -214,13 +214,13 @@ SwAnchoredDrawObject::~SwAnchoredDrawObject() // --> #i62875# void SwAnchoredDrawObject::UpdateLayoutDir() { - SwFrameFormat::tLayoutDir nOldLayoutDir( GetFrameFormat().GetLayoutDir() ); + SwFrameFormat::tLayoutDir nOldLayoutDir( GetFrameFormat()->GetLayoutDir() ); SwAnchoredObject::UpdateLayoutDir(); if ( !NotYetPositioned() && - GetFrameFormat().GetLayoutDir() != nOldLayoutDir && - GetFrameFormat().GetDoc()->GetDocumentSettingManager().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) && + GetFrameFormat()->GetLayoutDir() != nOldLayoutDir && + GetFrameFormat()->GetDoc()->GetDocumentSettingManager().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) && !IsOutsidePage() ) { mbCaptureAfterLayoutDirChange = true; @@ -284,7 +284,7 @@ void SwAnchoredDrawObject::MakeObjPos() // #i44334#, #i44681# - check, if positioning // attributes already have been set. if ( dynamic_cast< const SwDrawVirtObj* >(GetDrawObj()) == nullptr && - !static_cast<SwDrawFrameFormat&>(GetFrameFormat()).IsPosAttrSet() ) + !static_cast<SwDrawFrameFormat*>(GetFrameFormat())->IsPosAttrSet() ) { SetPositioningAttr(); } @@ -395,7 +395,7 @@ void SwAnchoredDrawObject::MakeObjPosAnchoredAtPara() // Format of anchor is needed for (vertical) fly offsets, otherwise the // lack of fly portions will result in an incorrect 0 offset. - bool bAddVerticalFlyOffsets = GetFrameFormat().getIDocumentSettingAccess().get( + bool bAddVerticalFlyOffsets = GetFrameFormat()->getIDocumentSettingAccess().get( DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS); bool bFormatAnchorOnce = !bJoinLocked && bAddVerticalFlyOffsets; @@ -518,11 +518,12 @@ void SwAnchoredDrawObject::SetDrawObjAnchor() // correct object position, caused by setting new anchor position DrawObj()->Move( aMove ); // Sync textbox if it wasn't done at move - if ( SwTextBoxHelper::isTextBox(&GetFrameFormat(), RES_DRAWFRMFMT) && GetFrameFormat().GetDoc() && - GetFrameFormat().GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() && - GetFrameFormat().GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()->IsInConstructor()) + SwFrameFormat* pObjFormat = GetFrameFormat(); + if ( SwTextBoxHelper::isTextBox(pObjFormat, RES_DRAWFRMFMT) && pObjFormat->GetDoc() && + pObjFormat->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() && + pObjFormat->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()->IsInConstructor()) { - SwTextBoxHelper::changeAnchor(&GetFrameFormat(), GetFrameFormat().FindRealSdrObject()); + SwTextBoxHelper::changeAnchor(pObjFormat, pObjFormat->FindRealSdrObject()); } // --> #i70122# - missing invalidation InvalidateObjRectWithSpaces(); @@ -543,7 +544,7 @@ void SwAnchoredDrawObject::InvalidatePage_( SwPageFrame* _pPageFrame ) // --> #i35007# - correct invalidation for as-character // anchored objects. - if ( GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR ) + if ( GetFrameFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR ) { _pPageFrame->InvalidateFlyInCnt(); } @@ -582,13 +583,14 @@ void SwAnchoredDrawObject::InvalidateObjPos() // anchored object, because its positioned by the format of its anchor frame. // --> #i44559# - assure, that text hint is already // existing in the text frame + const SwFrameFormat* pObjFormat = GetFrameFormat(); if ( GetAnchorFrame()->DynCastTextFrame() != nullptr && - (GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) ) + (pObjFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) ) { SwTextFrame* pAnchorTextFrame( static_cast<SwTextFrame*>(AnchorFrame()) ); - if (pAnchorTextFrame->CalcFlyPos(&GetFrameFormat()) != TextFrameIndex(COMPLETE_STRING)) + if (pAnchorTextFrame->CalcFlyPos(pObjFormat) != TextFrameIndex(COMPLETE_STRING)) { - AnchorFrame()->Prepare( PrepareHint::FlyFrameAttributesChanged, &GetFrameFormat() ); + AnchorFrame()->Prepare(PrepareHint::FlyFrameAttributesChanged, pObjFormat); } } @@ -615,15 +617,17 @@ void SwAnchoredDrawObject::InvalidateObjPos() } } -SwFrameFormat& SwAnchoredDrawObject::GetFrameFormat() +SwFrameFormat* SwAnchoredDrawObject::GetFrameFormat() { - assert(static_cast<SwDrawContact*>(GetUserCall(GetDrawObj()))->GetFormat()); - return *(static_cast<SwDrawContact*>(GetUserCall(GetDrawObj()))->GetFormat()); + if (SwDrawContact* pDC = static_cast<SwDrawContact*>(GetUserCall(GetDrawObj()))) + return pDC->GetFormat(); + return nullptr; } -const SwFrameFormat& SwAnchoredDrawObject::GetFrameFormat() const +const SwFrameFormat* SwAnchoredDrawObject::GetFrameFormat() const { - assert(static_cast<SwDrawContact*>(GetUserCall(GetDrawObj()))->GetFormat()); - return *(static_cast<SwDrawContact*>(GetUserCall(GetDrawObj()))->GetFormat()); + if (SwDrawContact* pDC = static_cast<SwDrawContact*>(GetUserCall(GetDrawObj()))) + return pDC->GetFormat(); + return nullptr; } SwRect SwAnchoredDrawObject::GetObjRect() const @@ -807,10 +811,11 @@ void SwAnchoredDrawObject::AdjustPositioningAttr( const SwFrame* _pNewAnchorFram SwFormatHoriOrient hori(nHoriRelPos, text::HoriOrientation::NONE, text::RelOrientation::FRAME); SwFormatVertOrient vert(nVertRelPos, text::VertOrientation::NONE, text::RelOrientation::FRAME); - SfxItemSetFixed<RES_VERT_ORIENT, RES_HORI_ORIENT> items(GetFrameFormat().GetDoc()->GetAttrPool()); + SwFrameFormat* pObjFormat = GetFrameFormat(); + SfxItemSetFixed<RES_VERT_ORIENT, RES_HORI_ORIENT> items(pObjFormat->GetDoc()->GetAttrPool()); items.Put(hori); items.Put(vert); - GetFrameFormat().GetDoc()->SetAttr(items, GetFrameFormat()); + pObjFormat->GetDoc()->SetAttr(items, *pObjFormat); } // --> #i34748# - change return type. @@ -845,6 +850,7 @@ void SwAnchoredDrawObject::SetPositioningAttr() SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall( GetDrawObj() )); + SwFrameFormat* pObjFormat = GetFrameFormat(); if ( !pDrawContact->ObjAnchoredAsChar() ) { SwRect aObjRect( GetObjRect() ); @@ -853,10 +859,10 @@ void SwAnchoredDrawObject::SetPositioningAttr() SwTwips nVertPos = aObjRect.Top(); // #i44334#, #i44681# // perform conversion only if position is in horizontal-left-to-right-layout. - if ( GetFrameFormat().GetPositionLayoutDir() == + if (pObjFormat->GetPositionLayoutDir() == text::PositionLayoutDir::PositionInHoriL2R ) { - SwFrameFormat::tLayoutDir eLayoutDir = GetFrameFormat().GetLayoutDir(); + SwFrameFormat::tLayoutDir eLayoutDir = pObjFormat->GetLayoutDir(); switch ( eLayoutDir ) { case SwFrameFormat::HORI_L2R: @@ -885,28 +891,28 @@ void SwAnchoredDrawObject::SetPositioningAttr() // --> #i71182# // only change position - do not lose other attributes - SwFormatHoriOrient aHori( GetFrameFormat().GetHoriOrient() ); + SwFormatHoriOrient aHori(pObjFormat->GetHoriOrient()); if (nHoriPos != aHori.GetPos()) { aHori.SetPos( nHoriPos ); InvalidateObjRectWithSpaces(); - GetFrameFormat().SetFormatAttr( aHori ); + pObjFormat->SetFormatAttr(aHori); } - SwFormatVertOrient aVert( GetFrameFormat().GetVertOrient() ); + SwFormatVertOrient aVert(pObjFormat->GetVertOrient()); if (nVertPos != aVert.GetPos()) { aVert.SetPos( nVertPos ); InvalidateObjRectWithSpaces(); - GetFrameFormat().SetFormatAttr( aVert ); + pObjFormat->SetFormatAttr(aVert); } // --> #i36010# - set layout direction of the position - GetFrameFormat().SetPositionLayoutDir( + pObjFormat->SetPositionLayoutDir( text::PositionLayoutDir::PositionInLayoutDirOfAnchor ); } // --> #i65798# - also for as-character anchored objects // --> #i45952# - indicate that position // attributes are set now. - static_cast<SwDrawFrameFormat&>(GetFrameFormat()).PosAttrSet(); + static_cast<SwDrawFrameFormat*>(pObjFormat)->PosAttrSet(); } void SwAnchoredDrawObject::NotifyBackground( SwPageFrame* _pPageFrame, diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx index 42e7dd39fc..a74438afb3 100644 --- a/sw/source/core/layout/anchoredobject.cxx +++ b/sw/source/core/layout/anchoredobject.cxx @@ -32,6 +32,7 @@ #include <layouter.hxx> #include <osl/diagnose.h> #include <flyfrms.hxx> +#include <dcontact.hxx> using namespace ::com::sun::star; @@ -215,7 +216,7 @@ void SwAnchoredObject::CheckCharRectAndTopOfLine( GetAnchorFrame()->IsTextFrame()) ) return; - const SwFormatAnchor& rAnch = GetFrameFormat().GetAnchor(); + const SwFormatAnchor& rAnch = GetFrameFormat()->GetAnchor(); if ( !((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) && rAnch.GetAnchorNode()) ) return; @@ -262,8 +263,9 @@ void SwAnchoredObject::CheckCharRect( const SwFormatAnchor& _rAnch, { SwRectFnSet aRectFnSet(&_rAnchorCharFrame); // determine positioning and alignment - SwFormatVertOrient aVert( GetFrameFormat().GetVertOrient() ); - SwFormatHoriOrient aHori( GetFrameFormat().GetHoriOrient() ); + const SwFrameFormat* pObjFormat = GetFrameFormat(); + SwFormatVertOrient aVert( pObjFormat->GetVertOrient() ); + SwFormatHoriOrient aHori( pObjFormat->GetHoriOrient() ); // check for anchor character rectangle changes for certain // positionings and alignments // add condition to invalidate position, @@ -316,7 +318,7 @@ void SwAnchoredObject::CheckTopOfLine( const SwFormatAnchor& _rAnch, return; // check alignment for invalidation of position - if ( GetFrameFormat().GetVertOrient().GetRelationOrient() == text::RelOrientation::TEXT_LINE ) + if ( GetFrameFormat()->GetVertOrient().GetRelationOrient() == text::RelOrientation::TEXT_LINE ) { // #i26945#, #i35911# - unlock position of // anchored object, if it isn't registered at the page, @@ -373,7 +375,7 @@ void SwAnchoredObject::UpdateLayoutDir() nLayoutDir = SwFrameFormat::HORI_R2L; } } - GetFrameFormat().SetLayoutDir( nLayoutDir ); + GetFrameFormat()->SetLayoutDir( nLayoutDir ); } /** method to perform necessary invalidations for the positioning of @@ -408,29 +410,31 @@ bool SwAnchoredObject::ConsiderObjWrapInfluenceOnObjPos() const { bool bRet( false ); - const SwFrameFormat& rObjFormat = GetFrameFormat(); - - // --> #i3317# - add condition <IsTmpConsiderWrapInfluence()> - // --> #i55204# - // - correction: wrapping style influence has been considered, if condition - // <IsTmpConsiderWrapInfluence()> is hold, regardless of its anchor type - // or its wrapping style. - if ( IsTmpConsiderWrapInfluence() ) - { - bRet = true; - } - else if ( rObjFormat.getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) ) + if (const SwFrameFormat* pObjFormat = GetFrameFormat()) { - const SwFormatAnchor& rAnchor = rObjFormat.GetAnchor(); - if ( ((rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR) || - (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA)) && - rObjFormat.GetSurround().GetSurround() != css::text::WrapTextMode_THROUGH ) + // --> #i3317# - add condition <IsTmpConsiderWrapInfluence()> + // --> #i55204# + // - correction: wrapping style influence has been considered, if condition + // <IsTmpConsiderWrapInfluence()> is hold, regardless of its anchor type + // or its wrapping style. + if (IsTmpConsiderWrapInfluence()) { - // --> #i34520# - text also wraps around anchored - // objects in the layer Hell - see the text formatting. - // Thus, it hasn't to be checked here. bRet = true; } + else if (pObjFormat->getIDocumentSettingAccess().get( + DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION)) + { + const SwFormatAnchor& rAnchor = pObjFormat->GetAnchor(); + if (((rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR) + || (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA)) + && pObjFormat->GetSurround().GetSurround() != css::text::WrapTextMode_THROUGH) + { + // --> #i34520# - text also wraps around anchored + // objects in the layer Hell - see the text formatting. + // Thus, it hasn't to be checked here. + bRet = true; + } + } } return bRet; @@ -567,18 +571,22 @@ const SwRect& SwAnchoredObject::GetObjRectWithSpaces() const if ( !mbObjRectWithSpacesValid ) { maObjRectWithSpaces = GetObjBoundRect(); - const SwFrameFormat& rFormat = GetFrameFormat(); - const SvxULSpaceItem& rUL = rFormat.GetULSpace(); - const SvxLRSpaceItem& rLR = rFormat.GetLRSpace(); + if (const SwFrameFormat* pFormat = GetFrameFormat()) { - maObjRectWithSpaces.Top ( std::max( maObjRectWithSpaces.Top() - tools::Long(rUL.GetUpper()), tools::Long(0) )); - maObjRectWithSpaces.Left( std::max( maObjRectWithSpaces.Left()- rLR.GetLeft(), tools::Long(0) )); - maObjRectWithSpaces.AddHeight(rUL.GetLower() ); - maObjRectWithSpaces.AddWidth(rLR.GetRight() ); - } + const SvxULSpaceItem& rUL = pFormat->GetULSpace(); + const SvxLRSpaceItem& rLR = pFormat->GetLRSpace(); + { + maObjRectWithSpaces.Top(std::max( + maObjRectWithSpaces.Top() - tools::Long(rUL.GetUpper()), tools::Long(0))); + maObjRectWithSpaces.Left( + std::max(maObjRectWithSpaces.Left() - rLR.GetLeft(), tools::Long(0))); + maObjRectWithSpaces.AddHeight(rUL.GetLower()); + maObjRectWithSpaces.AddWidth(rLR.GetRight()); + } - mbObjRectWithSpacesValid = true; - maLastObjRect = GetObjRect(); + mbObjRectWithSpacesValid = true; + maLastObjRect = GetObjRect(); + } } return maObjRectWithSpaces; @@ -617,7 +625,7 @@ void SwAnchoredObject::UpdateObjInSortedList() if(!GetAnchorFrame()) return; - if ( GetFrameFormat().getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) ) + if ( GetFrameFormat()->getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) ) { // invalidate position of all anchored objects at anchor frame if ( GetAnchorFrame()->GetDrawObjs() ) @@ -652,7 +660,7 @@ void SwAnchoredObject::UpdateObjInSortedList() // update its position in the sorted object list of its page frame // note: as-character anchored object aren't registered at a page frame if ( GetPageFrame() && GetPageFrame()->GetSortedObjs() && - GetFrameFormat().GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR ) + GetFrameFormat()->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR ) { GetPageFrame()->GetSortedObjs()->Update( *this ); } @@ -709,39 +717,43 @@ SwTextFrame* SwAnchoredObject::FindAnchorCharFrame() // --> #i44339# - check, if anchor frame exists. if ( mpAnchorFrame ) { - const SwFormatAnchor& rAnch = GetFrameFormat().GetAnchor(); - if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) || - (rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR)) + if (const SwFrameFormat* pFormat = GetFrameFormat()) { - SwTextFrame *const pFrame(static_cast<SwTextFrame*>(AnchorFrame())); - TextFrameIndex const nOffset(pFrame->MapModelToViewPos(*rAnch.GetContentAnchor())); - pAnchorCharFrame = &pFrame->GetFrameAtOfst(nOffset); - } - else if (SwFlyFrame* pFlyFrame = DynCastFlyFrame()) - { - // See if this fly is split. If so, then the anchor is also split. All anchors are - // empty, except the last follow. - if (pFlyFrame->IsFlySplitAllowed()) + const SwFormatAnchor& rAnch = pFormat->GetAnchor(); + if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) + || (rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR)) + { + SwTextFrame* const pFrame(static_cast<SwTextFrame*>(AnchorFrame())); + TextFrameIndex const nOffset(pFrame->MapModelToViewPos(*rAnch.GetContentAnchor())); + pAnchorCharFrame = &pFrame->GetFrameAtOfst(nOffset); + } + else if (SwFlyFrame* pFlyFrame = DynCastFlyFrame()) { - auto pFlyAtContentFrame = static_cast<SwFlyAtContentFrame*>(pFlyFrame); - SwFlyAtContentFrame* pFly = pFlyAtContentFrame; - SwTextFrame* pAnchor = static_cast<SwTextFrame*>(AnchorFrame()); - // If we have to jump back N frames to find the master fly, then we have to step N - // frames from the master anchor to reach the correct follow anchor. - while (pFly->GetPrecede()) + // See if this fly is split. If so, then the anchor is also split. All anchors are + // empty, except the last follow. + if (pFlyFrame->IsFlySplitAllowed()) { - pFly = pFly->GetPrecede(); - if (!pAnchor) + auto pFlyAtContentFrame = static_cast<SwFlyAtContentFrame*>(pFlyFrame); + SwFlyAtContentFrame* pFly = pFlyAtContentFrame; + SwTextFrame* pAnchor = static_cast<SwTextFrame*>(AnchorFrame()); + // If we have to jump back N frames to find the master fly, then we have to step N + // frames from the master anchor to reach the correct follow anchor. + while (pFly->GetPrecede()) { - SAL_WARN("sw.layout", "SwAnchoredObject::FindAnchorCharFrame: fly chain " - "length is longer then anchor chain length"); - break; + pFly = pFly->GetPrecede(); + if (!pAnchor) + { + SAL_WARN("sw.layout", + "SwAnchoredObject::FindAnchorCharFrame: fly chain " + "length is longer then anchor chain length"); + break; + } + pAnchor = pAnchor->GetFollow(); + } + if (pAnchor) + { + pAnchorCharFrame = pAnchor; } - pAnchor = pAnchor->GetFollow(); - } - if (pAnchor) - { - pAnchorCharFrame = pAnchor; } } } @@ -758,7 +770,9 @@ SwTextFrame* SwAnchoredObject::FindAnchorCharFrame() */ bool SwAnchoredObject::IsFormatPossible() const { - return GetFrameFormat().GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( GetDrawObj()->GetLayer() ); + if (const SwFrameFormat* pFormat = GetFrameFormat()) + return pFormat->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( GetDrawObj()->GetLayer() ); + return false; } bool SwAnchoredObject::IsDraggingOffPageAllowed(const SwFrameFormat* pFrameFormat) @@ -777,7 +791,7 @@ void SwAnchoredObject::SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrap // --> #i35911# if ( mbTmpConsiderWrapInfluence ) { - SwLayouter::InsertObjForTmpConsiderWrapInfluence( *(GetFrameFormat().GetDoc()), + SwLayouter::InsertObjForTmpConsiderWrapInfluence( *(GetFrameFormat()->GetDoc()), *this ); } } @@ -787,7 +801,7 @@ void SwAnchoredObject::ClearTmpConsiderWrapInfluence() mbTmpConsiderWrapInfluence = false; mbClearedEnvironment = false; SetClearedEnvironment( false ); - SwLayouter::RemoveObjForTmpConsiderWrapInfluence( *(GetFrameFormat().GetDoc()), + SwLayouter::RemoveObjForTmpConsiderWrapInfluence( *(GetFrameFormat()->GetDoc()), *this ); } void SwAnchoredObject::SetTmpConsiderWrapInfluenceOfOtherObjs() diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 2a1ab80763..5e95d1aaf7 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3121,7 +3121,7 @@ void SwFlyFrameFormat::MakeFrames() // #i28701# - consider changed type of // <SwSortedObjs> entries. if( pObj->DynCastFlyFrame() != nullptr && - (&pObj->GetFrameFormat()) == this ) + (pObj->GetFrameFormat()) == this ) { bAdd = false; break; diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 4d4b2de289..c2bbdd8904 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -1131,18 +1131,18 @@ void SwContentFrame::MakePrtArea( const SwBorderAttrs &rAttrs ) // #i28701# - consider changed type of // <SwSortedObjs> entries SwAnchoredObject* pObj = (*GetDrawObjs())[i]; - const SwFrameFormat& rFormat = pObj->GetFrameFormat(); + const SwFrameFormat* pFormat = pObj->GetFrameFormat(); const bool bFly = pObj->DynCastFlyFrame() != nullptr; if ((bFly && (FAR_AWAY == pObj->GetObjRect().Width())) - || rFormat.GetFrameSize().GetWidthPercent()) + || pFormat->GetFrameSize().GetWidthPercent()) { continue; } - if ( RndStdIds::FLY_AS_CHAR == rFormat.GetAnchor().GetAnchorId() ) + if ( RndStdIds::FLY_AS_CHAR == pFormat->GetAnchor().GetAnchorId() ) { nMinWidth = std::max( nMinWidth, - bFly ? rFormat.GetFrameSize().GetWidth() + bFly ? pFormat->GetFrameSize().GetWidth() : pObj->GetObjRect().Width() ); } } diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 981736de70..da509e2a6b 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -217,7 +217,7 @@ bool IsNextContentFullPage(const SwFrame& rThis) continue; } - const SwFormatSurround& rSurround = pDrawObj->GetFrameFormat().GetSurround(); + const SwFormatSurround& rSurround = pDrawObj->GetFrameFormat()->GetSurround(); if (rSurround.GetSurround() != text::WrapTextMode_NONE) { continue; @@ -379,10 +379,10 @@ sal_uInt8 SwFlowFrame::BwdMoveNecessary( const SwPageFrame *pPage, const SwRect { SwAnchoredObject* pObj = rObjs[i]; - const SwFrameFormat& rFormat = pObj->GetFrameFormat(); + const SwFrameFormat* pFormat = pObj->GetFrameFormat(); const SwRect aRect( pObj->GetObjRect() ); if ( aRect.Overlaps( rRect ) && - rFormat.GetSurround().GetSurround() != css::text::WrapTextMode_THROUGH ) + pFormat->GetSurround().GetSurround() != css::text::WrapTextMode_THROUGH ) { if( m_rThis.IsLayoutFrame() && //Fly Lower of This? Is_Lower_Of( &m_rThis, pObj->GetDrawObj() ) ) @@ -404,10 +404,10 @@ sal_uInt8 SwFlowFrame::BwdMoveNecessary( const SwPageFrame *pPage, const SwRect // flow, because then I wouldn't evade it. if ( ::IsFrameInSameContext( pAnchor, &m_rThis ) ) { - if ( rFormat.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PARA ) + if ( pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PARA ) { // The index of the other one can be retrieved using the anchor attribute. - SwNodeOffset nTmpIndex = rFormat.GetAnchor().GetAnchorNode()->GetIndex(); + SwNodeOffset nTmpIndex = pFormat->GetAnchor().GetAnchorNode()->GetIndex(); // Now we're going to check whether the current paragraph before // the anchor of the displacing object sits in the text. If this // is the case, we don't try to evade it. @@ -1224,13 +1224,13 @@ bool SwFlowFrame::IsPrevObjMove() const // text flow to the next layout frame for (SwAnchoredObject* pObj : *pPre->GetDrawObjs()) { - + const SwFrameFormat* pObjFormat = pObj->GetFrameFormat(); // Do not consider hidden objects // i#26945 - do not consider object, which // doesn't follow the text flow. - if ( pObj->GetFrameFormat().GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( + if ( pObjFormat->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( pObj->GetDrawObj()->GetLayer() ) && - pObj->GetFrameFormat().GetFollowTextFlow().GetValue() ) + pObjFormat->GetFollowTextFlow().GetValue() ) { const SwLayoutFrame* pVertPosOrientFrame = pObj->GetVertPosOrientFrame(); if ( pVertPosOrientFrame && diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index d23c30a0aa..db50a42de0 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -43,6 +43,7 @@ #include <svx/svdoashp.hxx> #include <svx/svdpage.hxx> #include <layouter.hxx> +#include <layact.hxx> #include <pagefrm.hxx> #include <rootfrm.hxx> #include <viewimp.hxx> @@ -99,10 +100,10 @@ SwTwips GetFlyAnchorBottom(SwFlyFrame* pFly, const SwFrame& rAnchor) return 0; } - const auto& rFrameFormat = pFly->GetFrameFormat(); - const IDocumentSettingAccess& rIDSA = rFrameFormat.getIDocumentSettingAccess(); + const auto* pFrameFormat = pFly->GetFrameFormat(); + const IDocumentSettingAccess& rIDSA = pFrameFormat->getIDocumentSettingAccess(); // Allow overlap with bottom margin / footer only in case we're relative to the page frame. - bool bVertPageFrame = rFrameFormat.GetVertOrient().GetRelationOrient() == text::RelOrientation::PAGE_FRAME; + bool bVertPageFrame = pFrameFormat->GetVertOrient().GetRelationOrient() == text::RelOrientation::PAGE_FRAME; bool bInBody = rAnchor.IsInDocBody(); bool bLegacy = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN) && (bVertPageFrame || !bInBody); if (bLegacy) @@ -1271,7 +1272,7 @@ void SwFlyFrame::ChgRelPos( const Point &rNewPos ) const SwTextFrame *pAutoFrame = nullptr; // #i34948# - handle also at-page and at-fly anchored // Writer fly frames - const RndStdIds eAnchorType = GetFrameFormat().GetAnchor().GetAnchorId(); + const RndStdIds eAnchorType = GetFrameFormat()->GetAnchor().GetAnchorId(); if ( eAnchorType == RndStdIds::FLY_AT_PAGE ) { aVert.SetVertOrient( text::VertOrientation::NONE ); @@ -1741,6 +1742,10 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) if (!SwObjectFormatter::FormatObj(*pAnchoredObj, pAnchorFrame, pAnchorPageFrame, rShell.Imp()->IsAction() ? &rShell.Imp()->GetLayAction() : nullptr)) { + if (rShell.Imp()->IsAction() && rShell.Imp()->GetLayAction().IsAgain()) + { // tdf#159015 will always fail, don't loop + return; + } bRestartLayoutProcess = true; break; } @@ -1759,13 +1764,13 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) { OSL_FAIL( "::CalcContent(..) - loop detected, perform attribute changes to avoid the loop" ); // Prevent oscillation - SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat(); - SwFormatSurround aAttr( rFormat.GetSurround() ); + SwFrameFormat* pFormat = pAnchoredObj->GetFrameFormat(); + SwFormatSurround aAttr( pFormat->GetSurround() ); if( css::text::WrapTextMode_THROUGH != aAttr.GetSurround() ) { // When on auto position, we can only set it to // flow through - if ((rFormat.GetAnchor().GetAnchorId() == + if ((pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) && (css::text::WrapTextMode_PARALLEL == aAttr.GetSurround())) @@ -1776,9 +1781,9 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) { aAttr.SetSurround( css::text::WrapTextMode_PARALLEL ); } - rFormat.LockModify(); - rFormat.SetFormatAttr( aAttr ); - rFormat.UnlockModify(); + pFormat->LockModify(); + pFormat->SetFormatAttr( aAttr ); + pFormat->UnlockModify(); } } else @@ -2054,7 +2059,7 @@ bool SwFlyFrame::IsShowUnfloatButton(SwWrtShell* pWrtSh) const if (pWrtSh->GetViewOptions()->IsReadonly()) return false; - const SdrObject *pObj = GetFrameFormat().FindRealSdrObject(); + const SdrObject *pObj = GetFrameFormat()->FindRealSdrObject(); if (pObj == nullptr) return false; @@ -2594,12 +2599,15 @@ void SwFrame::RemoveDrawObj( SwAnchoredObject& _rToRemoveObj ) { // Notify accessible layout. #if !ENABLE_WASM_STRIP_ACCESSIBILITY - SwViewShell* pSh = getRootFrame()->GetCurrShell(); - if( pSh ) + if (!mbInDtor) { - SwRootFrame* pLayout = getRootFrame(); - if (pLayout && pLayout->IsAnyShellAccessible()) - pSh->Imp()->DisposeAccessibleObj(_rToRemoveObj.GetDrawObj(), false); + SwViewShell* pSh = getRootFrame()->GetCurrShell(); + if (pSh) + { + SwRootFrame* pLayout = getRootFrame(); + if (pLayout && pLayout->IsAnyShellAccessible()) + pSh->Imp()->DisposeAccessibleObj(_rToRemoveObj.GetDrawObj(), false); + } } #endif @@ -2631,7 +2639,7 @@ void SwFrame::InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs ) for (SwAnchoredObject* pAnchoredObj : *GetDrawObjs()) { if ( _bNoInvaOfAsCharAnchoredObjs && - (pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId() + (pAnchoredObj->GetFrameFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) ) { continue; @@ -2738,7 +2746,7 @@ void SwLayoutFrame::NotifyLowerObjs( const bool _bUnlockPosOfObjs ) bool isPositionedByHF(false); if (IsHeaderFrame() || IsFooterFrame()) { - auto const nO(pObj->GetFrameFormat().GetVertOrient().GetRelationOrient()); + auto const nO(pObj->GetFrameFormat()->GetVertOrient().GetRelationOrient()); if (nO == text::RelOrientation::PAGE_PRINT_AREA || nO == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM || nO == text::RelOrientation::PAGE_PRINT_AREA_TOP) @@ -3093,17 +3101,17 @@ void SwFlyFrame::InvalidateObjPos() InvalidateObjRectWithSpaces(); } -SwFrameFormat& SwFlyFrame::GetFrameFormat() +SwFrameFormat* SwFlyFrame::GetFrameFormat() { OSL_ENSURE( GetFormat(), "<SwFlyFrame::GetFrameFormat()> - missing frame format -> crash." ); - return *GetFormat(); + return GetFormat(); } -const SwFrameFormat& SwFlyFrame::GetFrameFormat() const +const SwFrameFormat* SwFlyFrame::GetFrameFormat() const { OSL_ENSURE( GetFormat(), "<SwFlyFrame::GetFrameFormat()> - missing frame format -> crash." ); - return *GetFormat(); + return GetFormat(); } SwRect SwFlyFrame::GetObjRect() const diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index a53b8841f8..2ed6fbf089 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -162,13 +162,13 @@ void SwFlyAtContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rH // of the given fly frame format is registered. if(bFound && pContent && pContent->GetDrawObjs()) { - SwFrameFormat* pMyFlyFrameFormat(&GetFrameFormat()); + SwFrameFormat* pMyFlyFrameFormat(GetFrameFormat()); SwSortedObjs &rObjs = *pContent->GetDrawObjs(); for(SwAnchoredObject* rObj : rObjs) { SwFlyFrame* pFlyFrame = rObj->DynCastFlyFrame(); if (pFlyFrame && - &(pFlyFrame->GetFrameFormat()) == pMyFlyFrameFormat) + pFlyFrame->GetFrameFormat() == pMyFlyFrameFormat) { bFound = false; break; @@ -330,7 +330,8 @@ bool SwOszControl::ChkOsz() |*/ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* pRenderContext) { - if ( !GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) ) + const SwDoc& rDoc = *(GetFormat()->GetDoc()); + if (!rDoc.getIDocumentDrawModelAccess().IsVisibleLayerId(GetVirtDrawObj()->GetLayer())) { return; } @@ -450,7 +451,6 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* pRenderContext) SwTextFrame* pAnchorTextFrame( static_cast<SwTextFrame*>(AnchorFrame()) ); bool bInsert( true ); sal_uInt32 nAnchorFrameToPageNum( 0 ); - const SwDoc& rDoc = *(GetFrameFormat().GetDoc()); if ( SwLayouter::FrameMovedFwdByObjPos( rDoc, *pAnchorTextFrame, nAnchorFrameToPageNum ) ) { @@ -518,7 +518,7 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* pRenderContext) !bConsiderWrapInfluenceDueToOverlapPrevCol && // #i40444# !bConsiderWrapInfluenceDueToMovedFwdAnchor && - GetFormat()->GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) ); + rDoc.getIDocumentDrawModelAccess().IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) ); // #i3317# - instead of attribute change apply // temporarily the 'straightforward positioning process'. diff --git a/sw/source/core/layout/flyincnt.cxx b/sw/source/core/layout/flyincnt.cxx index 7fb8f93f16..36c7837e95 100644 --- a/sw/source/core/layout/flyincnt.cxx +++ b/sw/source/core/layout/flyincnt.cxx @@ -191,7 +191,7 @@ void SwFlyInContentFrame::MakeObjPos() void SwFlyInContentFrame::ActionOnInvalidation( const InvalidationType _nInvalid ) { if ( INVALID_POS == _nInvalid || INVALID_ALL == _nInvalid ) - AnchorFrame()->Prepare( PrepareHint::FlyFrameAttributesChanged, &GetFrameFormat() ); + AnchorFrame()->Prepare( PrepareHint::FlyFrameAttributesChanged, GetFrameFormat() ); } void SwFlyInContentFrame::NotifyBackground( SwPageFrame *, const SwRect& rRect, diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 457a0d41bb..7ac95d65e0 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -153,7 +153,7 @@ void SwFlyFreeFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) if ( !IsNoMoveOnCheckClip() && !( PositionLocked() && GetAnchorFrame()->IsInFly() && - GetFrameFormat().GetFollowTextFlow().GetValue() ) ) + GetFrameFormat()->GetFollowTextFlow().GetValue() ) ) { setFrameAreaPositionValid(false); } @@ -1100,7 +1100,7 @@ void SwPageFrame::AppendDrawObjToPage( SwAnchoredObject& _rNewObj ) pFlyFrame->GetVirtDrawObj()->SetOrdNum( nNewNum ); } - if ( RndStdIds::FLY_AS_CHAR == _rNewObj.GetFrameFormat().GetAnchor().GetAnchorId() ) + if ( RndStdIds::FLY_AS_CHAR == _rNewObj.GetFrameFormat()->GetAnchor().GetAnchorId() ) { return; } @@ -1140,8 +1140,9 @@ void SwPageFrame::RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj ) } if ( GetUpper() ) { - if (RndStdIds::FLY_AS_CHAR != - _rToRemoveObj.GetFrameFormat().GetAnchor().GetAnchorId()) + const SwFrameFormat* pObjFormat = _rToRemoveObj.GetFrameFormat(); + if (pObjFormat + && RndStdIds::FLY_AS_CHAR != pObjFormat->GetAnchor().GetAnchorId()) { static_cast<SwRootFrame*>(GetUpper())->SetSuperfluous(); InvalidatePage(); @@ -1454,63 +1455,67 @@ bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove ) } else { - const SwDrawContact *pC = static_cast<const SwDrawContact*>(GetUserCall(pSdrObj)); - const SwFrameFormat *pFormat = pC->GetFormat(); - const SwFormatAnchor &rAnch = pFormat->GetAnchor(); - if ( RndStdIds::FLY_AS_CHAR == rAnch.GetAnchorId() ) + if (const SwDrawContact* pC = static_cast<const SwDrawContact*>(GetUserCall(pSdrObj))) { - const SwFrame* pAnchorFrame = pC->GetAnchorFrame( pSdrObj ); - if( !pAnchorFrame ) + const SwFrameFormat* pFormat = pC->GetFormat(); + const SwFormatAnchor& rAnch = pFormat->GetAnchor(); + if (RndStdIds::FLY_AS_CHAR == rAnch.GetAnchorId()) { - OSL_FAIL( "<::CalcClipRect(..)> - missing anchor frame." ); - const_cast<SwDrawContact*>(pC)->ConnectToLayout(); - pAnchorFrame = pC->GetAnchorFrame(); - } - const SwFrame* pUp = pAnchorFrame->GetUpper(); - rRect = pUp->getFramePrintArea(); - rRect += pUp->getFrameArea().Pos(); - SwRectFnSet aRectFnSet(pAnchorFrame); - tools::Long nHeight = (9*aRectFnSet.GetHeight(rRect))/10; - tools::Long nTop; - const SvxULSpaceItem &rUL = pFormat->GetULSpace(); - SwRect aSnapRect( pSdrObj->GetSnapRect() ); - tools::Long nTmpH = 0; - if( bMove ) - { - nTop = aRectFnSet.YInc( aRectFnSet.IsVert() ? pSdrObj->GetAnchorPos().X() : - pSdrObj->GetAnchorPos().Y(), -nHeight ); - tools::Long nWidth = aRectFnSet.GetWidth(aSnapRect); - aRectFnSet.SetLeftAndWidth( rRect, aRectFnSet.IsVert() ? - pSdrObj->GetAnchorPos().Y() : - pSdrObj->GetAnchorPos().X(), nWidth ); - } - else - { - // #i26791# - value of <nTmpH> is needed to - // calculate value of <nTop>. - nTmpH = aRectFnSet.IsVert() ? pSdrObj->GetCurrentBoundRect().GetWidth() : - pSdrObj->GetCurrentBoundRect().GetHeight(); - nTop = aRectFnSet.YInc( aRectFnSet.GetTop(aSnapRect), - rUL.GetLower() + nTmpH - nHeight ); - } - nHeight = 2*nHeight - nTmpH - rUL.GetLower() - rUL.GetUpper(); - aRectFnSet.SetTopAndHeight( rRect, nTop, nHeight ); - } - else - { - // restrict clip rectangle for drawing - // objects in header/footer to the page frame. - // #i26791# - const SwFrame* pAnchorFrame = pC->GetAnchorFrame( pSdrObj ); - if ( pAnchorFrame && pAnchorFrame->FindFooterOrHeader() ) - { - // clip frame is the page frame the header/footer is on. - const SwFrame* pClipFrame = pAnchorFrame->FindPageFrame(); - rRect = pClipFrame->getFrameArea(); + const SwFrame* pAnchorFrame = pC->GetAnchorFrame(pSdrObj); + if (!pAnchorFrame) + { + OSL_FAIL("<::CalcClipRect(..)> - missing anchor frame."); + const_cast<SwDrawContact*>(pC)->ConnectToLayout(); + pAnchorFrame = pC->GetAnchorFrame(); + } + const SwFrame* pUp = pAnchorFrame->GetUpper(); + rRect = pUp->getFramePrintArea(); + rRect += pUp->getFrameArea().Pos(); + SwRectFnSet aRectFnSet(pAnchorFrame); + tools::Long nHeight = (9 * aRectFnSet.GetHeight(rRect)) / 10; + tools::Long nTop; + const SvxULSpaceItem& rUL = pFormat->GetULSpace(); + SwRect aSnapRect(pSdrObj->GetSnapRect()); + tools::Long nTmpH = 0; + if (bMove) + { + nTop = aRectFnSet.YInc(aRectFnSet.IsVert() ? pSdrObj->GetAnchorPos().X() + : pSdrObj->GetAnchorPos().Y(), + -nHeight); + tools::Long nWidth = aRectFnSet.GetWidth(aSnapRect); + aRectFnSet.SetLeftAndWidth(rRect, + aRectFnSet.IsVert() ? pSdrObj->GetAnchorPos().Y() + : pSdrObj->GetAnchorPos().X(), + nWidth); + } + else + { + // #i26791# - value of <nTmpH> is needed to + // calculate value of <nTop>. + nTmpH = aRectFnSet.IsVert() ? pSdrObj->GetCurrentBoundRect().GetWidth() + : pSdrObj->GetCurrentBoundRect().GetHeight(); + nTop = aRectFnSet.YInc(aRectFnSet.GetTop(aSnapRect), + rUL.GetLower() + nTmpH - nHeight); + } + nHeight = 2 * nHeight - nTmpH - rUL.GetLower() - rUL.GetUpper(); + aRectFnSet.SetTopAndHeight(rRect, nTop, nHeight); } else { - bRet = false; + // restrict clip rectangle for drawing + // objects in header/footer to the page frame. + // #i26791# + const SwFrame* pAnchorFrame = pC->GetAnchorFrame(pSdrObj); + if (pAnchorFrame && pAnchorFrame->FindFooterOrHeader()) + { + // clip frame is the page frame the header/footer is on. + const SwFrame* pClipFrame = pAnchorFrame->FindPageFrame(); + rRect = pClipFrame->getFrameArea(); + } + else + { + bRet = false; + } } } } diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index c3fa35fcdc..eeab5c60c1 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1025,7 +1025,7 @@ void SwContentNotify::ImplDestroy() SwSortedObjs* pObjs = pMasterFrame->GetDrawObjs(); for (SwAnchoredObject* pAnchoredObj : *pObjs) { - if ( pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId() + if ( pAnchoredObj->GetFrameFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR ) { pAnchoredObj->CheckCharRectAndTopOfLine( !pMasterFrame->IsEmpty() ); @@ -2835,7 +2835,7 @@ static void lcl_RemoveObjsFromPage( SwFrame* _pFrame ) // #115759# - remove also drawing objects from page else if ( auto pDrawObj = dynamic_cast<SwAnchoredDrawObject*>( pObj) ) { - if (pObj->GetFrameFormat().GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) + if (pObj->GetFrameFormat()->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) { if (SwPageFrame *pPg = pObj->GetPageFrame()) pPg->RemoveDrawObjFromPage( *pDrawObj ); @@ -2996,7 +2996,7 @@ static void lcl_AddObjsToPage( SwFrame* _pFrame, SwPageFrame* _pPage ) // #115759# - remove also drawing objects from page else if ( dynamic_cast<const SwAnchoredDrawObject*>( pObj) != nullptr ) { - if (pObj->GetFrameFormat().GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) + if (pObj->GetFrameFormat()->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) { pObj->InvalidateObjPos(); _pPage->AppendDrawObjToPage( @@ -3404,8 +3404,10 @@ void Notify_Background( const SdrObject* pObj, else { pFlyFrame = nullptr; - pAnchor = const_cast<SwFrame*>( - GetUserCall(pObj)->GetAnchoredObj( pObj )->GetAnchorFrame() ); + if (SwDrawContact* pC = static_cast<SwDrawContact*>(GetUserCall(pObj))) + pAnchor = const_cast<SwFrame*>(pC->GetAnchoredObj(pObj)->GetAnchorFrame()); + else + return; } if( PrepareHint::FlyFrameLeave != eHint && pAnchor->IsInFly() ) pArea = pAnchor->FindFlyFrame(); @@ -3879,7 +3881,32 @@ SwFrame* GetFrameOfModify(SwRootFrame const*const pLayout, sw::BroadcastingModif } while( bClientIterChanged ); if( pPos && pMinFrame && pMinFrame->IsTextFrame() ) - return static_cast<SwTextFrame*>(pMinFrame)->GetFrameAtPos( *pPos ); + { + SwTextFrame * pAtPos(static_cast<SwTextFrame*>(pMinFrame)->GetFrameAtPos(*pPos)); + if (!pViewPosAndCalcFrame) + { + return pAtPos; + } + TextFrameIndex nPos(pAtPos->MapModelToViewPos(*pPos)); + SwPageFrame const*const pPage(pAtPos->getRootFrame()->GetPageAtPos( + pViewPosAndCalcFrame->first, nullptr, true)); + SwFrame * pOnPage(pAtPos); // if all else fails return first one + ++nPos; // follow field portions are on follow frames that have mnOffset + // already incremented past the field, need to check that index too + while (pAtPos && pAtPos->GetOffset() <= nPos) + { + if (pAtPos->getFrameArea().Contains(pViewPosAndCalcFrame->first)) + { + return pAtPos; + } + if (pAtPos->FindPageFrame() == pPage) + { + pOnPage = pAtPos; + } + pAtPos = pAtPos->GetFollow(); + } + return pOnPage; + } return pMinFrame; } diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 747470129c..a705ef2511 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -1673,7 +1673,7 @@ bool SwLayAction::FormatContent(SwPageFrame *const pPage) assert(pAnchorPage); if (pAnchorPage != pPage && pPage->GetPhyPageNum() < pAnchorPage->GetPhyPageNum() - && pObj->GetFrameFormat().GetAnchor().GetAnchorId() + && pObj->GetFrameFormat()->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) { moved.emplace_back(pObj, pAnchorPage); diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 6b2503d40c..9a44b0df62 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -148,7 +148,7 @@ bool SwObjectFormatterTextFrame::DoFormatObj( SwAnchoredObject& _rAnchoredObj, _rAnchoredObj.RestartLayoutProcess() && !( _rAnchoredObj.PositionLocked() && _rAnchoredObj.GetAnchorFrame()->IsInFly() && - _rAnchoredObj.GetFrameFormat().GetFollowTextFlow().GetValue() ); + _rAnchoredObj.GetFrameFormat()->GetFollowTextFlow().GetValue() ); if ( bRestart ) { bSuccess = false; @@ -168,7 +168,7 @@ bool SwObjectFormatterTextFrame::DoFormatObj( SwAnchoredObject& _rAnchoredObj, if ( bSuccess && _rAnchoredObj.ConsiderObjWrapInfluenceOnObjPos() && ( _bCheckForMovedFwd || - _rAnchoredObj.GetFrameFormat().GetWrapInfluenceOnObjPos(). + _rAnchoredObj.GetFrameFormat()->GetWrapInfluenceOnObjPos(). // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE GetWrapInfluenceOnObjPos( true ) == // #i35017# - constant name has changed @@ -481,10 +481,11 @@ bool SwObjectFormatterTextFrame::DoFormatObjs() void SwObjectFormatterTextFrame::InvalidatePrevObjs( SwAnchoredObject& _rAnchoredObj ) { + const SwFrameFormat* pObjFormat = _rAnchoredObj.GetFrameFormat(); // invalidate all previous objects, whose wrapping influence on the object // positioning is <NONE_CONCURRENT_POSITIONED>. // Note: list of objects at anchor frame is sorted by this property. - if ( _rAnchoredObj.GetFrameFormat().GetWrapInfluenceOnObjPos(). + if (pObjFormat->GetWrapInfluenceOnObjPos(). // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE GetWrapInfluenceOnObjPos( true ) != // #i35017# - constant name has changed @@ -501,7 +502,7 @@ void SwObjectFormatterTextFrame::InvalidatePrevObjs( SwAnchoredObject& _rAnchore { --i; SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; - if ( pAnchoredObj->GetFrameFormat().GetWrapInfluenceOnObjPos(). + if (pObjFormat->GetWrapInfluenceOnObjPos(). // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE GetWrapInfluenceOnObjPos( true ) == // #i35017# - constant name has changed @@ -546,7 +547,7 @@ SwAnchoredObject* SwObjectFormatterTextFrame::GetFirstObjWithMovedFwdAnchor( { SwAnchoredObject* pAnchoredObj = GetCollectedObj(i); if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() && - pAnchoredObj->GetFrameFormat().GetWrapInfluenceOnObjPos(). + pAnchoredObj->GetFrameFormat()->GetWrapInfluenceOnObjPos(). // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE GetWrapInfluenceOnObjPos( true ) == _nWrapInfluenceOnPosition ) { @@ -648,8 +649,8 @@ bool SwObjectFormatterTextFrame::CheckMovedFwdCondition( // which will be on the next page. if ( !bAnchorIsMovedForward && _bAnchoredAtMasterBeforeFormatAnchor && - ((_rAnchoredObj.GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) || - (_rAnchoredObj.GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PARA))) + ((_rAnchoredObj.GetFrameFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) || + (_rAnchoredObj.GetFrameFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PARA))) { SwFrame* pAnchorFrame = _rAnchoredObj.GetAnchorFrameContainingAnchPos(); OSL_ENSURE( pAnchorFrame->IsTextFrame(), @@ -703,7 +704,7 @@ bool SwObjectFormatterTextFrame::CheckMovedFwdCondition( if ((pObjAnchorPage == &rFromPageFrame ? _boInFollow // same-page but will move forward : rFromPageFrame.GetPhyPageNum() < pObjAnchorPage->GetPhyPageNum()) - && pObj->GetFrameFormat().GetAnchor().GetAnchorId() + && pObj->GetFrameFormat()->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) { if (pPageFrameOfAnchor->GetPhyPageNum() < pObjAnchorPage->GetPhyPageNum()) diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index e70cb68469..bf4bcc45ea 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -1708,8 +1708,8 @@ void SwRootFrame::AssertPageFlys( SwPageFrame *pPage ) while ( pPage->GetSortedObjs() && i< pPage->GetSortedObjs()->size() ) { // #i28701# - SwFrameFormat& rFormat = (*pPage->GetSortedObjs())[i]->GetFrameFormat(); - const SwFormatAnchor &rAnch = rFormat.GetAnchor(); + SwFrameFormat* pFormat = (*pPage->GetSortedObjs())[i]->GetFrameFormat(); + const SwFormatAnchor &rAnch = pFormat->GetAnchor(); const sal_uInt16 nPg = rAnch.GetPageNum(); if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE) && nPg != pPage->GetPhyPageNum() ) @@ -1722,12 +1722,12 @@ void SwRootFrame::AssertPageFlys( SwPageFrame *pPage ) // It can move by itself. Just send a modify to its anchor attribute. #if OSL_DEBUG_LEVEL > 1 const size_t nCnt = pPage->GetSortedObjs()->size(); - rFormat.CallSwClientNotify(sw::LegacyModifyHint(nullptr, &rAnch)); + pFormat->CallSwClientNotify(sw::LegacyModifyHint(nullptr, &rAnch)); OSL_ENSURE( !pPage->GetSortedObjs() || nCnt != pPage->GetSortedObjs()->size(), "Object couldn't be reattached!" ); #else - rFormat.CallSwClientNotify(sw::LegacyModifyHint(nullptr, &rAnch)); + pFormat->CallSwClientNotify(sw::LegacyModifyHint(nullptr, &rAnch)); #endif // Do not increment index, in this case continue; @@ -1853,19 +1853,19 @@ void SwRootFrame::ImplCalcBrowseWidth() { // #i28701# SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i]; - const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat(); + const SwFrameFormat* pFormat = pAnchoredObj->GetFrameFormat(); const bool bFly = pAnchoredObj->DynCastFlyFrame() != nullptr; if ((bFly && (FAR_AWAY == pAnchoredObj->GetObjRect().Width())) - || rFormat.GetFrameSize().GetWidthPercent()) + || pFormat->GetFrameSize().GetWidthPercent()) { continue; } tools::Long nWidth = 0; - switch ( rFormat.GetAnchor().GetAnchorId() ) + switch ( pFormat->GetAnchor().GetAnchorId() ) { case RndStdIds::FLY_AS_CHAR: - nWidth = bFly ? rFormat.GetFrameSize().GetWidth() : + nWidth = bFly ? pFormat->GetFrameSize().GetWidth() : pAnchoredObj->GetObjRect().Width(); break; case RndStdIds::FLY_AT_PARA: @@ -1877,8 +1877,8 @@ void SwRootFrame::ImplCalcBrowseWidth() // at position FAR_AWAY. if ( bFly ) { - nWidth = rFormat.GetFrameSize().GetWidth(); - const SwFormatHoriOrient &rHori = rFormat.GetHoriOrient(); + nWidth = pFormat->GetFrameSize().GetWidth(); + const SwFormatHoriOrient &rHori = pFormat->GetHoriOrient(); switch ( rHori.GetHoriOrient() ) { case text::HoriOrientation::NONE: @@ -2013,8 +2013,8 @@ static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset ) for (size_t i = 0; i < pSortedObj->size(); ++i) { SwAnchoredObject *const pAnchoredObj = (*pSortedObj)[i]; - const SwFrameFormat& rObjFormat = pAnchoredObj->GetFrameFormat(); - const SwFormatAnchor& rAnchor = rObjFormat.GetAnchor(); + const SwFrameFormat* pObjFormat = pAnchoredObj->GetFrameFormat(); + const SwFormatAnchor& rAnchor = pObjFormat->GetAnchor(); // all except from the as character anchored objects are moved // when processing the page frame: @@ -2070,7 +2070,7 @@ static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const Point& rOffset ) pAnchoredDrawObj->SetLastObjRect( pAnchoredDrawObj->GetObjRect().SVRect() ); // clear contour cache - if ( pAnchoredDrawObj->GetFrameFormat().GetSurround().IsContour() ) + if ( pAnchoredDrawObj->GetFrameFormat()->GetSurround().IsContour() ) ClrContourCache( pAnchoredDrawObj->GetDrawObj() ); } // #i92511# diff --git a/sw/source/core/layout/sortedobjs.cxx b/sw/source/core/layout/sortedobjs.cxx index ce581bb663..e0c29d5180 100644 --- a/sw/source/core/layout/sortedobjs.cxx +++ b/sw/source/core/layout/sortedobjs.cxx @@ -78,12 +78,16 @@ struct ObjAnchorOrder const SwAnchoredObject* _pNewAnchoredObj ) { // get attributes of listed object - const SwFrameFormat& rFormatListed = _pListedAnchoredObj->GetFrameFormat(); - const SwFormatAnchor* pAnchorListed = &(rFormatListed.GetAnchor()); + const SwFrameFormat* pFormatListed = _pListedAnchoredObj->GetFrameFormat(); + if (!pFormatListed) + return false; + const SwFormatAnchor* pAnchorListed = &(pFormatListed->GetAnchor()); // get attributes of new object - const SwFrameFormat& rFormatNew = _pNewAnchoredObj->GetFrameFormat(); - const SwFormatAnchor* pAnchorNew = &(rFormatNew.GetAnchor()); + const SwFrameFormat* pFormatNew = _pNewAnchoredObj->GetFrameFormat(); + if (!pFormatNew) + return false; + const SwFormatAnchor* pAnchorNew = &(pFormatNew->GetAnchor()); // check for to-page anchored objects if ((pAnchorListed->GetAnchorId() == RndStdIds::FLY_AT_PAGE) && @@ -156,15 +160,15 @@ struct ObjAnchorOrder // objects anchored at the same content and at the same content anchor // node position with the same anchor type // Thus, compare its wrapping style including its layer - const IDocumentDrawModelAccess& rIDDMA = rFormatListed.getIDocumentDrawModelAccess(); + const IDocumentDrawModelAccess& rIDDMA = pFormatListed->getIDocumentDrawModelAccess(); const SdrLayerID nHellId = rIDDMA.GetHellId(); const SdrLayerID nInvisibleHellId = rIDDMA.GetInvisibleHellId(); const bool bWrapThroughOrHellListed = - rFormatListed.GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH || + pFormatListed->GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH || _pListedAnchoredObj->GetDrawObj()->GetLayer() == nHellId || _pListedAnchoredObj->GetDrawObj()->GetLayer() == nInvisibleHellId; const bool bWrapThroughOrHellNew = - rFormatNew.GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH || + pFormatNew->GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH || _pNewAnchoredObj->GetDrawObj()->GetLayer() == nHellId || _pNewAnchoredObj->GetDrawObj()->GetLayer() == nInvisibleHellId; if ( bWrapThroughOrHellListed != bWrapThroughOrHellNew ) @@ -179,9 +183,9 @@ struct ObjAnchorOrder // objects anchored at the same content with a set text wrapping // Thus, compare wrap influences on object position const SwFormatWrapInfluenceOnObjPos* pWrapInfluenceOnObjPosListed = - &(rFormatListed.GetWrapInfluenceOnObjPos()); + &(pFormatListed->GetWrapInfluenceOnObjPos()); const SwFormatWrapInfluenceOnObjPos* pWrapInfluenceOnObjPosNew = - &(rFormatNew.GetWrapInfluenceOnObjPos()); + &(pFormatNew->GetWrapInfluenceOnObjPos()); // #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE if ( pWrapInfluenceOnObjPosListed->GetWrapInfluenceOnObjPos( true ) != pWrapInfluenceOnObjPosNew->GetWrapInfluenceOnObjPos( true ) ) diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index c1acc0c9e9..f757824561 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -286,12 +286,12 @@ static void lcl_InvalidateLowerObjs( SwLayoutFrame& _rLayoutFrame, // that anchored object is correctly positioned. pAnchoredObj->ClearCharRectAndTopOfLine(); pAnchoredObj->SetCurrRelPos( Point( 0, 0 ) ); - if ( pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId() - == RndStdIds::FLY_AS_CHAR ) + const SwFrameFormat* pObjFormat = pAnchoredObj->GetFrameFormat(); + if (pObjFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) { pAnchoredObj->AnchorFrame() ->Prepare( PrepareHint::FlyFrameAttributesChanged, - &(pAnchoredObj->GetFrameFormat()) ); + pObjFormat ); } if ( pFly != nullptr ) { @@ -1451,7 +1451,102 @@ namespace return true; } -} + + auto IsAllHiddenSection(SwSectionFrame const& rSection) -> bool + { + for (SwFrame const* pFrame = rSection.Lower(); pFrame; pFrame = pFrame->GetNext()) + { + if (pFrame->IsColumnFrame()) + { + return false; // adds some padding + } + else if (pFrame->IsSctFrame()) + { + assert(false); // these aren't nested? + if (!IsAllHiddenSection(*static_cast<SwSectionFrame const*>(pFrame))) + { + return false; + } + } + else if (pFrame->IsTabFrame()) + { + return false; // presumably + } + else if (pFrame->IsTextFrame()) + { + if (!static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow()) + { + return false; + } + } + } + return true; + } + + auto IsAllHiddenRow(SwRowFrame const& rRow, SwTabFrame const& rTab) -> bool; + + auto IsAllHiddenCell(SwCellFrame const& rCell, SwRowFrame const& rRow, SwTabFrame const& rTab) -> bool + { + for (SwFrame const* pFrame = rCell.Lower(); pFrame; pFrame = pFrame->GetNext()) + { + if (pFrame->IsRowFrame()) + { + if (!IsAllHiddenRow(*static_cast<SwRowFrame const*>(pFrame), rTab)) + { + return false; + } + } + else if (pFrame->IsSctFrame()) + { + if (!IsAllHiddenSection(*static_cast<SwSectionFrame const*>(pFrame))) + { + return false; + } + } + else if (pFrame->IsTabFrame()) + { + return false; // presumably + } + else if (pFrame->IsTextFrame()) + { + if (!static_cast<SwTextFrame const*>(pFrame)->IsHiddenNow()) + { + return false; + } + } + } + if (rTab.IsCollapsingBorders() && !rCell.Lower()->IsRowFrame()) + { + if (rRow.GetTopMarginForLowers() != 0 + || rRow.GetBottomMarginForLowers() != 0) + { + return false; + } + } + else + { + SwBorderAttrAccess border(SwFrame::GetCache(), &rCell); + if (border.Get()->CalcTop() != 0 || border.Get()->CalcBottom() != 0) + { + return false; + } + } + return true; + } + + auto IsAllHiddenRow(SwRowFrame const& rRow, SwTabFrame const& rTab) -> bool + { + for (SwFrame const* pCell = rRow.Lower(); pCell; pCell = pCell->GetNext()) + { + if (!IsAllHiddenCell(*static_cast<SwCellFrame const*>(pCell), rRow, rTab)) + { + return false; + } + } + return true; + } + +} // namespace void SwTabFrame::Join() { @@ -1471,11 +1566,20 @@ void SwTabFrame::Join() SwFrame* pPrv = GetLastLower(); SwTwips nHeight = 0; //Total height of the inserted rows as return value. + bool isAllHidden(true); while ( pRow ) { pNxt = pRow->GetNext(); nHeight += aRectFnSet.GetHeight(pRow->getFrameArea()); + if (nHeight != 0) + { + isAllHidden = false; + } + if (isAllHidden) + { + isAllHidden = IsAllHiddenRow(*static_cast<SwRowFrame *>(pRow), *this); + } pRow->RemoveFromLayout(); pRow->InvalidateAll_(); pRow->InsertBehind( this, pPrv ); @@ -1489,6 +1593,18 @@ void SwTabFrame::Join() SwFrame::DestroyFrame(pFoll); Grow( nHeight ); + + // In case the row does not have a height, Grow(nHeight) did nothing. + // If this is not invalidated, subsequent follows may never be joined. + // Try to guess if the height of the row will be 0. If the document + // was just loaded, it will be 0 in any case, but probably it's not a good + // idea to join *all* follows for a newly loaded document, it would be + // easier not to split the table in the first place; presumably it is split + // because that improves performance. + if (isAllHidden) + { + InvalidateSize_(); + } } static void SwInvalidatePositions( SwFrame *pFrame, tools::Long nBottom ) @@ -3180,6 +3296,7 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, bool bShiftDown = css::text::WrapTextMode_NONE == nSurround; bool bSplitFly = pFly->IsFlySplitAllowed(); + const SwRect aFlyRectWithoutSpaces = pFly->GetObjRect(); if (!bShiftDown && bAddVerticalFlyOffsets) { if (nSurround == text::WrapTextMode_PARALLEL && isHoriOrientShiftDown) @@ -3194,7 +3311,6 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, // Ignore spacing when determining the left/right edge of the fly, like // Word does. - const SwRect aFlyRectWithoutSpaces = pFly->GetObjRect(); basegfx::B1DRange aFlyRange(aRectFnSet.GetLeft(aFlyRectWithoutSpaces), aRectFnSet.GetRight(aFlyRectWithoutSpaces)); @@ -3257,9 +3373,16 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper, bool bFlyHoriOrientLeft = text::HoriOrientation::LEFT == rHori.GetHoriOrient(); if (bSplitFly && !bFlyHoriOrientLeft) { - // If a split fly is oriented "from left", we already checked if it has enough space on - // the right, so from-left and left means the same here. - bFlyHoriOrientLeft = rHori.GetHoriOrient() == text::HoriOrientation::NONE; + // Only shift to the right if we don't have enough space on the left. + SwTwips nTabWidth = getFramePrintArea().Width(); + SwTwips nWidthDeadline = aFlyRectWithoutSpaces.Left() + - pFly->GetAnchorFrame()->GetUpper()->getFrameArea().Left(); + if (nTabWidth > nWidthDeadline) + { + // If a split fly is oriented "from left", we already checked if it has enough space on + // the right, so from-left and left means the same here. + bFlyHoriOrientLeft = rHori.GetHoriOrient() == text::HoriOrientation::NONE; + } } if ((css::text::WrapTextMode_RIGHT == nSurround || css::text::WrapTextMode_PARALLEL == nSurround) @@ -4447,8 +4570,8 @@ tools::Long CalcHeightWithFlys( const SwFrame *pFrame ) { // OD 30.09.2003 #i18732# - only objects, which follow // the text flow have to be considered. - const SwFrameFormat& rFrameFormat = pAnchoredObj->GetFrameFormat(); - bool bFollowTextFlow = rFrameFormat.GetFollowTextFlow().GetValue(); + const SwFrameFormat* pFrameFormat = pAnchoredObj->GetFrameFormat(); + bool bFollowTextFlow = pFrameFormat->GetFollowTextFlow().GetValue(); bool bIsFarAway = pAnchoredObj->GetObjRect().Top() != FAR_AWAY; const SwPageFrame* pPageFrm = pTmp->FindPageFrame(); bool bIsAnchoredToTmpFrm = false; @@ -4456,14 +4579,14 @@ tools::Long CalcHeightWithFlys( const SwFrame *pFrame ) bIsAnchoredToTmpFrm = pAnchoredObj->GetPageFrame() == pPageFrm || (pPageFrm->GetFormatPage().GetPhyPageNum() == pAnchoredObj->GetPageFrame()->GetFormatPage().GetPhyPageNum() + 1); const bool bConsiderObj = - (rFrameFormat.GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) && + (pFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) && bIsFarAway && bFollowTextFlow && bIsAnchoredToTmpFrm; - bool bWrapThrough = rFrameFormat.GetSurround().GetValue() == text::WrapTextMode_THROUGH; - bool bInBackground = !rFrameFormat.GetOpaque().GetValue(); + bool bWrapThrough = pFrameFormat->GetSurround().GetValue() == text::WrapTextMode_THROUGH; + bool bInBackground = !pFrameFormat->GetOpaque().GetValue(); // Legacy render requires in-background setting, the new mode does not. bool bConsiderFollowTextFlow = bInBackground - || !rFrameFormat.getIDocumentSettingAccess().get( + || !pFrameFormat->getIDocumentSettingAccess().get( DocumentSettingId::USE_FORMER_TEXT_WRAPPING); if (pFrame->IsInTab() && bFollowTextFlow && bWrapThrough && bConsiderFollowTextFlow) { @@ -4475,7 +4598,7 @@ tools::Long CalcHeightWithFlys( const SwFrame *pFrame ) if ( bConsiderObj ) { - const SwFormatFrameSize &rSz = rFrameFormat.GetFrameSize(); + const SwFormatFrameSize &rSz = pFrameFormat->GetFrameSize(); if( !rSz.GetHeightPercent() ) { const SwTwips nDistOfFlyBottomToAnchorTop = @@ -5428,7 +5551,7 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, tools::Long lYStart, bool bI // from its anchor frame. bool bVertPosDepOnAnchor( true ); { - SwFormatVertOrient aVert( pAnchoredObj->GetFrameFormat().GetVertOrient() ); + SwFormatVertOrient aVert( pAnchoredObj->GetFrameFormat()->GetVertOrient() ); switch ( aVert.GetRelationOrient() ) { case text::RelOrientation::PAGE_FRAME: @@ -5528,7 +5651,7 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, tools::Long lYStart, bool bI if ( pTabFrame && !( pTabFrame->IsFollow() && pTabFrame->FindMaster()->IsRebuildLastLine() ) && - (pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId() + (pAnchoredObj->GetFrameFormat()->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)) { SwPageFrame* pPageFrame = pAnchoredObj->GetPageFrame(); @@ -5546,7 +5669,7 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, tools::Long lYStart, bool bI // #i52904# - re-introduce direct move // of drawing objects const bool bDirectMove = - static_cast<const SwDrawFrameFormat&>(pAnchoredObj->GetFrameFormat()).IsPosAttrSet() && + static_cast<const SwDrawFrameFormat*>(pAnchoredObj->GetFrameFormat())->IsPosAttrSet() && bVertPosDepOnAnchor && !pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos(); if ( bDirectMove ) @@ -5804,8 +5927,8 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder const SwFrame* pAnch = pAnchoredObj->GetAnchorFrame(); if ( (bConsiderWrapOnObjPos && IsAnLower( pAnch )) || (!bConsiderWrapOnObjPos && aTmp.Overlaps( aRect )) ) { - const SwFrameFormat& rAnchoredObjFrameFormat = pAnchoredObj->GetFrameFormat(); - const SwFormatSurround &rSur = rAnchoredObjFrameFormat.GetSurround(); + const SwFrameFormat* pAnchoredObjFrameFormat = pAnchoredObj->GetFrameFormat(); + const SwFormatSurround &rSur = pAnchoredObjFrameFormat->GetSurround(); if ( bConsiderWrapOnObjPos || css::text::WrapTextMode_THROUGH != rSur.GetSurround() ) { @@ -5825,7 +5948,7 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder if ( bConsiderWrapOnObjPos || !IsAnLower( pAnch ) || pAnchoredObj->IsTmpConsiderWrapInfluence() || - !rAnchoredObjFrameFormat.GetFollowTextFlow().GetValue() ) + !pAnchoredObjFrameFormat->GetFollowTextFlow().GetValue() ) { bVertDir = false; break; diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 5f8e3aa995..a8445e90dd 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -70,8 +70,9 @@ namespace { const SwVirtFlyDrawObj* pObj = static_cast<const SwVirtFlyDrawObj*>(aIter()); const SwAnchoredObject* pAnchoredObj = GetUserCall( aIter() )->GetAnchoredObj( aIter() ); - const SwFormatSurround& rSurround = pAnchoredObj->GetFrameFormat().GetSurround(); - const SvxOpaqueItem& rOpaque = pAnchoredObj->GetFrameFormat().GetOpaque(); + const SwFrameFormat* pObjFormat = pAnchoredObj->GetFrameFormat(); + const SwFormatSurround& rSurround = pObjFormat->GetSurround(); + const SvxOpaqueItem& rOpaque = pObjFormat->GetOpaque(); bool bInBackground = ( rSurround.GetSurround() == css::text::WrapTextMode_THROUGH ) && !rOpaque.GetValue(); bool bBackgroundMatches = bInBackground == bSearchBackground; @@ -2599,40 +2600,49 @@ void SwRootFrame::CalcFrameRects(SwShellCursor const& rCursor, SwRects & rRects, // splitting of portions vertically (causes spurious extra PDF annotations) if (eMode == RectsMode::NoAnchoredFlys) { - assert(pStartFrame == pEndFrame); // link or field all in 1 frame - assert(pStartFrame->IsTextFrame()); - SwTextGridItem const*const pGrid(GetGridItem(pStartFrame->FindPageFrame())); - SwTextPaintInfo info(static_cast<SwTextFrame*>(pStartFrame), pStartFrame->FindPageFrame()->getFrameArea()); - SwTextPainter painter(static_cast<SwTextFrame*>(pStartFrame), &info); - // because nothing outside the start/end has been added, it doesn't - // matter to match exactly the start/end, subtracting outside is no-op - painter.CharToLine(static_cast<SwTextFrame*>(pStartFrame)->MapModelToViewPos(*pStartPos)); - do - { - info.SetPos(painter.GetTopLeft()); - bool const bAdjustBaseLine( - painter.GetLineInfo().HasSpecialAlign(pStartFrame->IsVertical()) - || nullptr != pGrid || painter.GetCurr()->GetHangingBaseline()); - SwTwips nAscent, nHeight; - painter.CalcAscentAndHeight(nAscent, nHeight); - SwTwips const nOldY(info.Y()); - for (SwLinePortion const* pLP = painter.GetCurr()->GetFirstPortion(); - pLP; pLP = pLP->GetNextPortion()) + for (SwContentFrame * pFrame = pStartFrame; ; pFrame = pFrame->GetFollow()) + { + assert(pFrame->IsTextFrame()); + SwTextGridItem const*const pGrid(GetGridItem(pFrame->FindPageFrame())); + SwTextPaintInfo info(static_cast<SwTextFrame*>(pFrame), pFrame->FindPageFrame()->getFrameArea()); + SwTextPainter painter(static_cast<SwTextFrame*>(pFrame), &info); + // because nothing outside the start/end has been added, it doesn't + // matter to match exactly the start/end, subtracting outside is no-op + if (pFrame == pStartFrame) { - if (pLP->IsFlyPortion()) + painter.CharToLine(static_cast<SwTextFrame*>(pFrame)->MapModelToViewPos(*pStartPos)); + } + do + { + info.SetPos(painter.GetTopLeft()); + bool const bAdjustBaseLine( + painter.GetLineInfo().HasSpecialAlign(pFrame->IsVertical()) + || nullptr != pGrid || painter.GetCurr()->GetHangingBaseline()); + SwTwips nAscent, nHeight; + painter.CalcAscentAndHeight(nAscent, nHeight); + SwTwips const nOldY(info.Y()); + for (SwLinePortion const* pLP = painter.GetCurr()->GetFirstPortion(); + pLP; pLP = pLP->GetNextPortion()) { - info.Y(info.Y() + (bAdjustBaseLine - ? painter.AdjustBaseLine(*painter.GetCurr(), pLP) - : nAscent)); - SwRect flyPortion; - info.CalcRect(*pLP, &flyPortion); - Sub(aRegion, flyPortion); - info.Y(nOldY); + if (pLP->IsFlyPortion()) + { + info.Y(info.Y() + (bAdjustBaseLine + ? painter.AdjustBaseLine(*painter.GetCurr(), pLP) + : nAscent)); + SwRect flyPortion; + info.CalcRect(*pLP, &flyPortion); + Sub(aRegion, flyPortion); + info.Y(nOldY); + } + pLP->Move(info); } - pLP->Move(info); + } + while (painter.Next()); + if (pFrame == pEndFrame) + { + break; } } - while (painter.Next()); } else while (pPage) { @@ -2646,7 +2656,7 @@ void SwRootFrame::CalcFrameRects(SwShellCursor const& rCursor, SwRects & rRects, continue; const SwVirtFlyDrawObj* pObj = pFly->GetVirtDrawObj(); const SwFormatSurround &rSur = pFly->GetFormat()->GetSurround(); - SwFormatAnchor const& rAnchor(pAnchoredObj->GetFrameFormat().GetAnchor()); + SwFormatAnchor const& rAnchor(pAnchoredObj->GetFrameFormat()->GetAnchor()); const SwPosition* anchoredAt = rAnchor.GetContentAnchor(); bool inSelection = ( anchoredAt != nullptr diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 1cd01d53c6..aa108e16b6 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -2347,8 +2347,8 @@ SwTwips SwContentFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo ) if( aBound.Overlaps( aRect ) ) { - const SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat(); - if( css::text::WrapTextMode_THROUGH != rFormat.GetSurround().GetSurround() ) + const SwFrameFormat* pFormat = pAnchoredObj->GetFrameFormat(); + if( css::text::WrapTextMode_THROUGH != pFormat->GetSurround().GetSurround() ) { const SwFrame* pAnchor = pAnchoredObj->GetAnchorFrame(); if ( pAnchor && pAnchor->FindFooterOrHeader() == GetUpper() ) @@ -4327,7 +4327,7 @@ void SwRootFrame::InvalidateAllObjPos() const SwSortedObjs& rObjs = *(pPageFrame->GetSortedObjs()); for (SwAnchoredObject* pAnchoredObj : rObjs) { - const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat().GetAnchor(); + const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat()->GetAnchor(); if ((rAnch.GetAnchorId() != RndStdIds::FLY_AT_PARA) && (rAnch.GetAnchorId() != RndStdIds::FLY_AT_CHAR)) { |