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 .
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX
23 #include "undobase.hxx"
25 #include "cellvalue.hxx"
26 #include <cellvalues.hxx>
45 class ScUndoCursorAttr
: public ScSimpleUndo
48 ScUndoCursorAttr( ScDocShell
* pNewDocShell
,
49 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
50 const ScPatternAttr
* pOldPat
, const ScPatternAttr
* pNewPat
,
51 const ScPatternAttr
* pApplyPat
);
52 virtual ~ScUndoCursorAttr();
54 virtual void Undo() override
;
55 virtual void Redo() override
;
56 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
57 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
59 virtual OUString
GetComment() const override
;
61 /** once the objects are passed to this class, their life-cycle is
62 managed by this class; the calling function must pass new'ed
63 objects to this method. */
64 void SetEditData( EditTextObject
* pOld
, EditTextObject
* pNew
);
70 ScPatternAttr
* pOldPattern
;
71 ScPatternAttr
* pNewPattern
;
72 ScPatternAttr
* pApplyPattern
;
73 std::shared_ptr
<EditTextObject
> pOldEditData
;
74 std::shared_ptr
<EditTextObject
> pNewEditData
;
77 void DoChange( const ScPatternAttr
* pWhichPattern
, const std::shared_ptr
<EditTextObject
>& pEditData
) const;
80 class ScUndoEnterData
: public ScSimpleUndo
94 typedef std::vector
<Value
> ValuesType
;
97 ScDocShell
* pNewDocShell
, const ScAddress
& rPos
,
98 ValuesType
& rOldValues
, const OUString
& rNewStr
, EditTextObject
* pObj
= nullptr );
100 virtual ~ScUndoEnterData();
102 virtual void Undo() override
;
103 virtual void Redo() override
;
104 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
105 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
107 virtual OUString
GetComment() const override
;
110 ValuesType maOldValues
;
112 OUString maNewString
;
113 std::unique_ptr
<EditTextObject
> mpNewEditData
;
114 sal_uLong mnEndChangeAction
;
117 void DoChange() const;
118 void SetChangeTrack();
121 class ScUndoEnterValue
: public ScSimpleUndo
125 ScDocShell
* pNewDocShell
, const ScAddress
& rNewPos
,
126 const ScCellValue
& rUndoCell
, double nVal
);
128 virtual ~ScUndoEnterValue();
130 virtual void Undo() override
;
131 virtual void Redo() override
;
132 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
133 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
135 virtual OUString
GetComment() const override
;
139 ScCellValue maOldCell
;
141 sal_uLong nEndChangeAction
;
143 void SetChangeTrack();
146 class ScUndoSetCell
: public ScSimpleUndo
149 ScUndoSetCell( ScDocShell
* pDocSh
, const ScAddress
& rPos
, const ScCellValue
& rOldVal
, const ScCellValue
& rNewVal
);
151 virtual ~ScUndoSetCell();
153 virtual void Undo() override
;
154 virtual void Redo() override
;
155 virtual void Repeat( SfxRepeatTarget
& rTarget
) override
;
156 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const override
;
157 virtual OUString
GetComment() const override
;
160 void SetChangeTrack();
161 void SetValue( const ScCellValue
& rVal
);
165 ScCellValue maOldValue
;
166 ScCellValue maNewValue
;
167 sal_uLong mnEndChangeAction
;
170 class ScUndoPageBreak
: public ScSimpleUndo
173 ScUndoPageBreak( ScDocShell
* pNewDocShell
,
174 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
175 bool bNewColumn
, bool bNewInsert
);
176 virtual ~ScUndoPageBreak();
178 virtual void Undo() override
;
179 virtual void Redo() override
;
180 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
181 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
183 virtual OUString
GetComment() const override
;
189 bool bColumn
; // Column or row break
190 bool bInsert
; // Insert or Delete
192 void DoChange( bool bInsert
) const;
195 class ScUndoPrintZoom
: public ScSimpleUndo
198 ScUndoPrintZoom( ScDocShell
* pNewDocShell
, SCTAB nT
,
199 sal_uInt16 nOS
, sal_uInt16 nOP
, sal_uInt16 nNS
, sal_uInt16 nNP
);
200 virtual ~ScUndoPrintZoom();
202 virtual void Undo() override
;
203 virtual void Redo() override
;
204 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
205 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
207 virtual OUString
GetComment() const override
;
211 sal_uInt16 nOldScale
;
212 sal_uInt16 nOldPages
;
213 sal_uInt16 nNewScale
;
214 sal_uInt16 nNewPages
;
216 void DoChange( bool bUndo
);
219 class ScUndoThesaurus
: public ScSimpleUndo
222 ScUndoThesaurus( ScDocShell
* pNewDocShell
,
223 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
224 const ScCellValue
& rOldText
, const ScCellValue
& rNewText
);
225 virtual ~ScUndoThesaurus();
227 virtual void Undo() override
;
228 virtual void Redo() override
;
229 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
230 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
232 virtual OUString
GetComment() const override
;
238 sal_uLong nEndChangeAction
;
240 ScCellValue maOldText
;
241 ScCellValue maNewText
;
243 void DoChange( bool bUndo
, const ScCellValue
& rText
);
244 void SetChangeTrack( const ScCellValue
& rOldCell
);
247 /** Undo action for inserting, removing, and replacing a cell note. */
248 class ScUndoReplaceNote
: public ScSimpleUndo
252 /** Constructs an undo action for inserting or removing a cell note. */
254 ScDocShell
& rDocShell
,
255 const ScAddress
& rPos
,
256 const ScNoteData
& rNoteData
,
258 SdrUndoAction
* pDrawUndo
);
260 /** Constructs an undo action for replacing a cell note with another. */
262 ScDocShell
& rDocShell
,
263 const ScAddress
& rPos
,
264 const ScNoteData
& rOldData
,
265 const ScNoteData
& rNewData
,
266 SdrUndoAction
* pDrawUndo
);
268 virtual ~ScUndoReplaceNote();
270 virtual void Undo() override
;
271 virtual void Redo() override
;
272 virtual void Repeat( SfxRepeatTarget
& rTarget
) override
;
273 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const override
;
275 virtual OUString
GetComment() const override
;
278 void DoInsertNote( const ScNoteData
& rNoteData
);
279 void DoRemoveNote( const ScNoteData
& rNoteData
);
283 ScNoteData maOldData
;
284 ScNoteData maNewData
;
285 SdrUndoAction
* mpDrawUndo
;
288 /** Undo action for showing or hiding a cell note caption. */
289 class ScUndoShowHideNote
: public ScSimpleUndo
292 ScUndoShowHideNote( ScDocShell
& rDocShell
, const ScAddress
& rPos
, bool bShow
);
293 virtual ~ScUndoShowHideNote();
295 virtual void Undo() override
;
296 virtual void Redo() override
;
297 virtual void Repeat( SfxRepeatTarget
& rTarget
) override
;
298 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const override
;
300 virtual OUString
GetComment() const override
;
307 class ScUndoDetective
: public ScSimpleUndo
310 ScUndoDetective( ScDocShell
* pNewDocShell
,
311 SdrUndoAction
* pDraw
, const ScDetOpData
* pOperation
,
312 ScDetOpList
* pUndoList
= nullptr );
313 virtual ~ScUndoDetective();
315 virtual void Undo() override
;
316 virtual void Redo() override
;
317 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
318 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
320 virtual OUString
GetComment() const override
;
324 ScDetOpList
* pOldList
;
327 SdrUndoAction
* pDrawUndo
;
330 class ScUndoRangeNames
: public ScSimpleUndo
333 //use nTab = -1 for global range names
334 ScUndoRangeNames( ScDocShell
* pNewDocShell
,
335 ScRangeName
* pOld
, ScRangeName
* pNew
, SCTAB nTab
= -1);
336 virtual ~ScUndoRangeNames();
338 virtual void Undo() override
;
339 virtual void Redo() override
;
340 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
341 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
343 virtual OUString
GetComment() const override
;
346 ScRangeName
* pOldRanges
;
347 ScRangeName
* pNewRanges
;
350 void DoChange( bool bUndo
);
355 class UndoSetCells
: public ScSimpleUndo
358 CellValues maOldValues
;
359 CellValues maNewValues
;
361 void DoChange( const CellValues
& rValues
);
364 UndoSetCells( ScDocShell
* pDocSh
, const ScAddress
& rTopPos
);
365 virtual ~UndoSetCells();
367 virtual void Undo() override
;
368 virtual void Redo() override
;
370 virtual bool CanRepeat( SfxRepeatTarget
& ) const override
;
371 virtual OUString
GetComment() const override
;
373 CellValues
& GetOldValues() { return maOldValues
;}
374 void SetNewValues( const std::vector
<double>& rVals
);
381 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */