sw/inc/calbck.hxx | 7 ++++--- sw/inc/hintids.hxx | 2 -- sw/inc/hints.hxx | 4 ++-- sw/inc/node.hxx | 2 +- sw/inc/pagedesc.hxx | 2 +- sw/inc/paratr.hxx | 2 +- sw/inc/section.hxx | 2 +- sw/inc/swtable.hxx | 2 +- sw/source/core/attr/calbck.cxx | 4 ++-- sw/source/core/attr/hints.cxx | 5 ----- sw/source/core/docnode/node.cxx | 13 ++++--------- sw/source/core/docnode/section.cxx | 16 ++++++---------- sw/source/core/layout/pagedesc.cxx | 2 +- sw/source/core/para/paratr.cxx | 2 +- sw/source/core/table/swtable.cxx | 18 ++++++------------ 15 files changed, 31 insertions(+), 52 deletions(-)
New commits: commit 0272d39589ad36a38f85928d6a21eb13d28d2904 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Sep 3 19:41:21 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 4 09:49:08 2024 +0200 convert SwFindNearestNode to regular class and simplify the GetInfo(), it is only used for this single purpose. Change-Id: I462cc10ff9341ace66581bd6af0cacc632866281 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172842 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 37e8b9ed62da..58a336bbc92b 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -38,6 +38,7 @@ class SwCellFrame; class SwTabFrame; class SwRowFrame; class SwTable; +class SwFindNearestNode; /* SwModify and SwClient cooperate in propagating attribute changes. @@ -169,7 +170,7 @@ public: // get information about attribute - virtual bool GetInfo( SfxPoolItem& ) const { return true; } + virtual bool GetInfo( SwFindNearestNode& ) const { return true; } }; @@ -204,7 +205,7 @@ public: bool HasOnlyOneListener() const { return m_pWriterListeners && m_pWriterListeners->IsLast(); } // get information about attribute - virtual bool GetInfo( SfxPoolItem& ) const override; + virtual bool GetInfo( SwFindNearestNode& ) const override; void LockModify() { m_bModifyLocked = true; } void UnlockModify() { m_bModifyLocked = false; } @@ -254,7 +255,7 @@ namespace sw } /** get Client information */ - virtual bool GetInfo( SfxPoolItem& rInfo) const override; + virtual bool GetInfo( SwFindNearestNode& rInfo) const override; private: virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) override; }; diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 7f661ab5209b..75d0f0e51a0a 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -142,7 +142,6 @@ class SwTransparencyGrf; class SwFormatRuby; class SwTableFormulaUpdate; class VirtPageNumHint; -class SwFindNearestNode; class SwFltAnchor; class SwFltTOX; class SwFltRedline; @@ -434,7 +433,6 @@ constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170); constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT(178); constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REMOVE_UNO_OBJECT(181); // empty -constexpr TypedWhichId<SwFindNearestNode> RES_FINDNEARESTNODE(184); 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/hints.hxx b/sw/inc/hints.hxx index 19fe86e95c5c..11589fb827ba 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -401,11 +401,11 @@ public: }; -class SwFindNearestNode final : public SwMsgPoolItem +class SwFindNearestNode final { const SwNode *m_pNode, *m_pFound; public: - SwFindNearestNode( const SwNode& rNd ); + SwFindNearestNode( const SwNode& rNd ) : m_pNode(&rNd), m_pFound(nullptr) {} void CheckNode( const SwNode& rNd ); const SwNode* GetFoundNode() const { return m_pFound; } diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index d8eaeaa9058a..dd16cff8c7a8 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -466,7 +466,7 @@ public: virtual SwContentNode* MakeCopy(SwDoc&, SwNode& rWhere, bool bNewFrames) const = 0; /// Get information from Client. - virtual bool GetInfo( SfxPoolItem& ) const override; + virtual bool GetInfo( SwFindNearestNode& ) const override; /// SS for PoolItems: hard attributation. diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 7ae59362cb42..a7769da69218 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -282,7 +282,7 @@ public: void SetPoolHlpFileId(sal_uInt8 const nId) { m_Master.SetPoolHlpFileId(nId); } /// Query information from Client. - virtual bool GetInfo( SfxPoolItem& ) const override; + virtual bool GetInfo( SwFindNearestNode& ) const override; const SwFrameFormat* GetPageFormatOfNode( const SwNode& rNd, bool bCheckForThisPgDc = true ) const; diff --git a/sw/inc/paratr.hxx b/sw/inc/paratr.hxx index ca67197e02be..19e44ba5929d 100644 --- a/sw/inc/paratr.hxx +++ b/sw/inc/paratr.hxx @@ -125,7 +125,7 @@ public: SwCharFormat *GetCharFormat() { return static_cast<SwCharFormat*>(GetRegisteredIn()); } void SetCharFormat( SwCharFormat *pNew ); /// Get information from Client. - virtual bool GetInfo( SfxPoolItem& ) const override; + virtual bool GetInfo( SwFindNearestNode& ) const override; /// Get and set Modify pointer. void ChgDefinedIn( const sw::FormatDropDefiner* pDefiner ) diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index b5c6442eb5fe..0c45e470d247 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -297,7 +297,7 @@ public: virtual void MakeFrames() override; // Get information from Format. - virtual bool GetInfo( SfxPoolItem& ) const override; + virtual bool GetInfo( SwFindNearestNode& ) const override; virtual bool IsVisible() const override; diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 86876f86aff7..4f4c5672ae4d 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -313,7 +313,7 @@ public: SwSelBoxes& rBoxes, bool bToTop = true ); // Get information from client. - virtual bool GetInfo( SfxPoolItem& ) const override; + virtual bool GetInfo( SwFindNearestNode& ) const override; // Search in format for registered table. SW_DLLPUBLIC static SwTable * FindTable( SwFrameFormat const*const pFormat ); diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index b14b479cc988..6bd48c17d794 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -32,7 +32,7 @@ namespace sw { - bool ListenerEntry::GetInfo(SfxPoolItem& rInfo) const + bool ListenerEntry::GetInfo(SwFindNearestNode& rInfo) const { return m_pToTell == nullptr || m_pToTell->GetInfo( rInfo ); } void ListenerEntry::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { @@ -158,7 +158,7 @@ SwModify::~SwModify() assert(!hasListenersOnDeath); } -bool SwModify::GetInfo( SfxPoolItem& rInfo ) const +bool SwModify::GetInfo( SwFindNearestNode& rInfo ) const { if(!m_pWriterListeners) return true; diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx index c6f4860bd547..129fe2d6dd7c 100644 --- a/sw/source/core/attr/hints.cxx +++ b/sw/source/core/attr/hints.cxx @@ -153,11 +153,6 @@ const SfxPoolItem* GetDfltAttr(sal_uInt16 nWhich) #endif } -SwFindNearestNode::SwFindNearestNode( const SwNode& rNd ) - : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr ) -{ -} - void SwFindNearestNode::CheckNode( const SwNode& rNd ) { if( &m_pNode->GetNodes() == &rNd.GetNodes() ) diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 7e114cb3da56..d32e717ea90a 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1559,16 +1559,11 @@ SwContentNode *SwContentNode::JoinNext() /// Get info from Modify -bool SwContentNode::GetInfo( SfxPoolItem& rInfo ) const +bool SwContentNode::GetInfo( SwFindNearestNode& rInfo ) const { - switch( rInfo.Which() ) - { - case RES_FINDNEARESTNODE: - if( GetAttr( RES_PAGEDESC ).GetPageDesc() ) - static_cast<SwFindNearestNode&>(rInfo).CheckNode( *this ); - return true; - } - return sw::BroadcastingModify::GetInfo( rInfo ); + if( GetAttr( RES_PAGEDESC ).GetPageDesc() ) + rInfo.CheckNode( *this ); + return true; } /// @param rAttr the attribute to set diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index c2f166ec9e9f..677fa0f75784 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -817,19 +817,15 @@ bool SwSectionFormat::IsVisible() const } // Get info from the Format -bool SwSectionFormat::GetInfo(SfxPoolItem& rInfo) const +bool SwSectionFormat::GetInfo(SwFindNearestNode& rInfo) const { - if(rInfo.Which() == RES_FINDNEARESTNODE) + if(GetFormatAttr( RES_PAGEDESC ).GetPageDesc()) { - if(GetFormatAttr( RES_PAGEDESC ).GetPageDesc()) - { - const SwSectionNode* pNd = GetSectionNode(); - if(pNd) - static_cast<SwFindNearestNode&>(rInfo).CheckNode(*pNd); - } - return true; + const SwSectionNode* pNd = GetSectionNode(); + if(pNd) + rInfo.CheckNode(*pNd); } - return sw::BroadcastingModify::GetInfo(rInfo); + return true; } static bool lcl_SectionCmpPos( const SwSection *pFirst, const SwSection *pSecond) diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 511a0539aa88..fa408703e8bd 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -204,7 +204,7 @@ void SwPageDesc::ResetAllAttr() } // gets information from Modify -bool SwPageDesc::GetInfo( SfxPoolItem & rInfo ) const +bool SwPageDesc::GetInfo( SwFindNearestNode & rInfo ) const { if (!m_Master.GetInfo(rInfo)) return false; // found diff --git a/sw/source/core/para/paratr.cxx b/sw/source/core/para/paratr.cxx index 5f67f56f2ef5..84c0afcb00fa 100644 --- a/sw/source/core/para/paratr.cxx +++ b/sw/source/core/para/paratr.cxx @@ -74,7 +74,7 @@ void SwFormatDrop::SetCharFormat( SwCharFormat *pNew ) pNew->Add(*this); } -bool SwFormatDrop::GetInfo( SfxPoolItem& ) const +bool SwFormatDrop::GetInfo( SwFindNearestNode& ) const { return true; // Continue } diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index f9358655edfc..36bae796cf05 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2305,19 +2305,13 @@ bool SwTableBox::IsEmpty( bool bWithRemainingNestedTable ) const } // retrieve information from the client -bool SwTable::GetInfo( SfxPoolItem& rInfo ) const +bool SwTable::GetInfo( SwFindNearestNode& rInfo ) const { - switch( rInfo.Which() ) - { - case RES_FINDNEARESTNODE: - if( GetFrameFormat() && - GetFrameFormat()->GetFormatAttr( RES_PAGEDESC ).GetPageDesc() && - !m_TabSortContentBoxes.empty() && - m_TabSortContentBoxes[0]->GetSttNd()->GetNodes().IsDocNodes() ) - static_cast<SwFindNearestNode&>(rInfo).CheckNode( * - m_TabSortContentBoxes[0]->GetSttNd()->FindTableNode() ); - break; - } + if( GetFrameFormat() && + GetFrameFormat()->GetFormatAttr( RES_PAGEDESC ).GetPageDesc() && + !m_TabSortContentBoxes.empty() && + m_TabSortContentBoxes[0]->GetSttNd()->GetNodes().IsDocNodes() ) + rInfo.CheckNode( *m_TabSortContentBoxes[0]->GetSttNd()->FindTableNode() ); return true; }