merge the formfield patch from ooo-build
[ooovba.git] / binfilter / inc / bf_sw / fldbas.hxx
bloba6ac2562ca13f156bcc28f6d6aa183ef9b12b730
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.11 $
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 #ifndef INCLUDED_I18NPOOL_LANG_H
36 #include <i18npool/lang.h>
37 #endif
38 #ifndef _DEBUG_HXX //autogen
39 #include <tools/debug.hxx>
40 #endif
41 #ifndef _STRING_HXX //autogen
42 #include <tools/string.hxx>
43 #endif
44 #ifndef _CALBCK_HXX
45 #include <calbck.hxx>
46 #endif
48 #ifndef _COM_SUN_STAR_UNO_ANY_HXX_
49 #include <com/sun/star/uno/Any.hxx>
50 #endif
51 class Date;
52 class Time;
54 namespace binfilter {
56 class SvStringsDtor;
57 class SvNumberFormatter;
58 class SwDoc;
59 class _SetGetExpFlds;
60 class SwEditShell;
61 } //namespace binfilter
62 #endif // FIELDIDS_ONLY
64 /*--------------------------------------------------------------------
65 Beschreibung: die ID's fuer die Feldtypen
66 --------------------------------------------------------------------*/
67 namespace binfilter {//STRIP009
68 enum RES_FIELDS
70 // Fuer die alten Dokumente muessen die Field-Which IDS erhalten bleiben !!!!
71 RES_FIELDS_BEGIN,
72 RES_DBFLD = RES_FIELDS_BEGIN,
73 RES_USERFLD,
74 RES_FILENAMEFLD,
75 RES_DBNAMEFLD,
76 RES_DATEFLD,
77 RES_TIMEFLD,
78 RES_PAGENUMBERFLD,
79 RES_AUTHORFLD,
80 RES_CHAPTERFLD,
81 RES_DOCSTATFLD,
82 RES_GETEXPFLD,
83 RES_SETEXPFLD,
84 RES_GETREFFLD,
85 RES_HIDDENTXTFLD,
86 RES_POSTITFLD,
87 RES_FIXDATEFLD,
88 RES_FIXTIMEFLD,
89 RES_REGFLD,
90 RES_VARREGFLD,
91 RES_SETREFFLD,
92 RES_INPUTFLD,
93 RES_MACROFLD,
94 RES_DDEFLD,
95 RES_TABLEFLD,
96 RES_HIDDENPARAFLD,
97 RES_DOCINFOFLD,
98 RES_TEMPLNAMEFLD,
99 RES_DBNEXTSETFLD,
100 RES_DBNUMSETFLD,
101 RES_DBSETNUMBERFLD,
102 RES_EXTUSERFLD,
103 RES_REFPAGESETFLD,
104 RES_REFPAGEGETFLD,
105 RES_INTERNETFLD,
106 RES_JUMPEDITFLD,
107 RES_SCRIPTFLD,
108 RES_DATETIMEFLD,
109 RES_AUTHORITY, //Table of authorities
110 RES_COMBINED_CHARS,
111 RES_DROPDOWN,
112 RES_FIELDS_END
115 /*--------------------------------------------------------------------
116 Beschreibung: Liste der FieldTypes am UI
117 --------------------------------------------------------------------*/
119 enum SwFldTypesEnum
121 TYP_BEGIN,
122 TYP_DATEFLD = TYP_BEGIN, // 0
123 TYP_TIMEFLD,
124 TYP_FILENAMEFLD,
125 TYP_DBNAMEFLD,
126 TYP_CHAPTERFLD,
127 TYP_PAGENUMBERFLD,
128 TYP_DOCSTATFLD,
129 TYP_AUTHORFLD,
130 TYP_SETFLD,
131 TYP_GETFLD,
132 TYP_FORMELFLD, // 10
133 TYP_HIDDENTXTFLD,
134 TYP_SETREFFLD,
135 TYP_GETREFFLD,
136 TYP_DDEFLD,
137 TYP_MACROFLD,
138 TYP_INPUTFLD,
139 TYP_HIDDENPARAFLD,
140 TYP_DOCINFOFLD,
141 TYP_DBFLD,
142 TYP_USERFLD, // 20
143 TYP_POSTITFLD,
144 TYP_TEMPLNAMEFLD,
145 TYP_SEQFLD,
146 TYP_DBNEXTSETFLD,
147 TYP_DBNUMSETFLD,
148 TYP_DBSETNUMBERFLD,
149 TYP_CONDTXTFLD,
150 TYP_NEXTPAGEFLD,
151 TYP_PREVPAGEFLD,
152 TYP_EXTUSERFLD, // 30
153 TYP_FIXDATEFLD,
154 TYP_FIXTIMEFLD,
155 TYP_SETINPFLD,
156 TYP_USRINPFLD,
157 TYP_SETREFPAGEFLD,
158 TYP_GETREFPAGEFLD,
159 TYP_INTERNETFLD,
160 TYP_JUMPEDITFLD,
161 TYP_SCRIPTFLD, // 40
162 TYP_AUTHORITY,
163 TYP_COMBINED_CHARS,
164 TYP_DROPDOWN,
165 TYP_END
169 enum SwFileNameFormat
171 FF_BEGIN,
172 FF_NAME = FF_BEGIN,
173 FF_PATHNAME,
174 FF_PATH,
175 FF_NAME_NOEXT,
176 FF_UI_NAME,
177 FF_UI_RANGE,
178 FF_END,
179 FF_FIXED = 0x8000
182 enum SwVarFormat
184 VVF_CMD = 0x0010, // Kommando anzeigen
185 VVF_INVISIBLE = 0x0040, // unsichtbar
186 VVF_XXP = 0x0400, // 1234%
187 VVF_XX_XXP = 0x0800, // 1.234,56%
188 VVF_CLEAR = 0x000f,
190 // ab hier neue Formate
191 VVF_SYS = 0x2000, //Zahlenformat aus der Systemeinstellung
192 VVF_X = 0x2100, // 1234
193 VVF_X_X = 0x2200, // 1234,5
194 VVF_X_XX = 0x2300, // 1245,56
195 VVF_XX_X = 0x2400, // 1.234,5
196 VVF_XX_XX = 0x2500, // 1.234,56
197 VVF_XX_XXX = 0x2600, // 1.234,567
198 VVF_SYS_CUR = 0x2700, // Wā€˛hrungsformat aus der Systemeinstellung
199 VVF_CUR_X = 0x2800, // DM 1234
200 VVF_CUR_XX_XX = 0x2900, // DM 1234,56 DM 1234,00
201 VVF_CUR_XX_X0 = 0x2a00, // DM 1234,56 DM 1234,--
202 VVF_X_CUR = 0x2b00, // 1234 DM
203 VVF_XX_XX_CUR = 0x2c00, // 1234,56 DM 1234,00 DM
204 VVF_XX_X0_CUR = 0x2d00, // 1234,56 DM 1234,-- DM
205 // Kompatibilitaet:
206 VF_CMD = VVF_CMD,
207 VF_INVISIBLE = VVF_INVISIBLE,
208 VF_XXP = VVF_XXP,
209 VF_XX_XXP = VVF_XX_XXP,
210 VF_VISIBLE = VVF_SYS,
211 VF_XX = VVF_X,
212 VF_XX_XX = VVF_XX_XX,
213 VF_XX_XX_CUR = VVF_SYS_CUR,
214 VF_CLEAR = VVF_CLEAR
218 enum SwGetSetExpType
220 GSE_STRING = 0x0001, // String
221 GSE_EXPR = 0x0002, // Expression
222 GSE_INP = 0x0004, // InputField
223 GSE_SEQ = 0x0008, // Sequence
224 GSE_FORMULA = 0x0010 // Formel
227 enum SwExtendedSubType
229 SUB_CMD = 0x0100, // Kommando anzeigen
230 SUB_INVISIBLE = 0x0200, // unsichtbar
231 SUB_OWN_FMT = 0x0400 // SwDBField: Uebernimmt Formatierung nicht
232 // aus Datenbank
235 enum SwInputFieldSubType
237 INP_TXT = 0x01,
238 INP_USR = 0x02,
239 INP_VAR = 0x03
243 enum SwUserType
245 UF_STRING = 0x01,
246 UF_EXPR = 0x02
249 enum SwDateTimeSubType
251 FIXEDFLD = 1,
252 DATEFLD = 2,
253 TIMEFLD = 4
256 #ifndef FIELDIDS_ONLY // SWG-Testreader!!
259 extern USHORT __FAR_DATA aTypeTab[];
261 /*--------------------------------------------------------------------
262 Beschreibung: Allgemeine Tools
263 --------------------------------------------------------------------*/
265 String GetResult(double nVal, sal_uInt32 nNumFmt, USHORT nLang = LANGUAGE_SYSTEM);
266 void SetErrorStr(const String& rStr);
267 //String ExpandDate(const Date& rDate, ULONG nFmt, USHORT nLang);
268 //String ExpandTime(const Time& rTime, ULONG nFmt, USHORT nLang);
269 String FormatNumber(USHORT nNum, sal_uInt32 nFormat);
271 /*--------------------------------------------------------------------
272 Beschreibung: Instanzen von SwFields und Abgeleiteten kommen 0-n mal vor.
273 Zu jeder Klasse SwFields existiert
274 1 Instanz der zugehoerigen Typenklasse
275 Basisklasse aller Feldtypen ist SwFieldType
276 --------------------------------------------------------------------*/
277 class SwFldNames;
279 DBG_NAMEEX(SwFieldType)//STRIP008
281 class SwFieldType : public SwModify
283 USHORT nWhich;
285 friend void _FinitUI(); // um den Pointer zu loeschen!
286 static SvStringsDtor* pFldNames;
288 static void _GetFldName(); // legt die FldNames an, fldmgr.cxx!
289 protected:
290 SwFieldType( USHORT nWhichId );
292 public:
294 #ifndef PRODUCT
295 virtual ~SwFieldType();
296 #endif
297 static const String& GetTypeStr( USHORT nTypeId );
299 // nur in abgeleiteten Klassen
300 virtual const String& GetName() const;
301 virtual SwFieldType* Copy() const = 0;
302 virtual BOOL QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMId ) const{DBG_BF_ASSERT(0, "STRIP"); return NULL;} //STRIP001 virtual BOOL QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMId ) const;
303 virtual BOOL PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMId ){DBG_BF_ASSERT(0, "STRIP"); return NULL;} //STRIP001 virtual BOOL PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMId );
305 USHORT Which() const { return nWhich; }
307 inline void UpdateFlds() const;
309 static inline SvStringsDtor* GetFldNames();
312 inline void SwFieldType::UpdateFlds() const
314 ((SwFieldType*)this)->Modify( 0, 0 );
317 /*--------------------------------------------------------------------
318 Beschreibung: Basisklasse aller Felder.
319 Ueber Which wird der Typ des Feldes abgefragt.
320 Ueber Expand() wird der expandierte Inhalt
321 des Feldes in Erfahrung gebracht.
322 --------------------------------------------------------------------*/
324 class SwField
326 USHORT nLang; // Immer ueber SetLanguage aendern!
327 BOOL bIsAutomaticLanguage;
328 sal_uInt32 nFormat;
330 SwFieldType* pType;
331 protected:
332 void SetFormat(sal_uInt32 nSet) {nFormat = nSet;}
334 SwField(SwFieldType* pTyp, sal_uInt32 nFmt = 0, USHORT nLang = LANGUAGE_SYSTEM);
335 public:
336 virtual ~SwField();
338 // Typ feststellen
339 inline SwFieldType* GetTyp() const;
341 // neuen Typ setzen (wird fuer das Kopieren zwischen Dokumenten benutzt)
342 virtual SwFieldType* ChgTyp( SwFieldType* );
344 // Expandierung fuer die Anzeige
345 virtual String Expand() const = 0;
347 // liefert den Namen oder den Inhalt
348 virtual String GetCntnt(BOOL bName = FALSE) const;
349 virtual SwField* Copy() const = 0;
351 // ResId
352 USHORT Which() const
353 #ifdef PRODUCT
354 { return pType->Which(); }
355 #else
356 ; // in fldbas.cxx implementiert
357 #endif
359 // TYP_ID
360 virtual USHORT GetSubType() const;
361 virtual void SetSubType(USHORT);
363 // Sprache an der Feldposition
364 inline USHORT GetLanguage() const;
365 virtual void SetLanguage(USHORT nLng);
367 // Parameter fuer Dialog und BASIC erfragen
368 inline sal_uInt32 GetFormat() const;
369 virtual const String& GetPar1() const;
370 virtual String GetPar2() const;
372 virtual String GetFormula() const;
374 virtual void ChangeFormat(sal_uInt32 n);
375 virtual void SetPar1(const String& rStr);
376 virtual void SetPar2(const String& rStr);
378 virtual BOOL QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMId ) const;
379 virtual BOOL PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMId );
380 // hat das Feld eine Action auf dem ClickHandler ? (z.B. INetFelder,..)
381 // ist es ein Fix-Feld?
382 FASTBOOL IsFixed() const;
384 BOOL IsAutomaticLanguage() const { return bIsAutomaticLanguage;}
385 void SetAutomaticLanguage(BOOL bSet){bIsAutomaticLanguage = bSet;}
388 inline SwFieldType* SwField::GetTyp() const
389 { return pType; }
391 inline sal_uInt32 SwField::GetFormat() const
392 { return nFormat; }
394 inline USHORT SwField::GetLanguage() const
395 { return nLang; }
397 /*--------------------------------------------------------------------
398 Beschreibung: Felder mit Values, die ueber der Numberformatter
399 formatiert werden muessen
400 --------------------------------------------------------------------*/
402 class SwValueFieldType : public SwFieldType
404 SwDoc* pDoc;
405 BOOL bUseFormat; // Numberformatter verwenden
407 protected:
408 SwValueFieldType( SwDoc* pDocPtr, USHORT nWhichId );
410 public:
411 inline SwDoc* GetDoc() const { return pDoc; }
412 inline void SetDoc(SwDoc* pNewDoc) { pDoc = pNewDoc; }
414 inline BOOL UseFormat() const { return bUseFormat; }
415 inline void EnableFormat(BOOL bFormat = TRUE) { bUseFormat = bFormat; }
417 String ExpandValue(const double& rVal, sal_uInt32 nFmt, USHORT nLng=0) const;
418 void DoubleToString(String &rValue, const double &rVal, LanguageType eLng) const;
421 class SwValueField : public SwField
423 double fValue;
424 // String sExpand;
426 protected:
427 SwValueField( SwValueFieldType* pFldType, sal_uInt32 nFmt = 0, USHORT nLang = LANGUAGE_SYSTEM, const double fVal = 0.0 );
429 public:
430 virtual ~SwValueField();
432 virtual SwFieldType* ChgTyp( SwFieldType* );
433 virtual void SetLanguage(USHORT nLng);
434 // os: wozu war das denn da?
435 // virtual void ChangeFormat(ULONG n);
437 inline SwDoc* GetDoc() const { return ((SwValueFieldType*)GetTyp())->GetDoc(); }
439 virtual double GetValue() const;
440 virtual void SetValue( const double& rVal );
442 inline String ExpandValue(const double& rVal, sal_uInt32 nFmt, USHORT nLng=0) const
443 { return ((SwValueFieldType*)GetTyp())->ExpandValue(rVal, nFmt, nLng); }
447 class SwFormulaField : public SwValueField
449 String sFormula;
451 protected:
452 SwFormulaField( SwValueFieldType* pFldType, sal_uInt32 nFmt = 0, const double fVal = 0.0 );
454 public:
455 virtual String GetFormula() const;
456 void SetFormula(const String& rStr);
458 void SetExpandedFormula(const String& rStr);
459 String GetExpandedFormula() const;
464 /*--------------------------------------------------------------------
465 Beschreibung: Sortierung von Felder nach der Position
466 --------------------------------------------------------------------*/
468 inline SvStringsDtor* SwFieldType::GetFldNames()
470 if( !SwFieldType::pFldNames )
471 SwFieldType::_GetFldName();
472 return SwFieldType::pFldNames;
475 #endif // FIELDIDS_ONLY
478 } //namespace binfilter
479 #endif // _FLDBAS_HXX