kformulacommand.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KFORMULACOMMAND_H
00022 #define KFORMULACOMMAND_H
00023
00024 #include <qmap.h>
00025 #include <qptrlist.h>
00026 #include <qvaluevector.h>
00027
00028 #include <kcommand.h>
00029
00030 #include "fontstyle.h"
00031 #include "kformulacontainer.h"
00032 #include "formulacursor.h"
00033
00034 KFORMULA_NAMESPACE_BEGIN
00035
00036
00051 class PlainCommand : public KNamedCommand
00052 {
00053 public:
00054
00063 PlainCommand(const QString& name);
00064 virtual ~PlainCommand();
00065
00069 static int getEvilDestructionCount() { return evilDestructionCount; }
00070
00071 private:
00072
00073
00074 static int evilDestructionCount;
00075 };
00076
00077
00078 class Command : public PlainCommand
00079 {
00080 public:
00081
00091 Command(const QString& name, Container* document);
00092 virtual ~Command();
00093
00094 protected:
00095
00100 FormulaCursor* getExecuteCursor();
00101
00106 FormulaCursor* getUnexecuteCursor();
00107
00114 void setUnexecuteCursor(FormulaCursor* cursor);
00115
00120 FormulaCursor* getActiveCursor() { return doc->activeCursor(); }
00121
00126 void testDirty() { doc->testDirty(); }
00127
00131 Container* getDocument() const { return doc; }
00132
00133 private:
00134
00135 void destroyUndoCursor() { delete undocursor; undocursor = 0; }
00136
00140 void setExecuteCursor(FormulaCursor* cursor);
00141
00145 FormulaCursor::CursorData* cursordata;
00146
00150 FormulaCursor::CursorData* undocursor;
00151
00155 Container* doc;
00156 };
00157
00158
00162 class KFCAdd : public Command
00163 {
00164 public:
00165
00166 KFCAdd(const QString &name, Container* document);
00167
00168 virtual void execute();
00169 virtual void unexecute();
00170
00174 void addElement(BasicElement* element) { addList.append(element); }
00175
00176 private:
00177
00182 QPtrList<BasicElement> addList;
00183 };
00184
00185
00190 class KFCRemoveSelection : public Command
00191 {
00192 public:
00193
00197 KFCRemoveSelection(Container* document,
00198 Direction dir = beforeCursor);
00199
00200 virtual void execute();
00201 virtual void unexecute();
00202
00203 private:
00204
00209 QPtrList<BasicElement> removedList;
00210
00211 Direction dir;
00212 };
00213
00214
00219 class KFCReplace : public KFCAdd
00220 {
00221 public:
00222
00223 KFCReplace(const QString &name, Container* document);
00224 ~KFCReplace();
00225
00226 virtual void execute();
00227 virtual void unexecute();
00228
00229 private:
00230
00234 KFCRemoveSelection* removeSelection;
00235 };
00236
00237
00242 class KFCRemove : public Command
00243 {
00244 public:
00245
00249 KFCRemove(Container* document, Direction dir);
00250 ~KFCRemove();
00251
00252 virtual void execute();
00253 virtual void unexecute();
00254
00259
00260
00261 private:
00262
00267 QPtrList<BasicElement> removedList;
00268
00272 BasicElement* element;
00273
00279 FormulaCursor::CursorData* simpleRemoveCursor;
00280
00281 Direction dir;
00282 };
00283
00284
00288 class KFCRemoveEnclosing : public Command
00289 {
00290 public:
00291 KFCRemoveEnclosing(Container* document, Direction dir);
00292 ~KFCRemoveEnclosing();
00293
00294 virtual void execute();
00295 virtual void unexecute();
00296
00297 private:
00298 BasicElement* element;
00299
00300 Direction direction;
00301 };
00302
00303
00308 class KFCAddReplacing : public Command
00309 {
00310 public:
00311 KFCAddReplacing(const QString &name, Container* document);
00312 ~KFCAddReplacing();
00313
00314 virtual void execute();
00315 virtual void unexecute();
00316
00317 void setElement(BasicElement* e) { element = e; }
00318
00319 private:
00320
00324 BasicElement* element;
00325 };
00326
00327
00332 class KFCAddGenericIndex : public KFCAdd
00333 {
00334 public:
00335
00336 KFCAddGenericIndex(Container* document, ElementIndexPtr index);
00337
00338 virtual void execute();
00339
00340 private:
00341 ElementIndexPtr index;
00342 };
00343
00344
00345 class IndexElement;
00346
00350 class KFCAddIndex : public KFCAddReplacing
00351 {
00352 public:
00353
00354 KFCAddIndex(Container* document, IndexElement* element, ElementIndexPtr index);
00355 ~KFCAddIndex();
00356
00357 virtual void execute();
00358 virtual void unexecute();
00359
00360 private:
00361 KFCAddGenericIndex addIndex;
00362 };
00363
00364
00365 class FormulaElement;
00366
00367 class KFCChangeBaseSize : public PlainCommand {
00368 public:
00369 KFCChangeBaseSize( const QString& name, Container* document, FormulaElement* formula, int size );
00370
00371 void execute();
00372 void unexecute();
00373
00374 private:
00375 Container* m_document;
00376 FormulaElement* m_formula;
00377 int m_size;
00378 int m_oldSize;
00379 };
00380
00381
00386 class FontCommand : public Command {
00387 public:
00388 FontCommand( const QString& name, Container* document );
00389
00393 void addTextElement( TextElement* element ) { list.append(element); }
00394
00398 void addElement( BasicElement* element ) { elementList.append( element ); }
00399
00400 protected:
00401
00402 QPtrList<TextElement>& childrenList() { return list; }
00403
00404 void collectChildren();
00405
00406 void parseSequences( const QMap<SequenceElement*, int>& parents );
00407
00408 private:
00409
00414 QPtrList<TextElement> list;
00415
00416 QPtrList<BasicElement> elementList;
00417 };
00418
00419
00423 class CharStyleCommand : public FontCommand {
00424 public:
00425 CharStyleCommand( CharStyle cs, const QString& name, Container* document );
00426
00427 virtual void execute();
00428 virtual void unexecute();
00429
00430 private:
00431
00432 typedef QValueVector<CharStyle> StyleList;
00433
00434 StyleList styleList;
00435 CharStyle charStyle;
00436 };
00437
00438
00442 class CharFamilyCommand : public FontCommand {
00443 public:
00444 CharFamilyCommand( CharFamily cf, const QString& name, Container* document );
00445
00446 virtual void execute();
00447 virtual void unexecute();
00448
00449 private:
00450
00451 typedef QValueVector<CharFamily> FamilyList;
00452
00453 FamilyList familyList;
00454 CharFamily charFamily;
00455 };
00456
00457
00458 KFORMULA_NAMESPACE_END
00459
00460 #endif // KFORMULACOMMAND_H
This file is part of the documentation for lib Library Version 1.3.5.