summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-17 15:19:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-20 08:02:25 +0200
commitec7ba61a6164c805f5a71b077715b7e1521a2d62 (patch)
tree4d4f3fb1ad960465897754601b0842c78db564bf /svx
parent7d58f26bf4dbeb4e138c2a91f039d8bc7fa00f0c (diff)
simplify SfxPoolItemArray_Impl (tdf#81765 related)
Since we want to look up items by pointer, just store them in a std::unordered_set, which allows fast find(). This dramatically simplifies most operations on this data structure. Fix a dodgy sd test that was relying on items with the same whichid being in the pool being in a certain order. Change-Id: I4d79fc718f95e3083a20788be1050fbe9fca7263 Reviewed-on: https://gerrit.libreoffice.org/70881 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/unodraw/UnoNameItemTable.cxx82
-rw-r--r--svx/source/unodraw/UnoNamespaceMap.cxx56
-rw-r--r--svx/source/unodraw/unomtabl.cxx119
-rw-r--r--svx/source/unodraw/unoshape.cxx10
-rw-r--r--svx/source/xoutdev/xattr.cxx98
5 files changed, 158 insertions, 207 deletions
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx
index 7f72bbe9ad31..64c1a354e982 100644
--- a/svx/source/unodraw/UnoNameItemTable.cxx
+++ b/svx/source/unodraw/UnoNameItemTable.cxx
@@ -157,18 +157,17 @@ void SAL_CALL SvxUnoNameItemTable::replaceByName( const OUString& aApiName, cons
// if it is not in our own sets, modify the pool!
bool bFound = false;
- sal_uInt32 nSurrogate;
- sal_uInt32 nCount = mpModelPool ? mpModelPool->GetItemCount2( mnWhich ) : 0;
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
- {
- NameOrIndex *pItem = const_cast<NameOrIndex*>(static_cast<const NameOrIndex*>(mpModelPool->GetItem2( mnWhich, nSurrogate)));
- if (pItem && aName == pItem->GetName())
+ if (mpModelPool)
+ for (const SfxPoolItem* pItem : mpModelPool->GetItemSurrogates(mnWhich))
{
- pItem->PutValue( aElement, mnMemberId );
- bFound = true;
- break;
+ NameOrIndex *pNameOrIndex = const_cast<NameOrIndex*>(static_cast<const NameOrIndex*>(pItem));
+ if (pNameOrIndex && aName == pNameOrIndex->GetName())
+ {
+ pNameOrIndex->PutValue( aElement, mnMemberId );
+ bFound = true;
+ break;
+ }
}
- }
if( !bFound )
throw container::NoSuchElementException();
@@ -191,16 +190,13 @@ uno::Any SAL_CALL SvxUnoNameItemTable::getByName( const OUString& aApiName )
if (mpModelPool && !aName.isEmpty())
{
- sal_uInt32 nSurrogate;
-
- sal_uInt32 nSurrogateCount = mpModelPool ? mpModelPool->GetItemCount2( mnWhich ) : 0;
- for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
+ for (const SfxPoolItem* pItem : mpModelPool->GetItemSurrogates(mnWhich))
{
- const NameOrIndex *pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( mnWhich, nSurrogate ));
+ const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
- if (isValid(pItem) && aName == pItem->GetName())
+ if (isValid(pNameOrIndex) && aName == pNameOrIndex->GetName())
{
- pItem->QueryValue( aAny, mnMemberId );
+ pNameOrIndex->QueryValue( aAny, mnMemberId );
return aAny;
}
}
@@ -216,18 +212,17 @@ uno::Sequence< OUString > SAL_CALL SvxUnoNameItemTable::getElementNames( )
std::set< OUString > aNameSet;
- const sal_uInt32 nSurrogateCount = mpModelPool ? mpModelPool->GetItemCount2( mnWhich ) : 0;
- sal_uInt32 nSurrogate;
- for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
- {
- const NameOrIndex *pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( mnWhich, nSurrogate ));
+ if (mpModelPool)
+ for (const SfxPoolItem* pItem : mpModelPool->GetItemSurrogates(mnWhich))
+ {
+ const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
- if( !isValid( pItem ) )
- continue;
+ if( !isValid( pNameOrIndex ) )
+ continue;
- OUString aApiName = SvxUnogetApiNameForItem(mnWhich, pItem->GetName());
- aNameSet.insert(aApiName);
- }
+ OUString aApiName = SvxUnogetApiNameForItem(mnWhich, pNameOrIndex->GetName());
+ aNameSet.insert(aApiName);
+ }
return comphelper::containerToSequence(aNameSet);
}
@@ -241,16 +236,13 @@ sal_Bool SAL_CALL SvxUnoNameItemTable::hasByName( const OUString& aApiName )
if (aName.isEmpty())
return false;
- sal_uInt32 nSurrogate;
-
-
- sal_uInt32 nCount = mpModelPool ? mpModelPool->GetItemCount2( mnWhich ) : 0;
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
- {
- const NameOrIndex *pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( mnWhich, nSurrogate ));
- if (isValid(pItem) && aName == pItem->GetName())
- return true;
- }
+ if (mpModelPool)
+ for (const SfxPoolItem* pItem : mpModelPool->GetItemSurrogates(mnWhich))
+ {
+ const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
+ if (isValid(pNameOrIndex) && aName == pNameOrIndex->GetName())
+ return true;
+ }
return false;
}
@@ -259,16 +251,14 @@ sal_Bool SAL_CALL SvxUnoNameItemTable::hasElements( )
{
SolarMutexGuard aGuard;
+ if (mpModelPool)
+ for (const SfxPoolItem* pItem : mpModelPool->GetItemSurrogates(mnWhich))
+ {
+ const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
- sal_uInt32 nSurrogate;
- const sal_uInt32 nSurrogateCount = mpModelPool ? mpModelPool->GetItemCount2( mnWhich ) : 0;
- for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
- {
- const NameOrIndex *pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( mnWhich, nSurrogate ));
-
- if( isValid( pItem ) )
- return true;
- }
+ if( isValid( pNameOrIndex ) )
+ return true;
+ }
return false;
}
diff --git a/svx/source/unodraw/UnoNamespaceMap.cxx b/svx/source/unodraw/UnoNamespaceMap.cxx
index 88049ce4d914..cc78931fd88a 100644
--- a/svx/source/unodraw/UnoNamespaceMap.cxx
+++ b/svx/source/unodraw/UnoNamespaceMap.cxx
@@ -93,8 +93,8 @@ namespace svx
sal_uInt16* mpWhichId;
- sal_uInt32 mnItemCount;
- sal_uInt32 mnItem;
+ std::vector<const SvXMLAttrContainerItem*> mvItems;
+ sal_Int32 mnItem;
const SvXMLAttrContainerItem* mpCurrentAttr;
sal_uInt16 mnCurrentAttr;
@@ -118,8 +118,13 @@ NamespaceIteratorImpl::NamespaceIteratorImpl( sal_uInt16* pWhichIds, SfxItemPool
mpWhichId = pWhichIds;
- mnItem = 0;
- mnItemCount = (mpWhichId && (0 != *mpWhichId) && mpPool) ? mpPool->GetItemCount2( *mpWhichId ) : 0;
+ mnItem = -1;
+ if (mpWhichId && (0 != *mpWhichId) && mpPool)
+ {
+ mvItems.reserve(mpPool->GetItemCount2( *mpWhichId ));
+ for (const SfxPoolItem* pItem : mpPool->GetItemSurrogates( *mpWhichId ))
+ mvItems.push_back(static_cast<const SvXMLAttrContainerItem*>(pItem));
+ }
}
bool NamespaceIteratorImpl::next( OUString& rPrefix, OUString& rURL )
@@ -136,43 +141,36 @@ bool NamespaceIteratorImpl::next( OUString& rPrefix, OUString& rURL )
// we need the next namespace item
mpCurrentAttr = nullptr;
-
- const SfxPoolItem* pItem = nullptr;
- // look for the next available item in the current pool
- while( (mnItem < mnItemCount) && ( nullptr == (pItem = mpPool->GetItem2( *mpWhichId, mnItem ) ) ) )
- mnItem++;
+ mnItem++;
// are we finished with the current whichid?
- if( mnItem == mnItemCount )
+ if( mnItem == static_cast<sal_Int32>(mvItems.size()) )
{
mpWhichId++;
// are we finished with the current pool?
- if( 0 != *mpWhichId )
- {
- mnItem = 0;
- mnItemCount = mpPool ? mpPool->GetItemCount2( *mpWhichId ) : 0;
- return next( rPrefix, rURL );
- }
+ if( 0 == *mpWhichId )
+ return false;
- pItem = nullptr;
- }
-
- if( pItem )
- {
- mnItem++;
-
- // get that item and see if there namespaces inside
- const SvXMLAttrContainerItem *pUnknown = static_cast<const SvXMLAttrContainerItem *>(pItem);
- if( pUnknown->GetAttrCount() > 0 )
+ mnItem = -1;
+ mvItems.clear();
+ if (mpPool)
{
- mpCurrentAttr = pUnknown;
- mnCurrentAttr = pUnknown->GetFirstNamespaceIndex();
+ mvItems.reserve(mpPool->GetItemCount2( *mpWhichId ));
+ for (const SfxPoolItem* pItem2 : mpPool->GetItemSurrogates( *mpWhichId ))
+ mvItems.push_back(static_cast<const SvXMLAttrContainerItem*>(pItem2));
}
return next( rPrefix, rURL );
}
- return false;
+ auto pItem = mvItems[mnItem];
+ // get that item and see if there namespaces inside
+ if( pItem->GetAttrCount() > 0 )
+ {
+ mpCurrentAttr = pItem;
+ mnCurrentAttr = pItem->GetFirstNamespaceIndex();
+ }
+ return next( rPrefix, rURL );
}
diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx
index 01d639df58ed..0dc25307cfaa 100644
--- a/svx/source/unodraw/unomtabl.cxx
+++ b/svx/source/unodraw/unomtabl.cxx
@@ -231,30 +231,29 @@ void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const
// if it is not in our own sets, modify the pool!
bool bFound = false;
- sal_uInt32 nSurrogate;
- const sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
- for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
- {
- NameOrIndex *pItem = const_cast<NameOrIndex*>(static_cast<const NameOrIndex*>(mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate)));
- if( pItem && pItem->GetName() == aName )
+ if (mpModelPool)
+ for (const SfxPoolItem* p : mpModelPool->GetItemSurrogates(XATTR_LINESTART))
{
- pItem->PutValue( aElement, 0 );
- bFound = true;
- break;
+ NameOrIndex *pItem = const_cast<NameOrIndex*>(static_cast<const NameOrIndex*>(p));
+ if( pItem && pItem->GetName() == aName )
+ {
+ pItem->PutValue( aElement, 0 );
+ bFound = true;
+ break;
+ }
}
- }
- const sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
- for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
- {
- NameOrIndex *pItem = const_cast<NameOrIndex*>(static_cast<const NameOrIndex*>(mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate)));
- if( pItem && pItem->GetName() == aName )
+ if (mpModelPool)
+ for (const SfxPoolItem* p : mpModelPool->GetItemSurrogates(XATTR_LINEEND))
{
- pItem->PutValue( aElement, 0 );
- bFound = true;
- break;
+ NameOrIndex *pItem = const_cast<NameOrIndex*>(static_cast<const NameOrIndex*>(p));
+ if( pItem && pItem->GetName() == aName )
+ {
+ pItem->PutValue( aElement, 0 );
+ bFound = true;
+ break;
+ }
}
- }
if( !bFound )
throw container::NoSuchElementException();
@@ -264,17 +263,17 @@ void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const
static bool getByNameFromPool( const OUString& rSearchName, SfxItemPool const * pPool, sal_uInt16 nWhich, uno::Any& rAny )
{
- const sal_uInt32 nSurrogateCount = pPool ? pPool->GetItemCount2( nWhich ) : 0;
- for( sal_uInt32 nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
- {
- const NameOrIndex *pItem = static_cast<const NameOrIndex*>(pPool->GetItem2( nWhich, nSurrogate ));
-
- if( pItem && pItem->GetName() == rSearchName )
+ if (pPool)
+ for (const SfxPoolItem* p : pPool->GetItemSurrogates(nWhich))
{
- pItem->QueryValue( rAny );
- return true;
+ const NameOrIndex *pItem = static_cast<const NameOrIndex*>(p);
+
+ if( pItem && pItem->GetName() == rSearchName )
+ {
+ pItem->QueryValue( rAny );
+ return true;
+ }
}
- }
return false;
}
@@ -308,11 +307,9 @@ uno::Any SAL_CALL SvxUnoMarkerTable::getByName( const OUString& aApiName )
static void createNamesForPool( SfxItemPool const * pPool, sal_uInt16 nWhich, std::set< OUString >& rNameSet )
{
- const sal_uInt32 nSuroCount = pPool->GetItemCount2( nWhich );
-
- for(sal_uInt32 nSurrogate = 0; nSurrogate < nSuroCount; ++nSurrogate)
+ for (const SfxPoolItem* p : pPool->GetItemSurrogates(nWhich))
{
- const NameOrIndex* pItem = static_cast<const NameOrIndex*>(pPool->GetItem2( nWhich, nSurrogate ));
+ const NameOrIndex* pItem = static_cast<const NameOrIndex*>(p);
if( pItem == nullptr || pItem->GetName().isEmpty() )
continue;
@@ -349,23 +346,22 @@ sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const OUString& aName )
const NameOrIndex *pItem;
aSearchName = SvxUnogetInternalNameForItem(XATTR_LINESTART, aName);
- sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
- sal_uInt32 nSurrogate;
- for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
- {
- pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate));
- if( pItem && pItem->GetName() == aSearchName )
- return true;
- }
+ if (mpModelPool)
+ for (const SfxPoolItem* p : mpModelPool->GetItemSurrogates(XATTR_LINESTART))
+ {
+ pItem = static_cast<const NameOrIndex*>(p);
+ if( pItem && pItem->GetName() == aSearchName )
+ return true;
+ }
aSearchName = SvxUnogetInternalNameForItem(XATTR_LINEEND, aName);
- sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
- for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
- {
- pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate));
- if( pItem && pItem->GetName() == aSearchName )
- return true;
- }
+ if (mpModelPool)
+ for (const SfxPoolItem* p : mpModelPool->GetItemSurrogates(XATTR_LINEEND))
+ {
+ pItem = static_cast<const NameOrIndex*>(p);
+ if( pItem && pItem->GetName() == aSearchName )
+ return true;
+ }
return false;
}
@@ -382,22 +378,21 @@ sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements( )
const NameOrIndex *pItem;
- const sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
- sal_uInt32 nSurrogate;
- for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
- {
- pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate));
- if( pItem && !pItem->GetName().isEmpty() )
- return true;
- }
+ if (mpModelPool)
+ for (const SfxPoolItem* p : mpModelPool->GetItemSurrogates(XATTR_LINESTART))
+ {
+ pItem = static_cast<const NameOrIndex*>(p);
+ if( pItem && !pItem->GetName().isEmpty() )
+ return true;
+ }
- const sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
- for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
- {
- pItem = static_cast<const NameOrIndex*>(mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate));
- if( pItem && !pItem->GetName().isEmpty() )
- return true;
- }
+ if (mpModelPool)
+ for (const SfxPoolItem* p : mpModelPool->GetItemSurrogates(XATTR_LINEEND))
+ {
+ pItem = static_cast<const NameOrIndex*>(p);
+ if( pItem && !pItem->GetName().isEmpty() )
+ return true;
+ }
return false;
}
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index b7790cd1a25d..315503fa547b 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -1578,14 +1578,10 @@ bool SvxShape::SetFillAttribute( sal_uInt16 nWID, const OUString& rName, SfxItem
return false;
}
- const SfxItemPool* pPool = rSet.GetPool();
-
- const sal_uInt32 nCount = pPool->GetItemCount2(nWID);
-
- for( sal_uInt32 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : rSet.GetPool()->GetItemSurrogates(nWID))
{
- const NameOrIndex* pItem = static_cast<const NameOrIndex*>(pPool->GetItem2(nWID, nSurrogate));
- if( pItem && ( pItem->GetName() == aName ) )
+ const NameOrIndex* pItem = static_cast<const NameOrIndex*>(p);
+ if( pItem->GetName() == aName )
{
rSet.Put( *pItem );
return true;
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index de1717d293f7..0830a9055f11 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -128,17 +128,15 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
if (!aUniqueName.isEmpty() && pPool1)
{
- const sal_uInt32 nCount = pPool1->GetItemCount2( nWhich );
-
- for( sal_uInt32 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
{
- const NameOrIndex *pItem = static_cast<const NameOrIndex*>(pPool1->GetItem2( nWhich, nSurrogate ));
+ const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
- if( pItem && ( pItem->GetName() == pCheckItem->GetName() ) )
+ if( pNameOrIndex->GetName() == pCheckItem->GetName() )
{
// if there is already an item with the same name and the same
// value it's ok to set it
- if( !pCompareValueFunc( pItem, pCheckItem ) )
+ if( !pCompareValueFunc( pNameOrIndex, pCheckItem ) )
{
// same name but different value, we need a new name for this item
aUniqueName.clear();
@@ -215,20 +213,18 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
if (aUniqueName.isEmpty() && pPool1)
{
- const sal_uInt32 nCount = pPool1->GetItemCount2( nWhich );
- const NameOrIndex *pItem;
- for( sal_uInt32 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* pItem : pPool1->GetItemSurrogates(nWhich))
{
- pItem = static_cast<const NameOrIndex*>(pPool1->GetItem2( nWhich, nSurrogate ));
+ const NameOrIndex *pNameOrIndex = static_cast<const NameOrIndex*>(pItem);
- if( pItem && !pItem->GetName().isEmpty() )
+ if( !pNameOrIndex->GetName().isEmpty() )
{
- if( !bForceNew && pCompareValueFunc( pItem, pCheckItem ) )
- return pItem->GetName();
+ if( !bForceNew && pCompareValueFunc( pNameOrIndex, pCheckItem ) )
+ return pNameOrIndex->GetName();
- if( pItem->GetName().startsWith( aUser ) )
+ if( pNameOrIndex->GetName().startsWith( aUser ) )
{
- sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32();
+ sal_Int32 nThisIndex = pNameOrIndex->GetName().copy( aUser.getLength() ).toInt32();
if( nThisIndex >= nUserIndex )
nUserIndex = nThisIndex + 1;
}
@@ -1098,16 +1094,12 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM
// 2. if we have a name check if there is already an item with the
// same name in the documents pool with a different line end or start
- sal_uInt32 nCount, nSurrogate;
-
const SfxItemPool& rPool1 = pModel->GetItemPool();
if (!aUniqueName.isEmpty())
{
- nCount = rPool1.GetItemCount2(XATTR_LINESTART);
-
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
{
- const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate);
+ auto pItem = dynamic_cast<const XLineStartItem*>(p);
if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
{
@@ -1125,11 +1117,9 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM
if( !bForceNew )
{
- nCount = rPool1.GetItemCount2(XATTR_LINEEND);
-
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
{
- const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate);
+ auto pItem = dynamic_cast<const XLineEndItem*>(p);
if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
{
@@ -1150,10 +1140,9 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM
const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
if( !aUniqueName.isEmpty() && pPool2)
{
- nCount = pPool2->GetItemCount2( XATTR_LINESTART );
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
{
- const XLineStartItem* pItem = pPool2->GetItem2( XATTR_LINESTART, nSurrogate );
+ auto pItem = dynamic_cast<const XLineStartItem*>(p);
if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
{
@@ -1171,10 +1160,9 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM
if( !bForceNew )
{
- nCount = pPool2->GetItemCount2( XATTR_LINEEND );
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
{
- const XLineEndItem* pItem = pPool2->GetItem2( XATTR_LINEEND, nSurrogate );
+ auto pItem = dynamic_cast<const XLineEndItem*>(p);
if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
{
@@ -1201,12 +1189,9 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM
sal_Int32 nUserIndex = 1;
const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
- nCount = rPool1.GetItemCount2(XATTR_LINESTART);
- sal_uInt32 nSurrogate2;
-
- for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++)
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
{
- const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate2);
+ auto pItem = dynamic_cast<const XLineStartItem*>(p);
if (pItem && !pItem->GetName().isEmpty())
{
@@ -1226,10 +1211,9 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM
}
}
- nCount = rPool1.GetItemCount2(XATTR_LINEEND);
- for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++)
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
{
- const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate2);
+ auto pItem = dynamic_cast<const XLineEndItem*>(p);
if (pItem && !pItem->GetName().isEmpty())
{
@@ -1349,16 +1333,12 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel
// 2. if we have a name check if there is already an item with the
// same name in the documents pool with a different line end or start
- sal_uInt16 nCount, nSurrogate;
-
const SfxItemPool& rPool1 = pModel->GetItemPool();
if (!aUniqueName.isEmpty())
{
- nCount = rPool1.GetItemCount2(XATTR_LINESTART);
-
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
{
- const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate);
+ auto pItem = dynamic_cast<const XLineStartItem*>(p);
if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
{
@@ -1376,11 +1356,9 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel
if( !bForceNew )
{
- nCount = rPool1.GetItemCount2(XATTR_LINEEND);
-
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
{
- const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate);
+ auto pItem = dynamic_cast<const XLineEndItem*>(p);
if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
{
@@ -1401,10 +1379,9 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel
const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr;
if( !aUniqueName.isEmpty() && pPool2)
{
- nCount = pPool2->GetItemCount2( XATTR_LINESTART );
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINESTART))
{
- const XLineStartItem* pItem = pPool2->GetItem2( XATTR_LINESTART, nSurrogate );
+ auto pItem = dynamic_cast<const XLineStartItem*>(p);
if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
{
@@ -1422,10 +1399,9 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel
if( !bForceNew )
{
- nCount = pPool2->GetItemCount2( XATTR_LINEEND );
- for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ for (const SfxPoolItem* p : pPool2->GetItemSurrogates(XATTR_LINEEND))
{
- const XLineEndItem* pItem = pPool2->GetItem2( XATTR_LINEEND, nSurrogate );
+ auto pItem = dynamic_cast<const XLineEndItem*>(p);
if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
{
@@ -1452,12 +1428,9 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel
sal_Int32 nUserIndex = 1;
const OUString aUser(SvxResId(RID_SVXSTR_LINEEND));
- nCount = rPool1.GetItemCount2(XATTR_LINESTART);
- sal_uInt32 nSurrogate2;
-
- for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++)
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINESTART))
{
- const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate2);
+ auto pItem = dynamic_cast<const XLineStartItem*>(p);
if (pItem && !pItem->GetName().isEmpty())
{
@@ -1477,10 +1450,9 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel
}
}
- nCount = rPool1.GetItemCount2(XATTR_LINEEND);
- for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++)
+ for (const SfxPoolItem* p : rPool1.GetItemSurrogates(XATTR_LINEEND))
{
- const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate2);
+ auto pItem = dynamic_cast<const XLineEndItem*>(p);
if (pItem && !pItem->GetName().isEmpty())
{