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 #ifndef INCLUDED_I18NPOOL_LANG_H
36 #include <i18npool/lang.h>
38 #ifndef _DEBUG_HXX //autogen
39 #include <tools/debug.hxx>
41 #ifndef _STRING_HXX //autogen
42 #include <tools/string.hxx>
48 #ifndef _COM_SUN_STAR_UNO_ANY_HXX_
49 #include <com/sun/star/uno/Any.hxx>
57 class SvNumberFormatter
;
61 } //namespace binfilter
62 #endif // FIELDIDS_ONLY
64 /*--------------------------------------------------------------------
65 Beschreibung: die ID's fuer die Feldtypen
66 --------------------------------------------------------------------*/
67 namespace binfilter
{//STRIP009
70 // Fuer die alten Dokumente muessen die Field-Which IDS erhalten bleiben !!!!
72 RES_DBFLD
= RES_FIELDS_BEGIN
,
109 RES_AUTHORITY
, //Table of authorities
115 /*--------------------------------------------------------------------
116 Beschreibung: Liste der FieldTypes am UI
117 --------------------------------------------------------------------*/
122 TYP_DATEFLD
= TYP_BEGIN
, // 0
152 TYP_EXTUSERFLD
, // 30
169 enum SwFileNameFormat
184 VVF_CMD
= 0x0010, // Kommando anzeigen
185 VVF_INVISIBLE
= 0x0040, // unsichtbar
186 VVF_XXP
= 0x0400, // 1234%
187 VVF_XX_XXP
= 0x0800, // 1.234,56%
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
207 VF_INVISIBLE
= VVF_INVISIBLE
,
209 VF_XX_XXP
= VVF_XX_XXP
,
210 VF_VISIBLE
= VVF_SYS
,
212 VF_XX_XX
= VVF_XX_XX
,
213 VF_XX_XX_CUR
= VVF_SYS_CUR
,
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
235 enum SwInputFieldSubType
249 enum SwDateTimeSubType
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 --------------------------------------------------------------------*/
279 DBG_NAMEEX(SwFieldType
)//STRIP008
281 class SwFieldType
: public SwModify
285 friend void _FinitUI(); // um den Pointer zu loeschen!
286 static SvStringsDtor
* pFldNames
;
288 static void _GetFldName(); // legt die FldNames an, fldmgr.cxx!
290 SwFieldType( USHORT nWhichId
);
295 virtual ~SwFieldType();
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 --------------------------------------------------------------------*/
326 USHORT nLang
; // Immer ueber SetLanguage aendern!
327 BOOL bIsAutomaticLanguage
;
332 void SetFormat(sal_uInt32 nSet
) {nFormat
= nSet
;}
334 SwField(SwFieldType
* pTyp
, sal_uInt32 nFmt
= 0, USHORT nLang
= LANGUAGE_SYSTEM
);
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;
354 { return pType
->Which(); }
356 ; // in fldbas.cxx implementiert
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
391 inline sal_uInt32
SwField::GetFormat() const
394 inline USHORT
SwField::GetLanguage() const
397 /*--------------------------------------------------------------------
398 Beschreibung: Felder mit Values, die ueber der Numberformatter
399 formatiert werden muessen
400 --------------------------------------------------------------------*/
402 class SwValueFieldType
: public SwFieldType
405 BOOL bUseFormat
; // Numberformatter verwenden
408 SwValueFieldType( SwDoc
* pDocPtr
, USHORT nWhichId
);
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
427 SwValueField( SwValueFieldType
* pFldType
, sal_uInt32 nFmt
= 0, USHORT nLang
= LANGUAGE_SYSTEM
, const double fVal
= 0.0 );
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
452 SwFormulaField( SwValueFieldType
* pFldType
, sal_uInt32 nFmt
= 0, const double fVal
= 0.0 );
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