diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-04-19 17:07:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-19 21:48:06 +0200 |
commit | cd073a4a945a527cec3080523a0d7ec42bc49b26 (patch) | |
tree | 982b997ddc759a5c062ea5d87ed20cc17b1b09c6 /svl | |
parent | 35dac3d5d51cf58c3f49e039b8a67b129055f267 (diff) |
svx properties: pass SfxItemSet around by value
so we avoid heap allocation costs when loading lots of shapes
Change-Id: I0de5819acc7f845973a284e68ab709989f27d402
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114297
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/itemset.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 883caf50d9d9..dea82de88d64 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -1459,6 +1459,31 @@ std::unique_ptr<SfxItemSet> SfxItemSet::Clone(bool bItems, SfxItemPool *pToPool : new SfxItemSet(*m_pPool, m_pWhichRanges)); } +SfxItemSet SfxItemSet::CloneAsValue(bool bItems, SfxItemPool *pToPool ) const +{ + if (pToPool && pToPool != m_pPool) + { + SfxItemSet aNewSet(*pToPool, m_pWhichRanges); + if ( bItems ) + { + SfxWhichIter aIter(aNewSet); + sal_uInt16 nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + const SfxPoolItem* pItem; + if ( SfxItemState::SET == GetItemState( nWhich, false, &pItem ) ) + aNewSet.Put( *pItem, pItem->Which() ); + nWhich = aIter.NextWhich(); + } + } + return aNewSet; + } + else + return bItems + ? *this + : SfxItemSet(*m_pPool, m_pWhichRanges); +} + void SfxItemSet::PutDirect(const SfxPoolItem &rItem) { SfxPoolItem const** ppFnd = m_pItems.get(); @@ -1742,4 +1767,11 @@ std::unique_ptr<SfxItemSet> SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPo return std::unique_ptr<SfxItemSet>(bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*m_pPool)); } +SfxItemSet SfxAllItemSet::CloneAsValue(bool , SfxItemPool * ) const +{ + // if you are trying to clone, then the thing you are cloning is polymorphic, which means + // it cannot be cloned as a value + throw std::logic_error("cannot do this"); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |