lib

KoVariable.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 kovariable_h
21#define kovariable_h
22
23#include <tqstring.h>
24#include <tqdatetime.h>
25#include <tqasciidict.h>
26#include <tqptrlist.h>
27#include <tqmap.h>
28#include <tqobject.h>
29#include <tdeaction.h>
30#include "KoRichText.h"
31#include <tqvariant.h>
32#include <koffice_export.h>
33
34class TQDomElement;
35// Always add new types at the _end_ of this list (but before VT_ALL of course).
36// (and update KWView::setupActions)
37enum VariableType {
38 VT_NONE = -1,
39
40 VT_DATE = 0,
41 VT_DATE_VAR_KWORD10 = 1,
42 VT_TIME = 2,
43 VT_TIME_VAR_KWORD10 = 3,
44 VT_PGNUM = 4,
45 // No number 5
46 VT_CUSTOM = 6,
47 VT_MAILMERGE = 7,
48 VT_FIELD = 8,
49 VT_LINK = 9,
50 VT_NOTE = 10,
51 VT_FOOTNOTE = 11,
52 VT_STATISTIC = 12,
53
54 VT_ALL = 256
55};
56
57enum VariableFormat {
58 VF_DATE = 0,
59 VF_TIME = 1,
60 VF_STRING = 2,
61 VF_NUM = 3
62};
63
64class KoVariable;
65class KoOasisSettings;
66
67class KOTEXT_EXPORT KoVariableSettings
68{
69 public:
70 KoVariableSettings();
71 virtual ~KoVariableSettings();
72
73 int startingPageNumber()const { return m_startingPageNumber; }
74 void setStartingPageNumber(int num) { m_startingPageNumber=num; }
75
76 bool displayLink() const{ return m_displayLink; }
77 void setDisplayLink( bool b) { m_displayLink=b; }
78
79 bool underlineLink() const { return m_underlineLink; }
80 void setUnderlineLink( bool b) { m_underlineLink=b; }
81
82 bool displayComment() const { return m_displayComment; }
83 void setDisplayComment( bool b) { m_displayComment=b; }
84
85 bool displayFieldCode() const { return m_displayFieldCode; }
86 void setDisplayFieldCode( bool b) { m_displayFieldCode=b; }
87
88 virtual void save( TQDomElement &parentElem );
89 virtual void load( TQDomElement &elem );
90
91 TQDateTime lastPrintingDate() const;
92 void setLastPrintingDate( const TQDateTime & _date);
93
94 TQDateTime creationDate() const;
95 void setCreationDate( const TQDateTime & _date);
96
97 TQDateTime modificationDate() const;
98 void setModificationDate( const TQDateTime & _date);
99
100 virtual void saveOasis( KoXmlWriter &settingsWriter ) const;
101 virtual void loadOasis(const KoOasisSettings&settingsDoc);
102
103
104 private:
105 int m_startingPageNumber;
106 bool m_displayLink;
107 bool m_displayComment;
108 bool m_underlineLink;
109 bool m_displayFieldCode;
110 class KoVariableSettingPrivate;
111 KoVariableSettingPrivate *d;
112};
113
121class KOTEXT_EXPORT KoVariableFormat
122{
123public:
125 virtual ~KoVariableFormat() {}
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;
150 virtual void setFormatProperties( const TQString& ) {}
154 virtual TQString formatProperties() const { return TQString(); }
158 virtual TQStringList formatPropsList() const { return TQStringList(); }
162 virtual TQStringList translatedFormatPropsList() const { return TQStringList(); }
163};
164
169class KOTEXT_EXPORT KoVariableDateFormat : public KoVariableFormat
170{
171public:
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 );
177
179 virtual void setFormatProperties( const TQString& props ) {
180 m_strFormat = props;
181 }
183 virtual TQString formatProperties() const { return m_strFormat; }
184
186 virtual TQStringList formatPropsList() const { return staticFormatPropsList(); }
187
189 virtual TQStringList translatedFormatPropsList() const { return staticTranslatedFormatPropsList(); }
190
191 static TQStringList staticFormatPropsList();
192 static TQStringList staticTranslatedFormatPropsList();
193
194private:
195 TQString m_strFormat;
196};
197
201class KOTEXT_EXPORT KoVariableTimeFormat : public KoVariableFormat
202{
203public:
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 & /*key*/ );
209
211 virtual void setFormatProperties( const TQString& props ) {
212 m_strFormat = props;
213 }
215 virtual TQString formatProperties() const { return m_strFormat; }
216
218 virtual TQStringList formatPropsList() const { return staticFormatPropsList(); }
219
221 virtual TQStringList translatedFormatPropsList() const { return staticTranslatedFormatPropsList(); }
222
223 static TQStringList staticFormatPropsList();
224 static TQStringList staticTranslatedFormatPropsList();
225
226private:
227 TQString m_strFormat;
228};
229
230
235{
236public:
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 & /*key*/ ) {}
242};
243
244
245class KOTEXT_EXPORT KoVariableNumberFormat : public KoVariableFormat
246{
247public:
248 KoVariableNumberFormat() : KoVariableFormat() {}
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 & /*key*/ ) {}
253};
254
255
262class KOTEXT_EXPORT KoVariableFormatCollection
263{
264public:
266
270 void clear() { m_dict.clear(); }
271
275 KoVariableFormat *format( const TQCString &key );
276
277 // TODO Refcounting and removing unused formats
278 // Not critical, that we don't delete unused formats until closing the doc...
279protected:
280 KoVariableFormat *createFormat( const TQCString &key );
281
282private:
283 TQAsciiDict<KoVariableFormat> m_dict;
284};
285
286class KoVariable;
287class KoVariableFormat;
288class KoDocument;
290class KoTextDocument;
291class KoVariableCollection;
292class KOTEXT_EXPORT KoVariableCollection : public TQObject
293{
294 TQ_OBJECT
295
296public:
297 // Note that the KoVariableSettings becomes owned by the collection;
298 // we take it as argument so that it can be subclassed though.
299 KoVariableCollection(KoVariableSettings *settings, KoVariableFormatCollection *formatCollection);
300 ~KoVariableCollection();
301 void registerVariable( KoVariable *var );
302 void unregisterVariable( KoVariable *var );
303 TQValueList<KoVariable *> recalcVariables(int type);
304
305 // For custom variables
306 void setVariableValue( const TQString &name, const TQString &value );
307 TQString getVariableValue( const TQString &name ) const;
308
309 const TQPtrList<KoVariable>& getVariables() const {
310 return variables;
311 }
312 void clear();
313
314 bool customVariableExist(const TQString &varname)const ;
315
316 virtual KoVariable *createVariable( int type, short int subtype, KoVariableFormatCollection * coll, KoVariableFormat *varFormat,KoTextDocument *textdoc, KoDocument * doc, int _correct , bool _forceDefaultFormat=false, bool loadFootNote= true );
317
319 virtual KoVariable* loadOasisField( KoTextDocument* textdoc, const TQDomElement& tag, KoOasisContext& context );
320 virtual KoVariable* loadOasisFieldCreateVariable( KoTextDocument* textdoc, const TQDomElement& tag, KoOasisContext& context, const TQString &key, int type );
321
322 KoVariableSettings *variableSetting() const { return m_variableSettings; }
323 KoVariableFormatCollection *formatCollection() const { return m_formatCollection; }
324
326 void setVariableSelected(KoVariable * var);
327 KoVariable *selectedVariable()const {return m_varSelected;}
328
330 TQPtrList<TDEAction> popupActionList() const;
331
332 protected slots:
333 // This is here because variables and formats are not TQObjects
334 void slotChangeSubType();
335 void slotChangeFormat();
336
337 private:
338 //typedef TQMap<TDEAction *, int> VariableSubTextMap;
339 //VariableSubTextMap m_variableSubTextMap;
340
341 TQPtrList<KoVariable> variables;
342 TQMap< TQString, TQString > varValues; // for custom variables
343 KoVariableSettings *m_variableSettings;
344 KoVariable *m_varSelected;
345 KoVariableFormatCollection *m_formatCollection;
346};
347
348
349// ----------------------------------------------------------------
350// KoVariable and derived classes
351
352
353class KoDocument;
354class KoVariable;
355class TQDomElement;
356class KoTextFormat;
357
358
363class KOTEXT_EXPORT KoVariable : public KoTextCustomItem
364{
365public:
366 KoVariable( KoTextDocument *fs, KoVariableFormat *varFormat,KoVariableCollection *varColl );
367 virtual ~KoVariable();
368
369 virtual VariableType type() const = 0;
370 virtual short int subType() const { return 0; }
371
372 // KoTextCustomItem stuff
373 virtual Placement placement() const { return PlaceInline; }
374 virtual void resize();
375 virtual int ascent() const { return m_ascent; } // for text, ascent != height!
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);
379
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 );
386
387 void setVariableFormat( KoVariableFormat *_varFormat );
388
389 KoVariableFormat *variableFormat() const
390 { return m_varFormat; }
391
392 KoVariableCollection *variableColl() const
393 { return m_varColl; }
394
400 virtual TQString text(bool realValue=false);
401
402 virtual TQString fieldCode();
403
405 TQVariant varValue() const { return m_varValue; }
406
413 void recalcAndRepaint();
414
416 virtual void save( TQDomElement &parentElem );
417 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
418 virtual void load( TQDomElement &elem );
419 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
420
424 virtual int typeId() const { return 4; }
425
427 virtual TQStringList subTypeList();
428
430 virtual void setVariableSubType( short int /*subtype*/ ) {}
431
435 virtual short int variableSubType(short int menuNumber){ return menuNumber; }
436
437 TQString convertKlocaleToTQDateTimeFormat( const TQString & _format );
438
439protected:
441 virtual void saveVariable( TQDomElement &parentElem ) = 0;
442 virtual int correctValue() const { return 0;}
443
444 KoVariableFormat *m_varFormat;
445 KoVariableCollection *m_varColl;
446 TQVariant m_varValue;
447 int m_ascent;
448
449 //typedef TQMap<TDEAction *, int> SubTextMap;
450 //SubTextMap m_subTextMap;
451 class Private;
452 Private *d;
453};
454
455
459class KOTEXT_EXPORT KoDateVariable : public KoVariable
460{
461public:
462 KoDateVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *_varFormat,KoVariableCollection *_varColl , int _correctDate = 0);
463
464 virtual VariableType type() const
465 { return VT_DATE; }
466
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();
469
470 virtual void recalc();
471 virtual TQString fieldCode();
472 virtual void resize();
473 void setDate( const TQDate & _date ) { m_varValue = TQVariant(_date); }
474
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 );
479 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
480
481 virtual TQStringList subTypeList();
483 virtual void setVariableSubType( short int subtype )
484 { m_subtype = subtype; }
485 virtual short int subType() const { return m_subtype; }
489 static TQCString formatStr( int & correct );
493 static TQCString defaultFormat();
494
495protected:
496 short int m_subtype;
497 int m_correctDate;
498};
499
500
504class KOTEXT_EXPORT KoTimeVariable : public KoVariable
505{
506public:
507 KoTimeVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *varFormat, KoVariableCollection *_varColl, int _correct);
508
509 virtual VariableType type() const
510 { return VT_TIME; }
511
512 enum { VST_TIME_FIX = 0, VST_TIME_CURRENT = 1 };
513 static TQStringList actionTexts();
514
515 virtual void recalc();
516 virtual void resize();
517 virtual TQString fieldCode();
518
519 void setTime( const TQTime & _time ) { m_varValue = TQVariant(_time); }
520
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 );
525 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
526
527 virtual TQStringList subTypeList();
528 virtual void setVariableSubType( short int subtype )
529 { m_subtype = subtype; }
530 virtual short int subType() const { return m_subtype; }
534 static TQCString formatStr(int & _correct);
538 static TQCString defaultFormat();
539
540protected:
541 short int m_subtype;
542 int m_correctTime; // in minutes
543};
544
545
546
551class KOTEXT_EXPORT KoCustomVariable : public KoVariable
552{
553public:
554 KoCustomVariable(KoTextDocument *textdoc , const TQString &name, KoVariableFormat *varFormat,KoVariableCollection *_varcoll );
555
556 virtual VariableType type() const
557 { return VT_CUSTOM; }
558 static TQStringList actionTexts();
559
560 virtual void saveVariable( TQDomElement &parentElem );
561 virtual void load( TQDomElement &elem );
562 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
563 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
564
565 TQString name() const { return m_varValue.toString(); }
566 virtual void recalc();
567 virtual TQString fieldCode();
568
569 virtual TQString text(bool realValue=false);
570
571 TQString value() const;
572 void setValue( const TQString &v );
573
574protected:
575};
576
577
583class KOTEXT_EXPORT KoFieldVariable : public KoVariable
584{
585public:
586 KoFieldVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *varFormat,KoVariableCollection *_varColl, KoDocument *_doc );
587
588 // Do not change existing values, they are saved in document files
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 };
597
598 virtual VariableType type() const
599 { return VT_FIELD; }
600
601 virtual void saveVariable( TQDomElement &parentElem );
602 virtual void load( TQDomElement &elem );
603 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
604 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
605 virtual TQString fieldCode();
606
607 virtual void recalc();
608 virtual TQString text(bool realValue=false);
609
610 TQString value() const { return m_varValue.toString(); }
611
612 static TQStringList actionTexts();
616 virtual short int variableSubType( short int menuNumber );
620 static FieldSubType fieldSubType( short int menuNumber);
621
622 virtual TQStringList subTypeList();
623 virtual void setVariableSubType( short int subtype )
624 { m_subtype = subtype; }
625 virtual short int subType() const { return m_subtype; }
626
627protected:
628 short int m_subtype;
629 KoDocument *m_doc;
630};
631
632
633class KOTEXT_EXPORT KoMailMergeVariable : public KoVariable
634{
635public:
636 KoMailMergeVariable( KoTextDocument *textdoc, const TQString &name, KoVariableFormat *varFormat, KoVariableCollection *_varColl );
637
638 virtual VariableType type() const
639 { return VT_MAILMERGE; }
640 static TQStringList actionTexts();
641 virtual TQString fieldCode();
642
643 virtual void saveVariable( TQDomElement &parentElem );
644 virtual void load( TQDomElement &elem );
645 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
646 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
647
648 virtual TQString text(bool realValue=false);
649 TQString name() const { return m_varValue.toString(); }
650 virtual TQString value() const;
651
652protected:
653};
654
655
661class KOTEXT_EXPORT KoPageVariable : public KoVariable
662{
663public:
664 KoPageVariable( KoTextDocument *textdoc, short int subtype, KoVariableFormat *varFormat ,KoVariableCollection *_varColl);
665
666 virtual VariableType type() const
667 { return VT_PGNUM; }
668
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();
672
673 virtual TQStringList subTypeList();
674
675 virtual void setVariableSubType( short int subtype );
676
677 // For the 'current page' variable. This is called by the app e.g. when painting
678 // a given page (see KWTextFrameSet::drawFrame and KPTextObject::recalcPageNum)
679 void setPgNum( int pgNum ) { m_varValue = TQVariant( pgNum); }
680 // For the 'current section title' variable. Same thing.
681 void setSectionTitle( const TQString& title );
682
683 virtual short int subType() const { return m_subtype; }
684
685 virtual void recalc() = 0;
686
687 virtual void saveVariable( TQDomElement &parentElem );
688 virtual void load( TQDomElement &elem );
689 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
690 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
691protected:
692 short int m_subtype;
693};
694
695
696class KOTEXT_EXPORT KoLinkVariable : public KoVariable
697{
698public:
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 /*cx*/, int /*cy*/, int /*cw*/, int /*ch*/, const TQColorGroup& cg, bool selected, int offset, bool drawingShadow );
701
702 virtual VariableType type() const
703 { return VT_LINK; }
704
705 static TQStringList actionTexts();
706 virtual TQString fieldCode();
707
708 virtual void saveVariable( TQDomElement &parentElem );
709 virtual void load( TQDomElement &elem );
710 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
711 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
712
713 virtual TQString text(bool realValue=false);
714 TQString value() const { return m_varValue.toString(); }
715 TQString url() const { return m_url;}
716
717 virtual void recalc();
718
719 void setLink(const TQString & _linkName, const TQString &_url)
720 {
721 m_varValue=TQVariant(_linkName);
722 m_url=_url;
723 }
724
725protected:
726 TQString m_url;
727};
728
729
730// A custom item that display a small yellow rect. Right-clicking on it shows the comment.
731class KOTEXT_EXPORT KoNoteVariable : public KoVariable
732{
733public:
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 /*cx*/, int /*cy*/, int /*cw*/, int /*ch*/, const TQColorGroup& cg, bool selected, int offset, bool drawingShadow );
736
737 virtual VariableType type() const
738 { return VT_NOTE; }
739
740 static TQStringList actionTexts();
741 virtual TQString fieldCode();
742
743 virtual void saveVariable( TQDomElement &parentElem );
744 virtual void load( TQDomElement &elem );
745 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
746 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
747
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();
752
753 TQString createdNote() const;
754protected:
755 TQDate m_createdNoteDate;
756};
757
758
759class KOTEXT_EXPORT KoStatisticVariable : public KoVariable
760{
761public:
762 KoStatisticVariable( KoTextDocument *textdoc, short int subtype,
763 KoVariableFormat *varFormat,
764 KoVariableCollection *_varColl);
765
766 enum {
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
777 };
778
779 virtual VariableType type() const
780 { return VT_STATISTIC; }
781 static TQStringList actionTexts();
782
783 virtual TQStringList subTypeList();
784
785 virtual void saveVariable( TQDomElement &parentElem );
786 virtual void load( TQDomElement &elem );
787 virtual void loadOasis( const TQDomElement &elem, KoOasisContext& context );
788 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context ) const;
789
790 virtual short int subType() const { return m_subtype; }
791
792 virtual void setVariableSubType( short int subtype );
793
794 TQString name() const { return m_varValue.toString(); }
795 virtual TQString fieldCode();
796
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; }
801protected:
802 short int m_subtype;
803 // extend type for kword.
804 static bool m_extendedType;
805};
806
807
808#endif
A custom variable is a variable whose value is entered by the user.
Definition KoVariable.h:552
Date-related variables.
Definition KoVariable.h:460
virtual void setVariableSubType(short int subtype)
Set this variable's subtype.
Definition KoVariable.h:483
The KOffice document class.
Definition KoDocument.h:61
Any variable that is a string, and whose value is automatically determined - as opposed to custom var...
Definition KoVariable.h:584
virtual void setVariableSubType(short int subtype)
Set this variable's subtype.
Definition KoVariable.h:623
Used during loading of Oasis format (and discarded at the end of the loading).
Parse settings.xml file.
"current page number" and "number of pages" variables This is a base class, it must be inherited by a...
Definition KoVariable.h:662
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...
Time-related variables.
Definition KoVariable.h:505
virtual void setVariableSubType(short int subtype)
Set this variable's subtype.
Definition KoVariable.h:528
Implementation of the "date" formats TODO: merge with KoVariableTimeFormat, for a single TQDateTime-b...
Definition KoVariable.h:170
virtual TQStringList formatPropsList() const
Definition KoVariable.h:186
virtual void setFormatProperties(const TQString &props)
Set the format string (e.g. DDMMYYYY)
Definition KoVariable.h:179
virtual TQString formatProperties() const
Definition KoVariable.h:183
virtual TQStringList translatedFormatPropsList() const
Definition KoVariable.h:189
The collection of formats for variables.
Definition KoVariable.h:263
void clear()
Forget (and erase) all the formats this collection knows about.
Definition KoVariable.h:270
Class: KoVariableFormat Base class for a variable format - held by KWDocument.
Definition KoVariable.h:122
virtual TQCString key() const =0
Return a key describing this format.
virtual TQString formatProperties() const
Definition KoVariable.h:154
virtual TQCString getKey(const TQString &props) const =0
virtual TQString convert(const TQVariant &data) const =0
Use this format to convert a piece of data into a string.
virtual TQStringList formatPropsList() const
Definition KoVariable.h:158
virtual TQStringList translatedFormatPropsList() const
Definition KoVariable.h:162
virtual void setFormatProperties(const TQString &)
Set the properties of this format, e.g.
Definition KoVariable.h:150
virtual void load(const TQCString &key)=0
Create a format from this key.
Implementation of the string format.
Definition KoVariable.h:235
virtual TQCString key() const
Return a key describing this format.
virtual void load(const TQCString &)
Create a format from this key.
Definition KoVariable.h:241
virtual TQString convert(const TQVariant &data) const
Use this format to convert a piece of data into a string.
virtual TQCString getKey(const TQString &props) const
Implementation of the "time" formats.
Definition KoVariable.h:202
virtual void setFormatProperties(const TQString &props)
Set the format string (e.g. hh:mm:ss)
Definition KoVariable.h:211
virtual TQStringList formatPropsList() const
Definition KoVariable.h:218
virtual TQString formatProperties() const
Definition KoVariable.h:215
virtual TQStringList translatedFormatPropsList() const
Definition KoVariable.h:221
A KoVariable is a custom item, i.e.
Definition KoVariable.h:364
TQVariant varValue() const
Return the variable value, as a TQVariant, before format conversion.
Definition KoVariable.h:405
virtual int typeId() const
Part of the KoTextCustomItem interface.
Definition KoVariable.h:424
virtual void saveVariable(TQDomElement &parentElem)=0
Variable should reimplement this to implement saving.
virtual void setVariableSubType(short int)
Set this variable's subtype.
Definition KoVariable.h:430
virtual short int variableSubType(short int menuNumber)
Converts the menuNumber to variable subtype number (VST_x)
Definition KoVariable.h:435
A class for writing out XML (to any TQIODevice), with a special attention on performance.
Definition KoXmlWriter.h:37
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)