summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svl/itempool.hxx2
-rw-r--r--svl/qa/unit/items/test_itempool.cxx2
-rw-r--r--svl/source/inc/poolio.hxx10
-rw-r--r--svl/source/items/itempool.cxx24
-rw-r--r--svl/source/items/itemset.cxx2
-rw-r--r--svl/source/items/poolio.cxx2
6 files changed, 18 insertions, 24 deletions
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index f4f5d86f3a08..29f736f44ca1 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -77,7 +77,7 @@ private:
public:
// for default SfxItemSet::CTOR, set default WhichRanges
- void FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const;
+ void FillItemIdRanges_Impl( std::unique_ptr<sal_uInt16[]>& pWhichRanges ) const;
const sal_uInt16* GetFrozenIdRanges() const;
protected:
diff --git a/svl/qa/unit/items/test_itempool.cxx b/svl/qa/unit/items/test_itempool.cxx
index a3132be80b0a..cde5dee62f2c 100644
--- a/svl/qa/unit/items/test_itempool.cxx
+++ b/svl/qa/unit/items/test_itempool.cxx
@@ -80,7 +80,7 @@ void PoolItemTest::testPool()
}
// Test rehash
- for (SfxPoolItemArray_Impl *pSlice : pImpl->maPoolItems)
+ for (auto & pSlice : pImpl->maPoolItems)
{
if (pSlice)
pSlice->ReHash();
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
index 538c89994603..359b88c863dd 100644
--- a/svl/source/inc/poolio.hxx
+++ b/svl/source/inc/poolio.hxx
@@ -71,14 +71,14 @@ public:
struct SfxItemPool_Impl
{
SfxBroadcaster aBC;
- std::vector<SfxPoolItemArray_Impl*> maPoolItems;
+ std::vector<std::unique_ptr<SfxPoolItemArray_Impl>> maPoolItems;
std::vector<SfxItemPoolUser*> maSfxItemPoolUsers; /// ObjectUser section
OUString aName;
std::vector<SfxPoolItem*> maPoolDefaults;
std::vector<SfxPoolItem*>* mpStaticDefaults;
SfxItemPool* mpMaster;
SfxItemPool* mpSecondary;
- sal_uInt16* mpPoolRanges;
+ std::unique_ptr<sal_uInt16[]> mpPoolRanges;
sal_uInt16 mnStart;
sal_uInt16 mnEnd;
MapUnit eDefMetric;
@@ -105,13 +105,9 @@ struct SfxItemPool_Impl
void DeleteItems()
{
- for (auto pPoolItemArray : maPoolItems)
- delete pPoolItemArray;
maPoolItems.clear();
maPoolDefaults.clear();
-
- delete[] mpPoolRanges;
- mpPoolRanges = nullptr;
+ mpPoolRanges.reset();
}
// unit testing
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 07eab0ab3435..76e9d90b485f 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -620,11 +620,11 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
typeid(rItem) == typeid(GetDefaultItem(nWhich)));
const sal_uInt16 nIndex = GetIndex_Impl(nWhich);
- SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex];
+ SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex].get();
if (!pItemArr)
{
- pImpl->maPoolItems[nIndex] = new SfxPoolItemArray_Impl;
- pItemArr = pImpl->maPoolItems[nIndex];
+ pImpl->maPoolItems[nIndex].reset(new SfxPoolItemArray_Impl);
+ pItemArr = pImpl->maPoolItems[nIndex].get();
}
std::vector<SfxPoolItem*>::iterator ppFree;
@@ -753,7 +753,7 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
return;
// Find Item in own Pool
- SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex];
+ SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex].get();
assert(pItemArr && "removing Item not in Pool");
SfxPoolItemArray_Impl::PoolItemPtrToIndexMap::const_iterator it;
@@ -826,7 +826,7 @@ void SfxItemPool::FreezeIdRanges()
}
-void SfxItemPool::FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const
+void SfxItemPool::FillItemIdRanges_Impl( std::unique_ptr<sal_uInt16[]>& pWhichRanges ) const
{
DBG_ASSERT( !pImpl->mpPoolRanges, "GetFrozenRanges() would be faster!" );
@@ -835,20 +835,20 @@ void SfxItemPool::FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const
for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary )
++nLevel;
- pWhichRanges = new sal_uInt16[ 2*nLevel + 1 ];
+ pWhichRanges.reset(new sal_uInt16[ 2*nLevel + 1 ]);
nLevel = 0;
for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary )
{
- *(pWhichRanges+(nLevel++)) = pPool->pImpl->mnStart;
- *(pWhichRanges+(nLevel++)) = pPool->pImpl->mnEnd;
- *(pWhichRanges+nLevel) = 0;
+ pWhichRanges[nLevel++] = pPool->pImpl->mnStart;
+ pWhichRanges[nLevel++] = pPool->pImpl->mnEnd;
+ pWhichRanges[nLevel] = 0;
}
}
const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const
{
- return pImpl->mpPoolRanges;
+ return pImpl->mpPoolRanges.get();
}
const SfxPoolItem *SfxItemPool::GetItem2Default(sal_uInt16 nWhich) const
@@ -870,7 +870,7 @@ const SfxPoolItem *SfxItemPool::GetItem2(sal_uInt16 nWhich, sal_uInt32 nOfst) co
if ( nOfst == SFX_ITEMS_DEFAULT )
return (*pImpl->mpStaticDefaults)[ GetIndex_Impl(nWhich) ];
- SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(nWhich)];
+ SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(nWhich)].get();
if( pItemArr && nOfst < pItemArr->size() )
return (*pItemArr)[nOfst];
@@ -887,7 +887,7 @@ sal_uInt32 SfxItemPool::GetItemCount2(sal_uInt16 nWhich) const
return 0;
}
- SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(nWhich)];
+ SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(nWhich)].get();
if ( pItemArr )
return pItemArr->size();
return 0;
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 784e23a33e22..e967089e17ee 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -94,8 +94,6 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool)
{
m_pWhichRanges = const_cast<sal_uInt16*>(m_pPool->GetFrozenIdRanges());
assert( m_pWhichRanges && "don't create ItemSets with full range before FreezeIdRanges()" );
- if (!m_pWhichRanges)
- m_pPool->FillItemIdRanges_Impl( m_pWhichRanges );
const sal_uInt16 nSize = TotalCount();
m_pItems.reset(new const SfxPoolItem*[nSize]{});
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index 4d73a8af581f..c73e85c2b0ac 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -104,7 +104,7 @@ bool SfxItemPool::CheckItemInPool(const SfxPoolItem *pItem) const
if( IsStaticDefaultItem(pItem) || IsPoolDefaultItem(pItem) )
return true;
- SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(pItem->Which())];
+ SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(pItem->Which())].get();
DBG_ASSERT(pItemArr, "ItemArr is not available");
for ( size_t i = 0; i < pItemArr->size(); ++i )