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 /include | |
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 'include')
-rw-r--r-- | include/svl/itemset.hxx | 2 | ||||
-rw-r--r-- | include/svx/sdr/properties/defaultproperties.hxx | 9 | ||||
-rw-r--r-- | include/svx/sdr/properties/properties.hxx | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 94ee142a2e77..41a782d7966f 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -125,6 +125,7 @@ public: 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; // Get number of items sal_uInt16 Count() const { return m_nCount; } @@ -256,6 +257,7 @@ public: SfxAllItemSet( const SfxAllItemSet & ); virtual std::unique_ptr<SfxItemSet> Clone( bool bItems = true, SfxItemPool *pToPool = nullptr ) const override; + virtual SfxItemSet CloneAsValue( bool bItems = true, SfxItemPool *pToPool = nullptr ) const override; protected: virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership ) override; }; diff --git a/include/svx/sdr/properties/defaultproperties.hxx b/include/svx/sdr/properties/defaultproperties.hxx index c9c4fdc5ec59..e901278d3b3e 100644 --- a/include/svx/sdr/properties/defaultproperties.hxx +++ b/include/svx/sdr/properties/defaultproperties.hxx @@ -22,10 +22,11 @@ #include <sal/config.h> -#include <memory> +#include <optional> #include <svx/sdr/properties/properties.hxx> #include <svx/svxdllapi.h> +#include <svl/itemset.hxx> struct _xmlTextWriter; typedef struct _xmlTextWriter* xmlTextWriterPtr; @@ -36,10 +37,10 @@ namespace sdr::properties { protected: // the to be used ItemSet - std::unique_ptr<SfxItemSet> mpItemSet; + mutable std::optional<SfxItemSet> mxItemSet; // create a new itemset - virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override; + virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; // test changeability for a single item virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const override; @@ -54,7 +55,7 @@ namespace sdr::properties virtual void ItemSetChanged(const SfxItemSet& rSet) override; // check if SfxItemSet exists - bool HasSfxItemSet() const { return bool(mpItemSet); } + bool HasSfxItemSet() const { return bool(mxItemSet); } public: // basic constructor diff --git a/include/svx/sdr/properties/properties.hxx b/include/svx/sdr/properties/properties.hxx index db40737756ca..600522981dc0 100644 --- a/include/svx/sdr/properties/properties.hxx +++ b/include/svx/sdr/properties/properties.hxx @@ -84,7 +84,7 @@ namespace sdr::properties virtual void applyDefaultStyleSheetFromSdrModel(); // create a new object specific itemset with object specific ranges. - virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0; + virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0; // internal access to SdrObject const SdrObject& GetSdrObject() const; |