loplugin:useuniqueptr in ScDocShell
Change-Id: I6d4d4899670d8c3254f8c4337a14ba2bb937a2bf Reviewed-on: https://gerrit.libreoffice.org/56555 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -267,7 +267,7 @@ void ScDocShell::BeforeXMLLoading()
|
||||
|
||||
// prevent unnecessary broadcasts and updates
|
||||
OSL_ENSURE(m_pModificator == nullptr, "The Modificator should not exist");
|
||||
m_pModificator = new ScDocShellModificator( *this );
|
||||
m_pModificator.reset( new ScDocShellModificator( *this ) );
|
||||
|
||||
m_aDocument.SetImportingXML( true );
|
||||
m_aDocument.EnableExecuteLink( false ); // #i101304# to be safe, prevent nested loading from external references
|
||||
@@ -372,8 +372,7 @@ void ScDocShell::AfterXMLLoading(bool bRet)
|
||||
// will set the cells dirty.
|
||||
if (eRecalcState == ScDocument::HardRecalcState::OFF)
|
||||
m_aDocument.SetHardRecalcState(ScDocument::HardRecalcState::TEMPORARY);
|
||||
delete m_pModificator;
|
||||
m_pModificator = nullptr;
|
||||
m_pModificator.reset();
|
||||
m_aDocument.SetHardRecalcState(eRecalcState);
|
||||
}
|
||||
else
|
||||
@@ -713,7 +712,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
|
||||
sal_uInt32 nTimeout = rStlHint.GetTimeout();
|
||||
|
||||
if (!m_pAutoStyleList)
|
||||
m_pAutoStyleList = new ScAutoStyleList(this);
|
||||
m_pAutoStyleList.reset( new ScAutoStyleList(this) );
|
||||
m_pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
|
||||
}
|
||||
else if ( dynamic_cast<const SfxEventHint*>(&rHint) )
|
||||
@@ -2779,9 +2778,9 @@ bool ScDocShell::HasAutomaticTableName( const OUString& rFilter )
|
||||
|| rFilter == pFilterRtf;
|
||||
}
|
||||
|
||||
ScDocFunc *ScDocShell::CreateDocFunc()
|
||||
std::unique_ptr<ScDocFunc> ScDocShell::CreateDocFunc()
|
||||
{
|
||||
return new ScDocFuncDirect( *this );
|
||||
return o3tl::make_unique<ScDocFuncDirect>( *this );
|
||||
}
|
||||
|
||||
ScDocument* ScDocShell::GetClipDoc()
|
||||
@@ -2899,28 +2898,28 @@ ScDocShell::~ScDocShell()
|
||||
EndListening(*pStlPool);
|
||||
EndListening(*this);
|
||||
|
||||
delete m_pAutoStyleList;
|
||||
m_pAutoStyleList.reset();
|
||||
|
||||
SfxApplication *pSfxApp = SfxGetpApp();
|
||||
if ( pSfxApp->GetDdeService() ) // Delete DDE for Document
|
||||
pSfxApp->RemoveDdeTopic( this );
|
||||
|
||||
delete m_pDocFunc;
|
||||
m_pDocFunc.reset();
|
||||
delete m_aDocument.mpUndoManager;
|
||||
m_aDocument.mpUndoManager = nullptr;
|
||||
delete m_pImpl;
|
||||
m_pImpl.reset();
|
||||
|
||||
delete m_pPaintLockData;
|
||||
m_pPaintLockData.reset();
|
||||
|
||||
delete m_pSolverSaveData;
|
||||
delete m_pSheetSaveData;
|
||||
delete m_pFormatSaveData;
|
||||
delete m_pOldAutoDBRange;
|
||||
m_pSolverSaveData.reset();
|
||||
m_pSheetSaveData.reset();
|
||||
m_pFormatSaveData.reset();
|
||||
m_pOldAutoDBRange.reset();
|
||||
|
||||
if (m_pModificator)
|
||||
{
|
||||
OSL_FAIL("The Modificator should not exist");
|
||||
delete m_pModificator;
|
||||
m_pModificator.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3077,26 +3076,25 @@ vcl::Window* ScDocShell::GetActiveDialogParent()
|
||||
return Application::GetDefDialogParent();
|
||||
}
|
||||
|
||||
void ScDocShell::SetSolverSaveData( const ScOptSolverSave& rData )
|
||||
void ScDocShell::SetSolverSaveData( std::unique_ptr<ScOptSolverSave> pData )
|
||||
{
|
||||
delete m_pSolverSaveData;
|
||||
m_pSolverSaveData = new ScOptSolverSave( rData );
|
||||
m_pSolverSaveData = std::move(pData);
|
||||
}
|
||||
|
||||
ScSheetSaveData* ScDocShell::GetSheetSaveData()
|
||||
{
|
||||
if (!m_pSheetSaveData)
|
||||
m_pSheetSaveData = new ScSheetSaveData;
|
||||
m_pSheetSaveData.reset( new ScSheetSaveData );
|
||||
|
||||
return m_pSheetSaveData;
|
||||
return m_pSheetSaveData.get();
|
||||
}
|
||||
|
||||
ScFormatSaveData* ScDocShell::GetFormatSaveData()
|
||||
{
|
||||
if (!m_pFormatSaveData)
|
||||
m_pFormatSaveData = new ScFormatSaveData;
|
||||
m_pFormatSaveData.reset( new ScFormatSaveData );
|
||||
|
||||
return m_pFormatSaveData;
|
||||
return m_pFormatSaveData.get();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@@ -108,7 +108,7 @@ void ScDocShell::InitItems()
|
||||
PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
|
||||
|
||||
// Other modifications after creation of the DrawLayer
|
||||
pDrawLayer->SetNotifyUndoActionHdl( LINK( m_pDocFunc, ScDocFunc, NotifyDrawUndo ) );
|
||||
pDrawLayer->SetNotifyUndoActionHdl( LINK( m_pDocFunc.get(), ScDocFunc, NotifyDrawUndo ) );
|
||||
}
|
||||
else if (!utl::ConfigManager::IsFuzzing())
|
||||
{
|
||||
|
@@ -231,7 +231,7 @@ void ScDocShell::UpdatePaintExt( sal_uInt16& rExtFlags, SCCOL nStartCol, SCROW n
|
||||
void ScDocShell::LockPaint_Impl(bool bDoc)
|
||||
{
|
||||
if ( !m_pPaintLockData )
|
||||
m_pPaintLockData = new ScPaintLockData;
|
||||
m_pPaintLockData.reset( new ScPaintLockData );
|
||||
m_pPaintLockData->IncLevel(bDoc);
|
||||
}
|
||||
|
||||
@@ -245,8 +245,8 @@ void ScDocShell::UnlockPaint_Impl(bool bDoc)
|
||||
{
|
||||
// Execute Paint now
|
||||
|
||||
ScPaintLockData* pPaint = m_pPaintLockData;
|
||||
m_pPaintLockData = nullptr; // don't continue collecting
|
||||
// don't continue collecting
|
||||
std::unique_ptr<ScPaintLockData> pPaint = std::move(m_pPaintLockData);
|
||||
|
||||
ScRangeListRef xRangeList = pPaint->GetRangeList();
|
||||
if ( xRangeList.is() )
|
||||
@@ -264,8 +264,6 @@ void ScDocShell::UnlockPaint_Impl(bool bDoc)
|
||||
|
||||
if ( pPaint->GetModified() )
|
||||
SetDocumentModified();
|
||||
|
||||
delete pPaint;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -301,7 +299,7 @@ void ScDocShell::SetLockCount(sal_uInt16 nNew)
|
||||
if (nNew) // set
|
||||
{
|
||||
if ( !m_pPaintLockData )
|
||||
m_pPaintLockData = new ScPaintLockData;
|
||||
m_pPaintLockData.reset( new ScPaintLockData );
|
||||
m_pPaintLockData->SetDocLevel(nNew-1);
|
||||
LockDocument_Impl(nNew);
|
||||
}
|
||||
|
@@ -241,14 +241,13 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe
|
||||
// sheet-local anonymous DBData from pOldAutoDBRange, unset so
|
||||
// that won't happen with data of a previous sheet-local
|
||||
// DBData.
|
||||
delete m_pOldAutoDBRange;
|
||||
m_pOldAutoDBRange = nullptr;
|
||||
m_pOldAutoDBRange.reset();
|
||||
}
|
||||
else if (!m_pOldAutoDBRange)
|
||||
{
|
||||
// store the old unnamed database range with its settings for undo
|
||||
// (store at the first change, get the state before all changes)
|
||||
m_pOldAutoDBRange = new ScDBData( *pNoNameData );
|
||||
m_pOldAutoDBRange.reset( new ScDBData( *pNoNameData ) );
|
||||
}
|
||||
else if (m_pOldAutoDBRange->GetTab() != pNoNameData->GetTab())
|
||||
{
|
||||
@@ -360,11 +359,9 @@ ScDBData* ScDocShell::GetAnonymousDBData(const ScRange& rRange)
|
||||
return pData;
|
||||
}
|
||||
|
||||
ScDBData* ScDocShell::GetOldAutoDBRange()
|
||||
std::unique_ptr<ScDBData> ScDocShell::GetOldAutoDBRange()
|
||||
{
|
||||
ScDBData* pRet = m_pOldAutoDBRange;
|
||||
m_pOldAutoDBRange = nullptr;
|
||||
return pRet; // has to be deleted by caller!
|
||||
return std::move(m_pOldAutoDBRange);
|
||||
}
|
||||
|
||||
void ScDocShell::CancelAutoDBRange()
|
||||
@@ -396,8 +393,7 @@ void ScDocShell::CancelAutoDBRange()
|
||||
}
|
||||
}
|
||||
|
||||
delete m_pOldAutoDBRange;
|
||||
m_pOldAutoDBRange = nullptr;
|
||||
m_pOldAutoDBRange.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -91,8 +91,8 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener
|
||||
OUString m_aDdeTextFmt;
|
||||
|
||||
double m_nPrtToScreenFactor;
|
||||
DocShell_Impl* m_pImpl;
|
||||
ScDocFunc* m_pDocFunc;
|
||||
std::unique_ptr<DocShell_Impl> m_pImpl;
|
||||
std::unique_ptr<ScDocFunc> m_pDocFunc;
|
||||
|
||||
bool m_bHeaderOn;
|
||||
bool m_bFooterOn;
|
||||
@@ -105,15 +105,15 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener
|
||||
sal_uInt16 m_nDocumentLock;
|
||||
sal_Int16 m_nCanUpdate; // stores the UpdateDocMode from loading a document till update links
|
||||
|
||||
ScDBData* m_pOldAutoDBRange;
|
||||
std::unique_ptr<ScDBData> m_pOldAutoDBRange;
|
||||
|
||||
ScAutoStyleList* m_pAutoStyleList;
|
||||
ScPaintLockData* m_pPaintLockData;
|
||||
ScOptSolverSave* m_pSolverSaveData;
|
||||
ScSheetSaveData* m_pSheetSaveData;
|
||||
ScFormatSaveData* m_pFormatSaveData;
|
||||
std::unique_ptr<ScAutoStyleList> m_pAutoStyleList;
|
||||
std::unique_ptr<ScPaintLockData> m_pPaintLockData;
|
||||
std::unique_ptr<ScOptSolverSave> m_pSolverSaveData;
|
||||
std::unique_ptr<ScSheetSaveData> m_pSheetSaveData;
|
||||
std::unique_ptr<ScFormatSaveData> m_pFormatSaveData;
|
||||
|
||||
ScDocShellModificator* m_pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading)
|
||||
std::unique_ptr<ScDocShellModificator> m_pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading)
|
||||
|
||||
css::uno::Reference< ooo::vba::excel::XWorkbook> mxAutomationWorkbookObject;
|
||||
|
||||
@@ -162,7 +162,7 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener
|
||||
|
||||
SAL_DLLPRIVATE void UseSheetSaveEntries();
|
||||
|
||||
SAL_DLLPRIVATE ScDocFunc *CreateDocFunc();
|
||||
SAL_DLLPRIVATE std::unique_ptr<ScDocFunc> CreateDocFunc();
|
||||
|
||||
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
|
||||
|
||||
@@ -299,7 +299,7 @@ public:
|
||||
void DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2 );
|
||||
ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel );
|
||||
ScDBData* GetAnonymousDBData(const ScRange& rRange);
|
||||
ScDBData* GetOldAutoDBRange(); // has to be deleted by caller!
|
||||
std::unique_ptr<ScDBData> GetOldAutoDBRange();
|
||||
void CancelAutoDBRange(); // called when dialog is cancelled
|
||||
|
||||
virtual void ReconnectDdeLink(SfxObjectShell& rServer) override;
|
||||
@@ -414,8 +414,8 @@ public:
|
||||
|
||||
virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates ) override;
|
||||
|
||||
const ScOptSolverSave* GetSolverSaveData() const { return m_pSolverSaveData; } // may be null
|
||||
void SetSolverSaveData( const ScOptSolverSave& rData );
|
||||
const ScOptSolverSave* GetSolverSaveData() const { return m_pSolverSaveData.get(); } // may be null
|
||||
void SetSolverSaveData( std::unique_ptr<ScOptSolverSave> pData );
|
||||
ScSheetSaveData* GetSheetSaveData();
|
||||
ScFormatSaveData* GetFormatSaveData();
|
||||
|
||||
|
@@ -585,10 +585,10 @@ IMPL_LINK( ScOptSolverDlg, BtnHdl, Button*, pBtn, void )
|
||||
{
|
||||
// Close: write dialog settings to DocShell for subsequent calls
|
||||
ReadConditions();
|
||||
ScOptSolverSave aSave(
|
||||
std::unique_ptr<ScOptSolverSave> pSave( new ScOptSolverSave(
|
||||
m_pEdObjectiveCell->GetText(), m_pRbMax->IsChecked(), m_pRbMin->IsChecked(), m_pRbValue->IsChecked(),
|
||||
m_pEdTargetValue->GetText(), m_pEdVariableCells->GetText(), maConditions, maEngine, maProperties );
|
||||
mpDocShell->SetSolverSaveData( aSave );
|
||||
m_pEdTargetValue->GetText(), m_pEdVariableCells->GetText(), maConditions, maEngine, maProperties ) );
|
||||
mpDocShell->SetSolverSaveData( std::move(pSave) );
|
||||
Close();
|
||||
}
|
||||
else
|
||||
|
@@ -464,7 +464,7 @@ ScDBFuncUndo::ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal ) :
|
||||
ScSimpleUndo( pDocSh ),
|
||||
aOriginalRange( rOriginal )
|
||||
{
|
||||
pAutoDBRange = pDocSh->GetOldAutoDBRange();
|
||||
pAutoDBRange = pDocSh->GetOldAutoDBRange().release();
|
||||
}
|
||||
|
||||
ScDBFuncUndo::~ScDBFuncUndo()
|
||||
|
Reference in New Issue
Block a user