1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/* This file is part of the KDE project
Copyright (C) 2001 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef kocommand_h
#define kocommand_h
#include <kcommand.h>
#include <KoRichText.h>
class KoTextObject;
class KoTextDocument;
class KoVariable;
#include <KoParagLayout.h>
#include <KoTextDocument.h>
#include <koffice_export.h>
/**
* Wraps a KoTextDocCommand into a KCommand, for the UI
* In fact the KoTextDocCommand isn't even known from here.
* When the UI orders execute or unexecute, we simply call undo/redo
* on the KoTextObject. Since one KCommand is created for each
* command there, the two simply map.
*/
class KOTEXT_EXPORT KoTextCommand : public KNamedCommand
{
public:
KoTextCommand( KoTextObject * textobj, const TQString & name ) :
KNamedCommand( name ), m_textobj(textobj) {}
~KoTextCommand() {}
virtual void execute();
virtual void unexecute();
protected:
KoTextObject * m_textobj;
};
/**
* Command created when deleting some text
*/
class KOTEXT_EXPORT KoTextDeleteCommand : public KoTextDocDeleteCommand
{
public:
KoTextDeleteCommand( KoTextDocument *d, int i, int idx, const TQMemArray<KoTextStringChar> &str,
const CustomItemsMap & customItemsMap,
const TQValueList<KoParagLayout> & oldParagLayouts );
KoTextCursor *execute( KoTextCursor *c );
KoTextCursor *unexecute( KoTextCursor *c );
protected:
TQValueList<KoParagLayout> m_oldParagLayouts;
CustomItemsMap m_customItemsMap;
};
/**
* Command created when inserting some text
*/
class KoTextInsertCommand : public KoTextDeleteCommand
{
public:
KoTextInsertCommand( KoTextDocument *d, int i, int idx, const TQMemArray<KoTextStringChar> &str,
const CustomItemsMap & customItemsMap,
const TQValueList<KoParagLayout> &oldParagLayouts )
: KoTextDeleteCommand( d, i, idx, str, customItemsMap, oldParagLayouts ) {}
Commands type() const { return Insert; };
KoTextCursor *execute( KoTextCursor *c ) { return KoTextDeleteCommand::unexecute( c ); }
KoTextCursor *unexecute( KoTextCursor *c ) { return KoTextDeleteCommand::execute( c ); }
};
/**
* Command created when changing paragraph attributes
*/
class KOTEXT_EXPORT KoTextParagCommand : public KoTextDocCommand
{
public:
KoTextParagCommand( KoTextDocument *d, int fParag, int lParag,
const TQValueList<KoParagLayout> &oldParagLayouts,
KoParagLayout newParagLayout,
int /*KoParagLayout::Flags*/ flags,
TQStyleSheetItem::Margin margin = (TQStyleSheetItem::Margin)-1 );
// margin is only meaningful if flags==Margins only. -1 means all.
KoTextCursor *execute( KoTextCursor *c );
KoTextCursor *unexecute( KoTextCursor *c );
protected:
int firstParag, lastParag;
TQValueList<KoParagLayout> m_oldParagLayouts;
KoParagLayout m_newParagLayout;
int m_flags;
int m_margin;
};
/**
* Command created when changing the default format of paragraphs.
* This is ONLY used for counters and bullet's formatting.
* See KoTextFormatCommand for the command used when changing the formatting of any set of characters.
*/
class KoParagFormatCommand : public KoTextDocCommand
{
public:
KoParagFormatCommand( KoTextDocument *d, int fParag, int lParag,
const TQValueList<KoTextFormat *> &oldFormats,
KoTextFormat * newFormat );
~KoParagFormatCommand();
KoTextCursor *execute( KoTextCursor *c );
KoTextCursor *unexecute( KoTextCursor *c );
protected:
int firstParag, lastParag;
TQValueList<KoTextFormat *> m_oldFormats;
KoTextFormat * m_newFormat;
};
/**
* Command created when changing formatted text
*/
class KoTextFormatCommand : public KoTextDocFormatCommand
{
public:
KoTextFormatCommand( KoTextDocument *d, int sid, int sidx, int eid, int eidx, const TQMemArray<KoTextStringChar> &old, const KoTextFormat *f, int fl );
virtual ~KoTextFormatCommand();
KoTextCursor *execute( KoTextCursor *c );
KoTextCursor *unexecute( KoTextCursor *c );
void resizeCustomItems();
};
/**
* Command created when changing the subtype of a variable
* (turning "fixed date" into "variable date").
*/
class KoChangeVariableSubType : public KCommand
{
public:
KoChangeVariableSubType( short int _oldValue, short int _newValue, KoVariable *var );
void execute();
void unexecute();
virtual TQString name() const;
private:
short int m_newValue;
short int m_oldValue;
KoVariable *m_var;
};
/**
* Command created when changing the properties of a variable's format
* (e.g. DD/MM/YYYY)
*/
class KoChangeVariableFormatProperties : public KCommand
{
public:
KoChangeVariableFormatProperties( const TQString &_oldValue, const TQString &_newValue, KoVariable *var);
virtual TQString name() const;
void execute();
void unexecute();
private:
TQString m_newValue;
TQString m_oldValue;
KoVariable *m_var;
};
#endif
|