kspread

commands.h

00001 /* This file is part of the KDE project
00002    Copyright 2004 Ariya Hidayat <ariya@kde.org>
00003    Copyright 2004 Laurent Montel <montel@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KSPREAD_COMMANDS
00022 #define KSPREAD_COMMANDS
00023 
00024 #include <KoPageLayout.h>
00025 #include <KoQueryTrader.h>
00026 #include <KoUnit.h>
00027 #include <qrect.h>
00028 #include <qstring.h>
00029 
00030 #include <kcommand.h>
00031 
00032 #include "kspread_object.h"
00033 #include "kspread_sheet.h" // for Sheet::LayoutDirection
00034 
00038 namespace KSpread
00039 {
00040 class Cell;
00041 class Doc;
00042 class UndoAction;
00043 
00089 class UndoWrapperCommand : public KCommand
00090 {
00091 public:
00092   UndoWrapperCommand( UndoAction* undoAction );
00093 
00094   virtual void execute();
00095   virtual void unexecute();
00096   virtual QString name() const;
00097 
00098 protected:
00099   UndoAction* undoAction;
00100 };
00101 
00102 
00107 class MergeCellCommand : public KCommand
00108 {
00109 public:
00110   MergeCellCommand( Cell* cell, int colSpan, int rowSpan );
00111 
00112   virtual void execute();
00113   virtual void unexecute();
00114   virtual QString name() const;
00115 
00116 protected:
00117   Cell* cell;
00118   int colSpan;
00119   int rowSpan;
00120   int oldColSpan;
00121   int oldRowSpan;
00122   QString rangeName;
00123 };
00124 
00125 
00129 class DissociateCellCommand : public KCommand
00130 {
00131 public:
00132   DissociateCellCommand( Cell* cell );
00133 
00134   virtual void execute();
00135   virtual void unexecute();
00136   virtual QString name() const;
00137 
00138 protected:
00139   Cell* cell;
00140   int oldColSpan;
00141   int oldRowSpan;
00142 };
00143 
00144 
00151 class RenameSheetCommand : public KCommand
00152 {
00153 public:
00154   RenameSheetCommand( Sheet* sheet, const QString &name );
00155 
00156   virtual void execute();
00157   virtual void unexecute();
00158   virtual QString name() const;
00159 
00160 protected:
00161   Sheet* sheet;
00162   QString oldName;
00163   QString newName;
00164 };
00165 
00166 class HideSheetCommand : public KCommand
00167 {
00168 public:
00169   HideSheetCommand( Sheet* sheet );
00170 
00171   virtual void execute();
00172   virtual void unexecute();
00173   virtual QString name() const;
00174 
00175 protected:
00176   Doc* doc;
00177   QString sheetName;
00178 };
00179 
00180 class ShowSheetCommand : public KCommand
00181 {
00182 public:
00183   ShowSheetCommand( Sheet* sheet );
00184 
00185   virtual void execute();
00186   virtual void unexecute();
00187   virtual QString name() const;
00188 
00189 protected:
00190   Doc* doc;
00191   QString sheetName;
00192 };
00193 
00194 
00195 class AddSheetCommand : public KCommand
00196 {
00197 public:
00198   AddSheetCommand( Sheet* sheet );
00199 
00200   virtual void execute();
00201   virtual void unexecute();
00202   virtual QString name() const;
00203 
00204 protected:
00205     Sheet* sheet;
00206     Doc* doc;
00207 };
00208 
00209 
00210 class RemoveSheetCommand : public KCommand
00211 {
00212 public:
00213   RemoveSheetCommand( Sheet* sheet );
00214 
00215   virtual void execute();
00216   virtual void unexecute();
00217   virtual QString name() const;
00218 
00219 protected:
00220     Sheet* sheet;
00221     Doc* doc;
00222 };
00223 
00224 
00229 class SheetPropertiesCommand : public KCommand
00230 {
00231 public:
00232   SheetPropertiesCommand( Doc* doc, Sheet* sheet );
00233   void setLayoutDirection( Sheet::LayoutDirection direction );
00234   void setAutoCalc( bool b );
00235   void setShowGrid( bool b );
00236   void setShowPageBorders( bool b );
00237   void setShowFormula( bool b );
00238   void setHideZero( bool b );
00239   void setShowFormulaIndicator( bool b );
00240   void setShowCommentIndicator( bool b );
00241   void setColumnAsNumber( bool b );
00242   void setLcMode( bool b );
00243   void setCapitalizeFirstLetter( bool b );
00244 
00245   virtual void execute();
00246   virtual void unexecute();
00247   virtual QString name() const;
00248 
00249 protected:
00250   Sheet* sheet;
00251   Doc* doc;
00252   Sheet::LayoutDirection oldDirection, newDirection;
00253   bool oldAutoCalc, newAutoCalc;
00254   bool oldShowGrid, newShowGrid;
00255   bool oldShowPageBorders, newShowPageBorders;
00256   bool oldShowFormula, newShowFormula;
00257   bool oldHideZero, newHideZero;
00258   bool oldShowFormulaIndicator, newShowFormulaIndicator;
00259   bool oldShowCommentIndicator, newShowCommentIndicator;
00260   bool oldColumnAsNumber, newColumnAsNumber;
00261   bool oldLcMode, newLcMode;
00262   bool oldCapitalizeFirstLetter, newCapitalizeFirstLetter;
00263 };
00264 
00265 
00266 class InsertColumnCommand : public KCommand
00267 {
00268 public:
00269   InsertColumnCommand( Sheet* s , unsigned int _column, unsigned int _nbCol );
00270 
00271   virtual void execute();
00272   virtual void unexecute();
00273   virtual QString name() const;
00274 
00275 protected:
00276     Doc* doc;
00277     QString sheetName;
00278     unsigned int insertPosColumn;
00279     unsigned int nbColumnInserted;
00280 
00281 };
00282 
00283 
00284 class DefinePrintRangeCommand : public KCommand
00285 {
00286 public:
00287   DefinePrintRangeCommand( Sheet* sheet );
00288 
00289   virtual void execute();
00290   virtual void unexecute();
00291   virtual QString name() const;
00292 
00293 protected:
00294     Doc* doc;
00295     QString sheetName;
00296     QRect printRangeRedo, printRange;
00297 };
00298 
00299 
00300 class PaperLayoutCommand : public KCommand
00301 {
00302 public:
00303   PaperLayoutCommand( Sheet* sheet );
00304 
00305   virtual void execute();
00306   virtual void unexecute();
00307   virtual QString name() const;
00308 
00309 protected:
00310     Doc* doc;
00311     QString sheetName;
00312     KoPageLayout pl;
00313     KoPageLayout plRedo;
00314     KoHeadFoot hf;
00315     KoHeadFoot hfRedo;
00316     KoUnit::Unit unit;
00317     KoUnit::Unit unitRedo;
00318     bool printGrid;
00319     bool printGridRedo;
00320     bool printCommentIndicator;
00321     bool printCommentIndicatorRedo;
00322     bool printFormulaIndicator;
00323     bool printFormulaIndicatorRedo;
00324     QRect printRange;
00325     QRect printRangeRedo;
00326     QPair<int, int> printRepeatColumns;
00327     QPair<int, int> printRepeatColumnsRedo;
00328     QPair<int, int> printRepeatRows;
00329     QPair<int, int> printRepeatRowsRedo;
00330     double zoom;
00331     double zoomRedo;
00332     int pageLimitX;
00333     int pageLimitXRedo;
00334     int pageLimitY;
00335     int pageLimitYRedo;
00336 
00337 };
00338 
00339 class LinkCommand : public KCommand
00340 {
00341 public:
00342   LinkCommand( Cell* cell, const QString& text, const QString& link );
00343 
00344   virtual void execute();
00345   virtual void unexecute();
00346   virtual QString name() const;
00347 
00348 protected:
00349   Cell* cell;
00350   Doc* doc;
00351   QString oldText;
00352   QString oldLink;
00353   QString newText;
00354   QString newLink;
00355 };
00356 
00357 
00358 class ChangeObjectGeometryCommand : public KCommand
00359 {
00360   public:
00361     ChangeObjectGeometryCommand( EmbeddedObject *_obj, const KoPoint &_m_diff, const KoSize &_r_diff );
00362     ~ChangeObjectGeometryCommand();
00363 
00364     virtual void execute();
00365     virtual void unexecute();
00366     virtual QString name() const;
00367 
00368   protected:
00369     KoPoint m_diff;
00370     KoSize r_diff;
00371     EmbeddedObject *obj;
00372     Doc *doc;
00373 };
00374 
00375 class RemoveObjectCommand : public KCommand
00376 {
00377   public:
00378     RemoveObjectCommand( EmbeddedObject *_obj, bool _cut = false );
00379     ~RemoveObjectCommand();
00380 
00381     virtual void execute();
00382     virtual void unexecute();
00383     virtual QString name() const;
00384 
00385   protected:
00386     EmbeddedObject *obj;
00387     Doc* doc;
00388     bool executed;
00389     bool cut;
00390 };
00391 
00392 class InsertObjectCommand : public KCommand
00393 {
00394   public:
00395     InsertObjectCommand( const KoRect& _geometry, KoDocumentEntry&, Canvas *_canvas ); //child
00396     InsertObjectCommand( const KoRect& _geometry, KoDocumentEntry&, const QRect& _data, Canvas *_canvas ); //chart
00397     InsertObjectCommand( const KoRect& _geometry, KURL& _file, Canvas *_canvas ); //picture
00398     ~InsertObjectCommand();
00399 
00400     virtual void execute();
00401     virtual void unexecute();
00402     virtual QString name() const;
00403 
00404   protected:
00405     KoRect geometry;
00406     Canvas *canvas;
00407     bool executed;
00408     KoDocumentEntry entry;
00409     QRect data;
00410     ObjType type;
00411     KURL file;
00412     EmbeddedObject *obj;
00413 };
00414 
00415 class RenameNameObjectCommand : public KNamedCommand
00416 {
00417 public:
00418     RenameNameObjectCommand( const QString &_name, const QString &_objectName, EmbeddedObject *_obj, Doc *_doc );
00419     ~RenameNameObjectCommand();
00420     void execute();
00421     void unexecute();
00422 protected:
00423     QString oldObjectName, newObjectName;
00424     EmbeddedObject *object;
00425     Doc *doc;
00426     Sheet *m_page;
00427 };
00428 
00429 
00430 class GeometryPropertiesCommand : public KNamedCommand
00431 {
00432 public:
00433     enum KgpType { ProtectSize, KeepRatio};
00434     GeometryPropertiesCommand( const QString &name, QPtrList<EmbeddedObject> &objects,
00435                                   bool newValue, KgpType type, Doc *_doc );
00436     GeometryPropertiesCommand( const QString &name, QValueList<bool> &lst, QPtrList<EmbeddedObject> &objects,
00437                                   bool newValue, KgpType type, Doc *_doc );
00438     ~GeometryPropertiesCommand();
00439 
00440     virtual void execute();
00441     virtual void unexecute();
00442 
00443 protected:
00444     QValueList<bool> m_oldValue;
00445     QPtrList<EmbeddedObject> m_objects;
00446     bool m_newValue;
00447     KgpType m_type;
00448     Doc *m_doc;
00449 };
00450 
00451 class MoveObjectByCmd : public KNamedCommand
00452 {
00453 public:
00454     MoveObjectByCmd( const QString &_name, const KoPoint &_diff, QPtrList<EmbeddedObject> &_objects,
00455                Doc *_doc, Sheet *m_page );
00456     ~MoveObjectByCmd();
00457 
00458     virtual void execute();
00459     virtual void unexecute();
00460 
00461 protected:
00462 
00463     KoPoint diff;
00464     QPtrList<EmbeddedObject> objects;
00465     Doc *doc;
00466     Sheet *m_page;
00467 };
00468 
00469 } // namespace KSpread
00470 
00471 #endif /* KSPREAD_COMMANDS */
KDE Home | KDE Accessibility Home | Description of Access Keys