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 /include | |
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 'include')
-rw-r--r-- | include/editeng/editeng.hxx | 2 | ||||
-rw-r--r-- | include/editeng/editobj.hxx | 4 | ||||
-rw-r--r-- | include/svl/itempool.hxx | 35 | ||||
-rw-r--r-- | include/svx/svdmodel.hxx | 6 | ||||
-rw-r--r-- | include/svx/svdobj.hxx | 3 | ||||
-rw-r--r-- | include/svx/svdpool.hxx | 2 | ||||
-rw-r--r-- | include/svx/unopool.hxx | 2 | ||||
-rw-r--r-- | include/svx/xpool.hxx | 2 |
8 files changed, 14 insertions, 42 deletions
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index cfa574d56cfb..cc043ec2a897 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -517,7 +517,7 @@ public: virtual tools::Rectangle GetBulletArea( sal_Int32 nPara ); - static SfxItemPool* CreatePool(); + static rtl::Reference<SfxItemPool> CreatePool(); static SfxItemPool& GetGlobalItemPool(); static bool DoesKeyChangeText( const KeyEvent& rKeyEvent ); static bool DoesKeyMoveCursor( const KeyEvent& rKeyEvent ); diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx index ea68d92df507..818e3ea28a73 100644 --- a/include/editeng/editobj.hxx +++ b/include/editeng/editobj.hxx @@ -56,7 +56,7 @@ enum class TextRotation { NONE, TOPTOBOTTOM, BOTTOMTOTOP }; class EditTextObjectImpl; -class EDITENG_DLLPUBLIC EditTextObject final : public SfxItemPoolUser +class EDITENG_DLLPUBLIC EditTextObject final { friend class EditTextObjectImpl; friend class editeng::FieldUpdaterImpl; @@ -139,8 +139,6 @@ public: // #i102062# bool isWrongListEqual(const EditTextObject& rCompare) const; - virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool) override; - #if DEBUG_EDIT_ENGINE void Dump() const; #endif diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index baab6da1a3d7..0ff1c8d4b27a 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -19,12 +19,14 @@ #pragma once +#include <rtl/ref.hxx> #include <svl/poolitem.hxx> #include <svl/svldllapi.h> #include <svl/typedwhich.hxx> #include <memory> #include <vector> #include <o3tl/sorted_vector.hxx> +#include <salhelper/simplereferenceobject.hxx> class SfxBroadcaster; struct SfxItemPool_Impl; @@ -37,15 +39,6 @@ struct SfxItemInfo class SfxItemPool; -class SVL_DLLPUBLIC SfxItemPoolUser -{ -public: - virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool) = 0; - -protected: - ~SfxItemPoolUser() {} -}; - /** Base class for providers of defaults of SfxPoolItems. * * The derived classes hold the concrete (const) instances which are referenced in several places @@ -53,7 +46,7 @@ protected: * This helps to lower the amount of calls to lifecycle methods, speeds up comparisons within a document * and facilitates loading and saving of attributes. */ -class SVL_DLLPUBLIC SfxItemPool +class SVL_DLLPUBLIC SfxItemPool : public salhelper::SimpleReferenceObject { friend struct SfxItemPool_Impl; friend class SfxItemSet; @@ -62,10 +55,6 @@ class SVL_DLLPUBLIC SfxItemPool const SfxItemInfo* pItemInfos; std::unique_ptr<SfxItemPool_Impl> pImpl; -public: - void AddSfxItemPoolUser(SfxItemPoolUser& rNewUser); - void RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser); - private: sal_uInt16 GetIndex_Impl(sal_uInt16 nWhich) const; sal_uInt16 GetSize_Impl() const; @@ -90,11 +79,8 @@ public: const SfxItemInfo *pItemInfos, std::vector<SfxPoolItem*> *pDefaults = nullptr ); -protected: - virtual ~SfxItemPool(); - public: - static void Free(SfxItemPool* pPool); + virtual ~SfxItemPool(); SfxBroadcaster& BC(); @@ -113,6 +99,7 @@ public: virtual MapUnit GetMetric( sal_uInt16 nWhich ) const; void SetDefaultMetric( MapUnit eNewMetric ); + MapUnit GetDefaultMetric() const; /** Request string representation of pool items. @@ -144,7 +131,7 @@ public: MapUnit ePresentationMetric, OUString& rText, const IntlWrapper& rIntlWrapper ) const; - virtual SfxItemPool* Clone() const; + virtual rtl::Reference<SfxItemPool> Clone() const; const OUString& GetName() const; template<class T> const T& Put( std::unique_ptr<T> xItem, sal_uInt16 nWhich = 0 ) @@ -234,14 +221,4 @@ inline sal_uInt32 SfxItemPool::ReleaseRef(const SfxPoolItem& rItem, sal_uInt32 n return rItem.ReleaseRef(n); } -// Utility class for using SfxItemPool with std::unique_ptr -struct SfxItemPoolDeleter -{ - void operator()(SfxItemPool* pPool) - { - SfxItemPool::Free(pPool); - } -}; - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index f525614c6b49..2d29d7585922 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -175,7 +175,7 @@ protected: int m_nUIUnitDecimalMark; // see above std::unique_ptr<SdrLayerAdmin> m_pLayerAdmin; - SfxItemPool* m_pItemPool; + rtl::Reference<SfxItemPool> m_pItemPool; comphelper::IEmbeddedHelper* m_pEmbeddedHelper; // helper for embedded objects to get rid of the SfxObjectShell std::unique_ptr<SdrOutliner> m_pDrawOutliner; // an Outliner for outputting text @@ -191,7 +191,7 @@ protected: std::unique_ptr<std::deque<std::unique_ptr<SfxUndoAction>>> m_pRedoStack; std::unique_ptr<SdrUndoGroup> m_pCurrentUndoGroup; // For multi-level sal_uInt16 m_nUndoLevel; // undo nesting - bool m_bMyPool:1; // to clean up pMyPool from 303a + bool m_bIsWriter:1; // to clean up pMyPool from 303a bool mbUndoEnabled:1; // If false no undo is recorded or we are during the execution of an undo action bool mbChanged:1; bool m_bPagNumsDirty:1; @@ -568,7 +568,7 @@ public: std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode ); void disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner ); - bool IsWriter() const { return !m_bMyPool; } + bool IsWriter() const { return m_bIsWriter; } // Used as a fallback in *::ReadUserDataSequence() to process common properties void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue); diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index ec72c9d39a41..0960826d2c63 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -964,9 +964,6 @@ private: std::unique_ptr<sdr::contact::ViewContact> mpViewContact; - // global static ItemPool for not-yet-inserted items - static SdrItemPool* mpGlobalItemPool; - // do not use directly, always use getSvxShape() if you have to! SvxShape* mpSvxShape; css::uno::WeakReference< css::uno::XInterface > diff --git a/include/svx/svdpool.hxx b/include/svx/svdpool.hxx index 54847e568cc9..95eea37c59c5 100644 --- a/include/svx/svdpool.hxx +++ b/include/svx/svdpool.hxx @@ -36,7 +36,7 @@ private: virtual ~SdrItemPool() override; public: - virtual SdrItemPool* Clone() const override; + virtual rtl::Reference<SfxItemPool> Clone() const override; virtual bool GetPresentation(const SfxPoolItem& rItem, MapUnit ePresentationMetric, OUString& rText, diff --git a/include/svx/unopool.hxx b/include/svx/unopool.hxx index d7736c36f7c2..96b9bc17956d 100644 --- a/include/svx/unopool.hxx +++ b/include/svx/unopool.hxx @@ -90,7 +90,7 @@ protected: protected: SdrModel* mpModel; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> mpDefaultsPool; + rtl::Reference<SfxItemPool> mpDefaultsPool; }; #endif diff --git a/include/svx/xpool.hxx b/include/svx/xpool.hxx index 26b27e10f0cd..e8fc6f5e7225 100644 --- a/include/svx/xpool.hxx +++ b/include/svx/xpool.hxx @@ -39,7 +39,7 @@ public: XOutdevItemPool(SfxItemPool* pMaster); XOutdevItemPool(const XOutdevItemPool& rPool); - virtual SfxItemPool* Clone() const override; + virtual rtl::Reference<SfxItemPool> Clone() const override; protected: virtual ~XOutdevItemPool() override; |