summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-07-20 09:52:22 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-07-20 09:32:08 +0200
commit1738f106bd73fa2cf153905fc28b198d6f0cf211 (patch)
tree668301d664b0c9dcf4a3b06c108cd89a6312341e /svl
parent59f2d8be6d43a57049db6ea3e425d49b5a3794e8 (diff)
Simplify SfxItemSet ctors and TotalCount using delegation
Change-Id: I6f40cf80bcd6c8a53f5d25f99688526d4b946bdf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119238 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itemset.cxx40
1 files changed, 8 insertions, 32 deletions
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 55804cdfe723..70ec5d1c825f 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -41,18 +41,12 @@
*
* For Sfx programmers: an SfxItemSet constructed in this way cannot
* contain any Items with SlotIds as Which values.
+ *
+ * Don't create ItemSets with full range before FreezeIdRanges()!
*/
SfxItemSet::SfxItemSet(SfxItemPool& rPool)
- : m_pPool( &rPool )
- , m_pParent(nullptr)
- , m_nCount(0)
+ : SfxItemSet(rPool, rPool.GetFrozenIdRanges())
{
- m_pWhichRanges = m_pPool->GetFrozenIdRanges();
- assert( !m_pWhichRanges.empty() && "don't create ItemSets with full range before FreezeIdRanges()" );
- assert(svl::detail::validRanges2(m_pWhichRanges));
-
- const sal_uInt16 nSize = TotalCount();
- m_pItems.reset(new const SfxPoolItem*[nSize]{});
}
SfxItemSet::SfxItemSet( SfxItemPool& rPool, SfxAllItemSetFlag )
@@ -96,27 +90,14 @@ SfxItemSet::SfxItemSet(
assert(svl::detail::validRanges2(m_pWhichRanges));
}
-SfxItemSet::SfxItemSet(
- SfxItemPool & pool, const WhichRangesContainer& wids):
- m_pPool(&pool), m_pParent(nullptr),
- m_pWhichRanges(wids),
- m_nCount(0)
+SfxItemSet::SfxItemSet(SfxItemPool& pool, const WhichRangesContainer& wids)
+ : SfxItemSet(pool, wids, svl::detail::CountRanges(wids))
{
- assert(wids.size() != 0);
- assert(svl::detail::validRanges2(m_pWhichRanges));
- std::size_t size = svl::detail::CountRanges(wids);
- m_pItems.reset( new SfxPoolItem const *[size]{} );
}
-SfxItemSet::SfxItemSet(
- SfxItemPool & pool, WhichRangesContainer&& wids):
- m_pPool(&pool), m_pParent(nullptr),
- m_pWhichRanges(std::move(wids)),
- m_nCount(0)
+SfxItemSet::SfxItemSet(SfxItemPool& pool, WhichRangesContainer&& wids)
+ : SfxItemSet(pool, wids, svl::detail::CountRanges(wids))
{
- assert(svl::detail::validRanges2(m_pWhichRanges));
- std::size_t size = svl::detail::CountRanges(m_pWhichRanges);
- m_pItems.reset( new SfxPoolItem const *[size]{} );
}
SfxItemSet::SfxItemSet( const SfxItemSet& rASet )
@@ -800,12 +781,7 @@ void SfxItemSet::Changed( const SfxPoolItem&, const SfxPoolItem& )
sal_uInt16 SfxItemSet::TotalCount() const
{
- sal_uInt16 nRet = 0;
- for (auto const & pPtr : m_pWhichRanges)
- {
- nRet += ( pPtr.second - pPtr.first ) + 1;
- }
- return nRet;
+ return svl::detail::CountRanges(m_pWhichRanges);
}
/**