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 namespace com
{ namespace sun
{ namespace star
{ namespace text
{
37 class SvNumberFormatter
;
40 // class SvxFieldItem ---------------------------------------------------
43 class EDITENG_DLLPUBLIC SvxFieldData
: public SvPersistBase
46 static const sal_Int32 UNKNOWN_FIELD
;
48 static SvxFieldData
* Create(const css::uno::Reference
<css::text::XTextContent
>& xContent
);
50 SV_DECL_PERSIST1( SvxFieldData
, css::text::textfield::Type::UNSPECIFIED
)
53 virtual ~SvxFieldData() override
;
55 virtual SvxFieldData
* Clone() const;
56 virtual bool operator==( const SvxFieldData
& ) const;
58 virtual MetaAction
* createBeginComment() const;
59 static MetaAction
* createEndComment();
63 * This item stores a field (SvxFieldData). The field is controlled by or
64 * belongs to the item. The field itself is determined by a derivation from
67 class EDITENG_DLLPUBLIC SvxFieldItem
: public SfxPoolItem
70 tools::SvRef
<SvxFieldData
> mxField
;
72 EDITENG_DLLPRIVATE
SvxFieldItem( SvxFieldData
* pField
, const sal_uInt16 nId
);
75 SvxFieldItem( const SvxFieldData
& rField
, const sal_uInt16 nId
);
76 SvxFieldItem( const SvxFieldItem
& rItem
);
77 virtual ~SvxFieldItem() override
;
79 virtual bool operator==( const SfxPoolItem
& ) const override
;
80 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
81 virtual SfxPoolItem
* Create( SvStream
&, sal_uInt16 nVer
) const override
;
82 virtual SvStream
& Store( SvStream
& , sal_uInt16 nItemVersion
) const override
;
84 const SvxFieldData
* GetField() const { return mxField
.get(); }
85 static SvClassManager
& GetClassManager();
89 // The following are the derivatives of SvxFieldData ...
92 enum class SvxDateType
{ Fix
, Var
};
93 enum SvxDateFormat
{ SVXDATEFORMAT_APPDEFAULT
= 0, // Set as in App
94 SVXDATEFORMAT_SYSTEM
, // Set as in System
95 SVXDATEFORMAT_STDSMALL
,
97 SVXDATEFORMAT_A
, // 13.02.96
98 SVXDATEFORMAT_B
, // 13.02.1996
99 SVXDATEFORMAT_C
, // 13.Feb 1996
100 SVXDATEFORMAT_D
, // 13.February 1996
101 SVXDATEFORMAT_E
, // Tue, 13.February 1996
102 SVXDATEFORMAT_F
// Tuesday, 13.February 1996
105 class EDITENG_DLLPUBLIC SvxDateField
: public SvxFieldData
109 SvxDateFormat eFormat
;
112 SV_DECL_PERSIST1( SvxDateField
, css::text::textfield::Type::DATE
)
115 explicit SvxDateField( const Date
& rDate
,
117 SvxDateFormat eFormat
= SVXDATEFORMAT_STDSMALL
);
119 sal_Int32
GetFixDate() const { return nFixDate
; }
120 void SetFixDate( const Date
& rDate
) { nFixDate
= rDate
.GetDate(); }
122 SvxDateType
GetType() const { return eType
; }
123 void SetType( SvxDateType eTp
) { eType
= eTp
; }
125 SvxDateFormat
GetFormat() const { return eFormat
; }
126 void SetFormat( SvxDateFormat eFmt
) { eFormat
= eFmt
; }
128 // If eLanguage==LANGUAGE_DONTKNOW the language/country
129 // used in number formatter initialization is taken.
130 OUString
GetFormatted( SvNumberFormatter
& rFormatter
, LanguageType eLanguage
) const;
131 static OUString
GetFormatted( Date
& rDate
, SvxDateFormat eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLanguage
);
133 virtual SvxFieldData
* Clone() const override
;
134 virtual bool operator==( const SvxFieldData
& ) const override
;
136 virtual MetaAction
* createBeginComment() const override
;
140 enum SvxURLFormat
{ SVXURLFORMAT_APPDEFAULT
= 0, // Set as in App
141 SVXURLFORMAT_URL
, // Represent URL
142 SVXURLFORMAT_REPR
// Constitute representation
145 class EDITENG_DLLPUBLIC SvxURLField
: public SvxFieldData
148 SvxURLFormat eFormat
;
149 OUString aURL
; // URL-Address
150 OUString aRepresentation
; // What is shown
151 OUString aTargetFrame
; // In what Frame
154 SV_DECL_PERSIST1( SvxURLField
, css::text::textfield::Type::URL
)
157 SvxURLField( const OUString
& rURL
, const OUString
& rRepres
, SvxURLFormat eFmt
= SVXURLFORMAT_URL
);
159 const OUString
& GetURL() const { return aURL
; }
160 void SetURL( const OUString
& rURL
) { aURL
= rURL
; }
162 const OUString
& GetRepresentation() const { return aRepresentation
; }
163 void SetRepresentation( const OUString
& rRep
) { aRepresentation
= rRep
; }
165 const OUString
& GetTargetFrame() const { return aTargetFrame
; }
166 void SetTargetFrame( const OUString
& rFrm
) { aTargetFrame
= rFrm
; }
168 SvxURLFormat
GetFormat() const { return eFormat
; }
169 void SetFormat( SvxURLFormat eFmt
) { eFormat
= eFmt
; }
171 virtual SvxFieldData
* Clone() const override
;
172 virtual bool operator==( const SvxFieldData
& ) const override
;
174 virtual MetaAction
* createBeginComment() const override
;
177 class EDITENG_DLLPUBLIC SvxPageField final
: public SvxFieldData
180 SV_DECL_PERSIST1( SvxPageField
, css::text::textfield::Type::PAGE
)
183 virtual SvxFieldData
* Clone() const override
;
184 virtual bool operator==( const SvxFieldData
& ) const override
;
186 virtual MetaAction
* createBeginComment() const override
;
189 class EDITENG_DLLPUBLIC SvxPageTitleField final
: public SvxFieldData
192 SV_DECL_PERSIST1( SvxPageTitleField
, css::text::textfield::Type::PAGE_NAME
)
195 virtual SvxFieldData
* Clone() const override
;
196 virtual bool operator==( const SvxFieldData
& ) const override
;
198 virtual MetaAction
* createBeginComment() const override
;
201 class EDITENG_DLLPUBLIC SvxPagesField final
: public SvxFieldData
204 SV_DECL_PERSIST1( SvxPagesField
, css::text::textfield::Type::PAGES
)
207 virtual SvxFieldData
* Clone() const override
;
208 virtual bool operator==( const SvxFieldData
& ) const override
;
211 class EDITENG_DLLPUBLIC SvxTimeField final
: public SvxFieldData
214 SV_DECL_PERSIST1( SvxTimeField
, css::text::textfield::Type::TIME
)
217 virtual SvxFieldData
* Clone() const override
;
218 virtual bool operator==( const SvxFieldData
& ) const override
;
220 virtual MetaAction
* createBeginComment() const override
;
223 class EDITENG_DLLPUBLIC SvxFileField final
: public SvxFieldData
226 SV_DECL_PERSIST1( SvxFileField
, css::text::textfield::Type::DOCINFO_TITLE
)
229 virtual SvxFieldData
* Clone() const override
;
230 virtual bool operator==( const SvxFieldData
& ) const override
;
233 class EDITENG_DLLPUBLIC SvxTableField final
: public SvxFieldData
237 SV_DECL_PERSIST1( SvxTableField
, css::text::textfield::Type::TABLE
)
239 explicit SvxTableField(int nTab
);
241 void SetTab(int nTab
);
242 int GetTab() const { return mnTab
;}
244 virtual SvxFieldData
* Clone() const override
;
245 virtual bool operator==( const SvxFieldData
& ) const override
;
249 enum SvxTimeType
{ SVXTIMETYPE_FIX
, SVXTIMETYPE_VAR
};
250 enum SvxTimeFormat
{ SVXTIMEFORMAT_APPDEFAULT
= 0, // Set as in App
251 SVXTIMEFORMAT_SYSTEM
, // Set as in System
252 SVXTIMEFORMAT_STANDARD
,
253 SVXTIMEFORMAT_24_HM
, // 13:49
254 SVXTIMEFORMAT_24_HMS
, // 13:49:38
255 SVXTIMEFORMAT_24_HMSH
, // 13:49:38.78
256 SVXTIMEFORMAT_12_HM
, // 01:49
257 SVXTIMEFORMAT_12_HMS
, // 01:49:38
258 SVXTIMEFORMAT_12_HMSH
, // 01:49:38.78
259 SVXTIMEFORMAT_AM_HM
, // 01:49 PM
260 SVXTIMEFORMAT_AM_HMS
, // 01:49:38 PM
261 SVXTIMEFORMAT_AM_HMSH
// 01:49:38.78 PM
264 class EDITENG_DLLPUBLIC SvxExtTimeField
: public SvxFieldData
267 sal_Int64 m_nFixTime
;
269 SvxTimeFormat eFormat
;
272 SV_DECL_PERSIST1( SvxExtTimeField
, css::text::textfield::Type::EXTENDED_TIME
)
274 explicit SvxExtTimeField( const tools::Time
& rTime
,
276 SvxTimeFormat eFormat
= SVXTIMEFORMAT_STANDARD
);
278 sal_Int64
GetFixTime() const { return m_nFixTime
; }
279 void SetFixTime( const tools::Time
& rTime
) { m_nFixTime
= rTime
.GetTime(); }
281 SvxTimeType
GetType() const { return eType
; }
282 void SetType( SvxTimeType eTp
) { eType
= eTp
; }
284 SvxTimeFormat
GetFormat() const { return eFormat
; }
285 void SetFormat( SvxTimeFormat eFmt
) { eFormat
= eFmt
; }
287 // If eLanguage==LANGUAGE_DONTKNOW the language/country
288 // used in number formatter initialization is taken.
289 OUString
GetFormatted( SvNumberFormatter
& rFormatter
, LanguageType eLanguage
) const;
290 static OUString
GetFormatted( tools::Time
& rTime
, SvxTimeFormat eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLanguage
);
292 virtual SvxFieldData
* Clone() const override
;
293 virtual bool operator==( const SvxFieldData
& ) const override
;
295 virtual MetaAction
* createBeginComment() const override
;
299 enum SvxFileType
{ SVXFILETYPE_FIX
, SVXFILETYPE_VAR
};
300 enum SvxFileFormat
{ SVXFILEFORMAT_NAME_EXT
= 0, // File name with Extension
301 SVXFILEFORMAT_FULLPATH
, // full path
302 SVXFILEFORMAT_PATH
, // only path
303 SVXFILEFORMAT_NAME
// only file name
307 class EDITENG_DLLPUBLIC SvxExtFileField
: public SvxFieldData
312 SvxFileFormat eFormat
;
315 SV_DECL_PERSIST1( SvxExtFileField
, css::text::textfield::Type::EXTENDED_FILE
)
317 explicit SvxExtFileField( const OUString
& rString
,
318 SvxFileType eType
= SVXFILETYPE_VAR
,
319 SvxFileFormat eFormat
= SVXFILEFORMAT_FULLPATH
);
321 const OUString
& GetFile() const { return aFile
; }
322 void SetFile( const OUString
& rString
) { aFile
= rString
; }
324 SvxFileType
GetType() const { return eType
; }
325 void SetType( SvxFileType eTp
) { eType
= eTp
; }
327 SvxFileFormat
GetFormat() const { return eFormat
; }
328 void SetFormat( SvxFileFormat eFmt
) { eFormat
= eFmt
; }
330 OUString
GetFormatted() const;
332 virtual SvxFieldData
* Clone() const override
;
333 virtual bool operator==( const SvxFieldData
& ) const override
;
337 enum SvxAuthorType
{ SVXAUTHORTYPE_FIX
, SVXAUTHORTYPE_VAR
};
338 enum SvxAuthorFormat
{ SVXAUTHORFORMAT_FULLNAME
= 0, // full name
339 SVXAUTHORFORMAT_NAME
, // Only Last name
340 SVXAUTHORFORMAT_FIRSTNAME
, // Only first name
341 SVXAUTHORFORMAT_SHORTNAME
// Initials
344 class EDITENG_DLLPUBLIC SvxAuthorField
: public SvxFieldData
351 SvxAuthorFormat eFormat
;
354 SV_DECL_PERSIST1( SvxAuthorField
, css::text::textfield::Type::AUTHOR
)
357 const OUString
& rFirstName
,
358 const OUString
& rLastName
,
359 const OUString
& rShortName
,
360 SvxAuthorType eType
= SVXAUTHORTYPE_VAR
,
361 SvxAuthorFormat eFormat
= SVXAUTHORFORMAT_FULLNAME
);
363 SvxAuthorType
GetType() const { return eType
; }
364 void SetType( SvxAuthorType eTp
) { eType
= eTp
; }
366 SvxAuthorFormat
GetFormat() const { return eFormat
; }
367 void SetFormat( SvxAuthorFormat eFmt
) { eFormat
= eFmt
; }
369 OUString
GetFormatted() const;
371 virtual SvxFieldData
* Clone() const override
;
372 virtual bool operator==( const SvxFieldData
& ) const override
;
375 /** this field is used as a placeholder for a header&footer in impress. The actual
376 value is stored at the page */
377 class EDITENG_DLLPUBLIC SvxHeaderField final
: public SvxFieldData
380 SV_DECL_PERSIST1( SvxHeaderField
, css::text::textfield::Type::PRESENTATION_HEADER
)
383 virtual SvxFieldData
* Clone() const override
;
384 virtual bool operator==( const SvxFieldData
& ) const override
;
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 SvxFooterField final
: public SvxFieldData
392 SV_DECL_PERSIST1( SvxFooterField
, css::text::textfield::Type::PRESENTATION_FOOTER
)
394 virtual SvxFieldData
* Clone() const override
;
395 virtual bool operator==( const SvxFieldData
& ) const override
;
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 SvxDateTimeField final
: public SvxFieldData
403 SV_DECL_PERSIST1( SvxDateTimeField
, css::text::textfield::Type::PRESENTATION_DATE_TIME
)
406 static OUString
GetFormatted( Date
& rDate
, tools::Time
& rTime
, int eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLanguage
);
408 virtual SvxFieldData
* Clone() const override
;
409 virtual bool operator==( const SvxFieldData
& ) const override
;
415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */