24#include <tqdatetime.h>
25#include <tqasciidict.h>
30#include "KoRichText.h"
32#include <koffice_export.h>
41 VT_DATE_VAR_KWORD10 = 1,
43 VT_TIME_VAR_KWORD10 = 3,
67class KOTEXT_EXPORT KoVariableSettings
71 virtual ~KoVariableSettings();
73 int startingPageNumber() const { return m_startingPageNumber; }
74 void setStartingPageNumber( int num) { m_startingPageNumber=num; }
76 bool displayLink() const{ return m_displayLink; }
77 void setDisplayLink( bool b) { m_displayLink=b; }
79 bool underlineLink() const { return m_underlineLink; }
80 void setUnderlineLink( bool b) { m_underlineLink=b; }
82 bool displayComment() const { return m_displayComment; }
83 void setDisplayComment( bool b) { m_displayComment=b; }
85 bool displayFieldCode() const { return m_displayFieldCode; }
86 void setDisplayFieldCode( bool b) { m_displayFieldCode=b; }
88 virtual void save( TQDomElement &parentElem );
89 virtual void load( TQDomElement &elem );
91 TQDateTime lastPrintingDate() const;
92 void setLastPrintingDate( const TQDateTime & _date);
94 TQDateTime creationDate() const;
95 void setCreationDate( const TQDateTime & _date);
97 TQDateTime modificationDate() const;
98 void setModificationDate( const TQDateTime & _date);
100 virtual void saveOasis( KoXmlWriter &settingsWriter ) const;
105 int m_startingPageNumber;
107 bool m_displayComment;
108 bool m_underlineLink;
109 bool m_displayFieldCode;
110 class KoVariableSettingPrivate;
111 KoVariableSettingPrivate *d;
130 virtual TQCString key() const = 0;
136 virtual TQCString getKey( const TQString& props ) const = 0;
140 virtual void load( const TQCString &key ) = 0;
144 virtual TQString convert( const TQVariant& data ) const = 0;
173 virtual TQString convert( const TQVariant& data ) const;
174 virtual TQCString key() const;
175 virtual TQCString getKey( const TQString& props ) const;
176 virtual void load( const TQCString &key );
191 static TQStringList staticFormatPropsList();
192 static TQStringList staticTranslatedFormatPropsList();
195 TQString m_strFormat;
205 virtual TQString convert( const TQVariant& data ) const;
206 virtual TQCString key() const;
207 virtual TQCString getKey( const TQString& props ) const;
208 virtual void load( const TQCString & );
223 static TQStringList staticFormatPropsList();
224 static TQStringList staticTranslatedFormatPropsList();
227 TQString m_strFormat;
238 virtual TQString convert( const TQVariant& data ) const;
239 virtual TQCString key() const;
240 virtual TQCString getKey( const TQString& props ) const;
241 virtual void load( const TQCString & ) {}
249 virtual TQString convert( const TQVariant& data ) const;
250 virtual TQCString key() const;
251 virtual TQCString getKey( const TQString& props ) const;
252 virtual void load( const TQCString & ) {}
283 TQAsciiDict<KoVariableFormat> m_dict;
291class KoVariableCollection;
292class KOTEXT_EXPORT KoVariableCollection : public TQObject
300 ~KoVariableCollection();
303 TQValueList<KoVariable *> recalcVariables( int type);
306 void setVariableValue( const TQString &name, const TQString &value );
307 TQString getVariableValue( const TQString &name ) const;
309 const TQPtrList<KoVariable>& getVariables() const {
314 bool customVariableExist( const TQString &varname) const ;
320 virtual KoVariable* loadOasisFieldCreateVariable( KoTextDocument* textdoc, const TQDomElement& tag, KoOasisContext& context, const TQString &key, int type );
322 KoVariableSettings *variableSetting() const { return m_variableSettings; }
327 KoVariable *selectedVariable() const { return m_varSelected;}
330 TQPtrList<TDEAction> popupActionList() const;
334 void slotChangeSubType();
335 void slotChangeFormat();
341 TQPtrList<KoVariable> variables;
342 TQMap< TQString, TQString > varValues;
343 KoVariableSettings *m_variableSettings;
369 virtual VariableType type() const = 0;
370 virtual short int subType() const { return 0; }
373 virtual Placement placement() const { return PlaceInline; }
374 virtual void resize();
375 virtual int ascent() const { return m_ascent; }
376 virtual int widthHint() const { return width; }
377 virtual int minimumWidth() const { return width; }
378 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);
385 void drawCustomItemHelper( TQPainter* p, int x, int y, int wpix, int hpix, int ascentpix, const TQColorGroup& cg, bool selected, int offset, KoTextFormat* fmt, const TQFont& font, TQColor textColor, bool drawingShadow );
390 { return m_varFormat; }
392 KoVariableCollection *variableColl() const
393 { return m_varColl; }
400 virtual TQString text( bool realValue= false);
402 virtual TQString fieldCode();
413 void recalcAndRepaint();
416 virtual void save( TQDomElement &parentElem );
418 virtual void load( TQDomElement &elem );
419 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
427 virtual TQStringList subTypeList();
437 TQString convertKlocaleToTQDateTimeFormat( const TQString & _format );
442 virtual int correctValue() const { return 0;}
445 KoVariableCollection *m_varColl;
446 TQVariant m_varValue;
464 virtual VariableType type() const
467 enum { VST_DATE_FIX = 0, VST_DATE_CURRENT = 1, VST_DATE_LAST_PRINTING = 2, VST_DATE_CREATE_FILE = 3, VST_DATE_MODIFY_FILE =4 };
468 static TQStringList actionTexts();
470 virtual void recalc();
471 virtual TQString fieldCode();
472 virtual void resize();
473 void setDate( const TQDate & _date ) { m_varValue = TQVariant(_date); }
475 virtual void saveVariable( TQDomElement &parentElem );
476 virtual int correctValue() const { return m_correctDate;}
477 virtual void load( TQDomElement &elem );
478 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
481 virtual TQStringList subTypeList();
484 { m_subtype = subtype; }
485 virtual short int subType() const { return m_subtype; }
489 static TQCString formatStr( int & correct );
493 static TQCString defaultFormat();
509 virtual VariableType type() const
512 enum { VST_TIME_FIX = 0, VST_TIME_CURRENT = 1 };
513 static TQStringList actionTexts();
515 virtual void recalc();
516 virtual void resize();
517 virtual TQString fieldCode();
519 void setTime( const TQTime & _time ) { m_varValue = TQVariant(_time); }
521 virtual void saveVariable( TQDomElement &parentElem );
522 virtual int correctValue() const { return m_correctTime;}
523 virtual void load( TQDomElement &elem );
524 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
527 virtual TQStringList subTypeList();
529 { m_subtype = subtype; }
530 virtual short int subType() const { return m_subtype; }
534 static TQCString formatStr( int & _correct);
538 static TQCString defaultFormat();
556 virtual VariableType type() const
557 { return VT_CUSTOM; }
558 static TQStringList actionTexts();
560 virtual void saveVariable( TQDomElement &parentElem );
561 virtual void load( TQDomElement &elem );
562 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
565 TQString name() const { return m_varValue.toString(); }
566 virtual void recalc();
567 virtual TQString fieldCode();
569 virtual TQString text( bool realValue= false);
571 TQString value() const;
572 void setValue( const TQString &v );
589 enum FieldSubType { VST_NONE = -1,
590 VST_FILENAME = 0, VST_DIRECTORYNAME = 1,
591 VST_AUTHORNAME = 2, VST_EMAIL = 3, VST_COMPANYNAME = 4,
592 VST_PATHFILENAME = 5, VST_FILENAMEWITHOUTEXTENSION=6,
593 VST_TELEPHONE_WORK = 7, VST_FAX = 8, VST_COUNTRY = 9,
594 VST_TITLE = 10, VST_ABSTRACT = 11,
595 VST_POSTAL_CODE = 12, VST_CITY = 13, VST_STREET = 14,
596 VST_AUTHORTITLE = 15, VST_INITIAL = 16, VST_TELEPHONE_HOME = 17, VST_SUBJECT = 18, VST_KEYWORDS=19,VST_AUTHORPOSITION = 20 };
598 virtual VariableType type() const
601 virtual void saveVariable( TQDomElement &parentElem );
602 virtual void load( TQDomElement &elem );
603 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
605 virtual TQString fieldCode();
607 virtual void recalc();
608 virtual TQString text( bool realValue= false);
610 TQString value() const { return m_varValue.toString(); }
612 static TQStringList actionTexts();
616 virtual short int variableSubType( short int menuNumber );
620 static FieldSubType fieldSubType( short int menuNumber);
622 virtual TQStringList subTypeList();
624 { m_subtype = subtype; }
625 virtual short int subType() const { return m_subtype; }
633class KOTEXT_EXPORT KoMailMergeVariable : public KoVariable
636 KoMailMergeVariable( KoTextDocument *textdoc, const TQString &name, KoVariableFormat *varFormat, KoVariableCollection *_varColl );
638 virtual VariableType type() const
639 { return VT_MAILMERGE; }
640 static TQStringList actionTexts();
641 virtual TQString fieldCode();
643 virtual void saveVariable( TQDomElement &parentElem );
644 virtual void load( TQDomElement &elem );
645 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
648 virtual TQString text( bool realValue= false);
649 TQString name() const { return m_varValue.toString(); }
650 virtual TQString value() const;
666 virtual VariableType type() const
669 enum { VST_PGNUM_CURRENT = 0, VST_PGNUM_TOTAL = 1, VST_CURRENT_SECTION = 2 , VST_PGNUM_PREVIOUS = 3, VST_PGNUM_NEXT = 4 };
670 static TQStringList actionTexts();
671 virtual TQString fieldCode();
673 virtual TQStringList subTypeList();
675 virtual void setVariableSubType( short int subtype );
679 void setPgNum( int pgNum ) { m_varValue = TQVariant( pgNum); }
681 void setSectionTitle( const TQString& title );
683 virtual short int subType() const { return m_subtype; }
687 virtual void saveVariable( TQDomElement &parentElem );
688 virtual void load( TQDomElement &elem );
689 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
696class KOTEXT_EXPORT KoLinkVariable : public KoVariable
699 KoLinkVariable( KoTextDocument *textdoc, const TQString & _linkName, const TQString & _ulr, KoVariableFormat *varFormat, KoVariableCollection *_varColl );
700 virtual void drawCustomItem( TQPainter* p, int x, int y, int wpix, int hpix, int ascentpix, int , int , int , int , const TQColorGroup& cg, bool selected, int offset, bool drawingShadow );
702 virtual VariableType type() const
705 static TQStringList actionTexts();
706 virtual TQString fieldCode();
708 virtual void saveVariable( TQDomElement &parentElem );
709 virtual void load( TQDomElement &elem );
710 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
713 virtual TQString text( bool realValue= false);
714 TQString value() const { return m_varValue.toString(); }
715 TQString url() const { return m_url;}
717 virtual void recalc();
719 void setLink( const TQString & _linkName, const TQString &_url)
721 m_varValue=TQVariant(_linkName);
731class KOTEXT_EXPORT KoNoteVariable : public KoVariable
734 KoNoteVariable( KoTextDocument *textdoc, const TQString & _note, KoVariableFormat *varFormat, KoVariableCollection *_varColl );
735 virtual void drawCustomItem( TQPainter* p, int x, int y, int wpix, int hpix, int ascentpix, int , int , int , int , const TQColorGroup& cg, bool selected, int offset, bool drawingShadow );
737 virtual VariableType type() const
740 static TQStringList actionTexts();
741 virtual TQString fieldCode();
743 virtual void saveVariable( TQDomElement &parentElem );
744 virtual void load( TQDomElement &elem );
745 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
748 virtual TQString text( bool realValue= false);
749 TQString note() const { return m_varValue.toString(); }
750 void setNote( const TQString & _note) { m_varValue = TQVariant(_note); }
751 virtual void recalc();
753 TQString createdNote() const;
755 TQDate m_createdNoteDate;
759class KOTEXT_EXPORT KoStatisticVariable : public KoVariable
762 KoStatisticVariable( KoTextDocument *textdoc, short int subtype,
764 KoVariableCollection *_varColl);
767 VST_STATISTIC_NB_WORD = 0,
768 VST_STATISTIC_NB_SENTENCE = 1,
769 VST_STATISTIC_NB_LINES = 2,
770 VST_STATISTIC_NB_CHARACTERE = 3,
771 VST_STATISTIC_NB_NON_WHITESPACE_CHARACTERE = 4,
772 VST_STATISTIC_NB_SYLLABLE = 5,
773 VST_STATISTIC_NB_FRAME = 6,
774 VST_STATISTIC_NB_EMBEDDED = 7,
775 VST_STATISTIC_NB_PICTURE = 8,
776 VST_STATISTIC_NB_TABLE = 9
779 virtual VariableType type() const
780 { return VT_STATISTIC; }
781 static TQStringList actionTexts();
783 virtual TQStringList subTypeList();
785 virtual void saveVariable( TQDomElement &parentElem );
786 virtual void load( TQDomElement &elem );
787 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
790 virtual short int subType() const { return m_subtype; }
792 virtual void setVariableSubType( short int subtype );
794 TQString name() const { return m_varValue.toString(); }
795 virtual TQString fieldCode();
797 TQString value() const;
798 void setValue( const TQString &v );
799 static void setExtendedType( bool _b) { m_extendedType = _b; }
800 static bool extendedType() { return m_extendedType; }
804 static bool m_extendedType;
A custom variable is a variable whose value is entered by the user.
virtual void setVariableSubType(short int subtype) Set this variable's subtype.
The KOffice document class.
Any variable that is a string, and whose value is automatically determined - as opposed to custom var...
virtual void setVariableSubType(short int subtype) Set this variable's subtype.
Used during loading of Oasis format (and discarded at the end of the loading).
"current page number" and "number of pages" variables This is a base class, it must be inherited by a...
virtual void recalc()=0 Reimplemented by KoVariable to recalculate the value.
Used during saving to Oasis format (and discarded at the end of the saving).
KoTextCustomItem is the base class for custom items (i.e.
Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that charac...
virtual void setVariableSubType(short int subtype) Set this variable's subtype.
A KoVariable is a custom item, i.e.
TQVariant varValue() const Return the variable value, as a TQVariant, before format conversion.
virtual int typeId() const Part of the KoTextCustomItem interface.
virtual void saveVariable(TQDomElement &parentElem)=0 Variable should reimplement this to implement saving.
virtual void setVariableSubType(short int) Set this variable's subtype.
virtual short int variableSubType(short int menuNumber) Converts the menuNumber to variable subtype number (VST_x)
A class for writing out XML (to any TQIODevice), with a special attention on performance.
TDEAction * save(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const char * name(StdAction id)
|