diff options
-rw-r--r-- | include/editeng/sizeitem.hxx | 9 | ||||
-rw-r--r-- | sw/inc/fmtfsize.hxx | 21 | ||||
-rw-r--r-- | sw/inc/fmtornt.hxx | 23 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 75 |
4 files changed, 112 insertions, 16 deletions
diff --git a/include/editeng/sizeitem.hxx b/include/editeng/sizeitem.hxx index 2247c76d9e79..62ba4f1fba51 100644 --- a/include/editeng/sizeitem.hxx +++ b/include/editeng/sizeitem.hxx @@ -56,12 +56,15 @@ public: virtual bool HasMetrics() const override; const Size& GetSize() const { return m_aSize; } - void SetSize(const Size& rSize) { m_aSize = rSize; } + void SetSize(const Size& rSize) + { assert( !isPooled() && "SetValue() with pooled item" ); m_aSize = rSize; } tools::Long GetWidth() const { return m_aSize.getWidth(); } tools::Long GetHeight() const { return m_aSize.getHeight(); } - void SetWidth(tools::Long n) { m_aSize.setWidth(n); } - void SetHeight(tools::Long n) { m_aSize.setHeight(n); } + void SetWidth(tools::Long n) + { assert( !isPooled() && "SetValue() with pooled item" ); m_aSize.setWidth(n); } + void SetHeight(tools::Long n) + { assert( !isPooled() && "SetValue() with pooled item" ); m_aSize.setHeight(n); } }; #endif diff --git a/sw/inc/fmtfsize.hxx b/sw/inc/fmtfsize.hxx index 66aea1e78e50..7b70411f666d 100644 --- a/sw/inc/fmtfsize.hxx +++ b/sw/inc/fmtfsize.hxx @@ -87,10 +87,12 @@ public: virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; SwFrameSize GetHeightSizeType() const { return m_eFrameHeightType; } - void SetHeightSizeType( SwFrameSize eSize ) { m_eFrameHeightType = eSize; } + void SetHeightSizeType( SwFrameSize eSize ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_eFrameHeightType = eSize; } SwFrameSize GetWidthSizeType() const { return m_eFrameWidthType; } - void SetWidthSizeType( SwFrameSize eSize ) { m_eFrameWidthType = eSize; } + void SetWidthSizeType( SwFrameSize eSize ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_eFrameWidthType = eSize; } enum PercentFlags { SYNCED = 0xff }; //0xff is reserved to indicate height is synced to width @@ -99,12 +101,19 @@ public: //0xff is reserved to indicate width is synced to height sal_uInt8 GetWidthPercent() const { return m_nWidthPercent; } sal_Int16 GetWidthPercentRelation() const { return m_eWidthPercentRelation; } - void SetHeightPercent( sal_uInt8 n ) { m_nHeightPercent = n; } - void SetHeightPercentRelation ( sal_Int16 n ) { m_eHeightPercentRelation = n; } - void SetWidthPercent ( sal_uInt8 n ) { m_nWidthPercent = n; } - void SetWidthPercentRelation ( sal_Int16 n ) { m_eWidthPercentRelation = n; } + void SetHeightPercent( sal_uInt8 n ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_nHeightPercent = n; } + void SetHeightPercentRelation ( sal_Int16 n ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_eHeightPercentRelation = n; } + void SetWidthPercent ( sal_uInt8 n ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_nWidthPercent = n; } + void SetWidthPercentRelation ( sal_Int16 n ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_eWidthPercentRelation = n; } void dumpAsXml(xmlTextWriterPtr pWriter) const override; + +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; }; inline const SwFormatFrameSize &SwAttrSet::GetFrameSize(bool bInP) const diff --git a/sw/inc/fmtornt.hxx b/sw/inc/fmtornt.hxx index 0a993243cf7a..644576b6fc7f 100644 --- a/sw/inc/fmtornt.hxx +++ b/sw/inc/fmtornt.hxx @@ -56,13 +56,19 @@ public: sal_Int16 GetVertOrient() const { return m_eOrient; } sal_Int16 GetRelationOrient() const { return m_eRelation; } - void SetVertOrient( sal_Int16 eNew ) { m_eOrient = eNew; } - void SetRelationOrient( sal_Int16 eNew ) { m_eRelation = eNew; } + void SetVertOrient( sal_Int16 eNew ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_eOrient = eNew; } + void SetRelationOrient( sal_Int16 eNew ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_eRelation = eNew; } SwTwips GetPos() const { return m_nYPos; } - void SetPos( SwTwips nNew ) { m_nYPos = nNew; } + void SetPos( SwTwips nNew ) + { assert( !isPooled() && "SetValue() with pooled item" ); m_nYPos = nNew; } void dumpAsXml(xmlTextWriterPtr pWriter) const override; + +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; }; /// Defines the horizontal position of a fly frame. @@ -93,16 +99,19 @@ public: sal_Int16 GetHoriOrient() const { return m_eOrient; } sal_Int16 GetRelationOrient() const { return m_eRelation; } - void SetHoriOrient( sal_Int16 eNew ) { m_eOrient = eNew; } - void SetRelationOrient( sal_Int16 eNew ) { m_eRelation = eNew; } + void SetHoriOrient( sal_Int16 eNew ) { assert( !isPooled() && "SetValue() with pooled item" ); m_eOrient = eNew; } + void SetRelationOrient( sal_Int16 eNew ) { assert( !isPooled() && "SetValue() with pooled item" ); m_eRelation = eNew; } SwTwips GetPos() const { return m_nXPos; } - void SetPos( SwTwips nNew ) { m_nXPos = nNew; } + void SetPos( SwTwips nNew ) { assert( !isPooled() && "SetValue() with pooled item" ); m_nXPos = nNew; } bool IsPosToggle() const { return m_bPosToggle; } - void SetPosToggle( bool bNew ) { m_bPosToggle = bNew; } + void SetPosToggle( bool bNew ) { assert( !isPooled() && "SetValue() with pooled item" ); m_bPosToggle = bNew; } void dumpAsXml(xmlTextWriterPtr pWriter) const override; + +protected: + virtual ItemInstanceManager* getItemInstanceManager() const override; }; inline const SwFormatVertOrient &SwAttrSet::GetVertOrient(bool bInP) const diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index c3534b19534a..8c44f2ac893b 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -216,6 +216,34 @@ static void lcl_DelHFFormat( SwClient *pToRemove, SwFrameFormat *pFormat ) delete pFormat; } +namespace +{ + class SwFormatFrameSizeInstanceManager : public TypeSpecificItemInstanceManager<SwFormatFrameSize> + { + protected: + virtual size_t hashCode(const SfxPoolItem& rItem) const override + { + auto const & rFormatItem = static_cast<const SwFormatFrameSize&>(rItem); + std::size_t seed(0); + o3tl::hash_combine(seed, rFormatItem.GetHeightSizeType()); + o3tl::hash_combine(seed, rFormatItem.GetWidthSizeType()); + o3tl::hash_combine(seed, rFormatItem.GetWidthPercent()); + o3tl::hash_combine(seed, rFormatItem.GetWidthPercentRelation()); + o3tl::hash_combine(seed, rFormatItem.GetHeightPercent()); + o3tl::hash_combine(seed, rFormatItem.GetHeightPercentRelation()); + o3tl::hash_combine(seed, rFormatItem.GetSize().Width()); + o3tl::hash_combine(seed, rFormatItem.GetSize().Height()); + return seed; + } + }; +} + +ItemInstanceManager* SwFormatFrameSize::getItemInstanceManager() const +{ + static SwFormatFrameSizeInstanceManager aInstanceManager; + return &aInstanceManager; +} + void SwFormatFrameSize::ScaleMetrics(tools::Long lMult, tools::Long lDiv) { // Don't inherit the SvxSizeItem override (might or might not be relevant; added "just in case" // when changing SwFormatFrameSize to derive from SvxSizeItem instead of directly from @@ -1375,6 +1403,29 @@ void SwFormatSurround::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterEndElement(pWriter); } +namespace +{ + class SwFormatVertOrientInstanceManager : public TypeSpecificItemInstanceManager<SwFormatVertOrient> + { + protected: + virtual size_t hashCode(const SfxPoolItem& rItem) const override + { + auto const & rFormatItem = static_cast<const SwFormatVertOrient&>(rItem); + std::size_t seed(0); + o3tl::hash_combine(seed, rFormatItem.GetPos()); + o3tl::hash_combine(seed, rFormatItem.GetVertOrient()); + o3tl::hash_combine(seed, rFormatItem.GetRelationOrient()); + return seed; + } + }; +} + +ItemInstanceManager* SwFormatVertOrient::getItemInstanceManager() const +{ + static SwFormatVertOrientInstanceManager aInstanceManager; + return &aInstanceManager; +} + // Partially implemented inline in hxx SwFormatVertOrient::SwFormatVertOrient( SwTwips nY, sal_Int16 eVert, sal_Int16 eRel ) @@ -1467,6 +1518,30 @@ void SwFormatVertOrient::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterEndElement(pWriter); } +namespace +{ + class SwFormatHoriOrientInstanceManager : public TypeSpecificItemInstanceManager<SwFormatHoriOrient> + { + protected: + virtual size_t hashCode(const SfxPoolItem& rItem) const override + { + auto const & rFormatItem = static_cast<const SwFormatHoriOrient&>(rItem); + std::size_t seed(0); + o3tl::hash_combine(seed, rFormatItem.GetPos()); + o3tl::hash_combine(seed, rFormatItem.GetHoriOrient()); + o3tl::hash_combine(seed, rFormatItem.GetRelationOrient()); + o3tl::hash_combine(seed, rFormatItem.IsPosToggle()); + return seed; + } + }; +} + +ItemInstanceManager* SwFormatHoriOrient::getItemInstanceManager() const +{ + static SwFormatHoriOrientInstanceManager aInstanceManager; + return &aInstanceManager; +} + // Partially implemented inline in hxx SwFormatHoriOrient::SwFormatHoriOrient( SwTwips nX, sal_Int16 eHori, sal_Int16 eRel, bool bPos ) |