1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_EDITENG_FLDITEM_HXX
20 #define INCLUDED_EDITENG_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
{
39 class SvNumberFormatter
;
42 // class SvxFieldItem ---------------------------------------------------
46 class EDITENG_DLLPUBLIC SvxFieldData
: public SvPersistBase
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
)
56 virtual ~SvxFieldData();
58 virtual SvxFieldData
* Clone() const;
59 virtual bool operator==( const SvxFieldData
& ) const;
61 virtual MetaAction
* createBeginComment() const;
62 static MetaAction
* createEndComment();
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
70 class EDITENG_DLLPUBLIC SvxFieldItem
: public SfxPoolItem
75 EDITENG_DLLPRIVATE
SvxFieldItem( SvxFieldData
* pField
, const sal_uInt16 nId
);
80 SvxFieldItem( const SvxFieldData
& rField
, const sal_uInt16 nId
);
81 SvxFieldItem( const SvxFieldItem
& rItem
);
82 virtual ~SvxFieldItem();
84 virtual bool operator==( const SfxPoolItem
& ) const SAL_OVERRIDE
;
85 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= 0 ) const SAL_OVERRIDE
;
86 virtual SfxPoolItem
* Create( SvStream
&, sal_uInt16 nVer
) const SAL_OVERRIDE
;
87 virtual SvStream
& Store( SvStream
& , sal_uInt16 nItemVersion
) const SAL_OVERRIDE
;
89 const SvxFieldData
* GetField() const { return pField
; }
90 static SvClassManager
& GetClassManager();
94 // The following are the derivatives of SvxFieldData ...
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
114 SvxDateFormat eFormat
;
117 SV_DECL_PERSIST1( SvxDateField
, SvxFieldData
, com::sun::star::text::textfield::Type::DATE
)
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 SAL_OVERRIDE
;
139 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
141 virtual MetaAction
* createBeginComment() const SAL_OVERRIDE
;
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
153 SvxURLFormat eFormat
;
154 OUString aURL
; // URL-Address
155 OUString aRepresentation
; // What is shown
156 OUString aTargetFrame
; // In what Frame
159 SV_DECL_PERSIST1( SvxURLField
, SvxFieldData
, com::sun::star::text::textfield::Type::URL
)
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 SAL_OVERRIDE
;
177 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
179 virtual MetaAction
* createBeginComment() const SAL_OVERRIDE
;
182 class EDITENG_DLLPUBLIC SvxPageField
: public SvxFieldData
185 SV_DECL_PERSIST1( SvxPageField
, SvxFieldData
, com::sun::star::text::textfield::Type::PAGE
)
188 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
189 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
191 virtual MetaAction
* createBeginComment() const SAL_OVERRIDE
;
194 class EDITENG_DLLPUBLIC SvxPageTitleField
: public SvxFieldData
197 SV_DECL_PERSIST1( SvxPageTitleField
, SvxFieldData
, com::sun::star::text::textfield::Type::PAGE_NAME
)
200 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
201 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
203 virtual MetaAction
* createBeginComment() const SAL_OVERRIDE
;
206 class EDITENG_DLLPUBLIC SvxPagesField
: public SvxFieldData
209 SV_DECL_PERSIST1( SvxPagesField
, SvxFieldData
, com::sun::star::text::textfield::Type::PAGES
)
212 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
213 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
216 class EDITENG_DLLPUBLIC SvxTimeField
: public SvxFieldData
219 SV_DECL_PERSIST1( SvxTimeField
, SvxFieldData
, com::sun::star::text::textfield::Type::TIME
)
222 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
223 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
225 virtual MetaAction
* createBeginComment() const SAL_OVERRIDE
;
228 class EDITENG_DLLPUBLIC SvxFileField
: public SvxFieldData
231 SV_DECL_PERSIST1( SvxFileField
, SvxFieldData
, com::sun::star::text::textfield::Type::DOCINFO_TITLE
)
234 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
235 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
238 class EDITENG_DLLPUBLIC SvxTableField
: public SvxFieldData
242 SV_DECL_PERSIST1( SvxTableField
, SvxFieldData
, com::sun::star::text::textfield::Type::TABLE
)
244 explicit SvxTableField(int nTab
);
246 void SetTab(int nTab
);
247 int GetTab() const { return mnTab
;}
249 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
250 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
254 enum SvxTimeType
{ SVXTIMETYPE_FIX
, SVXTIMETYPE_VAR
};
255 enum SvxTimeFormat
{ SVXTIMEFORMAT_APPDEFAULT
= 0, // Set as in App
256 SVXTIMEFORMAT_SYSTEM
, // Set as in System
257 SVXTIMEFORMAT_STANDARD
,
258 SVXTIMEFORMAT_24_HM
, // 13:49
259 SVXTIMEFORMAT_24_HMS
, // 13:49:38
260 SVXTIMEFORMAT_24_HMSH
, // 13:49:38.78
261 SVXTIMEFORMAT_12_HM
, // 01:49
262 SVXTIMEFORMAT_12_HMS
, // 01:49:38
263 SVXTIMEFORMAT_12_HMSH
, // 01:49:38.78
264 SVXTIMEFORMAT_AM_HM
, // 01:49 PM
265 SVXTIMEFORMAT_AM_HMS
, // 01:49:38 PM
266 SVXTIMEFORMAT_AM_HMSH
// 01:49:38.78 PM
269 class EDITENG_DLLPUBLIC SvxExtTimeField
: public SvxFieldData
272 sal_Int64 m_nFixTime
;
274 SvxTimeFormat eFormat
;
277 SV_DECL_PERSIST1( SvxExtTimeField
, SvxFieldData
, com::sun::star::text::textfield::Type::EXTENDED_TIME
)
279 explicit SvxExtTimeField( const tools::Time
& rTime
,
280 SvxTimeType eType
= SVXTIMETYPE_VAR
,
281 SvxTimeFormat eFormat
= SVXTIMEFORMAT_STANDARD
);
283 sal_Int64
GetFixTime() const { return m_nFixTime
; }
284 void SetFixTime( const tools::Time
& rTime
) { m_nFixTime
= rTime
.GetTime(); }
286 SvxTimeType
GetType() const { return eType
; }
287 void SetType( SvxTimeType eTp
) { eType
= eTp
; }
289 SvxTimeFormat
GetFormat() const { return eFormat
; }
290 void SetFormat( SvxTimeFormat eFmt
) { eFormat
= eFmt
; }
292 // If eLanguage==LANGUAGE_DONTKNOW the language/country
293 // used in number formatter initialization is taken.
294 OUString
GetFormatted( SvNumberFormatter
& rFormatter
, LanguageType eLanguage
) const;
295 static OUString
GetFormatted( tools::Time
& rTime
, SvxTimeFormat eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLanguage
);
297 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
298 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
300 virtual MetaAction
* createBeginComment() const SAL_OVERRIDE
;
304 enum SvxFileType
{ SVXFILETYPE_FIX
, SVXFILETYPE_VAR
};
305 enum SvxFileFormat
{ SVXFILEFORMAT_NAME_EXT
= 0, // File name with Extension
306 SVXFILEFORMAT_FULLPATH
, // full path
307 SVXFILEFORMAT_PATH
, // only path
308 SVXFILEFORMAT_NAME
// only file name
313 class EDITENG_DLLPUBLIC SvxExtFileField
: public SvxFieldData
318 SvxFileFormat eFormat
;
321 SV_DECL_PERSIST1( SvxExtFileField
, SvxFieldData
, com::sun::star::text::textfield::Type::EXTENDED_FILE
)
323 explicit SvxExtFileField( const OUString
& rString
,
324 SvxFileType eType
= SVXFILETYPE_VAR
,
325 SvxFileFormat eFormat
= SVXFILEFORMAT_FULLPATH
);
327 OUString
GetFile() const { return aFile
; }
328 void SetFile( const OUString
& rString
) { aFile
= rString
; }
330 SvxFileType
GetType() const { return eType
; }
331 void SetType( SvxFileType eTp
) { eType
= eTp
; }
333 SvxFileFormat
GetFormat() const { return eFormat
; }
334 void SetFormat( SvxFileFormat eFmt
) { eFormat
= eFmt
; }
336 OUString
GetFormatted() const;
338 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
339 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
343 enum SvxAuthorType
{ SVXAUTHORTYPE_FIX
, SVXAUTHORTYPE_VAR
};
344 enum SvxAuthorFormat
{ SVXAUTHORFORMAT_FULLNAME
= 0, // full name
345 SVXAUTHORFORMAT_NAME
, // Only Last name
346 SVXAUTHORFORMAT_FIRSTNAME
, // Only first name
347 SVXAUTHORFORMAT_SHORTNAME
// Initials
350 class EDITENG_DLLPUBLIC SvxAuthorField
: public SvxFieldData
357 SvxAuthorFormat eFormat
;
360 SV_DECL_PERSIST1( SvxAuthorField
, SvxFieldData
, com::sun::star::text::textfield::Type::AUTHOR
)
363 const OUString
& rFirstName
,
364 const OUString
& rLastName
,
365 const OUString
& rShortName
,
366 SvxAuthorType eType
= SVXAUTHORTYPE_VAR
,
367 SvxAuthorFormat eFormat
= SVXAUTHORFORMAT_FULLNAME
);
369 OUString
GetName() const { return aName
; }
370 void SetName( const OUString
& rString
) { aName
= rString
; }
372 OUString
GetFirstName() const { return aFirstName
; }
373 void SetFirstName( const OUString
& rString
) { aFirstName
= rString
; }
375 OUString
GetShortName() const { return aShortName
; }
376 void SetShortName( const OUString
& rString
) { aShortName
= rString
; }
378 SvxAuthorType
GetType() const { return eType
; }
379 void SetType( SvxAuthorType eTp
) { eType
= eTp
; }
381 SvxAuthorFormat
GetFormat() const { return eFormat
; }
382 void SetFormat( SvxAuthorFormat eFmt
) { eFormat
= eFmt
; }
384 OUString
GetFormatted() const;
386 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
387 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
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 SvxHeaderField
: public SvxFieldData
395 SV_DECL_PERSIST1( SvxHeaderField
, SvxFieldData
, com::sun::star::text::textfield::Type::PRESENTATION_HEADER
)
398 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
399 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
402 /** this field is used as a placeholder for a header&footer in impress. The actual
403 value is stored at the page */
404 class EDITENG_DLLPUBLIC SvxFooterField
: public SvxFieldData
407 SV_DECL_PERSIST1( SvxFooterField
, SvxFieldData
, com::sun::star::text::textfield::Type::PRESENTATION_FOOTER
)
409 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
410 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
413 /** this field is used as a placeholder for a header&footer in impress. The actual
414 value is stored at the page */
415 class EDITENG_DLLPUBLIC SvxDateTimeField
: public SvxFieldData
418 SV_DECL_PERSIST1( SvxDateTimeField
, SvxFieldData
, com::sun::star::text::textfield::Type::PRESENTATION_DATE_TIME
)
421 static OUString
GetFormatted( Date
& rDate
, tools::Time
& rTime
, int eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLanguage
);
423 virtual SvxFieldData
* Clone() const SAL_OVERRIDE
;
424 virtual bool operator==( const SvxFieldData
& ) const SAL_OVERRIDE
;
432 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */