1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SVX_FLDITEM_HXX 28 #define _SVX_FLDITEM_HXX 29 30 #include <i18npool/lang.h> 31 #include <tools/time.hxx> 32 #include <tools/date.hxx> 33 #include <svl/poolitem.hxx> 34 #include <tools/pstm.hxx> 35 #include "editeng/editengdllapi.h" 36 37 class SvNumberFormatter; 38 class MetaAction; 39 40 // class SvxFieldItem --------------------------------------------------- 41 42 43 44 class EDITENG_DLLPUBLIC SvxFieldData : public SvPersistBase 45 { 46 public: 47 SV_DECL_PERSIST1( SvxFieldData, SvPersistBase, 1 ) 48 49 SvxFieldData(); 50 virtual ~SvxFieldData(); 51 52 virtual SvxFieldData* Clone() const; 53 virtual int operator==( const SvxFieldData& ) const; 54 55 virtual MetaAction* createBeginComment() const; 56 virtual MetaAction* createEndComment() const; 57 }; 58 59 /* 60 [Beschreibung] 61 In diesem Item wird ein Feld (SvxFieldData) gespeichert. 62 Das Feld gehoert dem Item. 63 Das Feld selbst wird durch eine Ableitung von SvxFieldData bestimmt. (RTTI) 64 */ 65 66 class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem 67 { 68 private: 69 SvxFieldData* pField; 70 71 EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId ); 72 73 public: 74 TYPEINFO(); 75 76 SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ); 77 SvxFieldItem( const SvxFieldItem& rItem ); 78 ~SvxFieldItem(); 79 80 virtual int operator==( const SfxPoolItem& ) const; 81 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; 82 virtual SfxPoolItem* Create( SvStream&, sal_uInt16 nVer ) const; 83 virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const; 84 85 const SvxFieldData* GetField() const { return pField; } 86 static SvClassManager& GetClassManager(); 87 }; 88 89 // ================================================================= 90 // Es folgen die Ableitungen von SvxFieldData... 91 // ================================================================= 92 93 #define SVX_DATEFIELD 2 94 #define SVX_URLFIELD 3 95 96 #define SVX_PAGEFIELD 100 // Ex-Calc-Felder 97 #define SVX_PAGESFIELD 101 98 #define SVX_TIMEFIELD 102 99 #define SVX_FILEFIELD 103 100 #define SVX_TABLEFIELD 104 101 #define SVX_EXT_TIMEFIELD 105 102 #define SVX_EXT_FILEFIELD 106 103 #define SVX_AUTHORFIELD 107 104 #define SVX_HEADERFIELD 108 105 #define SVX_FOOTERFIELD 109 106 #define SVX_DATEFIMEFIELD 110 107 108 #define SVX_USERFIELD 200 // Ab hier eigene Felder, nicht im SVX 109 110 enum SvxDateType { SVXDATETYPE_FIX, SVXDATETYPE_VAR }; 111 enum SvxDateFormat { SVXDATEFORMAT_APPDEFAULT, // Wie in App eingestellt 112 SVXDATEFORMAT_SYSTEM, // Wie im System eingestellt 113 SVXDATEFORMAT_STDSMALL, 114 SVXDATEFORMAT_STDBIG, 115 SVXDATEFORMAT_A, // 13.02.96 116 SVXDATEFORMAT_B, // 13.02.1996 117 SVXDATEFORMAT_C, // 13.Feb 1996 118 SVXDATEFORMAT_D, // 13.Februar 1996 119 SVXDATEFORMAT_E, // Die, 13.Februar 1996 120 SVXDATEFORMAT_F // Dienstag, 13.Februar 1996 121 }; 122 123 class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData 124 { 125 sal_uInt32 nFixDate; 126 SvxDateType eType; 127 SvxDateFormat eFormat; 128 129 public: 130 SV_DECL_PERSIST1( SvxDateField, SvxFieldData, SVX_DATEFIELD ) 131 132 SvxDateField(); 133 SvxDateField( const Date& rDate, 134 SvxDateType eType = SVXDATETYPE_VAR, 135 SvxDateFormat eFormat = SVXDATEFORMAT_STDSMALL ); 136 137 sal_uInt32 GetFixDate() const { return nFixDate; } 138 void SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); } 139 140 SvxDateType GetType() const { return eType; } 141 void SetType( SvxDateType eTp ) { eType = eTp; } 142 143 SvxDateFormat GetFormat() const { return eFormat; } 144 void SetFormat( SvxDateFormat eFmt ) { eFormat = eFmt; } 145 146 // deprecated, to be removed 147 String GetFormatted( LanguageType eLanguage, LanguageType eFormat ) const; 148 // use this instead 149 // If eLanguage==LANGUAGE_DONTKNOW the language/country 150 // used in number formatter initialization is taken. 151 String GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const; 152 static String GetFormatted( Date& rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage ); 153 154 virtual SvxFieldData* Clone() const; 155 virtual int operator==( const SvxFieldData& ) const; 156 157 virtual MetaAction* createBeginComment() const; 158 }; 159 160 161 enum SvxURLFormat { SVXURLFORMAT_APPDEFAULT, // Wie in App eingestellt 162 SVXURLFORMAT_URL, // URL darstellen 163 SVXURLFORMAT_REPR // Repraesentation darstellen 164 }; 165 166 class EDITENG_DLLPUBLIC SvxURLField : public SvxFieldData 167 { 168 private: 169 SvxURLFormat eFormat; 170 XubString aURL; // URL-Adresse 171 XubString aRepresentation; // Was wird dargestellt 172 XubString aTargetFrame; // In welchem Frame 173 174 public: 175 SV_DECL_PERSIST1( SvxURLField, SvxFieldData, SVX_URLFIELD ) 176 177 SvxURLField(); 178 SvxURLField( const XubString& rURL, const XubString& rRepres, SvxURLFormat eFmt = SVXURLFORMAT_URL ); 179 180 const XubString& GetURL() const { return aURL; } 181 void SetURL( const XubString& rURL ) { aURL = rURL; } 182 183 const XubString& GetRepresentation() const { return aRepresentation; } 184 void SetRepresentation( const XubString& rRep ) { aRepresentation= rRep; } 185 186 const XubString& GetTargetFrame() const { return aTargetFrame; } 187 void SetTargetFrame( const XubString& rFrm ) { aTargetFrame = rFrm; } 188 189 SvxURLFormat GetFormat() const { return eFormat; } 190 void SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; } 191 192 virtual SvxFieldData* Clone() const; 193 virtual int operator==( const SvxFieldData& ) const; 194 195 virtual MetaAction* createBeginComment() const; 196 }; 197 198 class EDITENG_DLLPUBLIC SvxPageField : public SvxFieldData 199 { 200 public: 201 SV_DECL_PERSIST1( SvxPageField, SvxFieldData, SVX_PAGEFIELD ) 202 SvxPageField() {} 203 virtual SvxFieldData* Clone() const; 204 virtual int operator==( const SvxFieldData& ) const; 205 206 virtual MetaAction* createBeginComment() const; 207 }; 208 209 class EDITENG_DLLPUBLIC SvxPagesField : public SvxFieldData 210 { 211 public: 212 SV_DECL_PERSIST1( SvxPagesField, SvxFieldData, SVX_PAGESFIELD ) 213 SvxPagesField() {} 214 virtual SvxFieldData* Clone() const; 215 virtual int operator==( const SvxFieldData& ) const; 216 }; 217 218 class EDITENG_DLLPUBLIC SvxTimeField : public SvxFieldData 219 { 220 public: 221 SV_DECL_PERSIST1( SvxTimeField, SvxFieldData, SVX_TIMEFIELD ) 222 SvxTimeField() {} 223 virtual SvxFieldData* Clone() const; 224 virtual int operator==( const SvxFieldData& ) const; 225 226 virtual MetaAction* createBeginComment() const; 227 }; 228 229 class EDITENG_DLLPUBLIC SvxFileField : public SvxFieldData 230 { 231 public: 232 SV_DECL_PERSIST1( SvxFileField, SvxFieldData, SVX_FILEFIELD ) 233 SvxFileField() {} 234 virtual SvxFieldData* Clone() const; 235 virtual int operator==( const SvxFieldData& ) const; 236 }; 237 238 class EDITENG_DLLPUBLIC SvxTableField : public SvxFieldData 239 { 240 public: 241 SV_DECL_PERSIST1( SvxTableField, SvxFieldData, SVX_TABLEFIELD ) 242 SvxTableField() {} 243 virtual SvxFieldData* Clone() const; 244 virtual int operator==( const SvxFieldData& ) const; 245 }; 246 247 248 enum SvxTimeType { SVXTIMETYPE_FIX, SVXTIMETYPE_VAR }; 249 enum SvxTimeFormat { SVXTIMEFORMAT_APPDEFAULT, // Wie in App eingestellt 250 SVXTIMEFORMAT_SYSTEM, // Wie im System eingestellt 251 SVXTIMEFORMAT_STANDARD, 252 SVXTIMEFORMAT_24_HM, // 13:49 253 SVXTIMEFORMAT_24_HMS, // 13:49:38 254 SVXTIMEFORMAT_24_HMSH, // 13:49:38.78 255 SVXTIMEFORMAT_12_HM, // 01:49 256 SVXTIMEFORMAT_12_HMS, // 01:49:38 257 SVXTIMEFORMAT_12_HMSH, // 01:49:38.78 258 SVXTIMEFORMAT_AM_HM, // 01:49 PM 259 SVXTIMEFORMAT_AM_HMS, // 01:49:38 PM 260 SVXTIMEFORMAT_AM_HMSH // 01:49:38.78 PM 261 }; 262 263 class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData 264 { 265 private: 266 sal_uInt32 nFixTime; 267 SvxTimeType eType; 268 SvxTimeFormat eFormat; 269 270 public: 271 SV_DECL_PERSIST1( SvxExtTimeField, SvxFieldData, SVX_EXT_TIMEFIELD ) 272 SvxExtTimeField(); 273 SvxExtTimeField( const Time& rTime, 274 SvxTimeType eType = SVXTIMETYPE_VAR, 275 SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD ); 276 277 sal_uInt32 GetFixTime() const { return nFixTime; } 278 void SetFixTime( const Time& rTime ) { nFixTime = rTime.GetTime(); } 279 280 SvxTimeType GetType() const { return eType; } 281 void SetType( SvxTimeType eTp ) { eType = eTp; } 282 283 SvxTimeFormat GetFormat() const { return eFormat; } 284 void SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; } 285 286 // deprecated, to be removed 287 XubString GetFormatted( LanguageType eLanguage, LanguageType eFormat ) const; 288 // use this instead 289 // If eLanguage==LANGUAGE_DONTKNOW the language/country 290 // used in number formatter initialization is taken. 291 String GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const; 292 static String GetFormatted( Time& rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage ); 293 294 virtual SvxFieldData* Clone() const; 295 virtual int operator==( const SvxFieldData& ) const; 296 297 virtual MetaAction* createBeginComment() const; 298 }; 299 300 301 enum SvxFileType { SVXFILETYPE_FIX, SVXFILETYPE_VAR }; 302 enum SvxFileFormat { SVXFILEFORMAT_NAME_EXT, // Dateiname mit Extension 303 SVXFILEFORMAT_FULLPATH, // vollst�ndiger Pfad 304 SVXFILEFORMAT_PATH, // nur Pfad 305 SVXFILEFORMAT_NAME // nur Dateiname 306 }; 307 308 309 310 class EDITENG_DLLPUBLIC SvxExtFileField : public SvxFieldData 311 { 312 private: 313 XubString aFile; 314 SvxFileType eType; 315 SvxFileFormat eFormat; 316 317 public: 318 SV_DECL_PERSIST1( SvxExtFileField, SvxFieldData, SVX_EXT_FILEFIELD ) 319 SvxExtFileField(); 320 SvxExtFileField( const XubString& rString, 321 SvxFileType eType = SVXFILETYPE_VAR, 322 SvxFileFormat eFormat = SVXFILEFORMAT_FULLPATH ); 323 324 String GetFile() const { return aFile; } 325 void SetFile( const XubString& rString ) { aFile = rString; } 326 327 SvxFileType GetType() const { return eType; } 328 void SetType( SvxFileType eTp ) { eType = eTp; } 329 330 SvxFileFormat GetFormat() const { return eFormat; } 331 void SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; } 332 333 XubString GetFormatted() const; 334 335 virtual SvxFieldData* Clone() const; 336 virtual int operator==( const SvxFieldData& ) const; 337 }; 338 339 340 enum SvxAuthorType { SVXAUTHORTYPE_FIX, SVXAUTHORTYPE_VAR }; 341 enum SvxAuthorFormat { SVXAUTHORFORMAT_FULLNAME, // vollst�ndiger Name 342 SVXAUTHORFORMAT_NAME, // nur Nachname 343 SVXAUTHORFORMAT_FIRSTNAME, // nur Vorname 344 SVXAUTHORFORMAT_SHORTNAME // Initialen 345 }; 346 347 class EDITENG_DLLPUBLIC SvxAuthorField : public SvxFieldData 348 { 349 private: 350 XubString aName; 351 XubString aFirstName; 352 XubString aShortName; 353 SvxAuthorType eType; 354 SvxAuthorFormat eFormat; 355 356 public: 357 SV_DECL_PERSIST1( SvxAuthorField, SvxFieldData, SVX_AUTHORFIELD ) 358 SvxAuthorField(); 359 SvxAuthorField( 360 const XubString& rFirstName, 361 const XubString& rLastName, 362 const XubString& rShortName, 363 SvxAuthorType eType = SVXAUTHORTYPE_VAR, 364 SvxAuthorFormat eFormat = SVXAUTHORFORMAT_FULLNAME ); 365 366 XubString GetName() const { return aName; } 367 void SetName( const XubString& rString ) { aName = rString; } 368 369 XubString GetFirstName() const { return aFirstName; } 370 void SetFirstName( const XubString& rString ) { aFirstName = rString; } 371 372 XubString GetShortName() const { return aShortName; } 373 void SetShortName( const XubString& rString ) { aShortName = rString; } 374 375 SvxAuthorType GetType() const { return eType; } 376 void SetType( SvxAuthorType eTp ) { eType = eTp; } 377 378 SvxAuthorFormat GetFormat() const { return eFormat; } 379 void SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; } 380 381 XubString GetFormatted() const; 382 383 virtual SvxFieldData* Clone() const; 384 virtual int operator==( const SvxFieldData& ) const; 385 }; 386 387 /** this field is used as a placeholder for a header&footer in impress. The actual 388 value is stored at the page */ 389 class EDITENG_DLLPUBLIC SvxHeaderField : public SvxFieldData 390 { 391 public: 392 SV_DECL_PERSIST1( SvxHeaderField, SvxFieldData, SVX_HEADERFIELD ) 393 SvxHeaderField() {} 394 virtual SvxFieldData* Clone() const; 395 virtual int operator==( const SvxFieldData& ) const; 396 }; 397 398 /** this field is used as a placeholder for a header&footer in impress. The actual 399 value is stored at the page */ 400 class EDITENG_DLLPUBLIC SvxFooterField : public SvxFieldData 401 { 402 public: 403 SV_DECL_PERSIST1( SvxFooterField, SvxFieldData, SVX_FOOTERFIELD ) 404 SvxFooterField() {} 405 virtual SvxFieldData* Clone() const; 406 virtual int operator==( const SvxFieldData& ) const; 407 }; 408 409 /** this field is used as a placeholder for a header&footer in impress. The actual 410 value is stored at the page */ 411 class EDITENG_DLLPUBLIC SvxDateTimeField : public SvxFieldData 412 { 413 public: 414 SV_DECL_PERSIST1( SvxDateTimeField, SvxFieldData, SVX_DATEFIMEFIELD ) 415 SvxDateTimeField() {} 416 417 static String GetFormatted( Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage ); 418 419 virtual SvxFieldData* Clone() const; 420 virtual int operator==( const SvxFieldData& ) const; 421 }; 422 423 424 425 426 #endif 427 428