xref: /aoo41x/main/sc/source/ui/inc/undotab.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_UNDOTAB_HXX
29 #define SC_UNDOTAB_HXX
30 
31 #include "undobase.hxx"
32 #include "markdata.hxx"
33 #include "formula/grammar.hxx"
34 #include <tools/color.hxx>
35 #include "tabbgcolor.hxx"
36 
37 #ifndef _SVSTDARR_SHORTS
38 
39 #define _SVSTDARR_SHORTS
40 #include <svl/svstdarr.hxx>
41 
42 #endif
43 
44 #ifndef _SVSTDARR_STRINGS
45 
46 #define _SVSTDARR_STRINGS
47 #include <svl/svstdarr.hxx>
48 
49 #endif
50 
51 #include <com/sun/star/uno/Sequence.hxx>
52 
53 #include <memory>
54 
55 class ScDocShell;
56 class ScDocument;
57 class SdrUndoAction;
58 class ScPrintRangeSaver;
59 class SdrObject;
60 class ScDocProtection;
61 class ScTableProtection;
62 
63 //----------------------------------------------------------------------------
64 
65 class ScUndoInsertTab : public ScSimpleUndo
66 {
67 public:
68 					TYPEINFO();
69 					ScUndoInsertTab(
70 							ScDocShell* pNewDocShell,
71 							SCTAB nTabNum,
72 							sal_Bool bApp,
73 							const String& rNewName);
74 	virtual			~ScUndoInsertTab();
75 
76 	virtual void	Undo();
77 	virtual void	Redo();
78 	virtual void	Repeat(SfxRepeatTarget& rTarget);
79 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
80 
81 	virtual String	GetComment() const;
82 
83 private:
84 	String			sNewName;
85 	SdrUndoAction*	pDrawUndo;
86 	sal_uLong			nEndChangeAction;
87 	SCTAB			nTab;
88 	sal_Bool			bAppend;
89 
90 	void			SetChangeTrack();
91 };
92 
93 class ScUndoInsertTables : public ScSimpleUndo
94 {
95 public:
96 					TYPEINFO();
97 					ScUndoInsertTables(
98 							ScDocShell* pNewDocShell,
99 							SCTAB nTabNum,
100 							sal_Bool bApp,
101 							SvStrings *pNewNameList);
102 	virtual			~ScUndoInsertTables();
103 
104 	virtual void	Undo();
105 	virtual void	Redo();
106 	virtual void	Repeat(SfxRepeatTarget& rTarget);
107 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
108 
109 	virtual String	GetComment() const;
110 
111 private:
112 
113 	SdrUndoAction*	pDrawUndo;
114 	SvStrings*		pNameList;
115 	sal_uLong			nStartChangeAction;
116 	sal_uLong			nEndChangeAction;
117 	SCTAB			nTab;
118 	sal_Bool			bAppend;
119 
120 	void			SetChangeTrack();
121 };
122 
123 
124 class ScUndoDeleteTab: public ScMoveUndo	// Draw vom Move fuer geloeschte Tabelle
125 {
126 public:
127 					TYPEINFO();
128 					ScUndoDeleteTab(
129 							ScDocShell* pNewDocShell,
130 							const SvShorts &theTabs,		//SCTAB nNewTab,
131 							ScDocument* pUndoDocument,
132 							ScRefUndoData* pRefData );
133 	virtual			~ScUndoDeleteTab();
134 
135 	virtual void	Undo();
136 	virtual void	Redo();
137 	virtual void	Repeat(SfxRepeatTarget& rTarget);
138 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
139 
140 	virtual String	GetComment() const;
141 
142 private:
143 	SvShorts	theTabs;
144 	sal_uLong			nStartChangeAction;
145 	sal_uLong			nEndChangeAction;
146 
147 	void			SetChangeTrack();
148 };
149 
150 
151 class ScUndoRenameTab: public ScSimpleUndo
152 {
153 public:
154 					TYPEINFO();
155 					ScUndoRenameTab(
156 							ScDocShell* pNewDocShell,
157 							SCTAB nT,
158 							const String& rOldName,
159 							const String& rNewName);
160 	virtual			~ScUndoRenameTab();
161 
162 	virtual void	Undo();
163 	virtual void	Redo();
164 	virtual void	Repeat(SfxRepeatTarget& rTarget);
165 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
166 
167 	virtual String	GetComment() const;
168 
169 private:
170 	SCTAB	nTab;
171 	String	sOldName;
172 	String	sNewName;
173 
174 	void DoChange( SCTAB nTab, const String& rName ) const;
175 };
176 
177 
178 class ScUndoMoveTab: public ScSimpleUndo
179 {
180 public:
181 					TYPEINFO();
182 					ScUndoMoveTab( ScDocShell* pNewDocShell,
183 								  const SvShorts &aOldTab,
184 								  const SvShorts &aNewTab);
185 	virtual			~ScUndoMoveTab();
186 
187 	virtual void	Undo();
188 	virtual void	Redo();
189 	virtual void	Repeat(SfxRepeatTarget& rTarget);
190 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
191 
192 	virtual String	GetComment() const;
193 
194 private:
195 	SvShorts	theOldTabs;
196 	SvShorts	theNewTabs;
197 
198 	void DoChange( sal_Bool bUndo ) const;
199 };
200 
201 
202 class ScUndoCopyTab: public ScSimpleUndo
203 {
204 public:
205 					TYPEINFO();
206 					ScUndoCopyTab(ScDocShell* pNewDocShell,
207 								  const SvShorts &aOldTab,
208 								  const SvShorts &aNewTab);
209 
210 	virtual			~ScUndoCopyTab();
211 
212 	virtual void	Undo();
213 	virtual void	Redo();
214 	virtual void	Repeat(SfxRepeatTarget& rTarget);
215 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
216 
217 	virtual String	GetComment() const;
218 
219 private:
220 	SdrUndoAction*	pDrawUndo;
221 	SvShorts	theOldTabs;
222 	SvShorts	theNewTabs;
223 
224 	void DoChange() const;
225 };
226 
227 class ScUndoTabColor: public ScSimpleUndo
228 {
229 public:
230                     TYPEINFO();
231                     ScUndoTabColor(
232                             ScDocShell* pNewDocShell,
233                             SCTAB nT,
234                             const Color& aOTabBgColor,
235                             const Color& aNTabBgColor);
236                     ScUndoTabColor(
237                             ScDocShell* pNewDocShell,
238                             const ScUndoTabColorInfo::List& rUndoTabColorList);
239     virtual         ~ScUndoTabColor();
240 
241     virtual void    Undo();
242     virtual void    Redo();
243     virtual void    Repeat(SfxRepeatTarget& rTarget);
244     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
245 
246 virtual String	GetComment() const;
247 
248 private:
249     ScUndoTabColorInfo::List aTabColorList;
250     bool    bIsMultipleUndo;
251 
252     void DoChange(bool bUndoType) const;
253 };
254 
255 class ScUndoMakeScenario: public ScSimpleUndo
256 {
257 public:
258 					TYPEINFO();
259 					ScUndoMakeScenario(
260 							ScDocShell* pNewDocShell,
261 							SCTAB nSrc, SCTAB nDest,
262 							const String& rN, const String& rC,
263 							const Color& rCol, sal_uInt16 nF,
264 							const ScMarkData& rMark );
265 	virtual			~ScUndoMakeScenario();
266 
267 	virtual void	Undo();
268 	virtual void	Redo();
269 	virtual void	Repeat(SfxRepeatTarget& rTarget);
270 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
271 
272 	virtual String	GetComment() const;
273 
274 private:
275 	SCTAB		nSrcTab;
276 	SCTAB		nDestTab;
277 	String		aName;
278 	String		aComment;
279 	Color		aColor;
280 	sal_uInt16		nFlags;
281 	ScMarkData	aMarkData;
282     SdrUndoAction* pDrawUndo;
283 };
284 
285 
286 class ScUndoImportTab : public ScSimpleUndo
287 {
288 public:
289 					TYPEINFO();
290 					ScUndoImportTab(
291 							ScDocShell* pShell,
292 							SCTAB nNewTab, SCTAB nNewCount,
293 							sal_Bool bNewLink );
294 	virtual			~ScUndoImportTab();
295 
296 	virtual void	Undo();
297 	virtual void	Redo();
298 	virtual void	Repeat(SfxRepeatTarget& rTarget);
299 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
300 
301 	virtual String	GetComment() const;
302 
303 private:
304 	SCTAB		nTab;
305 	SCTAB		nCount;
306 	sal_Bool		bLink;
307 	ScDocument*	pRedoDoc;
308 	SdrUndoAction*	pDrawUndo;
309 
310 	void DoChange() const;
311 };
312 
313 
314 class ScUndoRemoveLink : public ScSimpleUndo
315 {
316 public:
317 					TYPEINFO();
318 					ScUndoRemoveLink(				// vor dem Loeschen aufrufen!
319 							ScDocShell* pShell,
320 							const String& rDoc );
321 	virtual			~ScUndoRemoveLink();
322 
323 	virtual void	Undo();
324 	virtual void	Redo();
325 	virtual void	Repeat(SfxRepeatTarget& rTarget);
326 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
327 
328 	virtual String	GetComment() const;
329 
330 private:
331 	String	aDocName;
332 	String	aFltName;
333 	String	aOptions;
334 	sal_uLong	nRefreshDelay;
335 	sal_uInt16	nCount;
336 	SCTAB*	pTabs;
337 	sal_uInt8*	pModes;
338 	String*	pTabNames;
339 
340 	void DoChange( sal_Bool bLink ) const;
341 };
342 
343 
344 class ScUndoShowHideTab : public ScSimpleUndo
345 {
346 public:
347 					TYPEINFO();
348 					ScUndoShowHideTab(
349 							ScDocShell* pShell,
350 							SCTAB nNewTab, sal_Bool bNewShow );
351 	virtual			~ScUndoShowHideTab();
352 
353 	virtual void	Undo();
354 	virtual void	Redo();
355 	virtual void	Repeat(SfxRepeatTarget& rTarget);
356 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
357 
358 	virtual String	GetComment() const;
359 
360 private:
361 	SCTAB	nTab;
362 	sal_Bool	bShow;
363 
364 	void DoChange( sal_Bool bShow ) const;
365 };
366 
367 // ============================================================================
368 
369 /** This class implements undo & redo of document protect & unprotect
370     operations. */
371 class ScUndoDocProtect : public ScSimpleUndo
372 {
373 public:
374                     ScUndoDocProtect(ScDocShell* pShell, ::std::auto_ptr<ScDocProtection> pProtectSettings);
375 	virtual			~ScUndoDocProtect();
376 
377 	virtual void	Undo();
378 	virtual void	Redo();
379 	virtual void	Repeat(SfxRepeatTarget& rTarget);
380 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
381 
382 	virtual String	GetComment() const;
383 
384 private:
385     ::std::auto_ptr<ScDocProtection> mpProtectSettings;
386 
387 	void	DoProtect(bool bProtect);
388 };
389 
390 // ============================================================================
391 
392 /** This class implements undo & redo of both protect and unprotect of
393     sheet. */
394 class ScUndoTabProtect : public ScSimpleUndo
395 {
396 public:
397                     ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab,
398                                      ::std::auto_ptr<ScTableProtection> pProtectSettings);
399 	virtual			~ScUndoTabProtect();
400 
401 	virtual void	Undo();
402 	virtual void	Redo();
403 	virtual void	Repeat(SfxRepeatTarget& rTarget);
404 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
405 
406 	virtual String	GetComment() const;
407 
408 private:
409     SCTAB   mnTab;
410     ::std::auto_ptr<ScTableProtection> mpProtectSettings;
411 
412 	void	DoProtect(bool bProtect);
413 };
414 
415 
416 class ScUndoPrintRange : public ScSimpleUndo
417 {
418 public:
419 					TYPEINFO();
420 					ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab,
421 										ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew );
422 	virtual			~ScUndoPrintRange();
423 
424 	virtual void	Undo();
425 	virtual void	Redo();
426 	virtual void	Repeat(SfxRepeatTarget& rTarget);
427 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
428 
429 	virtual String	GetComment() const;
430 
431 private:
432 	SCTAB				nTab;
433 	ScPrintRangeSaver*	pOldRanges;
434 	ScPrintRangeSaver*	pNewRanges;
435 
436 	void DoChange( sal_Bool bUndo );
437 };
438 
439 
440 class ScUndoScenarioFlags: public ScSimpleUndo
441 {
442 public:
443 					TYPEINFO();
444 					ScUndoScenarioFlags(
445 							ScDocShell* pNewDocShell, SCTAB nT,
446 							const String& rON, const String& rNN,
447 							const String& rOC, const String& rNC,
448 							const Color& rOCol, const Color& rNCol,
449 							sal_uInt16 nOF, sal_uInt16 nNF );
450 
451 	virtual			~ScUndoScenarioFlags();
452 
453 	virtual void	Undo();
454 	virtual void	Redo();
455 	virtual void	Repeat(SfxRepeatTarget& rTarget);
456 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
457 
458 	virtual String	GetComment() const;
459 
460 private:
461 	SCTAB	nTab;
462 	String	aOldName;
463 	String	aNewName;
464 	String	aOldComment;
465 	String	aNewComment;
466 	Color	aOldColor;
467 	Color	aNewColor;
468 	sal_uInt16	nOldFlags;
469 	sal_uInt16	nNewFlags;
470 };
471 
472 
473 class ScUndoRenameObject: public ScSimpleUndo
474 {
475 public:
476 					TYPEINFO();
477 					ScUndoRenameObject(
478 							ScDocShell* pNewDocShell, const String& rPN,
479 							const String& rON, const String& rNN );
480 
481 	virtual			~ScUndoRenameObject();
482 
483 	virtual void	Undo();
484 	virtual void	Redo();
485 	virtual void	Repeat(SfxRepeatTarget& rTarget);
486 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
487 
488 	virtual String	GetComment() const;
489 
490 private:
491 	String	aPersistName;		// to find object (works only for OLE objects)
492 	String	aOldName;
493 	String	aNewName;
494 
495 	SdrObject*	GetObject();
496 };
497 
498 
499 class ScUndoLayoutRTL : public ScSimpleUndo
500 {
501 public:
502 					TYPEINFO();
503 					ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, sal_Bool bNewRTL );
504 	virtual			~ScUndoLayoutRTL();
505 
506 	virtual void	Undo();
507 	virtual void	Redo();
508 	virtual void	Repeat(SfxRepeatTarget& rTarget);
509 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
510 
511 	virtual String	GetComment() const;
512 
513 private:
514 	SCTAB	nTab;
515 	sal_Bool	bRTL;
516 
517 	void DoChange( sal_Bool bNew );
518 };
519 
520 
521 //UNUSED2009-05 class ScUndoSetGrammar : public ScSimpleUndo
522 //UNUSED2009-05 {
523 //UNUSED2009-05 public:
524 //UNUSED2009-05                     TYPEINFO();
525 //UNUSED2009-05                     ScUndoSetGrammar( ScDocShell* pShell,
526 //UNUSED2009-05                                       formula::FormulaGrammar::Grammar eGrammar );
527 //UNUSED2009-05     virtual         ~ScUndoSetGrammar();
528 //UNUSED2009-05
529 //UNUSED2009-05     virtual void    Undo();
530 //UNUSED2009-05     virtual void    Redo();
531 //UNUSED2009-05     virtual void    Repeat(SfxRepeatTarget& rTarget);
532 //UNUSED2009-05     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
533 //UNUSED2009-05
534 //UNUSED2009-05     virtual String  GetComment() const;
535 //UNUSED2009-05
536 //UNUSED2009-05 private:
537 //UNUSED2009-05     formula::FormulaGrammar::Grammar meNewGrammar, meOldGrammar;
538 //UNUSED2009-05
539 //UNUSED2009-05     void DoChange( formula::FormulaGrammar::Grammar eGrammar );
540 //UNUSED2009-05 };
541 
542 #endif
543 
544