xref: /aoo41x/main/sc/source/ui/inc/undobase.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_UNDOBASE_HXX
25cdf0e10cSrcweir #define SC_UNDOBASE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svl/undo.hxx>
28cdf0e10cSrcweir #include "global.hxx"
29cdf0e10cSrcweir #include "address.hxx"
30cdf0e10cSrcweir #include "docsh.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class ScDocument;
33cdf0e10cSrcweir class ScDocShell;
34cdf0e10cSrcweir class SdrUndoAction;
35cdf0e10cSrcweir class ScRefUndoData;
36cdf0e10cSrcweir class ScDBData;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //----------------------------------------------------------------------------
39cdf0e10cSrcweir 
40cdf0e10cSrcweir class ScSimpleUndo: public SfxUndoAction
41cdf0e10cSrcweir {
42cdf0e10cSrcweir public:
43cdf0e10cSrcweir 					TYPEINFO();
44cdf0e10cSrcweir 					ScSimpleUndo( ScDocShell* pDocSh );
45cdf0e10cSrcweir 	virtual 		~ScSimpleUndo();
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	virtual sal_Bool	Merge( SfxUndoAction *pNextAction );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir protected:
50cdf0e10cSrcweir 	ScDocShell*		pDocShell;
51cdf0e10cSrcweir 	SfxUndoAction*	pDetectiveUndo;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     bool            IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     bool            SetViewMarkData( const ScMarkData& rMarkData );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	void			BeginUndo();
58cdf0e10cSrcweir 	void			EndUndo();
59cdf0e10cSrcweir 	void			BeginRedo();
60cdf0e10cSrcweir 	void			EndRedo();
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	static void		ShowTable( SCTAB nTab );
63cdf0e10cSrcweir 	static void		ShowTable( const ScRange& rRange );
64cdf0e10cSrcweir };
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //----------------------------------------------------------------------------
67cdf0e10cSrcweir 
68cdf0e10cSrcweir enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir class ScBlockUndo: public ScSimpleUndo
71cdf0e10cSrcweir {
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir 					TYPEINFO();
74cdf0e10cSrcweir 					ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
75cdf0e10cSrcweir 								 ScBlockUndoMode eBlockMode );
76cdf0e10cSrcweir 	virtual 		~ScBlockUndo();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir protected:
79cdf0e10cSrcweir 	ScRange			aBlockRange;
80cdf0e10cSrcweir 	SdrUndoAction*	pDrawUndo;
81cdf0e10cSrcweir 	ScBlockUndoMode	eMode;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	void			BeginUndo();
84cdf0e10cSrcweir 	void			EndUndo();
85cdf0e10cSrcweir //	void			BeginRedo();
86cdf0e10cSrcweir 	void			EndRedo();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	sal_Bool			AdjustHeight();
89cdf0e10cSrcweir 	void			ShowBlock();
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir //----------------------------------------------------------------------------
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // for functions that act on a database range - takes care of the unnamed database range
95cdf0e10cSrcweir // (collected separately, before the undo action, for showing dialogs etc.)
96cdf0e10cSrcweir 
97cdf0e10cSrcweir class ScDBFuncUndo: public ScSimpleUndo
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     ScDBData*       pAutoDBRange;
100cdf0e10cSrcweir     ScRange         aOriginalRange;
101cdf0e10cSrcweir     SdrUndoAction*  mpDrawUndo;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir public:
104cdf0e10cSrcweir                     TYPEINFO();
105cdf0e10cSrcweir                     ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal, SdrUndoAction* pDrawUndo = 0 );
106cdf0e10cSrcweir     virtual         ~ScDBFuncUndo();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     void            SetDrawUndoAction( SdrUndoAction* pDrawUndo );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     void            BeginUndo();
111cdf0e10cSrcweir     void            EndUndo();
112cdf0e10cSrcweir     void            BeginRedo();
113cdf0e10cSrcweir     void            EndRedo();
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //----------------------------------------------------------------------------
117cdf0e10cSrcweir 
118cdf0e10cSrcweir enum ScMoveUndoMode { SC_UNDO_REFFIRST, SC_UNDO_REFLAST };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir class ScMoveUndo: public ScSimpleUndo				// mit Referenzen
121cdf0e10cSrcweir {
122cdf0e10cSrcweir public:
123cdf0e10cSrcweir 					TYPEINFO();
124cdf0e10cSrcweir 					ScMoveUndo( ScDocShell* pDocSh,
125cdf0e10cSrcweir 								ScDocument* pRefDoc, ScRefUndoData* pRefData,
126cdf0e10cSrcweir 								ScMoveUndoMode eRefMode );
127cdf0e10cSrcweir 	virtual			~ScMoveUndo();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir protected:
130cdf0e10cSrcweir 	SdrUndoAction*	pDrawUndo;
131cdf0e10cSrcweir 	ScDocument*		pRefUndoDoc;
132cdf0e10cSrcweir 	ScRefUndoData*	pRefUndoData;
133cdf0e10cSrcweir 	ScMoveUndoMode	eMode;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	void			BeginUndo();
136cdf0e10cSrcweir 	void			EndUndo();
137cdf0e10cSrcweir //	void			BeginRedo();
138cdf0e10cSrcweir //	void			EndRedo();
139cdf0e10cSrcweir 
140cdf0e10cSrcweir private:
141cdf0e10cSrcweir 	void			UndoRef();
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir //----------------------------------------------------------------------------
145cdf0e10cSrcweir 
146cdf0e10cSrcweir class ScUndoWrapper: public SfxUndoAction           // for manual merging of actions
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     SfxUndoAction*  pWrappedUndo;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir public:
151cdf0e10cSrcweir                             TYPEINFO();
152cdf0e10cSrcweir                             ScUndoWrapper( SfxUndoAction* pUndo );
153cdf0e10cSrcweir     virtual                 ~ScUndoWrapper();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     SfxUndoAction*          GetWrappedUndo()        { return pWrappedUndo; }
156cdf0e10cSrcweir     void                    ForgetWrappedUndo();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     virtual sal_Bool            IsLinked();
159cdf0e10cSrcweir     virtual void            SetLinked( sal_Bool bIsLinked );
160cdf0e10cSrcweir     virtual void            Undo();
161cdf0e10cSrcweir     virtual void            Redo();
162cdf0e10cSrcweir     virtual void            Repeat(SfxRepeatTarget& rTarget);
163cdf0e10cSrcweir     virtual sal_Bool            CanRepeat(SfxRepeatTarget& rTarget) const;
164cdf0e10cSrcweir     virtual sal_Bool            Merge( SfxUndoAction *pNextAction );
165cdf0e10cSrcweir     virtual String          GetComment() const;
166cdf0e10cSrcweir     virtual String          GetRepeatComment(SfxRepeatTarget&) const;
167cdf0e10cSrcweir     virtual sal_uInt16          GetId() const;
168cdf0e10cSrcweir };
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 
171cdf0e10cSrcweir #endif
172cdf0e10cSrcweir 
173