xref: /AOO41X/main/sc/source/ui/inc/undocell.hxx (revision 38d50f7b14e1cf975d8c6468d9633894cd59b523)
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 SC_UNDOCELL_HXX
25 #define SC_UNDOCELL_HXX
26 
27 #include "undobase.hxx"
28 #include "postit.hxx"
29 
30 class ScDocShell;
31 class ScBaseCell;
32 class ScPatternAttr;
33 class EditTextObject;
34 class SdrUndoAction;
35 class ScDetOpList;
36 class ScDetOpData;
37 class ScRangeName;
38 
39 //----------------------------------------------------------------------------
40 
41 class ScUndoCursorAttr: public ScSimpleUndo
42 {
43 public:
44                     TYPEINFO();
45                     ScUndoCursorAttr( ScDocShell* pNewDocShell,
46                             SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
47                             const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
48                             const ScPatternAttr* pApplyPat, sal_Bool bAutomatic );
49     virtual         ~ScUndoCursorAttr();
50 
51     virtual void    Undo();
52     virtual void    Redo();
53     virtual void    Repeat(SfxRepeatTarget& rTarget);
54     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
55 
56     virtual String  GetComment() const;
57 
58 private:
59     SCCOL           nCol;
60     SCROW           nRow;
61     SCTAB           nTab;
62     ScPatternAttr*  pOldPattern;
63     ScPatternAttr*  pNewPattern;
64     ScPatternAttr*  pApplyPattern;
65     sal_Bool            bIsAutomatic;
66 
67     void            DoChange( const ScPatternAttr* pWhichPattern ) const;
68 };
69 
70 
71 class ScUndoEnterData: public ScSimpleUndo
72 {
73 public:
74                     TYPEINFO();
75                     ScUndoEnterData( ScDocShell* pNewDocShell,
76                             SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
77                             SCTAB nNewCount, SCTAB* pNewTabs,
78                             ScBaseCell** ppOldData, sal_Bool* pHasForm, sal_uLong* pOldForm,
79                             const String& rNewStr, EditTextObject* pObj = NULL );
80     virtual         ~ScUndoEnterData();
81 
82     virtual void    Undo();
83     virtual void    Redo();
84     virtual void    Repeat(SfxRepeatTarget& rTarget);
85     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
86 
87     virtual String  GetComment() const;
88 
89 private:
90     String          aNewString;
91     SCTAB*          pTabs;
92     ScBaseCell**    ppOldCells;
93     sal_Bool*           pHasFormat;
94     sal_uLong*          pOldFormats;
95     EditTextObject* pNewEditData;
96     sal_uLong           nEndChangeAction;
97     SCCOL           nCol;
98     SCROW           nRow;
99     SCTAB           nTab;
100     SCTAB           nCount;             //  markierte Tabellen
101 
102     void            DoChange() const;
103     void            SetChangeTrack();
104 };
105 
106 
107 class ScUndoEnterValue: public ScSimpleUndo
108 {
109 public:
110                     TYPEINFO();
111                     ScUndoEnterValue( ScDocShell* pNewDocShell,
112                             const ScAddress& rNewPos,
113                             ScBaseCell* pUndoCell, double nVal, sal_Bool bHeight );
114     virtual         ~ScUndoEnterValue();
115 
116     virtual void    Undo();
117     virtual void    Redo();
118     virtual void    Repeat(SfxRepeatTarget& rTarget);
119     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
120 
121     virtual String  GetComment() const;
122 
123 private:
124     ScAddress       aPos;
125     ScBaseCell*     pOldCell;
126     double          nValue;
127     sal_uLong           nEndChangeAction;
128     sal_Bool            bNeedHeight;
129 
130     void            SetChangeTrack();
131 };
132 
133 
134 class ScUndoPutCell: public ScSimpleUndo
135 {
136 public:
137                     TYPEINFO();
138                     ScUndoPutCell( ScDocShell* pNewDocShell,
139                             const ScAddress& rNewPos,
140                             ScBaseCell* pUndoCell, ScBaseCell* pRedoCell, sal_Bool bHeight );
141     virtual         ~ScUndoPutCell();
142 
143     virtual void    Undo();
144     virtual void    Redo();
145     virtual void    Repeat(SfxRepeatTarget& rTarget);
146     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
147 
148     virtual String  GetComment() const;
149 
150 private:
151     ScAddress       aPos;
152     ScBaseCell*     pOldCell;
153     ScBaseCell*     pEnteredCell;
154     sal_uLong           nEndChangeAction;
155     sal_Bool            bNeedHeight;
156 
157     void            SetChangeTrack();
158 };
159 
160 
161 class ScUndoPageBreak: public ScSimpleUndo
162 {
163 public:
164                     TYPEINFO();
165                     ScUndoPageBreak( ScDocShell* pNewDocShell,
166                             SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
167                             sal_Bool bNewColumn, sal_Bool bNewInsert );
168     virtual         ~ScUndoPageBreak();
169 
170     virtual void    Undo();
171     virtual void    Redo();
172     virtual void    Repeat(SfxRepeatTarget& rTarget);
173     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
174 
175     virtual String  GetComment() const;
176 
177 private:
178     SCCOL           nCol;
179     SCROW           nRow;
180     SCTAB           nTab;
181     sal_Bool            bColumn;        // Spalten- oder Zeilenumbruch
182     sal_Bool            bInsert;        // Einfuegen oder Loeschen
183 
184     void            DoChange( sal_Bool bInsert ) const;
185 };
186 
187 class ScUndoPrintZoom: public ScSimpleUndo
188 {
189 public:
190                     TYPEINFO();
191                     ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
192                                     sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP );
193     virtual         ~ScUndoPrintZoom();
194 
195     virtual void    Undo();
196     virtual void    Redo();
197     virtual void    Repeat(SfxRepeatTarget& rTarget);
198     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
199 
200     virtual String  GetComment() const;
201 
202 private:
203     SCTAB           nTab;
204     sal_uInt16          nOldScale;
205     sal_uInt16          nOldPages;
206     sal_uInt16          nNewScale;
207     sal_uInt16          nNewPages;
208 
209     void            DoChange( sal_Bool bUndo );
210 };
211 
212 class ScUndoThesaurus: public ScSimpleUndo
213 {
214 public:
215                     TYPEINFO();
216                     ScUndoThesaurus( ScDocShell* pNewDocShell,
217                             SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
218                             const String& rNewUndoStr, const EditTextObject* pUndoTObj,
219                             const String& rNewRedoStr, const EditTextObject* pRedoTObj);
220     virtual         ~ScUndoThesaurus();
221 
222     virtual void    Undo();
223     virtual void    Redo();
224     virtual void    Repeat(SfxRepeatTarget& rTarget);
225     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
226 
227     virtual String  GetComment() const;
228 
229 private:
230     SCCOL           nCol;
231     SCROW           nRow;
232     SCTAB           nTab;
233     String          aUndoStr;           // Daten bei StringZelle
234     EditTextObject* pUndoTObject;       //       bei EditZelle
235     String          aRedoStr;
236     EditTextObject* pRedoTObject;
237     sal_uLong           nEndChangeAction;
238 
239     void            DoChange( sal_Bool bUndo, const String& rStr,
240                                 const EditTextObject* pTObj );
241     void            SetChangeTrack( ScBaseCell* pOldCell );
242 };
243 
244 // ============================================================================
245 
246 /** Undo action for inserting, removing, and replacing a cell note. */
247 class ScUndoReplaceNote : public ScSimpleUndo
248 {
249 public:
250                     TYPEINFO();
251 
252     /** Constructs an undo action for inserting or removing a cell note. */
253                     ScUndoReplaceNote(
254                         ScDocShell& rDocShell,
255                         const ScAddress& rPos,
256                         const ScNoteData& rNoteData,
257                         bool bInsert,
258                         SdrUndoAction* pDrawUndo );
259 
260     /** Constructs an undo action for replacing a cell note with another. */
261                     ScUndoReplaceNote(
262                         ScDocShell& rDocShell,
263                         const ScAddress& rPos,
264                         const ScNoteData& rOldData,
265                         const ScNoteData& rNewData,
266                         SdrUndoAction* pDrawUndo );
267 
268     virtual         ~ScUndoReplaceNote();
269 
270     virtual void    Undo();
271     virtual void    Redo();
272     virtual void    Repeat( SfxRepeatTarget& rTarget );
273     virtual sal_Bool    CanRepeat( SfxRepeatTarget& rTarget ) const;
274 
275     virtual String  GetComment() const;
276 
277 private:
278     void            DoInsertNote( const ScNoteData& rNoteData );
279     void            DoRemoveNote( const ScNoteData& rNoteData );
280 
281 private:
282     ScAddress       maPos;
283     ScNoteData      maOldData;
284     ScNoteData      maNewData;
285     SdrUndoAction*  mpDrawUndo;
286 };
287 
288 // ============================================================================
289 
290 /** Undo action for showing or hiding a cell note caption. */
291 class ScUndoShowHideNote : public ScSimpleUndo
292 {
293 public:
294                     TYPEINFO();
295                     ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
296     virtual         ~ScUndoShowHideNote();
297 
298     virtual void    Undo();
299     virtual void    Redo();
300     virtual void    Repeat( SfxRepeatTarget& rTarget );
301     virtual sal_Bool    CanRepeat( SfxRepeatTarget& rTarget ) const;
302 
303     virtual String  GetComment() const;
304 
305 private:
306     ScAddress       maPos;
307     bool            mbShown;
308 };
309 
310 // ============================================================================
311 
312 class ScUndoDetective: public ScSimpleUndo
313 {
314 public:
315                     TYPEINFO();
316                     ScUndoDetective( ScDocShell* pNewDocShell,
317                                     SdrUndoAction* pDraw, const ScDetOpData* pOperation,
318                                     ScDetOpList* pUndoList = NULL );
319     virtual         ~ScUndoDetective();
320 
321     virtual void    Undo();
322     virtual void    Redo();
323     virtual void    Repeat(SfxRepeatTarget& rTarget);
324     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
325 
326     virtual String  GetComment() const;
327 
328 private:
329     sal_Bool            bIsDelete;
330     ScDetOpList*    pOldList;
331     sal_uInt16          nAction;
332     ScAddress       aPos;
333     SdrUndoAction*  pDrawUndo;
334 };
335 
336 
337 class ScUndoRangeNames: public ScSimpleUndo
338 {
339 public:
340                     TYPEINFO();
341                     ScUndoRangeNames( ScDocShell* pNewDocShell,
342                                         ScRangeName* pOld, ScRangeName* pNew );
343     virtual         ~ScUndoRangeNames();
344 
345     virtual void    Undo();
346     virtual void    Redo();
347     virtual void    Repeat(SfxRepeatTarget& rTarget);
348     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
349 
350     virtual String  GetComment() const;
351 
352 private:
353     ScRangeName*    pOldRanges;
354     ScRangeName*    pNewRanges;
355 
356     void            DoChange( sal_Bool bUndo );
357 };
358 
359 
360 
361 #endif
362 
363