diff options
85 files changed, 200 insertions, 364 deletions
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 2b3e59dc3c31..8c2bf391953c 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -204,7 +204,7 @@ ChartItemPool::~ChartItemPool() ReleaseDefaults(true); } -SfxItemPool* ChartItemPool::Clone() const +rtl::Reference<SfxItemPool> ChartItemPool::Clone() const { return new ChartItemPool(*this); } @@ -214,25 +214,16 @@ MapUnit ChartItemPool::GetMetric(sal_uInt16 /* nWhich */) const return MapUnit::Map100thMM; } -namespace { -struct PoolDeleter -{ - void operator()(SfxItemPool* pPool) - { - SfxItemPool::Free(pPool); - } -}; -} -static std::unique_ptr<SfxItemPool, PoolDeleter> g_Pool1, g_Pool2, g_Pool3; +static rtl::Reference<SfxItemPool> g_Pool1, g_Pool2, g_Pool3; SfxItemPool& ChartItemPool::GetGlobalChartItemPool() { if (!g_Pool1) { // similar logic to SdrModel's pool, but with our chart pool tagged on the end - g_Pool1.reset(new SdrItemPool(nullptr)); - g_Pool2.reset(EditEngine::CreatePool()); - g_Pool3.reset(new ChartItemPool()); + g_Pool1 = new SdrItemPool(nullptr); + g_Pool2 = EditEngine::CreatePool(); + g_Pool3 = new ChartItemPool(); g_Pool1->SetSecondaryPool(g_Pool2.get()); g_Pool1->SetDefaultMetric(MapUnit::Map100thMM); diff --git a/chart2/source/view/main/ChartItemPool.hxx b/chart2/source/view/main/ChartItemPool.hxx index 43f461a6aade..2ac440183740 100644 --- a/chart2/source/view/main/ChartItemPool.hxx +++ b/chart2/source/view/main/ChartItemPool.hxx @@ -36,7 +36,7 @@ protected: virtual ~ChartItemPool() override; public: - virtual SfxItemPool* Clone() const override; + virtual rtl::Reference<SfxItemPool> Clone() const override; MapUnit GetMetric(sal_uInt16 nWhich) const override; /// get the pure chart item pool diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx index 01f9182835df..062f99e96cae 100644 --- a/dbaccess/source/ui/control/sqledit.cxx +++ b/dbaccess/source/ui/control/sqledit.cxx @@ -67,7 +67,6 @@ private: SQLEditView::SQLEditView() : m_aHighlighter(HighlighterLanguage::SQL) - , m_pItemPool(nullptr) , m_bInUpdate(false) , m_bDisableInternalUndo(false) { @@ -114,8 +113,8 @@ void SQLEditView::makeEditEngine() { assert(!m_pItemPool); m_pItemPool = EditEngine::CreatePool(); - SetItemPoolFont(m_pItemPool); - m_xEditEngine.reset(new EditEngine(m_pItemPool)); + SetItemPoolFont(m_pItemPool.get()); + m_xEditEngine.reset(new EditEngine(m_pItemPool.get())); } void SQLEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea) @@ -366,7 +365,7 @@ void SQLEditView::ConfigurationChanged(utl::ConfigurationBroadcaster*, Configura void SQLEditView::ImplSetFont() { // see SmEditWindow::DataChanged for a similar case - SetItemPoolFont(m_pItemPool); // change default font + SetItemPoolFont(m_pItemPool.get()); // change default font // re-create with the new font EditEngine& rEditEngine = *GetEditEngine(); OUString aTxt(rEditEngine.GetText()); diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index e37541bfd271..0c79cf0c9bae 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -262,7 +262,7 @@ void ODbAdminDialog::clearPassword() m_pImpl->clearPassword(); } -void ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection) +void ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection) { // just to be sure... _rpSet = nullptr; @@ -408,7 +408,7 @@ void ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemP _rpSet.reset(new SfxItemSet(*_rpPool)); } -void ODbAdminDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults) +void ODbAdminDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults) { // _first_ delete the set (referring the pool) _rpSet.reset(); @@ -418,7 +418,6 @@ void ODbAdminDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItem { _rpPool->ReleaseDefaults(true); // the "true" means delete the items, too - SfxItemPool::Free(_rpPool); _rpPool = nullptr; } diff --git a/dbaccess/source/ui/inc/dbadmin.hxx b/dbaccess/source/ui/inc/dbadmin.hxx index eef3aed0874e..fb948f940fb8 100644 --- a/dbaccess/source/ui/inc/dbadmin.hxx +++ b/dbaccess/source/ui/inc/dbadmin.hxx @@ -62,10 +62,10 @@ public: @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case the pool will not contain a typecollection default. */ - static void createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection); + static void createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection); /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method> */ - static void destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults); + static void destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults); /** selects the DataSource @param _rName diff --git a/dbaccess/source/ui/inc/sqledit.hxx b/dbaccess/source/ui/inc/sqledit.hxx index c434a4f06555..6f85ba825a71 100644 --- a/dbaccess/source/ui/inc/sqledit.hxx +++ b/dbaccess/source/ui/inc/sqledit.hxx @@ -41,7 +41,7 @@ namespace dbaui Timer m_aUpdateDataTimer; const SyntaxHighlighter m_aHighlighter; svtools::ColorConfig m_ColorConfig; - SfxItemPool* m_pItemPool; + rtl::Reference<SfxItemPool> m_pItemPool; rtl::Reference<ChangesListener> m_listener; osl::Mutex m_mutex; diff --git a/dbaccess/source/ui/inc/unoadmin.hxx b/dbaccess/source/ui/inc/unoadmin.hxx index b18e4eb276db..944dccf87ae6 100644 --- a/dbaccess/source/ui/inc/unoadmin.hxx +++ b/dbaccess/source/ui/inc/unoadmin.hxx @@ -37,7 +37,7 @@ class ODatabaseAdministrationDialog { protected: std::unique_ptr<SfxItemSet> m_pDatasourceItems; // item set for the dialog - SfxItemPool* m_pItemPool; // item pool for the item set for the dialog + rtl::Reference<SfxItemPool> m_pItemPool; // item pool for the item set for the dialog std::vector<SfxPoolItem*>* m_pItemPoolDefaults; // pool defaults std::unique_ptr<::dbaccess::ODsnTypeCollection> diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index f22c9198ca69..fe28821bed62 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -788,7 +788,7 @@ bool callColumnFormatDialog(weld::Widget* _pParent, new SvxNumberInfoItem(SID_ATTR_NUMBERFORMAT_INFO) }; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pPool(new SfxItemPool("GridBrowserProperties", SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, &pDefaults)); + rtl::Reference<SfxItemPool> pPool(new SfxItemPool("GridBrowserProperties", SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, &pDefaults)); pPool->SetDefaultMetric( MapUnit::MapTwip ); // ripped, don't understand why pPool->FreezeIdRanges(); // the same @@ -855,7 +855,7 @@ bool callColumnFormatDialog(weld::Widget* _pParent, } pFormatDescriptor.reset(); - pPool.reset(); + pPool.clear(); for (SfxPoolItem* pDefault : pDefaults) delete pDefault; diff --git a/dbaccess/source/ui/uno/unoadmin.cxx b/dbaccess/source/ui/uno/unoadmin.cxx index f53df65a9e99..3d863b92e8f9 100644 --- a/dbaccess/source/ui/uno/unoadmin.cxx +++ b/dbaccess/source/ui/uno/unoadmin.cxx @@ -32,7 +32,6 @@ namespace dbaui ODatabaseAdministrationDialog::ODatabaseAdministrationDialog(const Reference< XComponentContext >& _rxORB) :ODatabaseAdministrationDialogBase(_rxORB) - ,m_pItemPool(nullptr) ,m_pItemPoolDefaults(nullptr) { m_pCollection.reset( new ::dbaccess::ODsnTypeCollection(_rxORB) ); @@ -41,15 +40,10 @@ ODatabaseAdministrationDialog::ODatabaseAdministrationDialog(const Reference< XC ODatabaseAdministrationDialog::~ODatabaseAdministrationDialog() { - if (m_xDialog) - { - ::osl::MutexGuard aGuard(m_aMutex); - if (m_xDialog) - { - destroyDialog(); - ODbAdminDialog::destroyItemSet(m_pDatasourceItems, m_pItemPool, m_pItemPoolDefaults); - } - } + ::osl::MutexGuard aGuard(m_aMutex); + if (m_xDialog) + destroyDialog(); + ODbAdminDialog::destroyItemSet(m_pDatasourceItems, m_pItemPool, m_pItemPoolDefaults); } void ODatabaseAdministrationDialog::implInitialize(const Any& _rValue) diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 7017516445f6..133ea1ca9daa 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -720,7 +720,7 @@ private: mutable sal_Int32 nLastCache; std::vector<std::unique_ptr<ContentNode> > maContents; - SfxItemPool* pItemPool; + rtl::Reference<SfxItemPool> pItemPool; Link<LinkParamNone*,void> aModifyHdl; SvxFont aDefFont; //faster than ever from the pool!! @@ -729,7 +729,6 @@ private: TextRotation mnRotation; bool bIsFixedCellHeight:1; - bool bOwnerOfPool:1; bool bModified:1; bool bDisableAttributeExpanding:1; diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index 70e86b7119fa..dca5a0a8babf 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -122,10 +122,10 @@ public: CPPUNIT_TEST_SUITE_END(); private: - EditEngineItemPool* mpItemPool; + rtl::Reference<EditEngineItemPool> mpItemPool; }; -Test::Test() : mpItemPool(nullptr) {} +Test::Test() {} void Test::setUp() { @@ -138,7 +138,7 @@ void Test::setUp() void Test::tearDown() { - SfxItemPool::Free(mpItemPool); + mpItemPool.clear(); test::BootstrapFixture::tearDown(); } @@ -146,7 +146,7 @@ void Test::tearDown() void Test::testLineSpacing() { // Create EditEngine's instance - EditEngine aEditEngine(mpItemPool); + EditEngine aEditEngine(mpItemPool.get()); if(aEditEngine.GetRefDevice()->GetDPIY() != 96 || aEditEngine.GetRefDevice()->GetDPIScaleFactor() != 1.0) @@ -223,7 +223,7 @@ void Test::testLineSpacing() void Test::testConstruction() { - EditEngine aEngine(mpItemPool); + EditEngine aEngine(mpItemPool.get()); aEngine.SetText("I am Edit Engine."); } @@ -551,7 +551,7 @@ IMPL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, pInfo, void ) void Test::testHyperlinkCopyPaste() { // Create Outliner instance - Outliner aOutliner(mpItemPool, OutlinerMode + Outliner aOutliner(mpItemPool.get(), OutlinerMode ::TextObject); aOutliner.SetCalcFieldValueHdl( LINK( nullptr, Test, CalcFieldValueHdl ) ); @@ -675,7 +675,7 @@ void Test::testHyperlinkCopyPaste() void Test::testCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -707,7 +707,7 @@ void Test::testCopyPaste() void Test::testMultiParaSelCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -752,7 +752,7 @@ void Test::testMultiParaSelCopyPaste() void Test::testTabsCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -817,7 +817,7 @@ public: // https://bugzilla.novell.com/show_bug.cgi?id=467459 void Test::testHyperlinkSearch() { - UrlEditEngine aEngine(mpItemPool); + UrlEditEngine aEngine(mpItemPool.get()); EditDoc &rDoc = aEngine.GetEditDoc(); OUString aSampleText = "Please write email to . if you find a fish(not a dog)."; @@ -902,7 +902,7 @@ bool hasItalic(const editeng::Section& rSecAttr) void Test::testBoldItalicCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -1083,7 +1083,7 @@ bool hasUnderline(const editeng::Section& rSecAttr) void Test::testUnderlineCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -1176,7 +1176,7 @@ void Test::testUnderlineCopyPaste() void Test::testMultiParaCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -1218,7 +1218,7 @@ void Test::testMultiParaCopyPaste() void Test::testParaBoldItalicCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -1489,7 +1489,7 @@ void Test::testParaBoldItalicCopyPaste() void Test::testParaStartCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -1533,7 +1533,7 @@ void Test::testParaStartCopyPaste() void Test::testSectionAttributes() { - EditEngine aEngine(mpItemPool); + EditEngine aEngine(mpItemPool.get()); std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEngine.GetEmptyItemSet())); SvxWeightItem aBold(WEIGHT_BOLD, EE_CHAR_WEIGHT); @@ -1675,7 +1675,7 @@ void Test::testSectionAttributes() void Test::testLargeParaCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); // Get EditDoc for current EditEngine's instance EditDoc &rDoc = aEditEngine.GetEditDoc(); @@ -1747,7 +1747,7 @@ void Test::testLargeParaCopyPaste() void Test::testTransliterate() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool ); + EditEngine aEditEngine( mpItemPool.get() ); OUString sText("one (two) three"); aEditEngine.SetText(sText); 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 diff --git a/extensions/source/propctrlr/controlfontdialog.cxx b/extensions/source/propctrlr/controlfontdialog.cxx index 26afa43a20bf..436770e60316 100644 --- a/extensions/source/propctrlr/controlfontdialog.cxx +++ b/extensions/source/propctrlr/controlfontdialog.cxx @@ -36,7 +36,6 @@ namespace pcr OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext ) :OGenericUnoDialog( _rxContext ) - ,m_pItemPool(nullptr) ,m_pItemPoolDefaults(nullptr) { registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT, diff --git a/extensions/source/propctrlr/controlfontdialog.hxx b/extensions/source/propctrlr/controlfontdialog.hxx index 202adadc73fe..8dc52010273f 100644 --- a/extensions/source/propctrlr/controlfontdialog.hxx +++ b/extensions/source/propctrlr/controlfontdialog.hxx @@ -44,7 +44,7 @@ namespace pcr // </properties> std::unique_ptr<SfxItemSet> m_pFontItems; // item set for the dialog - SfxItemPool* m_pItemPool; // item pool for the item set for the dialog + rtl::Reference<SfxItemPool> m_pItemPool; // item pool for the item set for the dialog std::vector<SfxPoolItem*>* m_pItemPoolDefaults; // pool defaults diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx index af276592fc41..0e4b11be2896 100644 --- a/extensions/source/propctrlr/fontdialog.cxx +++ b/extensions/source/propctrlr/fontdialog.cxx @@ -464,7 +464,7 @@ namespace pcr } } - void ControlCharacterDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults) + void ControlCharacterDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults) { // just to be sure... _rpSet = nullptr; @@ -534,7 +534,7 @@ namespace pcr _rpSet.reset(new SfxItemSet(*_rpPool)); } - void ControlCharacterDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults) + void ControlCharacterDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults) { // from the pool, get and remember the font list (needs to be deleted) const SvxFontListItem& rFontListItem = static_cast<const SvxFontListItem&>(_rpPool->GetDefaultItem(CFID_FONTLIST)); @@ -546,7 +546,6 @@ namespace pcr // delete the pool _rpPool->ReleaseDefaults(true); // the "true" means delete the items, too - SfxItemPool::Free(_rpPool); _rpPool = nullptr; // reset the defaults ptr diff --git a/extensions/source/propctrlr/fontdialog.hxx b/extensions/source/propctrlr/fontdialog.hxx index d2688f5ad200..eaba29db0b9c 100644 --- a/extensions/source/propctrlr/fontdialog.hxx +++ b/extensions/source/propctrlr/fontdialog.hxx @@ -36,10 +36,10 @@ namespace pcr virtual ~ControlCharacterDialog() override; /// creates an item set to be used with this dialog - static void createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults); + static void createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults); /// destroys an item previously created with <method>createItemSet</method> - static void destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults); + static void destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults); /// fills the given item set with values obtained from the given property set static void translatePropertiesToItems( diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index ceac37326a0a..5631014ef211 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2840,7 +2840,7 @@ namespace pcr // create an item set for use with the dialog std::unique_ptr<SfxItemSet> pSet; - SfxItemPool* pPool = nullptr; + rtl::Reference<SfxItemPool> pPool; std::vector<SfxPoolItem*>* pDefaults = nullptr; ControlCharacterDialog::createItemSet(pSet, pPool, pDefaults); ControlCharacterDialog::translatePropertiesToItems(m_xComponent, pSet.get()); diff --git a/forms/source/richtext/richtextengine.cxx b/forms/source/richtext/richtextengine.cxx index 437c9abee25e..e6fd4848aa4f 100644 --- a/forms/source/richtext/richtextengine.cxx +++ b/forms/source/richtext/richtextengine.cxx @@ -44,10 +44,10 @@ namespace frm { SolarMutexGuard g; - SfxItemPool* pPool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pPool = EditEngine::CreatePool(); pPool->FreezeIdRanges(); - RichTextEngine* pReturn = new RichTextEngine( pPool ); + RichTextEngine* pReturn = new RichTextEngine( pPool.get() ); OutputDevice* pOutputDevice = pReturn->GetRefDevice(); const MapMode& aDeviceMapMode( pOutputDevice->GetMapMode() ); diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx index 9e33fb2118dd..cd2ce3463e18 100644 --- a/forms/source/richtext/richtextmodel.cxx +++ b/forms/source/richtext/richtextmodel.cxx @@ -209,12 +209,8 @@ namespace frm if (m_pEngine) { SolarMutexGuard g; - SfxItemPool* pPool = m_pEngine->getPool(); m_pEngine.reset(); - SfxItemPool::Free(pPool); } - - } 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; diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx index afa270e60664..773e4d24a034 100644 --- a/reportdesign/source/ui/misc/UITools.cxx +++ b/reportdesign/source/ui/misc/UITools.cxx @@ -727,7 +727,7 @@ bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxRep 0 }; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pPool(new SfxItemPool("ReportCharProperties", XATTR_FILL_FIRST,ITEMID_WEIGHT_COMPLEX, aItemInfos, &pDefaults)); + rtl::Reference<SfxItemPool> pPool(new SfxItemPool("ReportCharProperties", XATTR_FILL_FIRST,ITEMID_WEIGHT_COMPLEX, aItemInfos, &pDefaults)); // not needed for font height pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why pPool->FreezeIdRanges(); // the same bool bSuccess = false; @@ -755,7 +755,7 @@ bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxRep DBG_UNHANDLED_EXCEPTION("reportdesign"); } - pPool.reset(); + pPool.clear(); for (SfxPoolItem* pDefault : pDefaults) delete pDefault; diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 6b7f10c377af..de4be54c181e 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -2369,7 +2369,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ SID_ATTR_METRIC,SID_ATTR_METRIC, 0 }; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pPool( new SfxItemPool("ReportPageProperties", RPTUI_ID_LRSPACE, RPTUI_ID_METRIC, aItemInfos ) ); + rtl::Reference<SfxItemPool> pPool( new SfxItemPool("ReportPageProperties", RPTUI_ID_LRSPACE, RPTUI_ID_METRIC, aItemInfos ) ); const Graphic aNullGraphic; const ::Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #i121448# Use defined default color @@ -2513,7 +2513,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ { DBG_UNHANDLED_EXCEPTION("reportdesign"); } - pPool.reset(); + pPool.clear(); for (SfxPoolItem* pDefault : pDefaults) delete pDefault; @@ -4218,7 +4218,7 @@ void OReportController::openZoomDialog() SID_ATTR_ZOOM,SID_ATTR_ZOOM, 0 }; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pPool( new SfxItemPool("ZoomProperties", SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, &pDefaults) ); + rtl::Reference<SfxItemPool> pPool( new SfxItemPool("ZoomProperties", SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, &pDefaults) ); pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why pPool->FreezeIdRanges(); // the same try @@ -4248,7 +4248,7 @@ void OReportController::openZoomDialog() { DBG_UNHANDLED_EXCEPTION("reportdesign"); } - pPool.reset(); + pPool.clear(); for (SfxPoolItem* pDefault : pDefaults) delete pDefault; diff --git a/sc/inc/docpool.hxx b/sc/inc/docpool.hxx index 3622aa38a68e..9280fb3602b0 100644 --- a/sc/inc/docpool.hxx +++ b/sc/inc/docpool.hxx @@ -37,7 +37,7 @@ private: virtual ~ScDocumentPool() override; public: - virtual SfxItemPool* Clone() const override; + virtual rtl::Reference<SfxItemPool> Clone() const override; virtual MapUnit GetMetric( sal_uInt16 nWhich ) const override; void StyleDeleted( const ScStyleSheet* pStyle ); // delete templates(?) in organizer diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx index 53664009b428..efec08dfdbc5 100644 --- a/sc/inc/editutil.hxx +++ b/sc/inc/editutil.hxx @@ -108,7 +108,7 @@ public: class ScEnginePoolHelper { protected: - SfxItemPool* pEnginePool; + rtl::Reference<SfxItemPool> pEnginePool; SfxItemSet* pDefaults; bool bDeleteEnginePool; bool bDeleteDefaults; diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 6847142a09a9..8f2a1b34ea8f 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -82,7 +82,7 @@ class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, Timer m_aIdleTimer; std::unique_ptr<ScDragData> m_pDragData; ScSelectionTransferObj* m_pSelTransfer; - std::unique_ptr<ScMessagePool, SfxItemPoolDeleter> m_pMessagePool; + rtl::Reference<ScMessagePool> m_pMessagePool; // there is no global InputHandler anymore, each View has its own ScInputHandler* m_pRefInputHandler; std::unique_ptr<ScViewCfg, o3tl::default_delete<ScViewCfg>> m_pViewCfg; diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx index 0466ac44f7d9..fc83491845bb 100644 --- a/sc/source/core/data/attrib.cxx +++ b/sc/source/core/data/attrib.cxx @@ -431,7 +431,7 @@ bool ScPageHFItem::PutValue( const uno::Any& rVal, sal_uInt8 /* nMemberId */ ) if ( !pLeftArea || !pCenterArea || !pRightArea ) { // no Text with Null are left - ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), true ); + ScEditEngineDefaulter aEngine( EditEngine::CreatePool().get(), true ); if (!pLeftArea) pLeftArea = aEngine.CreateTextObject(); if (!pCenterArea) diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx index 0a96c3b4ee5d..628c3686e2d0 100644 --- a/sc/source/core/data/docpool.cxx +++ b/sc/source/core/data/docpool.cxx @@ -376,7 +376,7 @@ void ScDocumentPool::CellStyleCreated( std::u16string_view rName, const ScDocume } } -SfxItemPool* ScDocumentPool::Clone() const +rtl::Reference<SfxItemPool> ScDocumentPool::Clone() const { return new SfxItemPool (*this, true); } diff --git a/sc/source/core/data/poolhelp.cxx b/sc/source/core/data/poolhelp.cxx index 2091bf167d9c..bd27a96c46cb 100644 --- a/sc/source/core/data/poolhelp.cxx +++ b/sc/source/core/data/poolhelp.cxx @@ -37,27 +37,29 @@ ScPoolHelper::ScPoolHelper( ScDocument& rSourceDoc ) ScPoolHelper::~ScPoolHelper() { - pEnginePool.reset(); - pEditPool.reset(); + pEnginePool.clear(); + pEditPool.clear(); pFormTable.reset(); mxStylePool.clear(); - pDocPool.reset(); + pDocPool.clear(); } -SfxItemPool* ScPoolHelper::GetEditPool() const + +SfxItemPool* ScPoolHelper::GetEditPool() const { if ( !pEditPool ) { - pEditPool.reset(EditEngine::CreatePool()); + pEditPool = EditEngine::CreatePool(); pEditPool->SetDefaultMetric( MapUnit::Map100thMM ); pEditPool->FreezeIdRanges(); } return pEditPool.get(); } -SfxItemPool* ScPoolHelper::GetEnginePool() const + +SfxItemPool* ScPoolHelper::GetEnginePool() const { if ( !pEnginePool ) { - pEnginePool.reset(EditEngine::CreatePool()); + pEnginePool = EditEngine::CreatePool(); pEnginePool->SetDefaultMetric( MapUnit::Map100thMM ); pEnginePool->FreezeIdRanges(); } // ifg ( pEnginePool ) diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index b4074c1773b5..8248218b14c3 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -218,7 +218,7 @@ void ScStyleSheetPool::CreateStandardStyles() SfxItemSet* pSet = nullptr; SfxItemSet* pHFSet = nullptr; SvxSetItem* pHFSetItem = nullptr; - std::unique_ptr<ScEditEngineDefaulter> pEdEngine(new ScEditEngineDefaulter( EditEngine::CreatePool(), true )); + std::unique_ptr<ScEditEngineDefaulter> pEdEngine(new ScEditEngineDefaulter( EditEngine::CreatePool().get(), true )); pEdEngine->SetUpdateMode( false ); std::unique_ptr<EditTextObject> pEmptyTxtObj = pEdEngine->CreateTextObject(); std::unique_ptr<EditTextObject> pTxtObj; diff --git a/sc/source/core/inc/poolhelp.hxx b/sc/source/core/inc/poolhelp.hxx index 267d60ea8eeb..ad725fcf82d8 100644 --- a/sc/source/core/inc/poolhelp.hxx +++ b/sc/source/core/inc/poolhelp.hxx @@ -36,11 +36,11 @@ class ScPoolHelper final : public salhelper::SimpleReferenceObject private: mutable osl::Mutex maMtxCreateNumFormatter; ScDocOptions aOpt; - std::unique_ptr<ScDocumentPool, SfxItemPoolDeleter> pDocPool; + rtl::Reference<ScDocumentPool> pDocPool; rtl::Reference< ScStyleSheetPool > mxStylePool; mutable std::unique_ptr<SvNumberFormatter> pFormTable; - mutable std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pEditPool; // EditTextObjectPool - mutable std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pEnginePool; // EditEnginePool + mutable rtl::Reference<SfxItemPool> pEditPool; // EditTextObjectPool + mutable rtl::Reference<SfxItemPool> pEnginePool; // EditEnginePool ScDocument& m_rSourceDoc; public: diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index c567e36b7b55..b47c2bd7ee39 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -510,8 +510,6 @@ ScEnginePoolHelper::~ScEnginePoolHelper() { if ( bDeleteDefaults ) delete pDefaults; - if ( bDeleteEnginePool ) - SfxItemPool::Free(pEnginePool); } ScEditEngineDefaulter::ScEditEngineDefaulter( SfxItemPool* pEnginePoolP, @@ -529,7 +527,7 @@ ScEditEngineDefaulter::ScEditEngineDefaulter( SfxItemPool* pEnginePoolP, ScEditEngineDefaulter::ScEditEngineDefaulter( const ScEditEngineDefaulter& rOrg ) : ScEnginePoolHelper( rOrg ), - EditEngine( pEnginePool ) + EditEngine( pEnginePool.get() ) { SetDefaultLanguage( ScGlobal::GetEditDefaultLanguage() ); } diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx index 7bc880988549..c232b6082b2f 100644 --- a/sc/source/filter/excel/xlroot.cxx +++ b/sc/source/filter/excel/xlroot.cxx @@ -372,7 +372,7 @@ ScHeaderEditEngine& XclRoot::GetHFEditEngine() const { if( !mrData.mxHFEditEngine ) { - mrData.mxHFEditEngine = std::make_shared<ScHeaderEditEngine>( EditEngine::CreatePool() ); + mrData.mxHFEditEngine = std::make_shared<ScHeaderEditEngine>( EditEngine::CreatePool().get() ); ScHeaderEditEngine& rEE = *mrData.mxHFEditEngine; rEE.SetRefMapMode(MapMode(MapUnit::MapTwip)); // headers/footers use twips as default metric rEE.SetUpdateMode( false ); diff --git a/sc/source/filter/inc/eeparser.hxx b/sc/source/filter/inc/eeparser.hxx index c691ca3abb9d..190caa4ec14e 100644 --- a/sc/source/filter/inc/eeparser.hxx +++ b/sc/source/filter/inc/eeparser.hxx @@ -100,8 +100,8 @@ class ScEEParser { protected: EditEngine* pEdit; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pPool; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pDocPool; + rtl::Reference<SfxItemPool> pPool; + rtl::Reference<SfxItemPool> pDocPool; std::vector<std::shared_ptr<ScEEParseEntry>> maList; std::shared_ptr<ScEEParseEntry> mxActEntry; ColWidthsMap maColWidths; diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 6511a806e295..b4aee6644918 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -637,8 +637,8 @@ ScEEParser::~ScEEParser() // Don't delete Pool until the lists have been deleted pPool->SetSecondaryPool( nullptr ); - pDocPool.reset(); - pPool.reset(); + pDocPool.clear(); + pPool.clear(); } void ScEEParser::NewActEntry( const ScEEParseEntry* pE ) diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx index 9b2ee6286b01..76782d1f6dae 100644 --- a/sc/source/filter/xml/xmlfonte.cxx +++ b/sc/source/filter/xml/xmlfonte.cxx @@ -36,7 +36,7 @@ class ScXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool { private: // #i120077# remember owned pool - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> mpEditEnginePool; + rtl::Reference<SfxItemPool> mpEditEnginePool; void AddFontItems(const sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const bool bExportDefaults); @@ -101,7 +101,7 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP, // #i120077# remember the SfxItemPool in member variable before usage. The // local EditEngine will not take over ownership of the pool. - mpEditEnginePool.reset(EditEngine::CreatePool()); + mpEditEnginePool = EditEngine::CreatePool(); EditEngine aEditEngine(mpEditEnginePool.get()); while (pStyle) diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx index 31f8586e1054..54f8f15f49fc 100644 --- a/sc/source/ui/Accessibility/AccessibleText.cxx +++ b/sc/source/ui/Accessibility/AccessibleText.cxx @@ -816,9 +816,9 @@ SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder() ResetEditMode(); if (!mpEditEngine) { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->FreezeIdRanges(); - mpEditEngine = new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true); + mpEditEngine = new ScFieldEditEngine(nullptr, pEnginePool.get(), nullptr, true); mbEditEngineCreated = true; mpEditEngine->EnableUndo( false ); mpEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM)); @@ -1020,9 +1020,9 @@ SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder() } else { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->FreezeIdRanges(); - pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) ); + pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool.get(), nullptr, true) ); } pEditEngine->EnableUndo( false ); if (pDocShell) @@ -1122,9 +1122,9 @@ SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder() { if (!mpEditEngine) { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->FreezeIdRanges(); - std::unique_ptr<ScHeaderEditEngine> pHdrEngine(new ScHeaderEditEngine( pEnginePool )); + std::unique_ptr<ScHeaderEditEngine> pHdrEngine(new ScHeaderEditEngine( pEnginePool.get() )); pHdrEngine->EnableUndo( false ); pHdrEngine->SetRefMapMode(MapMode(MapUnit::MapTwip)); @@ -1237,9 +1237,9 @@ SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder() } else { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->FreezeIdRanges(); - mpEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) ); + mpEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool.get(), nullptr, true) ); } mpEditEngine->EnableUndo( false ); if (mpDocSh) diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 69b6142d702f..ff6459f2ee7c 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -872,7 +872,7 @@ void ScInputHandler::ImplCreateEditEngine() mpEditEngine = std::make_unique<ScFieldEditEngine>(&rDoc, rDoc.GetEnginePool(), rDoc.GetEditPool()); } else - mpEditEngine = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool(), nullptr, true); + mpEditEngine = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool().get(), nullptr, true); mpEditEngine->SetWordDelimiters( ScEditUtil::ModifyDelimiters( mpEditEngine->GetWordDelimiters() ) ); UpdateRefDevice(); // also sets MapMode diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 670ccf6e9e06..a571d32fe0d7 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1485,7 +1485,7 @@ void ScTextWnd::InitEditEngine() pNew = std::make_unique<ScFieldEditEngine>(&rDoc, rDoc.GetEnginePool(), rDoc.GetEditPool()); } else - pNew = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool(), nullptr, true); + pNew = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool().get(), nullptr, true); pNew->SetExecuteURL( false ); m_xEditEngine = std::move(pNew); @@ -1988,7 +1988,7 @@ void ScTextWnd::MakeDialogEditView() pNew = std::make_unique<ScFieldEditEngine>(&rDoc, rDoc.GetEnginePool(), rDoc.GetEditPool()); } else - pNew = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool(), nullptr, true); + pNew = std::make_unique<ScFieldEditEngine>(nullptr, EditEngine::CreatePool().get(), nullptr, true); pNew->SetExecuteURL( false ); m_xEditEngine = std::move(pNew); diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 59ac6be2b17d..d8a25bd3a152 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -145,7 +145,7 @@ ScModule::ScModule( SfxObjectFactory* pFact ) : m_aIdleTimer.SetInvokeHandler( LINK( this, ScModule, IdleHandler ) ); m_aIdleTimer.Start(); - m_pMessagePool.reset(new ScMessagePool); + m_pMessagePool = new ScMessagePool; m_pMessagePool->FreezeIdRanges(); SetPool( m_pMessagePool.get() ); ScGlobal::InitTextHeight( m_pMessagePool.get() ); @@ -159,7 +159,7 @@ ScModule::~ScModule() // InputHandler does not need to be deleted (there's none in the App anymore) - m_pMessagePool.reset(); + m_pMessagePool.clear(); m_pDragData.reset(); m_pErrorHdl.reset(); diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index a732039c788f..1d05d38f1d3f 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -77,7 +77,7 @@ ScCsvGrid::ScCsvGrid(const ScCsvLayoutData& rData, std::unique_ptr<weld::Menu> x , mpGridDev( VclPtr<VirtualDevice>::Create() ) , mxPopup(std::move(xPopup)) , mpColorConfig( nullptr ) - , mpEditEngine( new ScEditEngineDefaulter( EditEngine::CreatePool(), true ) ) + , mpEditEngine( new ScEditEngineDefaulter( EditEngine::CreatePool().get(), true ) ) , maColStates( 1 ) , maTypeNames( 1 ) , mnFirstImpLine( 0 ) diff --git a/sc/source/ui/inc/msgpool.hxx b/sc/source/ui/inc/msgpool.hxx index b9a430d6ae4f..926fb38bf158 100644 --- a/sc/source/ui/inc/msgpool.hxx +++ b/sc/source/ui/inc/msgpool.hxx @@ -43,7 +43,7 @@ class ScMessagePool final : public SfxItemPool ScCondFormatDlgItem aCondFormatDlgItem; std::vector<SfxPoolItem*> mvPoolDefaults; - std::unique_ptr<ScDocumentPool, SfxItemPoolDeleter> pDocPool; + rtl::Reference<ScDocumentPool> pDocPool; public: ScMessagePool(); diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx index 932b635fe37a..403d6148454a 100644 --- a/sc/source/ui/pagedlg/tphfedit.cxx +++ b/sc/source/ui/pagedlg/tphfedit.cxx @@ -64,7 +64,7 @@ ScEditWindow::ScEditWindow(ScEditWindowLocation eLoc, weld::Window* pDialog) void ScEditWindow::makeEditEngine() { - m_xEditEngine.reset(new ScHeaderEditEngine(EditEngine::CreatePool())); + m_xEditEngine.reset(new ScHeaderEditEngine(EditEngine::CreatePool().get())); } ScHeaderEditEngine* ScEditWindow::GetEditEngine() const diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx index 6b3fa37447e6..231f080fa9da 100644 --- a/sc/source/ui/unoobj/editsrc.cxx +++ b/sc/source/ui/unoobj/editsrc.cxx @@ -141,9 +141,9 @@ SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder() } else { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->FreezeIdRanges(); - pEditEngine.reset( new ScEditEngineDefaulter( pEnginePool, true ) ); + pEditEngine.reset( new ScEditEngineDefaulter( pEnginePool.get(), true ) ); } pForwarder.reset( new SvxEditEngineForwarder(*pEditEngine) ); } diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx index d04a2647db76..27c46f7513c2 100644 --- a/sc/source/ui/unoobj/textuno.cxx +++ b/sc/source/ui/unoobj/textuno.cxx @@ -185,9 +185,9 @@ SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder() { if (!pEditEngine) { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->FreezeIdRanges(); - std::unique_ptr<ScHeaderEditEngine> pHdrEngine(new ScHeaderEditEngine( pEnginePool )); + std::unique_ptr<ScHeaderEditEngine> pHdrEngine(new ScHeaderEditEngine( pEnginePool.get() )); pHdrEngine->EnableUndo( false ); pHdrEngine->SetRefMapMode(MapMode(MapUnit::MapTwip)); @@ -330,7 +330,7 @@ OUString SAL_CALL ScHeaderFooterTextObj::getString() if (pData) { // for pure text, no font info is needed in pool defaults - ScHeaderEditEngine aEditEngine( EditEngine::CreatePool() ); + ScHeaderEditEngine aEditEngine( EditEngine::CreatePool().get() ); ScHeaderFieldData aData; FillDummyFieldData( aData ); @@ -347,7 +347,7 @@ void SAL_CALL ScHeaderFooterTextObj::setString( const OUString& aText ) SolarMutexGuard aGuard; // for pure text, no font info is needed in pool defaults - ScHeaderEditEngine aEditEngine(EditEngine::CreatePool()); + ScHeaderEditEngine aEditEngine(EditEngine::CreatePool().get()); aEditEngine.SetTextCurrentDefaults( aText ); aTextData.UpdateData(aEditEngine); } @@ -700,11 +700,11 @@ UNO3_GETIMPLEMENTATION2_IMPL(ScDrawTextCursor, SvxUnoTextCursor); ScSimpleEditSourceHelper::ScSimpleEditSourceHelper() { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->SetDefaultMetric( MapUnit::Map100thMM ); pEnginePool->FreezeIdRanges(); - pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) ); // TRUE: become owner of pool + pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool.get(), nullptr, true) ); // TRUE: become owner of pool pForwarder.reset( new SvxEditEngineForwarder( *pEditEngine ) ); pOriginalSource.reset( new ScSimpleEditSource( pForwarder.get() ) ); } @@ -788,9 +788,9 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder() } else { - SfxItemPool* pEnginePool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEnginePool = EditEngine::CreatePool(); pEnginePool->FreezeIdRanges(); - pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) ); + pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool.get(), nullptr, true) ); } // currently, GetPortions doesn't work if UpdateMode is sal_False, // this will be fixed (in EditEngine) by src600 diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index d12ccee4f779..bfee8d45eb15 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1662,7 +1662,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, else { // use EditEngine to draw mixed-script string - pEditEng.reset(new ScEditEngineDefaulter( EditEngine::CreatePool(), true )); + pEditEng.reset(new ScEditEngineDefaulter( EditEngine::CreatePool().get(), true )); pEditEng->SetRefMapMode(rRenderContext.GetMapMode()); auto pEditDefaults = std::make_unique<SfxItemSet>( pEditEng->GetEmptyItemSet() ); rDefPattern.FillEditItemSet( pEditDefaults.get() ); diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index e07511ccd907..b4b5e4d3ea80 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -505,7 +505,7 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) rDoc.GetPool()->GetDefaultItem(ATTR_PATTERN); std::unique_ptr<ScEditEngineDefaulter> pEditEng( - new ScEditEngineDefaulter(EditEngine::CreatePool(), true)); + new ScEditEngineDefaulter(EditEngine::CreatePool().get(), true)); pEditEng->SetRefMapMode(aMMMode); auto pEditDefaults = std::make_unique<SfxItemSet>( pEditEng->GetEmptyItemSet() ); diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 3828c031cc3c..128f726d1c76 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1701,7 +1701,7 @@ void ScPrintFunc::MakeEditEngine() { // can't use document's edit engine pool here, // because pool must have twips as default metric - pEditEngine.reset( new ScHeaderEditEngine( EditEngine::CreatePool() ) ); + pEditEngine.reset( new ScHeaderEditEngine( EditEngine::CreatePool().get() ) ); pEditEngine->EnableUndo(false); //fdo#45869 we want text to be positioned as it would be for the diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index a5892787be85..d1986d4309c1 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -99,8 +99,8 @@ namespace sd { SfxItemPool* GetAnnotationPool() { - static SfxItemPool* s_pAnnotationPool = nullptr; - if( s_pAnnotationPool == nullptr ) + static rtl::Reference<SfxItemPool> s_pAnnotationPool; + if( !s_pAnnotationPool ) { s_pAnnotationPool = EditEngine::CreatePool(); s_pAnnotationPool->SetPoolDefaultItem(SvxFontHeightItem(423,100,EE_CHAR_FONTHEIGHT)); @@ -109,7 +109,7 @@ SfxItemPool* GetAnnotationPool() s_pAnnotationPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(),aAppFont.GetFamilyName(),"",PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); } - return s_pAnnotationPool; + return s_pAnnotationPool.get(); } static SfxBindings* getBindings( ViewShellBase const & rBase ) diff --git a/sd/source/ui/presenter/PresenterTextView.cxx b/sd/source/ui/presenter/PresenterTextView.cxx index c55547c150d2..6f3b9f93b97e 100644 --- a/sd/source/ui/presenter/PresenterTextView.cxx +++ b/sd/source/ui/presenter/PresenterTextView.cxx @@ -79,7 +79,7 @@ private: cppcanvas::CanvasSharedPtr mpCanvas; VclPtr<VirtualDevice> mpOutputDevice; std::unique_ptr<EditEngine> mpEditEngine; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> mpEditEngineItemPool; + rtl::Reference<SfxItemPool> mpEditEngineItemPool; Size maSize; OUString msText; sal_Int32 mnTop; @@ -279,7 +279,7 @@ PresenterTextView::Implementation::Implementation() PresenterTextView::Implementation::~Implementation() { mpEditEngine.reset(); - mpEditEngineItemPool.reset(); + mpEditEngineItemPool.clear(); mpOutputDevice.disposeAndClear(); } diff --git a/starmath/CppunitTest_starmath_qa_cppunit.mk b/starmath/CppunitTest_starmath_qa_cppunit.mk index 6926c34ac0a7..07de25e48a08 100644 --- a/starmath/CppunitTest_starmath_qa_cppunit.mk +++ b/starmath/CppunitTest_starmath_qa_cppunit.mk @@ -32,6 +32,7 @@ $(eval $(call gb_CppunitTest_use_libraries,starmath_qa_cppunit,\ msfilter \ oox \ sal \ + salhelper \ sax \ sfx \ sot \ diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index 0c27c07bc2a4..d5d3657f2120 100644 --- a/starmath/Library_sm.mk +++ b/starmath/Library_sm.mk @@ -48,6 +48,7 @@ $(eval $(call gb_Library_use_libraries,sm,\ msfilter \ oox \ sal \ + salhelper \ sax \ sfx \ sot \ diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index cf52f4497e5b..2c3a9183bf87 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -81,7 +81,7 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener OUString maAccText; SvtLinguOptions maLinguOptions; std::unique_ptr<SmTableNode> mpTree; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> mpEditEngineItemPool; + rtl::Reference<SfxItemPool> mpEditEngineItemPool; std::unique_ptr<EditEngine> mpEditEngine; VclPtr<SfxPrinter> mpPrinter; //q.v. comment to SmPrinter Access! VclPtr<Printer> mpTmpPrinter; //ditto diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 5dd69cf62944..09078d11f94d 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -353,7 +353,7 @@ EditEngine& SmDocShell::GetEditEngine() //! see also SmEditWindow::DataChanged ! //! - mpEditEngineItemPool.reset( EditEngine::CreatePool() ); + mpEditEngineItemPool = EditEngine::CreatePool(); const StyleSettings& rStyleSettings = Application::GetDefaultDevice()->GetSettings().GetStyleSettings(); UpdateEditEngineDefaultFonts(rStyleSettings.GetFieldTextColor()); @@ -659,7 +659,7 @@ SmDocShell::~SmDocShell() mpCursor.reset(); mpEditEngine.reset(); - mpEditEngineItemPool.reset(); + mpEditEngineItemPool.clear(); mpPrinter.disposeAndClear(); } diff --git a/svl/CppunitTest_svl_itempool.mk b/svl/CppunitTest_svl_itempool.mk index 63745dd4312a..892107e906ca 100644 --- a/svl/CppunitTest_svl_itempool.mk +++ b/svl/CppunitTest_svl_itempool.mk @@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svl_itempool, \ svl \ comphelper \ sal \ + salhelper \ cppu \ cppuhelper \ )) diff --git a/svl/CppunitTest_svl_items.mk b/svl/CppunitTest_svl_items.mk index 28e8772d71ad..60bccd8a5852 100644 --- a/svl/CppunitTest_svl_items.mk +++ b/svl/CppunitTest_svl_items.mk @@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svl_items, \ svl \ comphelper \ sal \ + salhelper \ cppu \ cppuhelper \ )) diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk index 19b9d9f8b940..a4e41b6f9984 100644 --- a/svl/Library_svl.mk +++ b/svl/Library_svl.mk @@ -73,6 +73,7 @@ $(eval $(call gb_Library_use_libraries,svl,\ $(if $(ENABLE_JAVA), \ jvmfwk) \ sal \ + salhelper \ sot \ tl \ ucbhelper \ diff --git a/svl/qa/unit/items/stylepool.cxx b/svl/qa/unit/items/stylepool.cxx index c334360f5e3f..5fb94f29f9cd 100644 --- a/svl/qa/unit/items/stylepool.cxx +++ b/svl/qa/unit/items/stylepool.cxx @@ -28,7 +28,7 @@ CPPUNIT_TEST_FIXTURE(StylePoolTest, testIterationOrder) std::vector<SfxPoolItem*> aDefaults{ &aDefault1 }; SfxItemInfo const aItems[] = { { 1, false } }; - SfxItemPool* pPool = new SfxItemPool("test", 1, 1, aItems); + rtl::Reference<SfxItemPool> pPool = new SfxItemPool("test", 1, 1, aItems); pPool->SetDefaults(&aDefaults); { // Set up parents in mixed order to make sure we do not sort by pointer address. @@ -76,7 +76,6 @@ CPPUNIT_TEST_FIXTURE(StylePoolTest, testIterationOrder) CPPUNIT_ASSERT_EQUAL(OUString("Item3"), pItem3->GetValue()); CPPUNIT_ASSERT(!pIter->getNext()); } - SfxItemPool::Free(pPool); } } diff --git a/svl/qa/unit/items/test_itempool.cxx b/svl/qa/unit/items/test_itempool.cxx index fc19eec64752..4d15edaffd86 100644 --- a/svl/qa/unit/items/test_itempool.cxx +++ b/svl/qa/unit/items/test_itempool.cxx @@ -40,8 +40,8 @@ void PoolItemTest::testPool() { 4, false /* not poolable */} }; - SfxItemPool *pPool = new SfxItemPool("testpool", 1, 4, aItems); - SfxItemPool_Impl *pImpl = SfxItemPool_Impl::GetImpl(pPool); + rtl::Reference<SfxItemPool> pPool = new SfxItemPool("testpool", 1, 4, aItems); + SfxItemPool_Impl *pImpl = SfxItemPool_Impl::GetImpl(pPool.get()); CPPUNIT_ASSERT(pImpl != nullptr); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), pImpl->maPoolItemArrays.size()); @@ -91,7 +91,6 @@ void PoolItemTest::testPool() pPool->Put(aNotherFour); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pImpl->maPoolItemArrays[3].size()); - SfxItemPool::Free(pPool); } diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx index d5da51bc2d99..3ec1be562a01 100644 --- a/svl/source/inc/poolio.hxx +++ b/svl/source/inc/poolio.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SVL_SOURCE_INC_POOLIO_HXX #define INCLUDED_SVL_SOURCE_INC_POOLIO_HXX +#include <rtl/ref.hxx> #include <svl/itempool.hxx> #include <svl/SfxBroadcaster.hxx> #include <tools/debug.hxx> @@ -151,12 +152,11 @@ struct SfxItemPool_Impl { SfxBroadcaster aBC; std::vector<SfxPoolItemArray_Impl> maPoolItemArrays; - std::vector<SfxItemPoolUser*> maSfxItemPoolUsers; /// ObjectUser section OUString aName; std::vector<SfxPoolItem*> maPoolDefaults; std::vector<SfxPoolItem*>* mpStaticDefaults; SfxItemPool* mpMaster; - SfxItemPool* mpSecondary; + rtl::Reference<SfxItemPool> mpSecondary; std::unique_ptr<sal_uInt16[]> mpPoolRanges; sal_uInt16 mnStart; sal_uInt16 mnEnd; @@ -168,7 +168,6 @@ struct SfxItemPool_Impl , maPoolDefaults(nEnd - nStart + 1) , mpStaticDefaults(nullptr) , mpMaster(pMaster) - , mpSecondary(nullptr) , mnStart(nStart) , mnEnd(nEnd) , eDefMetric(MapUnit::MapCM) diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 24fda80d1bfe..20d0dcaca68e 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -73,7 +73,7 @@ lcl_CheckSlots2(std::map<sal_uInt16, sal_uInt16> & rSlotMap, #define CHECK_SLOTS() \ do { \ std::map<sal_uInt16, sal_uInt16> slotmap; \ - for (SfxItemPool * p = pImpl->mpMaster; p; p = p->pImpl->mpSecondary) \ + for (SfxItemPool * p = pImpl->mpMaster; p; p = p->pImpl->mpSecondary.get()) \ { \ lcl_CheckSlots2(slotmap, *p, p->pItemInfos); \ } \ @@ -84,24 +84,6 @@ do { \ #endif -void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser) -{ - // maintain sorted to reduce cost of remove - const auto insertIt = ::std::lower_bound( - pImpl->maSfxItemPoolUsers.begin(), pImpl->maSfxItemPoolUsers.end(), &rNewUser); - pImpl->maSfxItemPoolUsers.insert(insertIt, &rNewUser); -} - -void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser) -{ - const auto aFindResult = ::std::lower_bound( - pImpl->maSfxItemPoolUsers.begin(), pImpl->maSfxItemPoolUsers.end(), &rOldUser); - if(aFindResult != pImpl->maSfxItemPoolUsers.end() && *aFindResult == &rOldUser) - { - pImpl->maSfxItemPoolUsers.erase(aFindResult); - } -} - const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const { const SfxPoolItem* pRet; @@ -126,7 +108,7 @@ bool SfxItemPool::IsItemPoolable_Impl( sal_uInt16 nPos ) const bool SfxItemPool::IsItemPoolable( sal_uInt16 nWhich ) const { - for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImpl->mpSecondary ) + for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImpl->mpSecondary.get() ) { if ( pPool->IsInRange(nWhich) ) return pPool->IsItemPoolable_Impl( pPool->GetIndex_Impl(nWhich)); @@ -199,6 +181,7 @@ SfxItemPool::SfxItemPool false Take over static Defaults */ ) : + salhelper::SimpleReferenceObject(), pItemInfos(rPool.pItemInfos), pImpl( new SfxItemPool_Impl( this, rPool.pImpl->aName, rPool.pImpl->mnStart, rPool.pImpl->mnEnd ) ) { @@ -229,7 +212,7 @@ SfxItemPool::SfxItemPool // Repair linkage if ( rPool.pImpl->mpSecondary ) - SetSecondaryPool( rPool.pImpl->mpSecondary->Clone() ); + SetSecondaryPool( rPool.pImpl->mpSecondary->Clone().get() ); } void SfxItemPool::SetDefaults( std::vector<SfxPoolItem*>* pDefaults ) @@ -345,28 +328,6 @@ SfxItemPool::~SfxItemPool() } } -void SfxItemPool::Free(SfxItemPool* pPool) -{ - if(!pPool) - return; - - // tell all the registered SfxItemPoolUsers that the pool is in destruction - std::vector<SfxItemPoolUser*> aListCopy(pPool->pImpl->maSfxItemPoolUsers); - for(SfxItemPoolUser* pSfxItemPoolUser : aListCopy) - { - DBG_ASSERT(pSfxItemPoolUser, "corrupt SfxItemPoolUser list (!)"); - pSfxItemPoolUser->ObjectInDestruction(*pPool); - } - - // Clear the vector. This means that user do not need to call RemoveSfxItemPoolUser() - // when they get called from ObjectInDestruction(). - pPool->pImpl->maSfxItemPoolUsers.clear(); - - // delete pool - delete pPool; -} - - void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) { // Reset Master in attached Pools @@ -398,15 +359,15 @@ void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) } #endif - pImpl->mpSecondary->pImpl->mpMaster = pImpl->mpSecondary; - for ( SfxItemPool *p = pImpl->mpSecondary->pImpl->mpSecondary; p; p = p->pImpl->mpSecondary ) - p->pImpl->mpMaster = pImpl->mpSecondary; + pImpl->mpSecondary->pImpl->mpMaster = pImpl->mpSecondary.get(); + for ( SfxItemPool *p = pImpl->mpSecondary->pImpl->mpSecondary.get(); p; p = p->pImpl->mpSecondary.get() ) + p->pImpl->mpMaster = pImpl->mpSecondary.get(); } // Set Master of new Secondary Pools DBG_ASSERT( !pPool || pPool->pImpl->mpMaster == pPool, "Secondary is present in two Pools" ); SfxItemPool *pNewMaster = GetMasterPool() ? pImpl->mpMaster : this; - for ( SfxItemPool *p = pPool; p; p = p->pImpl->mpSecondary ) + for ( SfxItemPool *p = pPool; p; p = p->pImpl->mpSecondary.get() ) p->pImpl->mpMaster = pNewMaster; // Remember new Secondary Pool @@ -430,9 +391,15 @@ MapUnit SfxItemPool::GetMetric( sal_uInt16 ) const void SfxItemPool::SetDefaultMetric( MapUnit eNewMetric ) { +// assert((pImpl->eDefMetric == eNewMetric || !pImpl->mpPoolRanges) && "pool already frozen, cannot change metric"); pImpl->eDefMetric = eNewMetric; } +MapUnit SfxItemPool::GetDefaultMetric() const +{ + return pImpl->eDefMetric; +} + const OUString& SfxItemPool::GetName() const { return pImpl->aName; @@ -452,10 +419,9 @@ bool SfxItemPool::GetPresentation } -SfxItemPool* SfxItemPool::Clone() const +rtl::Reference<SfxItemPool> SfxItemPool::Clone() const { - SfxItemPool *pPool = new SfxItemPool( *this ); - return pPool; + return new SfxItemPool( *this ); } @@ -770,7 +736,7 @@ const SfxPoolItem& SfxItemPool::GetDefaultItem( sal_uInt16 nWhich ) const SfxItemPool* SfxItemPool::GetSecondaryPool() const { - return pImpl->mpSecondary; + return pImpl->mpSecondary.get(); } /* get the last pool by following the GetSecondaryPool chain */ @@ -796,6 +762,7 @@ SfxItemPool* SfxItemPool::GetMasterPool() const */ void SfxItemPool::FreezeIdRanges() { + assert(!pImpl->mpPoolRanges && "pool already frozen, cannot freeze twice"); FillItemIdRanges_Impl( pImpl->mpPoolRanges ); } @@ -806,13 +773,13 @@ void SfxItemPool::FillItemIdRanges_Impl( std::unique_ptr<sal_uInt16[]>& pWhichRa const SfxItemPool *pPool; sal_uInt16 nLevel = 0; - for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary ) + for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary.get() ) ++nLevel; pWhichRanges.reset(new sal_uInt16[ 2*nLevel + 1 ]); nLevel = 0; - for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary ) + for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary.get() ) { pWhichRanges[nLevel++] = pPool->pImpl->mnStart; pWhichRanges[nLevel++] = pPool->pImpl->mnEnd; diff --git a/svx/source/dialog/ClassificationEditView.cxx b/svx/source/dialog/ClassificationEditView.cxx index 4dd5c337ebb4..ba404982f685 100644 --- a/svx/source/dialog/ClassificationEditView.cxx +++ b/svx/source/dialog/ClassificationEditView.cxx @@ -40,7 +40,7 @@ ClassificationEditView::ClassificationEditView() void ClassificationEditView::makeEditEngine() { - m_xEditEngine.reset(new ClassificationEditEngine(EditEngine::CreatePool())); + m_xEditEngine.reset(new ClassificationEditEngine(EditEngine::CreatePool().get())); } ClassificationEditView::~ClassificationEditView() diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx index 4d979da20849..484980e70d7c 100644 --- a/svx/source/dialog/imapwnd.cxx +++ b/svx/source/dialog/imapwnd.cxx @@ -55,8 +55,8 @@ IMapWindow::IMapWindow(const Reference< XFrame >& rxDocumentFrame, weld::Dialog* : GraphCtrl(pDialog) , mxDocumentFrame(rxDocumentFrame) { - pIMapPool.reset(new SfxItemPool( "IMapItemPool", - SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, maItemInfos )); + pIMapPool = new SfxItemPool( "IMapItemPool", + SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, maItemInfos ); pIMapPool->FreezeIdRanges(); } diff --git a/svx/source/dialog/imapwnd.hxx b/svx/source/dialog/imapwnd.hxx index 27fe177a9aca..e7e3a1263da3 100644 --- a/svx/source/dialog/imapwnd.hxx +++ b/svx/source/dialog/imapwnd.hxx @@ -83,7 +83,7 @@ class IMapWindow final : public GraphCtrl ImageMap aIMap; TargetList aTargetList; Link<IMapWindow&,void> aInfoLink; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pIMapPool; + rtl::Reference<SfxItemPool> pIMapPool; SfxItemInfo maItemInfos[1] = {}; css::uno::Reference< css::frame::XFrame > mxDocumentFrame; diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx index cc6d0588109c..e89cfe4e71c9 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -105,7 +105,7 @@ WeldEditView::WeldEditView() // tdf#127033 want to use UI font so override makeEditEngine to enable that void WeldEditView::makeEditEngine() { - SfxItemPool* pItemPool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pItemPool = EditEngine::CreatePool(); vcl::Font aAppFont(Application::GetSettings().GetStyleSettings().GetAppFont()); @@ -126,7 +126,7 @@ void WeldEditView::makeEditEngine() pItemPool->SetPoolDefaultItem( SvxFontHeightItem(aAppFont.GetFontHeight() * 20, 100, EE_CHAR_FONTHEIGHT_CTL)); - m_xEditEngine.reset(new EditEngine(pItemPool)); + m_xEditEngine.reset(new EditEngine(pItemPool.get())); } void WeldEditView::Resize() diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index 5d4080928d1b..a17edcefaa88 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -621,7 +621,7 @@ namespace svx if ( !pFontList ) return; - std::unique_ptr<SfxItemPool, SfxItemPoolDeleter> pPool(EditEngine::CreatePool()); + rtl::Reference<SfxItemPool> pPool(EditEngine::CreatePool()); pPool->FreezeIdRanges(); std::unique_ptr< SfxItemSet > xPureItems( new SfxItemSet( *pPool ) ); @@ -722,7 +722,7 @@ namespace svx xDialog.reset(); xCurrentItems.reset(); xPureItems.reset(); - pPool.reset(); + pPool.clear(); } diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 8c777fa8af54..0d32ce6e0baf 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -365,7 +365,7 @@ SdrItemPool::SdrItemPool(const SdrItemPool& rPool) { } -SdrItemPool* SdrItemPool::Clone() const +rtl::Reference<SfxItemPool> SdrItemPool::Clone() const { return new SdrItemPool(*this); } diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index d60789ba3569..c8dc5f928534 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -111,7 +111,7 @@ SdrModel::SdrModel( m_nUIUnitDecimalMark=0; m_pLayerAdmin=nullptr; m_pItemPool=pPool; - m_bMyPool=false; + m_bIsWriter=true; m_pEmbeddedHelper=_pEmbeddedHelper; m_pDrawOutliner=nullptr; m_pHitTestOutliner=nullptr; @@ -154,11 +154,11 @@ SdrModel::SdrModel( { m_pItemPool=new SdrItemPool(nullptr); // Outliner doesn't have its own Pool, so use the EditEngine's - SfxItemPool* pOutlPool=EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pOutlPool=EditEngine::CreatePool(); // OutlinerPool as SecondaryPool of SdrPool - m_pItemPool->SetSecondaryPool(pOutlPool); + m_pItemPool->SetSecondaryPool(pOutlPool.get()); // remember that I created both pools myself - m_bMyPool=true; + m_bIsWriter=false; } m_pItemPool->SetDefaultMetric(m_eObjUnit); @@ -253,16 +253,6 @@ SdrModel::~SdrModel() mxStyleSheetPool.clear(); } - if (m_bMyPool) - { - // delete Pools if they're mine - SfxItemPool* pOutlPool=m_pItemPool->GetSecondaryPool(); - SfxItemPool::Free(m_pItemPool); - // OutlinerPool has to be deleted after deleting ItemPool, because - // ItemPool contains SetItems that themselves reference Items from OutlinerPool. - SfxItemPool::Free(pOutlPool); - } - mpForbiddenCharactersTable.reset(); delete mpImpl->mpUndoFactory; @@ -633,7 +623,7 @@ rtl::Reference<SdrPage> SdrModel::AllocPage(bool bMasterPage) void SdrModel::SetTextDefaults() const { - SetTextDefaults( m_pItemPool, mnDefTextHgt ); + SetTextDefaults( m_pItemPool.get(), mnDefTextHgt ); } void SdrModel::SetTextDefaults( SfxItemPool* pItemPool, sal_Int32 nDefTextHgt ) @@ -711,7 +701,7 @@ void SdrModel::ImpSetOutlinerDefaults( SdrOutliner* pOutliner, bool bInit ) { pOutliner->EraseVirtualDevice(); pOutliner->SetUpdateMode(false); - pOutliner->SetEditTextObjectPool(m_pItemPool); + pOutliner->SetEditTextObjectPool(m_pItemPool.get()); pOutliner->SetDefTab(m_nDefaultTabulator); } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index b0996d5d8405..9fc75da38f40 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -546,16 +546,17 @@ void SdrObject::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) } } -// init global static itempool -SdrItemPool* SdrObject::mpGlobalItemPool = nullptr; +// global static ItemPool for not-yet-inserted items +static SdrItemPool* mpGlobalItemPool; +// init global static itempool SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool() { if(!mpGlobalItemPool) { mpGlobalItemPool = new SdrItemPool(); - SfxItemPool* pGlobalOutlPool = EditEngine::CreatePool(); - mpGlobalItemPool->SetSecondaryPool(pGlobalOutlPool); + rtl::Reference<SfxItemPool> pGlobalOutlPool = EditEngine::CreatePool(); + mpGlobalItemPool->SetSecondaryPool(pGlobalOutlPool.get()); mpGlobalItemPool->SetDefaultMetric(SdrEngineDefaults::GetMapUnit()); mpGlobalItemPool->FreezeIdRanges(); } diff --git a/svx/source/unodraw/unopool.cxx b/svx/source/unodraw/unopool.cxx index 90addf6e0732..5931087349c3 100644 --- a/svx/source/unodraw/unopool.cxx +++ b/svx/source/unodraw/unopool.cxx @@ -54,19 +54,13 @@ SvxUnoDrawPool::SvxUnoDrawPool(SdrModel* pModel) SvxUnoDrawPool::~SvxUnoDrawPool() noexcept { - if (mpDefaultsPool) - { - SfxItemPool* pOutlPool = mpDefaultsPool->GetSecondaryPool(); - mpDefaultsPool.reset(); - SfxItemPool::Free(pOutlPool); - } } void SvxUnoDrawPool::init() { - mpDefaultsPool.reset(new SdrItemPool()); - SfxItemPool* pOutlPool=EditEngine::CreatePool(); - mpDefaultsPool->SetSecondaryPool(pOutlPool); + mpDefaultsPool = new SdrItemPool(); + rtl::Reference<SfxItemPool> pOutlPool = EditEngine::CreatePool(); + mpDefaultsPool->SetSecondaryPool(pOutlPool.get()); SdrModel::SetTextDefaults( mpDefaultsPool.get(), SdrEngineDefaults::GetFontHeight() ); mpDefaultsPool->SetDefaultMetric(SdrEngineDefaults::GetMapUnit()); diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx index be56e4fd7a14..bff5490aa565 100644 --- a/svx/source/xoutdev/xpool.cxx +++ b/svx/source/xoutdev/xpool.cxx @@ -203,7 +203,7 @@ XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool) { } -SfxItemPool* XOutdevItemPool::Clone() const +rtl::Reference<SfxItemPool> XOutdevItemPool::Clone() const { return new XOutdevItemPool(*this); } diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index ecfaa837a1cc..08510f634569 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -193,7 +193,7 @@ class SW_DLLPUBLIC SwDoc final // private Member std::unique_ptr<SwNodes> m_pNodes; //< document content (Nodes Array) - std::unique_ptr<SwAttrPool, SfxItemPoolDeleter> mpAttrPool; //< the attribute pool + rtl::Reference<SwAttrPool> mpAttrPool; //< the attribute pool SwPageDescs m_PageDescs; //< PageDescriptors Link<bool,void> maOle2Link; //< OLE 2.0-notification /* @@@MAINTAINABILITY-HORROR@@@ diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx index 6ba75632843a..987e75e61559 100644 --- a/sw/inc/swmodule.hxx +++ b/sw/inc/swmodule.hxx @@ -95,7 +95,7 @@ class SW_DLLPUBLIC SwModule final : public SfxModule, public SfxListener, public std::unique_ptr<SfxErrorHandler> m_pErrorHandler; - std::unique_ptr<SwAttrPool, SfxItemPoolDeleter> m_pAttrPool; + rtl::Reference<SwAttrPool> m_pAttrPool; // Current view is held here in order to avoid one's being forced // to work via GetActiveView. diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index f3b57d21a73c..1ec1d93323e1 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -51,7 +51,7 @@ SwAttrPool::SwAttrPool( SwDoc* pD ) // create SfxItemPool and EditEngine pool and add these in a chain. These // belong us and will be removed/destroyed in removeAndDeleteSecondaryPools() used from // the destructor - SfxItemPool *pSdrPool = new SdrItemPool(this); + rtl::Reference<SfxItemPool> pSdrPool = new SdrItemPool(this); // #75371# change DefaultItems for the SdrEdgeObj distance items // to TWIPS. @@ -69,9 +69,9 @@ SwAttrPool::SwAttrPool( SwDoc* pD ) pSdrPool->SetPoolDefaultItem(makeSdrShadowXDistItem(nDefShadowDist)); pSdrPool->SetPoolDefaultItem(makeSdrShadowYDistItem(nDefShadowDist)); - SfxItemPool *pEEgPool = EditEngine::CreatePool(); + rtl::Reference<SfxItemPool> pEEgPool = EditEngine::CreatePool(); - pSdrPool->SetSecondaryPool(pEEgPool); + pSdrPool->SetSecondaryPool(pEEgPool.get()); if(!GetFrozenIdRanges()) { @@ -87,17 +87,9 @@ SwAttrPool::~SwAttrPool() { // cleanup secondary pools SfxItemPool *pSdrPool = GetSecondaryPool(); - SfxItemPool *pEEgPool = pSdrPool->GetSecondaryPool(); - // first delete the items, then break the linking pSdrPool->Delete(); - SetSecondaryPool(nullptr); - pSdrPool->SetSecondaryPool(nullptr); - - // final cleanup of secondary pool(s) - SfxItemPool::Free(pSdrPool); - SfxItemPool::Free(pEEgPool); } SwAttrSet::SwAttrSet( SwAttrPool& rPool, sal_uInt16 nWh1, sal_uInt16 nWh2 ) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 35a59e111406..a674beb9fde6 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -597,7 +597,7 @@ SwDoc::~SwDoc() mpDfltCharFormat.reset(); mpDfltFrameFormat.reset(); mpLayoutCache.reset(); - mpAttrPool.reset(); + mpAttrPool.clear(); } void SwDoc::SetDocShell( SwDocShell* pDSh ) diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 6d15fcf2ff06..485bb7a52d41 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -331,14 +331,14 @@ void SwDLL::RegisterControls() void SwModule::InitAttrPool() { OSL_ENSURE(!m_pAttrPool, "Pool already exists!"); - m_pAttrPool.reset(new SwAttrPool(nullptr)); + m_pAttrPool = new SwAttrPool(nullptr); SetPool(m_pAttrPool.get()); } void SwModule::RemoveAttrPool() { SetPool(nullptr); - m_pAttrPool.reset(); + m_pAttrPool.clear(); } std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies() |