diff options
Diffstat (limited to 'svx/source/xoutdev/xattr.cxx')
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 98 |
1 files changed, 35 insertions, 63 deletions
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()) { |