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 SC_UNDOCELL_HXX
21 #define SC_UNDOCELL_HXX
23 #include "undobase.hxx"
25 #include "cellvalue.hxx"
27 #include <boost/shared_ptr.hpp>
28 #include <boost/scoped_ptr.hpp>
39 class ScUndoCursorAttr
: public ScSimpleUndo
43 ScUndoCursorAttr( ScDocShell
* pNewDocShell
,
44 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
45 const ScPatternAttr
* pOldPat
, const ScPatternAttr
* pNewPat
,
46 const ScPatternAttr
* pApplyPat
, sal_Bool bAutomatic
);
47 virtual ~ScUndoCursorAttr();
51 virtual void Repeat(SfxRepeatTarget
& rTarget
);
52 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
54 virtual OUString
GetComment() const;
56 /** once the objects are passed to this class, their life-cycle is
57 managed by this class; the calling function must pass new'ed
58 objects to this method. */
59 void SetEditData( EditTextObject
* pOld
, EditTextObject
* pNew
);
65 ScPatternAttr
* pOldPattern
;
66 ScPatternAttr
* pNewPattern
;
67 ScPatternAttr
* pApplyPattern
;
68 ::boost::shared_ptr
<EditTextObject
> pOldEditData
;
69 ::boost::shared_ptr
<EditTextObject
> pNewEditData
;
70 sal_Bool bIsAutomatic
;
72 void DoChange( const ScPatternAttr
* pWhichPattern
, const ::boost::shared_ptr
<EditTextObject
>& pEditData
) const;
76 class ScUndoEnterData
: public ScSimpleUndo
91 typedef std::vector
<Value
> ValuesType
;
94 ScDocShell
* pNewDocShell
, const ScAddress
& rPos
,
95 ValuesType
& rOldValues
, const OUString
& rNewStr
, EditTextObject
* pObj
= NULL
);
97 virtual ~ScUndoEnterData();
101 virtual void Repeat(SfxRepeatTarget
& rTarget
);
102 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
104 virtual OUString
GetComment() const;
107 ValuesType maOldValues
;
109 OUString maNewString
;
110 boost::scoped_ptr
<EditTextObject
> mpNewEditData
;
111 sal_uLong mnEndChangeAction
;
114 void DoChange() const;
115 void SetChangeTrack();
119 class ScUndoEnterValue
: public ScSimpleUndo
124 ScDocShell
* pNewDocShell
, const ScAddress
& rNewPos
,
125 const ScCellValue
& rUndoCell
, double nVal
);
127 virtual ~ScUndoEnterValue();
131 virtual void Repeat(SfxRepeatTarget
& rTarget
);
132 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
134 virtual OUString
GetComment() const;
138 ScCellValue maOldCell
;
140 sal_uLong nEndChangeAction
;
142 void SetChangeTrack();
145 class ScUndoSetCell
: public ScSimpleUndo
149 ScUndoSetCell( ScDocShell
* pDocSh
, const ScAddress
& rPos
, const ScCellValue
& rOldVal
, const ScCellValue
& rNewVal
);
151 virtual ~ScUndoSetCell();
155 virtual void Repeat( SfxRepeatTarget
& rTarget
);
156 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const;
157 virtual OUString
GetComment() const;
160 void SetChangeTrack();
161 void SetValue( const ScCellValue
& rVal
);
165 ScCellValue maOldValue
;
166 ScCellValue maNewValue
;
167 sal_uLong mnEndChangeAction
;
170 class ScUndoPageBreak
: public ScSimpleUndo
174 ScUndoPageBreak( ScDocShell
* pNewDocShell
,
175 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
176 sal_Bool bNewColumn
, sal_Bool bNewInsert
);
177 virtual ~ScUndoPageBreak();
181 virtual void Repeat(SfxRepeatTarget
& rTarget
);
182 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
184 virtual OUString
GetComment() const;
190 sal_Bool bColumn
; // Column or row break
191 sal_Bool bInsert
; // Insert or Delete
193 void DoChange( sal_Bool bInsert
) const;
196 class ScUndoPrintZoom
: public ScSimpleUndo
200 ScUndoPrintZoom( ScDocShell
* pNewDocShell
, SCTAB nT
,
201 sal_uInt16 nOS
, sal_uInt16 nOP
, sal_uInt16 nNS
, sal_uInt16 nNP
);
202 virtual ~ScUndoPrintZoom();
206 virtual void Repeat(SfxRepeatTarget
& rTarget
);
207 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
209 virtual OUString
GetComment() const;
213 sal_uInt16 nOldScale
;
214 sal_uInt16 nOldPages
;
215 sal_uInt16 nNewScale
;
216 sal_uInt16 nNewPages
;
218 void DoChange( sal_Bool bUndo
);
221 class ScUndoThesaurus
: public ScSimpleUndo
225 ScUndoThesaurus( ScDocShell
* pNewDocShell
,
226 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
227 const OUString
& rNewUndoStr
, const EditTextObject
* pUndoTObj
,
228 const OUString
& rNewRedoStr
, const EditTextObject
* pRedoTObj
);
229 virtual ~ScUndoThesaurus();
233 virtual void Repeat(SfxRepeatTarget
& rTarget
);
234 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
236 virtual OUString
GetComment() const;
242 OUString aUndoStr
; // Data at String cell
243 EditTextObject
* pUndoTObject
; // at Edit cell
245 EditTextObject
* pRedoTObject
;
246 sal_uLong nEndChangeAction
;
248 void DoChange( sal_Bool bUndo
, const OUString
& rStr
,
249 const EditTextObject
* pTObj
);
250 void SetChangeTrack( const ScCellValue
& rOldCell
);
253 // ============================================================================
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();
281 virtual void Repeat( SfxRepeatTarget
& rTarget
);
282 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const;
284 virtual OUString
GetComment() const;
287 void DoInsertNote( const ScNoteData
& rNoteData
);
288 void DoRemoveNote( const ScNoteData
& rNoteData
);
292 ScNoteData maOldData
;
293 ScNoteData maNewData
;
294 SdrUndoAction
* mpDrawUndo
;
297 // ============================================================================
299 /** Undo action for showing or hiding a cell note caption. */
300 class ScUndoShowHideNote
: public ScSimpleUndo
304 ScUndoShowHideNote( ScDocShell
& rDocShell
, const ScAddress
& rPos
, bool bShow
);
305 virtual ~ScUndoShowHideNote();
309 virtual void Repeat( SfxRepeatTarget
& rTarget
);
310 virtual bool CanRepeat( SfxRepeatTarget
& rTarget
) const;
312 virtual OUString
GetComment() const;
319 // ============================================================================
321 class ScUndoDetective
: public ScSimpleUndo
325 ScUndoDetective( ScDocShell
* pNewDocShell
,
326 SdrUndoAction
* pDraw
, const ScDetOpData
* pOperation
,
327 ScDetOpList
* pUndoList
= NULL
);
328 virtual ~ScUndoDetective();
332 virtual void Repeat(SfxRepeatTarget
& rTarget
);
333 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
335 virtual OUString
GetComment() const;
339 ScDetOpList
* pOldList
;
342 SdrUndoAction
* pDrawUndo
;
346 class ScUndoRangeNames
: public ScSimpleUndo
350 //use nTab = -1 for global range names
351 ScUndoRangeNames( ScDocShell
* pNewDocShell
,
352 ScRangeName
* pOld
, ScRangeName
* pNew
, SCTAB nTab
= -1);
353 virtual ~ScUndoRangeNames();
357 virtual void Repeat(SfxRepeatTarget
& rTarget
);
358 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const;
360 virtual OUString
GetComment() const;
363 ScRangeName
* pOldRanges
;
364 ScRangeName
* pNewRanges
;
367 void DoChange( sal_Bool bUndo
);
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */