diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-07 22:06:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-08 17:36:54 +0200 |
commit | 1545949690c750d7b512000723b564e69cf3c3a6 (patch) | |
tree | 1463c8b2912a9e269fe8b7ef3f7326dc85173830 /editeng/source | |
parent | c10ce2698a3b001d22db3d33f2f43513cc49ebda (diff) |
ref-count SfxItemPool
so we can remove SfxItemPoolUser, which is a right
performance hog when we have large calc spreadsheets
Change-Id: I344002f536f6eead5cf98c6647dd1667fd9c8874
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115247
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 9 | ||||
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 52 | ||||
-rw-r--r-- | editeng/source/editeng/editobj2.hxx | 7 |
4 files changed, 7 insertions, 65 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 84ef4feae971..55415db284e6 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1887,7 +1887,6 @@ EditDoc::EditDoc( SfxItemPool* pPool ) : bIsVertical(false), mnRotation(TextRotation::NONE), bIsFixedCellHeight(false), - bOwnerOfPool(pPool == nullptr), bModified(false), bDisableAttributeExpanding(false) { @@ -1897,8 +1896,6 @@ EditDoc::EditDoc( SfxItemPool* pPool ) : EditDoc::~EditDoc() { ImplDestroyContents(); - if ( bOwnerOfPool ) - SfxItemPool::Free(pItemPool); } namespace { @@ -3011,6 +3008,7 @@ EditEngineItemPool::EditEngineItemPool() EditEngineItemPool::~EditEngineItemPool() { ClearDefaults(); + SetSecondaryPool(nullptr); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 55481862430e..208e502f6215 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -83,7 +83,7 @@ static bool bDebugPaint = false; #endif -static std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pGlobalPool; +static rtl::Reference<SfxItemPool> pGlobalPool; EditEngine::EditEngine( SfxItemPool* pItemPool ) { @@ -2589,16 +2589,15 @@ void EditEngine::FieldClicked( const SvxFieldItem& ) // ====================== Static Methods ======================= -SfxItemPool* EditEngine::CreatePool() +rtl::Reference<SfxItemPool> EditEngine::CreatePool() { - SfxItemPool* pPool = new EditEngineItemPool(); - return pPool; + return new EditEngineItemPool(); } SfxItemPool& EditEngine::GetGlobalItemPool() { if ( !pGlobalPool ) - pGlobalPool.reset(CreatePool()); + pGlobalPool = CreatePool(); return *pGlobalPool; } diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 0d202ac59203..e5c5cbdf4760 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -212,7 +212,6 @@ EditTextObject::EditTextObject( SfxItemPool* pPool ) : } EditTextObject::EditTextObject( const EditTextObject& r ) : - SfxItemPoolUser(), mpImpl(new EditTextObjectImpl(this, *r.mpImpl)) { } @@ -390,11 +389,6 @@ bool EditTextObject::isWrongListEqual(const EditTextObject& rCompare) const return mpImpl->isWrongListEqual(*rCompare.mpImpl); } -void EditTextObject::ObjectInDestruction(const SfxItemPool& rSfxItemPool) -{ - mpImpl->ObjectInDestruction(rSfxItemPool); -} - #if DEBUG_EDIT_ENGINE void EditTextObject::Dump() const { @@ -429,31 +423,6 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const } } -// from SfxItemPoolUser -void EditTextObjectImpl::ObjectInDestruction(const SfxItemPool& rSfxItemPool) -{ - if(bOwnerOfPool || pPool != &rSfxItemPool) - return; - - // The pool we are based on gets destructed; get owner of pool by creating own one. - // No need to call RemoveSfxItemPoolUser(), this is done from the pool's destructor - // Base new pool on EditEnginePool; it would also be possible to clone the used - // pool if needed, but only text attributes should be used. - SfxItemPool* pNewPool = EditEngine::CreatePool(); - - pNewPool->SetDefaultMetric(pPool->GetMetric(DEF_METRIC)); - - ContentInfosType aReplaced; - aReplaced.reserve(aContents.size()); - for (auto const& content : aContents) - aReplaced.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content, *pNewPool))); - aReplaced.swap(aContents); - - // set local variables - pPool = pNewPool; - bOwnerOfPool = true; -} - #if DEBUG_EDIT_ENGINE void EditTextObjectImpl::Dump() const { @@ -504,12 +473,6 @@ EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, SfxItemPool* pP pPool = EditEngine::CreatePool(); bOwnerOfPool = true; } - - if(!bOwnerOfPool && pPool) - { - // it is sure now that the pool is an EditEngineItemPool - pPool->AddSfxItemPoolUser(*mpFront); - } } EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, const EditTextObjectImpl& r ) @@ -537,12 +500,6 @@ EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, const EditTextOb } - if (!bOwnerOfPool) - { - // it is sure now that the pool is an EditEngineItemPool - pPool->AddSfxItemPoolUser(*mpFront); - } - if (bOwnerOfPool && r.pPool) pPool->SetDefaultMetric( r.pPool->GetMetric( DEF_METRIC ) ); @@ -553,20 +510,11 @@ EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, const EditTextOb EditTextObjectImpl::~EditTextObjectImpl() { - if(!bOwnerOfPool && pPool) - { - pPool->RemoveSfxItemPoolUser(*mpFront); - } - ClearPortionInfo(); // Remove contents before deleting the pool instance since each content // has to access the pool instance in its destructor. aContents.clear(); - if ( bOwnerOfPool ) - { - SfxItemPool::Free(pPool); - } } diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx index ba9603a7416d..3c7f171d2da5 100644 --- a/editeng/source/editeng/editobj2.hxx +++ b/editeng/source/editeng/editobj2.hxx @@ -173,7 +173,7 @@ private: EditTextObject* mpFront; ContentInfosType aContents; - SfxItemPool* pPool; + rtl::Reference<SfxItemPool> pPool; std::unique_ptr<XParaPortionList> pPortionInfo; sal_uInt16 nMetric; @@ -217,7 +217,7 @@ public: ContentInfosType& GetContents() { return aContents;} const ContentInfosType& GetContents() const { return aContents;} - SfxItemPool* GetPool() const { return pPool; } + SfxItemPool* GetPool() const { return pPool.get(); } XParaPortionList* GetPortionInfo() const { return pPortionInfo.get(); } void SetPortionInfo( std::unique_ptr<XParaPortionList> pP ) { pPortionInfo = std::move(pP); } @@ -263,9 +263,6 @@ public: // #i102062# bool isWrongListEqual(const EditTextObjectImpl& rCompare) const; - // from SfxItemPoolUser - void ObjectInDestruction(const SfxItemPool& rSfxItemPool); - #if DEBUG_EDIT_ENGINE void Dump() const; #endif |