diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-04 13:09:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-05 07:49:42 +0100 |
commit | c85f872b1cb8e733b556c03584080d06022f287d (patch) | |
tree | d6f6c764ea178963ed0405a94fd77c86a540b1ca /sw | |
parent | e4472d3c139294499f4c0caeebd9d4e995958eb0 (diff) |
use unique_ptr in SwModule
Change-Id: I6c17853cc84365cb86b3dd2525ab8f2ff7844369
Reviewed-on: https://gerrit.libreoffice.org/64516
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/swmodule.hxx | 38 | ||||
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 56 | ||||
-rw-r--r-- | sw/source/uibase/app/appopt.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/app/swmodul1.cxx | 30 | ||||
-rw-r--r-- | sw/source/uibase/app/swmodule.cxx | 27 |
5 files changed, 72 insertions, 83 deletions
diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx index e82375966927..eec00ab2f3e5 100644 --- a/sw/inc/swmodule.hxx +++ b/sw/inc/swmodule.hxx @@ -75,21 +75,21 @@ class SW_DLLPUBLIC SwModule final : public SfxModule, public SfxListener, public OUString m_sActAuthor; // ConfigItems - SwModuleOptions* m_pModuleConfig; - SwMasterUsrPref* m_pUsrPref; - SwMasterUsrPref* m_pWebUsrPref; - SwPrintOptions* m_pPrintOptions; - SwPrintOptions* m_pWebPrintOptions; - SwChapterNumRules* m_pChapterNumRules; - SwStdFontConfig* m_pStdFontConfig; - SwNavigationConfig* m_pNavigationConfig; - SwToolbarConfigItem*m_pToolbarConfig; //For stacked toolbars. Which one was visible? - SwToolbarConfigItem*m_pWebToolbarConfig; - SwDBConfig* m_pDBConfig; - svtools::ColorConfig* m_pColorConfig; - SvtAccessibilityOptions* m_pAccessibilityOptions; - SvtCTLOptions* m_pCTLOptions; - SvtUserOptions* m_pUserOptions; + std::unique_ptr<SwModuleOptions> m_pModuleConfig; + std::unique_ptr<SwMasterUsrPref> m_pUsrPref; + std::unique_ptr<SwMasterUsrPref> m_pWebUsrPref; + std::unique_ptr<SwPrintOptions> m_pPrintOptions; + std::unique_ptr<SwPrintOptions> m_pWebPrintOptions; + std::unique_ptr<SwChapterNumRules> m_pChapterNumRules; + std::unique_ptr<SwStdFontConfig> m_pStdFontConfig; + std::unique_ptr<SwNavigationConfig> m_pNavigationConfig; + std::unique_ptr<SwToolbarConfigItem> m_pToolbarConfig; //For stacked toolbars. Which one was visible? + std::unique_ptr<SwToolbarConfigItem> m_pWebToolbarConfig; + std::unique_ptr<SwDBConfig> m_pDBConfig; + std::unique_ptr<svtools::ColorConfig> m_pColorConfig; + std::unique_ptr<SvtAccessibilityOptions> m_pAccessibilityOptions; + std::unique_ptr<SvtCTLOptions> m_pCTLOptions; + std::unique_ptr<SvtUserOptions> m_pUserOptions; std::unique_ptr<SfxErrorHandler> m_pErrorHandler; @@ -165,13 +165,13 @@ public: void ApplyUserCharUnit(bool bApplyChar, bool bWeb); // apply_char_unit // Create ConfigItems. - SwModuleOptions* GetModuleConfig() { return m_pModuleConfig;} + SwModuleOptions* GetModuleConfig() { return m_pModuleConfig.get();} SwPrintOptions* GetPrtOptions(bool bWeb); SwChapterNumRules* GetChapterNumRules(); - SwStdFontConfig* GetStdFontConfig() { return m_pStdFontConfig; } + SwStdFontConfig* GetStdFontConfig() { return m_pStdFontConfig.get(); } SwNavigationConfig* GetNavigationConfig(); - SwToolbarConfigItem*GetToolbarConfig() { return m_pToolbarConfig; } - SwToolbarConfigItem*GetWebToolbarConfig() { return m_pWebToolbarConfig; } + SwToolbarConfigItem*GetToolbarConfig() { return m_pToolbarConfig.get(); } + SwToolbarConfigItem*GetWebToolbarConfig() { return m_pWebToolbarConfig.get(); } SwDBConfig* GetDBConfig(); svtools::ColorConfig& GetColorConfig(); SvtAccessibilityOptions& GetAccessibilityOptions(); diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index a0aead88a3ea..b041a53964de 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -868,36 +868,36 @@ void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { if (rHint.GetId() == SfxHintId::Deinitializing) { - DELETEZ(m_pWebUsrPref); - DELETEZ(m_pUsrPref); - DELETEZ(m_pModuleConfig); - DELETEZ(m_pPrintOptions); - DELETEZ(m_pWebPrintOptions); - DELETEZ(m_pChapterNumRules); - DELETEZ(m_pStdFontConfig); - DELETEZ(m_pNavigationConfig); - DELETEZ(m_pToolbarConfig); - DELETEZ(m_pWebToolbarConfig); - DELETEZ(m_pDBConfig); + m_pWebUsrPref.reset(); + m_pUsrPref.reset(); + m_pModuleConfig.reset(); + m_pPrintOptions.reset(); + m_pWebPrintOptions.reset(); + m_pChapterNumRules.reset(); + m_pStdFontConfig.reset(); + m_pNavigationConfig.reset(); + m_pToolbarConfig.reset(); + m_pWebToolbarConfig.reset(); + m_pDBConfig.reset(); if( m_pColorConfig ) { m_pColorConfig->RemoveListener(this); - DELETEZ(m_pColorConfig); + m_pColorConfig.reset(); } if( m_pAccessibilityOptions ) { m_pAccessibilityOptions->RemoveListener(this); - DELETEZ(m_pAccessibilityOptions); + m_pAccessibilityOptions.reset(); } if( m_pCTLOptions ) { m_pCTLOptions->RemoveListener(this); - DELETEZ(m_pCTLOptions); + m_pCTLOptions.reset(); } if( m_pUserOptions ) { m_pUserOptions->RemoveListener(this); - DELETEZ(m_pUserOptions); + m_pUserOptions.reset(); } } } @@ -905,14 +905,14 @@ void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, ConfigurationHints ) { - if( pBrdCst == m_pUserOptions ) + if( pBrdCst == m_pUserOptions.get() ) { m_bAuthorInitialised = false; } - else if ( pBrdCst == m_pColorConfig || pBrdCst == m_pAccessibilityOptions ) + else if ( pBrdCst == m_pColorConfig.get() || pBrdCst == m_pAccessibilityOptions.get() ) { bool bAccessibility = false; - if( pBrdCst == m_pColorConfig ) + if( pBrdCst == m_pColorConfig.get() ) SwViewOption::ApplyColorConfigValues(*m_pColorConfig); else bAccessibility = true; @@ -940,7 +940,7 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con pViewShell = SfxViewShell::GetNext( *pViewShell ); } } - else if( pBrdCst == m_pCTLOptions ) + else if( pBrdCst == m_pCTLOptions.get() ) { const SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); while( pObjSh ) @@ -961,15 +961,15 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con SwDBConfig* SwModule::GetDBConfig() { if(!m_pDBConfig) - m_pDBConfig = new SwDBConfig; - return m_pDBConfig; + m_pDBConfig.reset(new SwDBConfig); + return m_pDBConfig.get(); } svtools::ColorConfig& SwModule::GetColorConfig() { if(!m_pColorConfig) { - m_pColorConfig = new svtools::ColorConfig; + m_pColorConfig.reset(new svtools::ColorConfig); SwViewOption::ApplyColorConfigValues(*m_pColorConfig); m_pColorConfig->AddListener(this); } @@ -980,7 +980,7 @@ SvtAccessibilityOptions& SwModule::GetAccessibilityOptions() { if(!m_pAccessibilityOptions) { - m_pAccessibilityOptions = new SvtAccessibilityOptions; + m_pAccessibilityOptions.reset(new SvtAccessibilityOptions); m_pAccessibilityOptions->AddListener(this); } return *m_pAccessibilityOptions; @@ -990,7 +990,7 @@ SvtCTLOptions& SwModule::GetCTLOptions() { if(!m_pCTLOptions) { - m_pCTLOptions = new SvtCTLOptions; + m_pCTLOptions.reset(new SvtCTLOptions); m_pCTLOptions->AddListener(this); } return *m_pCTLOptions; @@ -1000,7 +1000,7 @@ SvtUserOptions& SwModule::GetUserOptions() { if(!m_pUserOptions) { - m_pUserOptions = new SvtUserOptions; + m_pUserOptions.reset(new SvtUserOptions); m_pUserOptions->AddListener(this); } return *m_pUserOptions; @@ -1013,13 +1013,13 @@ const SwMasterUsrPref *SwModule::GetUsrPref(bool bWeb) const { // The SpellChecker is needed in SwMasterUsrPref's Load, but it must not // be created there #58256# - pNonConstModule->m_pWebUsrPref = new SwMasterUsrPref(true); + pNonConstModule->m_pWebUsrPref.reset(new SwMasterUsrPref(true)); } else if(!bWeb && !m_pUsrPref) { - pNonConstModule->m_pUsrPref = new SwMasterUsrPref(false); + pNonConstModule->m_pUsrPref.reset(new SwMasterUsrPref(false)); } - return bWeb ? m_pWebUsrPref : m_pUsrPref; + return bWeb ? m_pWebUsrPref.get() : m_pUsrPref.get(); } void NewXForms( SfxRequest& rReq ) diff --git a/sw/source/uibase/app/appopt.cxx b/sw/source/uibase/app/appopt.cxx index 595e2e992d83..626d797bc7c1 100644 --- a/sw/source/uibase/app/appopt.cxx +++ b/sw/source/uibase/app/appopt.cxx @@ -79,7 +79,7 @@ std::unique_ptr<SfxItemSet> SwModule::CreateItemSet( sal_uInt16 nId ) // the options for the Web- and Textdialog are put together here SwViewOption aViewOpt = *GetUsrPref(!bTextDialog); - SwMasterUsrPref* pPref = bTextDialog ? m_pUsrPref : m_pWebUsrPref; + SwMasterUsrPref* pPref = bTextDialog ? m_pUsrPref.get() : m_pWebUsrPref.get(); // no MakeUsrPref, because only options from textdoks can be used here SwView* pAppView = GetView(); if(pAppView && pAppView->GetViewFrame() != SfxViewFrame::Current()) @@ -251,7 +251,7 @@ void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) } SwViewOption aViewOpt = *GetUsrPref(!bTextDialog); - SwMasterUsrPref* pPref = bTextDialog ? m_pUsrPref : m_pWebUsrPref; + SwMasterUsrPref* pPref = bTextDialog ? m_pUsrPref.get() : m_pWebUsrPref.get(); const SfxPoolItem* pItem; SfxBindings *pBindings = pAppView ? &pAppView->GetViewFrame()->GetBindings() diff --git a/sw/source/uibase/app/swmodul1.cxx b/sw/source/uibase/app/swmodul1.cxx index eaddc4c7d9ae..a76477be082f 100644 --- a/sw/source/uibase/app/swmodul1.cxx +++ b/sw/source/uibase/app/swmodul1.cxx @@ -214,13 +214,13 @@ void SwModule::ApplyUserMetric( FieldUnit eMetric, bool bWeb ) { if(!m_pWebUsrPref) GetUsrPref(true); - pPref = m_pWebUsrPref; + pPref = m_pWebUsrPref.get(); } else { if(!m_pUsrPref) GetUsrPref(false); - pPref = m_pUsrPref; + pPref = m_pUsrPref.get(); } FieldUnit eOldMetric = pPref->GetMetric(); if(eOldMetric != eMetric) @@ -250,13 +250,13 @@ void SwModule::ApplyRulerMetric( FieldUnit eMetric, bool bHorizontal, bool bWeb { if(!m_pWebUsrPref) GetUsrPref(true); - pPref = m_pWebUsrPref; + pPref = m_pWebUsrPref.get(); } else { if(!m_pUsrPref) GetUsrPref(false); - pPref = m_pUsrPref; + pPref = m_pUsrPref.get(); } if( bHorizontal ) pPref->SetHScrollMetric(eMetric); @@ -286,13 +286,13 @@ void SwModule::ApplyUserCharUnit(bool bApplyChar, bool bWeb) { if(!m_pWebUsrPref) GetUsrPref(true); - pPref = m_pWebUsrPref; + pPref = m_pWebUsrPref.get(); } else { if(!m_pUsrPref) GetUsrPref(false); - pPref = m_pUsrPref; + pPref = m_pUsrPref.get(); } bool bOldApplyCharUnit = pPref->IsApplyCharUnit(); bool bHasChanged = false; @@ -342,30 +342,30 @@ SwNavigationConfig* SwModule::GetNavigationConfig() { if(!m_pNavigationConfig) { - m_pNavigationConfig = new SwNavigationConfig; + m_pNavigationConfig.reset( new SwNavigationConfig ); } - return m_pNavigationConfig; + return m_pNavigationConfig.get(); } SwPrintOptions* SwModule::GetPrtOptions(bool bWeb) { if(bWeb && !m_pWebPrintOptions) { - m_pWebPrintOptions = new SwPrintOptions(true); + m_pWebPrintOptions.reset(new SwPrintOptions(true)); } else if(!bWeb && !m_pPrintOptions) { - m_pPrintOptions = new SwPrintOptions(false); + m_pPrintOptions.reset(new SwPrintOptions(false)); } - return bWeb ? m_pWebPrintOptions : m_pPrintOptions; + return bWeb ? m_pWebPrintOptions.get() : m_pPrintOptions.get(); } SwChapterNumRules* SwModule::GetChapterNumRules() { if(!m_pChapterNumRules) - m_pChapterNumRules = new SwChapterNumRules; - return m_pChapterNumRules; + m_pChapterNumRules.reset(new SwChapterNumRules); + return m_pChapterNumRules.get(); } void SwModule::ShowDBObj(SwView const & rView, const SwDBData& rData) @@ -595,13 +595,13 @@ FieldUnit SwModule::GetMetric( bool bWeb ) const { if(!m_pWebUsrPref) GetUsrPref(true); - pPref = m_pWebUsrPref; + pPref = m_pWebUsrPref.get(); } else { if(!m_pUsrPref) GetUsrPref(false); - pPref = m_pUsrPref; + pPref = m_pUsrPref.get(); } return pPref->GetMetric(); } diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 8aa9841c4c06..963d35cadd3f 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -25,6 +25,8 @@ #include <vcl/graph.hxx> #include <svtools/ehdl.hxx> #include <unotools/resmgr.hxx> +#include <unotools/useroptions.hxx> +#include <svl/ctloptions.hxx> #include <svx/ParaLineSpacingPopup.hxx> #include <svx/TextCharacterSpacingPopup.hxx> #include <svx/TextUnderlinePopup.hxx> @@ -140,6 +142,8 @@ bool g_bNoInterrupt = false; #include <unomid.h> #include "swdllimpl.hxx" +#include <dbconfig.hxx> +#include <navicfg.hxx> using namespace com::sun::star; using namespace ::com::sun::star::uno; @@ -148,21 +152,6 @@ SwModule::SwModule( SfxObjectFactory* pWebFact, SfxObjectFactory* pFact, SfxObjectFactory* pGlobalFact ) : SfxModule("sw", {pWebFact, pFact, pGlobalFact}), - m_pModuleConfig(nullptr), - m_pUsrPref(nullptr), - m_pWebUsrPref(nullptr), - m_pPrintOptions(nullptr), - m_pWebPrintOptions(nullptr), - m_pChapterNumRules(nullptr), - m_pStdFontConfig(nullptr), - m_pNavigationConfig(nullptr), - m_pToolbarConfig(nullptr), - m_pWebToolbarConfig(nullptr), - m_pDBConfig(nullptr), - m_pColorConfig(nullptr), - m_pAccessibilityOptions(nullptr), - m_pCTLOptions(nullptr), - m_pUserOptions(nullptr), m_pAttrPool(nullptr), m_pView(nullptr), m_bAuthorInitialised(false), @@ -177,13 +166,13 @@ SwModule::SwModule( SfxObjectFactory* pWebFact, ErrCodeArea::Sw, GetResLocale() ) ); - m_pModuleConfig = new SwModuleOptions; + m_pModuleConfig.reset(new SwModuleOptions); // We need them anyways - m_pToolbarConfig = new SwToolbarConfigItem( false ); - m_pWebToolbarConfig = new SwToolbarConfigItem( true ); + m_pToolbarConfig.reset(new SwToolbarConfigItem( false )); + m_pWebToolbarConfig.reset(new SwToolbarConfigItem( true )); - m_pStdFontConfig = new SwStdFontConfig; + m_pStdFontConfig.reset(new SwStdFontConfig); StartListening( *SfxGetpApp() ); |