compilerplugins/clang/unusedmethods.results |    2 -
 include/svl/hint.hxx                        |    1 
 svl/source/items/poolitem.cxx               |    1 
 sw/inc/hintids.hxx                          |    3 --
 sw/inc/hints.hxx                            |   42 +++++++++++++++++-----------
 sw/source/core/attr/hints.cxx               |   14 ++++++---
 sw/source/core/inc/pagefrm.hxx              |    6 ++--
 sw/source/core/inc/tabfrm.hxx               |    1 
 sw/source/core/inc/txtfrm.hxx               |    1 
 sw/source/core/layout/pagechg.cxx           |    6 ++--
 sw/source/core/layout/tabfrm.cxx            |   19 +++++-------
 sw/source/core/layout/trvlfrm.cxx           |   14 ++++-----
 sw/source/core/text/txtfrm.cxx              |   20 ++++++-------
 13 files changed, 68 insertions(+), 62 deletions(-)

New commits:
commit 7f85415a2f07d62bf688cb33680054940d4dd7f1
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Sun Jul 30 09:01:30 2023 +0200
Commit:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
CommitDate: Thu Aug 3 08:01:55 2023 +0200

    move SwVirtPageNumInfo to SfxHint
    
    - also remove now obsolete GetInfo overrides
    
    Change-Id: Iaac75ed2e53daead06242ce4620fd2b879909e02
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155061
    Tested-by: Jenkins
    Reviewed-by: Bjoern Michaelsen <bjoern.michael...@libreoffice.org>

diff --git a/compilerplugins/clang/unusedmethods.results 
b/compilerplugins/clang/unusedmethods.results
index 77d563e9d719..a4b5e3d3dcd5 100644
--- a/compilerplugins/clang/unusedmethods.results
+++ b/compilerplugins/clang/unusedmethods.results
@@ -1934,8 +1934,6 @@ include/svl/typedwhich.hxx:31
      TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename 
enable_if<std::is_base_of_v<SwUINumRuleItem, derived_type>, int>::type)
 include/svl/typedwhich.hxx:31
      TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename 
enable_if<std::is_base_of_v<SwUpdateAttr, derived_type>, int>::type)
-include/svl/typedwhich.hxx:31
-     TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename 
enable_if<std::is_base_of_v<SwVirtPageNumInfo, derived_type>, int>::type)
 include/svl/typedwhich.hxx:31
      TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename 
enable_if<std::is_base_of_v<SwWrtShellItem, derived_type>, int>::type)
 include/svl/typedwhich.hxx:31
diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 5967d834ceeb..ba230f92b817 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -152,6 +152,7 @@ enum class SfxHintId {
     SwDocPosUpdate,
     SwDocPosUpdateAtIndex,
     SwTableHeadingChange,
+    SwVirtPageNumHint,
 
     ThisIsAnSdrHint
 };
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index dfa584f6114a..cb1bec15159c 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -437,7 +437,6 @@
 //     class SwTableFormulaUpdate : public SwMsgPoolItem
 //     class SwAutoFormatGetDocNode: public SwMsgPoolItem
 //     class SwAttrSetChg: public SwMsgPoolItem
-//     class SwVirtPageNumInfo: public SwMsgPoolItem
 //     class SwFindNearestNode : public SwMsgPoolItem
 //     class SwStringMsgPoolItem : public SwMsgPoolItem
 // class SwFormatDrop: public SfxPoolItem, public SwClient
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 1046dab3e1ca..339a73068162 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -141,7 +141,7 @@ class SwTransparencyGrf;
 class SwFormatRuby;
 class SwTableFormulaUpdate;
 class SwAutoFormatGetDocNode;
-class SwVirtPageNumInfo;
+class VirtPageNumHint;
 class SwFindNearestNode;
 class SwFltAnchor;
 class SwFltTOX;
@@ -433,7 +433,6 @@ constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(169);
 constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170);
 constexpr TypedWhichId<SwAutoFormatGetDocNode> RES_AUTOFMT_DOCNODE(176);
 constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT(178);
-constexpr TypedWhichId<SwVirtPageNumInfo> RES_VIRTPAGENUM_INFO(180);
 constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REMOVE_UNO_OBJECT(181);
 // empty
 constexpr TypedWhichId<SwFindNearestNode> RES_FINDNEARESTNODE(184);
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 46a3c586771f..eb3ba5a2cdc2 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -261,6 +261,32 @@ class TableHeadingChange final: public SfxHint
 public:
     TableHeadingChange() : SfxHint(SfxHintId::SwTableHeadingChange) {};
 };
+class VirtPageNumHint final: public SfxHint
+{
+    const SwPageFrame* m_pPage;
+    const SwPageFrame* m_pOrigPage;
+    const SwFrame* m_pFrame;
+    bool m_bFound;
+    /** Multiple attributes can be attached to a single paragraph / table
+     The frame, in the end, has to decide which attribute takes effect and 
which physical page it involves */
+public:
+    VirtPageNumHint(const SwPageFrame* pPg);
+    const SwPageFrame* GetPage() const
+        { return m_pPage; }
+    const SwPageFrame* GetOrigPage() const
+        { return m_pOrigPage; }
+    const SwFrame* GetFrame() const
+        { return m_pFrame; }
+    void SetInfo(const SwPageFrame* pPg, const SwFrame *pF)
+        { m_pFrame = pF; m_pPage = pPg; }
+    void SetFound()
+    {
+        assert(!m_bFound);
+        m_bFound = true;
+    }
+    bool IsFound()
+        { return m_bFound; }
+};
 }
 
 class SwUpdateAttr final : public SwMsgPoolItem
@@ -359,22 +385,6 @@ public:
 #endif
 };
 
-class SwVirtPageNumInfo final : public SwMsgPoolItem
-{
-    const SwPageFrame *m_pPage;
-    const SwPageFrame *m_pOrigPage;
-    const SwFrame     *m_pFrame;
-    /** Multiple attributes can be attached to a single paragraph / table
-     The frame, in the end, has to decide which attribute takes effect and 
which physical page it involves */
-public:
-    SwVirtPageNumInfo( const SwPageFrame *pPg );
-
-    const SwPageFrame *GetPage() const          { return m_pPage;    }
-    const SwPageFrame *GetOrigPage() const      { return m_pOrigPage;}
-    const SwFrame *GetFrame() const             { return m_pFrame; }
-    void  SetInfo( const SwPageFrame *pPg,
-                   const SwFrame *pF )    { m_pFrame = pF; m_pPage = pPg; }
-};
 
 class SwFindNearestNode final : public SwMsgPoolItem
 {
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx
index 20190d81e642..279bf9725edc 100644
--- a/sw/source/core/attr/hints.cxx
+++ b/sw/source/core/attr/hints.cxx
@@ -69,6 +69,15 @@ RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, 
sal_Int32 const nL)
 {
 }
 
+VirtPageNumHint::VirtPageNumHint(const SwPageFrame* pPg):
+    SfxHint(SfxHintId::SwVirtPageNumHint),
+    m_pPage(nullptr),
+    m_pOrigPage(pPg),
+    m_pFrame(nullptr),
+    m_bFound(false)
+{
+}
+
 } // namespace sw
 
 SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW )
@@ -159,11 +168,6 @@ const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
 }
 #endif
 
-SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrame *pPg ) :
-    SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( 
pPg ), m_pFrame( nullptr )
-{
-}
-
 SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
     : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr 
)
 {
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 53bf27a24bbc..237544ec6e05 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -36,7 +36,9 @@ class SwAttrSetChg;
 namespace vcl { class Font; }
 class SwSortedObjs;
 class SwAnchoredObject;
-class SwVirtPageNumInfo;
+namespace sw {
+    class VirtPageNumHint;
+}
 
 enum class SwPageFrameInvFlags : sal_uInt8
 {
@@ -351,7 +353,7 @@ public:
     const SwHeaderFrame* GetHeaderFrame() const;
     const SwFooterFrame* GetFooterFrame() const;
 
-    bool UpdateVirtPageNumInfo(SwVirtPageNumInfo& rHint, const SwFrame* 
pFrame) const;
+    void UpdateVirtPageNumInfo(sw::VirtPageNumHint& rHint, const SwFrame* 
pFrame) const;
 
     void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
 };
diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx
index 7e7a590c7907..0ad953a0adf3 100644
--- a/sw/source/core/inc/tabfrm.hxx
+++ b/sw/source/core/inc/tabfrm.hxx
@@ -143,7 +143,6 @@ public:
     inline       SwTabFrame *GetFollow();
     SwTabFrame* FindMaster( bool bFirstMaster = false ) const;
 
-    virtual bool GetInfo( SfxPoolItem &rHint ) const override;
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
                         SwPrintData const*const pPrintData = nullptr ) const 
override;
     virtual void CheckDirection( bool bVert ) override;
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index ca1b34239055..fe42319e1a41 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -421,7 +421,6 @@ public:
     SwRect GetPaintSwRect();
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
                         SwPrintData const*const pPrintData = nullptr ) const 
override;
-    virtual bool GetInfo( SfxPoolItem & ) const override;
 
     /**
      * Layout oriented cursor travelling:
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 042a34d46759..48c0c5ec7267 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -2598,13 +2598,14 @@ const SwFooterFrame* SwPageFrame::GetFooterFrame() const
     return nullptr;
 }
 
-bool SwPageFrame::UpdateVirtPageNumInfo(SwVirtPageNumInfo& rHint, const 
SwFrame* pFrame) const
+void SwPageFrame::UpdateVirtPageNumInfo(sw::VirtPageNumHint& rHint, const 
SwFrame* pFrame) const
 {
+    assert(!rHint.IsFound());
     if(this == rHint.GetOrigPage() && !pFrame->GetPrev())
     {
         // Should be the one (can temporarily be different, should we be 
concerned about this possibility?)
+        rHint.SetFound();
         rHint.SetInfo(this, pFrame);
-        return false;
     }
     if(GetPhyPageNum() < rHint.GetOrigPage()->GetPhyPageNum() &&
          (!rHint.GetPage() || GetPhyPageNum() > 
rHint.GetPage()->GetPhyPageNum()))
@@ -2612,7 +2613,6 @@ bool 
SwPageFrame::UpdateVirtPageNumInfo(SwVirtPageNumInfo& rHint, const SwFrame*
         // This could be the one.
         rHint.SetInfo(this, pFrame);
     }
-    return true;
 }
 
 void SwPageFrame::dumpAsXml(xmlTextWriterPtr writer) const
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 7ce35fd62512..23765a721361 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3512,6 +3512,14 @@ void SwTabFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         HandleTableHeadlineChange();
         return;
     }
+    else if(rHint.GetId() == SfxHintId::SwVirtPageNumHint)
+    {
+        auto& rVirtPageNumHint = 
const_cast<sw::VirtPageNumHint&>(static_cast<const 
sw::VirtPageNumHint&>(rHint));
+        if(!IsInDocBody() || IsFollow() || rVirtPageNumHint.IsFound())
+            return;
+        if(const SwPageFrame* pPage = FindPageFrame())
+            pPage->UpdateVirtPageNumInfo(rVirtPageNumHint, this);
+    }
     else if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
@@ -3638,17 +3646,6 @@ void SwTabFrame::UpdateAttr_( const SfxPoolItem *pOld, 
const SfxPoolItem *pNew,
     }
 }
 
-bool SwTabFrame::GetInfo(SfxPoolItem& rHint) const
-{
-    if(RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && !IsFollow())
-    {
-        SwVirtPageNumInfo& rInfo = static_cast<SwVirtPageNumInfo&>(rHint);
-        if(const SwPageFrame* pPage = FindPageFrame())
-            return pPage->UpdateVirtPageNumInfo(rInfo, this);
-    }
-    return true;
-}
-
 SwFrame *SwTabFrame::FindLastContentOrTable()
 {
     SwFrame *pRet = m_pLower;
diff --git a/sw/source/core/layout/trvlfrm.cxx 
b/sw/source/core/layout/trvlfrm.cxx
index dfcfad57cef5..0b4938f7fe8d 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1839,15 +1839,15 @@ sal_uInt16 SwFrame::GetVirtPageNum() const
 
         if ( pDesc->GetNumOffset() && pDesc->GetDefinedIn() )
         {
-            const sw::BroadcastingModify *pMod = pDesc->GetDefinedIn();
-            SwVirtPageNumInfo aInfo( pPage );
-            pMod->GetInfo( aInfo );
-            if ( aInfo.GetPage() )
+            auto pMod = 
const_cast<sw::BroadcastingModify*>(pDesc->GetDefinedIn());
+            sw::VirtPageNumHint aHint(pPage);
+            pMod->CallSwClientNotify(aHint);
+            if(aHint.GetPage())
             {
-                if( !pVirtPage || aInfo.GetPage()->GetPhyPageNum() > 
pVirtPage->GetPhyPageNum() )
+                if(!pVirtPage || aHint.GetPage()->GetPhyPageNum() > 
pVirtPage->GetPhyPageNum())
                 {
-                    pVirtPage = aInfo.GetPage();
-                    pFrame = aInfo.GetFrame();
+                    pVirtPage = aHint.GetPage();
+                    pFrame = aHint.GetFrame();
                 }
             }
         }
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 4bc70a7ae233..c1c2c2a40f6f 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2125,6 +2125,15 @@ void SwTextFrame::SwClientNotify(SwModify const& 
rModify, SfxHint const& rHint)
         InvalidateRange(SwCharRange(nIndex, TextFrameIndex(1)));
         return;
     }
+    else if (rHint.GetId() == SfxHintId::SwVirtPageNumHint)
+    {
+        auto& rVirtPageNumHint = 
const_cast<sw::VirtPageNumHint&>(static_cast<const 
sw::VirtPageNumHint&>(rHint));
+        if(!IsInDocBody() || IsFollow() || rVirtPageNumHint.IsFound())
+            return;
+        if(const SwPageFrame* pPage = FindPageFrame())
+            pPage->UpdateVirtPageNumInfo(rVirtPageNumHint, this);
+        return;
+    }
     else if (auto const pHt = dynamic_cast<sw::MoveText const*>(&rHint))
     {
         pMoveText = pHt;
@@ -2746,17 +2755,6 @@ void SwTextFrame::SwClientNotify(SwModify const& 
rModify, SfxHint const& rHint)
         CalcFootnoteFlag();
 }
 
-bool SwTextFrame::GetInfo(SfxPoolItem& rHint) const
-{
-    if(RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && !IsFollow())
-    {
-        SwVirtPageNumInfo& rInfo = static_cast<SwVirtPageNumInfo&>(rHint);
-        if(const SwPageFrame* pPage = FindPageFrame())
-            return pPage->UpdateVirtPageNumInfo(rInfo, this);
-    }
-    return true;
-}
-
 void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
 {
     OSL_ENSURE(GetFollow() && nNeed, "+SwTextFrame::Prepare: lost all 
friends");

Reply via email to