summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-20 12:54:11 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-22 09:53:45 +0100
commitb7654432bfeca619b7657abc8d27193e44cf4dfc (patch)
tree0935306e00e967c1dca4efc8af57f4d67c30a508 /sc/source/core/data
parentf82888653c853f236ab0035bb578a7129ec72fa5 (diff)
loplugin:useuniqueptr in ScDocument
and fix bug where we were deleting a pointer to an object we did not own via pFormatExchangeList Change-Id: I488c679734c48bd21bc6be04837e037e97550647 Reviewed-on: https://gerrit.libreoffice.org/51668 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/column2.cxx2
-rw-r--r--sc/source/core/data/documen2.cxx111
-rw-r--r--sc/source/core/data/documen3.cxx51
-rw-r--r--sc/source/core/data/documen4.cxx10
-rw-r--r--sc/source/core/data/documen6.cxx2
-rw-r--r--sc/source/core/data/documen7.cxx6
-rw-r--r--sc/source/core/data/documen9.cxx3
-rw-r--r--sc/source/core/data/document.cxx18
-rw-r--r--sc/source/core/data/formulacell.cxx4
9 files changed, 86 insertions, 121 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 9e866abbd125..f1e3628e9687 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -361,7 +361,7 @@ long ScColumn::GetNeededSize(
MapMode aHMMMode( MapUnit::Map100thMM, Point(), rZoomX, rZoomY );
// save in document ?
- ScFieldEditEngine* pEngine = pDocument->CreateFieldEditEngine();
+ std::unique_ptr<ScFieldEditEngine> pEngine = pDocument->CreateFieldEditEngine();
pEngine->SetUpdateMode( false );
bool bTextWysiwyg = ( pDev->GetOutDevType() == OUTDEV_PRINTER );
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 2db842f8e78f..bcb7599e658c 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -235,17 +235,15 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
{
mxPoolHelper = new ScPoolHelper( this );
- pBASM = new ScBroadcastAreaSlotMachine( this );
+ pBASM.reset( new ScBroadcastAreaSlotMachine( this ) );
pChartListenerCollection = new ScChartListenerCollection( this );
- pRefreshTimerControl = new ScRefreshTimerControl;
+ pRefreshTimerControl.reset( new ScRefreshTimerControl );
}
else
{
- pBASM = nullptr;
pChartListenerCollection = nullptr;
- pRefreshTimerControl = nullptr;
}
- pDBCollection = new ScDBCollection(this);
+ pDBCollection.reset( new ScDBCollection(this) );
pSelectionAttr = nullptr;
apTemporaryChartLock.reset( new ScTemporaryChartLock(this) );
xColNameRanges = new ScRangePairList;
@@ -306,22 +304,21 @@ sal_uInt32 ScDocument::GetDocumentID() const
void ScDocument::StartChangeTracking()
{
if (!pChangeTrack)
- pChangeTrack = new ScChangeTrack( this );
+ pChangeTrack.reset( new ScChangeTrack( this ) );
}
void ScDocument::EndChangeTracking()
{
- delete pChangeTrack;
- pChangeTrack = nullptr;
+ pChangeTrack.reset();
}
-void ScDocument::SetChangeTrack( ScChangeTrack* pTrack )
+void ScDocument::SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack )
{
OSL_ENSURE( pTrack->GetDocument() == this, "SetChangeTrack: different documents" );
if ( !pTrack || pTrack == pChangeTrack || pTrack->GetDocument() != this )
return ;
EndChangeTracking();
- pChangeTrack = pTrack;
+ pChangeTrack = std::move(pTrack);
}
IMPL_LINK_NOARG(ScDocument, TrackTimeHdl, Timer *, void)
@@ -378,8 +375,7 @@ ScDocument::~ScDocument()
{ // To be sure there isn't anything running do it with a protector,
// this ensures also that nothing needs the control anymore.
ScRefreshTimerProtector aProt( GetRefreshTimerControlAddress() );
- delete pRefreshTimerControl;
- pRefreshTimerControl = nullptr;
+ pRefreshTimerControl.reset();
}
if (IsClipboardSource())
@@ -407,14 +403,12 @@ ScDocument::~ScDocument()
DELETEZ(maThreadSpecific.pLookupCacheMapImpl);
// destroy BroadcastAreas first to avoid un-needed Single-EndListenings of Formula-Cells
- delete pBASM; // BroadcastAreaSlotMachine
- pBASM = nullptr;
+ pBASM.reset(); // BroadcastAreaSlotMachine
- delete pUnoBroadcaster; // broadcasts SfxHintId::Dying again
- pUnoBroadcaster = nullptr;
+ pUnoBroadcaster.reset(); // broadcasts SfxHintId::Dying again
- delete pUnoRefUndoList;
- delete pUnoListenerCalls;
+ pUnoRefUndoList.reset();
+ pUnoListenerCalls.reset();
Clear( true ); // true = from destructor (needed for SdrModel::ClearModel)
@@ -425,38 +419,37 @@ ScDocument::~ScDocument()
pValidationList->clear();
DELETEZ(pValidationList);
}
- delete pRangeName;
- delete pDBCollection;
- delete pSelectionAttr;
+ pRangeName.reset();
+ pDBCollection.reset();
+ pSelectionAttr.reset();
apTemporaryChartLock.reset();
DeleteDrawLayer();
- delete pFormatExchangeList;
mpPrinter.disposeAndClear();
ImplDeleteOptions();
- delete pConsolidateDlgData;
- delete pClipData;
- delete pDetOpList; // also deletes entries
- delete pChangeTrack;
- delete mpEditEngine;
- delete mpNoteEngine;
- delete pChangeViewSettings; // and delete
+ pConsolidateDlgData.reset();
+ pClipData.reset();
+ pDetOpList.reset(); // also deletes entries
+ pChangeTrack.reset();
+ mpEditEngine.reset();
+ mpNoteEngine.reset();
+ pChangeViewSettings.reset(); // and delete
mpVirtualDevice_100th_mm.disposeAndClear();
- delete pDPCollection;
- delete mpAnonymousDBData;
+ pDPCollection.reset();
+ mpAnonymousDBData.reset();
// delete the EditEngine before destroying the mxPoolHelper
- delete pCacheFieldEditEngine;
+ pCacheFieldEditEngine.reset();
if ( mxPoolHelper.is() && !bIsClip && !bIsUndo)
mxPoolHelper->SourceDocumentGone();
mxPoolHelper.clear();
- delete pScriptTypeData;
+ pScriptTypeData.reset();
delete maNonThreaded.pRecursionHelper;
delete maThreadSpecific.pRecursionHelper;
- delete pPreviewFont;
+ pPreviewFont.reset();
SAL_WARN_IF( pAutoNameCache, "sc.core", "AutoNameCache still set in dtor" );
mpFormulaGroupCxt.reset();
@@ -488,14 +481,12 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
pValidationList = new ScValidationDataList(this, *pSourceValid);
// store Links in Stream
- delete pClipData;
+ pClipData.reset();
if (pSourceDoc->GetDocLinkManager().hasDdeLinks())
{
- pClipData = new SvMemoryStream;
+ pClipData.reset( new SvMemoryStream );
pSourceDoc->SaveDdeLinks(*pClipData);
}
- else
- pClipData = nullptr;
// Options pointers exist (ImplCreateOptions) for any document.
// Must be copied for correct results in OLE objects (#i42666#).
@@ -523,7 +514,7 @@ ScFieldEditEngine& ScDocument::GetEditEngine()
{
if ( !mpEditEngine )
{
- mpEditEngine = new ScFieldEditEngine(this, GetEnginePool(), GetEditPool());
+ mpEditEngine.reset( new ScFieldEditEngine(this, GetEnginePool(), GetEditPool()) );
mpEditEngine->SetUpdateMode( false );
mpEditEngine->EnableUndo( false );
mpEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
@@ -537,7 +528,7 @@ ScNoteEditEngine& ScDocument::GetNoteEngine()
if ( !mpNoteEngine )
{
ScMutationGuard aGuard(this, ScMutationGuardFlags::CORE);
- mpNoteEngine = new ScNoteEditEngine( GetEnginePool(), GetEditPool() );
+ mpNoteEngine.reset( new ScNoteEditEngine( GetEnginePool(), GetEditPool() ) );
mpNoteEngine->SetUpdateMode( false );
mpNoteEngine->EnableUndo( false );
mpNoteEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
@@ -1036,7 +1027,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
sc::CopyToDocContext aCxt(*this);
nDestPos = std::min(nDestPos, static_cast<SCTAB>(GetTableCount() - 1));
{ // scope for bulk broadcast
- ScBulkBroadcast aBulkBroadcast( pBASM, SfxHintId::ScDataChanged);
+ ScBulkBroadcast aBulkBroadcast( pBASM.get(), SfxHintId::ScDataChanged);
if (!bResultsOnly)
{
const bool bGlobalNamesToLocal = false;
@@ -1173,33 +1164,26 @@ bool ScDocument::SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCe
return pTab->SetFormulaCells(rPos.Col(), rPos.Row(), rCells);
}
-void ScDocument::SetConsolidateDlgData( const ScConsolidateParam* pData )
+void ScDocument::SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData )
{
- delete pConsolidateDlgData;
-
- if ( pData )
- pConsolidateDlgData = new ScConsolidateParam( *pData );
- else
- pConsolidateDlgData = nullptr;
+ pConsolidateDlgData = std::move(pData);
}
void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew)
{
if (pChangeViewSettings==nullptr)
- pChangeViewSettings = new ScChangeViewSettings;
-
- OSL_ENSURE( pChangeViewSettings, "Oops. No ChangeViewSettings :-( by!" );
+ pChangeViewSettings.reset( new ScChangeViewSettings );
*pChangeViewSettings=rNew;
}
-ScFieldEditEngine* ScDocument::CreateFieldEditEngine()
+std::unique_ptr<ScFieldEditEngine> ScDocument::CreateFieldEditEngine()
{
- ScFieldEditEngine* pNewEditEngine = nullptr;
+ std::unique_ptr<ScFieldEditEngine> pNewEditEngine;
if (!pCacheFieldEditEngine)
{
- pNewEditEngine = new ScFieldEditEngine(
- this, GetEnginePool(), GetEditPool(), false);
+ pNewEditEngine.reset( new ScFieldEditEngine(
+ this, GetEnginePool(), GetEditPool(), false) );
}
else
{
@@ -1211,22 +1195,20 @@ ScFieldEditEngine* ScDocument::CreateFieldEditEngine()
pCacheFieldEditEngine->SetUpdateMode(true);
}
- pNewEditEngine = pCacheFieldEditEngine;
- pCacheFieldEditEngine = nullptr;
+ pNewEditEngine = std::move(pCacheFieldEditEngine);
}
return pNewEditEngine;
}
-void ScDocument::DisposeFieldEditEngine(ScFieldEditEngine*& rpEditEngine)
+void ScDocument::DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine)
{
if (!pCacheFieldEditEngine && rpEditEngine)
{
- pCacheFieldEditEngine = rpEditEngine;
+ pCacheFieldEditEngine = std::move( rpEditEngine );
pCacheFieldEditEngine->Clear();
}
else
- delete rpEditEngine;
- rpEditEngine = nullptr;
+ rpEditEngine.reset();
}
ScRecursionHelper* ScDocument::CreateRecursionHelperInstance()
@@ -1491,10 +1473,9 @@ void ScDocument::GetCellChangeTrackNote( const ScAddress &aCellPos, OUString &aT
}
}
-void ScDocument::SetPreviewFont( SfxItemSet* pFont )
+void ScDocument::SetPreviewFont( std::unique_ptr<SfxItemSet> pFont )
{
- delete pPreviewFont;
- pPreviewFont = pFont;
+ pPreviewFont = std::move(pFont);
}
void ScDocument::SetPreviewSelection( const ScMarkData& rSel )
@@ -1509,7 +1490,7 @@ SfxItemSet* ScDocument::GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab )
{
ScMarkData aSel = GetPreviewSelection();
if ( aSel.IsCellMarked( nCol, nRow ) && aSel.GetFirstSelected() == nTab )
- pRet = pPreviewFont;
+ pRet = pPreviewFont.get();
}
return pRet;
}
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 70afce47b4e3..4dc59a8127e7 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -131,12 +131,10 @@ void ScDocument::SetAllRangeNames(const std::map<OUString, std::unique_ptr<ScRan
{
if (itr->first == STR_GLOBAL_RANGE_NAME)
{
- delete pRangeName;
+ pRangeName.reset();
const ScRangeName *const pName = itr->second.get();
- if (pName->empty())
- pRangeName = nullptr;
- else
- pRangeName = new ScRangeName( *pName );
+ if (!pName->empty())
+ pRangeName.reset( new ScRangeName( *pName ) );
}
else
{
@@ -170,10 +168,10 @@ void ScDocument::GetRangeNameMap(std::map<OUString, ScRangeName*>& aRangeNameMap
}
if (!pRangeName)
{
- pRangeName = new ScRangeName();
+ pRangeName.reset(new ScRangeName());
}
OUString aGlobal(STR_GLOBAL_RANGE_NAME);
- aRangeNameMap.insert(std::pair<OUString, ScRangeName*>(aGlobal, pRangeName));
+ aRangeNameMap.insert(std::pair<OUString, ScRangeName*>(aGlobal, pRangeName.get()));
}
ScRangeName* ScDocument::GetRangeName(SCTAB nTab) const
@@ -187,8 +185,8 @@ ScRangeName* ScDocument::GetRangeName(SCTAB nTab) const
ScRangeName* ScDocument::GetRangeName() const
{
if (!pRangeName)
- pRangeName = new ScRangeName;
- return pRangeName;
+ pRangeName.reset(new ScRangeName);
+ return pRangeName.get();
}
void ScDocument::SetRangeName(SCTAB nTab, ScRangeName* pNew)
@@ -199,13 +197,9 @@ void ScDocument::SetRangeName(SCTAB nTab, ScRangeName* pNew)
return maTabs[nTab]->SetRangeName(pNew);
}
-void ScDocument::SetRangeName( ScRangeName* pNewRangeName )
+void ScDocument::SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName )
{
- if (pRangeName == pNewRangeName)
- return;
-
- delete pRangeName;
- pRangeName = pNewRangeName;
+ pRangeName = std::move(pNewRangeName);
}
bool ScDocument::IsAddressInRangeName( RangeNameScope eScope, ScAddress& rAddress )
@@ -270,7 +264,7 @@ ScRangeData* ScDocument::FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nI
return (pRN ? pRN->findByIndex( nIndex) : nullptr);
}
-void ScDocument::SetDBCollection( ScDBCollection* pNewDBCollection, bool bRemoveAutoFilter )
+void ScDocument::SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection, bool bRemoveAutoFilter )
{
if (pDBCollection && bRemoveAutoFilter)
{
@@ -315,9 +309,7 @@ void ScDocument::SetDBCollection( ScDBCollection* pNewDBCollection, bool bRemove
}
}
- delete pDBCollection;
-
- pDBCollection = pNewDBCollection;
+ pDBCollection = std::move(pNewDBCollection);
}
const ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
@@ -366,13 +358,13 @@ bool ScDocument::HasPivotTable() const
ScDPCollection* ScDocument::GetDPCollection()
{
if (!pDPCollection)
- pDPCollection = new ScDPCollection(this);
- return pDPCollection;
+ pDPCollection.reset( new ScDPCollection(this) );
+ return pDPCollection.get();
}
const ScDPCollection* ScDocument::GetDPCollection() const
{
- return pDPCollection;
+ return pDPCollection.get();
}
ScDPObject* ScDocument::GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
@@ -898,7 +890,7 @@ bool ScDocument::TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const
void ScDocument::AddUnoObject( SfxListener& rObject )
{
if (!pUnoBroadcaster)
- pUnoBroadcaster = new SfxBroadcaster;
+ pUnoBroadcaster.reset( new SfxBroadcaster );
rObject.StartListening( *pUnoBroadcaster );
}
@@ -980,23 +972,20 @@ void ScDocument::AddUnoListenerCall( const uno::Reference<util::XModifyListener>
OSL_ENSURE( bInUnoBroadcast, "AddUnoListenerCall is supposed to be called from BroadcastUno only" );
if ( !pUnoListenerCalls )
- pUnoListenerCalls = new ScUnoListenerCalls;
+ pUnoListenerCalls.reset( new ScUnoListenerCalls );
pUnoListenerCalls->Add( rListener, rEvent );
}
void ScDocument::BeginUnoRefUndo()
{
OSL_ENSURE( !pUnoRefUndoList, "BeginUnoRefUndo twice" );
- delete pUnoRefUndoList;
-
- pUnoRefUndoList = new ScUnoRefList;
+ pUnoRefUndoList.reset( new ScUnoRefList );
}
-ScUnoRefList* ScDocument::EndUnoRefUndo()
+std::unique_ptr<ScUnoRefList> ScDocument::EndUnoRefUndo()
{
- ScUnoRefList* pRet = pUnoRefUndoList;
- pUnoRefUndoList = nullptr;
- return pRet; // Must be deleted by caller!
+ return std::move(pUnoRefUndoList);
+ // Must be deleted by caller!
}
void ScDocument::AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges )
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 8a0753382e94..0b387179e306 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -908,21 +908,19 @@ bool ScDocument::HasDetectiveOperations() const
void ScDocument::AddDetectiveOperation( const ScDetOpData& rData )
{
if (!pDetOpList)
- pDetOpList = new ScDetOpList;
+ pDetOpList.reset(new ScDetOpList);
pDetOpList->Append( new ScDetOpData( rData ) );
}
void ScDocument::ClearDetectiveOperations()
{
- delete pDetOpList; // deletes also the entries
- pDetOpList = nullptr;
+ pDetOpList.reset(); // deletes also the entries
}
-void ScDocument::SetDetOpList(ScDetOpList* pNew)
+void ScDocument::SetDetOpList(std::unique_ptr<ScDetOpList> pNew)
{
- delete pDetOpList; // deletes also the entries
- pDetOpList = pNew;
+ pDetOpList = std::move(pNew);
}
// Comparison of Documents
diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx
index d4b8a41db979..fe414517b429 100644
--- a/sc/source/core/data/documen6.cxx
+++ b/sc/source/core/data/documen6.cxx
@@ -42,7 +42,7 @@ using namespace com::sun::star;
const uno::Reference< i18n::XBreakIterator >& ScDocument::GetBreakIterator()
{
if ( !pScriptTypeData )
- pScriptTypeData = new ScScriptTypeData;
+ pScriptTypeData.reset( new ScScriptTypeData );
if ( !pScriptTypeData->xBreakIter.is() )
{
pScriptTypeData->xBreakIter = i18n::BreakIterator::create( comphelper::getProcessComponentContext() );
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index b35d760137a1..63e14bba26ea 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -129,7 +129,7 @@ void ScDocument::Broadcast( const ScHint& rHint )
return ; // Clipboard or Undo
if ( eHardRecalcState == HardRecalcState::OFF )
{
- ScBulkBroadcast aBulkBroadcast( pBASM, rHint.GetId()); // scoped bulk broadcast
+ ScBulkBroadcast aBulkBroadcast( pBASM.get(), rHint.GetId()); // scoped bulk broadcast
bool bIsBroadcasted = false;
SvtBroadcaster* pBC = GetBroadcaster(rHint.GetAddress());
if ( pBC )
@@ -165,7 +165,7 @@ void ScDocument::BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bB
if (eHardRecalcState == HardRecalcState::OFF)
{
- ScBulkBroadcast aBulkBroadcast( pBASM, nHint); // scoped bulk broadcast
+ ScBulkBroadcast aBulkBroadcast( pBASM.get(), nHint); // scoped bulk broadcast
bool bIsBroadcasted = false;
if (bBroadcastSingleBroadcasters)
@@ -293,7 +293,7 @@ void ScDocument::AreaBroadcast( const ScHint& rHint )
return ; // Clipboard or Undo
if (eHardRecalcState == HardRecalcState::OFF)
{
- ScBulkBroadcast aBulkBroadcast( pBASM, rHint.GetId()); // scoped bulk broadcast
+ ScBulkBroadcast aBulkBroadcast( pBASM.get(), rHint.GetId()); // scoped bulk broadcast
if ( pBASM->AreaBroadcast( rHint ) )
TrackFormulas( rHint.GetId() );
}
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 8cc833062bf8..70b99bdf03e5 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -519,8 +519,7 @@ void ScDocument::Clear( bool bFromDestructor )
delete *it;
maTabs.clear();
- delete pSelectionAttr;
- pSelectionAttr = nullptr;
+ pSelectionAttr.reset();
if (mpDrawLayer)
{
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 7f4649e7c9d2..f9de8433ed13 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -319,15 +319,14 @@ void ScDocument::SetAnonymousDBData(SCTAB nTab, ScDBData* pDBData)
maTabs[nTab]->SetAnonymousDBData(pDBData);
}
-void ScDocument::SetAnonymousDBData( ScDBData* pDBData )
+void ScDocument::SetAnonymousDBData( std::unique_ptr<ScDBData> pDBData )
{
- delete mpAnonymousDBData;
- mpAnonymousDBData = pDBData;
+ mpAnonymousDBData = std::move(pDBData);
}
ScDBData* ScDocument::GetAnonymousDBData()
{
- return mpAnonymousDBData;
+ return mpAnonymousDBData.get();
}
bool ScDocument::ValidTabName( const OUString& rName )
@@ -2449,7 +2448,7 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
/* TODO: handle also sheet-local names */
sc::UpdatedRangeNames::NameIndicesType aUsedGlobalNames( aUsedNames.getUpdatedNames(-1));
- copyUsedNamesToClip(pClipDoc->GetRangeName(), pRangeName, aUsedGlobalNames);
+ copyUsedNamesToClip(pClipDoc->GetRangeName(), pRangeName.get(), aUsedGlobalNames);
}
ScDocument::NumFmtMergeHandler::NumFmtMergeHandler(ScDocument* pDoc, const ScDocument* pSrcDoc) :
@@ -5033,7 +5032,7 @@ void ScDocument::SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr )
maTabs[nTab]->SetPattern( rPos, rAttr );
}
-ScPatternAttr* ScDocument::CreateSelectionPattern( const ScMarkData& rMark, bool bDeep )
+std::unique_ptr<ScPatternAttr> ScDocument::CreateSelectionPattern( const ScMarkData& rMark, bool bDeep )
{
ScMergePatternState aState;
@@ -5061,21 +5060,20 @@ ScPatternAttr* ScDocument::CreateSelectionPattern( const ScMarkData& rMark, bool
OSL_ENSURE( aState.pItemSet, "SelectionPattern Null" );
if (aState.pItemSet)
{
- ScPatternAttr* pPattern = new ScPatternAttr( std::move(aState.pItemSet) );
+ std::unique_ptr<ScPatternAttr> pPattern(new ScPatternAttr( std::move(aState.pItemSet) ));
if (aState.mbValidPatternId)
pPattern->SetKey(aState.mnPatternId);
return pPattern;
}
else
- return new ScPatternAttr( GetPool() ); // empty
+ return std::unique_ptr<ScPatternAttr>(new ScPatternAttr( GetPool() )); // empty
}
const ScPatternAttr* ScDocument::GetSelectionPattern( const ScMarkData& rMark )
{
- delete pSelectionAttr;
pSelectionAttr = CreateSelectionPattern( rMark );
- return pSelectionAttr;
+ return pSelectionAttr.get();
}
void ScDocument::GetSelectionFrame( const ScMarkData& rMark,
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 04cfe1c0bb3e..ec230436ac26 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -462,8 +462,8 @@ void adjustDBRange(formula::FormulaToken* pToken, ScDocument& rNewDoc, const ScD
ScDBCollection* pNewDBCollection = rNewDoc.GetDBCollection();
if (!pNewDBCollection)
{
- pNewDBCollection = new ScDBCollection(&rNewDoc);
- rNewDoc.SetDBCollection(pNewDBCollection);
+ rNewDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new ScDBCollection(&rNewDoc)));
+ pNewDBCollection = rNewDoc.GetDBCollection();
}
ScDBCollection::NamedDBs& aNewNamedDBs = pNewDBCollection->getNamedDBs();
ScDBData* pNewDBData = aNewNamedDBs.findByUpperName(aDBName);