Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX
22 :
23 : #include "undobase.hxx"
24 : #include "postit.hxx"
25 : #include "cellvalue.hxx"
26 : #include <cellvalues.hxx>
27 :
28 : #include <boost/shared_ptr.hpp>
29 : #include <boost/scoped_ptr.hpp>
30 :
31 : class ScDocShell;
32 : class ScPatternAttr;
33 : class EditTextObject;
34 : class SdrUndoAction;
35 : class ScDetOpList;
36 : class ScDetOpData;
37 : class ScRangeName;
38 : class ScDocument;
39 :
40 : namespace sc {
41 :
42 : class CellValues;
43 :
44 : }
45 :
46 : class ScUndoCursorAttr: public ScSimpleUndo
47 : {
48 : public:
49 : TYPEINFO_OVERRIDE();
50 : ScUndoCursorAttr( ScDocShell* pNewDocShell,
51 : SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
52 : const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
53 : const ScPatternAttr* pApplyPat, bool bAutomatic );
54 : virtual ~ScUndoCursorAttr();
55 :
56 : virtual void Undo() SAL_OVERRIDE;
57 : virtual void Redo() SAL_OVERRIDE;
58 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
59 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
60 :
61 : virtual OUString GetComment() const SAL_OVERRIDE;
62 :
63 : /** once the objects are passed to this class, their life-cycle is
64 : managed by this class; the calling function must pass new'ed
65 : objects to this method. */
66 : void SetEditData( EditTextObject* pOld, EditTextObject* pNew );
67 :
68 : private:
69 : SCCOL nCol;
70 : SCROW nRow;
71 : SCTAB nTab;
72 : ScPatternAttr* pOldPattern;
73 : ScPatternAttr* pNewPattern;
74 : ScPatternAttr* pApplyPattern;
75 : ::boost::shared_ptr<EditTextObject> pOldEditData;
76 : ::boost::shared_ptr<EditTextObject> pNewEditData;
77 : bool bIsAutomatic;
78 :
79 : void DoChange( const ScPatternAttr* pWhichPattern, const ::boost::shared_ptr<EditTextObject>& pEditData ) const;
80 : };
81 :
82 : class ScUndoEnterData: public ScSimpleUndo
83 : {
84 : public:
85 : TYPEINFO_OVERRIDE();
86 :
87 3495 : struct Value
88 : {
89 : SCTAB mnTab;
90 : bool mbHasFormat;
91 : sal_uInt32 mnFormat;
92 : ScCellValue maCell;
93 :
94 : Value();
95 : };
96 :
97 : typedef std::vector<Value> ValuesType;
98 :
99 : ScUndoEnterData(
100 : ScDocShell* pNewDocShell, const ScAddress& rPos,
101 : ValuesType& rOldValues, const OUString& rNewStr, EditTextObject* pObj = NULL );
102 :
103 : virtual ~ScUndoEnterData();
104 :
105 : virtual void Undo() SAL_OVERRIDE;
106 : virtual void Redo() SAL_OVERRIDE;
107 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
108 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
109 :
110 : virtual OUString GetComment() const SAL_OVERRIDE;
111 :
112 : private:
113 : ValuesType maOldValues;
114 :
115 : OUString maNewString;
116 : boost::scoped_ptr<EditTextObject> mpNewEditData;
117 : sal_uLong mnEndChangeAction;
118 : ScAddress maPos;
119 :
120 : void DoChange() const;
121 : void SetChangeTrack();
122 : };
123 :
124 : class ScUndoEnterValue: public ScSimpleUndo
125 : {
126 : public:
127 : TYPEINFO_OVERRIDE();
128 : ScUndoEnterValue(
129 : ScDocShell* pNewDocShell, const ScAddress& rNewPos,
130 : const ScCellValue& rUndoCell, double nVal );
131 :
132 : virtual ~ScUndoEnterValue();
133 :
134 : virtual void Undo() SAL_OVERRIDE;
135 : virtual void Redo() SAL_OVERRIDE;
136 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
137 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
138 :
139 : virtual OUString GetComment() const SAL_OVERRIDE;
140 :
141 : private:
142 : ScAddress aPos;
143 : ScCellValue maOldCell;
144 : double nValue;
145 : sal_uLong nEndChangeAction;
146 :
147 : void SetChangeTrack();
148 : };
149 :
150 : class ScUndoSetCell : public ScSimpleUndo
151 : {
152 : public:
153 : TYPEINFO_OVERRIDE();
154 : ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal );
155 :
156 : virtual ~ScUndoSetCell();
157 :
158 : virtual void Undo() SAL_OVERRIDE;
159 : virtual void Redo() SAL_OVERRIDE;
160 : virtual void Repeat( SfxRepeatTarget& rTarget ) SAL_OVERRIDE;
161 : virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const SAL_OVERRIDE;
162 : virtual OUString GetComment() const SAL_OVERRIDE;
163 :
164 : private:
165 : void SetChangeTrack();
166 : void SetValue( const ScCellValue& rVal );
167 :
168 : private:
169 : ScAddress maPos;
170 : ScCellValue maOldValue;
171 : ScCellValue maNewValue;
172 : sal_uLong mnEndChangeAction;
173 : };
174 :
175 : class ScUndoPageBreak: public ScSimpleUndo
176 : {
177 : public:
178 : TYPEINFO_OVERRIDE();
179 : ScUndoPageBreak( ScDocShell* pNewDocShell,
180 : SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
181 : bool bNewColumn, bool bNewInsert );
182 : virtual ~ScUndoPageBreak();
183 :
184 : virtual void Undo() SAL_OVERRIDE;
185 : virtual void Redo() SAL_OVERRIDE;
186 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
187 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
188 :
189 : virtual OUString GetComment() const SAL_OVERRIDE;
190 :
191 : private:
192 : SCCOL nCol;
193 : SCROW nRow;
194 : SCTAB nTab;
195 : bool bColumn; // Column or row break
196 : bool bInsert; // Insert or Delete
197 :
198 : void DoChange( bool bInsert ) const;
199 : };
200 :
201 : class ScUndoPrintZoom: public ScSimpleUndo
202 : {
203 : public:
204 : TYPEINFO_OVERRIDE();
205 : ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
206 : sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP );
207 : virtual ~ScUndoPrintZoom();
208 :
209 : virtual void Undo() SAL_OVERRIDE;
210 : virtual void Redo() SAL_OVERRIDE;
211 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
212 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
213 :
214 : virtual OUString GetComment() const SAL_OVERRIDE;
215 :
216 : private:
217 : SCTAB nTab;
218 : sal_uInt16 nOldScale;
219 : sal_uInt16 nOldPages;
220 : sal_uInt16 nNewScale;
221 : sal_uInt16 nNewPages;
222 :
223 : void DoChange( bool bUndo );
224 : };
225 :
226 : class ScUndoThesaurus: public ScSimpleUndo
227 : {
228 : public:
229 : TYPEINFO_OVERRIDE();
230 : ScUndoThesaurus( ScDocShell* pNewDocShell,
231 : SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
232 : const ScCellValue& rOldText, const ScCellValue& rNewText );
233 : virtual ~ScUndoThesaurus();
234 :
235 : virtual void Undo() SAL_OVERRIDE;
236 : virtual void Redo() SAL_OVERRIDE;
237 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
238 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
239 :
240 : virtual OUString GetComment() const SAL_OVERRIDE;
241 :
242 : private:
243 : SCCOL nCol;
244 : SCROW nRow;
245 : SCTAB nTab;
246 : sal_uLong nEndChangeAction;
247 :
248 : ScCellValue maOldText;
249 : ScCellValue maNewText;
250 :
251 : void DoChange( bool bUndo, const ScCellValue& rText );
252 : void SetChangeTrack( const ScCellValue& rOldCell );
253 : };
254 :
255 : /** Undo action for inserting, removing, and replacing a cell note. */
256 : class ScUndoReplaceNote : public ScSimpleUndo
257 : {
258 : public:
259 : TYPEINFO_OVERRIDE();
260 :
261 : /** Constructs an undo action for inserting or removing a cell note. */
262 : ScUndoReplaceNote(
263 : ScDocShell& rDocShell,
264 : const ScAddress& rPos,
265 : const ScNoteData& rNoteData,
266 : bool bInsert,
267 : SdrUndoAction* pDrawUndo );
268 :
269 : /** Constructs an undo action for replacing a cell note with another. */
270 : ScUndoReplaceNote(
271 : ScDocShell& rDocShell,
272 : const ScAddress& rPos,
273 : const ScNoteData& rOldData,
274 : const ScNoteData& rNewData,
275 : SdrUndoAction* pDrawUndo );
276 :
277 : virtual ~ScUndoReplaceNote();
278 :
279 : virtual void Undo() SAL_OVERRIDE;
280 : virtual void Redo() SAL_OVERRIDE;
281 : virtual void Repeat( SfxRepeatTarget& rTarget ) SAL_OVERRIDE;
282 : virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const SAL_OVERRIDE;
283 :
284 : virtual OUString GetComment() const SAL_OVERRIDE;
285 :
286 : private:
287 : void DoInsertNote( const ScNoteData& rNoteData );
288 : void DoRemoveNote( const ScNoteData& rNoteData );
289 :
290 : private:
291 : ScAddress maPos;
292 : ScNoteData maOldData;
293 : ScNoteData maNewData;
294 : SdrUndoAction* mpDrawUndo;
295 : };
296 :
297 : /** Undo action for showing or hiding a cell note caption. */
298 : class ScUndoShowHideNote : public ScSimpleUndo
299 : {
300 : public:
301 : TYPEINFO_OVERRIDE();
302 : ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
303 : virtual ~ScUndoShowHideNote();
304 :
305 : virtual void Undo() SAL_OVERRIDE;
306 : virtual void Redo() SAL_OVERRIDE;
307 : virtual void Repeat( SfxRepeatTarget& rTarget ) SAL_OVERRIDE;
308 : virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const SAL_OVERRIDE;
309 :
310 : virtual OUString GetComment() const SAL_OVERRIDE;
311 :
312 : private:
313 : ScAddress maPos;
314 : bool mbShown;
315 : };
316 :
317 : class ScUndoDetective: public ScSimpleUndo
318 : {
319 : public:
320 : TYPEINFO_OVERRIDE();
321 : ScUndoDetective( ScDocShell* pNewDocShell,
322 : SdrUndoAction* pDraw, const ScDetOpData* pOperation,
323 : ScDetOpList* pUndoList = NULL );
324 : virtual ~ScUndoDetective();
325 :
326 : virtual void Undo() SAL_OVERRIDE;
327 : virtual void Redo() SAL_OVERRIDE;
328 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
329 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
330 :
331 : virtual OUString GetComment() const SAL_OVERRIDE;
332 :
333 : private:
334 : bool bIsDelete;
335 : ScDetOpList* pOldList;
336 : sal_uInt16 nAction;
337 : ScAddress aPos;
338 : SdrUndoAction* pDrawUndo;
339 : };
340 :
341 : class ScUndoRangeNames: public ScSimpleUndo
342 : {
343 : public:
344 : TYPEINFO_OVERRIDE();
345 : //use nTab = -1 for global range names
346 : ScUndoRangeNames( ScDocShell* pNewDocShell,
347 : ScRangeName* pOld, ScRangeName* pNew , SCTAB nTab = -1);
348 : virtual ~ScUndoRangeNames();
349 :
350 : virtual void Undo() SAL_OVERRIDE;
351 : virtual void Redo() SAL_OVERRIDE;
352 : virtual void Repeat(SfxRepeatTarget& rTarget) SAL_OVERRIDE;
353 : virtual bool CanRepeat(SfxRepeatTarget& rTarget) const SAL_OVERRIDE;
354 :
355 : virtual OUString GetComment() const SAL_OVERRIDE;
356 :
357 : private:
358 : ScRangeName* pOldRanges;
359 : ScRangeName* pNewRanges;
360 : SCTAB mnTab;
361 :
362 : void DoChange( bool bUndo );
363 : };
364 :
365 : namespace sc {
366 :
367 : class UndoSetCells : public ScSimpleUndo
368 : {
369 : ScAddress maTopPos;
370 : CellValues maOldValues;
371 : CellValues maNewValues;
372 :
373 : void DoChange( const CellValues& rValues );
374 :
375 : public:
376 : UndoSetCells( ScDocShell* pDocSh, const ScAddress& rTopPos );
377 : virtual ~UndoSetCells();
378 :
379 : virtual void Undo() SAL_OVERRIDE;
380 : virtual void Redo() SAL_OVERRIDE;
381 :
382 : virtual bool CanRepeat( SfxRepeatTarget& ) const SAL_OVERRIDE;
383 : virtual OUString GetComment() const SAL_OVERRIDE;
384 :
385 0 : CellValues& GetOldValues() { return maOldValues;}
386 : void SetNewValues( const std::vector<double>& rVals );
387 : };
388 :
389 : } // namespace sc
390 :
391 : #endif
392 :
393 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|