diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-11-24 16:12:03 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-11-25 16:13:47 +0100 |
commit | 52b692d16bc9b373067f3748fabf31aeace6e201 (patch) | |
tree | 57c8bdc5f3be8a04803728a9ff70c59905c2e658 /include | |
parent | 2bb923d236cbd53ea2b10634537cb23fa545b0a2 (diff) |
tdf#158317 fix cleanup of SfxPoolItems in editeng
It is not possible to use implCreateItemEntry/implCleanupItemEntry,
that is tooling limited *by purpose* to svl/Item/ItemSet stuff.
But what I can do is to do that SfxPoolItemHolder I already
talked/thought about. It is a helper that can safely hold a
SfxPoolItem in cases where an SfxItemSet is too expensive.
Think about it as a SfxItemSet for a single item. That solves
the problem why DirectPutItemInPool/DirectRemoveItemFromPool
is used in general (each usage is a 'compromize').
Did that now, works well. Editengine is now free of
DirectPutItemInPool/DirectRemoveItemFromPool.
Replaced ::CursorMoved with checkAndDeleteEmptyAttribs since all
these got static with no longer need to DirectRemoveItemFromPool.
Corrected create/delete counters.
Change-Id: Ia6e53f48ac2e479b461546515e68697039b5b628
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159931
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/editeng/editeng.hxx | 1 | ||||
-rw-r--r-- | include/svl/itemset.hxx | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index b3bbcbd608ca..57e327444a49 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -166,7 +166,6 @@ private: EditEngine& operator=( const EditEngine& ) = delete; EDITENG_DLLPRIVATE bool PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pView, vcl::Window const * pFrameWin ); - EDITENG_DLLPRIVATE void CursorMoved(const ContentNode* pPrevNode); EDITENG_DLLPRIVATE void CheckIdleFormatter(); EDITENG_DLLPRIVATE bool IsIdleFormatterActive() const; EDITENG_DLLPRIVATE ParaPortion* FindParaPortion(ContentNode const * pNode); diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 998830c6542a..60f028aeac39 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -34,12 +34,30 @@ class SfxItemPool; #ifdef DBG_UTIL SVL_DLLPUBLIC size_t getAllocatedSfxItemSetCount(); SVL_DLLPUBLIC size_t getUsedSfxItemSetCount(); +SVL_DLLPUBLIC size_t getAllocatedSfxPoolItemHolderCount(); +SVL_DLLPUBLIC size_t getUsedSfxPoolItemHolderCount(); #endif // ItemSet/ItemPool helpers SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pSource, sal_uInt16 nWhich, bool bPassingOwnership); void implCleanupItemEntry(SfxItemPool& rPool, SfxPoolItem const* pSource); +class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxPoolItemHolder +{ + SfxItemPool* m_pPool; + const SfxPoolItem* m_pItem; +public: + SfxPoolItemHolder(SfxItemPool&, const SfxPoolItem* = nullptr); + SfxPoolItemHolder(const SfxPoolItemHolder&); + ~SfxPoolItemHolder(); + + const SfxPoolItemHolder& operator=(const SfxPoolItemHolder&); + bool operator==(const SfxPoolItemHolder &) const; + SfxItemPool& getPool() const { return *m_pPool; } + const SfxPoolItem* getItem() const { return m_pItem; } + sal_uInt16 Which() const { if(nullptr != m_pItem) return m_pItem->Which(); return 0; } +}; + class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet { friend class SfxItemIter; |