From fe2ec505786bacc6f3baca3292367903644ac99b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 18 Feb 2022 10:56:56 +0200 Subject: improve the SfxItemSet::CloneAsValue check to prevent object slicing. Which reveals a problems with commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin Date: Thu Sep 23 18:44:42 2021 +0200 no need to allocate this SfxItemSet on the heap and commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin Date: Thu Sep 23 18:44:42 2021 +0200 no need to allocate this SfxItemSet on the heap so revert the problematic bits of those commits Change-Id: I5eeba1d5bdb91f4e539850516f2b1c11e69ff2c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130127 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/svl/itemset.hxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 5ce13bb1f4c8..8d5b9c3bb601 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -88,7 +88,9 @@ public: virtual ~SfxItemSet(); virtual std::unique_ptr Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const; - virtual SfxItemSet CloneAsValue(bool bItems = true, SfxItemPool *pToPool = nullptr) const; + /** note that this only works if you know for sure that you are dealing with an SfxItemSet + and not one of it's subclasses. */ + SfxItemSet CloneAsValue(bool bItems = true, SfxItemPool *pToPool = nullptr) const; // Get number of items sal_uInt16 Count() const { return m_nCount; } @@ -219,7 +221,6 @@ public: SfxAllItemSet( const SfxAllItemSet & ); virtual std::unique_ptr Clone( bool bItems = true, SfxItemPool *pToPool = nullptr ) const override; - virtual SfxItemSet CloneAsValue( bool bItems = true, SfxItemPool *pToPool = nullptr ) const override; private: virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership ) override; }; -- cgit