[Libreoffice-commits] core.git: svl/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jul 20 07:32:42 UTC 2021
svl/source/items/itemset.cxx | 40 ++++++++--------------------------------
1 file changed, 8 insertions(+), 32 deletions(-)
New commits:
commit 1738f106bd73fa2cf153905fc28b198d6f0cf211
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Jul 20 09:52:22 2021 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Jul 20 09:32:08 2021 +0200
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 at collabora.com>
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);
}
/**
More information about the Libreoffice-commits
mailing list