1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: undocell.hxx,v $
10 * $Revision: 1.5.128.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_UNDOCELL_HXX
32 #define SC_UNDOCELL_HXX
34 #include "undobase.hxx"
37 #include <boost/shared_ptr.hpp>
48 //----------------------------------------------------------------------------
50 class ScUndoCursorAttr
: public ScSimpleUndo
54 ScUndoCursorAttr( ScDocShell
* pNewDocShell
,
55 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
56 const ScPatternAttr
* pOldPat
, const ScPatternAttr
* pNewPat
,
57 const ScPatternAttr
* pApplyPat
, BOOL bAutomatic
);
58 virtual ~ScUndoCursorAttr();
62 virtual void Repeat(SfxRepeatTarget
& rTarget
);
63 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
65 virtual String
GetComment() const;
67 /** once the objects are passed to this class, their life-cycle is
68 managed by this class; the calling function must pass new'ed
69 objects to this method. */
70 void SetEditData( EditTextObject
* pOld
, EditTextObject
* pNew
);
76 ScPatternAttr
* pOldPattern
;
77 ScPatternAttr
* pNewPattern
;
78 ScPatternAttr
* pApplyPattern
;
79 ::boost::shared_ptr
<EditTextObject
> pOldEditData
;
80 ::boost::shared_ptr
<EditTextObject
> pNewEditData
;
83 void DoChange( const ScPatternAttr
* pWhichPattern
, const ::boost::shared_ptr
<EditTextObject
>& pEditData
) const;
87 class ScUndoEnterData
: public ScSimpleUndo
91 ScUndoEnterData( ScDocShell
* pNewDocShell
,
92 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
93 SCTAB nNewCount
, SCTAB
* pNewTabs
,
94 ScBaseCell
** ppOldData
, BOOL
* pHasForm
, ULONG
* pOldForm
,
95 const String
& rNewStr
, EditTextObject
* pObj
= NULL
);
96 virtual ~ScUndoEnterData();
100 virtual void Repeat(SfxRepeatTarget
& rTarget
);
101 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
103 virtual String
GetComment() const;
108 ScBaseCell
** ppOldCells
;
111 EditTextObject
* pNewEditData
;
112 ULONG nEndChangeAction
;
116 SCTAB nCount
; // markierte Tabellen
118 void DoChange() const;
119 void SetChangeTrack();
123 class ScUndoEnterValue
: public ScSimpleUndo
127 ScUndoEnterValue( ScDocShell
* pNewDocShell
,
128 const ScAddress
& rNewPos
,
129 ScBaseCell
* pUndoCell
, double nVal
, BOOL bHeight
);
130 virtual ~ScUndoEnterValue();
134 virtual void Repeat(SfxRepeatTarget
& rTarget
);
135 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
137 virtual String
GetComment() const;
141 ScBaseCell
* pOldCell
;
143 ULONG nEndChangeAction
;
146 void SetChangeTrack();
150 class ScUndoPutCell
: public ScSimpleUndo
154 ScUndoPutCell( ScDocShell
* pNewDocShell
,
155 const ScAddress
& rNewPos
,
156 ScBaseCell
* pUndoCell
, ScBaseCell
* pRedoCell
, BOOL bHeight
);
157 virtual ~ScUndoPutCell();
161 virtual void Repeat(SfxRepeatTarget
& rTarget
);
162 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
164 virtual String
GetComment() const;
168 ScBaseCell
* pOldCell
;
169 ScBaseCell
* pEnteredCell
;
170 ULONG nEndChangeAction
;
173 void SetChangeTrack();
177 class ScUndoPageBreak
: public ScSimpleUndo
181 ScUndoPageBreak( ScDocShell
* pNewDocShell
,
182 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
183 BOOL bNewColumn
, BOOL bNewInsert
);
184 virtual ~ScUndoPageBreak();
188 virtual void Repeat(SfxRepeatTarget
& rTarget
);
189 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
191 virtual String
GetComment() const;
197 BOOL bColumn
; // Spalten- oder Zeilenumbruch
198 BOOL bInsert
; // Einfuegen oder Loeschen
200 void DoChange( BOOL bInsert
) const;
203 class ScUndoPrintZoom
: public ScSimpleUndo
207 ScUndoPrintZoom( ScDocShell
* pNewDocShell
, SCTAB nT
,
208 USHORT nOS
, USHORT nOP
, USHORT nNS
, USHORT nNP
);
209 virtual ~ScUndoPrintZoom();
213 virtual void Repeat(SfxRepeatTarget
& rTarget
);
214 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
216 virtual String
GetComment() const;
225 void DoChange( BOOL bUndo
);
228 class ScUndoThesaurus
: public ScSimpleUndo
232 ScUndoThesaurus( ScDocShell
* pNewDocShell
,
233 SCCOL nNewCol
, SCROW nNewRow
, SCTAB nNewTab
,
234 const String
& rNewUndoStr
, const EditTextObject
* pUndoTObj
,
235 const String
& rNewRedoStr
, const EditTextObject
* pRedoTObj
);
236 virtual ~ScUndoThesaurus();
240 virtual void Repeat(SfxRepeatTarget
& rTarget
);
241 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
243 virtual String
GetComment() const;
249 String aUndoStr
; // Daten bei StringZelle
250 EditTextObject
* pUndoTObject
; // bei EditZelle
252 EditTextObject
* pRedoTObject
;
253 ULONG nEndChangeAction
;
255 void DoChange( BOOL bUndo
, const String
& rStr
,
256 const EditTextObject
* pTObj
);
257 void SetChangeTrack( ScBaseCell
* pOldCell
);
260 // ============================================================================
262 /** Undo action for inserting, removing, and replacing a cell note. */
263 class ScUndoReplaceNote
: public ScSimpleUndo
268 /** Constructs an undo action for inserting or removing a cell note. */
270 ScDocShell
& rDocShell
,
271 const ScAddress
& rPos
,
272 const ScNoteData
& rNoteData
,
274 SdrUndoAction
* pDrawUndo
);
276 /** Constructs an undo action for replacing a cell note with another. */
278 ScDocShell
& rDocShell
,
279 const ScAddress
& rPos
,
280 const ScNoteData
& rOldData
,
281 const ScNoteData
& rNewData
,
282 SdrUndoAction
* pDrawUndo
);
284 virtual ~ScUndoReplaceNote();
288 virtual void Repeat( SfxRepeatTarget
& rTarget
);
289 virtual BOOL
CanRepeat( SfxRepeatTarget
& rTarget
) const;
291 virtual String
GetComment() const;
294 void DoInsertNote( const ScNoteData
& rNoteData
);
295 void DoRemoveNote( const ScNoteData
& rNoteData
);
299 ScNoteData maOldData
;
300 ScNoteData maNewData
;
301 SdrUndoAction
* mpDrawUndo
;
304 // ============================================================================
306 /** Undo action for showing or hiding a cell note caption. */
307 class ScUndoShowHideNote
: public ScSimpleUndo
311 ScUndoShowHideNote( ScDocShell
& rDocShell
, const ScAddress
& rPos
, bool bShow
);
312 virtual ~ScUndoShowHideNote();
316 virtual void Repeat( SfxRepeatTarget
& rTarget
);
317 virtual BOOL
CanRepeat( SfxRepeatTarget
& rTarget
) const;
319 virtual String
GetComment() const;
326 // ============================================================================
328 class ScUndoDetective
: public ScSimpleUndo
332 ScUndoDetective( ScDocShell
* pNewDocShell
,
333 SdrUndoAction
* pDraw
, const ScDetOpData
* pOperation
,
334 ScDetOpList
* pUndoList
= NULL
);
335 virtual ~ScUndoDetective();
339 virtual void Repeat(SfxRepeatTarget
& rTarget
);
340 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
342 virtual String
GetComment() const;
346 ScDetOpList
* pOldList
;
349 SdrUndoAction
* pDrawUndo
;
353 class ScUndoRangeNames
: public ScSimpleUndo
357 ScUndoRangeNames( ScDocShell
* pNewDocShell
,
358 ScRangeName
* pOld
, ScRangeName
* pNew
);
359 virtual ~ScUndoRangeNames();
363 virtual void Repeat(SfxRepeatTarget
& rTarget
);
364 virtual BOOL
CanRepeat(SfxRepeatTarget
& rTarget
) const;
366 virtual String
GetComment() const;
369 ScRangeName
* pOldRanges
;
370 ScRangeName
* pNewRanges
;
372 void DoChange( BOOL bUndo
);