1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fldbas.hxx,v $
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 ************************************************************************/
33 #ifndef FIELDIDS_ONLY // SWG-Testreader!!
35 #include <i18npool/lang.h>
36 #include <tools/debug.hxx>
37 #include <tools/string.hxx>
40 #include <com/sun/star/uno/Any.hxx>
44 class SvNumberFormatter
;
46 #endif // FIELDIDS_ONLY
48 /*--------------------------------------------------------------------
49 Beschreibung: die ID's fuer die Feldtypen
50 --------------------------------------------------------------------*/
54 // Fuer die alten Dokumente muessen die Field-Which IDS erhalten bleiben !!!!
56 RES_DBFLD
= RES_FIELDS_BEGIN
,
93 RES_AUTHORITY
, //Table of authorities
99 /*--------------------------------------------------------------------
100 Beschreibung: Liste der FieldTypes am UI
101 --------------------------------------------------------------------*/
106 TYP_DATEFLD
= TYP_BEGIN
, // 0
136 TYP_EXTUSERFLD
, // 30
153 enum SwFileNameFormat
168 VVF_CMD
= 0x0010, // Kommando anzeigen
169 VVF_INVISIBLE
= 0x0040, // unsichtbar
170 VVF_XXP
= 0x0400, // 1234%
171 VVF_XX_XXP
= 0x0800, // 1.234,56%
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
191 VF_INVISIBLE
= VVF_INVISIBLE
,
193 VF_XX_XXP
= VVF_XX_XXP
,
194 VF_VISIBLE
= VVF_SYS
,
196 VF_XX_XX
= VVF_XX_XX
,
197 VF_XX_XX_CUR
= VVF_SYS_CUR
,
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
221 enum SwInputFieldSubType
235 enum SwDateTimeSubType
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
270 friend void _FinitUI(); // um den Pointer zu loeschen!
271 static SvStringsDtor
* pFldNames
;
273 static void _GetFldName(); // legt die FldNames an, fldmgr.cxx!
276 // single argument ctors shall be explicit.
277 explicit SwFieldType( USHORT nWhichId
);
282 virtual ~SwFieldType();
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
;
318 void SetFormat(sal_uInt32 nSet
) {nFormat
= nSet
;}
320 SwField(SwFieldType
* pTyp
, sal_uInt32 nFmt
= 0, USHORT nLang
= LANGUAGE_SYSTEM
);
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;
341 { return pType
->Which(); }
343 ; // in fldbas.cxx implementiert
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
382 inline sal_uInt32
SwField::GetFormat() const
385 inline USHORT
SwField::GetLanguage() const
388 /*--------------------------------------------------------------------
389 Beschreibung: Felder mit Values, die ueber der Numberformatter
390 formatiert werden muessen
391 --------------------------------------------------------------------*/
393 class SwValueFieldType
: public SwFieldType
396 BOOL bUseFormat
; // Numberformatter verwenden
399 SwValueFieldType( SwDoc
* pDocPtr
, USHORT nWhichId
);
400 SwValueFieldType( const SwValueFieldType
& rTyp
);
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
420 SwValueField( SwValueFieldType
* pFldType
, sal_uInt32 nFmt
= 0, USHORT nLang
= LANGUAGE_SYSTEM
, const double fVal
= 0.0 );
421 SwValueField( const SwValueField
& rFld
);
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
447 SwFormulaField( SwValueFieldType
* pFldType
, sal_uInt32 nFmt
= 0, const double fVal
= 0.0 );
448 SwFormulaField( const SwFormulaField
& rFld
);
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