kspread

commands.h
1/* This file is part of the KDE project
2 Copyright 2004 Ariya Hidayat <ariya@kde.org>
3 Copyright 2004 Laurent Montel <montel@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KSPREAD_COMMANDS
22#define KSPREAD_COMMANDS
23
24#include <KoPageLayout.h>
25#include <KoQueryTrader.h>
26#include <KoUnit.h>
27#include <tqrect.h>
28#include <tqstring.h>
29
30#include <kcommand.h>
31
32#include "kspread_object.h"
33#include "kspread_sheet.h" // for Sheet::LayoutDirection
34
38namespace KSpread
39{
40class Cell;
41class Doc;
42class UndoAction;
43
83
89class UndoWrapperCommand : public KCommand
90{
91public:
92 UndoWrapperCommand( UndoAction* undoAction );
93
94 virtual void execute();
95 virtual void unexecute();
96 virtual TQString name() const;
97
98protected:
99 UndoAction* undoAction;
100};
101
102
107class MergeCellCommand : public KCommand
108{
109public:
110 MergeCellCommand( Cell* cell, int colSpan, int rowSpan );
111
112 virtual void execute();
113 virtual void unexecute();
114 virtual TQString name() const;
115
116protected:
117 Cell* cell;
118 int colSpan;
119 int rowSpan;
120 int oldColSpan;
121 int oldRowSpan;
122 TQString rangeName;
123};
124
125
129class DissociateCellCommand : public KCommand
130{
131public:
132 DissociateCellCommand( Cell* cell );
133
134 virtual void execute();
135 virtual void unexecute();
136 virtual TQString name() const;
137
138protected:
139 Cell* cell;
140 int oldColSpan;
141 int oldRowSpan;
142};
143
144
150
151class RenameSheetCommand : public KCommand
152{
153public:
154 RenameSheetCommand( Sheet* sheet, const TQString &name );
155
156 virtual void execute();
157 virtual void unexecute();
158 virtual TQString name() const;
159
160protected:
161 Sheet* sheet;
162 TQString oldName;
163 TQString newName;
164};
165
166class HideSheetCommand : public KCommand
167{
168public:
169 HideSheetCommand( Sheet* sheet );
170
171 virtual void execute();
172 virtual void unexecute();
173 virtual TQString name() const;
174
175protected:
176 Doc* doc;
177 TQString sheetName;
178};
179
180class ShowSheetCommand : public KCommand
181{
182public:
183 ShowSheetCommand( Sheet* sheet );
184
185 virtual void execute();
186 virtual void unexecute();
187 virtual TQString name() const;
188
189protected:
190 Doc* doc;
191 TQString sheetName;
192};
193
194
195class AddSheetCommand : public KCommand
196{
197public:
198 AddSheetCommand( Sheet* sheet );
199
200 virtual void execute();
201 virtual void unexecute();
202 virtual TQString name() const;
203
204protected:
205 Sheet* sheet;
206 Doc* doc;
207};
208
209
210class RemoveSheetCommand : public KCommand
211{
212public:
213 RemoveSheetCommand( Sheet* sheet );
214
215 virtual void execute();
216 virtual void unexecute();
217 virtual TQString name() const;
218
219protected:
220 Sheet* sheet;
221 Doc* doc;
222};
223
224
228
229class SheetPropertiesCommand : public KCommand
230{
231public:
232 SheetPropertiesCommand( Doc* doc, Sheet* sheet );
233 void setLayoutDirection( Sheet::LayoutDirection direction );
234 void setAutoCalc( bool b );
235 void setShowGrid( bool b );
236 void setShowPageBorders( bool b );
237 void setShowFormula( bool b );
238 void setHideZero( bool b );
239 void setShowFormulaIndicator( bool b );
240 void setShowCommentIndicator( bool b );
241 void setColumnAsNumber( bool b );
242 void setLcMode( bool b );
243 void setCapitalizeFirstLetter( bool b );
244
245 virtual void execute();
246 virtual void unexecute();
247 virtual TQString name() const;
248
249protected:
250 Sheet* sheet;
251 Doc* doc;
252 Sheet::LayoutDirection oldDirection, newDirection;
253 bool oldAutoCalc, newAutoCalc;
254 bool oldShowGrid, newShowGrid;
255 bool oldShowPageBorders, newShowPageBorders;
256 bool oldShowFormula, newShowFormula;
257 bool oldHideZero, newHideZero;
258 bool oldShowFormulaIndicator, newShowFormulaIndicator;
259 bool oldShowCommentIndicator, newShowCommentIndicator;
260 bool oldColumnAsNumber, newColumnAsNumber;
261 bool oldLcMode, newLcMode;
262 bool oldCapitalizeFirstLetter, newCapitalizeFirstLetter;
263};
264
265
266class InsertColumnCommand : public KCommand
267{
268public:
269 InsertColumnCommand( Sheet* s , unsigned int _column, unsigned int _nbCol );
270
271 virtual void execute();
272 virtual void unexecute();
273 virtual TQString name() const;
274
275protected:
276 Doc* doc;
277 TQString sheetName;
278 unsigned int insertPosColumn;
279 unsigned int nbColumnInserted;
280
281};
282
283
284class DefinePrintRangeCommand : public KCommand
285{
286public:
287 DefinePrintRangeCommand( Sheet* sheet );
288
289 virtual void execute();
290 virtual void unexecute();
291 virtual TQString name() const;
292
293protected:
294 Doc* doc;
295 TQString sheetName;
296 TQRect printRangeRedo, printRange;
297};
298
299
300class PaperLayoutCommand : public KCommand
301{
302public:
303 PaperLayoutCommand( Sheet* sheet );
304
305 virtual void execute();
306 virtual void unexecute();
307 virtual TQString name() const;
308
309protected:
310 Doc* doc;
311 TQString sheetName;
312 KoPageLayout pl;
313 KoPageLayout plRedo;
314 KoHeadFoot hf;
315 KoHeadFoot hfRedo;
316 KoUnit::Unit unit;
317 KoUnit::Unit unitRedo;
318 bool printGrid;
319 bool printGridRedo;
320 bool printCommentIndicator;
321 bool printCommentIndicatorRedo;
322 bool printFormulaIndicator;
323 bool printFormulaIndicatorRedo;
324 TQRect printRange;
325 TQRect printRangeRedo;
326 TQPair<int, int> printRepeatColumns;
327 TQPair<int, int> printRepeatColumnsRedo;
328 TQPair<int, int> printRepeatRows;
329 TQPair<int, int> printRepeatRowsRedo;
330 double zoom;
331 double zoomRedo;
332 int pageLimitX;
333 int pageLimitXRedo;
334 int pageLimitY;
335 int pageLimitYRedo;
336
337};
338
339class LinkCommand : public KCommand
340{
341public:
342 LinkCommand( Cell* cell, const TQString& text, const TQString& link );
343
344 virtual void execute();
345 virtual void unexecute();
346 virtual TQString name() const;
347
348protected:
349 Cell* cell;
350 Doc* doc;
351 TQString oldText;
352 TQString oldLink;
353 TQString newText;
354 TQString newLink;
355};
356
357
358class ChangeObjectGeometryCommand : public KCommand
359{
360 public:
361 ChangeObjectGeometryCommand( EmbeddedObject *_obj, const KoPoint &_m_diff, const KoSize &_r_diff );
362 ~ChangeObjectGeometryCommand();
363
364 virtual void execute();
365 virtual void unexecute();
366 virtual TQString name() const;
367
368 protected:
369 KoPoint m_diff;
370 KoSize r_diff;
371 EmbeddedObject *obj;
372 Doc *doc;
373};
374
375class RemoveObjectCommand : public KCommand
376{
377 public:
378 RemoveObjectCommand( EmbeddedObject *_obj, bool _cut = false );
379 ~RemoveObjectCommand();
380
381 virtual void execute();
382 virtual void unexecute();
383 virtual TQString name() const;
384
385 protected:
386 EmbeddedObject *obj;
387 Doc* doc;
388 bool executed;
389 bool cut;
390};
391
392class InsertObjectCommand : public KCommand
393{
394 public:
395 InsertObjectCommand( const KoRect& _geometry, KoDocumentEntry&, Canvas *_canvas ); //child
396 InsertObjectCommand( const KoRect& _geometry, KoDocumentEntry&, const TQRect& _data, Canvas *_canvas ); //chart
397 InsertObjectCommand( const KoRect& _geometry, KURL& _file, Canvas *_canvas ); //picture
398 ~InsertObjectCommand();
399
400 virtual void execute();
401 virtual void unexecute();
402 virtual TQString name() const;
403
404 protected:
405 KoRect geometry;
406 Canvas *canvas;
407 bool executed;
408 KoDocumentEntry entry;
409 TQRect data;
410 ObjType type;
411 KURL file;
412 EmbeddedObject *obj;
413};
414
415class RenameNameObjectCommand : public KNamedCommand
416{
417public:
418 RenameNameObjectCommand( const TQString &_name, const TQString &_objectName, EmbeddedObject *_obj, Doc *_doc );
419 ~RenameNameObjectCommand();
420 void execute();
421 void unexecute();
422protected:
423 TQString oldObjectName, newObjectName;
424 EmbeddedObject *object;
425 Doc *doc;
426 Sheet *m_page;
427};
428
429
430class GeometryPropertiesCommand : public KNamedCommand
431{
432public:
433 enum KgpType { ProtectSize, KeepRatio};
434 GeometryPropertiesCommand( const TQString &name, TQPtrList<EmbeddedObject> &objects,
435 bool newValue, KgpType type, Doc *_doc );
436 GeometryPropertiesCommand( const TQString &name, TQValueList<bool> &lst, TQPtrList<EmbeddedObject> &objects,
437 bool newValue, KgpType type, Doc *_doc );
438 ~GeometryPropertiesCommand();
439
440 virtual void execute();
441 virtual void unexecute();
442
443protected:
444 TQValueList<bool> m_oldValue;
445 TQPtrList<EmbeddedObject> m_objects;
446 bool m_newValue;
447 KgpType m_type;
448 Doc *m_doc;
449};
450
451class MoveObjectByCmd : public KNamedCommand
452{
453public:
454 MoveObjectByCmd( const TQString &_name, const KoPoint &_diff, TQPtrList<EmbeddedObject> &_objects,
455 Doc *_doc, Sheet *m_page );
456 ~MoveObjectByCmd();
457
458 virtual void execute();
459 virtual void unexecute();
460
461protected:
462
463 KoPoint diff;
464 TQPtrList<EmbeddedObject> objects;
465 Doc *doc;
466 Sheet *m_page;
467};
468
469} // namespace KSpread
470
471#endif /* KSPREAD_COMMANDS */
For every cell in the spread sheet there is a Cell object.
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
Abstract base class.
The KSpread namespace.
Definition commands.h:39