xref: /aoo4110/main/sw/source/core/inc/SwUndoFmt.hxx (revision b1cdbd2c)
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 #ifndef SW_UNDO_TXT_FMT_COLL_HXX
24 #define SW_UNDO_TXT_FMT_COLL_HXX
25 
26 #include <undobj.hxx>
27 #include <swundo.hxx>
28 #include <numrule.hxx>
29 
30 
31 class SwDoc;
32 class SwTxtFmtColl;
33 class String;
34 class SwRewriter;
35 class SfxItemSet;
36 
37 class SwUndoFmtCreate : public SwUndo
38 {
39 protected:
40     SwFmt * pNew;
41     String sDerivedFrom;
42     SwDoc * pDoc;
43     mutable String sNewName;
44     SfxItemSet * pNewSet;
45     sal_uInt16 nId;     // FmtId related
46     sal_Bool bAuto;
47 
48 public:
49 
50     SwUndoFmtCreate(SwUndoId nUndoId, SwFmt * pNew, SwFmt * pDerivedFrom,
51                     SwDoc * pDoc);
52     virtual ~SwUndoFmtCreate();
53 
54     virtual void UndoImpl( ::sw::UndoRedoContext & );
55     virtual void RedoImpl( ::sw::UndoRedoContext & );
56 
57     virtual SwRewriter GetRewriter() const;
58 
59     virtual SwFmt * Create(SwFmt * pDerivedFrom) = 0;
60     virtual void Delete() = 0;
61     virtual SwFmt * Find(const String & rName) const = 0;
62 };
63 
64 class SwUndoFmtDelete : public SwUndo
65 {
66 protected:
67     String sDerivedFrom;
68     SwDoc * pDoc;
69     String sOldName;
70     SfxItemSet aOldSet;
71     sal_uInt16 nId;     // FmtId related
72     sal_Bool bAuto;
73 
74 public:
75     SwUndoFmtDelete(SwUndoId nUndoId, SwFmt * pOld, SwDoc * pDoc);
76     ~SwUndoFmtDelete();
77 
78     virtual void UndoImpl( ::sw::UndoRedoContext & );
79     virtual void RedoImpl( ::sw::UndoRedoContext & );
80 
81     virtual SwRewriter GetRewriter() const;
82 
83     virtual SwFmt * Create(SwFmt * pDerivedFrom) = 0;
84     virtual void Delete(SwFmt * pFmt) = 0;
85     virtual SwFmt * Find(const String & rName) const = 0;
86 };
87 
88 class SwUndoRenameFmt : public SwUndo
89 {
90 protected:
91     String sOldName, sNewName;
92     SwDoc * pDoc;
93 //    SwUndoId nId;
94 
95 public:
96     SwUndoRenameFmt(SwUndoId nUndoId, const String & sOldName,
97                     const String & sNewName,
98                     SwDoc * pDoc);
99     ~SwUndoRenameFmt();
100 
101     virtual void UndoImpl( ::sw::UndoRedoContext & );
102     virtual void RedoImpl( ::sw::UndoRedoContext & );
103 
104     SwRewriter GetRewriter() const;
105 
106     virtual SwFmt * Find(const String & rName) const = 0;
107 };
108 
109 class SwUndoTxtFmtCollCreate : public SwUndoFmtCreate
110 {
111 public:
112     SwUndoTxtFmtCollCreate(SwTxtFmtColl * pNew, SwTxtFmtColl * pDerivedFrom,
113                            SwDoc * pDoc);
114 
115     virtual SwFmt * Create(SwFmt * pDerivedFrom);
116     virtual void Delete();
117     virtual SwFmt * Find(const String & rName) const;
118 };
119 
120 class SwUndoTxtFmtCollDelete : public SwUndoFmtDelete
121 {
122 public:
123     SwUndoTxtFmtCollDelete(SwTxtFmtColl * pOld, SwDoc * pDoc);
124 
125     virtual SwFmt * Create(SwFmt * pDerivedFrom);
126     virtual void Delete(SwFmt * pFmt);
127     virtual SwFmt * Find(const String & rName) const;
128 };
129 
130 class SwUndoRenameFmtColl : public SwUndoRenameFmt
131 {
132 public:
133     SwUndoRenameFmtColl(const String & sOldName,
134                         const String & sNewName,
135                         SwDoc * pDoc);
136 
137     virtual SwFmt * Find(const String & rName) const;
138 };
139 
140 class SwUndoCharFmtCreate : public SwUndoFmtCreate
141 {
142 public:
143     SwUndoCharFmtCreate(SwCharFmt * pNew, SwCharFmt * pDerivedFrom,
144                            SwDoc * pDoc);
145 
146     virtual SwFmt * Create(SwFmt * pDerivedFrom);
147     virtual void Delete();
148     virtual SwFmt * Find(const String & rName) const;
149 };
150 
151 class SwUndoCharFmtDelete : public SwUndoFmtDelete
152 {
153 public:
154     SwUndoCharFmtDelete(SwCharFmt * pOld, SwDoc * pDoc);
155 
156     virtual SwFmt * Create(SwFmt * pDerivedFrom);
157     virtual void Delete(SwFmt * pFmt);
158     virtual SwFmt * Find(const String & rName) const;
159 };
160 
161 class SwUndoRenameCharFmt : public SwUndoRenameFmt
162 {
163 public:
164     SwUndoRenameCharFmt(const String & sOldName,
165                         const String & sNewName,
166                         SwDoc * pDoc);
167 
168     virtual SwFmt * Find(const String & rName) const;
169 };
170 
171 class SwUndoFrmFmtCreate : public SwUndoFmtCreate
172 {
173     sal_Bool bAuto;
174 
175 public:
176     SwUndoFrmFmtCreate(SwFrmFmt * pNew, SwFrmFmt * pDerivedFrom,
177                        SwDoc * pDoc);
178 
179     virtual SwFmt * Create(SwFmt * pDerivedFrom);
180     virtual void Delete();
181     virtual SwFmt * Find(const String & rName) const;
182 };
183 
184 class SwUndoFrmFmtDelete : public SwUndoFmtDelete
185 {
186 public:
187     SwUndoFrmFmtDelete(SwFrmFmt * pOld, SwDoc * pDoc);
188 
189     virtual SwFmt * Create(SwFmt * pDerivedFrom);
190     virtual void Delete(SwFmt * pFmt);
191     virtual SwFmt * Find(const String & rName) const;
192 };
193 
194 class SwUndoRenameFrmFmt : public SwUndoRenameFmt
195 {
196 public:
197     SwUndoRenameFrmFmt(const String & sOldName,
198                        const String & sNewName,
199                        SwDoc * pDoc);
200 
201     virtual SwFmt * Find(const String & rName) const;
202 };
203 
204 class SwUndoNumruleCreate : public SwUndo
205 {
206     const SwNumRule * pNew;
207     mutable SwNumRule aNew;
208     SwDoc * pDoc;
209     mutable bool bInitialized;
210 
211 public:
212     SwUndoNumruleCreate(const SwNumRule * pNew, SwDoc * pDoc);
213 
214     virtual void UndoImpl( ::sw::UndoRedoContext & );
215     virtual void RedoImpl( ::sw::UndoRedoContext & );
216 
217     SwRewriter GetRewriter() const;
218 };
219 
220 class SwUndoNumruleDelete : public SwUndo
221 {
222     SwNumRule aOld;
223     SwDoc * pDoc;
224 
225 public:
226     SwUndoNumruleDelete(const SwNumRule  & aRule, SwDoc * pDoc);
227 
228     virtual void UndoImpl( ::sw::UndoRedoContext & );
229     virtual void RedoImpl( ::sw::UndoRedoContext & );
230 
231     SwRewriter GetRewriter() const;
232 };
233 
234 class SwUndoNumruleRename : public SwUndo
235 {
236     String aOldName, aNewName;
237     SwDoc * pDoc;
238 
239  public:
240     SwUndoNumruleRename(const String & aOldName, const String & aNewName,
241                         SwDoc * pDoc);
242 
243     virtual void UndoImpl( ::sw::UndoRedoContext & );
244     virtual void RedoImpl( ::sw::UndoRedoContext & );
245 
246     SwRewriter GetRewriter() const;
247 };
248 
249 #endif // SW_UNDO_TXT_FMT_COLL_HXX
250