1
/* This file is part of the KDE project
2
Copyright (C) 2001 David Faure <faure@kde.org>
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.
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.
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., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
24
#include <korichtext.h>
28
#include <koparaglayout.h>
29
#include <kotextdocument.h>
32
* Wraps a KoTextDocCommand into a KCommand, for the UI
33
* In fact the KoTextDocCommand isn't even known from here.
34
* When the UI orders execute or unexecute, we simply call undo/redo
35
* on the KoTextObject. Since one KCommand is created for each
36
* command there, the two simply map.
38
class KoTextCommand : public KNamedCommand
41
KoTextCommand( KoTextObject * textobj, const QString & name ) :
42
KNamedCommand( name ), m_textobj(textobj) {}
45
virtual void execute();
46
virtual void unexecute();
49
KoTextObject * m_textobj;
53
* Command created when deleting some text
55
class KoTextDeleteCommand : public KoTextDocDeleteCommand
58
KoTextDeleteCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str,
59
const CustomItemsMap & customItemsMap,
60
const QValueList<KoParagLayout> & oldParagLayouts );
61
KoTextCursor *execute( KoTextCursor *c );
62
KoTextCursor *unexecute( KoTextCursor *c );
64
QValueList<KoParagLayout> m_oldParagLayouts;
65
CustomItemsMap m_customItemsMap;
69
* Command created when inserting some text
71
class KoTextInsertCommand : public KoTextDeleteCommand
74
KoTextInsertCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str,
75
const CustomItemsMap & customItemsMap,
76
const QValueList<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 ); }
84
* Command created when changing paragraph attributes
86
class KoTextParagCommand : public KoTextDocCommand
89
KoTextParagCommand( KoTextDocument *d, int fParag, int lParag,
90
const QValueList<KoParagLayout> &oldParagLayouts,
91
KoParagLayout newParagLayout,
92
int /*KoParagLayout::Flags*/ flags,
93
QStyleSheetItem::Margin margin = (QStyleSheetItem::Margin)-1, bool borderOutline=false );
94
// margin is only meaningful if flags==Margins only. -1 means all.
95
KoTextCursor *execute( KoTextCursor *c );
96
KoTextCursor *unexecute( KoTextCursor *c );
98
int firstParag, lastParag;
99
QValueList<KoParagLayout> m_oldParagLayouts;
100
KoParagLayout m_newParagLayout;
103
bool m_borderOutline;
107
* Command created when changing the default format of paragraphs.
108
* This is ONLY used for counters and bullet's formatting.
109
* See KoTextFormatCommand for the command used when changing the formatting of any set of characters.
111
class KoParagFormatCommand : public KoTextDocCommand
114
KoParagFormatCommand( KoTextDocument *d, int fParag, int lParag,
115
const QValueList<KoTextFormat *> &oldFormats,
116
KoTextFormat * newFormat );
117
~KoParagFormatCommand();
118
KoTextCursor *execute( KoTextCursor *c );
119
KoTextCursor *unexecute( KoTextCursor *c );
121
int firstParag, lastParag;
122
QValueList<KoTextFormat *> m_oldFormats;
123
KoTextFormat * m_newFormat;
127
* Command created when changing formatted text
129
class KoTextFormatCommand : public KoTextDocFormatCommand
132
KoTextFormatCommand( KoTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<KoTextStringChar> &old, const KoTextFormat *f, int fl );
133
virtual ~KoTextFormatCommand();
135
KoTextCursor *execute( KoTextCursor *c );
136
KoTextCursor *unexecute( KoTextCursor *c );
137
void resizeCustomItems();
141
* Command created when changing the subtype of a variable
142
* (turning "fixed date" into "variable date").
144
class KoChangeVariableSubType : public KCommand
147
KoChangeVariableSubType( short int _oldValue, short int _newValue, KoVariable *var );
150
virtual QString name() const;
152
short int m_newValue;
153
short int m_oldValue;
158
* Command created when changing the properties of a variable's format
161
class KoChangeVariableFormatProperties : public KCommand
164
KoChangeVariableFormatProperties( const QString &_oldValue, const QString &_newValue, KoVariable *var);
165
virtual QString name() const;