1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include "undobase.hxx"
23 #include "refundo.hxx"
24 #include <dpobject.hxx>
25 #include <olinetab.hxx>
26 #include <rangeutl.hxx>
27 #include <rangelst.hxx>
28 #include <queryparam.hxx>
29 #include <subtotalparam.hxx>
36 class ScUndoDoOutline
: public ScSimpleUndo
39 ScUndoDoOutline( ScDocShell
* pNewDocShell
,
40 SCCOLROW nNewStart
, SCCOLROW nNewEnd
, SCTAB nNewTab
,
41 ScDocumentUniquePtr pNewUndoDoc
, bool bNewColumns
,
42 sal_uInt16 nNewLevel
, sal_uInt16 nNewEntry
, bool bNewShow
);
43 virtual ~ScUndoDoOutline() override
;
45 virtual void Undo() override
;
46 virtual void Redo() override
;
47 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
48 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
50 virtual OUString
GetComment() const override
;
64 class ScUndoMakeOutline
: public ScSimpleUndo
67 ScUndoMakeOutline( ScDocShell
* pNewDocShell
,
68 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
69 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
70 std::unique_ptr
<ScOutlineTable
> pNewUndoTab
,
71 bool bNewColumns
, bool bNewMake
);
72 virtual ~ScUndoMakeOutline() override
;
74 virtual void Undo() override
;
75 virtual void Redo() override
;
76 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
77 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
79 virtual OUString
GetComment() const override
;
82 ScAddress aBlockStart
;
84 std::unique_ptr
<ScOutlineTable
>
90 class ScUndoOutlineLevel
: public ScSimpleUndo
93 ScUndoOutlineLevel(ScDocShell
* pNewDocShell
,
94 SCCOLROW nNewStart
, SCCOLROW nNewEnd
, SCTAB nNewTab
,
95 ScDocumentUniquePtr pNewUndoDoc
, std::unique_ptr
<ScOutlineTable
> pNewUndoTab
,
96 bool bNewColumns
, sal_uInt16 nNewLevel
);
98 virtual void Undo() override
;
99 virtual void Redo() override
;
100 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
101 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
103 virtual OUString
GetComment() const override
;
109 ScDocumentUniquePtr xUndoDoc
;
110 std::unique_ptr
<ScOutlineTable
> xUndoTable
;
115 class ScUndoOutlineBlock
: public ScSimpleUndo
118 ScUndoOutlineBlock(ScDocShell
* pNewDocShell
,
119 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
120 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
121 ScDocumentUniquePtr pNewUndoDoc
, std::unique_ptr
<ScOutlineTable
> pNewUndoTab
,
124 virtual void Undo() override
;
125 virtual void Redo() override
;
126 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
127 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
129 virtual OUString
GetComment() const override
;
132 ScAddress aBlockStart
;
134 ScDocumentUniquePtr xUndoDoc
;
135 std::unique_ptr
<ScOutlineTable
> xUndoTable
;
139 class ScUndoRemoveAllOutlines
: public ScSimpleUndo
142 ScUndoRemoveAllOutlines(ScDocShell
* pNewDocShell
,
143 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
144 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
145 ScDocumentUniquePtr pNewUndoDoc
, std::unique_ptr
<ScOutlineTable
> pNewUndoTab
);
147 virtual void Undo() override
;
148 virtual void Redo() override
;
149 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
150 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
152 virtual OUString
GetComment() const override
;
155 ScAddress aBlockStart
;
157 ScDocumentUniquePtr xUndoDoc
;
158 std::unique_ptr
<ScOutlineTable
> xUndoTable
;
161 class ScUndoAutoOutline
: public ScSimpleUndo
164 ScUndoAutoOutline(ScDocShell
* pNewDocShell
,
165 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
166 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
167 ScDocumentUniquePtr pNewUndoDoc
, std::unique_ptr
<ScOutlineTable
> pNewUndoTab
);
169 virtual void Undo() override
;
170 virtual void Redo() override
;
171 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
172 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
174 virtual OUString
GetComment() const override
;
177 ScAddress aBlockStart
;
179 ScDocumentUniquePtr xUndoDoc
;
180 std::unique_ptr
<ScOutlineTable
> xUndoTable
;
183 class ScUndoSubTotals
: public ScDBFuncUndo
186 ScUndoSubTotals(ScDocShell
* pNewDocShell
, SCTAB nNewTab
,
187 const ScSubTotalParam
& rNewParam
, SCROW nNewEndY
,
188 ScDocumentUniquePtr pNewUndoDoc
, std::unique_ptr
<ScOutlineTable
> pNewUndoTab
,
189 std::unique_ptr
<ScRangeName
> pNewUndoRange
, std::unique_ptr
<ScDBCollection
> pNewUndoDB
);
191 virtual void Undo() override
;
192 virtual void Redo() override
;
193 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
194 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
196 virtual OUString
GetComment() const override
;
200 ScSubTotalParam aParam
; // The original passed parameter
201 SCROW nNewEndRow
; // Size of result
202 ScDocumentUniquePtr xUndoDoc
;
203 std::unique_ptr
<ScOutlineTable
> xUndoTable
;
204 std::unique_ptr
<ScRangeName
> xUndoRange
;
205 std::unique_ptr
<ScDBCollection
> xUndoDB
;
208 class ScUndoQuery
: public ScDBFuncUndo
211 ScUndoQuery( ScDocShell
* pNewDocShell
, SCTAB nNewTab
,
212 const ScQueryParam
& rParam
, ScDocumentUniquePtr pNewUndoDoc
,
213 std::unique_ptr
<ScDBCollection
> pNewUndoDB
, const ScRange
* pOld
,
214 bool bSize
, const ScRange
* pAdvSrc
);
215 virtual ~ScUndoQuery() override
;
217 virtual void Undo() override
;
218 virtual void Redo() override
;
219 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
220 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
222 virtual OUString
GetComment() const override
;
225 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
227 ScQueryParam aQueryParam
;
228 ScDocumentUniquePtr xUndoDoc
;
229 std::unique_ptr
<ScDBCollection
> xUndoDB
; // due to source and target range
237 class ScUndoAutoFilter
: public ScDBFuncUndo
243 void DoChange( bool bUndo
);
246 ScUndoAutoFilter( ScDocShell
* pNewDocShell
, const ScRange
& rRange
,
247 OUString aName
, bool bSet
);
248 virtual ~ScUndoAutoFilter() override
;
250 virtual void Undo() override
;
251 virtual void Redo() override
;
252 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
253 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
255 virtual OUString
GetComment() const override
;
258 class ScUndoDBData
: public ScSimpleUndo
261 ScUndoDBData( ScDocShell
* pNewDocShell
,
262 std::unique_ptr
<ScDBCollection
> pNewUndoColl
,
263 std::unique_ptr
<ScDBCollection
> pNewRedoColl
);
264 virtual ~ScUndoDBData() override
;
266 virtual void Undo() override
;
267 virtual void Redo() override
;
268 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
269 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
271 virtual OUString
GetComment() const override
;
274 std::unique_ptr
<ScDBCollection
> pUndoColl
;
275 std::unique_ptr
<ScDBCollection
> pRedoColl
;
278 class ScUndoImportData
: public ScSimpleUndo
281 ScUndoImportData(ScDocShell
* pNewDocShell
, SCTAB nNewTab
,
282 const ScImportParam
& rParam
, SCCOL nNewEndX
, SCROW nNewEndY
,
284 ScDocumentUniquePtr pNewUndoDoc
, ScDocumentUniquePtr pNewRedoDoc
,
285 std::unique_ptr
<ScDBData
> pNewUndoData
, std::unique_ptr
<ScDBData
> pNewRedoData
);
287 virtual void Undo() override
;
288 virtual void Redo() override
;
289 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
290 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
292 virtual OUString
GetComment() const override
;
296 ScImportParam aImportParam
;
299 ScDocumentUniquePtr xUndoDoc
;
300 ScDocumentUniquePtr xRedoDoc
;
301 std::unique_ptr
<ScDBData
> xUndoDBData
;
302 std::unique_ptr
<ScDBData
> xRedoDBData
;
307 class ScUndoRepeatDB
: public ScSimpleUndo
310 ScUndoRepeatDB(ScDocShell
* pNewDocShell
, SCTAB nNewTab
,
311 SCCOL nStartX
, SCROW nStartY
, SCCOL nEndX
, SCROW nEndY
,
312 SCROW nResultEndRow
, SCCOL nCurX
, SCROW nCurY
,
313 ScDocumentUniquePtr pNewUndoDoc
, std::unique_ptr
<ScOutlineTable
> pNewUndoTab
,
314 std::unique_ptr
<ScRangeName
> pNewUndoRange
, std::unique_ptr
<ScDBCollection
> pNewUndoDB
,
315 const ScRange
* pOldQ
, const ScRange
* pNewQ
);
317 virtual void Undo() override
;
318 virtual void Redo() override
;
319 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
320 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
322 virtual OUString
GetComment() const override
;
325 ScAddress aBlockStart
;
328 ScAddress aCursorPos
;
329 ScDocumentUniquePtr xUndoDoc
;
330 std::unique_ptr
<ScOutlineTable
> xUndoTable
;
331 std::unique_ptr
<ScRangeName
> xUndoRange
;
332 std::unique_ptr
<ScDBCollection
> xUndoDB
;
338 class ScUndoDataPilot
: public ScSimpleUndo
341 ScUndoDataPilot(ScDocShell
* pNewDocShell
,
342 ScDocumentUniquePtr pOldDoc
, ScDocumentUniquePtr pNewDoc
,
343 const ScDPObject
* pOldObj
, const ScDPObject
* pNewObj
,
346 virtual void Undo() override
;
347 virtual void Redo() override
;
348 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
349 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
351 virtual OUString
GetComment() const override
;
354 ScDocumentUniquePtr xOldUndoDoc
;
355 ScDocumentUniquePtr xNewUndoDoc
;
356 std::unique_ptr
<ScDPObject
> xOldDPObject
;
357 std::unique_ptr
<ScDPObject
> xNewDPObject
;
361 class ScUndoConsolidate
: public ScSimpleUndo
364 ScUndoConsolidate(ScDocShell
* pNewDocShell
,
365 const ScArea
& rArea
, const ScConsolidateParam
& rPar
,
366 ScDocumentUniquePtr pNewUndoDoc
, bool bReference
,
367 SCROW nInsCount
, std::unique_ptr
<ScOutlineTable
> pTab
,
368 std::unique_ptr
<ScDBData
> pData
);
370 virtual void Undo() override
;
371 virtual void Redo() override
;
372 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
373 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
375 virtual OUString
GetComment() const override
;
379 ScDocumentUniquePtr xUndoDoc
;
380 ScConsolidateParam aParam
;
383 std::unique_ptr
<ScOutlineTable
> xUndoTab
;
384 std::unique_ptr
<ScDBData
> xUndoData
;
387 class ScUndoChartData
: public ScSimpleUndo
390 ScUndoChartData( ScDocShell
* pNewDocShell
,
391 OUString aName
, const ScRange
& rNew
,
392 bool bColHdr
, bool bRowHdr
, bool bAdd
);
393 ScUndoChartData( ScDocShell
* pNewDocShell
,
394 OUString aName
, ScRangeListRef xNew
,
395 bool bColHdr
, bool bRowHdr
, bool bAdd
);
396 virtual ~ScUndoChartData() override
;
398 virtual void Undo() override
;
399 virtual void Redo() override
;
400 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
401 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
403 virtual OUString
GetComment() const override
;
407 ScRangeListRef aOldRangeListRef
;
410 // ScRange aNewRange;
411 ScRangeListRef aNewRangeListRef
;
419 class ScUndoDataForm
: public ScBlockUndo
422 ScUndoDataForm(ScDocShell
* pNewDocShell
,
423 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
424 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
425 const ScMarkData
& rMark
,
426 ScDocumentUniquePtr pNewUndoDoc
, ScDocumentUniquePtr pNewRedoDoc
,
427 std::unique_ptr
<ScRefUndoData
> pRefData
);
428 virtual void Undo() override
;
429 virtual void Redo() override
;
430 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
431 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
433 virtual OUString
GetComment() const override
;
436 std::unique_ptr
<ScMarkData
> mxMarkData
;
437 ScDocumentUniquePtr xUndoDoc
;
438 ScDocumentUniquePtr xRedoDoc
;
439 std::unique_ptr
<ScRefUndoData
> xRefUndoData
;
440 std::unique_ptr
<ScRefUndoData
> xRefRedoData
;
443 void DoChange( const bool bUndo
);
446 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */