Update ooo320-m1
[ooovba.git] / sw / inc / fldbas.hxx
blobf4753a176e7e5f3db2bc6d70119dfa9a7bc848bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fldbas.hxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _FLDBAS_HXX
31 #define _FLDBAS_HXX
33 #ifndef FIELDIDS_ONLY // SWG-Testreader!!
35 #include <i18npool/lang.h>
36 #include <tools/debug.hxx>
37 #include <tools/string.hxx>
38 #include "swdllapi.h"
39 #include <calbck.hxx>
40 #include <com/sun/star/uno/Any.hxx>
42 class SwDoc;
43 class SvStringsDtor;
44 class SvNumberFormatter;
46 #endif // FIELDIDS_ONLY
48 /*--------------------------------------------------------------------
49 Beschreibung: die ID's fuer die Feldtypen
50 --------------------------------------------------------------------*/
52 enum RES_FIELDS
54 // Fuer die alten Dokumente muessen die Field-Which IDS erhalten bleiben !!!!
55 RES_FIELDS_BEGIN,
56 RES_DBFLD = RES_FIELDS_BEGIN,
57 RES_USERFLD,
58 RES_FILENAMEFLD,
59 RES_DBNAMEFLD,
60 RES_DATEFLD,
61 RES_TIMEFLD,
62 RES_PAGENUMBERFLD,
63 RES_AUTHORFLD,
64 RES_CHAPTERFLD,
65 RES_DOCSTATFLD,
66 RES_GETEXPFLD,
67 RES_SETEXPFLD,
68 RES_GETREFFLD,
69 RES_HIDDENTXTFLD,
70 RES_POSTITFLD,
71 RES_FIXDATEFLD,
72 RES_FIXTIMEFLD,
73 RES_REGFLD,
74 RES_VARREGFLD,
75 RES_SETREFFLD,
76 RES_INPUTFLD,
77 RES_MACROFLD,
78 RES_DDEFLD,
79 RES_TABLEFLD,
80 RES_HIDDENPARAFLD,
81 RES_DOCINFOFLD,
82 RES_TEMPLNAMEFLD,
83 RES_DBNEXTSETFLD,
84 RES_DBNUMSETFLD,
85 RES_DBSETNUMBERFLD,
86 RES_EXTUSERFLD,
87 RES_REFPAGESETFLD,
88 RES_REFPAGEGETFLD,
89 RES_INTERNETFLD,
90 RES_JUMPEDITFLD,
91 RES_SCRIPTFLD,
92 RES_DATETIMEFLD,
93 RES_AUTHORITY, //Table of authorities
94 RES_COMBINED_CHARS,
95 RES_DROPDOWN,
96 RES_FIELDS_END
99 /*--------------------------------------------------------------------
100 Beschreibung: Liste der FieldTypes am UI
101 --------------------------------------------------------------------*/
103 enum SwFldTypesEnum
105 TYP_BEGIN,
106 TYP_DATEFLD = TYP_BEGIN, // 0
107 TYP_TIMEFLD,
108 TYP_FILENAMEFLD,
109 TYP_DBNAMEFLD,
110 TYP_CHAPTERFLD,
111 TYP_PAGENUMBERFLD,
112 TYP_DOCSTATFLD,
113 TYP_AUTHORFLD,
114 TYP_SETFLD,
115 TYP_GETFLD,
116 TYP_FORMELFLD, // 10
117 TYP_HIDDENTXTFLD,
118 TYP_SETREFFLD,
119 TYP_GETREFFLD,
120 TYP_DDEFLD,
121 TYP_MACROFLD,
122 TYP_INPUTFLD,
123 TYP_HIDDENPARAFLD,
124 TYP_DOCINFOFLD,
125 TYP_DBFLD,
126 TYP_USERFLD, // 20
127 TYP_POSTITFLD,
128 TYP_TEMPLNAMEFLD,
129 TYP_SEQFLD,
130 TYP_DBNEXTSETFLD,
131 TYP_DBNUMSETFLD,
132 TYP_DBSETNUMBERFLD,
133 TYP_CONDTXTFLD,
134 TYP_NEXTPAGEFLD,
135 TYP_PREVPAGEFLD,
136 TYP_EXTUSERFLD, // 30
137 TYP_FIXDATEFLD,
138 TYP_FIXTIMEFLD,
139 TYP_SETINPFLD,
140 TYP_USRINPFLD,
141 TYP_SETREFPAGEFLD,
142 TYP_GETREFPAGEFLD,
143 TYP_INTERNETFLD,
144 TYP_JUMPEDITFLD,
145 TYP_SCRIPTFLD, // 40
146 TYP_AUTHORITY,
147 TYP_COMBINED_CHARS,
148 TYP_DROPDOWN,
149 TYP_END
153 enum SwFileNameFormat
155 FF_BEGIN,
156 FF_NAME = FF_BEGIN,
157 FF_PATHNAME,
158 FF_PATH,
159 FF_NAME_NOEXT,
160 FF_UI_NAME,
161 FF_UI_RANGE,
162 FF_END,
163 FF_FIXED = 0x8000
166 enum SwVarFormat
168 VVF_CMD = 0x0010, // Kommando anzeigen
169 VVF_INVISIBLE = 0x0040, // unsichtbar
170 VVF_XXP = 0x0400, // 1234%
171 VVF_XX_XXP = 0x0800, // 1.234,56%
172 VVF_CLEAR = 0x000f,
174 // ab hier neue Formate
175 VVF_SYS = 0x2000, //Zahlenformat aus der Systemeinstellung
176 VVF_X = 0x2100, // 1234
177 VVF_X_X = 0x2200, // 1234,5
178 VVF_X_XX = 0x2300, // 1245,56
179 VVF_XX_X = 0x2400, // 1.234,5
180 VVF_XX_XX = 0x2500, // 1.234,56
181 VVF_XX_XXX = 0x2600, // 1.234,567
182 VVF_SYS_CUR = 0x2700, // W???hrungsformat aus der Systemeinstellung
183 VVF_CUR_X = 0x2800, // DM 1234
184 VVF_CUR_XX_XX = 0x2900, // DM 1234,56 DM 1234,00
185 VVF_CUR_XX_X0 = 0x2a00, // DM 1234,56 DM 1234,--
186 VVF_X_CUR = 0x2b00, // 1234 DM
187 VVF_XX_XX_CUR = 0x2c00, // 1234,56 DM 1234,00 DM
188 VVF_XX_X0_CUR = 0x2d00, // 1234,56 DM 1234,-- DM
189 // Kompatibilitaet:
190 VF_CMD = VVF_CMD,
191 VF_INVISIBLE = VVF_INVISIBLE,
192 VF_XXP = VVF_XXP,
193 VF_XX_XXP = VVF_XX_XXP,
194 VF_VISIBLE = VVF_SYS,
195 VF_XX = VVF_X,
196 VF_XX_XX = VVF_XX_XX,
197 VF_XX_XX_CUR = VVF_SYS_CUR,
198 VF_CLEAR = VVF_CLEAR
202 typedef USHORT SwGetSetExpType;
203 namespace nsSwGetSetExpType
205 const SwGetSetExpType GSE_STRING = 0x0001; // String
206 const SwGetSetExpType GSE_EXPR = 0x0002; // Expression
207 const SwGetSetExpType GSE_INP = 0x0004; // InputField
208 const SwGetSetExpType GSE_SEQ = 0x0008; // Sequence
209 const SwGetSetExpType GSE_FORMULA = 0x0010; // Formel
212 typedef USHORT SwExtendedSubType;
213 namespace nsSwExtendedSubType
215 const SwExtendedSubType SUB_CMD = 0x0100; // Kommando anzeigen
216 const SwExtendedSubType SUB_INVISIBLE = 0x0200; // unsichtbar
217 const SwExtendedSubType SUB_OWN_FMT = 0x0400; // SwDBField: Uebernimmt Formatierung nicht
218 // aus Datenbank
221 enum SwInputFieldSubType
223 INP_TXT = 0x01,
224 INP_USR = 0x02,
225 INP_VAR = 0x03
229 enum SwUserType
231 UF_STRING = 0x01,
232 UF_EXPR = 0x02
235 enum SwDateTimeSubType
237 FIXEDFLD = 1,
238 DATEFLD = 2,
239 TIMEFLD = 4
242 #ifndef FIELDIDS_ONLY // SWG-Testreader!!
245 extern USHORT __FAR_DATA aTypeTab[];
247 /*--------------------------------------------------------------------
248 Beschreibung: Allgemeine Tools
249 --------------------------------------------------------------------*/
251 String GetResult(double nVal, sal_uInt32 nNumFmt, USHORT nLang = LANGUAGE_SYSTEM);
252 void SetErrorStr(const String& rStr);
253 //String ExpandDate(const Date& rDate, ULONG nFmt, USHORT nLang);
254 //String ExpandTime(const Time& rTime, ULONG nFmt, USHORT nLang);
255 String FormatNumber(USHORT nNum, sal_uInt32 nFormat);
257 /*--------------------------------------------------------------------
258 Beschreibung: Instanzen von SwFields und Abgeleiteten kommen 0-n mal vor.
259 Zu jeder Klasse SwFields existiert
260 1 Instanz der zugehoerigen Typenklasse
261 Basisklasse aller Feldtypen ist SwFieldType
262 --------------------------------------------------------------------*/
264 DBG_NAMEEX(SwFieldType)
266 class SW_DLLPUBLIC SwFieldType : public SwModify
268 USHORT nWhich;
270 friend void _FinitUI(); // um den Pointer zu loeschen!
271 static SvStringsDtor* pFldNames;
273 static void _GetFldName(); // legt die FldNames an, fldmgr.cxx!
275 protected:
276 // single argument ctors shall be explicit.
277 explicit SwFieldType( USHORT nWhichId );
279 public:
281 #ifndef PRODUCT
282 virtual ~SwFieldType();
283 #endif
284 static const String& GetTypeStr( USHORT nTypeId );
286 // nur in abgeleiteten Klassen
287 virtual const String& GetName() const;
288 virtual SwFieldType* Copy() const = 0;
289 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhich ) const;
290 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhich );
292 USHORT Which() const { return nWhich; }
294 inline void UpdateFlds() const;
297 inline void SwFieldType::UpdateFlds() const
299 ((SwFieldType*)this)->Modify( 0, 0 );
302 /*--------------------------------------------------------------------
303 Beschreibung: Basisklasse aller Felder.
304 Ueber Which wird der Typ des Feldes abgefragt.
305 Ueber Expand() wird der expandierte Inhalt
306 des Feldes in Erfahrung gebracht.
307 --------------------------------------------------------------------*/
309 class SW_DLLPUBLIC SwField
311 USHORT nLang; // Immer ueber SetLanguage aendern!
312 BOOL bIsAutomaticLanguage;
313 sal_uInt32 nFormat;
315 SwFieldType* pType;
317 protected:
318 void SetFormat(sal_uInt32 nSet) {nFormat = nSet;}
320 SwField(SwFieldType* pTyp, sal_uInt32 nFmt = 0, USHORT nLang = LANGUAGE_SYSTEM);
322 public:
323 virtual ~SwField();
325 // Typ feststellen
326 inline SwFieldType* GetTyp() const;
328 // neuen Typ setzen (wird fuer das Kopieren zwischen Dokumenten benutzt)
329 virtual SwFieldType* ChgTyp( SwFieldType* );
331 // Expandierung fuer die Anzeige
332 virtual String Expand() const = 0;
334 // liefert den Namen oder den Inhalt
335 virtual String GetCntnt(BOOL bName = FALSE) const;
336 virtual SwField* Copy() const = 0;
338 // ResId
339 USHORT Which() const
340 #ifdef PRODUCT
341 { return pType->Which(); }
342 #else
343 ; // in fldbas.cxx implementiert
344 #endif
346 // TYP_ID
347 USHORT GetTypeId() const;
348 virtual USHORT GetSubType() const;
349 virtual void SetSubType(USHORT);
351 // Sprache an der Feldposition
352 inline USHORT GetLanguage() const;
353 virtual void SetLanguage(USHORT nLng);
355 // Parameter fuer Dialog und BASIC erfragen
356 inline sal_uInt32 GetFormat() const;
357 virtual const String& GetPar1() const;
358 virtual String GetPar2() const;
360 virtual String GetFormula() const;
362 virtual void ChangeFormat(sal_uInt32 n);
363 virtual void SetPar1(const String& rStr);
364 virtual void SetPar2(const String& rStr);
366 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhichId ) const;
367 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhichId );
368 // hat das Feld eine Action auf dem ClickHandler ? (z.B. INetFelder,..)
369 BOOL HasClickHdl() const;
370 // ist es ein Fix-Feld?
371 BOOL IsFixed() const;
373 BOOL IsAutomaticLanguage() const { return bIsAutomaticLanguage;}
374 void SetAutomaticLanguage(BOOL bSet){bIsAutomaticLanguage = bSet;}
376 virtual String GetDescription() const;
379 inline SwFieldType* SwField::GetTyp() const
380 { return pType; }
382 inline sal_uInt32 SwField::GetFormat() const
383 { return nFormat; }
385 inline USHORT SwField::GetLanguage() const
386 { return nLang; }
388 /*--------------------------------------------------------------------
389 Beschreibung: Felder mit Values, die ueber der Numberformatter
390 formatiert werden muessen
391 --------------------------------------------------------------------*/
393 class SwValueFieldType : public SwFieldType
395 SwDoc* pDoc;
396 BOOL bUseFormat; // Numberformatter verwenden
398 protected:
399 SwValueFieldType( SwDoc* pDocPtr, USHORT nWhichId );
400 SwValueFieldType( const SwValueFieldType& rTyp );
402 public:
403 inline SwDoc* GetDoc() const { return pDoc; }
404 inline void SetDoc(SwDoc* pNewDoc) { pDoc = pNewDoc; }
406 inline BOOL UseFormat() const { return bUseFormat; }
407 inline void EnableFormat(BOOL bFormat = TRUE) { bUseFormat = bFormat; }
409 String ExpandValue(const double& rVal, sal_uInt32 nFmt, USHORT nLng=0) const;
410 void DoubleToString(String &rValue, const double &rVal, LanguageType eLng) const;
411 void DoubleToString(String &rValue, const double &rVal, sal_uInt32 nFmt) const;
414 class SW_DLLPUBLIC SwValueField : public SwField
416 double fValue;
417 // String sExpand;
419 protected:
420 SwValueField( SwValueFieldType* pFldType, sal_uInt32 nFmt = 0, USHORT nLang = LANGUAGE_SYSTEM, const double fVal = 0.0 );
421 SwValueField( const SwValueField& rFld );
423 public:
424 virtual ~SwValueField();
426 virtual SwFieldType* ChgTyp( SwFieldType* );
427 virtual void SetLanguage(USHORT nLng);
428 // os: wozu war das denn da?
429 // virtual void ChangeFormat(ULONG n);
431 inline SwDoc* GetDoc() const { return ((SwValueFieldType*)GetTyp())->GetDoc(); }
433 virtual double GetValue() const;
434 virtual void SetValue( const double& rVal );
436 inline String ExpandValue(const double& rVal, sal_uInt32 nFmt, USHORT nLng=0) const
437 { return ((SwValueFieldType*)GetTyp())->ExpandValue(rVal, nFmt, nLng); }
439 static sal_uInt32 GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFmt);
442 class SW_DLLPUBLIC SwFormulaField : public SwValueField
444 String sFormula;
446 protected:
447 SwFormulaField( SwValueFieldType* pFldType, sal_uInt32 nFmt = 0, const double fVal = 0.0 );
448 SwFormulaField( const SwFormulaField& rFld );
450 public:
451 virtual String GetFormula() const;
452 void SetFormula(const String& rStr);
454 void SetExpandedFormula(const String& rStr);
455 String GetExpandedFormula() const;
458 #endif // FIELDIDS_ONLY
459 #endif // _FLDBAS_HXX