xref: /trunk/main/sc/source/ui/inc/undobase.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_UNDOBASE_HXX
29 #define SC_UNDOBASE_HXX
30 
31 #include <svl/undo.hxx>
32 #include "global.hxx"
33 #include "address.hxx"
34 #include "docsh.hxx"
35 
36 class ScDocument;
37 class ScDocShell;
38 class SdrUndoAction;
39 class ScRefUndoData;
40 class ScDBData;
41 
42 //----------------------------------------------------------------------------
43 
44 class ScSimpleUndo: public SfxUndoAction
45 {
46 public:
47                     TYPEINFO();
48                     ScSimpleUndo( ScDocShell* pDocSh );
49     virtual         ~ScSimpleUndo();
50 
51     virtual sal_Bool    Merge( SfxUndoAction *pNextAction );
52 
53 protected:
54     ScDocShell*     pDocShell;
55     SfxUndoAction*  pDetectiveUndo;
56 
57     bool            IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
58 
59     bool            SetViewMarkData( const ScMarkData& rMarkData );
60 
61     void            BeginUndo();
62     void            EndUndo();
63     void            BeginRedo();
64     void            EndRedo();
65 
66     static void     ShowTable( SCTAB nTab );
67     static void     ShowTable( const ScRange& rRange );
68 };
69 
70 //----------------------------------------------------------------------------
71 
72 enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
73 
74 class ScBlockUndo: public ScSimpleUndo
75 {
76 public:
77                     TYPEINFO();
78                     ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
79                                  ScBlockUndoMode eBlockMode );
80     virtual         ~ScBlockUndo();
81 
82 protected:
83     ScRange         aBlockRange;
84     SdrUndoAction*  pDrawUndo;
85     ScBlockUndoMode eMode;
86 
87     void            BeginUndo();
88     void            EndUndo();
89 //  void            BeginRedo();
90     void            EndRedo();
91 
92     sal_Bool            AdjustHeight();
93     void            ShowBlock();
94 };
95 
96 //----------------------------------------------------------------------------
97 
98 // for functions that act on a database range - takes care of the unnamed database range
99 // (collected separately, before the undo action, for showing dialogs etc.)
100 
101 class ScDBFuncUndo: public ScSimpleUndo
102 {
103     ScDBData*       pAutoDBRange;
104     ScRange         aOriginalRange;
105     SdrUndoAction*  mpDrawUndo;
106 
107 public:
108                     TYPEINFO();
109                     ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal, SdrUndoAction* pDrawUndo = 0 );
110     virtual         ~ScDBFuncUndo();
111 
112     void            SetDrawUndoAction( SdrUndoAction* pDrawUndo );
113 
114     void            BeginUndo();
115     void            EndUndo();
116     void            BeginRedo();
117     void            EndRedo();
118 };
119 
120 //----------------------------------------------------------------------------
121 
122 enum ScMoveUndoMode { SC_UNDO_REFFIRST, SC_UNDO_REFLAST };
123 
124 class ScMoveUndo: public ScSimpleUndo               // mit Referenzen
125 {
126 public:
127                     TYPEINFO();
128                     ScMoveUndo( ScDocShell* pDocSh,
129                                 ScDocument* pRefDoc, ScRefUndoData* pRefData,
130                                 ScMoveUndoMode eRefMode );
131     virtual         ~ScMoveUndo();
132 
133 protected:
134     SdrUndoAction*  pDrawUndo;
135     ScDocument*     pRefUndoDoc;
136     ScRefUndoData*  pRefUndoData;
137     ScMoveUndoMode  eMode;
138 
139     void            BeginUndo();
140     void            EndUndo();
141 //  void            BeginRedo();
142 //  void            EndRedo();
143 
144 private:
145     void            UndoRef();
146 };
147 
148 //----------------------------------------------------------------------------
149 
150 class ScUndoWrapper: public SfxUndoAction           // for manual merging of actions
151 {
152     SfxUndoAction*  pWrappedUndo;
153 
154 public:
155                             TYPEINFO();
156                             ScUndoWrapper( SfxUndoAction* pUndo );
157     virtual                 ~ScUndoWrapper();
158 
159     SfxUndoAction*          GetWrappedUndo()        { return pWrappedUndo; }
160     void                    ForgetWrappedUndo();
161 
162     virtual sal_Bool            IsLinked();
163     virtual void            SetLinked( sal_Bool bIsLinked );
164     virtual void            Undo();
165     virtual void            Redo();
166     virtual void            Repeat(SfxRepeatTarget& rTarget);
167     virtual sal_Bool            CanRepeat(SfxRepeatTarget& rTarget) const;
168     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
169     virtual String          GetComment() const;
170     virtual String          GetRepeatComment(SfxRepeatTarget&) const;
171     virtual sal_uInt16          GetId() const;
172 };
173 
174 
175 #endif
176 
177