update credits
[LibreOffice.git] / include / editeng / flditem.hxx
blob7cf8df232c3c9cfe54ddc8042d65a00a9c337040
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _SVX_FLDITEM_HXX
20 #define _SVX_FLDITEM_HXX
22 #include <i18nlangtag/lang.h>
23 #include <tools/time.hxx>
24 #include <tools/date.hxx>
25 #include <svl/poolitem.hxx>
26 #include <tools/pstm.hxx>
27 #include "editeng/editengdllapi.h"
29 #include <com/sun/star/text/textfield/Type.hpp>
31 #include <boost/noncopyable.hpp>
33 namespace com { namespace sun { namespace star { namespace text {
35 class XTextContent;
37 }}}}
39 class SvNumberFormatter;
40 class MetaAction;
42 // class SvxFieldItem ---------------------------------------------------
46 class EDITENG_DLLPUBLIC SvxFieldData : public SvPersistBase
48 public:
49 static const sal_Int32 UNKNOWN_FIELD;
51 static SvxFieldData* Create(const com::sun::star::uno::Reference<com::sun::star::text::XTextContent>& xContent);
53 SV_DECL_PERSIST1( SvxFieldData, SvPersistBase, com::sun::star::text::textfield::Type::UNSPECIFIED)
55 SvxFieldData();
56 virtual ~SvxFieldData();
58 virtual SvxFieldData* Clone() const;
59 virtual int operator==( const SvxFieldData& ) const;
61 virtual MetaAction* createBeginComment() const;
62 virtual MetaAction* createEndComment() const;
65 /**
66 * This item stores a field (SvxFieldData). The field is controlled by or
67 * belongs to the item. The field itself is determined by a derivation from
68 * SvxFieldData (RTTI)
70 class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem
72 private:
73 SvxFieldData* pField;
75 EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId );
77 public:
78 TYPEINFO();
80 SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId );
81 SvxFieldItem( const SvxFieldItem& rItem );
82 ~SvxFieldItem();
84 virtual int operator==( const SfxPoolItem& ) const;
85 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
86 virtual SfxPoolItem* Create( SvStream&, sal_uInt16 nVer ) const;
87 virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const;
89 const SvxFieldData* GetField() const { return pField; }
90 static SvClassManager& GetClassManager();
93 // =================================================================
94 // The following are the derivatives of SvxFieldData ...
95 // =================================================================
97 enum SvxDateType { SVXDATETYPE_FIX, SVXDATETYPE_VAR };
98 enum SvxDateFormat { SVXDATEFORMAT_APPDEFAULT = 0, // Set as in App
99 SVXDATEFORMAT_SYSTEM, // Set as in System
100 SVXDATEFORMAT_STDSMALL,
101 SVXDATEFORMAT_STDBIG,
102 SVXDATEFORMAT_A, // 13.02.96
103 SVXDATEFORMAT_B, // 13.02.1996
104 SVXDATEFORMAT_C, // 13.Feb 1996
105 SVXDATEFORMAT_D, // 13.February 1996
106 SVXDATEFORMAT_E, // Tue, 13.February 1996
107 SVXDATEFORMAT_F // Tuesday, 13.February 1996
110 class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
112 sal_uInt32 nFixDate;
113 SvxDateType eType;
114 SvxDateFormat eFormat;
116 public:
117 SV_DECL_PERSIST1( SvxDateField, SvxFieldData, com::sun::star::text::textfield::Type::DATE )
119 SvxDateField();
120 explicit SvxDateField( const Date& rDate,
121 SvxDateType eType = SVXDATETYPE_VAR,
122 SvxDateFormat eFormat = SVXDATEFORMAT_STDSMALL );
124 sal_uInt32 GetFixDate() const { return nFixDate; }
125 void SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); }
127 SvxDateType GetType() const { return eType; }
128 void SetType( SvxDateType eTp ) { eType = eTp; }
130 SvxDateFormat GetFormat() const { return eFormat; }
131 void SetFormat( SvxDateFormat eFmt ) { eFormat = eFmt; }
133 // If eLanguage==LANGUAGE_DONTKNOW the language/country
134 // used in number formatter initialization is taken.
135 OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
136 static OUString GetFormatted( Date& rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
138 virtual SvxFieldData* Clone() const;
139 virtual int operator==( const SvxFieldData& ) const;
141 virtual MetaAction* createBeginComment() const;
145 enum SvxURLFormat { SVXURLFORMAT_APPDEFAULT = 0, // Set as in App
146 SVXURLFORMAT_URL, // Represent URL
147 SVXURLFORMAT_REPR // Constitute repraesentation
150 class EDITENG_DLLPUBLIC SvxURLField : public SvxFieldData
152 private:
153 SvxURLFormat eFormat;
154 OUString aURL; // URL-Address
155 OUString aRepresentation; // What is shown
156 OUString aTargetFrame; // In what Frame
158 public:
159 SV_DECL_PERSIST1( SvxURLField, SvxFieldData, com::sun::star::text::textfield::Type::URL )
161 SvxURLField();
162 SvxURLField( const OUString& rURL, const OUString& rRepres, SvxURLFormat eFmt = SVXURLFORMAT_URL );
164 const OUString& GetURL() const { return aURL; }
165 void SetURL( const OUString& rURL ) { aURL = rURL; }
167 const OUString& GetRepresentation() const { return aRepresentation; }
168 void SetRepresentation( const OUString& rRep ) { aRepresentation= rRep; }
170 const OUString& GetTargetFrame() const { return aTargetFrame; }
171 void SetTargetFrame( const OUString& rFrm ) { aTargetFrame = rFrm; }
173 SvxURLFormat GetFormat() const { return eFormat; }
174 void SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
176 virtual SvxFieldData* Clone() const;
177 virtual int operator==( const SvxFieldData& ) const;
179 virtual MetaAction* createBeginComment() const;
182 class EDITENG_DLLPUBLIC SvxPageField : public SvxFieldData
184 public:
185 SV_DECL_PERSIST1( SvxPageField, SvxFieldData, com::sun::star::text::textfield::Type::PAGE )
186 SvxPageField();
188 virtual SvxFieldData* Clone() const;
189 virtual int operator==( const SvxFieldData& ) const;
191 virtual MetaAction* createBeginComment() const;
194 class EDITENG_DLLPUBLIC SvxPagesField : public SvxFieldData
196 public:
197 SV_DECL_PERSIST1( SvxPagesField, SvxFieldData, com::sun::star::text::textfield::Type::PAGES )
198 SvxPagesField();
200 virtual SvxFieldData* Clone() const;
201 virtual int operator==( const SvxFieldData& ) const;
204 class EDITENG_DLLPUBLIC SvxTimeField : public SvxFieldData
206 public:
207 SV_DECL_PERSIST1( SvxTimeField, SvxFieldData, com::sun::star::text::textfield::Type::TIME )
208 SvxTimeField();
210 virtual SvxFieldData* Clone() const;
211 virtual int operator==( const SvxFieldData& ) const;
213 virtual MetaAction* createBeginComment() const;
216 class EDITENG_DLLPUBLIC SvxFileField : public SvxFieldData
218 public:
219 SV_DECL_PERSIST1( SvxFileField, SvxFieldData, com::sun::star::text::textfield::Type::DOCINFO_TITLE )
220 SvxFileField();
222 virtual SvxFieldData* Clone() const;
223 virtual int operator==( const SvxFieldData& ) const;
226 class EDITENG_DLLPUBLIC SvxTableField : public SvxFieldData
228 int mnTab;
229 public:
230 SV_DECL_PERSIST1( SvxTableField, SvxFieldData, com::sun::star::text::textfield::Type::TABLE )
231 SvxTableField();
232 explicit SvxTableField(int nTab);
234 void SetTab(int nTab);
235 int GetTab() const;
237 virtual SvxFieldData* Clone() const;
238 virtual int operator==( const SvxFieldData& ) const;
242 enum SvxTimeType { SVXTIMETYPE_FIX, SVXTIMETYPE_VAR };
243 enum SvxTimeFormat { SVXTIMEFORMAT_APPDEFAULT = 0, // Set as in App
244 SVXTIMEFORMAT_SYSTEM, // Set as in System
245 SVXTIMEFORMAT_STANDARD,
246 SVXTIMEFORMAT_24_HM, // 13:49
247 SVXTIMEFORMAT_24_HMS, // 13:49:38
248 SVXTIMEFORMAT_24_HMSH, // 13:49:38.78
249 SVXTIMEFORMAT_12_HM, // 01:49
250 SVXTIMEFORMAT_12_HMS, // 01:49:38
251 SVXTIMEFORMAT_12_HMSH, // 01:49:38.78
252 SVXTIMEFORMAT_AM_HM, // 01:49 PM
253 SVXTIMEFORMAT_AM_HMS, // 01:49:38 PM
254 SVXTIMEFORMAT_AM_HMSH // 01:49:38.78 PM
257 class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData
259 private:
260 sal_Int64 m_nFixTime;
261 SvxTimeType eType;
262 SvxTimeFormat eFormat;
264 public:
265 SV_DECL_PERSIST1( SvxExtTimeField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_TIME )
266 SvxExtTimeField();
267 explicit SvxExtTimeField( const Time& rTime,
268 SvxTimeType eType = SVXTIMETYPE_VAR,
269 SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD );
271 sal_Int64 GetFixTime() const { return m_nFixTime; }
272 void SetFixTime( const Time& rTime ) { m_nFixTime = rTime.GetTime(); }
274 SvxTimeType GetType() const { return eType; }
275 void SetType( SvxTimeType eTp ) { eType = eTp; }
277 SvxTimeFormat GetFormat() const { return eFormat; }
278 void SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; }
280 // If eLanguage==LANGUAGE_DONTKNOW the language/country
281 // used in number formatter initialization is taken.
282 OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
283 static OUString GetFormatted( Time& rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
285 virtual SvxFieldData* Clone() const;
286 virtual int operator==( const SvxFieldData& ) const;
288 virtual MetaAction* createBeginComment() const;
292 enum SvxFileType { SVXFILETYPE_FIX, SVXFILETYPE_VAR };
293 enum SvxFileFormat { SVXFILEFORMAT_NAME_EXT = 0, // File name with Extension
294 SVXFILEFORMAT_FULLPATH, // full path
295 SVXFILEFORMAT_PATH, // only path
296 SVXFILEFORMAT_NAME // only file name
301 class EDITENG_DLLPUBLIC SvxExtFileField : public SvxFieldData
303 private:
304 OUString aFile;
305 SvxFileType eType;
306 SvxFileFormat eFormat;
308 public:
309 SV_DECL_PERSIST1( SvxExtFileField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_FILE )
310 SvxExtFileField();
311 explicit SvxExtFileField( const OUString& rString,
312 SvxFileType eType = SVXFILETYPE_VAR,
313 SvxFileFormat eFormat = SVXFILEFORMAT_FULLPATH );
315 OUString GetFile() const { return aFile; }
316 void SetFile( const OUString& rString ) { aFile = rString; }
318 SvxFileType GetType() const { return eType; }
319 void SetType( SvxFileType eTp ) { eType = eTp; }
321 SvxFileFormat GetFormat() const { return eFormat; }
322 void SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; }
324 OUString GetFormatted() const;
326 virtual SvxFieldData* Clone() const;
327 virtual int operator==( const SvxFieldData& ) const;
331 enum SvxAuthorType { SVXAUTHORTYPE_FIX, SVXAUTHORTYPE_VAR };
332 enum SvxAuthorFormat { SVXAUTHORFORMAT_FULLNAME = 0, // full name
333 SVXAUTHORFORMAT_NAME, // Only Last name
334 SVXAUTHORFORMAT_FIRSTNAME, // Only first name
335 SVXAUTHORFORMAT_SHORTNAME // Initials
338 class EDITENG_DLLPUBLIC SvxAuthorField : public SvxFieldData
340 private:
341 OUString aName;
342 OUString aFirstName;
343 OUString aShortName;
344 SvxAuthorType eType;
345 SvxAuthorFormat eFormat;
347 public:
348 SV_DECL_PERSIST1( SvxAuthorField, SvxFieldData, com::sun::star::text::textfield::Type::AUTHOR )
349 SvxAuthorField();
350 SvxAuthorField(
351 const OUString& rFirstName,
352 const OUString& rLastName,
353 const OUString& rShortName,
354 SvxAuthorType eType = SVXAUTHORTYPE_VAR,
355 SvxAuthorFormat eFormat = SVXAUTHORFORMAT_FULLNAME );
357 OUString GetName() const { return aName; }
358 void SetName( const OUString& rString ) { aName = rString; }
360 OUString GetFirstName() const { return aFirstName; }
361 void SetFirstName( const OUString& rString ) { aFirstName = rString; }
363 OUString GetShortName() const { return aShortName; }
364 void SetShortName( const OUString& rString ) { aShortName = rString; }
366 SvxAuthorType GetType() const { return eType; }
367 void SetType( SvxAuthorType eTp ) { eType = eTp; }
369 SvxAuthorFormat GetFormat() const { return eFormat; }
370 void SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; }
372 OUString GetFormatted() const;
374 virtual SvxFieldData* Clone() const;
375 virtual int operator==( const SvxFieldData& ) const;
378 /** this field is used as a placeholder for a header&footer in impress. The actual
379 value is stored at the page */
380 class EDITENG_DLLPUBLIC SvxHeaderField : public SvxFieldData
382 public:
383 SV_DECL_PERSIST1( SvxHeaderField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_HEADER )
384 SvxHeaderField();
386 virtual SvxFieldData* Clone() const;
387 virtual int operator==( const SvxFieldData& ) const;
390 /** this field is used as a placeholder for a header&footer in impress. The actual
391 value is stored at the page */
392 class EDITENG_DLLPUBLIC SvxFooterField : public SvxFieldData
394 public:
395 SV_DECL_PERSIST1( SvxFooterField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_FOOTER )
396 SvxFooterField();
397 virtual SvxFieldData* Clone() const;
398 virtual int operator==( const SvxFieldData& ) const;
401 /** this field is used as a placeholder for a header&footer in impress. The actual
402 value is stored at the page */
403 class EDITENG_DLLPUBLIC SvxDateTimeField : public SvxFieldData
405 public:
406 SV_DECL_PERSIST1( SvxDateTimeField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_DATE_TIME )
407 SvxDateTimeField();
409 static OUString GetFormatted( Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
411 virtual SvxFieldData* Clone() const;
412 virtual int operator==( const SvxFieldData& ) const;
418 #endif
420 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */