include/svl/itempool.hxx           |    4 +-
 svl/source/items/itempool.cxx      |   13 +++---
 svx/source/unodraw/unomtabl.cxx    |   32 +++++++---------
 svx/source/unodraw/unoshape.cxx    |    4 --
 svx/source/xoutdev/xattr.cxx       |   72 ++++++++++++++++++-------------------
 sw/source/filter/ww8/rtfexport.cxx |    4 --
 6 files changed, 61 insertions(+), 68 deletions(-)

New commits:
commit 451776bc900f032f375adfb0454d088549374f16
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat May 24 12:50:26 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat May 24 12:28:22 2025 +0200

    Make GetItemSurrogatesForItem return a value, instead of using an out 
argument
    
    Change-Id: I9f54cf6a016d3f01ae37de5c6429cb0c585b9a04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185732
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index 0a781aa3e03a..923d1805ad43 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -324,8 +324,8 @@ public:
     ItemSurrogates GetItemSurrogates(sal_uInt16 nWhich) const;
 
     // special version for read-only itemSurrogates for NameOrIndex Items
-    void GetItemSurrogatesForItem(ItemSurrogates& rTarget, const SfxPoolItem& 
rItem) const;
-    void GetItemSurrogatesForItem(ItemSurrogates& rTarget, SfxItemType 
eItemType) const;
+    ItemSurrogates GetItemSurrogatesForItem(const SfxPoolItem& rItem) const;
+    ItemSurrogates GetItemSurrogatesForItem(SfxItemType eItemType) const;
 
     sal_uInt16 GetFirstWhich() const { return mnStart; }
     sal_uInt16 GetLastWhich() const { return mnEnd; }
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 49fa7bf9b5df..06c4c59a4eb7 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -882,23 +882,24 @@ void SfxItemPool::iterateItemSurrogates(
     }
 }
 
-void SfxItemPool::GetItemSurrogatesForItem(ItemSurrogates& rTarget, 
SfxItemType eItemType) const
+ItemSurrogates SfxItemPool::GetItemSurrogatesForItem(SfxItemType eItemType) 
const
 {
-    rTarget.clear();
+    ItemSurrogates aTarget;
     const registeredNameOrIndex& 
rRegistered(GetMasterPool()->maRegisteredNameOrIndex);
     registeredNameOrIndex::const_iterator aHit(rRegistered.find(eItemType));
     if (aHit != rRegistered.end())
     {
-        rTarget.reserve(aHit->second.size());
+        aTarget.reserve(aHit->second.size());
         for (const auto& entry : aHit->second)
-            rTarget.push_back(entry.first);
+            aTarget.push_back(entry.first);
     }
+    return aTarget;
 }
 
-void SfxItemPool::GetItemSurrogatesForItem(ItemSurrogates& rTarget, const 
SfxPoolItem& rItem) const
+ItemSurrogates SfxItemPool::GetItemSurrogatesForItem(const SfxPoolItem& rItem) 
const
 {
     assert(rItem.isNameOrIndex() && "ITEM: only Items derived from NameOrIndex 
supported for this mechanism (!)");
-    GetItemSurrogatesForItem(rTarget, rItem.ItemType());
+    return GetItemSurrogatesForItem(rItem.ItemType());
 }
 
 ItemSurrogates SfxItemPool::GetItemSurrogates(sal_uInt16 nWhich) const
diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx
index 236ba81ac774..681b81bb2883 100644
--- a/svx/source/unodraw/unomtabl.cxx
+++ b/svx/source/unodraw/unomtabl.cxx
@@ -289,9 +289,7 @@ static bool getByNameFromPool( std::u16string_view 
rSearchName, SfxItemPool cons
 {
     if (pPool)
     {
-        ItemSurrogates aSurrogates;
-        pPool->GetItemSurrogatesForItem(aSurrogates, eItemType);
-        for (const SfxPoolItem* p : aSurrogates)
+        for (const SfxPoolItem* p : pPool->GetItemSurrogatesForItem(eItemType))
         {
             const NameOrIndex *pItem = static_cast<const NameOrIndex*>(p);
 
@@ -335,9 +333,7 @@ uno::Any SAL_CALL SvxUnoMarkerTable::getByName( const 
OUString& aApiName )
 
 static void createNamesForPool( SfxItemPool const * pPool, SfxItemType 
eItemType, std::set< OUString >& rNameSet )
 {
-    ItemSurrogates aSurrogates;
-    pPool->GetItemSurrogatesForItem(aSurrogates, eItemType);
-    for (const SfxPoolItem* p : aSurrogates)
+    for (const SfxPoolItem* p : pPool->GetItemSurrogatesForItem(eItemType))
     {
         const NameOrIndex* pItem = static_cast<const NameOrIndex*>(p);
 
@@ -378,9 +374,9 @@ sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const 
OUString& aName )
     aSearchName = SvxUnogetInternalNameForItem(XATTR_LINESTART, aName);
     if (mpModelPool)
     {
-        ItemSurrogates aSurrogates;
-        mpModelPool->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             
mpModelPool->GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             pItem = static_cast<const NameOrIndex*>(p);
             if( pItem && pItem->GetName() == aSearchName )
@@ -391,9 +387,9 @@ sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const 
OUString& aName )
     aSearchName = SvxUnogetInternalNameForItem(XATTR_LINEEND, aName);
     if (mpModelPool)
     {
-        ItemSurrogates aSurrogates;
-        mpModelPool->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINEEND
+        for (const SfxPoolItem* p :
+             
mpModelPool->GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
         {
             pItem = static_cast<const NameOrIndex*>(p);
             if( pItem && pItem->GetName() == aSearchName )
@@ -418,9 +414,9 @@ sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements(  )
 
     if (mpModelPool)
     {
-        ItemSurrogates aSurrogates;
-        mpModelPool->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             
mpModelPool->GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             pItem = static_cast<const NameOrIndex*>(p);
             if( pItem && !pItem->GetName().isEmpty() )
@@ -430,9 +426,9 @@ sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements(  )
 
     if (mpModelPool)
     {
-        ItemSurrogates aSurrogates;
-        mpModelPool->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINEEND
+        for (const SfxPoolItem* p :
+             
mpModelPool->GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
         {
             pItem = static_cast<const NameOrIndex*>(p);
             if( pItem && !pItem->GetName().isEmpty() )
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 546d5f14fbfa..6ef52ffff75d 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -1435,9 +1435,7 @@ bool SvxShape::SetFillAttribute( sal_uInt16 nWID, const 
OUString& rName, SfxItem
         case XATTR_LINEDASH: eItemType = SfxItemType::XLineDashItemType; break;
         default: assert(false); abort();
     }
-    ItemSurrogates aSurrogates;
-    rSet.GetPool()->GetItemSurrogatesForItem(aSurrogates, eItemType);
-    for (const SfxPoolItem* p : aSurrogates)
+    for (const SfxPoolItem* p : 
rSet.GetPool()->GetItemSurrogatesForItem(eItemType))
     {
         const NameOrIndex* pItem = static_cast<const NameOrIndex*>(p);
         if( pItem->GetName() == aName )
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 4d6aeb90f3c5..a48a93bc6149 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -145,10 +145,8 @@ OUString NameOrIndex::CheckNamedItem(const sal_uInt16 
nWhich, const SfxItemPool*
 
     if (!aUniqueName.isEmpty() && pPool1)
     {
-        ItemSurrogates aSurrogates;
         // use special version to get buffered NameOrIndex Items
-        pPool1->GetItemSurrogatesForItem(aSurrogates, *this);
-        for (const SfxPoolItem* pItem : aSurrogates)
+        for (const SfxPoolItem* pItem : 
pPool1->GetItemSurrogatesForItem(*this))
         {
             const NameOrIndex *pNameOrIndex = static_cast<const 
NameOrIndex*>(pItem);
 
@@ -234,10 +232,8 @@ OUString NameOrIndex::CheckNamedItem(const sal_uInt16 
nWhich, const SfxItemPool*
 
         if (aUniqueName.isEmpty() && pPool1)
         {
-            ItemSurrogates aSurrogates;
             // use special version to get buffered NameOrIndex Items
-            pPool1->GetItemSurrogatesForItem(aSurrogates, *this);
-            for (const SfxPoolItem* pItem : aSurrogates)
+            for (const SfxPoolItem* pItem : 
pPool1->GetItemSurrogatesForItem(*this))
             {
                 const NameOrIndex *pNameOrIndex = static_cast<const 
NameOrIndex*>(pItem);
 
@@ -1254,9 +1250,9 @@ std::unique_ptr<XLineStartItem> 
XLineStartItem::checkForUniqueItem( SdrModel& rM
     const SfxItemPool& rPool1 = rModel.GetItemPool();
     if (!aUniqueName.isEmpty())
     {
-        ItemSurrogates aSurrogates;
-        rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             rPool1.GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             auto pItem = static_cast<const XLineStartItem*>(p);
 
@@ -1276,8 +1272,9 @@ std::unique_ptr<XLineStartItem> 
XLineStartItem::checkForUniqueItem( SdrModel& rM
 
         if( !bForceNew )
         {
-            rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-            for (const SfxPoolItem* p : aSurrogates)
+            // XATTR_LINEEND
+            for (const SfxPoolItem* p :
+                 
rPool1.GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
             {
                 auto pItem = static_cast<const XLineEndItem*>(p);
 
@@ -1300,9 +1297,9 @@ std::unique_ptr<XLineStartItem> 
XLineStartItem::checkForUniqueItem( SdrModel& rM
     const SfxItemPool* pPool2 = rModel.GetStyleSheetPool() ? 
&rModel.GetStyleSheetPool()->GetPool() : nullptr;
     if( !aUniqueName.isEmpty() && pPool2)
     {
-        ItemSurrogates aSurrogates;
-        pPool2->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             pPool2->GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             auto pItem = static_cast<const XLineStartItem*>(p);
 
@@ -1322,8 +1319,9 @@ std::unique_ptr<XLineStartItem> 
XLineStartItem::checkForUniqueItem( SdrModel& rM
 
         if( !bForceNew )
         {
-            pPool2->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-            for (const SfxPoolItem* p : aSurrogates)
+            // XATTR_LINEEND
+            for (const SfxPoolItem* p :
+                 
pPool2->GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
             {
                 auto pItem = static_cast<const XLineEndItem*>(p);
 
@@ -1352,9 +1350,9 @@ std::unique_ptr<XLineStartItem> 
XLineStartItem::checkForUniqueItem( SdrModel& rM
         sal_Int32 nUserIndex = 1;
         const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
 
-        ItemSurrogates aSurrogates;
-        rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             rPool1.GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             auto pItem = static_cast<const XLineStartItem*>(p);
 
@@ -1376,8 +1374,8 @@ std::unique_ptr<XLineStartItem> 
XLineStartItem::checkForUniqueItem( SdrModel& rM
             }
         }
 
-        rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINEEND
+        for (const SfxPoolItem* p : 
rPool1.GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
         {
             auto pItem = static_cast<const XLineEndItem*>(p);
 
@@ -1499,9 +1497,9 @@ std::unique_ptr<XLineEndItem> 
XLineEndItem::checkForUniqueItem( SdrModel& rModel
     const SfxItemPool& rPool1 = rModel.GetItemPool();
     if (!aUniqueName.isEmpty())
     {
-        ItemSurrogates aSurrogates;
-        rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             rPool1.GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             auto pItem = static_cast<const XLineStartItem*>(p);
 
@@ -1521,8 +1519,9 @@ std::unique_ptr<XLineEndItem> 
XLineEndItem::checkForUniqueItem( SdrModel& rModel
 
         if( !bForceNew )
         {
-            rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-            for (const SfxPoolItem* p : aSurrogates)
+            // XATTR_LINEEND
+            for (const SfxPoolItem* p :
+                 
rPool1.GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
             {
                 auto pItem = static_cast<const XLineEndItem*>(p);
 
@@ -1545,9 +1544,9 @@ std::unique_ptr<XLineEndItem> 
XLineEndItem::checkForUniqueItem( SdrModel& rModel
     const SfxItemPool* pPool2 = rModel.GetStyleSheetPool() ? 
&rModel.GetStyleSheetPool()->GetPool() : nullptr;
     if( !aUniqueName.isEmpty() && pPool2)
     {
-        ItemSurrogates aSurrogates;
-        pPool2->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             pPool2->GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             auto pItem = static_cast<const XLineStartItem*>(p);
 
@@ -1567,8 +1566,9 @@ std::unique_ptr<XLineEndItem> 
XLineEndItem::checkForUniqueItem( SdrModel& rModel
 
         if( !bForceNew )
         {
-            pPool2->GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-            for (const SfxPoolItem* p : aSurrogates)
+            // XATTR_LINEEND
+            for (const SfxPoolItem* p :
+                 
pPool2->GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
             {
                 auto pItem = static_cast<const XLineEndItem*>(p);
 
@@ -1597,9 +1597,9 @@ std::unique_ptr<XLineEndItem> 
XLineEndItem::checkForUniqueItem( SdrModel& rModel
         sal_Int32 nUserIndex = 1;
         const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
 
-        ItemSurrogates aSurrogates;
-        rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineStartItemType); // XATTR_LINESTART
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINESTART
+        for (const SfxPoolItem* p :
+             rPool1.GetItemSurrogatesForItem(SfxItemType::XLineStartItemType))
         {
             auto pItem = static_cast<const XLineStartItem*>(p);
 
@@ -1621,8 +1621,8 @@ std::unique_ptr<XLineEndItem> 
XLineEndItem::checkForUniqueItem( SdrModel& rModel
             }
         }
 
-        rPool1.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XLineEndItemType); // XATTR_LINEEND
-        for (const SfxPoolItem* p : aSurrogates)
+        // XATTR_LINEEND
+        for (const SfxPoolItem* p : 
rPool1.GetItemSurrogatesForItem(SfxItemType::XLineEndItemType))
         {
             auto pItem = static_cast<const XLineEndItem*>(p);
 
diff --git a/sw/source/filter/ww8/rtfexport.cxx 
b/sw/source/filter/ww8/rtfexport.cxx
index c4694de5e572..e5a078713284 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -1412,9 +1412,7 @@ void RtfExport::OutColorTable()
     }
 
     // TextFrame or paragraph background solid fill.
-    ItemSurrogates aSurrogates;
-    rPool.GetItemSurrogatesForItem(aSurrogates, 
SfxItemType::XFillColorItemType);
-    for (const SfxPoolItem* pItem : aSurrogates)
+    for (const SfxPoolItem* pItem : 
rPool.GetItemSurrogatesForItem(SfxItemType::XFillColorItemType))
     {
         const auto& rColorItem = static_cast<const XFillColorItem&>(*pItem);
         InsColor(rColorItem.GetColorValue());

Reply via email to