summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/cellsuno.hxx4
-rw-r--r--sc/inc/document.hxx87
-rw-r--r--sc/inc/refreshtimer.hxx4
-rw-r--r--sc/inc/refreshtimerprotector.hxx4
-rw-r--r--sc/inc/textuno.hxx4
-rw-r--r--sc/qa/unit/ucalc.cxx22
-rw-r--r--sc/qa/unit/ucalc_sharedformula.cxx12
-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
-rw-r--r--sc/source/core/tool/chgtrack.cxx11
-rw-r--r--sc/source/core/tool/refreshtimer.cxx6
-rw-r--r--sc/source/filter/inc/XclImpChangeTrack.hxx2
-rw-r--r--sc/source/filter/oox/revisionfragment.cxx2
-rw-r--r--sc/source/filter/xcl97/XclImpChangeTrack.cxx7
-rw-r--r--sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx2
-rw-r--r--sc/source/filter/xml/XMLConsolidationContext.cxx24
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx4
-rw-r--r--sc/source/ui/Accessibility/AccessibleText.cxx6
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx10
-rw-r--r--sc/source/ui/docshell/docfunc.cxx2
-rw-r--r--sc/source/ui/docshell/docsh5.cxx6
-rw-r--r--sc/source/ui/inc/AccessibleText.hxx2
-rw-r--r--sc/source/ui/inc/refundo.hxx3
-rw-r--r--sc/source/ui/undo/refundo.cxx9
-rw-r--r--sc/source/ui/undo/undocell.cxx6
-rw-r--r--sc/source/ui/undo/undodat.cxx14
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx10
-rw-r--r--sc/source/ui/unoobj/docuno.cxx2
-rw-r--r--sc/source/ui/unoobj/textuno.cxx6
-rw-r--r--sc/source/ui/view/cellsh1.cxx2
-rw-r--r--sc/source/ui/view/formatsh.cxx2
38 files changed, 223 insertions, 259 deletions
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx
index 8e0a80668dec..b59a84218f88 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -176,8 +176,8 @@ private:
const SfxItemPropertySet* pPropSet;
ScDocShell* pDocShell;
ScLinkListener* pValueListener;
- ScPatternAttr* pCurrentFlat;
- ScPatternAttr* pCurrentDeep;
+ std::unique_ptr<ScPatternAttr> pCurrentFlat;
+ std::unique_ptr<ScPatternAttr> pCurrentDeep;
SfxItemSet* pCurrentDataSet;
SfxItemSet* pNoDfltCurrentDataSet;
ScMarkData* pMarkData;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 08fa0849ff09..bc05e844812e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -358,48 +358,48 @@ private:
ScCalcConfig maCalcConfig;
SfxUndoManager* mpUndoManager;
- ScFieldEditEngine* mpEditEngine; // uses pEditPool from xPoolHelper
- ScNoteEditEngine* mpNoteEngine; // uses pEditPool from xPoolHelper
+ std::unique_ptr<ScFieldEditEngine> mpEditEngine; // uses pEditPool from xPoolHelper
+ std::unique_ptr<ScNoteEditEngine> mpNoteEngine; // uses pEditPool from xPoolHelper
SfxObjectShell* mpShell;
VclPtr<SfxPrinter> mpPrinter;
VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
ScDrawLayer* mpDrawLayer; // SdrModel
rtl::Reference<XColorList> pColorList;
ScValidationDataList* pValidationList; // validity
- SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
+ SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
TableContainer maTabs;
std::vector<OUString> maTabNames; // for undo document, we need the information tab name <-> index
- mutable ScRangeName* pRangeName;
- ScDBCollection* pDBCollection;
- ScDPCollection* pDPCollection;
+ mutable std::unique_ptr<ScRangeName> pRangeName;
+ std::unique_ptr<ScDBCollection> pDBCollection;
+ std::unique_ptr<ScDPCollection> pDPCollection;
std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock;
- ScPatternAttr* pSelectionAttr; // Attributes of a block
+ std::unique_ptr<ScPatternAttr> pSelectionAttr; // Attributes of a block
ScFormulaCell* pFormulaTree; // formula tree (start)
ScFormulaCell* pEOFormulaTree; // formula tree (end), last cell
ScFormulaCell* pFormulaTrack; // BroadcastTrack (start)
ScFormulaCell* pEOFormulaTrack; // BroadcastTrack (end), last cell
- ScBroadcastAreaSlotMachine* pBASM; // BroadcastAreas
+ std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM; // BroadcastAreas
ScChartListenerCollection* pChartListenerCollection;
- SvMemoryStream* pClipData;
- ScDetOpList* pDetOpList;
- ScChangeTrack* pChangeTrack;
- SfxBroadcaster* pUnoBroadcaster;
- ScUnoListenerCalls* pUnoListenerCalls;
- ScUnoRefList* pUnoRefUndoList;
- ScChangeViewSettings* pChangeViewSettings;
- ScScriptTypeData* pScriptTypeData;
- ScRefreshTimerControl* pRefreshTimerControl;
+ std::unique_ptr<SvMemoryStream> pClipData;
+ std::unique_ptr<ScDetOpList> pDetOpList;
+ std::unique_ptr<ScChangeTrack> pChangeTrack;
+ std::unique_ptr<SfxBroadcaster> pUnoBroadcaster;
+ std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls;
+ std::unique_ptr<ScUnoRefList> pUnoRefUndoList;
+ std::unique_ptr<ScChangeViewSettings> pChangeViewSettings;
+ std::unique_ptr<ScScriptTypeData> pScriptTypeData;
+ std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl;
std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters;
- ScDBData* mpAnonymousDBData;
+ std::unique_ptr<ScDBData> mpAnonymousDBData;
std::unique_ptr<sc::ExternalDataMapper> mpDataMapper;
- ScFieldEditEngine* pCacheFieldEditEngine;
+ std::unique_ptr<ScFieldEditEngine> pCacheFieldEditEngine;
- std::unique_ptr<ScDocProtection> pDocProtection;
- std::unique_ptr<ScClipParam> mpClipParam;
+ std::unique_ptr<ScDocProtection> pDocProtection;
+ std::unique_ptr<ScClipParam> mpClipParam;
std::unique_ptr<ScExternalRefManager> pExternalRefMgr;
- std::unique_ptr<ScMacroManager> mpMacroMgr;
+ std::unique_ptr<ScMacroManager> mpMacroMgr;
// mutable for lazy construction
mutable std::unique_ptr< ScFormulaParserPool >
@@ -415,11 +415,11 @@ private:
ScDocOptions* pDocOptions; // document options
ScExtDocOptions* pExtDocOptions; // for import etc.
std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options
- ScConsolidateParam* pConsolidateDlgData;
+ std::unique_ptr<ScConsolidateParam> pConsolidateDlgData;
ScAutoNameCache* pAutoNameCache; // for automatic name lookup during CompileXML
- SfxItemSet* pPreviewFont; // convert to std::unique_ptr or whatever
+ std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever
ScStyleSheet* pPreviewCellStyle;
ScMarkData maPreviewSelection;
sal_Int64 nUnoObjectId; // counted up for UNO objects
@@ -596,13 +596,13 @@ public:
SC_DLLPUBLIC void GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
void SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
- void SetConsolidateDlgData( const ScConsolidateParam* pData );
- const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData; }
+ void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData );
+ const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); }
void Clear( bool bFromDestructor = false );
- ScFieldEditEngine* CreateFieldEditEngine();
- void DisposeFieldEditEngine(ScFieldEditEngine*& rpEditEngine);
+ std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine();
+ void DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine);
/**
* Get all range names that are local to each table. It only returns
@@ -614,7 +614,7 @@ public:
SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
SC_DLLPUBLIC ScRangeName* GetRangeName() const;
void SetRangeName(SCTAB nTab, ScRangeName* pNew);
- void SetRangeName( ScRangeName* pNewRangeName );
+ void SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName );
bool IsAddressInRangeName( RangeNameScope eScope, ScAddress& rAddress);
/** Find a named expression / range name in either global or a local scope.
@@ -761,8 +761,8 @@ public:
ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }
- SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection;}
- void SetDBCollection( ScDBCollection* pNewDBCollection,
+ SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
+ void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
bool bRemoveAutoFilter = false );
const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const;
ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion);
@@ -825,7 +825,7 @@ public:
used if the corresponding sheet-local anonymous database range is
already used with AutoFilter and range differs. Not stored in document
files. */
- SC_DLLPUBLIC void SetAnonymousDBData(ScDBData* pDBData);
+ SC_DLLPUBLIC void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
SC_DLLPUBLIC ScDBData* GetAnonymousDBData();
SC_DLLPUBLIC SCTAB GetTableCount() const;
@@ -995,7 +995,8 @@ public:
void BeginUnoRefUndo();
bool HasUnoRefUndo() const { return ( pUnoRefUndoList != nullptr ); }
- ScUnoRefList* EndUnoRefUndo(); // must be deleted by caller!
+ SAL_WARN_UNUSED_RESULT
+ std::unique_ptr<ScUnoRefList> EndUnoRefUndo(); // must be deleted by caller!
sal_Int64 GetNewUnoId() { return ++nUnoObjectId; }
void AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );
@@ -1262,8 +1263,8 @@ public:
bool CompileErrorCells(FormulaError nErrCode);
ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache; }
- void SetPreviewFont( SfxItemSet* pFontSet );
- SfxItemSet* GetPreviewFont() { return pPreviewFont; }
+ void SetPreviewFont( std::unique_ptr<SfxItemSet> pFontSet );
+ SfxItemSet* GetPreviewFont() { return pPreviewFont.get(); }
SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
const ScMarkData& GetPreviewSelection() const { return maPreviewSelection; }
void SetPreviewSelection( const ScMarkData& rSel );
@@ -1635,7 +1636,7 @@ public:
SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const;
SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark );
- ScPatternAttr* CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
+ std::unique_ptr<ScPatternAttr> CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
@@ -1661,8 +1662,8 @@ public:
bool HasDetectiveOperations() const;
void AddDetectiveOperation( const ScDetOpData& rData );
void ClearDetectiveOperations();
- ScDetOpList* GetDetOpList() const { return pDetOpList; }
- void SetDetOpList(ScDetOpList* pNew);
+ ScDetOpList* GetDetOpList() const { return pDetOpList.get(); }
+ void SetDetOpList(std::unique_ptr<ScDetOpList> pNew);
bool HasDetectiveObjects(SCTAB nTab) const;
@@ -2035,7 +2036,7 @@ public:
bool IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
void SetNoListening( bool bVal ) { bNoListening = bVal; }
bool GetNoListening() const { return bNoListening; }
- ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM; }
+ ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM.get(); }
SC_DLLPUBLIC ScChartListenerCollection* GetChartListenerCollection() const { return pChartListenerCollection;}
void SetChartListenerCollection( ScChartListenerCollection*,
@@ -2047,7 +2048,7 @@ public:
void SetChartListenerCollectionNeedsUpdate( bool bFlg ) { bChartListenerCollectionNeedsUpdate = bFlg; }
void AddOLEObjectToCollection(const OUString& rName);
- ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings; }
+ ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings.get(); }
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings& rNew);
const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharacters();
@@ -2292,11 +2293,11 @@ public:
void KeyInput(); // TimerDelays etc.
- ScChangeTrack* GetChangeTrack() const { return pChangeTrack; }
+ ScChangeTrack* GetChangeTrack() const { return pChangeTrack.get(); }
//! only for import filter, deletes any existing ChangeTrack via
//! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
- SC_DLLPUBLIC void SetChangeTrack( ScChangeTrack* pTrack );
+ SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack );
void StartChangeTracking();
void EndChangeTracking();
@@ -2318,7 +2319,7 @@ public:
SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
SC_DLLPUBLIC ScNoteEditEngine& GetNoteEngine();
- ScRefreshTimerControl * const & GetRefreshTimerControlAddress() const
+ std::unique_ptr<ScRefreshTimerControl> const & GetRefreshTimerControlAddress() const
{ return pRefreshTimerControl; }
void SetPastingDrawFromOtherDoc( bool bVal )
diff --git a/sc/inc/refreshtimer.hxx b/sc/inc/refreshtimer.hxx
index 93ccc315d0d6..ba390ad7bfd2 100644
--- a/sc/inc/refreshtimer.hxx
+++ b/sc/inc/refreshtimer.hxx
@@ -41,7 +41,7 @@ public:
class ScRefreshTimer : public AutoTimer
{
- ScRefreshTimerControl * const * ppControl;
+ std::unique_ptr<ScRefreshTimerControl> const * ppControl;
public:
ScRefreshTimer();
@@ -53,7 +53,7 @@ public:
bool operator==( const ScRefreshTimer& r ) const;
bool operator!=( const ScRefreshTimer& r ) const;
- void SetRefreshControl( ScRefreshTimerControl * const * pp );
+ void SetRefreshControl( std::unique_ptr<ScRefreshTimerControl> const * pp );
void SetRefreshHandler( const Link<Timer *, void>& rLink );
sal_uLong GetRefreshDelay() const;
void StopRefreshTimer();
diff --git a/sc/inc/refreshtimerprotector.hxx b/sc/inc/refreshtimerprotector.hxx
index 743643a48b28..9a4f41b6e209 100644
--- a/sc/inc/refreshtimerprotector.hxx
+++ b/sc/inc/refreshtimerprotector.hxx
@@ -17,10 +17,10 @@ class ScRefreshTimerControl;
class SC_DLLPUBLIC ScRefreshTimerProtector
{
- ScRefreshTimerControl * const & m_rpControl;
+ std::unique_ptr<ScRefreshTimerControl> const & m_rpControl;
public:
- ScRefreshTimerProtector( ScRefreshTimerControl * const & rp );
+ ScRefreshTimerProtector( std::unique_ptr<ScRefreshTimerControl> const & rp );
~ScRefreshTimerProtector();
};
diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx
index c88a2831261d..0ffbcc483949 100644
--- a/sc/inc/textuno.hxx
+++ b/sc/inc/textuno.hxx
@@ -325,7 +325,7 @@ class ScCellTextData : public SfxListener
protected:
ScDocShell* pDocShell;
ScAddress aCellPos;
- ScFieldEditEngine* pEditEngine;
+ std::unique_ptr<ScFieldEditEngine> pEditEngine;
SvxEditEngineForwarder* pForwarder;
ScCellEditSource* pOriginalSource;
bool bDataValid;
@@ -342,7 +342,7 @@ public:
// helper functions for ScSharedCellEditSource:
virtual SvxTextForwarder* GetTextForwarder();
void UpdateData();
- ScFieldEditEngine* GetEditEngine() { GetTextForwarder(); return pEditEngine; }
+ ScFieldEditEngine* GetEditEngine() { GetTextForwarder(); return pEditEngine.get(); }
ScCellEditSource* GetOriginalSource(); // used as argument for SvxUnoText ctor
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 0f60db22a8ba..59b9d51824a1 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1511,10 +1511,10 @@ void Test::testNamedRange()
m_pDoc->SetValue (0, 0, 0, 101);
- ScRangeName* pNames = new ScRangeName;
- bool bSuccess = insertRangeNames(m_pDoc, pNames, aNames, aNames + SAL_N_ELEMENTS(aNames));
+ std::unique_ptr<ScRangeName> pNames(new ScRangeName);
+ bool bSuccess = insertRangeNames(m_pDoc, pNames.get(), aNames, aNames + SAL_N_ELEMENTS(aNames));
CPPUNIT_ASSERT_MESSAGE("Failed to insert range names.", bSuccess);
- m_pDoc->SetRangeName(pNames);
+ m_pDoc->SetRangeName(std::move(pNames));
ScRangeName* pNewRanges = m_pDoc->GetRangeName();
CPPUNIT_ASSERT(pNewRanges);
@@ -1537,12 +1537,12 @@ void Test::testNamedRange()
ASSERT_DOUBLES_EQUAL_MESSAGE ("calculation failed", 1.0, result);
// Test copy-ability of range names.
- ScRangeName* pCopiedRanges = new ScRangeName(*pNewRanges);
- m_pDoc->SetRangeName(pCopiedRanges);
+ std::unique_ptr<ScRangeName> pCopiedRanges(new ScRangeName(*pNewRanges));
+ m_pDoc->SetRangeName(std::move(pCopiedRanges));
// Make sure the index lookup still works.
for (size_t i = 0; i < SAL_N_ELEMENTS(aNames); ++i)
{
- const ScRangeData* p = pCopiedRanges->findByIndex(aNames[i].mnIndex);
+ const ScRangeData* p = m_pDoc->GetRangeName()->findByIndex(aNames[i].mnIndex);
CPPUNIT_ASSERT_MESSAGE("lookup of range name by index failed with the copied instance.", p);
OUString aName = p->GetName();
CPPUNIT_ASSERT_MESSAGE("wrong range name is retrieved with the copied instance.", aName.equalsAscii(aNames[i].mpName));
@@ -1588,10 +1588,10 @@ void Test::testInsertNameList()
{ "MyRange3", "$Test.$C$1:$C$100", 3 }
};
- ScRangeName* pNames = new ScRangeName;
- bool bSuccess = insertRangeNames(m_pDoc, pNames, aNames, aNames + SAL_N_ELEMENTS(aNames));
+ std::unique_ptr<ScRangeName> pNames(new ScRangeName);
+ bool bSuccess = insertRangeNames(m_pDoc, pNames.get(), aNames, aNames + SAL_N_ELEMENTS(aNames));
CPPUNIT_ASSERT_MESSAGE("Failed to insert range names.", bSuccess);
- m_pDoc->SetRangeName(pNames);
+ m_pDoc->SetRangeName(std::move(pNames));
ScDocFunc& rDocFunc = getDocShell().GetDocFunc();
ScAddress aPos(1,1,0);
@@ -3282,7 +3282,7 @@ void Test::testCopyPaste()
ScRangeData* pGlobal = new ScRangeData( m_pDoc, "global", aAdr);
const OUString aGlobal2Symbol("$Sheet1.$A$1:$A$23");
ScRangeData* pGlobal2 = new ScRangeData( m_pDoc, "global2", aGlobal2Symbol);
- ScRangeName* pGlobalRangeName = new ScRangeName();
+ std::unique_ptr<ScRangeName> pGlobalRangeName(new ScRangeName());
pGlobalRangeName->insert(pGlobal);
pGlobalRangeName->insert(pGlobal2);
ScRangeName* pLocalRangeName1 = new ScRangeName();
@@ -3291,7 +3291,7 @@ void Test::testCopyPaste()
pLocalRangeName1->insert(pLocal3);
pLocalRangeName1->insert(pLocal4);
pLocalRangeName1->insert(pLocal5);
- m_pDoc->SetRangeName(pGlobalRangeName);
+ m_pDoc->SetRangeName(std::move(pGlobalRangeName));
m_pDoc->SetRangeName(0, pLocalRangeName1);
// Add formula to B1.
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index 1d801ee73fc6..0f2c50f9d204 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1473,11 +1473,11 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
aName.mpName = pName;
aName.mpExpr = pExpr1;
aName.mnIndex = 1;
- ScRangeName* pNames = new ScRangeName;
- bool bSuccess = insertRangeNames(m_pDoc, pNames, &aName, &aName + 1);
+ std::unique_ptr<ScRangeName> pNames(new ScRangeName);
+ bool bSuccess = insertRangeNames(m_pDoc, pNames.get(), &aName, &aName + 1);
CPPUNIT_ASSERT(bSuccess);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pNames->size());
- m_pDoc->SetRangeName(pNames);
+ m_pDoc->SetRangeName(std::move(pNames));
// Set values to A1:A4.
m_pDoc->SetValue(ScAddress(0,0,0), 1.0);
@@ -1525,9 +1525,9 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,0,0)));
// Update the range of MyRange.
- pNames = new ScRangeName;
+ pNames.reset(new ScRangeName);
aName.mpExpr = pExpr2;
- bSuccess = insertRangeNames(m_pDoc, pNames, &aName, &aName + 1);
+ bSuccess = insertRangeNames(m_pDoc, pNames.get(), &aName, &aName + 1);
CPPUNIT_ASSERT(bSuccess);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pNames->size());
ScDocFunc& rFunc = getDocShell().GetDocFunc();
@@ -1535,7 +1535,7 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
typedef std::map<OUString, std::unique_ptr<ScRangeName>> NameMapType;
NameMapType aNewNames;
OUString aScope(STR_GLOBAL_RANGE_NAME);
- aNewNames.insert(std::make_pair(aScope, std::unique_ptr<ScRangeName>(pNames)));
+ aNewNames.insert(std::make_pair(aScope, std::move(pNames)));
rFunc.ModifyAllRangeNames(aNewNames);
// Check to make sure all displayed formulas are still good.
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);
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 44f1ab7e2cdc..7045a24a5d9c 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -4437,7 +4437,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
return nullptr;
}
- ScChangeTrack* pClonedTrack = new ScChangeTrack( pDocument );
+ std::unique_ptr<ScChangeTrack> pClonedTrack(new ScChangeTrack( pDocument ));
pClonedTrack->SetTimeNanoSeconds( IsTimeNanoSeconds() );
// clone generated actions
@@ -4517,7 +4517,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
pAction->GetComment(),
eType,
nD,
- pClonedTrack );
+ pClonedTrack.get() );
}
break;
case SC_CAT_MOVE:
@@ -4534,7 +4534,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
pAction->GetDateTimeUTC(),
pAction->GetComment(),
pMove->GetFromRange(),
- pClonedTrack );
+ pClonedTrack.get() );
}
break;
case SC_CAT_CONTENT:
@@ -4687,9 +4687,10 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
pClonedTrack->SetLastSavedActionNumber( pClonedTrack->GetLast()->GetActionNumber() );
}
- pDocument->SetChangeTrack( pClonedTrack );
+ auto tmp = pClonedTrack.get();
+ pDocument->SetChangeTrack( std::move(pClonedTrack) );
- return pClonedTrack;
+ return tmp;
}
void ScChangeTrack::MergeActionState( ScChangeAction* pAct, const ScChangeAction* pOtherAct )
diff --git a/sc/source/core/tool/refreshtimer.cxx b/sc/source/core/tool/refreshtimer.cxx
index 3db86b814be3..72ff16679af6 100644
--- a/sc/source/core/tool/refreshtimer.cxx
+++ b/sc/source/core/tool/refreshtimer.cxx
@@ -28,14 +28,14 @@ void ScRefreshTimerControl::SetAllowRefresh( bool b )
++nBlockRefresh;
}
-ScRefreshTimerProtector::ScRefreshTimerProtector( ScRefreshTimerControl * const & rp )
+ScRefreshTimerProtector::ScRefreshTimerProtector( std::unique_ptr<ScRefreshTimerControl> const & rp )
:
m_rpControl( rp )
{
if ( m_rpControl )
{
m_rpControl->SetAllowRefresh( false );
- // wait for any running refresh in another thread to finnish
+ // wait for any running refresh in another thread to finish
::osl::MutexGuard aGuard( m_rpControl->GetMutex() );
}
}
@@ -84,7 +84,7 @@ bool ScRefreshTimer::operator!=( const ScRefreshTimer& r ) const
return !ScRefreshTimer::operator==( r );
}
-void ScRefreshTimer::SetRefreshControl( ScRefreshTimerControl * const * pp )
+void ScRefreshTimer::SetRefreshControl( std::unique_ptr<ScRefreshTimerControl> const * pp )
{
ppControl = pp;
}
diff --git a/sc/source/filter/inc/XclImpChangeTrack.hxx b/sc/source/filter/inc/XclImpChangeTrack.hxx
index 82e1f2bb74af..9f374472e76c 100644
--- a/sc/source/filter/inc/XclImpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclImpChangeTrack.hxx
@@ -54,7 +54,7 @@ private:
XclImpChTrRecHeader aRecHeader;
OUString sOldUsername;
- ScChangeTrack* pChangeTrack;
+ std::unique_ptr<ScChangeTrack> pChangeTrack;
tools::SvRef<SotStorageStream> xInStrm; // input stream
XclImpStream* pStrm; // stream import class
sal_uInt16 nTabIdCount;
diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx
index bacde362a7ab..bd38fb4ffb0d 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -269,7 +269,7 @@ void RevisionHeadersFragment::finalizeImport()
pCT->SetUser(aSelfUser); // set the default user to the document owner.
pCT->SetUseFixDateTime(false);
- rDoc.SetChangeTrack(pCT.release());
+ rDoc.SetChangeTrack(std::move(pCT));
// Turn on visibility of tracked changes.
ScChangeViewSettings aSettings;
diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
index 797075a8b08d..8a943ce5aa79 100644
--- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
@@ -58,7 +58,7 @@ XclImpChangeTrack::XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStrea
xInStrm->Seek( STREAM_SEEK_TO_BEGIN );
pStrm = new XclImpStream( *xInStrm, GetRoot() );
pStrm->CopyDecrypterFrom( rBookStrm );
- pChangeTrack = new ScChangeTrack( &GetDocRef() );
+ pChangeTrack.reset(new ScChangeTrack( &GetDocRef() ));
sOldUsername = pChangeTrack->GetUser();
pChangeTrack->SetUseFixDateTime( true );
@@ -70,7 +70,7 @@ XclImpChangeTrack::XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStrea
XclImpChangeTrack::~XclImpChangeTrack()
{
- delete pChangeTrack;
+ pChangeTrack.reset();
delete pStrm;
}
@@ -491,8 +491,7 @@ void XclImpChangeTrack::Apply()
pChangeTrack->SetUser( sOldUsername );
pChangeTrack->SetUseFixDateTime( false );
- GetDoc().SetChangeTrack( pChangeTrack );
- pChangeTrack = nullptr;
+ GetDoc().SetChangeTrack( std::move(pChangeTrack) );
ScChangeViewSettings aSettings;
aSettings.SetShowChanges( true );
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
index f3147046c2fd..3144fe1ece3c 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
@@ -887,7 +887,7 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc)
if ( pTrack->GetLast() )
pTrack->SetLastSavedActionNumber(pTrack->GetLast()->GetActionNumber());
- pDoc->SetChangeTrack(pTrack);
+ pDoc->SetChangeTrack(std::unique_ptr<ScChangeTrack>(pTrack));
}
}
diff --git a/sc/source/filter/xml/XMLConsolidationContext.cxx b/sc/source/filter/xml/XMLConsolidationContext.cxx
index cfdbe34a18db..f27b4b1508de 100644
--- a/sc/source/filter/xml/XMLConsolidationContext.cxx
+++ b/sc/source/filter/xml/XMLConsolidationContext.cxx
@@ -77,11 +77,11 @@ void SAL_CALL ScXMLConsolidationContext::endFastElement( sal_Int32 /*nElement*/
{
if (bTargetAddr)
{
- ScConsolidateParam aConsParam;
- aConsParam.nCol = aTargetAddr.Col();
- aConsParam.nRow = aTargetAddr.Row();
- aConsParam.nTab = aTargetAddr.Tab();
- aConsParam.eFunction = eFunction;
+ std::unique_ptr<ScConsolidateParam> pConsParam(new ScConsolidateParam);
+ pConsParam->nCol = aTargetAddr.Col();
+ pConsParam->nRow = aTargetAddr.Row();
+ pConsParam->nTab = aTargetAddr.Tab();
+ pConsParam->eFunction = eFunction;
sal_uInt16 nCount = static_cast<sal_uInt16>(std::min( ScRangeStringConverter::GetTokenCount( sSourceList ), sal_Int32(0xFFFF) ));
ScArea** ppAreas = nCount ? new ScArea*[ nCount ] : nullptr;
@@ -99,7 +99,7 @@ void SAL_CALL ScXMLConsolidationContext::endFastElement( sal_Int32 /*nElement*/
}
}
- aConsParam.SetAreas( ppAreas, nCount );
+ pConsParam->SetAreas( ppAreas, nCount );
// array is copied in SetAreas
for( nIndex = 0; nIndex < nCount; ++nIndex )
@@ -107,19 +107,19 @@ void SAL_CALL ScXMLConsolidationContext::endFastElement( sal_Int32 /*nElement*/
delete[] ppAreas;
}
- aConsParam.bByCol = aConsParam.bByRow = false;
+ pConsParam->bByCol = pConsParam->bByRow = false;
if( IsXMLToken(sUseLabel, XML_COLUMN ) )
- aConsParam.bByCol = true;
+ pConsParam->bByCol = true;
else if( IsXMLToken( sUseLabel, XML_ROW ) )
- aConsParam.bByRow = true;
+ pConsParam->bByRow = true;
else if( IsXMLToken( sUseLabel, XML_BOTH ) )
- aConsParam.bByCol = aConsParam.bByRow = true;
+ pConsParam->bByCol = pConsParam->bByRow = true;
- aConsParam.bReferenceData = bLinkToSource;
+ pConsParam->bReferenceData = bLinkToSource;
ScDocument* pDoc = GetScImport().GetDocument();
if( pDoc )
- pDoc->SetConsolidateDlgData( &aConsParam );
+ pDoc->SetConsolidateDlgData( std::move(pConsParam) );
}
}
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index c85589ac9a73..c6f64e737540 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1137,9 +1137,9 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa
else
{
std::set<OUString> aUsers;
- ScChangeTrack* pTrack = new ScChangeTrack(pDoc, aUsers);
+ std::unique_ptr<ScChangeTrack> pTrack( new ScChangeTrack(pDoc, aUsers) );
pTrack->SetProtection(aPass);
- pDoc->SetChangeTrack(pTrack);
+ pDoc->SetChangeTrack(std::move(pTrack));
}
}
}
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index 4842d7b211c6..66bcc5f4ad88 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -1251,7 +1251,7 @@ SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
{
SfxItemPool* pEnginePool = EditEngine::CreatePool();
pEnginePool->FreezeIdRanges();
- pEditEngine = new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true);
+ pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) );
}
pEditEngine->EnableUndo( false );
if (pDocShell)
@@ -1443,7 +1443,7 @@ ScAccessibleNoteTextData::~ScAccessibleNoteTextData()
mpDocSh->GetDocument().RemoveUnoObject(*this);
if (mpEditEngine)
mpEditEngine->SetNotifyHdl(Link<EENotify&,void>());
- delete mpEditEngine;
+ mpEditEngine.reset();
delete mpForwarder;
}
@@ -1476,7 +1476,7 @@ SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder()
{
SfxItemPool* pEnginePool = EditEngine::CreatePool();
pEnginePool->FreezeIdRanges();
- mpEditEngine = new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true);
+ mpEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) );
}
mpEditEngine->EnableUndo( false );
if (mpDocSh)
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 7e21ade37edd..3a409e774d64 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -163,7 +163,7 @@ bool ScDBDocFunc::RenameDBRange( const OUString& rOld, const OUString& rNew )
ScDBData* pNewData = new ScDBData(rNew, **iterOld);
- ScDBCollection* pUndoColl = new ScDBCollection( *pDocColl );
+ std::unique_ptr<ScDBCollection> pUndoColl( new ScDBCollection( *pDocColl ) );
rDoc.PreprocessDBDataUpdate();
rDBs.erase(iterOld);
@@ -171,7 +171,7 @@ bool ScDBDocFunc::RenameDBRange( const OUString& rOld, const OUString& rNew )
if (!bInserted) // error -> restore old state
{
delete pNewData;
- rDoc.SetDBCollection(pUndoColl); // belongs to the document then
+ rDoc.SetDBCollection(std::move(pUndoColl)); // belongs to the document then
}
rDoc.CompileHybridFormula();
@@ -182,10 +182,10 @@ bool ScDBDocFunc::RenameDBRange( const OUString& rOld, const OUString& rNew )
{
ScDBCollection* pRedoColl = new ScDBCollection( *pDocColl );
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDBData( &rDocShell, pUndoColl, pRedoColl ) );
+ new ScUndoDBData( &rDocShell, pUndoColl.release(), pRedoColl ) );
}
else
- delete pUndoColl;
+ pUndoColl.reset();
aModificator.SetDocumentModified();
SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
@@ -264,7 +264,7 @@ void ScDBDocFunc::ModifyAllDBData( const ScDBCollection& rNewColl, const std::ve
// register target in SBA no longer necessary
rDoc.PreprocessDBDataUpdate();
- rDoc.SetDBCollection( new ScDBCollection( rNewColl ) );
+ rDoc.SetDBCollection( std::unique_ptr<ScDBCollection>(new ScDBCollection( rNewColl )) );
rDoc.CompileHybridFormula();
pOldColl = nullptr;
rDocShell.PostPaint(ScRange(0, 0, 0, MAXCOL, MAXROW, MAXTAB), PaintPartFlags::Grid);
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 1e4e6556c9b3..80c99cef7f40 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5037,7 +5037,7 @@ void ScDocFunc::SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc, SCTA
if (nTab >= 0)
rDoc.SetRangeName( nTab, pNewRanges ); // takes ownership
else
- rDoc.SetRangeName( pNewRanges ); // takes ownership
+ rDoc.SetRangeName( std::unique_ptr<ScRangeName>(pNewRanges) ); // takes ownership
if ( bCompile )
rDoc.CompileHybridFormula();
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index acd05f0ec21b..3eae94341395 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -232,9 +232,9 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe
pNoNameData = aDocument.GetAnonymousDBData();
if (!pNoNameData)
{
- pNoNameData = new ScDBData( STR_DB_LOCAL_NONAME,
- nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, bHasHeader);
- aDocument.SetAnonymousDBData( pNoNameData);
+ aDocument.SetAnonymousDBData( std::unique_ptr<ScDBData>(new ScDBData( STR_DB_LOCAL_NONAME,
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, bHasHeader) ) );
+ pNoNameData = aDocument.GetAnonymousDBData();
}
// ScDocShell::CancelAutoDBRange() would restore the
// sheet-local anonymous DBData from pOldAutoDBRange, unset so
diff --git a/sc/source/ui/inc/AccessibleText.hxx b/sc/source/ui/inc/AccessibleText.hxx
index 940b854b7d13..c36c63f02cab 100644
--- a/sc/source/ui/inc/AccessibleText.hxx
+++ b/sc/source/ui/inc/AccessibleText.hxx
@@ -245,7 +245,7 @@ public:
private:
ScPreviewViewForwarder* mpViewForwarder;
ScPreviewShell* mpViewShell;
- ScEditEngineDefaulter* mpEditEngine;
+ std::unique_ptr<ScEditEngineDefaulter> mpEditEngine;
SvxEditEngineForwarder* mpForwarder;
ScDocShell* mpDocSh;
OUString msText;
diff --git a/sc/source/ui/inc/refundo.hxx b/sc/source/ui/inc/refundo.hxx
index 12d267ce0da9..c3e4466f8733 100644
--- a/sc/source/ui/inc/refundo.hxx
+++ b/sc/source/ui/inc/refundo.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_REFUNDO_HXX
#define INCLUDED_SC_SOURCE_UI_INC_REFUNDO_HXX
+#include <memory>
class ScDocument;
class ScDBCollection;
@@ -41,7 +42,7 @@ private:
ScDetOpList* pDetOpList;
ScChartListenerCollection* pChartListenerCollection;
ScAreaLinkSaveCollection* pAreaLinks;
- ScUnoRefList* pUnoRefs;
+ std::unique_ptr<ScUnoRefList> pUnoRefs;
public:
ScRefUndoData( const ScDocument* pDoc );
diff --git a/sc/source/ui/undo/refundo.cxx b/sc/source/ui/undo/refundo.cxx
index 7488465e63af..857120cc69da 100644
--- a/sc/source/ui/undo/refundo.cxx
+++ b/sc/source/ui/undo/refundo.cxx
@@ -80,7 +80,6 @@ ScRefUndoData::~ScRefUndoData()
delete pDetOpList;
delete pChartListenerCollection;
delete pAreaLinks;
- delete pUnoRefs;
}
void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc )
@@ -140,7 +139,7 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc )
pUnoRefs = const_cast<ScDocument*>(pDoc)->EndUnoRefUndo();
if ( pUnoRefs && pUnoRefs->IsEmpty() )
{
- DELETEZ( pUnoRefs );
+ pUnoRefs.reset();
}
}
}
@@ -148,9 +147,9 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc )
void ScRefUndoData::DoUndo( ScDocument* pDoc, bool bUndoRefFirst )
{
if (pDBCollection)
- pDoc->SetDBCollection( new ScDBCollection(*pDBCollection) );
+ pDoc->SetDBCollection( std::unique_ptr<ScDBCollection>(new ScDBCollection(*pDBCollection)) );
if (pRangeName)
- pDoc->SetRangeName( new ScRangeName(*pRangeName) );
+ pDoc->SetRangeName( std::unique_ptr<ScRangeName>(new ScRangeName(*pRangeName)) );
if (pPrintRanges)
pDoc->RestorePrintRanges(*pPrintRanges);
@@ -163,7 +162,7 @@ void ScRefUndoData::DoUndo( ScDocument* pDoc, bool bUndoRefFirst )
}
if (pDetOpList)
- pDoc->SetDetOpList( new ScDetOpList(*pDetOpList) );
+ pDoc->SetDetOpList( std::unique_ptr<ScDetOpList>(new ScDetOpList(*pDetOpList)) );
// bUndoRefFirst is bSetChartRangeLists
if ( pChartListenerCollection )
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 522914ec9cdc..9e8e09a1bb6f 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -912,7 +912,7 @@ void ScUndoDetective::Undo()
if (bIsDelete)
{
if ( pOldList )
- rDoc.SetDetOpList( new ScDetOpList(*pOldList) );
+ rDoc.SetDetOpList( std::unique_ptr<ScDetOpList>(new ScDetOpList(*pOldList)) );
}
else
{
@@ -999,14 +999,14 @@ void ScUndoRangeNames::DoChange( bool bUndo )
if (mnTab >= 0)
rDoc.SetRangeName( mnTab, new ScRangeName( *pOldRanges ) );
else
- rDoc.SetRangeName( new ScRangeName( *pOldRanges ) );
+ rDoc.SetRangeName( std::unique_ptr<ScRangeName>(new ScRangeName( *pOldRanges )) );
}
else
{
if (mnTab >= 0)
rDoc.SetRangeName( mnTab, new ScRangeName( *pNewRanges ) );
else
- rDoc.SetRangeName( new ScRangeName( *pNewRanges ) );
+ rDoc.SetRangeName( std::unique_ptr<ScRangeName>(new ScRangeName( *pNewRanges )) );
}
rDoc.CompileHybridFormula();
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index d3cef474a5d0..afaed1811b1e 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -656,9 +656,9 @@ void ScUndoSubTotals::Undo()
aParam.nCol2,aParam.nRow2,nTab );
if (xUndoRange)
- rDoc.SetRangeName(new ScRangeName(*xUndoRange));
+ rDoc.SetRangeName(std::unique_ptr<ScRangeName>(new ScRangeName(*xUndoRange)));
if (xUndoDB)
- rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true);
+ rDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new ScDBCollection(*xUndoDB)), true);
SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
if ( nVisTab != nTab )
@@ -796,7 +796,7 @@ void ScUndoQuery::Undo()
InsertDeleteFlags::NONE, false, rDoc);
if (xUndoDB)
- rDoc.SetDBCollection(new ScDBCollection(*xUndoDB ), true);
+ rDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new ScDBCollection(*xUndoDB )), true);
if (!bCopy)
{
@@ -980,7 +980,7 @@ void ScUndoDBData::Undo()
bool bOldAutoCalc = rDoc.GetAutoCalc();
rDoc.SetAutoCalc( false ); // Avoid unnecessary calculations
rDoc.PreprocessDBDataUpdate();
- rDoc.SetDBCollection( new ScDBCollection(*pUndoColl), true );
+ rDoc.SetDBCollection( std::unique_ptr<ScDBCollection>(new ScDBCollection(*pUndoColl)), true );
rDoc.CompileHybridFormula();
rDoc.SetAutoCalc( bOldAutoCalc );
@@ -998,7 +998,7 @@ void ScUndoDBData::Redo()
bool bOldAutoCalc = rDoc.GetAutoCalc();
rDoc.SetAutoCalc( false ); // Avoid unnecessary calculations
rDoc.PreprocessDBDataUpdate();
- rDoc.SetDBCollection( new ScDBCollection(*pRedoColl), true );
+ rDoc.SetDBCollection( std::unique_ptr<ScDBCollection>(new ScDBCollection(*pRedoColl)), true );
rDoc.CompileHybridFormula();
rDoc.SetAutoCalc( bOldAutoCalc );
@@ -1333,9 +1333,9 @@ void ScUndoRepeatDB::Undo()
aBlockEnd.Col(),aBlockEnd.Row(),nTab );
if (xUndoRange)
- rDoc.SetRangeName(new ScRangeName(*xUndoRange));
+ rDoc.SetRangeName(std::unique_ptr<ScRangeName>(new ScRangeName(*xUndoRange)));
if (xUndoDB)
- rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true);
+ rDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new ScDBCollection(*xUndoDB)), true);
SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
if ( nVisTab != nTab )
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 0e6b0ef4e16a..c5830ce06c56 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1485,12 +1485,10 @@ ScCellRangesBase::~ScCellRangesBase()
void ScCellRangesBase::ForgetCurrentAttrs()
{
- delete pCurrentFlat;
- delete pCurrentDeep;
+ pCurrentFlat.reset();
+ pCurrentDeep.reset();
delete pCurrentDataSet;
delete pNoDfltCurrentDataSet;
- pCurrentFlat = nullptr;
- pCurrentDeep = nullptr;
pCurrentDataSet = nullptr;
pNoDfltCurrentDataSet = nullptr;
@@ -1512,7 +1510,7 @@ const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
ScDocument& rDoc = pDocShell->GetDocument();
pCurrentFlat = rDoc.CreateSelectionPattern( *GetMarkData(), false );
}
- return pCurrentFlat;
+ return pCurrentFlat.get();
}
const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
@@ -1524,7 +1522,7 @@ const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
ScDocument& rDoc = pDocShell->GetDocument();
pCurrentDeep = rDoc.CreateSelectionPattern( *GetMarkData() );
}
- return pCurrentDeep;
+ return pCurrentDeep.get();
}
SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 88e1a43dd7b8..c60b03778692 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2328,7 +2328,7 @@ void SAL_CALL ScModelObj::consolidate(
{
const ScConsolidateParam& rParam = xImpl->GetParam();
pDocShell->DoConsolidate( rParam );
- pDocShell->GetDocument().SetConsolidateDlgData( &rParam );
+ pDocShell->GetDocument().SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam>(new ScConsolidateParam(rParam)) );
}
}
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index ee4600b6627c..5d4576636105 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -889,7 +889,7 @@ ScCellTextData::~ScCellTextData()
pDocShell->GetDocument().DisposeFieldEditEngine(pEditEngine);
}
else
- delete pEditEngine;
+ pEditEngine.reset();
delete pForwarder;
@@ -916,7 +916,7 @@ SvxTextForwarder* ScCellTextData::GetTextForwarder()
{
SfxItemPool* pEnginePool = EditEngine::CreatePool();
pEnginePool->FreezeIdRanges();
- pEditEngine = new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true);
+ pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) );
}
// currently, GetPortions doesn't work if UpdateMode is sal_False,
// this will be fixed (in EditEngine) by src600
@@ -1004,7 +1004,7 @@ void ScCellTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
pDocShell = nullptr; // invalid now
DELETEZ( pForwarder );
- DELETEZ( pEditEngine ); // EditEngine uses document's pool
+ pEditEngine.reset(); // EditEngine uses document's pool
}
else if ( nId == SfxHintId::DataChanged )
{
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 93779d60752b..a36745ce4fc8 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1851,7 +1851,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
static_cast<const ScConsolidateItem*>(pItem)->GetData();
pTabViewShell->Consolidate( rParam );
- GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam );
+ GetViewData()->GetDocument()->SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam>(new ScConsolidateParam(rParam)) );
rReq.Done();
}
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index d75204e3546d..364ab9c654ef 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -1775,7 +1775,7 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
ScMarkData aFuncMark( pViewData->GetMarkData() );
ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
- pDoc->SetPreviewFont( aSetItem.GetItemSet().Clone() );
+ pDoc->SetPreviewFont( std::unique_ptr<SfxItemSet>(aSetItem.GetItemSet().Clone()) );
aFuncMark.MarkToMulti();
if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )