lib

KoTextCommand.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef kocommand_h
00021 #define kocommand_h
00022 
00023 #include <kcommand.h>
00024 #include <KoRichText.h>
00025 class KoTextObject;
00026 class KoTextDocument;
00027 class KoVariable;
00028 #include <KoParagLayout.h>
00029 #include <KoTextDocument.h>
00030 #include <koffice_export.h>
00038 class KOTEXT_EXPORT KoTextCommand : public KNamedCommand
00039 {
00040 public:
00041     KoTextCommand( KoTextObject * textobj, const QString & name ) :
00042         KNamedCommand( name ), m_textobj(textobj) {}
00043     ~KoTextCommand() {}
00044 
00045     virtual void execute();
00046     virtual void unexecute();
00047 
00048 protected:
00049     KoTextObject * m_textobj;
00050 };
00051 
00055 class KOTEXT_EXPORT KoTextDeleteCommand : public KoTextDocDeleteCommand
00056 {
00057 public:
00058     KoTextDeleteCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str,
00059                          const CustomItemsMap & customItemsMap,
00060                          const QValueList<KoParagLayout> & oldParagLayouts );
00061     KoTextCursor *execute( KoTextCursor *c );
00062     KoTextCursor *unexecute( KoTextCursor *c );
00063 protected:
00064     QValueList<KoParagLayout> m_oldParagLayouts;
00065     CustomItemsMap m_customItemsMap;
00066 };
00067 
00071 class KoTextInsertCommand : public KoTextDeleteCommand
00072 {
00073 public:
00074     KoTextInsertCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str,
00075                          const CustomItemsMap & customItemsMap,
00076                          const QValueList<KoParagLayout> &oldParagLayouts )
00077         : KoTextDeleteCommand( d, i, idx, str, customItemsMap, oldParagLayouts ) {}
00078     Commands type() const { return Insert; };
00079     KoTextCursor *execute( KoTextCursor *c ) { return KoTextDeleteCommand::unexecute( c ); }
00080     KoTextCursor *unexecute( KoTextCursor *c ) { return KoTextDeleteCommand::execute( c ); }
00081 };
00082 
00086 class KOTEXT_EXPORT KoTextParagCommand : public KoTextDocCommand
00087 {
00088 public:
00089     KoTextParagCommand( KoTextDocument *d, int fParag, int lParag,
00090                         const QValueList<KoParagLayout> &oldParagLayouts,
00091                         KoParagLayout newParagLayout,
00092                         int /*KoParagLayout::Flags*/ flags,
00093                         QStyleSheetItem::Margin margin = (QStyleSheetItem::Margin)-1 );
00094                         // margin is only meaningful if flags==Margins only. -1 means all.
00095     KoTextCursor *execute( KoTextCursor *c );
00096     KoTextCursor *unexecute( KoTextCursor *c );
00097 protected:
00098     int firstParag, lastParag;
00099     QValueList<KoParagLayout> m_oldParagLayouts;
00100     KoParagLayout m_newParagLayout;
00101     int m_flags;
00102     int m_margin;
00103 };
00104 
00110 class KoParagFormatCommand : public KoTextDocCommand
00111 {
00112 public:
00113     KoParagFormatCommand( KoTextDocument *d, int fParag, int lParag,
00114                           const QValueList<KoTextFormat *> &oldFormats,
00115                           KoTextFormat * newFormat );
00116     ~KoParagFormatCommand();
00117     KoTextCursor *execute( KoTextCursor *c );
00118     KoTextCursor *unexecute( KoTextCursor *c );
00119 protected:
00120     int firstParag, lastParag;
00121     QValueList<KoTextFormat *> m_oldFormats;
00122     KoTextFormat * m_newFormat;
00123 };
00124 
00128 class KoTextFormatCommand : public KoTextDocFormatCommand
00129 {
00130 public:
00131     KoTextFormatCommand( KoTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<KoTextStringChar> &old, const KoTextFormat *f, int fl );
00132     virtual ~KoTextFormatCommand();
00133 
00134     KoTextCursor *execute( KoTextCursor *c );
00135     KoTextCursor *unexecute( KoTextCursor *c );
00136     void resizeCustomItems();
00137 };
00138 
00143 class KoChangeVariableSubType : public KCommand
00144 {
00145 public:
00146     KoChangeVariableSubType( short int _oldValue, short int _newValue, KoVariable *var );
00147     void execute();
00148     void unexecute();
00149     virtual QString name() const;
00150 private:
00151     short int m_newValue;
00152     short int m_oldValue;
00153     KoVariable *m_var;
00154 };
00155 
00160 class KoChangeVariableFormatProperties : public KCommand
00161 {
00162  public:
00163     KoChangeVariableFormatProperties( const QString &_oldValue, const QString &_newValue, KoVariable *var);
00164     virtual QString name() const;
00165     void execute();
00166     void unexecute();
00167 private:
00168     QString m_newValue;
00169     QString m_oldValue;
00170     KoVariable *m_var;
00171 };
00172 
00173 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys