summaryrefslogtreecommitdiff
path: root/include/svl/itemset.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'include/svl/itemset.hxx')
-rw-r--r--include/svl/itemset.hxx52
1 files changed, 35 insertions, 17 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 7c85e7534f59..efae21b3be61 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -32,6 +32,7 @@
#include <svl/svldllapi.h>
#include <svl/poolitem.hxx>
#include <svl/typedwhich.hxx>
+#include <svl/whichranges.hxx>
class SfxItemPool;
@@ -84,7 +85,12 @@ constexpr std::size_t rangesSize()
}
-template<sal_uInt16... WIDs> struct Items {};
+template<sal_uInt16... WIDs> struct Items
+{
+ // This is passed to WhichRangesContainer so we can avoid needing to malloc()
+ // for compile-time data.
+ static constexpr std::array<sal_uInt16, sizeof...(WIDs)> value = { { WIDs... } };
+};
}
@@ -96,18 +102,18 @@ class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet
const SfxItemSet* m_pParent; ///< derivation
std::unique_ptr<SfxPoolItem const*[]>
m_pItems; ///< array of items
- sal_uInt16* m_pWhichRanges; ///< array of Which Ranges
+ WhichRangesContainer m_pWhichRanges; ///< array of Which Ranges
sal_uInt16 m_nCount; ///< number of items
friend class SfxItemPoolCache;
friend class SfxAllItemSet;
private:
- SVL_DLLPRIVATE sal_uInt16 InitRanges_Impl(const sal_uInt16 *nWhichPairTable);
+ SVL_DLLPRIVATE void RecreateRanges_Impl(const WhichRangesContainer& pNewRanges);
- SfxItemSet(
- SfxItemPool & pool, std::initializer_list<sal_uInt16> wids,
- std::size_t items);
+ SfxItemSet( SfxItemPool & pool, const WhichRangesContainer& wids, std::size_t items );
+ SfxItemSet( SfxItemPool & pool, WhichRangesContainer&& wids, std::size_t items );
+ SfxItemSet( SfxItemPool & pool, std::initializer_list<sal_uInt16> wids, std::size_t items );
public:
SfxPoolItem const** GetItems_Impl() const { return m_pItems.get(); }
@@ -123,21 +129,32 @@ protected:
virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership );
+ /** special constructor for SfxAllItemSet */
+ enum class SfxAllItemSetFlag { Flag };
+ SfxItemSet( SfxItemPool&, SfxAllItemSetFlag );
+
public:
struct Pair { sal_uInt16 wid1, wid2; };
+ SfxItemSet( const SfxItemSet& );
+ SfxItemSet( SfxItemSet&& ) noexcept;
+ SfxItemSet( SfxItemPool& );
+ SfxItemSet( SfxItemPool&, const WhichRangesContainer& ranges );
+ SfxItemSet( SfxItemPool&, WhichRangesContainer&& ranges );
- SfxItemSet( const SfxItemSet& );
- SfxItemSet( SfxItemSet&& ) noexcept;
+ SfxItemSet( SfxItemPool& rPool, sal_uInt16 nWhichStart, sal_uInt16 nWhichEnd )
+ : SfxItemSet(rPool, WhichRangesContainer(nWhichStart, nWhichEnd)) {}
- SfxItemSet( SfxItemPool&);
- template<sal_uInt16... WIDs> SfxItemSet(
+ template<sal_uInt16... WIDs>
+ SfxItemSet(
typename std::enable_if<
svl::detail::validRanges<WIDs...>(), SfxItemPool &>::type pool,
- svl::Items<WIDs...>):
- SfxItemSet(pool, {WIDs...}, svl::detail::rangesSize<WIDs...>()) {}
- SfxItemSet( SfxItemPool&, std::initializer_list<Pair> wids );
- SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable );
- virtual ~SfxItemSet();
+ svl::Items<WIDs...>)
+ : SfxItemSet(pool, WhichRangesContainer(svl::Items<WIDs...>::value), svl::detail::rangesSize<WIDs...>()) {}
+
+ SfxItemSet( SfxItemPool&, std::initializer_list<Pair> wids );
+ SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable );
+
+ virtual ~SfxItemSet();
virtual std::unique_ptr<SfxItemSet> Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const;
virtual SfxItemSet CloneAsValue(bool bItems = true, SfxItemPool *pToPool = nullptr) const;
@@ -231,8 +248,9 @@ public:
void MergeValue( const SfxPoolItem& rItem, bool bOverwriteDefaults = false );
SfxItemPool* GetPool() const { return m_pPool; }
- const sal_uInt16* GetRanges() const { return m_pWhichRanges; }
- void SetRanges( const sal_uInt16 *pRanges );
+ const WhichRangesContainer & GetRanges() const { return m_pWhichRanges; }
+ void SetRanges( const WhichRangesContainer& );
+ void SetRanges( WhichRangesContainer&& );
void MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo );
const SfxItemSet* GetParent() const { return m_pParent; }