F:/KPlato/koffice/libs/kotext/KoVariable.h

Aller à la documentation de ce fichier.
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 kovariable_h
00021 #define kovariable_h
00022 
00023 #include <QString>
00024 #include <QDateTime>
00025 #include <q3asciidict.h>
00026 #include <q3ptrlist.h>
00027 #include <QMap>
00028 #include <QObject>
00029 //Added by qt3to4:
00030 #include <QString>
00031 #include <Q3ValueList>
00032 #include <kaction.h>
00033 #include "KoRichText.h"
00034 #include <QVariant>
00035 #include <koffice_export.h>
00036 
00037 class QDomElement;
00038 // Always add new types at the _end_ of this list (but before VT_ALL of course).
00039 // (and update KWView::setupActions)
00040 enum VariableType {
00041     VT_NONE             = -1,
00042 
00043     VT_DATE             = 0,
00044     VT_DATE_VAR_KWORD10 = 1,
00045     VT_TIME             = 2,
00046     VT_TIME_VAR_KWORD10 = 3,
00047     VT_PGNUM            = 4,
00048     // No number 5
00049     VT_CUSTOM           = 6,
00050     VT_MAILMERGE        = 7,
00051     VT_FIELD            = 8,
00052     VT_LINK             = 9,
00053     VT_NOTE             = 10,
00054     VT_FOOTNOTE         = 11,
00055     VT_STATISTIC        = 12,
00056 
00057     VT_ALL              = 256
00058 };
00059 
00060 enum VariableFormat {
00061     VF_DATE   = 0,
00062     VF_TIME   = 1,
00063     VF_STRING = 2,
00064     VF_NUM    = 3
00065 };
00066 
00067 class KoVariable;
00068 class KoOasisSettings;
00069 
00070 class KOTEXT_EXPORT KoVariableSettings
00071 {
00072  public:
00073     KoVariableSettings();
00074     virtual ~KoVariableSettings();
00075 
00076     int startingPageNumber()const { return m_startingPageNumber; }
00077     void setStartingPageNumber(int num) { m_startingPageNumber=num; }
00078 
00079     bool displayLink() const{ return m_displayLink; }
00080     void setDisplayLink( bool b) { m_displayLink=b; }
00081 
00082     bool underlineLink() const { return m_underlineLink; }
00083     void setUnderlineLink( bool b) { m_underlineLink=b; }
00084 
00085     bool displayComment() const { return m_displayComment; }
00086     void setDisplayComment( bool b) { m_displayComment=b; }
00087 
00088     bool displayFieldCode() const { return m_displayFieldCode; }
00089     void setDisplayFieldCode( bool b) { m_displayFieldCode=b; }
00090 
00091     virtual void save( QDomElement &parentElem );
00092     virtual void load( QDomElement &elem );
00093 
00094     QDateTime lastPrintingDate() const;
00095     void setLastPrintingDate( const QDateTime & _date);
00096 
00097     QDateTime creationDate() const;
00098     void setCreationDate( const QDateTime & _date);
00099 
00100     QDateTime modificationDate() const;
00101     void setModificationDate( const QDateTime & _date);
00102 
00103     virtual void saveOasis( KoXmlWriter &settingsWriter ) const;
00104     virtual void loadOasis(const KoOasisSettings&settingsDoc);
00105 
00106 
00107  private:
00108     int m_startingPageNumber;
00109     bool m_displayLink;
00110     bool m_displayComment;
00111     bool m_underlineLink;
00112     bool m_displayFieldCode;
00113     class KoVariableSettingPrivate;
00114     KoVariableSettingPrivate *d;
00115 };
00116 
00124 class KOTEXT_EXPORT KoVariableFormat
00125 {
00126 public:
00127     KoVariableFormat() {}
00128     virtual ~KoVariableFormat() {}
00133     virtual QString key() const = 0;
00139     virtual QString getKey( const QString& props ) const = 0;
00143     virtual void load( const QString &key ) = 0;
00147     virtual QString convert(const QVariant& data ) const = 0;
00153     virtual void setFormatProperties( const QString& ) {}
00157     virtual QString formatProperties() const { return QString::null; }
00161     virtual QStringList formatPropsList() const { return QStringList(); }
00165     virtual QStringList translatedFormatPropsList() const { return QStringList(); }
00166 };
00167 
00172 class KOTEXT_EXPORT KoVariableDateFormat : public KoVariableFormat
00173 {
00174 public:
00175     KoVariableDateFormat();
00176     virtual QString convert(const QVariant& data ) const;
00177     virtual QString key() const;
00178     virtual QString getKey( const QString& props ) const;
00179     virtual void load( const QString &key );
00180 
00182     virtual void setFormatProperties( const QString& props ) {
00183         m_strFormat = props;
00184     }
00186     virtual QString formatProperties() const { return m_strFormat; }
00187 
00189     virtual QStringList formatPropsList() const { return staticFormatPropsList(); }
00190 
00192     virtual QStringList translatedFormatPropsList() const { return staticTranslatedFormatPropsList(); }
00193 
00194     static QStringList staticFormatPropsList();
00195     static QStringList staticTranslatedFormatPropsList();
00196 
00197 private:
00198     QString m_strFormat;
00199 };
00200 
00204 class KOTEXT_EXPORT KoVariableTimeFormat : public KoVariableFormat
00205 {
00206 public:
00207     KoVariableTimeFormat();
00208     virtual QString convert(const QVariant& data ) const;
00209     virtual QString key() const;
00210     virtual QString getKey( const QString& props ) const;
00211     virtual void load( const QString & /*key*/ );
00212 
00214     virtual void setFormatProperties( const QString& props ) {
00215         m_strFormat = props;
00216     }
00218     virtual QString formatProperties() const { return m_strFormat; }
00219 
00221     virtual QStringList formatPropsList() const { return staticFormatPropsList(); }
00222 
00224     virtual QStringList translatedFormatPropsList() const { return staticTranslatedFormatPropsList(); }
00225 
00226     static QStringList staticFormatPropsList();
00227     static QStringList staticTranslatedFormatPropsList();
00228 
00229 private:
00230     QString m_strFormat;
00231 };
00232 
00233 
00237 class KoVariableStringFormat : public KoVariableFormat
00238 {
00239 public:
00240     KoVariableStringFormat() : KoVariableFormat() {}
00241     virtual QString convert(const QVariant& data ) const;
00242     virtual QString key() const;
00243     virtual QString getKey( const QString& props ) const;
00244     virtual void load( const QString & /*key*/ ) {}
00245 };
00246 
00247 
00248 class KOTEXT_EXPORT KoVariableNumberFormat : public KoVariableFormat
00249 {
00250 public:
00251     KoVariableNumberFormat() : KoVariableFormat() {}
00252     virtual QString convert(const QVariant& data ) const;
00253     virtual QString key() const;
00254     virtual QString getKey( const QString& props ) const;
00255     virtual void load( const QString & /*key*/ ) {}
00256 };
00257 
00258 
00265 class KOTEXT_EXPORT KoVariableFormatCollection
00266 {
00267 public:
00268     KoVariableFormatCollection();
00269 
00273     void clear() { m_dict.clear(); }
00274 
00278     KoVariableFormat *format( const QString &key );
00279 
00280     // TODO Refcounting and removing unused formats
00281     // Not critical, that we don't delete unused formats until closing the doc...
00282 protected:
00283     KoVariableFormat *createFormat( const QString &key );
00284 
00285 private:
00286     Q3AsciiDict<KoVariableFormat> m_dict;
00287 };
00288 
00289 class KoVariable;
00290 class KoVariableFormat;
00291 class KoDocument;
00292 class KoVariableFormatCollection;
00293 class KoTextDocument;
00294 class KoVariableCollection;
00295 class KOTEXT_EXPORT KoVariableCollection : public QObject
00296 {
00297     Q_OBJECT
00298 public:
00299     // Note that the KoVariableSettings becomes owned by the collection;
00300     // we take it as argument so that it can be subclassed though.
00301     KoVariableCollection(KoVariableSettings *settings, KoVariableFormatCollection *formatCollection);
00302     ~KoVariableCollection();
00303     void registerVariable( KoVariable *var );
00304     void unregisterVariable( KoVariable *var );
00305     Q3ValueList<KoVariable *> recalcVariables(int type);
00306 
00307     // For custom variables
00308     void setVariableValue( const QString &name, const QString &value );
00309     QString getVariableValue( const QString &name ) const;
00310 
00311     const Q3PtrList<KoVariable>& getVariables() const {
00312         return variables;
00313     }
00314     void clear();
00315 
00316     bool customVariableExist(const QString &varname)const ;
00317 
00318     virtual KoVariable *createVariable( int type, short int subtype, KoVariableFormatCollection * coll, KoVariableFormat *varFormat,KoTextDocument *textdoc, KoDocument * doc, int _correct , bool _forceDefaultFormat=false, bool loadFootNote= true );
00319 
00321     virtual KoVariable* loadOasisField( KoTextDocument* textdoc, const QDomElement& tag, KoOasisContext& context );
00322     virtual KoVariable* loadOasisFieldCreateVariable( KoTextDocument* textdoc, const QDomElement& tag, KoOasisContext& context, const QString &key, int type );
00323 
00324     KoVariableSettings *variableSetting() const { return m_variableSettings; }
00325     KoVariableFormatCollection *formatCollection() const { return m_formatCollection; }
00326 
00328     void setVariableSelected(KoVariable * var);
00329     KoVariable *selectedVariable()const {return m_varSelected;}
00330 
00332     QList<KAction*> popupActionList() const;
00333 
00334  protected slots:
00335     // This is here because variables and formats are not QObjects
00336     void slotChangeSubType();
00337     void slotChangeFormat();
00338 
00339  private:
00340     //typedef QMap<KAction *, int> VariableSubTextMap;
00341     //VariableSubTextMap m_variableSubTextMap;
00342 
00343     Q3PtrList<KoVariable> variables;
00344     QMap< QString, QString > varValues; // for custom variables
00345     KoVariableSettings *m_variableSettings;
00346     KoVariable *m_varSelected;
00347     KoVariableFormatCollection *m_formatCollection;
00348 };
00349 
00350 
00351 // ----------------------------------------------------------------
00352 //                KoVariable and derived classes
00353 
00354 
00355 class KoDocument;
00356 class KoVariable;
00357 class QDomElement;
00358 class KoTextFormat;
00359 
00360 
00365 class KOTEXT_EXPORT KoVariable : public KoTextCustomItem
00366 {
00367 public:
00368     KoVariable( KoTextDocument *fs, KoVariableFormat *varFormat,KoVariableCollection *varColl );
00369     virtual ~KoVariable();
00370 
00371     virtual VariableType type() const = 0;
00372     virtual short int subType() const { return 0; }
00373 
00374     // KoTextCustomItem stuff
00375     virtual Placement placement() const { return PlaceInline; }
00376     virtual void resize();
00377     virtual int ascent() const { return m_ascent; } // for text, ascent != height!
00378     virtual int widthHint() const { return width; }
00379     virtual int minimumWidth() const { return width; }
00380     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);
00381 
00387     void drawCustomItemHelper( QPainter* p, int x, int y, int wpix, int hpix, int ascentpix, const QColorGroup& cg, bool selected, int offset, KoTextFormat* fmt, const QFont& font, QColor textColor, bool drawingShadow );
00388 
00389     void setVariableFormat( KoVariableFormat *_varFormat );
00390 
00391     KoVariableFormat *variableFormat() const
00392         { return m_varFormat; }
00393 
00394     KoVariableCollection *variableColl() const
00395         { return m_varColl; }
00396 
00402     virtual QString text(bool realValue=false);
00403 
00404     virtual QString fieldCode();
00405 
00407     QVariant varValue() const { return m_varValue; }
00408 
00415     void recalcAndRepaint();
00416 
00418     virtual void save( QDomElement &parentElem );
00419     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00420     virtual void load( QDomElement &elem );
00421     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00422 
00426     virtual int typeId() const { return 4; }
00427 
00429     virtual QStringList subTypeList();
00430 
00432     virtual void setVariableSubType( short int /*subtype*/ ) {}
00433 
00437     virtual short int variableSubType(short int menuNumber){ return menuNumber; }
00438 
00439     QString convertKlocaleToQDateTimeFormat( const QString & _format );
00440 
00441 protected:
00443     virtual void saveVariable( QDomElement &parentElem ) = 0;
00444     virtual int correctValue() const { return 0;}
00445 
00446     KoVariableFormat *m_varFormat;
00447     KoVariableCollection *m_varColl;
00448     QVariant m_varValue;
00449     int m_ascent;
00450 
00451     //typedef QMap<KAction *, int> SubTextMap;
00452     //SubTextMap m_subTextMap;
00453     class Private;
00454     Private *d;
00455 };
00456 
00457 
00461 class KOTEXT_EXPORT KoDateVariable : public KoVariable
00462 {
00463 public:
00464     KoDateVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *_varFormat,KoVariableCollection *_varColl , int _correctDate = 0);
00465 
00466     virtual VariableType type() const
00467     { return VT_DATE; }
00468 
00469     enum { VST_DATE_FIX = 0, VST_DATE_CURRENT = 1, VST_DATE_LAST_PRINTING = 2, VST_DATE_CREATE_FILE = 3, VST_DATE_MODIFY_FILE =4 };
00470     static QStringList actionTexts();
00471 
00472     virtual void recalc();
00473     virtual QString fieldCode();
00474     virtual void resize();
00475     void setDate( const QDate & _date ) { m_varValue = QVariant(_date); }
00476 
00477     virtual void saveVariable( QDomElement &parentElem );
00478     virtual int correctValue() const { return m_correctDate;}
00479     virtual void load( QDomElement &elem );
00480     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00481     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00482 
00483     virtual QStringList subTypeList();
00485     virtual void setVariableSubType( short int subtype )
00486         { m_subtype = subtype; }
00487     virtual short int subType() const { return m_subtype; }
00491     static QString formatStr( int & correct );
00495     static QString defaultFormat();
00496 
00497 protected:
00498     short int m_subtype;
00499     int m_correctDate;
00500 };
00501 
00502 
00506 class KOTEXT_EXPORT KoTimeVariable : public KoVariable
00507 {
00508 public:
00509     KoTimeVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *varFormat, KoVariableCollection *_varColl,  int _correct);
00510 
00511     virtual VariableType type() const
00512     { return VT_TIME; }
00513 
00514     enum { VST_TIME_FIX = 0, VST_TIME_CURRENT = 1 };
00515     static QStringList actionTexts();
00516 
00517     virtual void recalc();
00518     virtual void resize();
00519     virtual QString fieldCode();
00520 
00521     void setTime( const QTime & _time ) { m_varValue = QVariant(_time); }
00522 
00523     virtual void saveVariable( QDomElement &parentElem );
00524     virtual int correctValue() const { return m_correctTime;}
00525     virtual void load( QDomElement &elem );
00526     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00527     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00528 
00529     virtual QStringList subTypeList();
00530     virtual void setVariableSubType( short int subtype )
00531         { m_subtype = subtype; }
00532     virtual short int subType() const { return m_subtype; }
00536     static QString formatStr(int & _correct);
00540     static QString defaultFormat();
00541 
00542 protected:
00543     short int m_subtype;
00544     int m_correctTime; // in minutes
00545 };
00546 
00547 
00548 
00553 class KOTEXT_EXPORT KoCustomVariable : public KoVariable
00554 {
00555 public:
00556     KoCustomVariable(KoTextDocument *textdoc , const QString &name, KoVariableFormat *varFormat,KoVariableCollection *_varcoll );
00557 
00558     virtual VariableType type() const
00559     { return VT_CUSTOM; }
00560     static QStringList actionTexts();
00561 
00562     virtual void saveVariable( QDomElement &parentElem );
00563     virtual void load( QDomElement &elem );
00564     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00565     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00566 
00567     QString name() const { return m_varValue.toString(); }
00568     virtual void recalc();
00569     virtual QString fieldCode();
00570 
00571     virtual QString text(bool realValue=false);
00572 
00573     QString value() const;
00574     void setValue( const QString &v );
00575 
00576 protected:
00577 };
00578 
00579 
00585 class KOTEXT_EXPORT KoFieldVariable : public KoVariable
00586 {
00587 public:
00588     KoFieldVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KoDocument *_doc );
00589 
00590     // Do not change existing values, they are saved in document files
00591     enum FieldSubType { VST_NONE = -1,
00592                         VST_FILENAME = 0, VST_DIRECTORYNAME = 1,
00593                         VST_AUTHORNAME = 2, VST_EMAIL = 3, VST_COMPANYNAME = 4,
00594                         VST_PATHFILENAME = 5, VST_FILENAMEWITHOUTEXTENSION=6,
00595                         VST_TELEPHONE_WORK = 7, VST_FAX = 8, VST_COUNTRY = 9,
00596                         VST_TITLE = 10, VST_ABSTRACT = 11,
00597                         VST_POSTAL_CODE = 12, VST_CITY = 13, VST_STREET = 14,
00598                         VST_AUTHORTITLE = 15, VST_INITIAL = 16, VST_TELEPHONE_HOME = 17, VST_SUBJECT = 18, VST_KEYWORDS=19,VST_AUTHORPOSITION = 20 };
00599 
00600     virtual VariableType type() const
00601     { return VT_FIELD; }
00602 
00603     virtual void saveVariable( QDomElement &parentElem );
00604     virtual void load( QDomElement &elem );
00605     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00606     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00607     virtual QString fieldCode();
00608 
00609     virtual void recalc();
00610     virtual QString text(bool realValue=false);
00611 
00612     QString value() const { return m_varValue.toString(); }
00613 
00614     static QStringList actionTexts();
00618     virtual short int variableSubType( short int menuNumber );
00622     static FieldSubType fieldSubType( short int menuNumber);
00623 
00624     virtual QStringList subTypeList();
00625     virtual void setVariableSubType( short int subtype )
00626         { m_subtype = subtype; }
00627     virtual short int subType() const { return m_subtype; }
00628 
00629 protected:
00630     short int m_subtype;
00631     KoDocument *m_doc;
00632 };
00633 
00634 
00635 class KOTEXT_EXPORT KoMailMergeVariable : public KoVariable
00636 {
00637 public:
00638     KoMailMergeVariable( KoTextDocument *textdoc, const QString &name, KoVariableFormat *varFormat, KoVariableCollection *_varColl );
00639 
00640     virtual VariableType type() const
00641     { return VT_MAILMERGE; }
00642     static QStringList actionTexts();
00643     virtual QString fieldCode();
00644 
00645     virtual void saveVariable( QDomElement &parentElem );
00646     virtual void load( QDomElement &elem );
00647     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00648     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00649 
00650     virtual QString text(bool realValue=false);
00651     QString name() const { return m_varValue.toString(); }
00652     virtual QString value() const;
00653 
00654 protected:
00655 };
00656 
00657 
00663 class KOTEXT_EXPORT KoPageVariable : public KoVariable
00664 {
00665 public:
00666     KoPageVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *varFormat ,KoVariableCollection *_varColl);
00667 
00668     virtual VariableType type() const
00669     { return VT_PGNUM; }
00670 
00671     enum { VST_PGNUM_CURRENT = 0, VST_PGNUM_TOTAL = 1, VST_CURRENT_SECTION = 2 , VST_PGNUM_PREVIOUS = 3, VST_PGNUM_NEXT = 4 };
00672     static QStringList actionTexts();
00673     virtual QString fieldCode();
00674 
00675     virtual QStringList subTypeList();
00676 
00677     virtual void setVariableSubType( short int subtype );
00678 
00679     // For the 'current page' variable. This is called by the app e.g. when painting
00680     // a given page (see KWTextFrameSet::drawFrame and KPTextObject::recalcPageNum)
00681     void setPgNum( int pgNum ) { m_varValue = QVariant( pgNum); }
00682     // For the 'current section title' variable. Same thing.
00683     void setSectionTitle( const QString& title );
00684 
00685     virtual short int subType() const { return m_subtype; }
00686 
00687     virtual void recalc() = 0;
00688 
00689     virtual void saveVariable( QDomElement &parentElem );
00690     virtual void load( QDomElement &elem );
00691     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00692     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00693 protected:
00694     short int m_subtype;
00695 };
00696 
00697 
00698 class KOTEXT_EXPORT KoLinkVariable : public KoVariable
00699 {
00700 public:
00701     KoLinkVariable( KoTextDocument *textdoc, const QString & _linkName, const QString & _ulr,KoVariableFormat *varFormat, KoVariableCollection *_varColl );
00702     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 );
00703 
00704     virtual VariableType type() const
00705     { return VT_LINK; }
00706 
00707     static QStringList actionTexts();
00708     virtual QString fieldCode();
00709 
00710     virtual void saveVariable( QDomElement &parentElem );
00711     virtual void load( QDomElement &elem );
00712     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00713     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00714 
00715     virtual QString text(bool realValue=false);
00716     QString value() const { return m_varValue.toString(); }
00717     QString url() const { return m_url;}
00718 
00719     virtual void recalc();
00720 
00721     void setLink(const QString & _linkName, const QString &_url)
00722         {
00723             m_varValue=QVariant(_linkName);
00724             m_url=_url;
00725         }
00726 
00727 protected:
00728     QString m_url;
00729 };
00730 
00731 
00732 // A custom item that display a small yellow rect. Right-clicking on it shows the comment.
00733 class KOTEXT_EXPORT KoNoteVariable : public KoVariable
00734 {
00735 public:
00736     KoNoteVariable( KoTextDocument *textdoc, const QString & _note,KoVariableFormat *varFormat, KoVariableCollection *_varColl );
00737     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 );
00738 
00739     virtual VariableType type() const
00740     { return VT_NOTE; }
00741 
00742     static QStringList actionTexts();
00743     virtual QString fieldCode();
00744 
00745     virtual void saveVariable( QDomElement &parentElem );
00746     virtual void load( QDomElement &elem );
00747     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00748     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00749 
00750     virtual QString text(bool realValue=false);
00751     QString note() const { return m_varValue.toString(); }
00752     void setNote( const QString & _note) { m_varValue = QVariant(_note); }
00753     virtual void recalc();
00754 
00755     QString createdNote() const;
00756 protected:
00757     QDate m_createdNoteDate;
00758 };
00759 
00760 
00761 class KOTEXT_EXPORT KoStatisticVariable : public KoVariable
00762 {
00763 public:
00764     KoStatisticVariable( KoTextDocument *textdoc, short int subtype,
00765                          KoVariableFormat *varFormat,
00766                          KoVariableCollection *_varColl);
00767 
00768     enum {
00769         VST_STATISTIC_NB_WORD                      = 0,
00770         VST_STATISTIC_NB_SENTENCE                  = 1,
00771         VST_STATISTIC_NB_LINES                     = 2,
00772         VST_STATISTIC_NB_CHARACTERE                = 3,
00773         VST_STATISTIC_NB_NON_WHITESPACE_CHARACTERE = 4,
00774         VST_STATISTIC_NB_SYLLABLE                  = 5,
00775         VST_STATISTIC_NB_FRAME                     = 6,
00776         VST_STATISTIC_NB_EMBEDDED                  = 7,
00777         VST_STATISTIC_NB_PICTURE                   = 8,
00778         VST_STATISTIC_NB_TABLE                     = 9
00779     };
00780 
00781     virtual VariableType type() const
00782     { return VT_STATISTIC; }
00783     static QStringList actionTexts();
00784 
00785     virtual QStringList subTypeList();
00786 
00787     virtual void saveVariable( QDomElement &parentElem );
00788     virtual void load( QDomElement &elem );
00789     virtual void loadOasis( const QDomElement &elem, KoOasisContext& context );
00790     virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
00791 
00792     virtual short int subType() const { return m_subtype; }
00793 
00794     virtual void setVariableSubType( short int subtype );
00795 
00796     QString name() const { return m_varValue.toString(); }
00797     virtual QString fieldCode();
00798 
00799     QString value() const;
00800     void setValue( const QString &v );
00801     static void setExtendedType( bool _b) { m_extendedType = _b; }
00802     static bool extendedType() { return m_extendedType; }
00803 protected:
00804     short int m_subtype;
00805     // extend type for kword.
00806     static bool m_extendedType;
00807 };
00808 
00809 
00810 #endif

Généré le Wed Nov 22 23:41:11 2006 pour KPlato par  doxygen 1.5.1-p1