loplugin:useuniqueptr in ScModule

Change-Id: I6433050af217668800c7257433c11bfec37d9634
Reviewed-on: https://gerrit.libreoffice.org/56557
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2018-06-27 11:53:31 +02:00
parent f35ddce379
commit 0bd2c35937
2 changed files with 59 additions and 62 deletions

View File

@@ -80,26 +80,26 @@ class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationL
{ {
Timer m_aIdleTimer; Timer m_aIdleTimer;
Idle m_aSpellIdle; Idle m_aSpellIdle;
ScDragData* m_pDragData; std::unique_ptr<ScDragData> m_pDragData;
ScSelectionTransferObj* m_pSelTransfer; ScSelectionTransferObj* m_pSelTransfer;
ScMessagePool* m_pMessagePool; ScMessagePool* m_pMessagePool;
// there is no global InputHandler anymore, each View has its own // there is no global InputHandler anymore, each View has its own
ScInputHandler* m_pRefInputHandler; ScInputHandler* m_pRefInputHandler;
ScViewCfg* m_pViewCfg; std::unique_ptr<ScViewCfg> m_pViewCfg;
ScDocCfg* m_pDocCfg; std::unique_ptr<ScDocCfg> m_pDocCfg;
ScAppCfg* m_pAppCfg; std::unique_ptr<ScAppCfg> m_pAppCfg;
ScDefaultsCfg* m_pDefaultsCfg; std::unique_ptr<ScDefaultsCfg> m_pDefaultsCfg;
ScFormulaCfg* m_pFormulaCfg; std::unique_ptr<ScFormulaCfg> m_pFormulaCfg;
ScInputCfg* m_pInputCfg; std::unique_ptr<ScInputCfg> m_pInputCfg;
ScPrintCfg* m_pPrintCfg; std::unique_ptr<ScPrintCfg> m_pPrintCfg;
ScNavipiCfg* m_pNavipiCfg; std::unique_ptr<ScNavipiCfg> m_pNavipiCfg;
ScAddInCfg* m_pAddInCfg; std::unique_ptr<ScAddInCfg> m_pAddInCfg;
svtools::ColorConfig* m_pColorConfig; std::unique_ptr<svtools::ColorConfig> m_pColorConfig;
SvtAccessibilityOptions* m_pAccessOptions; std::unique_ptr<SvtAccessibilityOptions> m_pAccessOptions;
SvtCTLOptions* m_pCTLOptions; std::unique_ptr<SvtCTLOptions> m_pCTLOptions;
SvtUserOptions* m_pUserOptions; std::unique_ptr<SvtUserOptions> m_pUserOptions;
SfxErrorHandler* m_pErrorHdl; std::unique_ptr<SfxErrorHandler> m_pErrorHdl;
ScFormEditData* m_pFormEditData; std::unique_ptr<ScFormEditData> m_pFormEditData;
sal_uInt16 m_nCurRefDlgId; sal_uInt16 m_nCurRefDlgId;
bool m_bIsWaterCan:1; bool m_bIsWaterCan:1;
bool m_bIsInEditCommand:1; bool m_bIsInEditCommand:1;
@@ -219,7 +219,7 @@ public:
void InitFormEditData(); void InitFormEditData();
void ClearFormEditData(); void ClearFormEditData();
ScFormEditData* GetFormEditData() { return m_pFormEditData; } ScFormEditData* GetFormEditData() { return m_pFormEditData.get(); }
// input of reference: // input of reference:
SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr ); SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr );

View File

