diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-09 14:37:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-09 21:15:07 +0200 |
commit | fddda044b5983497f7423f8a32376301480d58fe (patch) | |
tree | dbfd5242f53edbc33ef9fec683567251c220c025 /include | |
parent | ec77620279c27da7e3901e69fccf42a882224065 (diff) |
Revert "fix and simplify the ItemInstanceManager mechanism"
This reverts commit 85fd526fc681a994415bb422090d1d23aa7d54f6.
Change-Id: I5019f72f88497f50a77666d57f2d16c2749bd1c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170218
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
43 files changed, 174 insertions, 132 deletions
diff --git a/include/editeng/adjustitem.hxx b/include/editeng/adjustitem.hxx index 006bede075d7..c660598abfc7 100644 --- a/include/editeng/adjustitem.hxx +++ b/include/editeng/adjustitem.hxx @@ -44,6 +44,9 @@ class EDITENG_DLLPUBLIC SvxAdjustItem final : public SfxEnumItemInterface bool bLastCenter : 1; bool bLastBlock : 1; +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); @@ -51,8 +54,6 @@ public: const sal_uInt16 nId ); // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; diff --git a/include/editeng/boxitem.hxx b/include/editeng/boxitem.hxx index 6ceff99268c3..7afb8f2bf821 100644 --- a/include/editeng/boxitem.hxx +++ b/include/editeng/boxitem.hxx @@ -73,6 +73,9 @@ class EDITENG_DLLPUBLIC SvxBoxItem final : public SfxPoolItem void tryMigrateComplexColor(SvxBoxItemLine eLine); +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx index 8412634a1157..6897e319a3b6 100644 --- a/include/editeng/brushitem.hxx +++ b/include/editeng/brushitem.hxx @@ -54,6 +54,9 @@ class EDITENG_DLLPUBLIC SvxBrushItem final : public SfxPoolItem void ApplyGraphicTransparency_Impl(); +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/charreliefitem.hxx b/include/editeng/charreliefitem.hxx index 78b57fa7df00..910adcf11e24 100644 --- a/include/editeng/charreliefitem.hxx +++ b/include/editeng/charreliefitem.hxx @@ -33,6 +33,9 @@ class EDITENG_DLLPUBLIC SvxCharReliefItem final : public SfxEnumItem<FontRelief> { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx index 220d7964ad2c..15c352ebff25 100644 --- a/include/editeng/colritem.hxx +++ b/include/editeng/colritem.hxx @@ -43,8 +43,6 @@ public: virtual ~SvxColorItem() override; // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem& rPoolItem) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override; diff --git a/include/editeng/crossedoutitem.hxx b/include/editeng/crossedoutitem.hxx index 5d8b18fe2650..259eb412e1e1 100644 --- a/include/editeng/crossedoutitem.hxx +++ b/include/editeng/crossedoutitem.hxx @@ -31,6 +31,9 @@ class EDITENG_DLLPUBLIC SvxCrossedOutItem final : public SfxEnumItem<FontStrikeout> { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/emphasismarkitem.hxx b/include/editeng/emphasismarkitem.hxx index e0fd74cf4400..94d48e4b8d9c 100644 --- a/include/editeng/emphasismarkitem.hxx +++ b/include/editeng/emphasismarkitem.hxx @@ -32,6 +32,9 @@ class EDITENG_DLLPUBLIC SvxEmphasisMarkItem final : public SfxUInt16Item { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/escapementitem.hxx b/include/editeng/escapementitem.hxx index 87afbcdd9e88..d889d7bc309e 100644 --- a/include/editeng/escapementitem.hxx +++ b/include/editeng/escapementitem.hxx @@ -51,8 +51,6 @@ public: const sal_uInt16 nId ); // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool GetPresentation( SfxItemPresentation ePres, MapUnit eCoreMetric, diff --git a/include/editeng/fhgtitem.hxx b/include/editeng/fhgtitem.hxx index 342419e4e359..bdde8c6f0afd 100644 --- a/include/editeng/fhgtitem.hxx +++ b/include/editeng/fhgtitem.hxx @@ -44,6 +44,9 @@ class EDITENG_DLLPUBLIC SvxFontHeightItem final : public SfxPoolItem friend void Create_legacy_direct_set(SvxFontHeightItem& rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP); void legacy_direct_set(sal_uInt32 nH, sal_uInt16 nP, MapUnit eP) { nHeight = nH; nProp = nP; ePropUnit = eP; } +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); @@ -51,8 +54,6 @@ public: const sal_uInt16 nId ); // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; diff --git a/include/editeng/fontitem.hxx b/include/editeng/fontitem.hxx index 82d19ca40490..f892178c521e 100644 --- a/include/editeng/fontitem.hxx +++ b/include/editeng/fontitem.hxx @@ -34,6 +34,9 @@ class EDITENG_DLLPUBLIC SvxFontItem final : public SfxPoolItem FontPitch ePitch; rtl_TextEncoding eTextEncoding; +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); @@ -45,8 +48,6 @@ public: const sal_uInt16 nId); // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem& rItem) const override; virtual SvxFontItem* Clone(SfxItemPool *pPool = nullptr) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; diff --git a/include/editeng/frmdiritem.hxx b/include/editeng/frmdiritem.hxx index 7bb6dc09950d..e2bba96b8974 100644 --- a/include/editeng/frmdiritem.hxx +++ b/include/editeng/frmdiritem.hxx @@ -30,6 +30,9 @@ class EDITENG_DLLPUBLIC SvxFrameDirectionItem final : public SfxEnumItem<SvxFrameDirection> { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: SvxFrameDirectionItem( SvxFrameDirection nValue, sal_uInt16 nWhich ); virtual ~SvxFrameDirectionItem() override; diff --git a/include/editeng/langitem.hxx b/include/editeng/langitem.hxx index c84aebf3b33c..4ebef0837a6c 100644 --- a/include/editeng/langitem.hxx +++ b/include/editeng/langitem.hxx @@ -40,6 +40,9 @@ protected: class EDITENG_DLLPUBLIC SvxLanguageItem final : public SvxLanguageItem_Base { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx index 998ea71fbb84..edab3ef23d73 100644 --- a/include/editeng/lrspitem.hxx +++ b/include/editeng/lrspitem.hxx @@ -68,8 +68,6 @@ public: SvxLeftMarginItem(SvxLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem&) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; @@ -112,8 +110,6 @@ public: SvxTextLeftMarginItem(SvxTextLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem&) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; @@ -149,19 +145,17 @@ public: void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100); short GetTextFirstLineOffset() const { return m_nFirstLineOffset; } void SetPropTextFirstLineOffset(const sal_uInt16 nProp) - { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nPropFirstLineOffset = nProp; } + { m_nPropFirstLineOffset = nProp; } sal_uInt16 GetPropTextFirstLineOffset() const { return m_nPropFirstLineOffset; } void SetTextFirstLineOffsetValue(const short nValue) - { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nFirstLineOffset = nValue; } + { m_nFirstLineOffset = nValue; } explicit SvxFirstLineIndentItem(const sal_uInt16 nId); SvxFirstLineIndentItem(const short nOffset, const sal_uInt16 nId); SvxFirstLineIndentItem(SvxFirstLineIndentItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem&) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; @@ -201,8 +195,6 @@ public: SvxRightMarginItem(SvxRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem&) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; @@ -229,15 +221,13 @@ private: tools::Long m_nGutterMargin = 0; public: - void SetGutterMargin(const tools::Long nGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nGutterMargin = nGutterMargin; } + void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; } tools::Long GetGutterMargin() const { return m_nGutterMargin; } explicit SvxGutterLeftMarginItem(const sal_uInt16 nId); SvxGutterLeftMarginItem(SvxGutterLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem&) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; @@ -270,8 +260,6 @@ public: SvxGutterRightMarginItem(SvxGutterRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==(const SfxPoolItem&) const override; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override; @@ -317,8 +305,6 @@ public: SvxLRSpaceItem(SvxLRSpaceItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; @@ -340,15 +326,15 @@ public: // Query/direct setting of the absolute values tools::Long GetLeft() const { return nLeftMargin; } tools::Long GetRight() const { return nRightMargin;} - void SetLeftValue( const tools::Long nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; assert(nFirstLineOffset == 0); nLeftMargin = nL; } - void SetRightValue( const tools::Long nR ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nRightMargin = nR; } + void SetLeftValue( const tools::Long nL ) { assert(nFirstLineOffset == 0); nLeftMargin = nL; } + void SetRightValue( const tools::Long nR ) { nRightMargin = nR; } bool IsAutoFirst() const { return bAutoFirst; } - void SetAutoFirst( const bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bAutoFirst = bNew; } + void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; } bool IsExplicitZeroMarginValRight() const { return bExplicitZeroMarginValRight; } bool IsExplicitZeroMarginValLeft() const { return bExplicitZeroMarginValLeft; } - void SetExplicitZeroMarginValRight( const bool eR ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bExplicitZeroMarginValRight = eR; } - void SetExplicitZeroMarginValLeft( const bool eL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bExplicitZeroMarginValLeft = eL; } + void SetExplicitZeroMarginValRight( const bool eR ) { bExplicitZeroMarginValRight = eR; } + void SetExplicitZeroMarginValLeft( const bool eL ) { bExplicitZeroMarginValLeft = eL; } sal_uInt16 GetPropLeft() const { return nPropLeftMargin; } sal_uInt16 GetPropRight() const { return nPropRightMargin;} @@ -359,14 +345,14 @@ public: void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100); short GetTextFirstLineOffset() const { return nFirstLineOffset; } void SetPropTextFirstLineOffset( const sal_uInt16 nProp ) - { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropFirstLineOffset = nProp; } + { nPropFirstLineOffset = nProp; } sal_uInt16 GetPropTextFirstLineOffset() const { return nPropFirstLineOffset; } void SetTextFirstLineOffsetValue( const short nValue ) - { ASSERT_CHANGE_REFCOUNTED_ITEM; nFirstLineOffset = nValue; } - void SetGutterMargin(const tools::Long nGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nGutterMargin = nGutterMargin; } + { nFirstLineOffset = nValue; } + void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; } tools::Long GetGutterMargin() const { return m_nGutterMargin; } - void SetRightGutterMargin(const tools::Long nRightGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nRightGutterMargin = nRightGutterMargin; } + void SetRightGutterMargin(const tools::Long nRightGutterMargin) { m_nRightGutterMargin = nRightGutterMargin; } tools::Long GetRightGutterMargin() const { return m_nRightGutterMargin; } void dumpAsXml(xmlTextWriterPtr pWriter) const override; diff --git a/include/editeng/postitem.hxx b/include/editeng/postitem.hxx index 93ed44b6b794..392a9627feb6 100644 --- a/include/editeng/postitem.hxx +++ b/include/editeng/postitem.hxx @@ -32,6 +32,9 @@ class EDITENG_DLLPUBLIC SvxPostureItem final : public SfxEnumItem<FontItalic> { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/protitem.hxx b/include/editeng/protitem.hxx index 18ad76fcf3ac..0c3b473700d1 100644 --- a/include/editeng/protitem.hxx +++ b/include/editeng/protitem.hxx @@ -43,8 +43,6 @@ public: SvxProtectItem(SvxProtectItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool GetPresentation( SfxItemPresentation ePres, @@ -58,9 +56,9 @@ public: bool IsContentProtected() const { return bCntnt; } bool IsSizeProtected() const { return bSize; } bool IsPosProtected() const { return bPos; } - void SetContentProtect( bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bCntnt = bNew; } - void SetSizeProtect ( bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bSize = bNew; } - void SetPosProtect ( bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bPos = bNew; } + void SetContentProtect( bool bNew ) { bCntnt = bNew; } + void SetSizeProtect ( bool bNew ) { bSize = bNew; } + void SetPosProtect ( bool bNew ) { bPos = bNew; } virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; diff --git a/include/editeng/rsiditem.hxx b/include/editeng/rsiditem.hxx index 5c91006dcb9b..9e9cf18767ee 100644 --- a/include/editeng/rsiditem.hxx +++ b/include/editeng/rsiditem.hxx @@ -33,6 +33,8 @@ public: void dumpAsXml(xmlTextWriterPtr pWriter) const override; +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; }; #endif // INCLUDED_EDITENG_RSIDITEM_HXX diff --git a/include/editeng/shaditem.hxx b/include/editeng/shaditem.hxx index 9d15e5ea56e5..bed848215985 100644 --- a/include/editeng/shaditem.hxx +++ b/include/editeng/shaditem.hxx @@ -48,8 +48,6 @@ public: const SvxShadowLocation eLoc = SvxShadowLocation::NONE ); // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; @@ -64,13 +62,13 @@ public: virtual bool HasMetrics() const override; const Color& GetColor() const { return aShadowColor;} - void SetColor( const Color &rNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; aShadowColor = rNew; } + void SetColor( const Color &rNew ) { aShadowColor = rNew; } sal_uInt16 GetWidth() const { return nWidth; } SvxShadowLocation GetLocation() const { return eLocation; } - void SetWidth( sal_uInt16 nNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nWidth = nNew; } - void SetLocation( SvxShadowLocation eNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; eLocation = eNew; } + void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; } + void SetLocation( SvxShadowLocation eNew ) { eLocation = eNew; } // Calculate width of the shadow on the page. sal_uInt16 CalcShadowSpace( SvxShadowItemSide nShadow ) const; diff --git a/include/editeng/sizeitem.hxx b/include/editeng/sizeitem.hxx index 7e10873496f3..172099985fac 100644 --- a/include/editeng/sizeitem.hxx +++ b/include/editeng/sizeitem.hxx @@ -42,8 +42,6 @@ public: SvxSizeItem( const sal_uInt16 nId, const Size& rSize, SfxItemType eItemType = SfxItemType::SvxSizeItemType); // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; diff --git a/include/editeng/udlnitem.hxx b/include/editeng/udlnitem.hxx index 47c8fea73ca7..ec0f35d54ae6 100644 --- a/include/editeng/udlnitem.hxx +++ b/include/editeng/udlnitem.hxx @@ -88,6 +88,9 @@ public: class EDITENG_DLLPUBLIC SvxUnderlineItem final : public SvxTextLineItem { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); @@ -104,6 +107,9 @@ public: class EDITENG_DLLPUBLIC SvxOverlineItem final : public SvxTextLineItem { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/ulspitem.hxx b/include/editeng/ulspitem.hxx index 5c26ce2eb6a8..b0131ab9904d 100644 --- a/include/editeng/ulspitem.hxx +++ b/include/editeng/ulspitem.hxx @@ -46,8 +46,6 @@ public: const sal_uInt16 nId ); // "pure virtual Methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; @@ -65,11 +63,11 @@ public: inline void SetUpper( const sal_uInt16 nU, const sal_uInt16 nProp = 100 ); inline void SetLower( const sal_uInt16 nL, const sal_uInt16 nProp = 100 ); - void SetUpperValue( const sal_uInt16 nU ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nUpper = nU; } - void SetLowerValue( const sal_uInt16 nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nLower = nL; } - void SetContextValue( const bool bC ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bContext = bC; } - void SetPropUpper( const sal_uInt16 nU ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropUpper = nU; } - void SetPropLower( const sal_uInt16 nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropLower = nL; } + void SetUpperValue( const sal_uInt16 nU ) { nUpper = nU; } + void SetLowerValue( const sal_uInt16 nL ) { nLower = nL; } + void SetContextValue( const bool bC ) { bContext = bC; } + void SetPropUpper( const sal_uInt16 nU ) { nPropUpper = nU; } + void SetPropLower( const sal_uInt16 nL ) { nPropLower = nL; } sal_uInt16 GetUpper() const { return nUpper; } sal_uInt16 GetLower() const { return nLower; } diff --git a/include/editeng/wghtitem.hxx b/include/editeng/wghtitem.hxx index 121cfcf318a6..f8beb7c7a62f 100644 --- a/include/editeng/wghtitem.hxx +++ b/include/editeng/wghtitem.hxx @@ -32,6 +32,9 @@ class EDITENG_DLLPUBLIC SvxWeightItem final : public SfxEnumItem<FontWeight> { +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); diff --git a/include/svl/cintitem.hxx b/include/svl/cintitem.hxx index c10be9ccb8f9..d9c0f273f260 100644 --- a/include/svl/cintitem.hxx +++ b/include/svl/cintitem.hxx @@ -33,8 +33,6 @@ public: CntByteItem(sal_uInt16 which, sal_uInt8 nTheValue, SfxItemType eItemType = SfxItemType::CntByteItemType): SfxPoolItem(which, eItemType), m_nValue(nTheValue) {} - virtual bool isHashable() const override final { return true; } - virtual size_t hashCode() const override final { return m_nValue; } virtual bool operator ==(const SfxPoolItem & rItem) const override; virtual bool GetPresentation(SfxItemPresentation, @@ -66,8 +64,6 @@ public: SfxPoolItem(which, eItemType), m_nValue(nTheValue) {} - virtual bool isHashable() const override final { return true; } - virtual size_t hashCode() const override final { return m_nValue; } virtual bool operator ==(const SfxPoolItem & rItem) const override; virtual bool GetPresentation(SfxItemPresentation, @@ -100,8 +96,6 @@ public: SfxPoolItem(which, eItemType), m_nValue(nTheValue) {} - virtual bool isHashable() const override final { return true; } - virtual size_t hashCode() const override final { return m_nValue; } virtual bool operator ==(const SfxPoolItem & rItem) const override; virtual bool GetPresentation(SfxItemPresentation, @@ -134,8 +128,6 @@ public: SfxPoolItem(which, eItemType), m_nValue(nTheValue) {} - virtual bool isHashable() const override final { return true; } - virtual size_t hashCode() const override final { return m_nValue; } virtual bool operator ==(const SfxPoolItem & rItem) const override; virtual bool GetPresentation(SfxItemPresentation, diff --git a/include/svl/custritm.hxx b/include/svl/custritm.hxx index 309c0ebfe48a..118fd0963f15 100644 --- a/include/svl/custritm.hxx +++ b/include/svl/custritm.hxx @@ -39,8 +39,6 @@ public: SfxPoolItem(which, eItemType), m_aValue(std::move(aTheValue)) {} - // not all of the subclasses of this are hashable, so we only define the shared hashCode function here - virtual size_t hashCode() const override; virtual bool operator ==(const SfxPoolItem & rItem) const override; virtual bool GetPresentation(SfxItemPresentation, diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx index 141e292ceaad..f6fb22bfeb7d 100644 --- a/include/svl/eitem.hxx +++ b/include/svl/eitem.hxx @@ -62,16 +62,6 @@ public: return SfxEnumItemInterface::operator==(other) && m_nValue == static_cast<const SfxEnumItem<EnumT> &>(other).m_nValue; } - - virtual bool isHashable() const override final - { - return true; - } - - virtual size_t hashCode() const override final - { - return GetEnumValue(); - } }; class SVL_DLLPUBLIC SfxBoolItem @@ -79,6 +69,9 @@ class SVL_DLLPUBLIC SfxBoolItem { bool m_bValue; +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; + public: static SfxPoolItem* CreateDefault(); @@ -88,9 +81,6 @@ public: , m_bValue(bValue) { } - virtual bool isHashable() const override; - virtual size_t hashCode() const override; - bool GetValue() const { return m_bValue; } void SetValue(bool const bTheValue); diff --git a/include/svl/flagitem.hxx b/include/svl/flagitem.hxx index f9967af78b9c..ac32bab18ca9 100644 --- a/include/svl/flagitem.hxx +++ b/include/svl/flagitem.hxx @@ -36,8 +36,6 @@ public: virtual sal_uInt8 GetFlagCount() const; - virtual bool isHashable() const override { return true; } - virtual size_t hashCode() const override final { return nVal; } virtual bool operator==( const SfxPoolItem& ) const override; virtual SfxFlagItem* Clone( SfxItemPool *pPool = nullptr ) const override; diff --git a/include/svl/globalnameitem.hxx b/include/svl/globalnameitem.hxx index 36824d3a39e4..edbb56273232 100644 --- a/include/svl/globalnameitem.hxx +++ b/include/svl/globalnameitem.hxx @@ -39,8 +39,6 @@ public: SfxGlobalNameItem & operator =(SfxGlobalNameItem const &) = delete; // due to SfxPoolItem SfxGlobalNameItem & operator =(SfxGlobalNameItem &&) = delete; // due to SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual SfxGlobalNameItem* Clone( SfxItemPool *pPool = nullptr ) const override; const SvGlobalName& GetValue() const { return m_aName; } diff --git a/include/svl/grabbagitem.hxx b/include/svl/grabbagitem.hxx index d14bde539620..77a619aec4c1 100644 --- a/include/svl/grabbagitem.hxx +++ b/include/svl/grabbagitem.hxx @@ -33,14 +33,8 @@ public: const std::map<OUString, css::uno::Any>& GetGrabBag() const { return m_aMap; } - std::map<OUString, css::uno::Any>& GetGrabBag() - { - ASSERT_CHANGE_REFCOUNTED_ITEM; - return m_aMap; - } - - virtual bool isHashable() const override; - virtual size_t hashCode() const override; + std::map<OUString, css::uno::Any>& GetGrabBag() { return m_aMap; } + bool operator==(const SfxPoolItem& rItem) const override; SfxGrabBagItem* Clone(SfxItemPool* pPool = nullptr) const override; diff --git a/include/svl/ilstitem.hxx b/include/svl/ilstitem.hxx index 53f2a6204b64..bb49d18c9dbb 100644 --- a/include/svl/ilstitem.hxx +++ b/include/svl/ilstitem.hxx @@ -44,8 +44,6 @@ public: const std::vector< sal_Int32 >& GetList() const { return m_aList; } - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual SfxIntegerListItem* Clone( SfxItemPool *pPool = nullptr ) const override; virtual bool PutValue ( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; diff --git a/include/svl/imageitm.hxx b/include/svl/imageitm.hxx index d5c871ed8c4c..f06eb7fd6902 100644 --- a/include/svl/imageitm.hxx +++ b/include/svl/imageitm.hxx @@ -34,15 +34,13 @@ public: virtual ~SfxImageItem() override; virtual SfxImageItem* Clone( SfxItemPool* pPool = nullptr ) const override; - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; - void SetRotation( Degree10 nValue ) { ASSERT_CHANGE_REFCOUNTED_ITEM; mnAngle = nValue; } + void SetRotation( Degree10 nValue ) { mnAngle = nValue; } Degree10 GetRotation() const { return mnAngle; } - void SetMirrored( bool bSet ) { ASSERT_CHANGE_REFCOUNTED_ITEM; mbMirrored = bSet; } + void SetMirrored( bool bSet ) { mbMirrored = bSet; } bool IsMirrored() const { return mbMirrored; } private: diff --git a/include/svl/int64item.hxx b/include/svl/int64item.hxx index 0dd33e0a735c..70a502c645a8 100644 --- a/include/svl/int64item.hxx +++ b/include/svl/int64item.hxx @@ -27,8 +27,6 @@ public: SfxInt64Item & operator =(SfxInt64Item const &) = delete; // due to SfxPoolItem; SfxInt64Item & operator =(SfxInt64Item &&) = delete; // due to SfxPoolItem - virtual bool isHashable() const override { return true; } - virtual size_t hashCode() const override { return mnValue; } virtual bool operator== ( const SfxPoolItem& rItem ) const override; virtual bool GetPresentation( diff --git a/include/svl/intitem.hxx b/include/svl/intitem.hxx index 82fa80f12d09..0d3adcf0a750 100644 --- a/include/svl/intitem.hxx +++ b/include/svl/intitem.hxx @@ -50,8 +50,6 @@ public: SfxPoolItem(which, eItemType), m_nValue(nTheValue) {} - virtual bool isHashable() const override { return true; } - virtual size_t hashCode() const override { return m_nValue; } virtual bool operator ==(const SfxPoolItem & rItem) const override; virtual bool GetPresentation(SfxItemPresentation, diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 8be865c4e9b0..c993039afa7b 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -523,6 +523,7 @@ SVL_DLLPUBLIC void listAllocatedSfxPoolItems(); class SfxItemPool; class SfxItemSet; typedef struct _xmlTextWriter* xmlTextWriterPtr; +class ItemInstanceManager; class SVL_DLLPUBLIC SfxPoolItem { @@ -579,6 +580,15 @@ protected: void setIsSetItem() { m_bIsSetItem = true; } void setNonShareable() { m_bShareable = false; } + // access ItemInstanceManager for this Item, default + // is nullptr. If you overload this it is expected that + // you return a ptr to a static, Item-local managed + // instance that exists the whole office lifetime. This + // usually means to have a static instance directly in the + // implementation of the overloaded function (just grep + // for examples) + virtual ItemInstanceManager* getItemInstanceManager() const; + public: inline void AddRef(sal_uInt32 n = 1) const { @@ -691,14 +701,100 @@ public: virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; virtual boost::property_tree::ptree dumpAsJSON() const; - // Only return true from isHashable() if hashCode is implemented. - virtual bool isHashable() const; - virtual size_t hashCode() const; - private: SfxPoolItem& operator=( const SfxPoolItem& ) = delete; }; +// basic Interface definition +class SVL_DLLPUBLIC ItemInstanceManager +{ + // allow *only* ItemSetTooling to access + friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem const*, bool); + friend void implCleanupItemEntry(SfxPoolItem const*); + + // Define for which class to register (usually typeid().hash_code()). + std::size_t m_aClassHash; + +public: + ItemInstanceManager(const std::size_t aClassHash) + : m_aClassHash(aClassHash) + { + } + virtual ~ItemInstanceManager() = default; + + std::size_t getClassHash() const { return m_aClassHash; } + +private: + // standard interface, accessed exclusively + // by implCreateItemEntry/implCleanupItemEntry + virtual const SfxPoolItem* find(const SfxPoolItem&) const = 0; + virtual void add(const SfxPoolItem&) = 0; + virtual void remove(const SfxPoolItem&) = 0; +}; + +// offering a default implementation that can be use for +// each SfxPoolItem (except when !isShareable()). It just +// uses an unordered_set holding ptrs to SfxPoolItems added +// and SfxPoolItem::operator== to linearly search for one. +// Thus this is not the fastest, but as fast as old 'poooled' +// stuff - better use an intelligent, pro-Item implementation +// that does e.g. hashing or whatever might be feasible for +// that specific Item (see other derivations) +class SVL_DLLPUBLIC DefaultItemInstanceManager : public ItemInstanceManager +{ + std::unordered_map<sal_uInt16, std::unordered_set<const SfxPoolItem*>> maRegistered; + +public: + DefaultItemInstanceManager(const std::size_t aClassHash) + : ItemInstanceManager(aClassHash) + { + } + +private: + virtual const SfxPoolItem* find(const SfxPoolItem&) const override; + virtual void add(const SfxPoolItem&) override; + virtual void remove(const SfxPoolItem&) override; +}; + +/** + Utility template to reduce boilerplate code when creating item instance managers + for specific PoolItem subclasses. +*/ +template<class T> +class TypeSpecificItemInstanceManager : public ItemInstanceManager +{ +public: + TypeSpecificItemInstanceManager() + : ItemInstanceManager(typeid(T).hash_code()) + { + } + + // standard interface, accessed exclusively + // by implCreateItemEntry/implCleanupItemEntry + virtual const SfxPoolItem* find(const SfxPoolItem& rItem) const override final + { + auto aHit(maRegistered.find(hashCode(rItem))); + if (aHit != maRegistered.end()) + return aHit->second; + return nullptr; + } + virtual void add(const SfxPoolItem& rItem) override final + { + maRegistered.insert({hashCode(rItem), &rItem}); + } + virtual void remove(const SfxPoolItem& rItem) override final + { + maRegistered.erase(hashCode(rItem)); + } + +protected: + virtual size_t hashCode(const SfxPoolItem&) const = 0; + +private: + std::unordered_map<size_t, const SfxPoolItem*> maRegistered; +}; + + inline bool IsStaticDefaultItem(const SfxPoolItem *pItem ) { return pItem && pItem->isStaticDefault(); diff --git a/include/svl/ptitem.hxx b/include/svl/ptitem.hxx index 66a47fd992e1..90db98bbc869 100644 --- a/include/svl/ptitem.hxx +++ b/include/svl/ptitem.hxx @@ -41,8 +41,6 @@ public: OUString &rText, const IntlWrapper& ) const override; - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual SfxPointItem* Clone( SfxItemPool *pPool = nullptr ) const override; diff --git a/include/svl/rectitem.hxx b/include/svl/rectitem.hxx index ff7dce5fb3aa..26c2acd37b65 100644 --- a/include/svl/rectitem.hxx +++ b/include/svl/rectitem.hxx @@ -40,8 +40,6 @@ public: OUString &rText, const IntlWrapper& ) const override; - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual SfxRectangleItem* Clone( SfxItemPool *pPool = nullptr ) const override; diff --git a/include/svl/rngitem.hxx b/include/svl/rngitem.hxx index bb606b7149af..8e41184749b1 100644 --- a/include/svl/rngitem.hxx +++ b/include/svl/rngitem.hxx @@ -34,8 +34,6 @@ private: sal_uInt16 nTo; public: SfxRangeItem( sal_uInt16 nWID, sal_uInt16 nFrom, sal_uInt16 nTo ); - virtual bool isHashable() const override { return true; } - virtual size_t hashCode() const override { return (static_cast<size_t>(nFrom) << 16) | nTo; } virtual bool operator==( const SfxPoolItem& ) const override; virtual bool GetPresentation( SfxItemPresentation ePres, MapUnit eCoreMetric, diff --git a/include/svl/visitem.hxx b/include/svl/visitem.hxx index 04d76365cda8..8a458bbf2f6c 100644 --- a/include/svl/visitem.hxx +++ b/include/svl/visitem.hxx @@ -36,8 +36,6 @@ public: m_nValue.bVisible = bVisible; } - virtual bool isHashable() const override { return true; } - virtual size_t hashCode() const override { return static_cast<size_t>(m_nValue.bVisible); } virtual bool operator ==(const SfxPoolItem & rItem) const override; virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, diff --git a/include/svx/algitem.hxx b/include/svx/algitem.hxx index 450a349f0e53..d0245403360d 100644 --- a/include/svx/algitem.hxx +++ b/include/svx/algitem.hxx @@ -77,8 +77,6 @@ public: MapUnit ePresMetric, OUString &rText, const IntlWrapper& ) const override; - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual SvxMarginItem* Clone( SfxItemPool *pPool = nullptr ) const override; diff --git a/include/svx/chrtitem.hxx b/include/svx/chrtitem.hxx index 9cff3a00a0e1..eb6d42fde640 100644 --- a/include/svx/chrtitem.hxx +++ b/include/svx/chrtitem.hxx @@ -142,8 +142,6 @@ public: MapUnit ePresMetric, OUString &rText, const IntlWrapper&) const override; - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator == (const SfxPoolItem&) const override; virtual SvxDoubleItem* Clone(SfxItemPool *pPool = nullptr) const override; diff --git a/include/svx/e3ditem.hxx b/include/svx/e3ditem.hxx index 61f3dddd85c7..bad0e95c89f5 100644 --- a/include/svx/e3ditem.hxx +++ b/include/svx/e3ditem.hxx @@ -34,8 +34,6 @@ public: SvxB3DVectorItem( const SvxB3DVectorItem& ); virtual ~SvxB3DVectorItem() override; - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual SvxB3DVectorItem* Clone( SfxItemPool *pPool = nullptr ) const override; diff --git a/include/svx/grfcrop.hxx b/include/svx/grfcrop.hxx index b7e9f8dbd400..354ee8b16c44 100644 --- a/include/svx/grfcrop.hxx +++ b/include/svx/grfcrop.hxx @@ -43,8 +43,6 @@ public: SvxGrfCrop & operator =(SvxGrfCrop &&) = delete; // due to SfxPoolItem // "pure virtual methods" from SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual bool GetPresentation( SfxItemPresentation ePres, MapUnit eCoreMetric, diff --git a/include/svx/postattr.hxx b/include/svx/postattr.hxx index 22ede7dffc92..af980a3e5b9e 100644 --- a/include/svx/postattr.hxx +++ b/include/svx/postattr.hxx @@ -39,8 +39,6 @@ public: OUString &rText, const IntlWrapper& ) const override; virtual SvxPostItAuthorItem* Clone( SfxItemPool *pPool = nullptr ) const override; - - virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem }; @@ -61,8 +59,6 @@ public: OUString &rText, const IntlWrapper& ) const override; virtual SvxPostItDateItem* Clone( SfxItemPool *pPool = nullptr ) const override; - - virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem }; /** The text of a note @@ -83,8 +79,6 @@ public: OUString &rText, const IntlWrapper& ) const override; virtual SvxPostItTextItem* Clone( SfxItemPool *pPool = nullptr ) const override; - - virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem }; @@ -99,8 +93,6 @@ public: SvxPostItIdItem( TypedWhichId<SvxPostItIdItem> nWhich ); virtual SvxPostItIdItem* Clone( SfxItemPool *pPool = nullptr ) const override; - - virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem }; #endif diff --git a/include/svx/sdasitm.hxx b/include/svx/sdasitm.hxx index 6ec62db34e00..7821bbd2e0a8 100644 --- a/include/svx/sdasitm.hxx +++ b/include/svx/sdasitm.hxx @@ -69,8 +69,6 @@ private: SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem const &) = delete; // due to SfxPoolItem SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem &&) = delete; // due to SfxPoolItem - virtual bool isHashable() const override; - virtual size_t hashCode() const override; SAL_DLLPRIVATE virtual bool operator==( const SfxPoolItem& ) const override; SAL_DLLPRIVATE virtual bool GetPresentation(SfxItemPresentation ePresentation, diff --git a/include/svx/svxgraphicitem.hxx b/include/svx/svxgraphicitem.hxx index 47f8d1b59354..6d78b0980baa 100644 --- a/include/svx/svxgraphicitem.hxx +++ b/include/svx/svxgraphicitem.hxx @@ -31,8 +31,6 @@ class SVX_DLLPUBLIC SvxGraphicItem final : public SfxPoolItem public: SvxGraphicItem( Graphic aGraphic); - virtual bool isHashable() const override; - virtual size_t hashCode() const override; virtual bool operator==( const SfxPoolItem& ) const override; virtual SvxGraphicItem* Clone( SfxItemPool *pPool = nullptr ) const override; |