xref: /aoo42x/main/sc/source/ui/inc/undocell.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_UNDOCELL_HXX
29 #define SC_UNDOCELL_HXX
30 
31 #include "undobase.hxx"
32 #include "postit.hxx"
33 
34 class ScDocShell;
35 class ScBaseCell;
36 class ScPatternAttr;
37 class EditTextObject;
38 class SdrUndoAction;
39 class ScDetOpList;
40 class ScDetOpData;
41 class ScRangeName;
42 
43 //----------------------------------------------------------------------------
44 
45 class ScUndoCursorAttr: public ScSimpleUndo
46 {
47 public:
48 					TYPEINFO();
49 					ScUndoCursorAttr( ScDocShell* pNewDocShell,
50 							SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
51 							const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
52 							const ScPatternAttr* pApplyPat, sal_Bool bAutomatic );
53 	virtual 		~ScUndoCursorAttr();
54 
55 	virtual void	Undo();
56 	virtual void	Redo();
57 	virtual void	Repeat(SfxRepeatTarget& rTarget);
58 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
59 
60 	virtual String	GetComment() const;
61 
62 private:
63 	SCCOL			nCol;
64 	SCROW			nRow;
65 	SCTAB			nTab;
66 	ScPatternAttr*	pOldPattern;
67 	ScPatternAttr*	pNewPattern;
68 	ScPatternAttr*	pApplyPattern;
69 	sal_Bool			bIsAutomatic;
70 
71 	void			DoChange( const ScPatternAttr* pWhichPattern ) const;
72 };
73 
74 
75 class ScUndoEnterData: public ScSimpleUndo
76 {
77 public:
78 					TYPEINFO();
79 					ScUndoEnterData( ScDocShell* pNewDocShell,
80 							SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
81 							SCTAB nNewCount, SCTAB* pNewTabs,
82 							ScBaseCell** ppOldData, sal_Bool* pHasForm, sal_uLong* pOldForm,
83 							const String& rNewStr, EditTextObject* pObj = NULL );
84 	virtual 		~ScUndoEnterData();
85 
86 	virtual void	Undo();
87 	virtual void	Redo();
88 	virtual void	Repeat(SfxRepeatTarget& rTarget);
89 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
90 
91 	virtual String	GetComment() const;
92 
93 private:
94 	String			aNewString;
95 	SCTAB*			pTabs;
96 	ScBaseCell**	ppOldCells;
97 	sal_Bool*			pHasFormat;
98 	sal_uLong*			pOldFormats;
99 	EditTextObject*	pNewEditData;
100 	sal_uLong			nEndChangeAction;
101 	SCCOL			nCol;
102 	SCROW			nRow;
103 	SCTAB			nTab;
104 	SCTAB			nCount;				//	markierte Tabellen
105 
106 	void			DoChange() const;
107 	void			SetChangeTrack();
108 };
109 
110 
111 class ScUndoEnterValue: public ScSimpleUndo
112 {
113 public:
114 					TYPEINFO();
115 					ScUndoEnterValue( ScDocShell* pNewDocShell,
116 							const ScAddress& rNewPos,
117 							ScBaseCell* pUndoCell, double nVal, sal_Bool bHeight );
118 	virtual 		~ScUndoEnterValue();
119 
120 	virtual void	Undo();
121 	virtual void	Redo();
122 	virtual void	Repeat(SfxRepeatTarget& rTarget);
123 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
124 
125 	virtual String	GetComment() const;
126 
127 private:
128 	ScAddress		aPos;
129 	ScBaseCell*		pOldCell;
130 	double			nValue;
131 	sal_uLong			nEndChangeAction;
132 	sal_Bool			bNeedHeight;
133 
134 	void			SetChangeTrack();
135 };
136 
137 
138 class ScUndoPutCell: public ScSimpleUndo
139 {
140 public:
141 					TYPEINFO();
142 					ScUndoPutCell( ScDocShell* pNewDocShell,
143 							const ScAddress& rNewPos,
144 							ScBaseCell* pUndoCell, ScBaseCell* pRedoCell, sal_Bool bHeight );
145 	virtual 		~ScUndoPutCell();
146 
147 	virtual void	Undo();
148 	virtual void	Redo();
149 	virtual void	Repeat(SfxRepeatTarget& rTarget);
150 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
151 
152 	virtual String	GetComment() const;
153 
154 private:
155 	ScAddress		aPos;
156 	ScBaseCell*		pOldCell;
157 	ScBaseCell*		pEnteredCell;
158 	sal_uLong			nEndChangeAction;
159 	sal_Bool			bNeedHeight;
160 
161 	void			SetChangeTrack();
162 };
163 
164 
165 class ScUndoPageBreak: public ScSimpleUndo
166 {
167 public:
168 					TYPEINFO();
169 					ScUndoPageBreak( ScDocShell* pNewDocShell,
170 							SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
171 							sal_Bool bNewColumn, sal_Bool bNewInsert );
172 	virtual 		~ScUndoPageBreak();
173 
174 	virtual void	Undo();
175 	virtual void	Redo();
176 	virtual void	Repeat(SfxRepeatTarget& rTarget);
177 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
178 
179 	virtual String	GetComment() const;
180 
181 private:
182 	SCCOL			nCol;
183 	SCROW			nRow;
184 	SCTAB			nTab;
185 	sal_Bool			bColumn;		// Spalten- oder Zeilenumbruch
186 	sal_Bool			bInsert;		// Einfuegen oder Loeschen
187 
188 	void			DoChange( sal_Bool bInsert ) const;
189 };
190 
191 class ScUndoPrintZoom: public ScSimpleUndo
192 {
193 public:
194 					TYPEINFO();
195 					ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
196 									sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP );
197 	virtual 		~ScUndoPrintZoom();
198 
199 	virtual void	Undo();
200 	virtual void	Redo();
201 	virtual void	Repeat(SfxRepeatTarget& rTarget);
202 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
203 
204 	virtual String	GetComment() const;
205 
206 private:
207 	SCTAB			nTab;
208 	sal_uInt16			nOldScale;
209 	sal_uInt16			nOldPages;
210 	sal_uInt16			nNewScale;
211 	sal_uInt16			nNewPages;
212 
213 	void			DoChange( sal_Bool bUndo );
214 };
215 
216 class ScUndoThesaurus: public ScSimpleUndo
217 {
218 public:
219 					TYPEINFO();
220 					ScUndoThesaurus( ScDocShell* pNewDocShell,
221 							SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
222 							const String& rNewUndoStr, const EditTextObject* pUndoTObj,
223 							const String& rNewRedoStr, const EditTextObject* pRedoTObj);
224 	virtual 		~ScUndoThesaurus();
225 
226 	virtual void	Undo();
227 	virtual void	Redo();
228 	virtual void	Repeat(SfxRepeatTarget& rTarget);
229 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
230 
231 	virtual String	GetComment() const;
232 
233 private:
234 	SCCOL			nCol;
235 	SCROW			nRow;
236 	SCTAB			nTab;
237 	String			aUndoStr;			// Daten bei StringZelle
238 	EditTextObject* pUndoTObject;		//       bei EditZelle
239 	String			aRedoStr;
240 	EditTextObject* pRedoTObject;
241 	sal_uLong			nEndChangeAction;
242 
243 	void			DoChange( sal_Bool bUndo, const String& rStr,
244 								const EditTextObject* pTObj );
245 	void			SetChangeTrack( ScBaseCell* pOldCell );
246 };
247 
248 // ============================================================================
249 
250 /** Undo action for inserting, removing, and replacing a cell note. */
251 class ScUndoReplaceNote : public ScSimpleUndo
252 {
253 public:
254                     TYPEINFO();
255 
256     /** Constructs an undo action for inserting or removing a cell note. */
257                     ScUndoReplaceNote(
258                         ScDocShell& rDocShell,
259                         const ScAddress& rPos,
260                         const ScNoteData& rNoteData,
261                         bool bInsert,
262                         SdrUndoAction* pDrawUndo );
263 
264     /** Constructs an undo action for replacing a cell note with another. */
265                     ScUndoReplaceNote(
266                         ScDocShell& rDocShell,
267                         const ScAddress& rPos,
268                         const ScNoteData& rOldData,
269                         const ScNoteData& rNewData,
270                         SdrUndoAction* pDrawUndo );
271 
272     virtual         ~ScUndoReplaceNote();
273 
274     virtual void    Undo();
275     virtual void    Redo();
276     virtual void    Repeat( SfxRepeatTarget& rTarget );
277     virtual sal_Bool    CanRepeat( SfxRepeatTarget& rTarget ) const;
278 
279     virtual String  GetComment() const;
280 
281 private:
282     void            DoInsertNote( const ScNoteData& rNoteData );
283     void            DoRemoveNote( const ScNoteData& rNoteData );
284 
285 private:
286     ScAddress       maPos;
287     ScNoteData      maOldData;
288     ScNoteData      maNewData;
289     SdrUndoAction*  mpDrawUndo;
290 };
291 
292 // ============================================================================
293 
294 /** Undo action for showing or hiding a cell note caption. */
295 class ScUndoShowHideNote : public ScSimpleUndo
296 {
297 public:
298 					TYPEINFO();
299 					ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
300 	virtual 		~ScUndoShowHideNote();
301 
302 	virtual void	Undo();
303 	virtual void	Redo();
304 	virtual void	Repeat( SfxRepeatTarget& rTarget );
305 	virtual sal_Bool	CanRepeat( SfxRepeatTarget& rTarget ) const;
306 
307 	virtual String	GetComment() const;
308 
309 private:
310 	ScAddress		maPos;
311 	bool			mbShown;
312 };
313 
314 // ============================================================================
315 
316 class ScUndoDetective: public ScSimpleUndo
317 {
318 public:
319 					TYPEINFO();
320 					ScUndoDetective( ScDocShell* pNewDocShell,
321 									SdrUndoAction* pDraw, const ScDetOpData* pOperation,
322 									ScDetOpList* pUndoList = NULL );
323 	virtual 		~ScUndoDetective();
324 
325 	virtual void	Undo();
326 	virtual void	Redo();
327 	virtual void	Repeat(SfxRepeatTarget& rTarget);
328 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
329 
330 	virtual String	GetComment() const;
331 
332 private:
333 	sal_Bool			bIsDelete;
334 	ScDetOpList*	pOldList;
335 	sal_uInt16			nAction;
336 	ScAddress		aPos;
337 	SdrUndoAction*	pDrawUndo;
338 };
339 
340 
341 class ScUndoRangeNames: public ScSimpleUndo
342 {
343 public:
344 					TYPEINFO();
345 					ScUndoRangeNames( ScDocShell* pNewDocShell,
346 										ScRangeName* pOld, ScRangeName* pNew );
347 	virtual 		~ScUndoRangeNames();
348 
349 	virtual void	Undo();
350 	virtual void	Redo();
351 	virtual void	Repeat(SfxRepeatTarget& rTarget);
352 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
353 
354 	virtual String	GetComment() const;
355 
356 private:
357 	ScRangeName*	pOldRanges;
358 	ScRangeName*	pNewRanges;
359 
360 	void			DoChange( sal_Bool bUndo );
361 };
362 
363 
364 
365 #endif
366 
367