kword

KWVariable.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef variable_h
00021 #define variable_h
00022 
00023 #include <qstring.h>
00024 #include <qdatetime.h>
00025 #include <qasciidict.h>
00026 
00027 #include "defs.h"
00028 
00029 #include <KoVariable.h>
00030 #include <KoParagCounter.h>
00031 
00032 class KWDocument;
00033 class KWTextFrameSet;
00034 class KWFootNoteFrameSet;
00035 class KoVariable;
00036 class KoPageVariable;
00037 class KoMailMergeVariable;
00038 class QDomElement;
00039 class KoTextFormat;
00040 
00041 
00042 class KWVariableSettings : public KoVariableSettings
00043 {
00044  public:
00045     KWVariableSettings();
00046     virtual ~KWVariableSettings() {}
00047     virtual void save( QDomElement &parentElem );
00048     virtual void load( QDomElement &elem );
00049     void saveNoteConfiguration( KoXmlWriter& writer ) const;
00050     void loadNoteConfiguration( const QDomElement& parent );
00051     void changeFootNoteCounter( KoParagCounter _c );
00052     void changeEndNoteCounter( KoParagCounter _c );
00053     KoParagCounter endNoteCounter() const { return m_endNoteCounter;}
00054     KoParagCounter footNoteCounter() const { return m_footNoteCounter;}
00055  private:
00056     KoParagCounter m_footNoteCounter;
00057     KoParagCounter m_endNoteCounter;
00058 };
00059 
00060 class KWVariableCollection : public KoVariableCollection
00061 {
00062  public:
00063     KWVariableCollection(KWVariableSettings *_settings, KoVariableFormatCollection* coll);
00064     virtual KoVariable *createVariable( int type, short int subtype, KoVariableFormatCollection * coll, KoVariableFormat *varFormat,KoTextDocument *textdoc, KoDocument * doc, int _correct, bool _forceDefaultFormat=false, bool loadFootNote= true );
00065     virtual KoVariable* loadOasisField( KoTextDocument* textdoc, const QDomElement& tag, KoOasisContext& context );
00066 
00067  private:
00068     KWDocument *m_doc;
00069 };
00070 
00074 class KWPgNumVariable : public KoPageVariable
00075 {
00076 public:
00077     KWPgNumVariable( KoTextDocument *textdoc, int subtype, KoVariableFormat *varFormat ,KoVariableCollection *_varColl, KWDocument *doc );
00078 
00079     virtual void recalc();
00080     virtual QString text(bool realValue=false);
00081 
00082 private:
00083     KWDocument *m_doc;
00084 };
00085 
00086 
00090 class KWMailMergeVariable : public KoMailMergeVariable
00091 {
00092 public:
00093     KWMailMergeVariable( KoTextDocument *textdoc, const QString &name, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KWDocument *doc );
00094 
00095     virtual QString text(bool realValue=false);
00096     virtual QString value() const;
00097     virtual void recalc();
00098  private:
00099     KWDocument *m_doc;
00100 };
00101 
00105 class KWFootNoteVariable : public KoVariable
00106 {
00107 public:
00108     KWFootNoteVariable( KoTextDocument *textdoc, KoVariableFormat *varFormat, KoVariableCollection *varColl, KWDocument *doc );
00109     virtual VariableType type() const
00110     { return VT_FOOTNOTE; }
00111     enum Numbering {Auto, Manual};
00112 
00113     void setNoteType( NoteType _noteType ) { m_noteType = _noteType;}
00114     NoteType noteType() const {return m_noteType; }
00115 
00116     void setNumberingType( Numbering _type );
00117     Numbering numberingType() const { return m_numberingType;}
00118 
00119     void setManualString( const QString & _str ) { m_varValue=QVariant(_str);}
00120     QString manualString() const { return m_varValue.toString();}
00121 
00122     virtual void resize();
00123     virtual void drawCustomItem( QPainter* p, int x, int y, int wpix, int hpix, int ascentpix, int /*cx*/, int /*cy*/, int /*cw*/, int /*ch*/, const QColorGroup& cg, bool selected, int offset, bool drawingShadow );
00124 
00126     KWFootNoteFrameSet * frameSet() const { return m_frameset; }
00127     void setFrameSet( KWFootNoteFrameSet* fs ) { Q_ASSERT( !m_frameset ); m_frameset = fs; }
00128 
00129     virtual void saveVariable( QDomElement &parentElem );
00130     virtual void load( QDomElement &elem );
00131 
00132     virtual void loadOasis( const QDomElement &footNoteTag, KoOasisContext& context );
00133     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00134 
00135 
00136     virtual QString text(bool realValue=false);
00137     // Nothing to do here. Numbering done by KWTextFrameSet::renumberFootNotes
00138     virtual void recalc() { }
00139 
00140     // This is a sequence number, to order footnotes. It is always set, and different for all footnotes.
00141     void setNum( int _num ) { m_num = _num; }
00142     int num() const { return m_num; }
00143 
00144     // The number being displayed - for auto-numbered footnotes only.
00145     void setNumDisplay( int val );
00146     int numDisplay() const { return m_numDisplay; }
00147 
00148     virtual void finalize();
00149 
00150     // The page this var is on
00151     int pageNum() const;
00152     // The current Y position of the var (in doc pt)
00153     double varY() const;
00154 
00155     virtual void setDeleted( bool del );
00156 
00157     void formatedNote();
00158     virtual QString fieldCode();
00159 protected:
00160     QString applyStyle();
00161 
00162 private:
00163     KWDocument *m_doc;
00164     NoteType m_noteType;
00165     KWFootNoteFrameSet* m_frameset;
00166     Numbering m_numberingType;
00167     int m_num;
00168     int m_numDisplay;
00169 };
00170 
00171 
00172 class KWStatisticVariable : public KoStatisticVariable
00173 {
00174 public:
00175     KWStatisticVariable( KoTextDocument *textdoc, int subtype, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KWDocument *doc );
00176     virtual void recalc();
00177     virtual QString text(bool realValue=false);
00178 
00179 protected:
00180     KWDocument *m_doc;
00181 };
00182 
00183 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys