kspread
manipulator.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KSPREAD_MANIPULATOR
00022 #define KSPREAD_MANIPULATOR
00023
00024 #include <qrect.h>
00025 #include <qstring.h>
00026 #include <qvaluelist.h>
00027
00028 #include <kcommand.h>
00029 #include <klocale.h>
00030
00031 #include <koffice_export.h>
00032
00033 #include "kspread_format.h"
00034 #include "kspread_undo.h"
00035 #include "region.h"
00036
00037 namespace KSpread
00038 {
00039 class Cell;
00040 class ColumnFormat;
00041 class RowFormat;
00042 class Sheet;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00066 class Manipulator : public Region, public KCommand
00067 {
00068 public:
00069 Manipulator();
00070 virtual ~Manipulator();
00071
00072 Sheet* sheet() const { return m_sheet; }
00073 void setSheet(Sheet* sheet) { m_sheet = sheet; }
00074
00075 bool creation() { return m_creation; }
00076 void setCreation(bool creation) { m_creation = creation; }
00077
00081 bool format() { return m_format; };
00082 void setFormat (bool f) { m_format = f; };
00083
00084 virtual void execute();
00085 virtual void unexecute();
00086
00087 virtual void setArgument(const QString& , const QString& ) {};
00088
00089 virtual void setReverse(bool reverse) { m_reverse = reverse; }
00090 void setRegisterUndo(bool registerUndo) { m_register = registerUndo; }
00091
00092 virtual void setName (const QString &n) { m_name = n; }
00093 virtual QString name() const { return m_name; };
00094
00095 protected:
00096 virtual bool process(Element*);
00097 virtual bool process(Cell*) { return true; }
00098 virtual bool process(Format*) { return true; }
00099
00100 virtual bool preProcessing() { return true; }
00101 virtual bool postProcessing() { return true; }
00102
00103
00104 Sheet* m_sheet;
00105 QString m_name;
00106 bool m_creation : 1;
00107 bool m_reverse : 1;
00108 bool m_firstrun : 1;
00109 bool m_format : 1;
00110 bool m_register : 1;
00111 private:
00112 };
00113
00114
00115
00119 class FormatManipulator : public Manipulator
00120 {
00121 public:
00122 FormatManipulator();
00123 virtual ~FormatManipulator();
00124
00125 void setProperty(Format::Properties property) { m_properties |= property; }
00126 bool isEmpty() { return m_properties == 0; }
00127
00128
00129
00130 void setFontFamily(const QString& font) { m_properties |= Format::PFont; m_font = font; }
00131 void setFontSize(int size) { m_properties |= Format::PFont; m_size = size; }
00132 void setFontBold(uint bold) { m_properties |= Format::PFont; m_bold = bold; }
00133 void setFontItalic(uint italic) { m_properties |= Format::PFont; m_italic = italic; }
00134 void setFontStrike(uint strike) { m_properties |= Format::PFont; m_strike = strike; }
00135 void setFontUnderline(uint underline) { m_properties |= Format::PFont; m_underline = underline; }
00136
00137 void setAngle(int angle) { m_properties |= Format::PAngle; m_angle = angle; }
00138
00139 void setTextColor(const QColor& textColor) { m_properties |= Format::PTextPen; m_textColor = textColor; }
00140
00141 void setBackgroundColor(const QColor& bgColor) { m_properties |= Format::PBackgroundColor; m_backgroundColor = bgColor; }
00142
00143 void setTopBorderPen(const QPen& pen) { m_properties |= Format::PTopBorder; m_topBorderPen = pen; }
00144 void setBottomBorderPen(const QPen& pen) { m_properties |= Format::PBottomBorder; m_bottomBorderPen = pen; }
00145 void setLeftBorderPen(const QPen& pen) { m_properties |= Format::PLeftBorder; m_leftBorderPen = pen; }
00146 void setRightBorderPen(const QPen& pen) { m_properties |= Format::PRightBorder; m_rightBorderPen = pen; }
00147 void setHorizontalPen(const QPen& pen) { m_properties |= Format::PTopBorder | Format::PBottomBorder; m_horizontalPen = pen; }
00148 void setVerticalPen(const QPen& pen) { m_properties |= Format::PLeftBorder | Format::PRightBorder; m_verticalPen = pen; }
00149 void setFallDiagonalPen(const QPen& pen) { m_properties |= Format::PFallDiagonal; m_fallDiagonalPen = pen; }
00150 void setGoUpDiagonalPen(const QPen& pen) { m_properties |= Format::PGoUpDiagonal; m_goUpDiagonalPen = pen; }
00151
00152 void setHorizontalAlignment(Format::Align align) { m_properties |= Format::PAlign; m_horAlign = align; }
00153
00154 void setVerticalAlignment(Format::AlignY align) { m_properties |= Format::PAlignY; m_verAlign = align; }
00155
00156 void setBackgroundBrush(const QBrush& brush) { m_properties |= Format::PBackgroundBrush; m_backgroundBrush = brush; }
00157 void setIndent(double indent) { m_properties |= Format::PIndent; m_indent = indent; }
00158 void setMultiRow(bool multiRow) { m_properties |= Format::PMultiRow; m_multiRow = multiRow; }
00159 void setVerticalText(bool verticalText) { m_properties |= Format::PVerticalText; m_verticalText = verticalText; }
00160 void setDontPrintText(bool dontPrintText) { m_properties |= Format::PDontPrintText; m_dontPrintText = dontPrintText; }
00161 void setNotProtected(bool notProtected) { m_properties |= Format::PNotProtected; m_notProtected = notProtected; }
00162 void setHideAll(bool hideAll) { m_properties |= Format::PHideAll; m_hideAll = hideAll; }
00163 void setHideFormula(bool hideFormula) { m_properties |= Format::PHideFormula; m_hideFormula = hideFormula; }
00164 void setComment(const QString& comment) { m_properties |= Format::PComment; m_comment = comment; }
00165 void setPrefix(const QString& prefix) { m_properties |= Format::PPrefix; m_prefix = prefix; }
00166 void setPostfix(const QString& postfix) { m_properties |= Format::PPostfix; m_postfix = postfix; }
00167 void setPrecision(int precision) { m_properties |= Format::PPrecision; m_precision = precision; }
00168 void setFloatFormat(Format::FloatFormat floatFormat) { m_properties |= Format::PFloatFormat; m_floatFormat = floatFormat; }
00169 void setFloatColor(Format::FloatColor floatColor) { m_properties |= Format::PFloatColor; m_floatColor = floatColor; }
00170 void setFormatType(FormatType formatType) { m_properties |= Format::PFormatType; m_formatType = formatType; }
00171 void setCurrency(int type, const QString& symbol) { m_currencyType = type; m_currencySymbol = symbol; }
00172
00173 protected:
00174 virtual QString name() const { return i18n("Format Change"); }
00175
00176 virtual bool preProcessing();
00177 virtual bool process(Element*);
00178
00179 void copyFormat(QValueList<layoutCell> &list,
00180 QValueList<layoutColumn> &listCol,
00181 QValueList<layoutRow> &listRow);
00182 bool testCondition(RowFormat*);
00183 void doWork(Format*, bool isTop, bool isBottom, bool isLeft, bool isRight);
00184 void prepareCell(Cell*);
00185
00186 private:
00187 Q_UINT32 m_properties;
00188
00189
00190 QValueList<layoutCell> m_lstFormats;
00191 QValueList<layoutCell> m_lstRedoFormats;
00192 QValueList<layoutColumn> m_lstColFormats;
00193 QValueList<layoutColumn> m_lstRedoColFormats;
00194 QValueList<layoutRow> m_lstRowFormats;
00195 QValueList<layoutRow> m_lstRedoRowFormats;
00196
00197
00198
00199 QString m_font;
00200 int m_size;
00201 signed char m_bold;
00202 signed char m_italic;
00203 signed char m_strike;
00204 signed char m_underline;
00205
00206 int m_angle;
00207 int m_precision;
00208 int m_currencyType;
00209 double m_indent;
00210 bool m_multiRow;
00211 bool m_verticalText;
00212 bool m_dontPrintText;
00213 bool m_notProtected;
00214 bool m_hideAll;
00215 bool m_hideFormula;
00216
00217
00218 QColor m_textColor;
00219
00220 QColor m_backgroundColor;
00221
00222 QPen m_topBorderPen;
00223 QPen m_bottomBorderPen;
00224 QPen m_leftBorderPen;
00225 QPen m_rightBorderPen;
00226 QPen m_horizontalPen;
00227 QPen m_verticalPen;
00228 QPen m_fallDiagonalPen;
00229 QPen m_goUpDiagonalPen;
00230
00231 QBrush m_backgroundBrush;
00232 QString m_comment;
00233 QString m_prefix;
00234 QString m_postfix;
00235 QString m_currencySymbol;
00236
00237
00238 Format::Align m_horAlign;
00239
00240 Format::AlignY m_verAlign;
00241 Format::FloatFormat m_floatFormat;
00242 Format::FloatColor m_floatColor;
00243 FormatType m_formatType;
00244 };
00245
00246
00247
00251 class ResizeColumnManipulator : public Manipulator
00252 {
00253 public:
00254 ResizeColumnManipulator();
00255 ~ResizeColumnManipulator();
00256
00257 void setSize(double size) { m_newSize = size; }
00258 void setOldSize(double size) { m_oldSize = size; }
00259
00260 protected:
00261 virtual bool process(Element*);
00262
00263 virtual QString name() const { return i18n("Resize Column"); }
00264
00265 private:
00266 double m_newSize;
00267 double m_oldSize;
00268 };
00269
00270
00271
00275 class ResizeRowManipulator : public Manipulator
00276 {
00277 public:
00278 ResizeRowManipulator();
00279 ~ResizeRowManipulator();
00280
00281 void setSize(double size) { m_newSize = size; }
00282 void setOldSize(double size) { m_oldSize = size; }
00283
00284 protected:
00285 virtual bool process(Element*);
00286
00287 virtual QString name() const { return i18n("Resize Row"); }
00288
00289 private:
00290 double m_newSize;
00291 double m_oldSize;
00292 };
00293
00294
00295
00299 class BorderManipulator : public FormatManipulator
00300 {
00301 public:
00302 BorderManipulator() {}
00303 ~BorderManipulator() {}
00304
00305 protected:
00306 virtual QString name() const { return i18n("Change Border"); }
00307
00308 private:
00309 };
00310
00311
00312
00316 class BackgroundColorManipulator : public FormatManipulator
00317 {
00318 public:
00319 BackgroundColorManipulator() {}
00320 ~BackgroundColorManipulator() {}
00321
00322 protected:
00323 virtual QString name() const { return i18n("Change Background Color"); }
00324
00325 private:
00326 };
00327
00328
00329
00333 class FontColorManipulator : public FormatManipulator
00334 {
00335 public:
00336 FontColorManipulator() {}
00337 ~FontColorManipulator() {}
00338
00339 protected:
00340 virtual QString name() const { return i18n("Change Text Color"); }
00341
00342 private:
00343 };
00344
00345
00346
00350 class FontManipulator : public FormatManipulator
00351 {
00352 public:
00353 FontManipulator() {}
00354 ~FontManipulator() {}
00355
00356 protected:
00357 virtual QString name() const { return i18n("Change Font"); }
00358
00359 private:
00360 };
00361
00362
00363
00367 class AngleManipulator : public FormatManipulator
00368 {
00369 public:
00370 AngleManipulator() {}
00371 ~AngleManipulator() {}
00372
00373 protected:
00374 virtual QString name() const { return i18n("Change Angle"); }
00375
00376 private:
00377 };
00378
00379
00380
00384 class HorAlignManipulator : public FormatManipulator
00385 {
00386 public:
00387 HorAlignManipulator() {}
00388 ~HorAlignManipulator() {}
00389
00390 protected:
00391 virtual QString name() const { return i18n("Change Horizontal Alignment"); }
00392
00393 private:
00394 };
00395
00396
00397
00401 class VerAlignManipulator : public FormatManipulator
00402 {
00403 public:
00404 VerAlignManipulator() {}
00405 ~VerAlignManipulator() {}
00406
00407 protected:
00408 virtual QString name() const { return i18n("Change Vertical Alignment"); }
00409
00410 private:
00411 };
00412
00413
00414
00415
00419 class MergeManipulator : public Manipulator
00420 {
00421 public:
00422 MergeManipulator();
00423 virtual ~MergeManipulator();
00424
00425 virtual bool preProcessing();
00426
00427 virtual void setReverse(bool reverse) { m_merge = !reverse; }
00428 void setHorizontalMerge(bool state) { m_mergeHorizontal = state; }
00429 void setVerticalMerge(bool state) { m_mergeVertical = state; }
00430
00431 protected:
00432 virtual bool process(Element*);
00433
00434 virtual bool postProcessing();
00435
00436 virtual QString name() const;
00437
00438 bool m_merge;
00439 private:
00440 bool m_mergeHorizontal : 1;
00441 bool m_mergeVertical : 1;
00442 Manipulator* m_unmerger;
00443 };
00444
00445
00446
00450 class DilationManipulator : public Manipulator
00451 {
00452 public:
00453 DilationManipulator();
00454 virtual ~DilationManipulator();
00455
00456 virtual void execute();
00457 virtual void unexecute();
00458
00459 protected:
00460 virtual QString name() const { return i18n("Dilate Region"); }
00461
00462 private:
00463 };
00464
00465
00466
00470 class AdjustColumnRowManipulator : public Manipulator
00471 {
00472 public:
00473 AdjustColumnRowManipulator();
00474 virtual ~AdjustColumnRowManipulator();
00475
00476 virtual bool process(Element*);
00477 virtual bool preProcessing();
00478
00479 void setAdjustColumn(bool state) { m_adjustColumn = state; }
00480 void setAdjustRow(bool state) { m_adjustRow = state; }
00481
00482 protected:
00483 virtual QString name() const;
00484
00485 double adjustColumnHelper( Cell * c, int _col, int _row );
00486 double adjustRowHelper( Cell * c, int _col, int _row );
00487
00488 private:
00489 bool m_adjustColumn : 1;
00490 bool m_adjustRow : 1;
00491 QMap<int, double> m_newWidths;
00492 QMap<int, double> m_oldWidths;
00493 QMap<int, double> m_newHeights;
00494 QMap<int, double> m_oldHeights;
00495 };
00496
00497
00498
00502 class HideShowManipulator : public Manipulator
00503 {
00504 public:
00505 HideShowManipulator();
00506 virtual ~HideShowManipulator();
00507
00508 virtual bool process(Element*);
00509 virtual bool preProcessing();
00510 virtual bool postProcessing();
00511
00512 void setManipulateColumns(bool state) { m_manipulateColumns = state; }
00513 void setManipulateRows(bool state) { m_manipulateRows = state; }
00514
00515 protected:
00516 virtual QString name() const;
00517
00518 private:
00519 bool m_manipulateColumns : 1;
00520 bool m_manipulateRows : 1;
00521 };
00522
00523
00524
00528 class InsertDeleteManipulator : public Manipulator
00529 {
00530 public:
00531 InsertDeleteManipulator();
00532 ~InsertDeleteManipulator();
00533
00534 protected:
00535
00536 private:
00537 bool m_manipulateColumns : 1;
00538 bool m_manipulateRows : 1;
00539 };
00540
00541
00542
00543
00544
00548 class ManipulatorManager
00549 {
00550 public:
00551 static ManipulatorManager* self();
00552 ~ManipulatorManager();
00553 Manipulator* create(const QString&);
00554
00555 private:
00556 ManipulatorManager();
00557 static ManipulatorManager* m_self;
00558 };
00559
00560 }
00561
00562 #endif // KSPREAD_MANIPULATOR
|