diff options
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/inc/undoblk.hxx | 68 | ||||
-rw-r--r-- | sc/source/ui/inc/undodat.hxx | 178 | ||||
-rw-r--r-- | sc/source/ui/inc/undotab.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 60 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk3.cxx | 114 | ||||
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 545 | ||||
-rw-r--r-- | sc/source/ui/undo/undotab.cxx | 56 | ||||
-rw-r--r-- | sc/source/ui/unoobj/funcuno.cxx | 18 |
8 files changed, 454 insertions, 587 deletions
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx index 6dd755ff153a..4be768e47de1 100644 --- a/sc/source/ui/inc/undoblk.hxx +++ b/sc/source/ui/inc/undoblk.hxx @@ -439,7 +439,7 @@ public: private: ScCellMergeOption maOption; bool mbMergeContents; // Merge contents in Redo(). - ScDocument* mpUndoDoc; // when data is merged + std::unique_ptr<ScDocument> mxUndoDoc; // when data is merged SdrUndoAction* mpDrawUndo; void DoChange( bool bUndo ) const; @@ -592,10 +592,9 @@ private: class ScUndoListNames: public ScBlockUndo { public: - ScUndoListNames( ScDocShell* pNewDocShell, - const ScRange& rRange, - ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc ); - virtual ~ScUndoListNames() override; + ScUndoListNames(ScDocShell* pNewDocShell, + const ScRange& rRange, + ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc); virtual void Undo() override; virtual void Redo() override; @@ -605,8 +604,8 @@ public: virtual OUString GetComment() const override; private: - ScDocument* pUndoDoc; - ScDocument* pRedoDoc; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScDocument> xRedoDoc; void DoChange( ScDocument* pSrcDoc ) const; }; @@ -687,9 +686,8 @@ private: class ScUndoRefreshLink: public ScSimpleUndo { public: - ScUndoRefreshLink( ScDocShell* pNewDocShell, - ScDocument* pNewUndoDoc ); - virtual ~ScUndoRefreshLink() override; + ScUndoRefreshLink(ScDocShell* pNewDocShell, + ScDocument* pNewUndoDoc); virtual void Undo() override; virtual void Redo() override; @@ -699,8 +697,8 @@ public: virtual OUString GetComment() const override; private: - ScDocument* pUndoDoc; - ScDocument* pRedoDoc; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScDocument> xRedoDoc; }; class ScUndoEnterMatrix: public ScBlockUndo @@ -784,18 +782,17 @@ private: class ScUndoUpdateAreaLink : public ScSimpleUndo //! also change BlockUndo? { public: - ScUndoUpdateAreaLink( ScDocShell* pShell, - const OUString& rOldD, - const OUString& rOldF, const OUString& rOldO, - const OUString& rOldA, const ScRange& rOldR, - sal_uLong nOldRD, - const OUString& rNewD, - const OUString& rNewF, const OUString& rNewO, - const OUString& rNewA, const ScRange& rNewR, - sal_uLong nNewRD, - ScDocument* pUndo, ScDocument* pRedo, - bool bDoInsert ); - virtual ~ScUndoUpdateAreaLink() override; + ScUndoUpdateAreaLink(ScDocShell* pShell, + const OUString& rOldD, + const OUString& rOldF, const OUString& rOldO, + const OUString& rOldA, const ScRange& rOldR, + sal_uLong nOldRD, + const OUString& rNewD, + const OUString& rNewF, const OUString& rNewO, + const OUString& rNewA, const ScRange& rNewR, + sal_uLong nNewRD, + ScDocument* pUndo, ScDocument* pRedo, + bool bDoInsert); virtual void Undo() override; virtual void Redo() override; @@ -815,8 +812,8 @@ private: OUString aNewOpt; OUString aNewArea; ScRange aNewRange; - ScDocument* pUndoDoc; - ScDocument* pRedoDoc; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScDocument> xRedoDoc; sal_uLong nOldRefresh; sal_uLong nNewRefresh; bool bWithInsert; @@ -937,12 +934,11 @@ private: class ScUndoBorder: public ScBlockUndo { public: - ScUndoBorder( ScDocShell* pNewDocShell, - const ScRangeList& rRangeList, - ScDocument* pNewUndoDoc, - const SvxBoxItem& rNewOuter, - const SvxBoxInfoItem& rNewInner ); - virtual ~ScUndoBorder() override; + ScUndoBorder(ScDocShell* pNewDocShell, + const ScRangeList& rRangeList, + ScDocument* pNewUndoDoc, + const SvxBoxItem& rNewOuter, + const SvxBoxInfoItem& rNewInner); virtual void Undo() override; virtual void Redo() override; @@ -952,10 +948,10 @@ public: virtual OUString GetComment() const override; private: - ScDocument* pUndoDoc; - ScRangeList* pRanges; - SvxBoxItem* pOuter; - SvxBoxInfoItem* pInner; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScRangeList> xRanges; + std::unique_ptr<SvxBoxItem> xOuter; + std::unique_ptr<SvxBoxInfoItem> xInner; }; #endif diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx index ae55159602ff..fdb6f3c27504 100644 --- a/sc/source/ui/inc/undodat.hxx +++ b/sc/source/ui/inc/undodat.hxx @@ -97,11 +97,10 @@ private: class ScUndoOutlineLevel: public ScSimpleUndo { public: - ScUndoOutlineLevel( ScDocShell* pNewDocShell, - SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, - bool bNewColumns, sal_uInt16 nNewLevel ); - virtual ~ScUndoOutlineLevel() override; + ScUndoOutlineLevel(ScDocShell* pNewDocShell, + SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + bool bNewColumns, sal_uInt16 nNewLevel); virtual void Undo() override; virtual void Redo() override; @@ -114,8 +113,8 @@ private: SCCOLROW nStart; SCCOLROW nEnd; SCTAB nTab; - ScDocument* pUndoDoc; - ScOutlineTable* pUndoTable; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; bool bColumns; sal_uInt16 nLevel; }; @@ -123,12 +122,11 @@ private: class ScUndoOutlineBlock: public ScSimpleUndo { public: - ScUndoOutlineBlock( ScDocShell* pNewDocShell, - SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, - SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, - bool bNewShow ); - virtual ~ScUndoOutlineBlock() override; + ScUndoOutlineBlock(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + bool bNewShow); virtual void Undo() override; virtual void Redo() override; @@ -140,19 +138,18 @@ public: private: ScAddress aBlockStart; ScAddress aBlockEnd; - ScDocument* pUndoDoc; - ScOutlineTable* pUndoTable; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; bool bShow; }; class ScUndoRemoveAllOutlines: public ScSimpleUndo { public: - ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell, - SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, - SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ); - virtual ~ScUndoRemoveAllOutlines() override; + ScUndoRemoveAllOutlines(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab); virtual void Undo() override; virtual void Redo() override; @@ -164,18 +161,17 @@ public: private: ScAddress aBlockStart; ScAddress aBlockEnd; - ScDocument* pUndoDoc; - ScOutlineTable* pUndoTable; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; }; class ScUndoAutoOutline: public ScSimpleUndo { public: - ScUndoAutoOutline( ScDocShell* pNewDocShell, - SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, - SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ); - virtual ~ScUndoAutoOutline() override; + ScUndoAutoOutline(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab); virtual void Undo() override; virtual void Redo() override; @@ -187,19 +183,17 @@ public: private: ScAddress aBlockStart; ScAddress aBlockEnd; - ScDocument* pUndoDoc; - ScOutlineTable* pUndoTable; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; }; class ScUndoSubTotals: public ScDBFuncUndo { public: - ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab, - const ScSubTotalParam& rNewParam, SCROW nNewEndY, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, -// ScDBData* pNewData, - ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB ); - virtual ~ScUndoSubTotals() override; + ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab, + const ScSubTotalParam& rNewParam, SCROW nNewEndY, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB); virtual void Undo() override; virtual void Redo() override; @@ -212,11 +206,10 @@ private: SCTAB nTab; ScSubTotalParam aParam; // The original passed parameter SCROW nNewEndRow; // Size of result - ScDocument* pUndoDoc; - ScOutlineTable* pUndoTable; -// ScDBData* pUndoDBData; - ScRangeName* pUndoRange; - ScDBCollection* pUndoDB; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; + std::unique_ptr<ScRangeName> xUndoRange; + std::unique_ptr<ScDBCollection> xUndoDB; }; class ScUndoQuery: public ScDBFuncUndo @@ -239,8 +232,8 @@ private: SdrUndoAction* pDrawUndo; SCTAB nTab; ScQueryParam aQueryParam; - ScDocument* pUndoDoc; - ScDBCollection* pUndoDB; // due to source and target range + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScDBCollection> xUndoDB; // due to source and target range ScRange aOldDest; ScRange aAdvSource; bool bIsAdvanced; @@ -291,12 +284,11 @@ private: class ScUndoImportData: public ScSimpleUndo { public: - ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab, - const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY, - SCCOL nNewFormula, - ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, - ScDBData* pNewUndoData, ScDBData* pNewRedoData ); - virtual ~ScUndoImportData() override; + ScUndoImportData(ScDocShell* pNewDocShell, SCTAB nNewTab, + const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY, + SCCOL nNewFormula, + ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, + ScDBData* pNewUndoData, ScDBData* pNewRedoData); virtual void Undo() override; virtual void Redo() override; @@ -310,10 +302,10 @@ private: ScImportParam aImportParam; SCCOL nEndCol; SCROW nEndRow; - ScDocument* pUndoDoc; - ScDocument* pRedoDoc; - ScDBData* pUndoDBData; - ScDBData* pRedoDBData; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScDocument> xRedoDoc; + std::unique_ptr<ScDBData> xUndoDBData; + std::unique_ptr<ScDBData> xRedoDBData; SCCOL nFormulaCols; bool bRedoFilled; }; @@ -321,13 +313,12 @@ private: class ScUndoRepeatDB: public ScSimpleUndo { public: - ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab, - SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, - SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, - ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB, - const ScRange* pOldQ, const ScRange* pNewQ ); - virtual ~ScUndoRepeatDB() override; + ScUndoRepeatDB(ScDocShell* pNewDocShell, SCTAB nNewTab, + SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, + SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB, + const ScRange* pOldQ, const ScRange* pNewQ); virtual void Undo() override; virtual void Redo() override; @@ -341,10 +332,10 @@ private: ScAddress aBlockEnd; SCROW nNewEndRow; ScAddress aCursorPos; - ScDocument* pUndoDoc; - ScOutlineTable* pUndoTable; - ScRangeName* pUndoRange; - ScDBCollection* pUndoDB; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScOutlineTable> xUndoTable; + std::unique_ptr<ScRangeName> xUndoRange; + std::unique_ptr<ScDBCollection> xUndoDB; ScRange aOldQuery; ScRange aNewQuery; bool bQuerySize; @@ -353,11 +344,10 @@ private: class ScUndoDataPilot: public ScSimpleUndo { public: - ScUndoDataPilot( ScDocShell* pNewDocShell, - ScDocument* pOldDoc, ScDocument* pNewDoc, - const ScDPObject* pOldObj, const ScDPObject* pNewObj, - bool bMove ); - virtual ~ScUndoDataPilot() override; + ScUndoDataPilot(ScDocShell* pNewDocShell, + ScDocument* pOldDoc, ScDocument* pNewDoc, + const ScDPObject* pOldObj, const ScDPObject* pNewObj, + bool bMove); virtual void Undo() override; virtual void Redo() override; @@ -367,22 +357,21 @@ public: virtual OUString GetComment() const override; private: - ScDocument* pOldUndoDoc; - ScDocument* pNewUndoDoc; - ScDPObject* pOldDPObject; - ScDPObject* pNewDPObject; + std::unique_ptr<ScDocument> xOldUndoDoc; + std::unique_ptr<ScDocument> xNewUndoDoc; + std::unique_ptr<ScDPObject> xOldDPObject; + std::unique_ptr<ScDPObject> xNewDPObject; bool bAllowMove; }; class ScUndoConsolidate: public ScSimpleUndo { public: - ScUndoConsolidate( ScDocShell* pNewDocShell, - const ScArea& rArea, const ScConsolidateParam& rPar, - ScDocument* pNewUndoDoc, bool bReference, - SCROW nInsCount, ScOutlineTable* pTab, - ScDBData* pData ); - virtual ~ScUndoConsolidate() override; + ScUndoConsolidate(ScDocShell* pNewDocShell, + const ScArea& rArea, const ScConsolidateParam& rPar, + ScDocument* pNewUndoDoc, bool bReference, + SCROW nInsCount, ScOutlineTable* pTab, + ScDBData* pData); virtual void Undo() override; virtual void Redo() override; @@ -393,12 +382,12 @@ public: private: ScArea aDestArea; - ScDocument* pUndoDoc; + std::unique_ptr<ScDocument> xUndoDoc; ScConsolidateParam aParam; bool bInsRef; SCSIZE nInsertCount; - ScOutlineTable* pUndoTab; - ScDBData* pUndoData; + std::unique_ptr<ScOutlineTable> xUndoTab; + std::unique_ptr<ScDBData> xUndoData; }; class ScUndoChartData: public ScSimpleUndo @@ -436,16 +425,13 @@ private: class ScUndoDataForm: public ScBlockUndo { public: - ScUndoDataForm( ScDocShell* pNewDocShell, - SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, - SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, - const ScMarkData& rMark, - ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, - InsertDeleteFlags nNewFlags, - ScRefUndoData* pRefData - ); - virtual ~ScUndoDataForm() override; - + ScUndoDataForm(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + const ScMarkData& rMark, + ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, + InsertDeleteFlags nNewFlags, + ScRefUndoData* pRefData); virtual void Undo() override; virtual void Redo() override; virtual void Repeat(SfxRepeatTarget& rTarget) override; @@ -454,12 +440,12 @@ public: virtual OUString GetComment() const override; private: - std::unique_ptr<ScMarkData> mpMarkData; - ScDocument* pUndoDoc; - ScDocument* pRedoDoc; + std::unique_ptr<ScMarkData> mxMarkData; + std::unique_ptr<ScDocument> xUndoDoc; + std::unique_ptr<ScDocument> xRedoDoc; InsertDeleteFlags nFlags; - ScRefUndoData* pRefUndoData; - ScRefUndoData* pRefRedoData; + std::unique_ptr<ScRefUndoData> xRefUndoData; + std::unique_ptr<ScRefUndoData> xRefRedoData; sal_uLong nStartChangeAction; sal_uLong nEndChangeAction; bool bRedoFilled; diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx index 214881479dce..662dd0358c1b 100644 --- a/sc/source/ui/inc/undotab.hxx +++ b/sc/source/ui/inc/undotab.hxx @@ -271,7 +271,7 @@ public: private: SCTAB nTab; SCTAB nCount; - ScDocument* pRedoDoc; + std::unique_ptr<ScDocument> xRedoDoc; SdrUndoAction* pDrawUndo; void DoChange() const; diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 3bbe625b206c..46b5d47fa3ee 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1432,20 +1432,14 @@ bool ScUndoDragDrop::CanRepeat(SfxRepeatTarget& /* rTarget */) const return false; // not possible } -// Insert list containing range names -// (Insert|Name|Insert =>[List]) -ScUndoListNames::ScUndoListNames( ScDocShell* pNewDocShell, const ScRange& rRange, - ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc ) : - ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ), - pUndoDoc( pNewUndoDoc ), - pRedoDoc( pNewRedoDoc ) -{ -} - -ScUndoListNames::~ScUndoListNames() +// Insert list containing range names +// (Insert|Name|Insert =>[List]) +ScUndoListNames::ScUndoListNames(ScDocShell* pNewDocShell, const ScRange& rRange, + ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc) + : ScBlockUndo(pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT) + , xUndoDoc(pNewUndoDoc) + , xRedoDoc(pNewRedoDoc) { - delete pUndoDoc; - delete pRedoDoc; } OUString ScUndoListNames::GetComment() const @@ -1469,14 +1463,14 @@ void ScUndoListNames::DoChange( ScDocument* pSrcDoc ) const void ScUndoListNames::Undo() { BeginUndo(); - DoChange(pUndoDoc); + DoChange(xUndoDoc.get()); EndUndo(); } void ScUndoListNames::Redo() { BeginRedo(); - DoChange(pRedoDoc); + DoChange(xRedoDoc.get()); EndRedo(); } @@ -2258,23 +2252,15 @@ static ScRange lcl_TotalRange( const ScRangeList& rRanges ) return aTotal; } -ScUndoBorder::ScUndoBorder( ScDocShell* pNewDocShell, - const ScRangeList& rRangeList, ScDocument* pNewUndoDoc, - const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner ) : - ScBlockUndo( pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE ), - pUndoDoc( pNewUndoDoc ) -{ - pRanges = new ScRangeList(rRangeList); - pOuter = new SvxBoxItem(rNewOuter); - pInner = new SvxBoxInfoItem(rNewInner); -} - -ScUndoBorder::~ScUndoBorder() +ScUndoBorder::ScUndoBorder(ScDocShell* pNewDocShell, + const ScRangeList& rRangeList, ScDocument* pNewUndoDoc, + const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner) + : ScBlockUndo(pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE) + , xUndoDoc(pNewUndoDoc) { - delete pUndoDoc; - delete pRanges; - delete pOuter; - delete pInner; + xRanges.reset(new ScRangeList(rRangeList)); + xOuter.reset(new SvxBoxItem(rNewOuter)); + xInner.reset(new SvxBoxInfoItem(rNewInner)); } OUString ScUndoBorder::GetComment() const @@ -2288,8 +2274,8 @@ void ScUndoBorder::Undo() ScDocument& rDoc = pDocShell->GetDocument(); ScMarkData aMarkData; - aMarkData.MarkFromRangeList( *pRanges, false ); - pUndoDoc->CopyToDocument(aBlockRange, InsertDeleteFlags::ATTRIB, true, rDoc, &aMarkData); + aMarkData.MarkFromRangeList(*xRanges, false); + xUndoDoc->CopyToDocument(aBlockRange, InsertDeleteFlags::ATTRIB, true, rDoc, &aMarkData); pDocShell->PostPaint( aBlockRange, PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE ); EndUndo(); @@ -2300,20 +2286,20 @@ void ScUndoBorder::Redo() BeginRedo(); ScDocument& rDoc = pDocShell->GetDocument(); // call function at docfunc - size_t nCount = pRanges->size(); + size_t nCount = xRanges->size(); for (size_t i = 0; i < nCount; ++i ) { - ScRange aRange = *(*pRanges)[i]; + ScRange aRange = *(*xRanges)[i]; SCTAB nTab = aRange.aStart.Tab(); ScMarkData aMark; aMark.SetMarkArea( aRange ); aMark.SelectTable( nTab, true ); - rDoc.ApplySelectionFrame( aMark, pOuter, pInner ); + rDoc.ApplySelectionFrame(aMark, xOuter.get(), xInner.get()); } for (size_t i = 0; i < nCount; ++i) - pDocShell->PostPaint( *(*pRanges)[i], PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE ); + pDocShell->PostPaint( *(*xRanges)[i], PaintPartFlags::Grid, SC_PF_LINES | SC_PF_TESTMERGE ); EndRedo(); } diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 5fe6c5ebd3b6..d5690e250baa 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -634,19 +634,18 @@ bool ScUndoAutoFill::CanRepeat(SfxRepeatTarget& rTarget) const return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr; } -ScUndoMerge::ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption, - bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo ) - : ScSimpleUndo( pNewDocShell ), - maOption(rOption), - mbMergeContents( bMergeContents ), - mpUndoDoc( pUndoDoc ), - mpDrawUndo( pDrawUndo ) +ScUndoMerge::ScUndoMerge(ScDocShell* pNewDocShell, const ScCellMergeOption& rOption, + bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo) + : ScSimpleUndo(pNewDocShell) + , maOption(rOption) + , mbMergeContents(bMergeContents) + , mxUndoDoc(pUndoDoc) + , mpDrawUndo(pDrawUndo) { } ScUndoMerge::~ScUndoMerge() { - delete mpUndoDoc; DeleteSdrUndoAction( mpDrawUndo ); } @@ -697,7 +696,7 @@ void ScUndoMerge::DoChange( bool bUndo ) const } // undo -> copy back deleted contents - if (bUndo && mpUndoDoc) + if (bUndo && mxUndoDoc) { // If there are note captions to be deleted during Undo they were // kept or moved during the merge and copied to the Undo document @@ -706,7 +705,7 @@ void ScUndoMerge::DoChange( bool bUndo ) const // instead of deleting it. rDoc.DeleteAreaTab( aRange, InsertDeleteFlags::CONTENTS | InsertDeleteFlags::NOCAPTIONS | InsertDeleteFlags::FORGETCAPTIONS ); - mpUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL|InsertDeleteFlags::NOCAPTIONS, false, rDoc); + mxUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL|InsertDeleteFlags::NOCAPTIONS, false, rDoc); } // redo -> merge contents again @@ -1364,18 +1363,11 @@ bool ScUndoRefConversion::CanRepeat(SfxRepeatTarget& rTarget) const return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr; } -ScUndoRefreshLink::ScUndoRefreshLink( ScDocShell* pNewDocShell, - ScDocument* pNewUndoDoc ) - : ScSimpleUndo( pNewDocShell ), - pUndoDoc( pNewUndoDoc ), - pRedoDoc( nullptr ) -{ -} - -ScUndoRefreshLink::~ScUndoRefreshLink() +ScUndoRefreshLink::ScUndoRefreshLink(ScDocShell* pNewDocShell, + ScDocument* pNewUndoDoc) + : ScSimpleUndo(pNewDocShell) + , xUndoDoc(pNewUndoDoc) { - delete pUndoDoc; - delete pRedoDoc; } OUString ScUndoRefreshLink::GetComment() const @@ -1387,42 +1379,42 @@ void ScUndoRefreshLink::Undo() { BeginUndo(); - bool bMakeRedo = !pRedoDoc; + bool bMakeRedo = !xRedoDoc; if (bMakeRedo) - pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); + xRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO)); bool bFirst = true; ScDocument& rDoc = pDocShell->GetDocument(); SCTAB nCount = rDoc.GetTableCount(); for (SCTAB nTab=0; nTab<nCount; nTab++) - if (pUndoDoc->HasTable(nTab)) + if (xUndoDoc->HasTable(nTab)) { ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab); if (bMakeRedo) { if (bFirst) - pRedoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); + xRedoDoc->InitUndo(&rDoc, nTab, nTab, true, true); else - pRedoDoc->AddUndoTab( nTab, nTab, true, true ); + xRedoDoc->AddUndoTab(nTab, nTab, true, true); bFirst = false; - rDoc.CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *pRedoDoc); - pRedoDoc->SetLink( nTab, - rDoc.GetLinkMode(nTab), - rDoc.GetLinkDoc(nTab), - rDoc.GetLinkFlt(nTab), - rDoc.GetLinkOpt(nTab), - rDoc.GetLinkTab(nTab), - rDoc.GetLinkRefreshDelay(nTab) ); - pRedoDoc->SetTabBgColor( nTab, rDoc.GetTabBgColor(nTab) ); + rDoc.CopyToDocument(aRange, InsertDeleteFlags::ALL, false, *xRedoDoc); + xRedoDoc->SetLink(nTab, + rDoc.GetLinkMode(nTab), + rDoc.GetLinkDoc(nTab), + rDoc.GetLinkFlt(nTab), + rDoc.GetLinkOpt(nTab), + rDoc.GetLinkTab(nTab), + rDoc.GetLinkRefreshDelay(nTab)); + xRedoDoc->SetTabBgColor( nTab, rDoc.GetTabBgColor(nTab) ); } rDoc.DeleteAreaTab( aRange,InsertDeleteFlags::ALL ); - pUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc); - rDoc.SetLink( nTab, pUndoDoc->GetLinkMode(nTab), pUndoDoc->GetLinkDoc(nTab), - pUndoDoc->GetLinkFlt(nTab), pUndoDoc->GetLinkOpt(nTab), - pUndoDoc->GetLinkTab(nTab), - pUndoDoc->GetLinkRefreshDelay(nTab) ); - rDoc.SetTabBgColor( nTab, pUndoDoc->GetTabBgColor(nTab) ); + xUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc); + rDoc.SetLink(nTab, xUndoDoc->GetLinkMode(nTab), xUndoDoc->GetLinkDoc(nTab), + xUndoDoc->GetLinkFlt(nTab), xUndoDoc->GetLinkOpt(nTab), + xUndoDoc->GetLinkTab(nTab), + xUndoDoc->GetLinkRefreshDelay(nTab) ); + rDoc.SetTabBgColor(nTab, xUndoDoc->GetTabBgColor(nTab)); } pDocShell->PostPaintGridAll(); @@ -1433,27 +1425,27 @@ void ScUndoRefreshLink::Undo() void ScUndoRefreshLink::Redo() { - OSL_ENSURE(pRedoDoc, "No RedoDoc for ScUndoRefreshLink::Redo"); + OSL_ENSURE(xRedoDoc, "No RedoDoc for ScUndoRefreshLink::Redo"); BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); SCTAB nCount = rDoc.GetTableCount(); for (SCTAB nTab=0; nTab<nCount; nTab++) - if (pRedoDoc->HasTable(nTab)) + if (xRedoDoc->HasTable(nTab)) { ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab); rDoc.DeleteAreaTab( aRange, InsertDeleteFlags::ALL ); - pRedoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc); - rDoc.SetLink( nTab, - pRedoDoc->GetLinkMode(nTab), - pRedoDoc->GetLinkDoc(nTab), - pRedoDoc->GetLinkFlt(nTab), - pRedoDoc->GetLinkOpt(nTab), - pRedoDoc->GetLinkTab(nTab), - pRedoDoc->GetLinkRefreshDelay(nTab) ); - rDoc.SetTabBgColor( nTab, pRedoDoc->GetTabBgColor(nTab) ); + xRedoDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL, false, rDoc); + rDoc.SetLink(nTab, + xRedoDoc->GetLinkMode(nTab), + xRedoDoc->GetLinkDoc(nTab), + xRedoDoc->GetLinkFlt(nTab), + xRedoDoc->GetLinkOpt(nTab), + xRedoDoc->GetLinkTab(nTab), + xRedoDoc->GetLinkRefreshDelay(nTab) ); + rDoc.SetTabBgColor(nTab, xRedoDoc->GetTabBgColor(nTab)); } pDocShell->PostPaintGridAll(); @@ -1632,8 +1624,8 @@ ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell, aNewOpt ( rNewO ), aNewArea ( rNewA ), aNewRange ( rNewR ), - pUndoDoc ( pUndo ), - pRedoDoc ( pRedo ), + xUndoDoc ( pUndo ), + xRedoDoc ( pRedo ), nOldRefresh ( nOldRD ), nNewRefresh ( nNewRD ), bWithInsert ( bDoInsert ) @@ -1641,12 +1633,6 @@ ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell, OSL_ENSURE( aOldRange.aStart == aNewRange.aStart, "AreaLink moved ?" ); } -ScUndoUpdateAreaLink::~ScUndoUpdateAreaLink() -{ - delete pUndoDoc; - delete pRedoDoc; -} - OUString ScUndoUpdateAreaLink::GetComment() const { return ScGlobal::GetRscString( STR_UNDO_UPDATELINK ); //! own text ?? @@ -1666,13 +1652,13 @@ void ScUndoUpdateAreaLink::DoChange( const bool bUndo ) const { rDoc.FitBlock( aNewRange, aOldRange ); rDoc.DeleteAreaTab( aOldRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); - pUndoDoc->UndoToDocument( aOldRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc ); + xUndoDoc->UndoToDocument(aOldRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); } else { ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) ); rDoc.DeleteAreaTab( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); - pUndoDoc->CopyToDocument( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc ); + xUndoDoc->CopyToDocument(aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); } } else @@ -1681,13 +1667,13 @@ void ScUndoUpdateAreaLink::DoChange( const bool bUndo ) const { rDoc.FitBlock( aOldRange, aNewRange ); rDoc.DeleteAreaTab( aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); - pRedoDoc->CopyToDocument( aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc ); + xRedoDoc->CopyToDocument(aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); } else { ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) ); rDoc.DeleteAreaTab( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); - pRedoDoc->CopyToDocument( aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc ); + xRedoDoc->CopyToDocument(aCopyRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); } } diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index b6527a5faddd..372033807d84 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -222,22 +222,16 @@ bool ScUndoMakeOutline::CanRepeat(SfxRepeatTarget& rTarget) const ScUndoOutlineLevel::ScUndoOutlineLevel( ScDocShell* pNewDocShell, SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab, ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, - bool bNewColumns, sal_uInt16 nNewLevel ) : - ScSimpleUndo( pNewDocShell ), - nStart( nNewStart ), - nEnd( nNewEnd ), - nTab( nNewTab ), - pUndoDoc( pNewUndoDoc ), - pUndoTable( pNewUndoTab ), - bColumns( bNewColumns ), - nLevel( nNewLevel ) -{ -} - -ScUndoOutlineLevel::~ScUndoOutlineLevel() + bool bNewColumns, sal_uInt16 nNewLevel ) + : ScSimpleUndo(pNewDocShell) + , nStart(nNewStart) + , nEnd(nNewEnd) + , nTab(nNewTab) + , xUndoDoc(pNewUndoDoc) + , xUndoTable(pNewUndoTab) + , bColumns(bNewColumns) + , nLevel(nNewLevel) { - delete pUndoDoc; - delete pUndoTable; } OUString ScUndoOutlineLevel::GetComment() const @@ -254,15 +248,15 @@ void ScUndoOutlineLevel::Undo() // Original Outline table - rDoc.SetOutlineTable( nTab, pUndoTable ); + rDoc.SetOutlineTable(nTab, xUndoTable.get()); // Original column/row status if (bColumns) - pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, nTab, + xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, nTab, static_cast<SCCOL>(nEnd), MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); else - pUndoDoc->CopyToDocument(0, nStart, nTab, MAXCOL, nEnd, nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(0, nStart, nTab, MAXCOL, nEnd, nTab, InsertDeleteFlags::NONE, false, rDoc); rDoc.UpdatePageBreaks( nTab ); @@ -313,18 +307,12 @@ ScUndoOutlineBlock::ScUndoOutlineBlock( ScDocShell* pNewDocShell, ScSimpleUndo( pNewDocShell ), aBlockStart( nStartX, nStartY, nStartZ ), aBlockEnd( nEndX, nEndY, nEndZ ), - pUndoDoc( pNewUndoDoc ), - pUndoTable( pNewUndoTab ), + xUndoDoc(pNewUndoDoc), + xUndoTable(pNewUndoTab), bShow( bNewShow ) { } -ScUndoOutlineBlock::~ScUndoOutlineBlock() -{ - delete pUndoDoc; - delete pUndoTable; -} - OUString ScUndoOutlineBlock::GetComment() const { // "Show outline" "Hide outline" return bShow ? @@ -341,7 +329,7 @@ void ScUndoOutlineBlock::Undo() SCTAB nTab = aBlockStart.Tab(); // Original Outline table - rDoc.SetOutlineTable( nTab, pUndoTable ); + rDoc.SetOutlineTable(nTab, xUndoTable.get()); // Original column/row status SCCOLROW nStartCol = aBlockStart.Col(); @@ -352,15 +340,15 @@ void ScUndoOutlineBlock::Undo() if (!bShow) { // Size of the hidden blocks size_t nLevel; - pUndoTable->GetColArray().FindTouchedLevel( nStartCol, nEndCol, nLevel ); - pUndoTable->GetColArray().ExtendBlock( nLevel, nStartCol, nEndCol ); - pUndoTable->GetRowArray().FindTouchedLevel( nStartRow, nEndRow, nLevel ); - pUndoTable->GetRowArray().ExtendBlock( nLevel, nStartRow, nEndRow ); + xUndoTable->GetColArray().FindTouchedLevel(nStartCol, nEndCol, nLevel); + xUndoTable->GetColArray().ExtendBlock(nLevel, nStartCol, nEndCol); + xUndoTable->GetRowArray().FindTouchedLevel(nStartRow, nEndRow, nLevel); + xUndoTable->GetRowArray().ExtendBlock(nLevel, nStartRow, nEndRow); } - pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, + xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); - pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); rDoc.UpdatePageBreaks( nTab ); @@ -408,22 +396,16 @@ bool ScUndoOutlineBlock::CanRepeat(SfxRepeatTarget& rTarget) const return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr; } -ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell, +ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines(ScDocShell* pNewDocShell, SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) : - ScSimpleUndo( pNewDocShell ), - aBlockStart( nStartX, nStartY, nStartZ ), - aBlockEnd( nEndX, nEndY, nEndZ ), - pUndoDoc( pNewUndoDoc ), - pUndoTable( pNewUndoTab ) -{ -} - -ScUndoRemoveAllOutlines::~ScUndoRemoveAllOutlines() + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab) + : ScSimpleUndo(pNewDocShell) + , aBlockStart(nStartX, nStartY, nStartZ) + , aBlockEnd(nEndX, nEndY, nEndZ) + , xUndoDoc(pNewUndoDoc) + , xUndoTable(pNewUndoTab) { - delete pUndoDoc; - delete pUndoTable; } OUString ScUndoRemoveAllOutlines::GetComment() const @@ -440,7 +422,7 @@ void ScUndoRemoveAllOutlines::Undo() SCTAB nTab = aBlockStart.Tab(); // Original Outline table - rDoc.SetOutlineTable( nTab, pUndoTable ); + rDoc.SetOutlineTable(nTab, xUndoTable.get()); // Original column/row status SCCOL nStartCol = aBlockStart.Col(); @@ -448,8 +430,8 @@ void ScUndoRemoveAllOutlines::Undo() SCROW nStartRow = aBlockStart.Row(); SCROW nEndRow = aBlockEnd.Row(); - pUndoDoc->CopyToDocument(nStartCol, 0, nTab, nEndCol, MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); - pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(nStartCol, 0, nTab, nEndCol, MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); rDoc.UpdatePageBreaks( nTab ); @@ -493,24 +475,18 @@ bool ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr; } -ScUndoAutoOutline::ScUndoAutoOutline( ScDocShell* pNewDocShell, - SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, - SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) : - ScSimpleUndo( pNewDocShell ), - aBlockStart( nStartX, nStartY, nStartZ ), - aBlockEnd( nEndX, nEndY, nEndZ ), - pUndoDoc( pNewUndoDoc ), - pUndoTable( pNewUndoTab ) +ScUndoAutoOutline::ScUndoAutoOutline(ScDocShell* pNewDocShell, + SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, + SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab) + : ScSimpleUndo(pNewDocShell) + , aBlockStart(nStartX, nStartY, nStartZ) + , aBlockEnd(nEndX, nEndY, nEndZ) + , xUndoDoc(pNewUndoDoc) + , xUndoTable(pNewUndoTab) { } -ScUndoAutoOutline::~ScUndoAutoOutline() -{ - delete pUndoDoc; - delete pUndoTable; -} - OUString ScUndoAutoOutline::GetComment() const { return ScGlobal::GetRscString( STR_UNDO_AUTOOUTLINE ); @@ -525,22 +501,22 @@ void ScUndoAutoOutline::Undo() SCTAB nTab = aBlockStart.Tab(); // Original outline table - rDoc.SetOutlineTable( nTab, pUndoTable ); + rDoc.SetOutlineTable(nTab, xUndoTable.get()); // Original column/row status - if (pUndoDoc && pUndoTable) + if (xUndoDoc && xUndoTable) { SCCOLROW nStartCol; SCCOLROW nStartRow; SCCOLROW nEndCol; SCCOLROW nEndRow; - pUndoTable->GetColArray().GetRange( nStartCol, nEndCol ); - pUndoTable->GetRowArray().GetRange( nStartRow, nEndRow ); + xUndoTable->GetColArray().GetRange(nStartCol, nEndCol); + xUndoTable->GetRowArray().GetRange(nStartRow, nEndRow); - pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, + xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); - pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); pViewShell->UpdateScrollBars(); } @@ -596,30 +572,22 @@ bool ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr; } -ScUndoSubTotals::ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab, - const ScSubTotalParam& rNewParam, SCROW nNewEndY, - ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, - ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB ) : - ScDBFuncUndo( pNewDocShell, ScRange( rNewParam.nCol1, rNewParam.nRow1, nNewTab, - rNewParam.nCol2, rNewParam.nRow2, nNewTab ) ), - nTab( nNewTab ), - aParam( rNewParam ), - nNewEndRow( nNewEndY ), - pUndoDoc( pNewUndoDoc ), - pUndoTable( pNewUndoTab ), - pUndoRange( pNewUndoRange ), - pUndoDB( pNewUndoDB ) +ScUndoSubTotals::ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab, + const ScSubTotalParam& rNewParam, SCROW nNewEndY, + ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, + ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB) + : ScDBFuncUndo(pNewDocShell, ScRange(rNewParam.nCol1, rNewParam.nRow1, nNewTab, + rNewParam.nCol2, rNewParam.nRow2, nNewTab)) + , nTab(nNewTab) + , aParam(rNewParam) + , nNewEndRow(nNewEndY) + , xUndoDoc(pNewUndoDoc) + , xUndoTable(pNewUndoTab) + , xUndoRange(pNewUndoRange) + , xUndoDB(pNewUndoDB) { } -ScUndoSubTotals::~ScUndoSubTotals() -{ - delete pUndoDoc; - delete pUndoTable; - delete pUndoRange; - delete pUndoDB; -} - OUString ScUndoSubTotals::GetComment() const { // "Subtotals" return ScGlobal::GetRscString( STR_UNDO_SUBTOTALS ); @@ -642,22 +610,22 @@ void ScUndoSubTotals::Undo() } // Original Outline table - rDoc.SetOutlineTable( nTab, pUndoTable ); + rDoc.SetOutlineTable(nTab, xUndoTable.get()); // Original column/row status - if (pUndoTable) + if (xUndoTable) { SCCOLROW nStartCol; SCCOLROW nStartRow; SCCOLROW nEndCol; SCCOLROW nEndRow; - pUndoTable->GetColArray().GetRange( nStartCol, nEndCol ); - pUndoTable->GetRowArray().GetRange( nStartRow, nEndRow ); + xUndoTable->GetColArray().GetRange(nStartCol, nEndCol); + xUndoTable->GetRowArray().GetRange(nStartRow, nEndRow); - pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, + xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); - pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); pViewShell->UpdateScrollBars(); } @@ -669,18 +637,18 @@ void ScUndoSubTotals::Undo() rDoc.DeleteAreaTab( 0,aParam.nRow1+1, MAXCOL,aParam.nRow2, nTab, InsertDeleteFlags::ALL ); - pUndoDoc->CopyToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab, - InsertDeleteFlags::NONE, false, rDoc ); // Flags - pUndoDoc->UndoToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab, - InsertDeleteFlags::ALL, false, rDoc ); + xUndoDoc->CopyToDocument(0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab, + InsertDeleteFlags::NONE, false, rDoc); // Flags + xUndoDoc->UndoToDocument(0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab, + InsertDeleteFlags::ALL, false, rDoc); ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab, aParam.nCol2,aParam.nRow2,nTab ); - if (pUndoRange) - rDoc.SetRangeName( new ScRangeName( *pUndoRange ) ); - if (pUndoDB) - rDoc.SetDBCollection( new ScDBCollection( *pUndoDB ), true ); + if (xUndoRange) + rDoc.SetRangeName(new ScRangeName(*xUndoRange)); + if (xUndoDB) + rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true); SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); if ( nVisTab != nTab ) @@ -726,8 +694,8 @@ ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQuery pDrawUndo( nullptr ), nTab( nNewTab ), aQueryParam( rParam ), - pUndoDoc( pNewUndoDoc ), - pUndoDB( pNewUndoDB ), + xUndoDoc( pNewUndoDoc ), + xUndoDB( pNewUndoDB ), bIsAdvanced( false ), bDestArea( false ), bDoSize( bSize ) @@ -748,8 +716,6 @@ ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQuery ScUndoQuery::~ScUndoQuery() { - delete pUndoDoc; - delete pUndoDB; DeleteSdrUndoAction( pDrawUndo ); } @@ -800,24 +766,24 @@ void ScUndoQuery::Undo() pViewShell->DoneBlockMode(); - pUndoDoc->CopyToDocument( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab, - nDestEndCol, nDestEndRow, aQueryParam.nDestTab, - InsertDeleteFlags::ALL, false, rDoc ); + xUndoDoc->CopyToDocument(aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab, + nDestEndCol, nDestEndRow, aQueryParam.nDestTab, + InsertDeleteFlags::ALL, false, rDoc); // Attributes are always copied (#49287#) // rest of the old range if ( bDestArea && !bDoSize ) { rDoc.DeleteAreaTab( aOldDest, InsertDeleteFlags::ALL ); - pUndoDoc->CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, rDoc); + xUndoDoc->CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, rDoc); } } else - pUndoDoc->CopyToDocument(0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab, + xUndoDoc->CopyToDocument(0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab, InsertDeleteFlags::NONE, false, rDoc); - if (pUndoDB) - rDoc.SetDBCollection( new ScDBCollection( *pUndoDB ), true ); + if (xUndoDB) + rDoc.SetDBCollection(new ScDBCollection(*xUndoDB ), true); if (!bCopy) { @@ -1042,24 +1008,16 @@ ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab, aImportParam( rParam ), nEndCol( nNewEndX ), nEndRow( nNewEndY ), - pUndoDoc( pNewUndoDoc ), - pRedoDoc( pNewRedoDoc ), - pUndoDBData( pNewUndoData ), - pRedoDBData( pNewRedoData ), + xUndoDoc(pNewUndoDoc), + xRedoDoc(pNewRedoDoc), + xUndoDBData(pNewUndoData), + xRedoDBData(pNewRedoData), nFormulaCols( nNewFormula ), bRedoFilled( false ) { // redo doc doesn't contain imported data (but everything else) } -ScUndoImportData::~ScUndoImportData() -{ - delete pUndoDoc; - delete pRedoDoc; - delete pUndoDBData; - delete pRedoDBData; -} - OUString ScUndoImportData::GetComment() const { return ScGlobal::GetRscString( STR_UNDO_IMPORTDATA ); @@ -1079,11 +1037,11 @@ void ScUndoImportData::Undo() SCCOL nCol1, nCol2; SCROW nRow1, nRow2; ScDBData* pCurrentData = nullptr; - if (pUndoDBData && pRedoDBData) + if (xUndoDBData && xRedoDBData) { - pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); - pCurrentData = ScUndoUtil::GetOldDBData( pRedoDBData, &rDoc, nTab, - nCol1, nRow1, nCol2, nRow2 ); + xRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + pCurrentData = ScUndoUtil::GetOldDBData(xRedoDBData.get(), &rDoc, nTab, + nCol1, nRow1, nCol2, nRow2); if ( !bRedoFilled ) { @@ -1096,22 +1054,22 @@ void ScUndoImportData::Undo() for (SCCOL nCopyCol = nCol1; nCopyCol <= nCol2; nCopyCol++) { rDoc.CopyToDocument(nCopyCol,nRow1,nTab, nCopyCol,nRow2,nTab, - InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE, false, *pRedoDoc); - rDoc.DeleteAreaTab(nCopyCol,nRow1, nCopyCol,nRow2, nTab, InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE); + InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE, false, *xRedoDoc); + rDoc.DeleteAreaTab(nCopyCol, nRow1, nCopyCol, nRow2, nTab, InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE); } rDoc.SetAutoCalc( bOldAutoCalc ); bRedoFilled = true; } } - bool bMoveCells = pUndoDBData && pRedoDBData && - pRedoDBData->IsDoSize(); // the same in old and new + bool bMoveCells = xUndoDBData && xRedoDBData && + xRedoDBData->IsDoSize(); // the same in old and new if (bMoveCells) { // Undo: first delete the new data, then FitBlock backwards ScRange aOld, aNew; - pUndoDBData->GetArea( aOld ); - pRedoDBData->GetArea( aNew ); + xUndoDBData->GetArea(aOld); + xRedoDBData->GetArea(aNew); rDoc.DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(), aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); @@ -1124,15 +1082,15 @@ void ScUndoImportData::Undo() rDoc.DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1, nEndCol,nEndRow, nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); - pUndoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab, + xUndoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab, nEndCol+nFormulaCols,nEndRow,nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); if (pCurrentData) { - *pCurrentData = *pUndoDBData; + *pCurrentData = *xUndoDBData; - pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + xUndoDBData->GetArea(nTable, nCol1, nRow1, nCol2, nRow2); ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable ); } @@ -1164,21 +1122,21 @@ void ScUndoImportData::Redo() SCCOL nCol1, nCol2; SCROW nRow1, nRow2; ScDBData* pCurrentData = nullptr; - if (pUndoDBData && pRedoDBData) + if (xUndoDBData && xRedoDBData) { - pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); - pCurrentData = ScUndoUtil::GetOldDBData( pUndoDBData, &rDoc, nTab, - nCol1, nRow1, nCol2, nRow2 ); + xUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + pCurrentData = ScUndoUtil::GetOldDBData(xUndoDBData.get(), &rDoc, nTab, + nCol1, nRow1, nCol2, nRow2); } - bool bMoveCells = pUndoDBData && pRedoDBData && - pRedoDBData->IsDoSize(); // the same in old and new + bool bMoveCells = xUndoDBData && xRedoDBData && + xRedoDBData->IsDoSize(); // the same in old and new if (bMoveCells) { // Redo: FitBlock, then delete data (needed for CopyToDocument) ScRange aOld, aNew; - pUndoDBData->GetArea( aOld ); - pRedoDBData->GetArea( aNew ); + xUndoDBData->GetArea(aOld); + xRedoDBData->GetArea(aNew); aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols ); // FitBlock also for formulas aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols ); @@ -1187,21 +1145,21 @@ void ScUndoImportData::Redo() rDoc.DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(), aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); - pRedoDoc->CopyToDocument(aNew, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); // including formulas + xRedoDoc->CopyToDocument(aNew, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); // including formulas } else { rDoc.DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1, nEndCol,nEndRow, nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); - pRedoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab, + xRedoDoc->CopyToDocument(aImportParam.nCol1,aImportParam.nRow1,nTab, nEndCol,nEndRow,nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, rDoc); } if (pCurrentData) { - *pCurrentData = *pRedoDBData; + *pCurrentData = *xRedoDBData; - pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 ); + xRedoDBData->GetArea(nTable, nCol1, nRow1, nCol2, nRow2); ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable ); } @@ -1236,9 +1194,9 @@ void ScUndoImportData::Repeat(SfxRepeatTarget& rTarget) bool ScUndoImportData::CanRepeat(SfxRepeatTarget& rTarget) const { - // Repeat only for import using a database range, then pUndoDBData is set + // Repeat only for import using a database range, then xUndoDBData is set - if (pUndoDBData) + if (xUndoDBData) return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr; else return false; // Address book @@ -1255,10 +1213,10 @@ ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab, aBlockEnd( nEndX,nEndY,nNewTab ), nNewEndRow( nResultEndRow ), aCursorPos( nCurX,nCurY,nNewTab ), - pUndoDoc( pNewUndoDoc ), - pUndoTable( pNewUndoTab ), - pUndoRange( pNewUndoRange ), - pUndoDB( pNewUndoDB ), + xUndoDoc(pNewUndoDoc), + xUndoTable(pNewUndoTab), + xUndoRange(pNewUndoRange), + xUndoDB(pNewUndoDB), bQuerySize( false ) { if ( pOldQ && pNewQ ) @@ -1269,14 +1227,6 @@ ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab, } } -ScUndoRepeatDB::~ScUndoRepeatDB() -{ - delete pUndoDoc; - delete pUndoTable; - delete pUndoRange; - delete pUndoDB; -} - OUString ScUndoRepeatDB::GetComment() const { return ScGlobal::GetRscString( STR_UNDO_REPEATDB ); @@ -1330,22 +1280,22 @@ void ScUndoRepeatDB::Undo() } // Original Outline table - rDoc.SetOutlineTable( nTab, pUndoTable ); + rDoc.SetOutlineTable(nTab, xUndoTable.get()); // Original column/row status - if (pUndoTable) + if (xUndoTable) { SCCOLROW nStartCol; SCCOLROW nStartRow; SCCOLROW nEndCol; SCCOLROW nEndRow; - pUndoTable->GetColArray().GetRange( nStartCol, nEndCol ); - pUndoTable->GetRowArray().GetRange( nStartRow, nEndRow ); + xUndoTable->GetColArray().GetRange(nStartCol, nEndCol); + xUndoTable->GetRowArray().GetRange(nStartRow, nEndRow); - pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, + xUndoDoc->CopyToDocument(static_cast<SCCOL>(nStartCol), 0, nTab, static_cast<SCCOL>(nEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); - pUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(0, nStartRow, nTab, MAXCOL, nEndRow, nTab, InsertDeleteFlags::NONE, false, rDoc); pViewShell->UpdateScrollBars(); } @@ -1356,18 +1306,18 @@ void ScUndoRepeatDB::Undo() rDoc.DeleteAreaTab( 0, aBlockStart.Row(), MAXCOL, aBlockEnd.Row(), nTab, InsertDeleteFlags::ALL ); - pUndoDoc->CopyToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab, + xUndoDoc->CopyToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab, InsertDeleteFlags::NONE, false, rDoc); // Flags - pUndoDoc->UndoToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab, + xUndoDoc->UndoToDocument(0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab, InsertDeleteFlags::ALL, false, rDoc); ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab, aBlockEnd.Col(),aBlockEnd.Row(),nTab ); - if (pUndoRange) - rDoc.SetRangeName( new ScRangeName( *pUndoRange ) ); - if (pUndoDB) - rDoc.SetDBCollection( new ScDBCollection( *pUndoDB ), true ); + if (xUndoRange) + rDoc.SetRangeName(new ScRangeName(*xUndoRange)); + if (xUndoDB) + rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true); SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); if ( nVisTab != nTab ) @@ -1412,34 +1362,24 @@ bool ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const ScUndoDataPilot::ScUndoDataPilot( ScDocShell* pNewDocShell, ScDocument* pOldDoc, ScDocument* pNewDoc, - const ScDPObject* pOldObj, const ScDPObject* pNewObj, bool bMove ) : - ScSimpleUndo( pNewDocShell ), - pOldUndoDoc( pOldDoc ), - pNewUndoDoc( pNewDoc ), - pOldDPObject( nullptr ), - pNewDPObject( nullptr ), - bAllowMove( bMove ) + const ScDPObject* pOldObj, const ScDPObject* pNewObj, bool bMove ) + : ScSimpleUndo(pNewDocShell) + , xOldUndoDoc(pOldDoc) + , xNewUndoDoc(pNewDoc) + , bAllowMove( bMove) { if (pOldObj) - pOldDPObject = new ScDPObject( *pOldObj ); + xOldDPObject.reset(new ScDPObject(*pOldObj)); if (pNewObj) - pNewDPObject = new ScDPObject( *pNewObj ); -} - -ScUndoDataPilot::~ScUndoDataPilot() -{ - delete pOldDPObject; - delete pNewDPObject; - delete pOldUndoDoc; - delete pNewUndoDoc; + xNewDPObject.reset(new ScDPObject(*pNewObj)); } OUString ScUndoDataPilot::GetComment() const { sal_uInt16 nIndex; - if ( pOldUndoDoc && pNewUndoDoc ) + if (xOldUndoDoc && xNewUndoDoc) nIndex = STR_UNDO_PIVOT_MODIFY; - else if ( pNewUndoDoc ) + else if (xNewUndoDoc) nIndex = STR_UNDO_PIVOT_NEW; else nIndex = STR_UNDO_PIVOT_DELETE; @@ -1456,22 +1396,21 @@ void ScUndoDataPilot::Undo() ScRange aOldRange; ScRange aNewRange; - if ( pNewDPObject && pNewUndoDoc ) + if (xNewDPObject && xNewUndoDoc) { - aNewRange = pNewDPObject->GetOutRange(); + aNewRange = xNewDPObject->GetOutRange(); rDoc.DeleteAreaTab( aNewRange, InsertDeleteFlags::ALL ); - pNewUndoDoc->CopyToDocument(aNewRange, InsertDeleteFlags::ALL, false, rDoc); + xNewUndoDoc->CopyToDocument(aNewRange, InsertDeleteFlags::ALL, false, rDoc); } - if ( pOldDPObject && pOldUndoDoc ) + if (xOldDPObject && xOldUndoDoc) { - aOldRange = pOldDPObject->GetOutRange(); - rDoc.DeleteAreaTab( aOldRange, InsertDeleteFlags::ALL ); - pOldUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc); + aOldRange = xOldDPObject->GetOutRange(); + rDoc.DeleteAreaTab(aOldRange, InsertDeleteFlags::ALL); + xOldUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc); } // update objects in collection - - if ( pNewDPObject ) + if (xNewDPObject) { // find updated object //! find by name! @@ -1481,15 +1420,15 @@ void ScUndoDataPilot::Undo() OSL_ENSURE(pDocObj, "DPObject not found"); if (pDocObj) { - if ( pOldDPObject ) + if (xOldDPObject) { // restore old settings - pOldDPObject->WriteSourceDataTo( *pDocObj ); - ScDPSaveData* pData = pOldDPObject->GetSaveData(); + xOldDPObject->WriteSourceDataTo( *pDocObj ); + ScDPSaveData* pData = xOldDPObject->GetSaveData(); if (pData) pDocObj->SetSaveData(*pData); - pDocObj->SetOutRange( pOldDPObject->GetOutRange() ); - pOldDPObject->WriteTempDataTo( *pDocObj ); + pDocObj->SetOutRange(xOldDPObject->GetOutRange()); + xOldDPObject->WriteTempDataTo( *pDocObj ); } else { @@ -1498,11 +1437,11 @@ void ScUndoDataPilot::Undo() } } } - else if ( pOldDPObject ) + else if (xOldDPObject) { // re-insert deleted object - ScDPObject* pDestObj = new ScDPObject( *pOldDPObject ); + ScDPObject* pDestObj = new ScDPObject(*xOldDPObject); if ( !rDoc.GetDPCollection()->InsertNewTable(pDestObj) ) { OSL_FAIL("cannot insert DPObject"); @@ -1510,10 +1449,10 @@ void ScUndoDataPilot::Undo() } } - if (pNewUndoDoc) - pDocShell->PostPaint( aNewRange, PaintPartFlags::Grid, SC_PF_LINES ); - if (pOldUndoDoc) - pDocShell->PostPaint( aOldRange, PaintPartFlags::Grid, SC_PF_LINES ); + if (xNewUndoDoc) + pDocShell->PostPaint(aNewRange, PaintPartFlags::Grid, SC_PF_LINES); + if (xOldUndoDoc) + pDocShell->PostPaint(aOldRange, PaintPartFlags::Grid, SC_PF_LINES); pDocShell->PostDataChanged(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); @@ -1522,10 +1461,10 @@ void ScUndoDataPilot::Undo() //! set current sheet } - if (pNewDPObject) + if (xNewDPObject) { // notify API objects - rDoc.BroadcastUno( ScDataPilotModifiedHint( pNewDPObject->GetName() ) ); + rDoc.BroadcastUno(ScDataPilotModifiedHint(xNewDPObject->GetName())); } EndUndo(); @@ -1541,19 +1480,19 @@ void ScUndoDataPilot::Redo() ScDocument& rDoc = pDocShell->GetDocument(); ScDPObject* pSourceObj = nullptr; - if ( pOldDPObject ) + if (xOldDPObject) { // find object to modify //! find by name! - ScRange aOldRange = pOldDPObject->GetOutRange(); + ScRange aOldRange = xOldDPObject->GetOutRange(); pSourceObj = rDoc.GetDPAtCursor( aOldRange.aStart.Col(), aOldRange.aStart.Row(), aOldRange.aStart.Tab() ); OSL_ENSURE(pSourceObj, "DPObject not found"); } ScDBDocFunc aFunc( *pDocShell ); - aFunc.DataPilotUpdate( pSourceObj, pNewDPObject, false, false, bAllowMove ); // no new undo action + aFunc.DataPilotUpdate(pSourceObj, xNewDPObject.get(), false, false, bAllowMove); // no new undo action EndRedo(); } @@ -1572,25 +1511,18 @@ bool ScUndoDataPilot::CanRepeat(SfxRepeatTarget& /* rTarget */) const ScUndoConsolidate::ScUndoConsolidate( ScDocShell* pNewDocShell, const ScArea& rArea, const ScConsolidateParam& rPar, ScDocument* pNewUndoDoc, bool bReference, SCROW nInsCount, ScOutlineTable* pTab, - ScDBData* pData ) : - ScSimpleUndo( pNewDocShell ), - aDestArea( rArea ), - pUndoDoc( pNewUndoDoc ), - aParam( rPar ), - bInsRef( bReference ), - nInsertCount( nInsCount ), - pUndoTab( pTab ), - pUndoData( pData ) + ScDBData* pData ) + : ScSimpleUndo(pNewDocShell) + , aDestArea(rArea) + , xUndoDoc(pNewUndoDoc) + , aParam(rPar) + , bInsRef(bReference) + , nInsertCount(nInsCount) + , xUndoTab(pTab) + , xUndoData(pData) { } -ScUndoConsolidate::~ScUndoConsolidate() -{ - delete pUndoDoc; - delete pUndoTab; - delete pUndoData; -} - OUString ScUndoConsolidate::GetComment() const { return ScGlobal::GetRscString( STR_UNDO_CONSOLIDATE ); @@ -1604,28 +1536,28 @@ void ScUndoConsolidate::Undo() SCTAB nTab = aDestArea.nTab; ScRange aOldRange; - if (pUndoData) - pUndoData->GetArea(aOldRange); + if (xUndoData) + xUndoData->GetArea(aOldRange); if (bInsRef) { rDoc.DeleteRow( 0,nTab, MAXCOL,nTab, aDestArea.nRowStart, nInsertCount ); - rDoc.SetOutlineTable( nTab, pUndoTab ); + rDoc.SetOutlineTable(nTab, xUndoTab.get()); // Row status - pUndoDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, InsertDeleteFlags::NONE, false, rDoc); + xUndoDoc->CopyToDocument(0, 0, nTab, MAXCOL, MAXROW, nTab, InsertDeleteFlags::NONE, false, rDoc); // Data and references rDoc.DeleteAreaTab( 0,aDestArea.nRowStart, MAXCOL,aDestArea.nRowEnd, nTab, InsertDeleteFlags::ALL ); - pUndoDoc->UndoToDocument(0, aDestArea.nRowStart, nTab, + xUndoDoc->UndoToDocument(0, aDestArea.nRowStart, nTab, MAXCOL, aDestArea.nRowEnd, nTab, InsertDeleteFlags::ALL, false, rDoc); // Original range - if (pUndoData) + if (xUndoData) { rDoc.DeleteAreaTab(aOldRange, InsertDeleteFlags::ALL); - pUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc); + xUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc); } pDocShell->PostPaint( 0,aDestArea.nRowStart,nTab, MAXCOL,MAXROW,nTab, @@ -1635,20 +1567,20 @@ void ScUndoConsolidate::Undo() { rDoc.DeleteAreaTab( aDestArea.nColStart,aDestArea.nRowStart, aDestArea.nColEnd,aDestArea.nRowEnd, nTab, InsertDeleteFlags::ALL ); - pUndoDoc->CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, nTab, + xUndoDoc->CopyToDocument(aDestArea.nColStart, aDestArea.nRowStart, nTab, aDestArea.nColEnd, aDestArea.nRowEnd, nTab, InsertDeleteFlags::ALL, false, rDoc); // Original range - if (pUndoData) + if (xUndoData) { rDoc.DeleteAreaTab(aOldRange, InsertDeleteFlags::ALL); - pUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc); + xUndoDoc->CopyToDocument(aOldRange, InsertDeleteFlags::ALL, false, rDoc); } SCCOL nEndX = aDestArea.nColEnd; SCROW nEndY = aDestArea.nRowEnd; - if ( pUndoData ) + if (xUndoData) { if ( aOldRange.aEnd.Col() > nEndX ) nEndX = aOldRange.aEnd.Col(); @@ -1660,14 +1592,14 @@ void ScUndoConsolidate::Undo() } // Adjust Database range again - if (pUndoData) + if (xUndoData) { ScDBCollection* pColl = rDoc.GetDBCollection(); if (pColl) { - ScDBData* pDocData = pColl->getNamedDBs().findByUpperName(pUndoData->GetUpperName()); + ScDBData* pDocData = pColl->getNamedDBs().findByUpperName(xUndoData->GetUpperName()); if (pDocData) - *pDocData = *pUndoData; + *pDocData = *xUndoData; } } @@ -1788,70 +1720,61 @@ ScUndoDataForm::ScUndoDataForm( ScDocShell* pNewDocShell, const ScMarkData& rMark, ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, InsertDeleteFlags nNewFlags, - ScRefUndoData* pRefData ) : - ScBlockUndo( pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE ), - mpMarkData(new ScMarkData(rMark)), - pUndoDoc( pNewUndoDoc ), - pRedoDoc( pNewRedoDoc ), - nFlags( nNewFlags ), - pRefUndoData( pRefData ), - pRefRedoData( nullptr ), - bRedoFilled( false ) -{ - // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting) - // don't have to be changed and branched for 641. - // They can be removed later. - - if (!mpMarkData->IsMarked()) // no cell marked: - mpMarkData->SetMarkArea(aBlockRange); // mark paste block - - if ( pRefUndoData ) - pRefUndoData->DeleteUnchanged( &pDocShell->GetDocument() ); + ScRefUndoData* pRefData ) + : ScBlockUndo(pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE) + , mxMarkData(new ScMarkData(rMark)) + , xUndoDoc(pNewUndoDoc) + , xRedoDoc(pNewRedoDoc) + , nFlags(nNewFlags) + , xRefUndoData(pRefData) + , bRedoFilled(false) +{ + // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting) + // don't have to be changed and branched for 641. + // They can be removed later. - SetChangeTrack(); -} + if (!mxMarkData->IsMarked()) // no cell marked: + mxMarkData->SetMarkArea(aBlockRange); // mark paste block -ScUndoDataForm::~ScUndoDataForm() -{ - delete pUndoDoc; - delete pRedoDoc; - delete pRefUndoData; - delete pRefRedoData; + if (xRefUndoData) + xRefUndoData->DeleteUnchanged(&pDocShell->GetDocument()); + + SetChangeTrack(); } OUString ScUndoDataForm::GetComment() const { - return ScGlobal::GetRscString( STR_UNDO_PASTE ); + return ScGlobal::GetRscString( STR_UNDO_PASTE ); } void ScUndoDataForm::SetChangeTrack() { - ScChangeTrack* pChangeTrack = pDocShell->GetDocument().GetChangeTrack(); - if ( pChangeTrack && (nFlags & InsertDeleteFlags::CONTENTS) ) - pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc, - nStartChangeAction, nEndChangeAction, SC_CACM_PASTE ); - else - nStartChangeAction = nEndChangeAction = 0; + ScChangeTrack* pChangeTrack = pDocShell->GetDocument().GetChangeTrack(); + if ( pChangeTrack && (nFlags & InsertDeleteFlags::CONTENTS) ) + pChangeTrack->AppendContentRange(aBlockRange, xUndoDoc.get(), + nStartChangeAction, nEndChangeAction, SC_CACM_PASTE); + else + nStartChangeAction = nEndChangeAction = 0; } void ScUndoDataForm::Undo() { - BeginUndo(); - DoChange( true ); - ShowTable( aBlockRange ); - EndUndo(); - SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); + BeginUndo(); + DoChange( true ); + ShowTable( aBlockRange ); + EndUndo(); + SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); } void ScUndoDataForm::Redo() { - BeginRedo(); - ScDocument& rDoc = pDocShell->GetDocument(); - EnableDrawAdjust( &rDoc, false ); //! include in ScBlockUndo? - DoChange( false ); - EnableDrawAdjust( &rDoc, true ); //! include in ScBlockUndo? - EndRedo(); - SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); + BeginRedo(); + ScDocument& rDoc = pDocShell->GetDocument(); + EnableDrawAdjust( &rDoc, false ); //! include in ScBlockUndo? + DoChange( false ); + EnableDrawAdjust( &rDoc, true ); //! include in ScBlockUndo? + EndRedo(); + SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); } void ScUndoDataForm::Repeat(SfxRepeatTarget& /*rTarget*/) @@ -1860,7 +1783,7 @@ void ScUndoDataForm::Repeat(SfxRepeatTarget& /*rTarget*/) bool ScUndoDataForm::CanRepeat(SfxRepeatTarget& rTarget) const { - return (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr); + return (dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr); } void ScUndoDataForm::DoChange( const bool bUndo ) @@ -1869,11 +1792,11 @@ void ScUndoDataForm::DoChange( const bool bUndo ) // RefUndoData for redo is created before first undo // (with DeleteUnchanged after the DoUndo call) - bool bCreateRedoData = ( bUndo && pRefUndoData && !pRefRedoData ); - if ( bCreateRedoData ) - pRefRedoData = new ScRefUndoData( &rDoc ); + bool bCreateRedoData = (bUndo && xRefUndoData && !xRefRedoData); + if (bCreateRedoData) + xRefRedoData.reset(new ScRefUndoData(&rDoc)); - ScRefUndoData* pWorkRefData = bUndo ? pRefUndoData : pRefRedoData; + ScRefUndoData* pWorkRefData = bUndo ? xRefUndoData.get() : xRefRedoData.get(); // Always back-up either all or none of the content for Undo InsertDeleteFlags nUndoFlags = InsertDeleteFlags::NONE; @@ -1889,20 +1812,20 @@ void ScUndoDataForm::DoChange( const bool bUndo ) SCTAB nTabCount = rDoc.GetTableCount(); if ( bUndo && !bRedoFilled ) { - if (!pRedoDoc) + if (!xRedoDoc) { bool bColInfo = ( aBlockRange.aStart.Row()==0 && aBlockRange.aEnd.Row()==MAXROW ); bool bRowInfo = ( aBlockRange.aStart.Col()==0 && aBlockRange.aEnd.Col()==MAXCOL ); - pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); - pRedoDoc->InitUndoSelected( &rDoc, *mpMarkData, bColInfo, bRowInfo ); + xRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO)); + xRedoDoc->InitUndoSelected(&rDoc, *mxMarkData, bColInfo, bRowInfo); } // read "redo" data from the document in the first undo // all sheets - CopyToDocument skips those that don't exist in pRedoDoc ScRange aCopyRange = aBlockRange; aCopyRange.aStart.SetTab(0); aCopyRange.aEnd.SetTab(nTabCount-1); - rDoc.CopyToDocument(aCopyRange, InsertDeleteFlags::VALUE, false, *pRedoDoc); + rDoc.CopyToDocument(aCopyRange, InsertDeleteFlags::VALUE, false, *xRedoDoc); bRedoFilled = true; } @@ -1911,7 +1834,7 @@ void ScUndoDataForm::DoChange( const bool bUndo ) for ( sal_uInt16 i=0; i <= ( aBlockRange.aEnd.Col() - aBlockRange.aStart.Col() ); i++ ) { - OUString aOldString = pUndoDoc->GetString( + OUString aOldString = xUndoDoc->GetString( aBlockRange.aStart.Col()+i, aBlockRange.aStart.Row(), aBlockRange.aStart.Tab()); rDoc.SetString( aBlockRange.aStart.Col()+i , aBlockRange.aStart.Row() , aBlockRange.aStart.Tab() , aOldString ); } @@ -1923,8 +1846,8 @@ void ScUndoDataForm::DoChange( const bool bUndo ) bPaintAll = true; } - if ( bCreateRedoData && pRefRedoData ) - pRefRedoData->DeleteUnchanged( &rDoc ); + if (bCreateRedoData && xRefRedoData) + xRefRedoData->DeleteUnchanged(&rDoc); if ( bUndo ) { diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 5a4f873ea4a7..0e5416638173 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -858,20 +858,18 @@ bool ScUndoMakeScenario::CanRepeat(SfxRepeatTarget& rTarget) const return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr; } -ScUndoImportTab::ScUndoImportTab( ScDocShell* pShell, - SCTAB nNewTab, SCTAB nNewCount ) : - ScSimpleUndo( pShell ), - nTab( nNewTab ), - nCount( nNewCount ), - pRedoDoc( nullptr ), - pDrawUndo( nullptr ) +ScUndoImportTab::ScUndoImportTab(ScDocShell* pShell, + SCTAB nNewTab, SCTAB nNewCount) + : ScSimpleUndo(pShell) + , nTab(nNewTab) + , nCount(nNewCount) + , pDrawUndo(nullptr) { pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ); } ScUndoImportTab::~ScUndoImportTab() { - delete pRedoDoc; DeleteSdrUndoAction( pDrawUndo ); } @@ -908,38 +906,38 @@ void ScUndoImportTab::Undo() SCTAB i; ScDocument& rDoc = pDocShell->GetDocument(); - bool bMakeRedo = !pRedoDoc; + bool bMakeRedo = !xRedoDoc; if (bMakeRedo) { - pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); - pRedoDoc->InitUndo( &rDoc, nTab,nTab+nCount-1, true,true ); + xRedoDoc.reset(new ScDocument(SCDOCMODE_UNDO)); + xRedoDoc->InitUndo(&rDoc, nTab,nTab+nCount-1, true, true); OUString aOldName; for (i=0; i<nCount; i++) { SCTAB nTabPos=nTab+i; - rDoc.CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, *pRedoDoc); + rDoc.CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, *xRedoDoc); rDoc.GetName( nTabPos, aOldName ); - pRedoDoc->RenameTab( nTabPos, aOldName, false ); - pRedoDoc->SetTabBgColor( nTabPos, rDoc.GetTabBgColor(nTabPos) ); + xRedoDoc->RenameTab(nTabPos, aOldName, false); + xRedoDoc->SetTabBgColor(nTabPos, rDoc.GetTabBgColor(nTabPos)); if ( rDoc.IsScenario(nTabPos) ) { - pRedoDoc->SetScenario(nTabPos, true ); + xRedoDoc->SetScenario(nTabPos, true); OUString aComment; Color aColor; ScScenarioFlags nScenFlags; rDoc.GetScenarioData(nTabPos, aComment, aColor, nScenFlags ); - pRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags ); + xRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags); bool bActive = rDoc.IsActiveScenario(nTabPos); - pRedoDoc->SetActiveScenario(nTabPos, bActive ); + xRedoDoc->SetActiveScenario(nTabPos, bActive); bool bVisible = rDoc.IsVisible(nTabPos); - pRedoDoc->SetVisible(nTabPos,bVisible ); + xRedoDoc->SetVisible(nTabPos, bVisible); } if ( rDoc.IsTabProtected( nTabPos ) ) - pRedoDoc->SetTabProtection(nTabPos, rDoc.GetTabProtection(nTabPos)); + xRedoDoc->SetTabProtection(nTabPos, rDoc.GetTabProtection(nTabPos)); } } @@ -956,7 +954,7 @@ void ScUndoImportTab::Undo() void ScUndoImportTab::Redo() { - if (!pRedoDoc) + if (!xRedoDoc) { OSL_FAIL("Where is my Redo Document?"); return; @@ -968,7 +966,7 @@ void ScUndoImportTab::Redo() for (i=0; i<nCount; i++) // first insert all sheets (#63304#) { SCTAB nTabPos=nTab+i; - pRedoDoc->GetName(nTabPos,aName); + xRedoDoc->GetName(nTabPos, aName); bDrawIsInUndo = true; rDoc.InsertTab(nTabPos,aName); bDrawIsInUndo = false; @@ -976,25 +974,25 @@ void ScUndoImportTab::Redo() for (i=0; i<nCount; i++) // then copy into inserted sheets { SCTAB nTabPos=nTab+i; - pRedoDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, rDoc); - rDoc.SetTabBgColor( nTabPos, pRedoDoc->GetTabBgColor(nTabPos) ); + xRedoDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, InsertDeleteFlags::ALL,false, rDoc); + rDoc.SetTabBgColor(nTabPos, xRedoDoc->GetTabBgColor(nTabPos)); - if ( pRedoDoc->IsScenario(nTabPos) ) + if (xRedoDoc->IsScenario(nTabPos)) { rDoc.SetScenario(nTabPos, true ); OUString aComment; Color aColor; ScScenarioFlags nScenFlags; - pRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags ); + xRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags ); rDoc.SetScenarioData(nTabPos, aComment, aColor, nScenFlags ); - bool bActive = pRedoDoc->IsActiveScenario(nTabPos); + bool bActive = xRedoDoc->IsActiveScenario(nTabPos); rDoc.SetActiveScenario(nTabPos, bActive ); - bool bVisible=pRedoDoc->IsVisible(nTabPos); + bool bVisible = xRedoDoc->IsVisible(nTabPos); rDoc.SetVisible(nTabPos,bVisible ); } - if ( pRedoDoc->IsTabProtected( nTabPos ) ) - rDoc.SetTabProtection(nTabPos, pRedoDoc->GetTabProtection(nTabPos)); + if (xRedoDoc->IsTabProtected(nTabPos)) + rDoc.SetTabProtection(nTabPos, xRedoDoc->GetTabProtection(nTabPos)); } RedoSdrUndoAction( pDrawUndo ); // after the sheets are inserted diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 1f90c52d0525..ce7e6d9e038a 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -109,29 +109,21 @@ ScDocument* ScTempDocSource::GetDocument() return rCache.GetDocument(); } -ScTempDocCache::ScTempDocCache() : - pDoc( nullptr ), - bInUse( false ) +ScTempDocCache::ScTempDocCache() + : bInUse(false) { } -ScTempDocCache::~ScTempDocCache() -{ - OSL_ENSURE( !bInUse, "ScTempDocCache dtor: bInUse" ); - delete pDoc; -} - void ScTempDocCache::SetDocument( ScDocument* pNew ) { - OSL_ENSURE( !pDoc, "ScTempDocCache::SetDocument: already set" ); - pDoc = pNew; + OSL_ENSURE(!xDoc, "ScTempDocCache::SetDocument: already set"); + xDoc.reset(pNew); } void ScTempDocCache::Clear() { OSL_ENSURE( !bInUse, "ScTempDocCache::Clear: bInUse" ); - delete pDoc; - pDoc = nullptr; + xDoc.reset(); } // copy results from one document into another |