xref: /AOO41X/main/editeng/source/editeng/editundo.hxx (revision 4c5491ea21520f5347760e8fc7d072f082fcde5f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _EDITUNDO_HXX
25 #define _EDITUNDO_HXX
26 
27 #include <editdoc.hxx>
28 #include <editeng/editund2.hxx>
29 #include <editeng/editdata.hxx>
30 
31 #define UNDO_NOACTION           0
32 #define UNDO_NEWUNDO            1
33 #define UNDO_UNDOSDELETED       2
34 #define UNDO_EMPTYGROUPDELETED  3
35 #define UNDO_INVALIDEND         4
36 
37 class ImpEditEngine;
38 class EditView;
39 
40 // -----------------------------------------------------------------------
41 // EditUndoDelContent
42 // ------------------------------------------------------------------------
43 class EditUndoDelContent : public EditUndo
44 {
45 private:
46     sal_Bool            bDelObject;
47     sal_uInt16          nNode;
48     ContentNode*    pContentNode;   // Zeigt auf das gueltige,
49                                     // nicht zerstoerte Objekt!
50 
51 public:
52                     TYPEINFO();
53                     EditUndoDelContent( ImpEditEngine* pImpEE, ContentNode* pNode, sal_uInt16 nPortio );
54                     ~EditUndoDelContent();
55 
56     virtual void    Undo();
57     virtual void    Redo();
58 };
59 
60 // -----------------------------------------------------------------------
61 // EditUndoConnectParas
62 // ------------------------------------------------------------------------
63 class EditUndoConnectParas : public EditUndo
64 {
65 private:
66     sal_uInt16          nNode;
67     sal_uInt16          nSepPos;
68     SfxItemSet      aLeftParaAttribs;
69     SfxItemSet      aRightParaAttribs;
70 
71     // 2 Pointer waeren schoener, aber dann muesste es ein SfxListener sein.
72     String          aLeftStyleName;
73     String          aRightStyleName;
74     SfxStyleFamily  eLeftStyleFamily;
75     SfxStyleFamily  eRightStyleFamily;
76 
77     sal_Bool            bBackward;
78 
79 public:
80                     TYPEINFO();
81                     EditUndoConnectParas( ImpEditEngine* pImpEE, sal_uInt16 nNode, sal_uInt16 nSepPos,
82                                             const SfxItemSet& rLeftParaAttribs, const SfxItemSet& rRightParaAttribs,
83                                             const SfxStyleSheet* pLeftStyle, const SfxStyleSheet* pRightStyle, sal_Bool bBackward );
84                     ~EditUndoConnectParas();
85 
86     virtual void    Undo();
87     virtual void    Redo();
88 };
89 
90 // -----------------------------------------------------------------------
91 // EditUndoSplitPara
92 // ------------------------------------------------------------------------
93 class EditUndoSplitPara : public EditUndo
94 {
95 private:
96     sal_uInt16          nNode;
97     sal_uInt16          nSepPos;
98 
99 public:
100                     TYPEINFO();
101                     EditUndoSplitPara( ImpEditEngine* pImpEE, sal_uInt16 nNode, sal_uInt16 nSepPos );
102                     ~EditUndoSplitPara();
103 
104     virtual void    Undo();
105     virtual void    Redo();
106 };
107 
108 // -----------------------------------------------------------------------
109 // EditUndoInsertChars
110 // ------------------------------------------------------------------------
111 class EditUndoInsertChars : public EditUndo
112 {
113 private:
114     EPaM            aEPaM;
115     String          aText;
116 
117 public:
118                     TYPEINFO();
119                     EditUndoInsertChars( ImpEditEngine* pImpEE, const EPaM& rEPaM, const String& rStr );
120 
GetEPaM()121     const EPaM&     GetEPaM() { return aEPaM; }
GetStr()122     String&         GetStr() { return aText; }
123 
124     virtual void    Undo();
125     virtual void    Redo();
126 
127     virtual sal_Bool    Merge( SfxUndoAction *pNextAction );
128 };
129 
130 // -----------------------------------------------------------------------
131 // EditUndoRemoveChars
132 // ------------------------------------------------------------------------
133 class EditUndoRemoveChars : public EditUndo
134 {
135 private:
136     EPaM            aEPaM;
137     String          aText;
138 
139 public:
140                     TYPEINFO();
141                     EditUndoRemoveChars( ImpEditEngine* pImpEE, const EPaM& rEPaM, const String& rStr );
142 
GetEPaM()143     const EPaM&     GetEPaM() { return aEPaM; }
GetStr()144     String&         GetStr() { return aText; }
145 
146     virtual void    Undo();
147     virtual void    Redo();
148 };
149 
150 // -----------------------------------------------------------------------
151 // EditUndoInsertFeature
152 // ------------------------------------------------------------------------
153 class EditUndoInsertFeature : public EditUndo
154 {
155 private:
156     EPaM            aEPaM;
157     SfxPoolItem*    pFeature;
158 
159 public:
160                     TYPEINFO();
161                     EditUndoInsertFeature( ImpEditEngine* pImpEE, const EPaM& rEPaM,
162                                             const SfxPoolItem& rFeature);
163                     ~EditUndoInsertFeature();
164 
165     virtual void    Undo();
166     virtual void    Redo();
167 };
168 
169 // -----------------------------------------------------------------------
170 // EditUndoMoveParagraphs
171 // ------------------------------------------------------------------------
172 class EditUndoMoveParagraphs: public EditUndo
173 {
174 private:
175     Range           nParagraphs;
176     sal_uInt16          nDest;
177 
178 public:
179                     TYPEINFO();
180                     EditUndoMoveParagraphs( ImpEditEngine* pImpEE, const Range& rParas, sal_uInt16 nDest );
181                     ~EditUndoMoveParagraphs();
182 
183     virtual void    Undo();
184     virtual void    Redo();
185 };
186 
187 // -----------------------------------------------------------------------
188 // EditUndoSetStyleSheet
189 // ------------------------------------------------------------------------
190 class EditUndoSetStyleSheet: public EditUndo
191 {
192 private:
193     sal_uInt16          nPara;
194     XubString       aPrevName;
195     XubString       aNewName;
196     SfxStyleFamily  ePrevFamily;
197     SfxStyleFamily  eNewFamily;
198     SfxItemSet      aPrevParaAttribs;
199 
200 public:
201                     TYPEINFO();
202 
203                     EditUndoSetStyleSheet( ImpEditEngine* pImpEE, sal_uInt16 nPara,
204                         const XubString& rPrevName, SfxStyleFamily ePrevFamily,
205                         const XubString& rNewName, SfxStyleFamily eNewFamily,
206                         const SfxItemSet& rPrevParaAttribs );
207                     ~EditUndoSetStyleSheet();
208 
209     virtual void    Undo();
210     virtual void    Redo();
211 };
212 
213 // -----------------------------------------------------------------------
214 // EditUndoSetParaAttribs
215 // ------------------------------------------------------------------------
216 class EditUndoSetParaAttribs: public EditUndo
217 {
218 private:
219     sal_uInt16          nPara;
220     SfxItemSet      aPrevItems;
221     SfxItemSet      aNewItems;
222 
223 public:
224                     TYPEINFO();
225                     EditUndoSetParaAttribs( ImpEditEngine* pImpEE, sal_uInt16 nPara, const SfxItemSet& rPrevItems, const SfxItemSet& rNewItems );
226                     ~EditUndoSetParaAttribs();
227 
228     virtual void    Undo();
229     virtual void    Redo();
230 };
231 
232 // -----------------------------------------------------------------------
233 // EditUndoSetAttribs
234 // ------------------------------------------------------------------------
235 class EditUndoSetAttribs: public EditUndo
236 {
237 private:
238     ESelection          aESel;
239     SfxItemSet          aNewAttribs;
240     ContentInfoArray    aPrevAttribs;
241 
242     sal_uInt8               nSpecial;
243     sal_Bool                bSetIsRemove;
244     sal_Bool                bRemoveParaAttribs;
245     sal_uInt16              nRemoveWhich;
246 
247     void                ImpSetSelection( EditView* pView );
248 
249 
250 public:
251                         TYPEINFO();
252                         EditUndoSetAttribs( ImpEditEngine* pImpEE, const ESelection& rESel, const SfxItemSet& rNewItems );
253                         ~EditUndoSetAttribs();
254 
GetContentInfos()255     ContentInfoArray&   GetContentInfos()   { return aPrevAttribs; }
GetNewAttribs()256     SfxItemSet&         GetNewAttribs()     { return aNewAttribs; }
257 
SetSpecial(sal_uInt8 n)258     void                SetSpecial( sal_uInt8 n )           { nSpecial = n; }
SetRemoveAttribs(sal_Bool b)259     void                SetRemoveAttribs( sal_Bool b )      { bSetIsRemove = b; }
SetRemoveParaAttribs(sal_Bool b)260     void                SetRemoveParaAttribs( sal_Bool b )  { bRemoveParaAttribs = b; }
SetRemoveWhich(sal_uInt16 n)261     void                SetRemoveWhich( sal_uInt16 n )      { nRemoveWhich = n; }
262 
263     virtual void        Undo();
264     virtual void        Redo();
265 };
266 
267 // -----------------------------------------------------------------------
268 // EditUndoTransliteration
269 // ------------------------------------------------------------------------
270 class EditUndoTransliteration: public EditUndo
271 {
272 private:
273     ESelection          aOldESel;
274     ESelection          aNewESel;
275 
276     sal_Int32           nMode;
277     EditTextObject*     pTxtObj;
278     String              aText;
279 
280 public:
281                         TYPEINFO();
282                         EditUndoTransliteration( ImpEditEngine* pImpEE, const ESelection& rESel, sal_Int32 nMode );
283                         ~EditUndoTransliteration();
284 
SetText(const String & rText)285     void                SetText( const String& rText ) { aText = rText; }
SetText(EditTextObject * pObj)286     void                SetText( EditTextObject* pObj ) { pTxtObj = pObj; }
SetNewSelection(const ESelection & rSel)287     void                SetNewSelection( const ESelection& rSel ) { aNewESel = rSel; }
288 
289     virtual void        Undo();
290     virtual void        Redo();
291 };
292 
293 // -----------------------------------------------------------------------
294 // EditUndoMarkSelection
295 // ------------------------------------------------------------------------
296 class EditUndoMarkSelection: public EditUndo
297 {
298 private:
299     ESelection      aSelection;
300 
301 public:
302                     TYPEINFO();
303                     EditUndoMarkSelection( ImpEditEngine* pImpEE, const ESelection& rSel );
304                     ~EditUndoMarkSelection();
305 
306     virtual void    Undo();
307     virtual void    Redo();
308 };
309 
310 
311 #endif // _EDITUNDO_HXX
312