summaryrefslogtreecommitdiff
path: root/include/svl/itemset.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-12-06 09:56:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-12-18 20:10:29 +0100
commit4bcdbddf9a29d27c5246825826765377ef832800 (patch)
tree92a5ac3ad0e732ec9aa3ee7a6f8b425980258063 /include/svl/itemset.hxx
parent133959ca7658920928631eee99807aff2b77dc5f (diff)
add copy constructor for SfxItemSetFixed
which flushes out the fact that, previously, when SfxItemSetFixed was being copied, we were not actually taking advantage of the "internal" memory, and were actually allocating a separate block of memory, like a "normal" SfxItemSet. Change-Id: I6a8073c58b464d53bfd2a54cf1dd27a3f2cb3df7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160377 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/svl/itemset.hxx')
-rw-r--r--include/svl/itemset.hxx24
1 files changed, 19 insertions, 5 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 599afc7ab5bd..ffd7e7ac8caa 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -120,6 +120,8 @@ protected:
SfxItemSet( SfxItemPool&, SfxAllItemSetFlag );
/** special constructor for SfxItemSetFixed */
SfxItemSet( SfxItemPool&, WhichRangesContainer&& ranges, SfxPoolItem const ** ppItems, sal_uInt16 nTotalCount );
+ /** special constructor for SfxItemSetFixed copy constructor */
+ SfxItemSet( const SfxItemSet& rOther, SfxPoolItem const ** ppMyItems );
public:
SfxItemSet( const SfxItemSet& );
@@ -145,6 +147,8 @@ public:
sal_uInt16 Count() const { return m_nCount; }
sal_uInt16 TotalCount() const { return m_nTotalCount; }
+ bool IsItemsFixed() const { return m_bItemsFixed; }
+
const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const;
template<class T>
const T& Get( TypedWhichId<T> nWhich, bool bSrchInParent = true ) const
@@ -333,17 +337,27 @@ static constexpr sal_uInt16 CountRanges1()
return nCapacity;
}}
+// Split out the array because we need it to be initialised before we call
+// the SfxItemSet constructor
+template<sal_uInt16... WIDs>
+struct SfxItemSetFixedStorage
+{
+ static constexpr sal_uInt16 NITEMS = svl::detail::CountRanges1<WIDs...>();
+ const SfxPoolItem* m_aItems[NITEMS] {};
+};
+
// Allocate the items array inside the object, to reduce allocation cost.
//
template<sal_uInt16... WIDs>
-class SfxItemSetFixed : public SfxItemSet
+class SfxItemSetFixed : public SfxItemSetFixedStorage<WIDs...>, public SfxItemSet
{
public:
SfxItemSetFixed( SfxItemPool& rPool)
- : SfxItemSet(rPool, WhichRangesContainer(svl::Items_t<WIDs...>{}), m_aItems, NITEMS) {}
-private:
- static constexpr sal_uInt16 NITEMS = svl::detail::CountRanges1<WIDs...>();
- const SfxPoolItem* m_aItems[NITEMS] = {};
+ : SfxItemSet(rPool, WhichRangesContainer(svl::Items_t<WIDs...>{}),
+ SfxItemSetFixedStorage<WIDs...>::m_aItems,
+ SfxItemSetFixedStorage<WIDs...>::NITEMS) {}
+ SfxItemSetFixed( const SfxItemSetFixed<WIDs...>& rOther )
+ : SfxItemSet(rOther, SfxItemSetFixedStorage<WIDs...>::m_aItems) {}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */