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>
28 #include <boost/shared_ptr.hpp>
29 #include <boost/scoped_ptr.hpp>
46 class ScUndoCursorAttr
: public ScSimpleUndo
50 ScUndoCursorAttr( ScDocShell
* pNewDocShell
,
51 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
52 const ScPatternAttr
* pOldPat
, const ScPatternAttr
* pNewPat
,
53 const ScPatternAttr
* pApplyPat
, bool bAutomatic
);
54 virtual ~ScUndoCursorAttr();
56 virtual void Undo() SAL_OVERRIDE
;
57 virtual void Redo() SAL_OVERRIDE
;
58 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
59 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
61 virtual OUString
GetComment() const SAL_OVERRIDE
;
63 /** once the objects are passed to this class, their life-cycle is
64 managed by this class; the calling function must pass new'ed
65 objects to this method. */
66 void SetEditData( EditTextObject
* pOld
, EditTextObject
* pNew
);
72 ScPatternAttr
* pOldPattern
;
73 ScPatternAttr
* pNewPattern
;
74 ScPatternAttr
* pApplyPattern
;
75 ::boost::shared_ptr
<EditTextObject
> pOldEditData
;
76 ::boost::shared_ptr
<EditTextObject
> pNewEditData
;
79 void DoChange( const ScPatternAttr
* pWhichPattern
, const ::boost::shared_ptr
<EditTextObject
>& pEditData
) const;
82 class ScUndoEnterData
: public ScSimpleUndo
97 typedef std::vector
<Value
> ValuesType
;
100 ScDocShell
* pNewDocShell
, const ScAddress
& rPos
,
101 ValuesType
& rOldValues
, const OUString
& rNewStr
, EditTextObject
* pObj
= NULL
);
103 virtual ~ScUndoEnterData();
105 virtual void Undo() SAL_OVERRIDE
;
106 virtual void Redo() SAL_OVERRIDE
;
107 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
108 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
110 virtual OUString
GetComment() const SAL_OVERRIDE
;
113 ValuesType maOldValues
;
115 OUString maNewString
;
116 boost::scoped_ptr
<EditTextObject
> mpNewEditData
;
117 sal_uLong mnEndChangeAction
;
120 void DoChange() const;
121 void SetChangeTrack();
124 class ScUndoEnterValue
: public ScSimpleUndo
129 ScDocShell
* pNewDocShell
, const ScAddress
& rNewPos
,
130 const ScCellValue
& rUndoCell
, double nVal
);
132 virtual ~ScUndoEnterValue();
134 virtual void Undo() SAL_OVERRIDE
;
135 virtual void Redo() SAL_OVERRIDE
;
136 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
137 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
139 virtual OUString
GetComment() const SAL_OVERRIDE
;
143 ScCellValue maOldCell
;
145 sal_uLong nEndChangeAction
;
147 void SetChangeTrack();
150 class ScUndoSetCell
: public ScSimpleUndo
154 ScUndoSetCell( ScDocShell
* pDocSh
, const ScAddress
& rPos
, const ScCellValue
& rOldVal
, const ScCellValue
& rNewVal
);
156 virtual ~ScUndoSetCell();
158 virtual void Undo() SAL_OVERRIDE
;
159 virtual void Redo() SAL_OVERRIDE
;
160 virtual void Repeat( SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
161 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
162 virtual OUString
GetComment() const SAL_OVERRIDE
;
165 void SetChangeTrack();
166 void SetValue( const ScCellValue
& rVal
);
170 ScCellValue maOldValue
;
171 ScCellValue maNewValue
;
172 sal_uLong mnEndChangeAction
;
175 class ScUndoPageBreak
: public ScSimpleUndo
179 ScUndoPageBreak( ScDocShell
* pNewDocShell
,
180 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
181 bool bNewColumn
, bool bNewInsert
);
182 virtual ~ScUndoPageBreak();
184 virtual void Undo() SAL_OVERRIDE
;
185 virtual void Redo() SAL_OVERRIDE
;
186 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
187 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
189 virtual OUString
GetComment() const SAL_OVERRIDE
;
195 bool bColumn
; // Column or row break
196 bool bInsert
; // Insert or Delete
198 void DoChange( bool bInsert
) const;
201 class ScUndoPrintZoom
: public ScSimpleUndo
205 ScUndoPrintZoom( ScDocShell
* pNewDocShell
, SCTAB nT
,
206 sal_uInt16 nOS
, sal_uInt16 nOP
, sal_uInt16 nNS
, sal_uInt16 nNP
);
207 virtual ~ScUndoPrintZoom();
209 virtual void Undo() SAL_OVERRIDE
;
210 virtual void Redo() SAL_OVERRIDE
;
211 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
212 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
214 virtual OUString
GetComment() const SAL_OVERRIDE
;
218 sal_uInt16 nOldScale
;
219 sal_uInt16 nOldPages
;
220 sal_uInt16 nNewScale
;
221 sal_uInt16 nNewPages
;
223 void DoChange( bool bUndo
);
226 class ScUndoThesaurus
: public ScSimpleUndo
230 ScUndoThesaurus( ScDocShell
* pNewDocShell
,
231 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
232 const ScCellValue
& rOldText
, const ScCellValue
& rNewText
);
233 virtual ~ScUndoThesaurus();
235 virtual void Undo() SAL_OVERRIDE
;
236 virtual void Redo() SAL_OVERRIDE
;
237 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
238 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
240 virtual OUString
GetComment() const SAL_OVERRIDE
;
246 sal_uLong nEndChangeAction
;
248 ScCellValue maOldText
;
249 ScCellValue maNewText
;
251 void DoChange( bool bUndo
, const ScCellValue
& rText
);
252 void SetChangeTrack( const ScCellValue
& rOldCell
);
255 /** Undo action for inserting, removing, and replacing a cell note. */
256 class ScUndoReplaceNote
: public ScSimpleUndo
261 /** Constructs an undo action for inserting or removing a cell note. */
263 ScDocShell
& rDocShell
,
264 const ScAddress
& rPos
,
265 const ScNoteData
& rNoteData
,
267 SdrUndoAction
* pDrawUndo
);
269 /** Constructs an undo action for replacing a cell note with another. */
271 ScDocShell
& rDocShell
,
272 const ScAddress
& rPos
,
273 const ScNoteData
& rOldData
,
274 const ScNoteData
& rNewData
,
275 SdrUndoAction
* pDrawUndo
);
277 virtual ~ScUndoReplaceNote();
279 virtual void Undo() SAL_OVERRIDE
;
280 virtual void Redo() SAL_OVERRIDE
;
281 virtual void Repeat( SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
282 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
284 virtual OUString
GetComment() const SAL_OVERRIDE
;
287 void DoInsertNote( const ScNoteData
& rNoteData
);
288 void DoRemoveNote( const ScNoteData
& rNoteData
);
292 ScNoteData maOldData
;
293 ScNoteData maNewData
;
294 SdrUndoAction
* mpDrawUndo
;
297 /** Undo action for showing or hiding a cell note caption. */
298 class ScUndoShowHideNote
: public ScSimpleUndo
302 ScUndoShowHideNote( ScDocShell
& rDocShell
, const ScAddress
& rPos
, bool bShow
);
303 virtual ~ScUndoShowHideNote();
305 virtual void Undo() SAL_OVERRIDE
;
306 virtual void Redo() SAL_OVERRIDE
;
307 virtual void Repeat( SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
308 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
310 virtual OUString
GetComment() const SAL_OVERRIDE
;
317 class ScUndoDetective
: public ScSimpleUndo
321 ScUndoDetective( ScDocShell
* pNewDocShell
,
322 SdrUndoAction
* pDraw
, const ScDetOpData
* pOperation
,
323 ScDetOpList
* pUndoList
= NULL
);
324 virtual ~ScUndoDetective();
326 virtual void Undo() SAL_OVERRIDE
;
327 virtual void Redo() SAL_OVERRIDE
;
328 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
329 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
331 virtual OUString
GetComment() const SAL_OVERRIDE
;
335 ScDetOpList
* pOldList
;
338 SdrUndoAction
* pDrawUndo
;
341 class ScUndoRangeNames
: public ScSimpleUndo
345 //use nTab = -1 for global range names
346 ScUndoRangeNames( ScDocShell
* pNewDocShell
,
347 ScRangeName
* pOld
, ScRangeName
* pNew
, SCTAB nTab
= -1);
348 virtual ~ScUndoRangeNames();
350 virtual void Undo() SAL_OVERRIDE
;
351 virtual void Redo() SAL_OVERRIDE
;
352 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
353 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
355 virtual OUString
GetComment() const SAL_OVERRIDE
;
358 ScRangeName
* pOldRanges
;
359 ScRangeName
* pNewRanges
;
362 void DoChange( bool bUndo
);
367 class UndoSetCells
: public ScSimpleUndo
370 CellValues maOldValues
;
371 CellValues maNewValues
;
373 void DoChange( const CellValues
& rValues
);
376 UndoSetCells( ScDocShell
* pDocSh
, const ScAddress
& rTopPos
);
377 virtual ~UndoSetCells();
379 virtual void Undo() SAL_OVERRIDE
;
380 virtual void Redo() SAL_OVERRIDE
;
382 virtual bool CanRepeat( SfxRepeatTarget
& ) const SAL_OVERRIDE
;
383 virtual OUString
GetComment() const SAL_OVERRIDE
;
385 CellValues
& GetOldValues() { return maOldValues
;}
386 void SetNewValues( const std::vector
<double>& rVals
);
393 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */