sw/inc/frmfmt.hxx | 3 -- sw/inc/hintids.hxx | 1 sw/inc/section.hxx | 2 + sw/source/core/docnode/node.cxx | 18 ++++----------- sw/source/core/docnode/section.cxx | 42 ++++++++++++++----------------------- sw/source/core/inc/doctxm.hxx | 3 -- sw/source/core/layout/atrfrm.cxx | 24 ++++----------------- sw/source/core/table/swtable.cxx | 4 --- sw/source/uibase/utlui/content.cxx | 10 ++------ sw/source/uibase/wrtsh/wrtsh1.cxx | 9 +------ 10 files changed, 36 insertions(+), 80 deletions(-)
New commits: commit b614797a34d25b35c06e20153495795ecfe4e4fe Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Wed Apr 5 08:28:14 2023 +0200 Commit: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Tue Apr 11 08:13:17 2023 +0200 introduce SwFrameFormat::IsVisible() - as a replacement for RES_CONTENT_VISIBLE - broadly: if a FrameFormat has at least one Frame, it is visible - however, sections are special and need to recurse into their childs - SwFlyFrameFormat::GetInfo then does not need to override anymore Change-Id: I01c469e7330a7daaccd2be0541af1d83c7d1a424 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150038 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index eb97de392d15..ec67847247f8 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -183,6 +183,7 @@ public: virtual void SetFormatName( const OUString& rNewName, bool bBroadcast=false ) override; void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat); + virtual bool IsVisible() const; }; // The FlyFrame-Format @@ -219,8 +220,6 @@ public: virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override; - virtual bool GetInfo( SfxPoolItem& rInfo ) const override; - OUString GetObjTitle() const; void SetObjTitle( const OUString& rTitle, bool bBroadcast = false ); diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 0673e724552c..0428d5e1258a 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -438,7 +438,6 @@ constexpr TypedWhichId<SwVirtPageNumInfo> RES_VIRTPAGENUM_INFO(180); constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REMOVE_UNO_OBJECT(181); // empty constexpr TypedWhichId<SwFindNearestNode> RES_FINDNEARESTNODE(184); -constexpr TypedWhichId<SwPtrMsgPoolItem> RES_CONTENT_VISIBLE(185); constexpr sal_uInt16 RES_FORMAT_MSG_END(190); // An ID for the RTF-reader. The stylesheets are treated like attributes, diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 9e29e952cdec..f75c68b13f80 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -299,6 +299,8 @@ public: // Get information from Format. virtual bool GetInfo( SfxPoolItem& ) const override; + virtual bool IsVisible() const override; + SwSection* GetSection() const; inline SwSectionFormat* GetParent() const; inline SwSection* GetParentSection() const; diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 6002830a2525..91ac1697ea30 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1564,31 +1564,23 @@ SwContentNode *SwContentNode::JoinNext() return this; } + /// Get info from Modify bool SwContentNode::GetInfo( SfxPoolItem& rInfo ) const { switch( rInfo.Which() ) { - case RES_AUTOFMT_DOCNODE: - if( &GetNodes() == static_cast<SwAutoFormatGetDocNode&>(rInfo).pNodes ) - { - return false; - } - break; - case RES_FINDNEARESTNODE: if( GetAttr( RES_PAGEDESC ).GetPageDesc() ) static_cast<SwFindNearestNode&>(rInfo).CheckNode( *this ); return true; - - case RES_CONTENT_VISIBLE: + case RES_AUTOFMT_DOCNODE: + if( &GetNodes() == static_cast<SwAutoFormatGetDocNode&>(rInfo).pNodes ) { - static_cast<SwPtrMsgPoolItem&>(rInfo).pObject = - SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti>(*this).First(); + return false; } - return false; + break; } - return sw::BroadcastingModify::GetInfo( rInfo ); } diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 46ac8308abd5..bce8f371f9ee 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -810,39 +810,31 @@ void SwSectionFormat::SetXTextSection(rtl::Reference<SwXTextSection> const& xTex m_wXTextSection = xTextSection.get(); } +bool SwSectionFormat::IsVisible() const +{ + if(SwFrameFormat::IsVisible()) + return true; + SwIterator<SwSectionFormat,SwSectionFormat> aFormatIter(*this); + for(SwSectionFormat* pChild = aFormatIter.First(); pChild; pChild = aFormatIter.Next()) + if(pChild->IsVisible()) + return true; + return false; +} + // Get info from the Format -bool SwSectionFormat::GetInfo( SfxPoolItem& rInfo ) const +bool SwSectionFormat::GetInfo(SfxPoolItem& rInfo) const { - switch( rInfo.Which() ) + if(rInfo.Which() == RES_FINDNEARESTNODE) { - case RES_FINDNEARESTNODE: - if( GetFormatAttr( RES_PAGEDESC ).GetPageDesc() ) + if(GetFormatAttr( RES_PAGEDESC ).GetPageDesc()) { const SwSectionNode* pNd = GetSectionNode(); - if( pNd ) - static_cast<SwFindNearestNode&>(rInfo).CheckNode( *pNd ); + if(pNd) + static_cast<SwFindNearestNode&>(rInfo).CheckNode(*pNd); } return true; - - case RES_CONTENT_VISIBLE: - { - SwFrame* pFrame = SwIterator<SwFrame,SwFormat>(*this).First(); - // if the current section has no own frame search for the children - if(!pFrame) - { - SwIterator<SwSectionFormat,SwSectionFormat> aFormatIter(*this); - SwSectionFormat* pChild = aFormatIter.First(); - while(pChild && !pFrame) - { - pFrame = SwIterator<SwFrame,SwFormat>(*pChild).First(); - pChild = aFormatIter.Next(); - } - } - static_cast<SwPtrMsgPoolItem&>(rInfo).pObject = pFrame; - } - return false; } - return sw::BroadcastingModify::GetInfo( rInfo ); + return sw::BroadcastingModify::GetInfo(rInfo); } static bool lcl_SectionCmpPos( const SwSection *pFirst, const SwSection *pSecond) diff --git a/sw/source/core/inc/doctxm.hxx b/sw/source/core/inc/doctxm.hxx index b2cfe4a55fae..d33809d5d885 100644 --- a/sw/source/core/inc/doctxm.hxx +++ b/sw/source/core/inc/doctxm.hxx @@ -89,8 +89,7 @@ public: bool SetPosAtStartEnd( SwPosition& rPos ) const; bool IsVisible() const override { - SwPtrMsgPoolItem aInfo(RES_CONTENT_VISIBLE, nullptr); - return GetFormat() && !GetFormat()->GetInfo(aInfo) && aInfo.pObject; + return GetFormat() && GetFormat()->IsVisible(); } }; diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index b976f6ee1377..649f31c9807e 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3189,25 +3189,6 @@ SwAnchoredObject* SwFlyFrameFormat::GetAnchoredObj() const } } -bool SwFlyFrameFormat::GetInfo( SfxPoolItem& rInfo ) const -{ - bool bRet = true; - switch( rInfo.Which() ) - { - case RES_CONTENT_VISIBLE: - { - static_cast<SwPtrMsgPoolItem&>(rInfo).pObject = SwIterator<SwFrame,SwFormat>( *this ).First(); - } - bRet = false; - break; - - default: - bRet = SwFrameFormat::GetInfo( rInfo ); - break; - } - return bRet; -} - // #i73249# void SwFlyFrameFormat::SetObjTitle( const OUString& rTitle, bool bBroadcast ) { @@ -3660,6 +3641,11 @@ void SwFrameFormat::MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOl } +bool SwFrameFormat::IsVisible() const +{ + return SwIterator<SwFrame, SwFrameFormat>(*this).First(); +}; + namespace sw { bool IsFlyFrameFormatInHeader(const SwFrameFormat& rFormat) diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 83bd94623526..889f4820e0fd 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2250,10 +2250,6 @@ bool SwTable::GetInfo( SfxPoolItem& rInfo ) const static_cast<SwFindNearestNode&>(rInfo).CheckNode( * m_TabSortContentBoxes[0]->GetSttNd()->FindTableNode() ); break; - - case RES_CONTENT_VISIBLE: - static_cast<SwPtrMsgPoolItem&>(rInfo).pObject = SwIterator<SwFrame,SwFormat>( *GetFrameFormat() ).First(); - return false; } return true; } diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index b010313ea49e..cbb0cba64edc 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -421,7 +421,6 @@ void SwContentType::FillMemberList(bool* pbContentChanged) { std::unique_ptr<SwContentArr> pOldMember; size_t nOldMemberCount = 0; - SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, nullptr ); if(m_pMember && pbContentChanged) { pOldMember = std::move(m_pMember); @@ -507,8 +506,7 @@ void SwContentType::FillMemberList(bool* pbContentChanged) nYPos = getYPos(*pTable->GetTableNode()); } auto pCnt = std::make_unique<SwContent>(this, rTableFormat.GetName(), nYPos); - if( !rTableFormat.GetInfo( aAskItem ) && - !aAskItem.pObject ) // not visible + if(!rTableFormat.IsVisible()) pCnt->SetInvisible(); m_pMember->insert(std::move(pCnt)); } @@ -558,8 +556,7 @@ void SwContentType::FillMemberList(bool* pbContentChanged) { pCnt = new SwContent(this, sFrameName, nYPos); } - if( !pFrameFormat->GetInfo( aAskItem ) && - !aAskItem.pObject ) // not visible + if(!pFrameFormat->IsVisible()) pCnt->SetInvisible(); m_pMember->insert(std::unique_ptr<SwContent>(pCnt)); } @@ -793,8 +790,7 @@ void SwContentType::FillMemberList(bool* pbContentChanged) std::unique_ptr<SwContent> pCnt(new SwRegionContent(this, sSectionName, nLevel, m_bAlphabeticSort ? 0 : getYPos(pNodeIndex->GetNode()))); - if( !pFormat->GetInfo( aAskItem ) && - !aAskItem.pObject ) // not visible + if(!pFormat->IsVisible()) pCnt->SetInvisible(); m_pMember->insert(std::move(pCnt)); } diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 95f625aa49c9..d195ae74d617 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -2358,13 +2358,8 @@ bool SwWrtShell::IsOutlineContentVisible(const size_t nPos) } if (aIdx.GetNode().IsSectionNode()) { - const SwSectionFormat* pFormat = - aIdx.GetNode().GetSectionNode()->GetSection().GetFormat(); - if (!pFormat) - return false; - SwPtrMsgPoolItem aAskItem(RES_CONTENT_VISIBLE, nullptr); - pFormat->GetInfo(aAskItem); - return aAskItem.pObject; + const auto pFormat = aIdx.GetNode().GetSectionNode()->GetSection().GetFormat(); + return pFormat && pFormat->IsVisible(); } }