~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to lib/kotext/kocommand.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#ifndef kocommand_h
 
21
#define kocommand_h
 
22
 
 
23
#include <kcommand.h>
 
24
#include <korichtext.h>
 
25
class KoTextObject;
 
26
class KoTextDocument;
 
27
class KoVariable;
 
28
#include <koparaglayout.h>
 
29
#include <kotextdocument.h>
 
30
 
 
31
/**
 
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.
 
37
 */
 
38
class KoTextCommand : public KNamedCommand
 
39
{
 
40
public:
 
41
    KoTextCommand( KoTextObject * textobj, const QString & name ) :
 
42
        KNamedCommand( name ), m_textobj(textobj) {}
 
43
    ~KoTextCommand() {}
 
44
 
 
45
    virtual void execute();
 
46
    virtual void unexecute();
 
47
 
 
48
protected:
 
49
    KoTextObject * m_textobj;
 
50
};
 
51
 
 
52
/**
 
53
 * Command created when deleting some text
 
54
 */
 
55
class KoTextDeleteCommand : public KoTextDocDeleteCommand
 
56
{
 
57
public:
 
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 );
 
63
protected:
 
64
    QValueList<KoParagLayout> m_oldParagLayouts;
 
65
    CustomItemsMap m_customItemsMap;
 
66
};
 
67
 
 
68
/**
 
69
 * Command created when inserting some text
 
70
 */
 
71
class KoTextInsertCommand : public KoTextDeleteCommand
 
72
{
 
73
public:
 
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 ); }
 
81
};
 
82
 
 
83
/**
 
84
 * Command created when changing paragraph attributes
 
85
 */
 
86
class KoTextParagCommand : public KoTextDocCommand
 
87
{
 
88
public:
 
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 );
 
97
protected:
 
98
    int firstParag, lastParag;
 
99
    QValueList<KoParagLayout> m_oldParagLayouts;
 
100
    KoParagLayout m_newParagLayout;
 
101
    int m_flags;
 
102
    int m_margin;
 
103
    bool m_borderOutline;
 
104
};
 
105
 
 
106
/**
 
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.
 
110
 */
 
111
class KoParagFormatCommand : public KoTextDocCommand
 
112
{
 
113
public:
 
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 );
 
120
protected:
 
121
    int firstParag, lastParag;
 
122
    QValueList<KoTextFormat *> m_oldFormats;
 
123
    KoTextFormat * m_newFormat;
 
124
};
 
125
 
 
126
/**
 
127
 * Command created when changing formatted text
 
128
 */
 
129
class KoTextFormatCommand : public KoTextDocFormatCommand
 
130
{
 
131
public:
 
132
    KoTextFormatCommand( KoTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<KoTextStringChar> &old, const KoTextFormat *f, int fl );
 
133
    virtual ~KoTextFormatCommand();
 
134
 
 
135
    KoTextCursor *execute( KoTextCursor *c );
 
136
    KoTextCursor *unexecute( KoTextCursor *c );
 
137
    void resizeCustomItems();
 
138
};
 
139
 
 
140
/**
 
141
 * Command created when changing the subtype of a variable
 
142
 * (turning "fixed date" into "variable date").
 
143
 */
 
144
class KoChangeVariableSubType : public KCommand
 
145
{
 
146
public:
 
147
    KoChangeVariableSubType( short int _oldValue, short int _newValue, KoVariable *var );
 
148
    void execute();
 
149
    void unexecute();
 
150
    virtual QString name() const;
 
151
private:
 
152
    short int m_newValue;
 
153
    short int m_oldValue;
 
154
    KoVariable *m_var;
 
155
};
 
156
 
 
157
/**
 
158
 * Command created when changing the properties of a variable's format
 
159
 * (e.g. DD/MM/YYYY)
 
160
 */
 
161
class KoChangeVariableFormatProperties : public KCommand
 
162
{
 
163
 public:
 
164
    KoChangeVariableFormatProperties( const QString &_oldValue, const QString &_newValue, KoVariable *var);
 
165
    virtual QString name() const;
 
166
    void execute();
 
167
    void unexecute();
 
168
private:
 
169
    QString m_newValue;
 
170
    QString m_oldValue;
 
171
    KoVariable *m_var;
 
172
};
 
173
 
 
174
#endif