lib

KoTextCommand.h
1/* This file is part of the KDE project
2 Copyright (C) 2001 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef kocommand_h
21#define kocommand_h
22
23#include <kcommand.h>
24#include <KoRichText.h>
25class KoTextObject;
26class KoTextDocument;
27class KoVariable;
28#include <KoParagLayout.h>
29#include <KoTextDocument.h>
30#include <koffice_export.h>
38class KOTEXT_EXPORT KoTextCommand : public KNamedCommand
39{
40public:
41 KoTextCommand( KoTextObject * textobj, const TQString & name ) :
42 KNamedCommand( name ), m_textobj(textobj) {}
43 ~KoTextCommand() {}
44
45 virtual void execute();
46 virtual void unexecute();
47
48protected:
49 KoTextObject * m_textobj;
50};
51
55class KOTEXT_EXPORT KoTextDeleteCommand : public KoTextDocDeleteCommand
56{
57public:
58 KoTextDeleteCommand( KoTextDocument *d, int i, int idx, const TQMemArray<KoTextStringChar> &str,
59 const CustomItemsMap & customItemsMap,
60 const TQValueList<KoParagLayout> & oldParagLayouts );
61 KoTextCursor *execute( KoTextCursor *c );
62 KoTextCursor *unexecute( KoTextCursor *c );
63protected:
64 TQValueList<KoParagLayout> m_oldParagLayouts;
65 CustomItemsMap m_customItemsMap;
66};
67
71class KoTextInsertCommand : public KoTextDeleteCommand
72{
73public:
74 KoTextInsertCommand( KoTextDocument *d, int i, int idx, const TQMemArray<KoTextStringChar> &str,
75 const CustomItemsMap & customItemsMap,
76 const TQValueList<KoParagLayout> &oldParagLayouts )
77 : KoTextDeleteCommand( d, i, idx, str, customItemsMap, oldParagLayouts ) {}
78 Commands type() const { return Insert; };
79 KoTextCursor *execute( KoTextCursor *c ) { return KoTextDeleteCommand::unexecute( c ); }
80 KoTextCursor *unexecute( KoTextCursor *c ) { return KoTextDeleteCommand::execute( c ); }
81};
82
86class KOTEXT_EXPORT KoTextParagCommand : public KoTextDocCommand
87{
88public:
89 KoTextParagCommand( KoTextDocument *d, int fParag, int lParag,
90 const TQValueList<KoParagLayout> &oldParagLayouts,
91 KoParagLayout newParagLayout,
92 int /*KoParagLayout::Flags*/ flags,
93 TQStyleSheetItem::Margin margin = (TQStyleSheetItem::Margin)-1 );
94 // margin is only meaningful if flags==Margins only. -1 means all.
95 KoTextCursor *execute( KoTextCursor *c );
96 KoTextCursor *unexecute( KoTextCursor *c );
97protected:
98 int firstParag, lastParag;
99 TQValueList<KoParagLayout> m_oldParagLayouts;
100 KoParagLayout m_newParagLayout;
101 int m_flags;
102 int m_margin;
103};
104
110class KoParagFormatCommand : public KoTextDocCommand
111{
112public:
113 KoParagFormatCommand( KoTextDocument *d, int fParag, int lParag,
114 const TQValueList<KoTextFormat *> &oldFormats,
115 KoTextFormat * newFormat );
116 ~KoParagFormatCommand();
117 KoTextCursor *execute( KoTextCursor *c );
118 KoTextCursor *unexecute( KoTextCursor *c );
119protected:
120 int firstParag, lastParag;
121 TQValueList<KoTextFormat *> m_oldFormats;
122 KoTextFormat * m_newFormat;
123};
124
128class KoTextFormatCommand : public KoTextDocFormatCommand
129{
130public:
131 KoTextFormatCommand( KoTextDocument *d, int sid, int sidx, int eid, int eidx, const TQMemArray<KoTextStringChar> &old, const KoTextFormat *f, int fl );
132 virtual ~KoTextFormatCommand();
133
134 KoTextCursor *execute( KoTextCursor *c );
135 KoTextCursor *unexecute( KoTextCursor *c );
136 void resizeCustomItems();
137};
138
143class KoChangeVariableSubType : public KCommand
144{
145public:
146 KoChangeVariableSubType( short int _oldValue, short int _newValue, KoVariable *var );
147 void execute();
148 void unexecute();
149 virtual TQString name() const;
150private:
151 short int m_newValue;
152 short int m_oldValue;
153 KoVariable *m_var;
154};
155
160class KoChangeVariableFormatProperties : public KCommand
161{
162 public:
163 KoChangeVariableFormatProperties( const TQString &_oldValue, const TQString &_newValue, KoVariable *var);
164 virtual TQString name() const;
165 void execute();
166 void unexecute();
167private:
168 TQString m_newValue;
169 TQString m_oldValue;
170 KoVariable *m_var;
171};
172
173#endif
A CustomItemsMap associates a custom item to an index Used in the undo/redo info for insert/delete te...
virtual TQString name() const=0
virtual void unexecute()=0
virtual void execute()=0
virtual TQString name() const
KNamedCommand(const TQString &name)
This class holds the paragraph-specific formatting information It's separated from KoTextParag so tha...
Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that charac...
The KoTextObject is the high-level object that contains a KoTextDocument (the list of paragraphs),...
A KoVariable is a custom item, i.e.
Definition KoVariable.h:364