kword

KWVariable.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@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 variable_h
21#define variable_h
22
23#include <tqstring.h>
24#include <tqdatetime.h>
25#include <tqasciidict.h>
26
27#include "defs.h"
28
29#include <KoVariable.h>
30#include <KoParagCounter.h>
31
32class KWDocument;
33class KWTextFrameSet;
34class KWFootNoteFrameSet;
35class KoVariable;
36class KoPageVariable;
37class KoMailMergeVariable;
38class TQDomElement;
39class KoTextFormat;
40
41
42class KWVariableSettings : public KoVariableSettings
43{
44 public:
45 KWVariableSettings();
46 virtual ~KWVariableSettings() {}
47 virtual void save( TQDomElement &parentElem );
48 virtual void load( TQDomElement &elem );
49 void saveNoteConfiguration( KoXmlWriter& writer ) const;
50 void loadNoteConfiguration( const TQDomElement& parent );
51 void changeFootNoteCounter( KoParagCounter _c );
52 void changeEndNoteCounter( KoParagCounter _c );
53 KoParagCounter endNoteCounter() const { return m_endNoteCounter;}
54 KoParagCounter footNoteCounter() const { return m_footNoteCounter;}
55 private:
56 KoParagCounter m_footNoteCounter;
57 KoParagCounter m_endNoteCounter;
58};
59
60class KWVariableCollection : public KoVariableCollection
61{
62 public:
63 KWVariableCollection(KWVariableSettings *_settings, KoVariableFormatCollection* coll);
64 virtual KoVariable *createVariable( int type, short int subtype, KoVariableFormatCollection * coll, KoVariableFormat *varFormat,KoTextDocument *textdoc, KoDocument * doc, int _correct, bool _forceDefaultFormat=false, bool loadFootNote= true );
65 virtual KoVariable* loadOasisField( KoTextDocument* textdoc, const TQDomElement& tag, KoOasisContext& context );
66
67 private:
68 KWDocument *m_doc;
69};
70
74class KWPgNumVariable : public KoPageVariable
75{
76public:
77 KWPgNumVariable( KoTextDocument *textdoc, int subtype, KoVariableFormat *varFormat ,KoVariableCollection *_varColl, KWDocument *doc );
78
79 virtual void recalc();
80 virtual TQString text(bool realValue=false);
81
82private:
83 KWDocument *m_doc;
84};
85
86
90class KWMailMergeVariable : public KoMailMergeVariable
91{
92public:
93 KWMailMergeVariable( KoTextDocument *textdoc, const TQString &name, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KWDocument *doc );
94
95 virtual TQString text(bool realValue=false);
96 virtual TQString value() const;
97 virtual void recalc();
98 private:
99 KWDocument *m_doc;
100};
101
105class KWFootNoteVariable : public KoVariable
106{
107public:
108 KWFootNoteVariable( KoTextDocument *textdoc, KoVariableFormat *varFormat, KoVariableCollection *varColl, KWDocument *doc );
109 virtual VariableType type() const
110 { return VT_FOOTNOTE; }
111 enum Numbering {Auto, Manual};
112
113 void setNoteType( NoteType _noteType ) { m_noteType = _noteType;}
114 NoteType noteType() const {return m_noteType; }
115
116 void setNumberingType( Numbering _type );
117 Numbering numberingType() const { return m_numberingType;}
118
119 void setManualString( const TQString & _str ) { m_varValue=TQVariant(_str);}
120 TQString manualString() const { return m_varValue.toString();}
121
122 virtual void resize();
123 virtual void drawCustomItem( TQPainter* p, int x, int y, int wpix, int hpix, int ascentpix, int /*cx*/, int /*cy*/, int /*cw*/, int /*ch*/, const TQColorGroup& cg, bool selected, int offset, bool drawingShadow );
124
126 KWFootNoteFrameSet * frameSet() const { return m_frameset; }
127 void setFrameSet( KWFootNoteFrameSet* fs ) { Q_ASSERT( !m_frameset ); m_frameset = fs; }
128
129 virtual void saveVariable( TQDomElement &parentElem );
130 virtual void load( TQDomElement &elem );
131
132 virtual void loadOasis( const TQDomElement &footNoteTag, KoOasisContext& context );
133 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
134
135
136 virtual TQString text(bool realValue=false);
137 // Nothing to do here. Numbering done by KWTextFrameSet::renumberFootNotes
138 virtual void recalc() { }
139
140 // This is a sequence number, to order footnotes. It is always set, and different for all footnotes.
141 void setNum( int _num ) { m_num = _num; }
142 int num() const { return m_num; }
143
144 // The number being displayed - for auto-numbered footnotes only.
145 void setNumDisplay( int val );
146 int numDisplay() const { return m_numDisplay; }
147
148 virtual void finalize();
149
150 // The page this var is on
151 int pageNum() const;
152 // The current Y position of the var (in doc pt)
153 double varY() const;
154
155 virtual void setDeleted( bool del );
156
157 void formatedNote();
158 virtual TQString fieldCode();
159protected:
160 TQString applyStyle();
161
162private:
163 KWDocument *m_doc;
164 NoteType m_noteType;
165 KWFootNoteFrameSet* m_frameset;
166 Numbering m_numberingType;
167 int m_num;
168 int m_numDisplay;
169};
170
171
172class KWStatisticVariable : public KoStatisticVariable
173{
174public:
175 KWStatisticVariable( KoTextDocument *textdoc, int subtype, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KWDocument *doc );
176 virtual void recalc();
177 virtual TQString text(bool realValue=false);
178
179protected:
180 KWDocument *m_doc;
181};
182
183#endif
KWFootNoteFrameSet * frameSet() const
The frameset that contains the text for this footnote.
Definition KWVariable.h:126
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.