@@ -175,10 +175,10 @@ ScModule::ScModule( SfxObjectFactory* pFact ) :
// Create ErrorHandler - was in Init() // Create ErrorHandler - was in Init()
// Between OfficeApplication::Init and ScGlobal::Init // Between OfficeApplication::Init and ScGlobal::Init
SvxErrorHandler::ensure(); SvxErrorHandler::ensure();
m_pErrorHdl = new SfxErrorHandler(RID_ERRHDLSC, m_pErrorHdl.reset( new SfxErrorHandler(RID_ERRHDLSC,
ErrCodeArea::Sc, ErrCodeArea::Sc,
ErrCodeArea::Sc, ErrCodeArea::Sc,
GetResLocale()); GetResLocale()) );
m_aSpellIdle.SetInvokeHandler( LINK( this, ScModule, SpellTimerHdl ) ); m_aSpellIdle.SetInvokeHandler( LINK( this, ScModule, SpellTimerHdl ) );
@@ -202,10 +202,10 @@ ScModule::~ScModule()
SfxItemPool::Free(m_pMessagePool); SfxItemPool::Free(m_pMessagePool);
DELETEZ( m_pFormEditData ); m_pFormEditData.reset();
delete m_pDragData; m_pDragData.reset();
delete m_pErrorHdl; m_pErrorHdl.reset();
ScGlobal::Clear(); // Also calls ScDocumentPool::DeleteVersionMaps(); ScGlobal::Clear(); // Also calls ScDocumentPool::DeleteVersionMaps();
@@ -214,7 +214,7 @@ ScModule::~ScModule()
void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, ConfigurationHints ) void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, ConfigurationHints )
{ {
if ( p == m_pColorConfig || p == m_pAccessOptions ) if ( p == m_pColorConfig.get() || p == m_pAccessOptions.get() )
{ {
// Test if detective objects have to be updated with new colors // Test if detective objects have to be updated with new colors
// (if the detective colors haven't been used yet, there's nothing to update) // (if the detective colors haven't been used yet, there's nothing to update)
@@ -271,7 +271,7 @@ void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, Configura
pViewShell = SfxViewShell::GetNext( *pViewShell ); pViewShell = SfxViewShell::GetNext( *pViewShell );
} }
} }
else if ( p == m_pCTLOptions ) else if ( p == m_pCTLOptions.get() )
{ {
// for all documents: set digit language for printer, recalc output factor, update row heights // for all documents: set digit language for printer, recalc output factor, update row heights
SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
@@ -331,35 +331,32 @@ void ScModule::Notify( SfxBroadcaster&, const SfxHint& rHint )
void ScModule::DeleteCfg() void ScModule::DeleteCfg()
{ {
DELETEZ( m_pViewCfg ); // Saving happens automatically before Exit() m_pViewCfg.reset(); // Saving happens automatically before Exit()
DELETEZ( m_pDocCfg ); m_pDocCfg.reset();
DELETEZ( m_pAppCfg ); m_pAppCfg.reset();
DELETEZ( m_pDefaultsCfg ); m_pDefaultsCfg.reset();
DELETEZ( m_pFormulaCfg ); m_pFormulaCfg.reset();
DELETEZ( m_pInputCfg ); m_pInputCfg.reset();
DELETEZ( m_pPrintCfg ); m_pPrintCfg.reset();
DELETEZ( m_pNavipiCfg ); m_pNavipiCfg.reset();
DELETEZ( m_pAddInCfg ); m_pAddInCfg.reset();
if ( m_pColorConfig ) if ( m_pColorConfig )
{ {
m_pColorConfig->RemoveListener(this); m_pColorConfig->RemoveListener(this);
DELETEZ( m_pColorConfig ); m_pColorConfig.reset();
} }
if ( m_pAccessOptions ) if ( m_pAccessOptions )
{ {
m_pAccessOptions->RemoveListener(this); m_pAccessOptions->RemoveListener(this);
DELETEZ( m_pAccessOptions ); m_pAccessOptions.reset();
} }
if ( m_pCTLOptions ) if ( m_pCTLOptions )
{ {
m_pCTLOptions->RemoveListener(this); m_pCTLOptions->RemoveListener(this);
DELETEZ( m_pCTLOptions ); m_pCTLOptions.reset();
}
if( m_pUserOptions )
{
DELETEZ( m_pUserOptions );
} }
m_pUserOptions.reset();
} }
// Moved here from the App // Moved here from the App
@@ -667,18 +664,18 @@ void ScModule::SetSelectionTransfer( ScSelectionTransferObj* pNew )
void ScModule::InitFormEditData() void ScModule::InitFormEditData()
{ {
m_pFormEditData = new ScFormEditData; m_pFormEditData.reset( new ScFormEditData );
} }
void ScModule::ClearFormEditData() void ScModule::ClearFormEditData()
{ {
DELETEZ( m_pFormEditData ); m_pFormEditData.reset();
} }
void ScModule::SetViewOptions( const ScViewOptions& rOpt ) void ScModule::SetViewOptions( const ScViewOptions& rOpt )
{ {
if ( !m_pViewCfg ) if ( !m_pViewCfg )
m_pViewCfg = new ScViewCfg; m_pViewCfg.reset(new ScViewCfg);
m_pViewCfg->SetOptions( rOpt ); m_pViewCfg->SetOptions( rOpt );
} }
@@ -686,7 +683,7 @@ void ScModule::SetViewOptions( const ScViewOptions& rOpt )
const ScViewOptions& ScModule::GetViewOptions() const ScViewOptions& ScModule::GetViewOptions()
{ {
if ( !m_pViewCfg ) if ( !m_pViewCfg )
m_pViewCfg = new ScViewCfg; m_pViewCfg.reset( new ScViewCfg );
return *m_pViewCfg; return *m_pViewCfg;
} }
@@ -694,7 +691,7 @@ const ScViewOptions& ScModule::GetViewOptions()
void ScModule::SetDocOptions( const ScDocOptions& rOpt ) void ScModule::SetDocOptions( const ScDocOptions& rOpt )
{ {
if ( !m_pDocCfg ) if ( !m_pDocCfg )
m_pDocCfg = new ScDocCfg; m_pDocCfg.reset( new ScDocCfg );
m_pDocCfg->SetOptions( rOpt ); m_pDocCfg->SetOptions( rOpt );
} }
@@ -702,7 +699,7 @@ void ScModule::SetDocOptions( const ScDocOptions& rOpt )
const ScDocOptions& ScModule::GetDocOptions() const ScDocOptions& ScModule::GetDocOptions()
{ {
if ( !m_pDocCfg ) if ( !m_pDocCfg )
m_pDocCfg = new ScDocCfg; m_pDocCfg.reset( new ScDocCfg );
return *m_pDocCfg; return *m_pDocCfg;
} }
@@ -746,7 +743,7 @@ void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex)
void ScModule::SetAppOptions( const ScAppOptions& rOpt ) void ScModule::SetAppOptions( const ScAppOptions& rOpt )
{ {
if ( !m_pAppCfg ) if ( !m_pAppCfg )
m_pAppCfg = new ScAppCfg; m_pAppCfg.reset( new ScAppCfg );
m_pAppCfg->SetOptions( rOpt ); m_pAppCfg->SetOptions( rOpt );
} }
@@ -759,7 +756,7 @@ void global_InitAppOptions()
const ScAppOptions& ScModule::GetAppOptions() const ScAppOptions& ScModule::GetAppOptions()
{ {
if ( !m_pAppCfg ) if ( !m_pAppCfg )
m_pAppCfg = new ScAppCfg; m_pAppCfg.reset( new ScAppCfg );
return *m_pAppCfg; return *m_pAppCfg;
} }
@@ -767,7 +764,7 @@ const ScAppOptions& ScModule::GetAppOptions()
void ScModule::SetDefaultsOptions( const ScDefaultsOptions& rOpt ) void ScModule::SetDefaultsOptions( const ScDefaultsOptions& rOpt )
{ {
if ( !m_pDefaultsCfg ) if ( !m_pDefaultsCfg )
m_pDefaultsCfg = new ScDefaultsCfg; m_pDefaultsCfg.reset( new ScDefaultsCfg );
m_pDefaultsCfg->SetOptions( rOpt ); m_pDefaultsCfg->SetOptions( rOpt );
} }
@@ -775,7 +772,7 @@ void ScModule::SetDefaultsOptions( const ScDefaultsOptions& rOpt )
const ScDefaultsOptions& ScModule::GetDefaultsOptions() const ScDefaultsOptions& ScModule::GetDefaultsOptions()
{ {
if ( !m_pDefaultsCfg ) if ( !m_pDefaultsCfg )
m_pDefaultsCfg = new ScDefaultsCfg; m_pDefaultsCfg.reset( new ScDefaultsCfg );
return *m_pDefaultsCfg; return *m_pDefaultsCfg;
} }
@@ -783,7 +780,7 @@ const ScDefaultsOptions& ScModule::GetDefaultsOptions()
void ScModule::SetFormulaOptions( const ScFormulaOptions& rOpt ) void ScModule::SetFormulaOptions( const ScFormulaOptions& rOpt )
{ {
if ( !m_pFormulaCfg ) if ( !m_pFormulaCfg )
m_pFormulaCfg = new ScFormulaCfg; m_pFormulaCfg.reset( new ScFormulaCfg );
m_pFormulaCfg->SetOptions( rOpt ); m_pFormulaCfg->SetOptions( rOpt );
} }
@@ -791,7 +788,7 @@ void ScModule::SetFormulaOptions( const ScFormulaOptions& rOpt )
const ScFormulaOptions& ScModule::GetFormulaOptions() const ScFormulaOptions& ScModule::GetFormulaOptions()
{ {
if ( !m_pFormulaCfg ) if ( !m_pFormulaCfg )
m_pFormulaCfg = new ScFormulaCfg; m_pFormulaCfg.reset( new ScFormulaCfg );
return *m_pFormulaCfg; return *m_pFormulaCfg;
} }
@@ -799,7 +796,7 @@ const ScFormulaOptions& ScModule::GetFormulaOptions()
void ScModule::SetInputOptions( const ScInputOptions& rOpt ) void ScModule::SetInputOptions( const ScInputOptions& rOpt )
{ {
if ( !m_pInputCfg ) if ( !m_pInputCfg )
m_pInputCfg = new ScInputCfg; m_pInputCfg.reset( new ScInputCfg );
m_pInputCfg->SetOptions( rOpt ); m_pInputCfg->SetOptions( rOpt );
} }
@@ -807,7 +804,7 @@ void ScModule::SetInputOptions( const ScInputOptions& rOpt )
const ScInputOptions& ScModule::GetInputOptions() const ScInputOptions& ScModule::GetInputOptions()
{ {
if ( !m_pInputCfg ) if ( !m_pInputCfg )
m_pInputCfg = new ScInputCfg; m_pInputCfg.reset( new ScInputCfg );
return *m_pInputCfg; return *m_pInputCfg;
} }
@@ -815,7 +812,7 @@ const ScInputOptions& ScModule::GetInputOptions()
void ScModule::SetPrintOptions( const ScPrintOptions& rOpt ) void ScModule::SetPrintOptions( const ScPrintOptions& rOpt )
{ {
if ( !m_pPrintCfg ) if ( !m_pPrintCfg )
m_pPrintCfg = new ScPrintCfg; m_pPrintCfg.reset( new ScPrintCfg );
m_pPrintCfg->SetOptions( rOpt ); m_pPrintCfg->SetOptions( rOpt );
} }
@@ -823,7 +820,7 @@ void ScModule::SetPrintOptions( const ScPrintOptions& rOpt )
const ScPrintOptions& ScModule::GetPrintOptions() const ScPrintOptions& ScModule::GetPrintOptions()
{ {
if ( !m_pPrintCfg ) if ( !m_pPrintCfg )
m_pPrintCfg = new ScPrintCfg; m_pPrintCfg.reset( new ScPrintCfg );
return *m_pPrintCfg; return *m_pPrintCfg;
} }
@@ -831,7 +828,7 @@ const ScPrintOptions& ScModule::GetPrintOptions()
ScNavipiCfg& ScModule::GetNavipiCfg() ScNavipiCfg& ScModule::GetNavipiCfg()
{ {
if ( !m_pNavipiCfg ) if ( !m_pNavipiCfg )
m_pNavipiCfg = new ScNavipiCfg; m_pNavipiCfg.reset( new ScNavipiCfg );
return *m_pNavipiCfg; return *m_pNavipiCfg;
} }
@@ -839,7 +836,7 @@ ScNavipiCfg& ScModule::GetNavipiCfg()
ScAddInCfg& ScModule::GetAddInCfg() ScAddInCfg& ScModule::GetAddInCfg()
{ {
if ( !m_pAddInCfg ) if ( !m_pAddInCfg )
m_pAddInCfg = new ScAddInCfg; m_pAddInCfg.reset( new ScAddInCfg );
return *m_pAddInCfg; return *m_pAddInCfg;
} }
@@ -848,7 +845,7 @@ svtools::ColorConfig& ScModule::GetColorConfig()
{ {
if ( !m_pColorConfig ) if ( !m_pColorConfig )
{ {
m_pColorConfig = new svtools::ColorConfig; m_pColorConfig.reset( new svtools::ColorConfig );
m_pColorConfig->AddListener(this); m_pColorConfig->AddListener(this);
} }
@@ -859,7 +856,7 @@ SvtAccessibilityOptions& ScModule::GetAccessOptions()
{ {
if ( !m_pAccessOptions ) if ( !m_pAccessOptions )
{ {
m_pAccessOptions = new SvtAccessibilityOptions; m_pAccessOptions.reset( new SvtAccessibilityOptions );
m_pAccessOptions->AddListener(this); m_pAccessOptions->AddListener(this);
} }
@@ -870,7 +867,7 @@ SvtCTLOptions& ScModule::GetCTLOptions()
{ {
if ( !m_pCTLOptions ) if ( !m_pCTLOptions )
{ {
m_pCTLOptions = new SvtCTLOptions; m_pCTLOptions.reset( new SvtCTLOptions );
m_pCTLOptions->AddListener(this); m_pCTLOptions->AddListener(this);
} }
@@ -881,7 +878,7 @@ SvtUserOptions& ScModule::GetUserOptions()
{ {
if( !m_pUserOptions ) if( !m_pUserOptions )
{ {
m_pUserOptions = new SvtUserOptions; m_pUserOptions.reset( new SvtUserOptions );
} }
return *m_pUserOptions; return *m_pUserOptions;
} }