diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2016-04-23 20:23:29 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-27 07:21:45 +0000 |
commit | 9eb2e683ab051edd0bce18841f0ac05df5038854 (patch) | |
tree | 71e7a4d4b8389c09ff17024fceaed94668751082 /include/svl | |
parent | fd964e3b9f60bf2043fdc39ab8161a586049b481 (diff) |
tdf#34465 remove calls to SfxItemSet::Put(const SfxPoolItem&, sal_uInt16)
and put an assert in SfxPoolItem::SetWhich() so nothing new
creeps in.
Change-Id: I6497650fa61ffb2b6941ffff2d471c8f117be1df
Reviewed-on: https://gerrit.libreoffice.org/24324
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'include/svl')
-rw-r--r-- | include/svl/itemset.hxx | 2 | ||||
-rw-r--r-- | include/svl/poolitem.hxx | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index adfcf0608d98..76511021567c 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -124,7 +124,9 @@ public: inline void SetParent( const SfxItemSet* pNew ); // add, delete items, work on items +protected: virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich ); +public: const SfxPoolItem* Put( const SfxPoolItem& rItem ) { return Put(rItem, rItem.Which()); } bool Put( const SfxItemSet&, diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index f1f47a3bae30..f2f9f2947f68 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -163,7 +163,12 @@ protected: public: virtual ~SfxPoolItem(); - void SetWhich( sal_uInt16 nId ) { m_nWhich = nId; } + void SetWhich( sal_uInt16 nId ) + { + // can only change the Which before we are in a set + assert(m_nRefCount==0); + m_nWhich = nId; + } sal_uInt16 Which() const { return m_nWhich; } virtual bool operator==( const SfxPoolItem& ) const = 0; bool operator!=( const SfxPoolItem& rItem ) const @@ -186,6 +191,8 @@ public: virtual SfxPoolItem* Create( SvStream &, sal_uInt16 nItemVersion ) const; virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const; virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const = 0; + // clone and call SetWhich + SfxPoolItem* CloneSetWhich( sal_uInt16 nNewWhich ) const; sal_uLong GetRefCount() const { return m_nRefCount; } inline SfxItemKind GetKind() const { return m_nKind; } |