[Libreoffice-commits] core.git: chart2/source include/svl svl/source svx/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 7 18:20:12 UTC 2021


 chart2/source/view/main/DrawModelWrapper.cxx |   11 +----------
 include/svl/itempool.hxx                     |    2 ++
 svl/source/items/itempool.cxx                |    9 +++++++++
 svx/source/xoutdev/xpool.cxx                 |    9 +--------
 4 files changed, 13 insertions(+), 18 deletions(-)

New commits:
commit 13ce37a85ac73a88567c2066fac694e4fc02a6f8
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Fri May 7 19:00:38 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 7 20:19:32 2021 +0200

    add utility method to get last pool in chain
    
    Change-Id: If21defdf1b59219e3b81d803423713972412da7a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115244
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx
index 14bd6b55cfcb..916087e6c69a 100644
--- a/chart2/source/view/main/DrawModelWrapper.cxx
+++ b/chart2/source/view/main/DrawModelWrapper.cxx
@@ -62,17 +62,8 @@ DrawModelWrapper::DrawModelWrapper()
     pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, true) );
     pMasterPool->SetPoolDefaultItem(makeSvx3DPercentDiagonalItem (5));
 
-    SfxItemPool* pPool = pMasterPool;
     // append chart pool to end of pool chain
-    for (;;)
-    {
-        SfxItemPool* pSecondary = pPool->GetSecondaryPool();
-        if (!pSecondary)
-            break;
-
-        pPool = pSecondary;
-    }
-    pPool->SetSecondaryPool(m_pChartItemPool);
+    pMasterPool->GetLastPoolInChain()->SetSecondaryPool(m_pChartItemPool);
     pMasterPool->FreezeIdRanges();
     SetTextDefaults();
 
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index 12e525722d6a..baab6da1a3d7 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -184,6 +184,8 @@ public:
     bool                            IsInRange( sal_uInt16 nWhich ) const;
     void                            SetSecondaryPool( SfxItemPool *pPool );
     SfxItemPool*                    GetSecondaryPool() const;
+    /* get the last pool by following the GetSecondaryPool chain */
+    SfxItemPool*                    GetLastPoolInChain();
     SfxItemPool*                    GetMasterPool() const;
     void                            FreezeIdRanges();
 
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 1d84ab00a115..24fda80d1bfe 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -773,6 +773,15 @@ SfxItemPool* SfxItemPool::GetSecondaryPool() const
     return pImpl->mpSecondary;
 }
 
+/* get the last pool by following the GetSecondaryPool chain */
+SfxItemPool* SfxItemPool::GetLastPoolInChain()
+{
+    SfxItemPool* pLast = this;
+    while(pLast->GetSecondaryPool())
+        pLast = pLast->GetSecondaryPool();
+    return pLast;
+}
+
 SfxItemPool* SfxItemPool::GetMasterPool() const
 {
     return pImpl->mpMaster;
diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx
index 997c6b576f36..be56e4fd7a14 100644
--- a/svx/source/xoutdev/xpool.cxx
+++ b/svx/source/xoutdev/xpool.cxx
@@ -88,14 +88,7 @@ XOutdevItemPool::XOutdevItemPool(SfxItemPool* _pMaster)
     }
     else
     {
-        SfxItemPool* pParent = _pMaster;
-
-        while(pParent->GetSecondaryPool())
-        {
-            pParent = pParent->GetSecondaryPool();
-        }
-
-        pParent->SetSecondaryPool(this);
+        _pMaster->GetLastPoolInChain()->SetSecondaryPool(this);
     }
 
     // prepare PoolDefaults


More information about the Libreoffice-commits mailing list