Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / undotab.hxx
blob9eda6cb060a7c2295ac6cac79ef46981a8f3d542
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_UNDOTAB_HXX
21 #define SC_UNDOTAB_HXX
23 #include "undobase.hxx"
24 #include "formula/grammar.hxx"
25 #include <tools/color.hxx>
26 #include "tabbgcolor.hxx"
28 #include <com/sun/star/uno/Sequence.hxx>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/scoped_ptr.hpp>
33 #include <memory>
34 #include <vector>
36 class ScDocShell;
37 class ScDocument;
38 class SdrUndoAction;
39 class ScPrintRangeSaver;
40 class SdrObject;
41 class ScDocProtection;
42 class ScTableProtection;
43 class ScMarkData;
45 //----------------------------------------------------------------------------
47 class ScUndoInsertTab : public ScSimpleUndo
49 public:
50 TYPEINFO();
51 ScUndoInsertTab(
52 ScDocShell* pNewDocShell,
53 SCTAB nTabNum,
54 sal_Bool bApp,
55 const OUString& rNewName);
56 virtual ~ScUndoInsertTab();
58 virtual void Undo();
59 virtual void Redo();
60 virtual void Repeat(SfxRepeatTarget& rTarget);
61 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
63 virtual OUString GetComment() const;
65 private:
66 OUString sNewName;
67 SdrUndoAction* pDrawUndo;
68 sal_uLong nEndChangeAction;
69 SCTAB nTab;
70 sal_Bool bAppend;
72 void SetChangeTrack();
75 class ScUndoInsertTables : public ScSimpleUndo
77 public:
78 TYPEINFO();
79 ScUndoInsertTables(
80 ScDocShell* pNewDocShell,
81 SCTAB nTabNum,
82 std::vector<OUString>& newNameList);
83 virtual ~ScUndoInsertTables();
85 virtual void Undo();
86 virtual void Redo();
87 virtual void Repeat(SfxRepeatTarget& rTarget);
88 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
90 virtual OUString GetComment() const;
92 private:
94 SdrUndoAction* pDrawUndo;
95 std::vector<OUString> aNameList;
96 sal_uLong nStartChangeAction;
97 sal_uLong nEndChangeAction;
98 SCTAB nTab;
100 void SetChangeTrack();
104 class ScUndoDeleteTab: public ScMoveUndo
106 public:
107 TYPEINFO();
108 ScUndoDeleteTab(
109 ScDocShell* pNewDocShell,
110 const std::vector<SCTAB> &theTabs, //SCTAB nNewTab,
111 ScDocument* pUndoDocument,
112 ScRefUndoData* pRefData );
113 virtual ~ScUndoDeleteTab();
115 virtual void Undo();
116 virtual void Redo();
117 virtual void Repeat(SfxRepeatTarget& rTarget);
118 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
120 virtual OUString GetComment() const;
122 private:
123 std::vector<SCTAB> theTabs;
124 sal_uLong nStartChangeAction;
125 sal_uLong nEndChangeAction;
127 void SetChangeTrack();
131 class ScUndoRenameTab: public ScSimpleUndo
133 public:
134 TYPEINFO();
135 ScUndoRenameTab(
136 ScDocShell* pNewDocShell,
137 SCTAB nT,
138 const OUString& rOldName,
139 const OUString& rNewName);
140 virtual ~ScUndoRenameTab();
142 virtual void Undo();
143 virtual void Redo();
144 virtual void Repeat(SfxRepeatTarget& rTarget);
145 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
147 virtual OUString GetComment() const;
149 private:
150 SCTAB nTab;
151 OUString sOldName;
152 OUString sNewName;
154 void DoChange( SCTAB nTab, const OUString& rName ) const;
158 class ScUndoMoveTab: public ScSimpleUndo
160 public:
161 TYPEINFO();
162 ScUndoMoveTab(
163 ScDocShell* pNewDocShell,
164 ::std::vector<SCTAB>* pOldTabs,
165 ::std::vector<SCTAB>* pNewTabs,
166 ::std::vector< OUString>* pOldNames = NULL,
167 ::std::vector< OUString>* pNewNames = NULL );
169 virtual ~ScUndoMoveTab();
171 virtual void Undo();
172 virtual void Redo();
173 virtual void Repeat(SfxRepeatTarget& rTarget);
174 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
176 virtual OUString GetComment() const;
178 private:
179 ::boost::shared_ptr< ::std::vector<SCTAB> > mpOldTabs;
180 ::boost::shared_ptr< ::std::vector<SCTAB> > mpNewTabs;
181 ::boost::shared_ptr< ::std::vector< OUString> > mpOldNames;
182 ::boost::shared_ptr< ::std::vector< OUString> > mpNewNames;
184 void DoChange( sal_Bool bUndo ) const;
188 class ScUndoCopyTab: public ScSimpleUndo
190 public:
191 TYPEINFO();
192 ScUndoCopyTab(
193 ScDocShell* pNewDocShell,
194 ::std::vector<SCTAB>* pOldTabs,
195 ::std::vector<SCTAB>* pNewTabs,
196 ::std::vector< OUString>* pNewNames = NULL );
198 virtual ~ScUndoCopyTab();
200 virtual void Undo();
201 virtual void Redo();
202 virtual void Repeat(SfxRepeatTarget& rTarget);
203 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
205 virtual OUString GetComment() const;
207 private:
208 ::boost::shared_ptr< ::std::vector<SCTAB> > mpOldTabs;
209 ::boost::shared_ptr< ::std::vector<SCTAB> > mpNewTabs;
210 ::boost::shared_ptr< ::std::vector< OUString> > mpNewNames;
211 SdrUndoAction* pDrawUndo;
213 void DoChange() const;
216 class ScUndoTabColor: public ScSimpleUndo
218 public:
219 TYPEINFO();
220 ScUndoTabColor(
221 ScDocShell* pNewDocShell,
222 SCTAB nT,
223 const Color& aOTabBgColor,
224 const Color& aNTabBgColor);
225 ScUndoTabColor(
226 ScDocShell* pNewDocShell,
227 const ScUndoTabColorInfo::List& rUndoTabColorList);
228 virtual ~ScUndoTabColor();
230 virtual void Undo();
231 virtual void Redo();
232 virtual void Repeat(SfxRepeatTarget& rTarget);
233 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
235 virtual OUString GetComment() const;
237 private:
238 ScUndoTabColorInfo::List aTabColorList;
240 void DoChange(bool bUndoType) const;
243 class ScUndoMakeScenario: public ScSimpleUndo
245 public:
246 TYPEINFO();
247 ScUndoMakeScenario(
248 ScDocShell* pNewDocShell,
249 SCTAB nSrc, SCTAB nDest,
250 const OUString& rN, const OUString& rC,
251 const Color& rCol, sal_uInt16 nF,
252 const ScMarkData& rMark );
253 virtual ~ScUndoMakeScenario();
255 virtual void Undo();
256 virtual void Redo();
257 virtual void Repeat(SfxRepeatTarget& rTarget);
258 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
260 virtual OUString GetComment() const;
262 private:
263 boost::scoped_ptr<ScMarkData> mpMarkData;
264 SCTAB nSrcTab;
265 SCTAB nDestTab;
266 OUString aName;
267 OUString aComment;
268 Color aColor;
269 sal_uInt16 nFlags;
270 SdrUndoAction* pDrawUndo;
274 class ScUndoImportTab : public ScSimpleUndo
276 public:
277 TYPEINFO();
278 ScUndoImportTab(
279 ScDocShell* pShell,
280 SCTAB nNewTab, SCTAB nNewCount );
281 virtual ~ScUndoImportTab();
283 virtual void Undo();
284 virtual void Redo();
285 virtual void Repeat(SfxRepeatTarget& rTarget);
286 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
288 virtual OUString GetComment() const;
290 private:
291 SCTAB nTab;
292 SCTAB nCount;
293 ScDocument* pRedoDoc;
294 SdrUndoAction* pDrawUndo;
296 void DoChange() const;
300 class ScUndoRemoveLink : public ScSimpleUndo
302 public:
303 TYPEINFO();
304 ScUndoRemoveLink( // Call before delete!
305 ScDocShell* pShell,
306 const OUString& rDoc );
307 virtual ~ScUndoRemoveLink();
309 virtual void Undo();
310 virtual void Redo();
311 virtual void Repeat(SfxRepeatTarget& rTarget);
312 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
314 virtual OUString GetComment() const;
316 private:
317 OUString aDocName;
318 OUString aFltName;
319 OUString aOptions;
320 sal_uLong nRefreshDelay;
321 sal_uInt16 nCount;
322 SCTAB* pTabs;
323 sal_uInt8* pModes;
324 OUString* pTabNames;
326 void DoChange( sal_Bool bLink ) const;
330 class ScUndoShowHideTab : public ScSimpleUndo
332 public:
333 TYPEINFO();
334 ScUndoShowHideTab(
335 ScDocShell* pShell,
336 const std::vector<SCTAB>& newUndoTabs,
337 sal_Bool bNewShow );
338 virtual ~ScUndoShowHideTab();
340 virtual void Undo();
341 virtual void Redo();
342 virtual void Repeat(SfxRepeatTarget& rTarget);
343 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
345 virtual OUString GetComment() const;
347 private:
348 std::vector<SCTAB> undoTabs;
349 sal_Bool bShow;
351 void DoChange( sal_Bool bShow ) const;
354 // ============================================================================
356 /** This class implements undo & redo of document protect & unprotect
357 operations. */
358 class ScUndoDocProtect : public ScSimpleUndo
360 public:
361 SAL_WNODEPRECATED_DECLARATIONS_PUSH
362 ScUndoDocProtect(ScDocShell* pShell, ::std::auto_ptr<ScDocProtection> pProtectSettings);
363 SAL_WNODEPRECATED_DECLARATIONS_POP
364 virtual ~ScUndoDocProtect();
366 virtual void Undo();
367 virtual void Redo();
368 virtual void Repeat(SfxRepeatTarget& rTarget);
369 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
371 virtual OUString GetComment() const;
373 private:
374 SAL_WNODEPRECATED_DECLARATIONS_PUSH
375 ::std::auto_ptr<ScDocProtection> mpProtectSettings;
376 SAL_WNODEPRECATED_DECLARATIONS_POP
378 void DoProtect(bool bProtect);
381 // ============================================================================
383 /** This class implements undo & redo of both protect and unprotect of
384 sheet. */
385 class ScUndoTabProtect : public ScSimpleUndo
387 public:
388 SAL_WNODEPRECATED_DECLARATIONS_PUSH
389 ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab,
390 ::std::auto_ptr<ScTableProtection> pProtectSettings);
391 SAL_WNODEPRECATED_DECLARATIONS_POP
392 virtual ~ScUndoTabProtect();
394 virtual void Undo();
395 virtual void Redo();
396 virtual void Repeat(SfxRepeatTarget& rTarget);
397 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
399 virtual OUString GetComment() const;
401 private:
402 SCTAB mnTab;
403 SAL_WNODEPRECATED_DECLARATIONS_PUSH
404 ::std::auto_ptr<ScTableProtection> mpProtectSettings;
405 SAL_WNODEPRECATED_DECLARATIONS_POP
407 void DoProtect(bool bProtect);
411 class ScUndoPrintRange : public ScSimpleUndo
413 public:
414 TYPEINFO();
415 ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab,
416 ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew );
417 virtual ~ScUndoPrintRange();
419 virtual void Undo();
420 virtual void Redo();
421 virtual void Repeat(SfxRepeatTarget& rTarget);
422 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
424 virtual OUString GetComment() const;
426 private:
427 SCTAB nTab;
428 ScPrintRangeSaver* pOldRanges;
429 ScPrintRangeSaver* pNewRanges;
431 void DoChange( sal_Bool bUndo );
435 class ScUndoScenarioFlags: public ScSimpleUndo
437 public:
438 TYPEINFO();
439 ScUndoScenarioFlags(
440 ScDocShell* pNewDocShell, SCTAB nT,
441 const OUString& rON, const OUString& rNN,
442 const OUString& rOC, const OUString& rNC,
443 const Color& rOCol, const Color& rNCol,
444 sal_uInt16 nOF, sal_uInt16 nNF );
446 virtual ~ScUndoScenarioFlags();
448 virtual void Undo();
449 virtual void Redo();
450 virtual void Repeat(SfxRepeatTarget& rTarget);
451 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
453 virtual OUString GetComment() const;
455 private:
456 SCTAB nTab;
457 OUString aOldName;
458 OUString aNewName;
459 OUString aOldComment;
460 OUString aNewComment;
461 Color aOldColor;
462 Color aNewColor;
463 sal_uInt16 nOldFlags;
464 sal_uInt16 nNewFlags;
468 class ScUndoRenameObject: public ScSimpleUndo
470 public:
471 TYPEINFO();
472 ScUndoRenameObject(
473 ScDocShell* pNewDocShell, const OUString& rPN,
474 const OUString& rON, const OUString& rNN );
476 virtual ~ScUndoRenameObject();
478 virtual void Undo();
479 virtual void Redo();
480 virtual void Repeat(SfxRepeatTarget& rTarget);
481 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
483 virtual OUString GetComment() const;
485 private:
486 OUString aPersistName; // to find object (works only for OLE objects)
487 OUString aOldName;
488 OUString aNewName;
490 SdrObject* GetObject();
494 class ScUndoLayoutRTL : public ScSimpleUndo
496 public:
497 TYPEINFO();
498 ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, sal_Bool bNewRTL );
499 virtual ~ScUndoLayoutRTL();
501 virtual void Undo();
502 virtual void Redo();
503 virtual void Repeat(SfxRepeatTarget& rTarget);
504 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const;
506 virtual OUString GetComment() const;
508 private:
509 SCTAB nTab;
510 sal_Bool bRTL;
512 void DoChange( sal_Bool bNew );
515 #endif
517 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */