Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / undocell.hxx
blob8183d2ab4715a7627909f3dad343903aeaedcc3c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
24 #include "postit.hxx"
25 #include "cellvalue.hxx"
27 #include <boost/shared_ptr.hpp>
28 #include <boost/scoped_ptr.hpp>
30 class ScDocShell;
31 class ScPatternAttr;
32 class EditTextObject;
33 class SdrUndoAction;
34 class ScDetOpList;
35 class ScDetOpData;
36 class ScRangeName;
37 class ScDocument;
39 class ScUndoCursorAttr: public ScSimpleUndo
41 public:
42 TYPEINFO();
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();
49 virtual void Undo();
50 virtual void Redo();
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 );
61 private:
62 SCCOL nCol;
63 SCROW nRow;
64 SCTAB nTab;
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
78 public:
79 TYPEINFO();
81 struct Value
83 SCTAB mnTab;
84 bool mbHasFormat;
85 sal_uInt32 mnFormat;
86 ScCellValue maCell;
88 Value();
91 typedef std::vector<Value> ValuesType;
93 ScUndoEnterData(
94 ScDocShell* pNewDocShell, const ScAddress& rPos,
95 ValuesType& rOldValues, const OUString& rNewStr, EditTextObject* pObj = NULL );
97 virtual ~ScUndoEnterData();
99 virtual void Undo();
100 virtual void Redo();
101 virtual void Repeat(SfxRepeatTarget& rTarget);
102 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
104 virtual OUString GetComment() const;
106 private:
107 ValuesType maOldValues;
109 OUString maNewString;
110 boost::scoped_ptr<EditTextObject> mpNewEditData;
111 sal_uLong mnEndChangeAction;
112 ScAddress maPos;
114 void DoChange() const;
115 void SetChangeTrack();
119 class ScUndoEnterValue: public ScSimpleUndo
121 public:
122 TYPEINFO();
123 ScUndoEnterValue(
124 ScDocShell* pNewDocShell, const ScAddress& rNewPos,
125 const ScCellValue& rUndoCell, double nVal );
127 virtual ~ScUndoEnterValue();
129 virtual void Undo();
130 virtual void Redo();
131 virtual void Repeat(SfxRepeatTarget& rTarget);
132 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
134 virtual OUString GetComment() const;
136 private:
137 ScAddress aPos;
138 ScCellValue maOldCell;
139 double nValue;
140 sal_uLong nEndChangeAction;
142 void SetChangeTrack();
145 class ScUndoSetCell : public ScSimpleUndo
147 public:
148 TYPEINFO();
149 ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal );
151 virtual ~ScUndoSetCell();
153 virtual void Undo();
154 virtual void Redo();
155 virtual void Repeat( SfxRepeatTarget& rTarget );
156 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const;
157 virtual OUString GetComment() const;
159 private:
160 void SetChangeTrack();
161 void SetValue( const ScCellValue& rVal );
163 private:
164 ScAddress maPos;
165 ScCellValue maOldValue;
166 ScCellValue maNewValue;
167 sal_uLong mnEndChangeAction;
170 class ScUndoPageBreak: public ScSimpleUndo
172 public:
173 TYPEINFO();
174 ScUndoPageBreak( ScDocShell* pNewDocShell,
175 SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
176 sal_Bool bNewColumn, sal_Bool bNewInsert );
177 virtual ~ScUndoPageBreak();
179 virtual void Undo();
180 virtual void Redo();
181 virtual void Repeat(SfxRepeatTarget& rTarget);
182 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
184 virtual OUString GetComment() const;
186 private:
187 SCCOL nCol;
188 SCROW nRow;
189 SCTAB nTab;
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
198 public:
199 TYPEINFO();
200 ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
201 sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP );
202 virtual ~ScUndoPrintZoom();
204 virtual void Undo();
205 virtual void Redo();
206 virtual void Repeat(SfxRepeatTarget& rTarget);
207 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
209 virtual OUString GetComment() const;
211 private:
212 SCTAB nTab;
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
223 public:
224 TYPEINFO();
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();
231 virtual void Undo();
232 virtual void Redo();
233 virtual void Repeat(SfxRepeatTarget& rTarget);
234 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
236 virtual OUString GetComment() const;
238 private:
239 SCCOL nCol;
240 SCROW nRow;
241 SCTAB nTab;
242 OUString aUndoStr; // Data at String cell
243 EditTextObject* pUndoTObject; // at Edit cell
244 OUString aRedoStr;
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
258 public:
259 TYPEINFO();
261 /** Constructs an undo action for inserting or removing a cell note. */
262 ScUndoReplaceNote(
263 ScDocShell& rDocShell,
264 const ScAddress& rPos,
265 const ScNoteData& rNoteData,
266 bool bInsert,
267 SdrUndoAction* pDrawUndo );
269 /** Constructs an undo action for replacing a cell note with another. */
270 ScUndoReplaceNote(
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();
280 virtual void Redo();
281 virtual void Repeat( SfxRepeatTarget& rTarget );
282 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const;
284 virtual OUString GetComment() const;
286 private:
287 void DoInsertNote( const ScNoteData& rNoteData );
288 void DoRemoveNote( const ScNoteData& rNoteData );
290 private:
291 ScAddress maPos;
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
302 public:
303 TYPEINFO();
304 ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
305 virtual ~ScUndoShowHideNote();
307 virtual void Undo();
308 virtual void Redo();
309 virtual void Repeat( SfxRepeatTarget& rTarget );
310 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const;
312 virtual OUString GetComment() const;
314 private:
315 ScAddress maPos;
316 bool mbShown;
319 // ============================================================================
321 class ScUndoDetective: public ScSimpleUndo
323 public:
324 TYPEINFO();
325 ScUndoDetective( ScDocShell* pNewDocShell,
326 SdrUndoAction* pDraw, const ScDetOpData* pOperation,
327 ScDetOpList* pUndoList = NULL );
328 virtual ~ScUndoDetective();
330 virtual void Undo();
331 virtual void Redo();
332 virtual void Repeat(SfxRepeatTarget& rTarget);
333 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
335 virtual OUString GetComment() const;
337 private:
338 sal_Bool bIsDelete;
339 ScDetOpList* pOldList;
340 sal_uInt16 nAction;
341 ScAddress aPos;
342 SdrUndoAction* pDrawUndo;
346 class ScUndoRangeNames: public ScSimpleUndo
348 public:
349 TYPEINFO();
350 //use nTab = -1 for global range names
351 ScUndoRangeNames( ScDocShell* pNewDocShell,
352 ScRangeName* pOld, ScRangeName* pNew , SCTAB nTab = -1);
353 virtual ~ScUndoRangeNames();
355 virtual void Undo();
356 virtual void Redo();
357 virtual void Repeat(SfxRepeatTarget& rTarget);
358 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
360 virtual OUString GetComment() const;
362 private:
363 ScRangeName* pOldRanges;
364 ScRangeName* pNewRanges;
365 SCTAB mnTab;
367 void DoChange( sal_Bool bUndo );
372 #endif
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */