build fix
[LibreOffice.git] / include / editeng / flditem.hxx
blob272b919dc8a5aa37dbc64593ae13adea1e82b8e4
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 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 {
33 class XTextContent;
35 }}}}
37 class SvNumberFormatter;
38 class MetaAction;
40 // class SvxFieldItem ---------------------------------------------------
43 class EDITENG_DLLPUBLIC SvxFieldData : public SvPersistBase
45 public:
46 static const sal_Int32 UNKNOWN_FIELD;
48 static SvxFieldData* Create(const css::uno::Reference<css::text::XTextContent>& xContent);
50 SV_DECL_PERSIST1( SvxFieldData, SvPersistBase, css::text::textfield::Type::UNSPECIFIED)
52 SvxFieldData();
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();
62 /**
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
65 * SvxFieldData (RTTI)
67 class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem
69 private:
70 SvxFieldData* pField;
72 EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId );
74 public:
75 static SfxPoolItem* CreateDefault();
77 SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId );
78 SvxFieldItem( const SvxFieldItem& rItem );
79 virtual ~SvxFieldItem() override;
81 virtual bool operator==( const SfxPoolItem& ) const override;
82 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
83 virtual SfxPoolItem* Create( SvStream&, sal_uInt16 nVer ) const override;
84 virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const override;
86 const SvxFieldData* GetField() const { return pField; }
87 static SvClassManager& GetClassManager();
91 // The following are the derivatives of SvxFieldData ...
94 enum SvxDateType { SVXDATETYPE_FIX, SVXDATETYPE_VAR };
95 enum SvxDateFormat { SVXDATEFORMAT_APPDEFAULT = 0, // Set as in App
96 SVXDATEFORMAT_SYSTEM, // Set as in System
97 SVXDATEFORMAT_STDSMALL,
98 SVXDATEFORMAT_STDBIG,
99 SVXDATEFORMAT_A, // 13.02.96
100 SVXDATEFORMAT_B, // 13.02.1996
101 SVXDATEFORMAT_C, // 13.Feb 1996
102 SVXDATEFORMAT_D, // 13.February 1996
103 SVXDATEFORMAT_E, // Tue, 13.February 1996
104 SVXDATEFORMAT_F // Tuesday, 13.February 1996
107 class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
109 sal_Int32 nFixDate;
110 SvxDateType eType;
111 SvxDateFormat eFormat;
113 public:
114 SV_DECL_PERSIST1( SvxDateField, SvxFieldData, css::text::textfield::Type::DATE )
116 SvxDateField();
117 explicit SvxDateField( const Date& rDate,
118 SvxDateType eType = SVXDATETYPE_VAR,
119 SvxDateFormat eFormat = SVXDATEFORMAT_STDSMALL );
121 sal_Int32 GetFixDate() const { return nFixDate; }
122 void SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); }
124 SvxDateType GetType() const { return eType; }
125 void SetType( SvxDateType eTp ) { eType = eTp; }
127 SvxDateFormat GetFormat() const { return eFormat; }
128 void SetFormat( SvxDateFormat eFmt ) { eFormat = eFmt; }
130 // If eLanguage==LANGUAGE_DONTKNOW the language/country
131 // used in number formatter initialization is taken.
132 OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
133 static OUString GetFormatted( Date& rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
135 virtual SvxFieldData* Clone() const override;
136 virtual bool operator==( const SvxFieldData& ) const override;
138 virtual MetaAction* createBeginComment() const override;
142 enum SvxURLFormat { SVXURLFORMAT_APPDEFAULT = 0, // Set as in App
143 SVXURLFORMAT_URL, // Represent URL
144 SVXURLFORMAT_REPR // Constitute repraesentation
147 class EDITENG_DLLPUBLIC SvxURLField : public SvxFieldData
149 private:
150 SvxURLFormat eFormat;
151 OUString aURL; // URL-Address
152 OUString aRepresentation; // What is shown
153 OUString aTargetFrame; // In what Frame
155 public:
156 SV_DECL_PERSIST1( SvxURLField, SvxFieldData, css::text::textfield::Type::URL )
158 SvxURLField();
159 SvxURLField( const OUString& rURL, const OUString& rRepres, SvxURLFormat eFmt = SVXURLFORMAT_URL );
161 const OUString& GetURL() const { return aURL; }
162 void SetURL( const OUString& rURL ) { aURL = rURL; }
164 const OUString& GetRepresentation() const { return aRepresentation; }
165 void SetRepresentation( const OUString& rRep ) { aRepresentation= rRep; }
167 const OUString& GetTargetFrame() const { return aTargetFrame; }
168 void SetTargetFrame( const OUString& rFrm ) { aTargetFrame = rFrm; }
170 SvxURLFormat GetFormat() const { return eFormat; }
171 void SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
173 virtual SvxFieldData* Clone() const override;
174 virtual bool operator==( const SvxFieldData& ) const override;
176 virtual MetaAction* createBeginComment() const override;
179 class EDITENG_DLLPUBLIC SvxPageField final: public SvxFieldData
181 public:
182 SV_DECL_PERSIST1( SvxPageField, SvxFieldData, css::text::textfield::Type::PAGE )
183 SvxPageField();
185 virtual SvxFieldData* Clone() const override;
186 virtual bool operator==( const SvxFieldData& ) const override;
188 virtual MetaAction* createBeginComment() const override;
191 class EDITENG_DLLPUBLIC SvxPageTitleField final: public SvxFieldData
193 public:
194 SV_DECL_PERSIST1( SvxPageTitleField, SvxFieldData, css::text::textfield::Type::PAGE_NAME )
195 SvxPageTitleField();
197 virtual SvxFieldData* Clone() const override;
198 virtual bool operator==( const SvxFieldData& ) const override;
200 virtual MetaAction* createBeginComment() const override;
203 class EDITENG_DLLPUBLIC SvxPagesField final: public SvxFieldData
205 public:
206 SV_DECL_PERSIST1( SvxPagesField, SvxFieldData, css::text::textfield::Type::PAGES )
207 SvxPagesField();
209 virtual SvxFieldData* Clone() const override;
210 virtual bool operator==( const SvxFieldData& ) const override;
213 class EDITENG_DLLPUBLIC SvxTimeField final: public SvxFieldData
215 public:
216 SV_DECL_PERSIST1( SvxTimeField, SvxFieldData, css::text::textfield::Type::TIME )
217 SvxTimeField();
219 virtual SvxFieldData* Clone() const override;
220 virtual bool operator==( const SvxFieldData& ) const override;
222 virtual MetaAction* createBeginComment() const override;
225 class EDITENG_DLLPUBLIC SvxFileField final: public SvxFieldData
227 public:
228 SV_DECL_PERSIST1( SvxFileField, SvxFieldData, css::text::textfield::Type::DOCINFO_TITLE )
229 SvxFileField();
231 virtual SvxFieldData* Clone() const override;
232 virtual bool operator==( const SvxFieldData& ) const override;
235 class EDITENG_DLLPUBLIC SvxTableField final: public SvxFieldData
237 int mnTab;
238 public:
239 SV_DECL_PERSIST1( SvxTableField, SvxFieldData, css::text::textfield::Type::TABLE )
240 SvxTableField();
241 explicit SvxTableField(int nTab);
243 void SetTab(int nTab);
244 int GetTab() const { return mnTab;}
246 virtual SvxFieldData* Clone() const override;
247 virtual bool operator==( const SvxFieldData& ) const override;
251 enum SvxTimeType { SVXTIMETYPE_FIX, SVXTIMETYPE_VAR };
252 enum SvxTimeFormat { SVXTIMEFORMAT_APPDEFAULT = 0, // Set as in App
253 SVXTIMEFORMAT_SYSTEM, // Set as in System
254 SVXTIMEFORMAT_STANDARD,
255 SVXTIMEFORMAT_24_HM, // 13:49
256 SVXTIMEFORMAT_24_HMS, // 13:49:38
257 SVXTIMEFORMAT_24_HMSH, // 13:49:38.78
258 SVXTIMEFORMAT_12_HM, // 01:49
259 SVXTIMEFORMAT_12_HMS, // 01:49:38
260 SVXTIMEFORMAT_12_HMSH, // 01:49:38.78
261 SVXTIMEFORMAT_AM_HM, // 01:49 PM
262 SVXTIMEFORMAT_AM_HMS, // 01:49:38 PM
263 SVXTIMEFORMAT_AM_HMSH // 01:49:38.78 PM
266 class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData
268 private:
269 sal_Int64 m_nFixTime;
270 SvxTimeType eType;
271 SvxTimeFormat eFormat;
273 public:
274 SV_DECL_PERSIST1( SvxExtTimeField, SvxFieldData, css::text::textfield::Type::EXTENDED_TIME )
275 SvxExtTimeField();
276 explicit SvxExtTimeField( const tools::Time& rTime,
277 SvxTimeType eType = SVXTIMETYPE_VAR,
278 SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD );
280 sal_Int64 GetFixTime() const { return m_nFixTime; }
281 void SetFixTime( const tools::Time& rTime ) { m_nFixTime = rTime.GetTime(); }
283 SvxTimeType GetType() const { return eType; }
284 void SetType( SvxTimeType eTp ) { eType = eTp; }
286 SvxTimeFormat GetFormat() const { return eFormat; }
287 void SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; }
289 // If eLanguage==LANGUAGE_DONTKNOW the language/country
290 // used in number formatter initialization is taken.
291 OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
292 static OUString GetFormatted( tools::Time& rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
294 virtual SvxFieldData* Clone() const override;
295 virtual bool operator==( const SvxFieldData& ) const override;
297 virtual MetaAction* createBeginComment() const override;
301 enum SvxFileType { SVXFILETYPE_FIX, SVXFILETYPE_VAR };
302 enum SvxFileFormat { SVXFILEFORMAT_NAME_EXT = 0, // File name with Extension
303 SVXFILEFORMAT_FULLPATH, // full path
304 SVXFILEFORMAT_PATH, // only path
305 SVXFILEFORMAT_NAME // only file name
309 class EDITENG_DLLPUBLIC SvxExtFileField : public SvxFieldData
311 private:
312 OUString aFile;
313 SvxFileType eType;
314 SvxFileFormat eFormat;
316 public:
317 SV_DECL_PERSIST1( SvxExtFileField, SvxFieldData, css::text::textfield::Type::EXTENDED_FILE )
318 SvxExtFileField();
319 explicit SvxExtFileField( const OUString& rString,
320 SvxFileType eType = SVXFILETYPE_VAR,
321 SvxFileFormat eFormat = SVXFILEFORMAT_FULLPATH );
323 const OUString& GetFile() const { return aFile; }
324 void SetFile( const OUString& rString ) { aFile = rString; }
326 SvxFileType GetType() const { return eType; }
327 void SetType( SvxFileType eTp ) { eType = eTp; }
329 SvxFileFormat GetFormat() const { return eFormat; }
330 void SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; }
332 OUString GetFormatted() const;
334 virtual SvxFieldData* Clone() const override;
335 virtual bool operator==( const SvxFieldData& ) const override;
339 enum SvxAuthorType { SVXAUTHORTYPE_FIX, SVXAUTHORTYPE_VAR };
340 enum SvxAuthorFormat { SVXAUTHORFORMAT_FULLNAME = 0, // full name
341 SVXAUTHORFORMAT_NAME, // Only Last name
342 SVXAUTHORFORMAT_FIRSTNAME, // Only first name
343 SVXAUTHORFORMAT_SHORTNAME // Initials
346 class EDITENG_DLLPUBLIC SvxAuthorField : public SvxFieldData
348 private:
349 OUString aName;
350 OUString aFirstName;
351 OUString aShortName;
352 SvxAuthorType eType;
353 SvxAuthorFormat eFormat;
355 public:
356 SV_DECL_PERSIST1( SvxAuthorField, SvxFieldData, css::text::textfield::Type::AUTHOR )
357 SvxAuthorField();
358 SvxAuthorField(
359 const OUString& rFirstName,
360 const OUString& rLastName,
361 const OUString& rShortName,
362 SvxAuthorType eType = SVXAUTHORTYPE_VAR,
363 SvxAuthorFormat eFormat = SVXAUTHORFORMAT_FULLNAME );
365 SvxAuthorType GetType() const { return eType; }
366 void SetType( SvxAuthorType eTp ) { eType = eTp; }
368 SvxAuthorFormat GetFormat() const { return eFormat; }
369 void SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; }
371 OUString GetFormatted() const;
373 virtual SvxFieldData* Clone() const override;
374 virtual bool operator==( const SvxFieldData& ) const override;
377 /** this field is used as a placeholder for a header&footer in impress. The actual
378 value is stored at the page */
379 class EDITENG_DLLPUBLIC SvxHeaderField final: public SvxFieldData
381 public:
382 SV_DECL_PERSIST1( SvxHeaderField, SvxFieldData, css::text::textfield::Type::PRESENTATION_HEADER )
383 SvxHeaderField();
385 virtual SvxFieldData* Clone() const override;
386 virtual bool operator==( const SvxFieldData& ) const override;
389 /** this field is used as a placeholder for a header&footer in impress. The actual
390 value is stored at the page */
391 class EDITENG_DLLPUBLIC SvxFooterField final: public SvxFieldData
393 public:
394 SV_DECL_PERSIST1( SvxFooterField, SvxFieldData, css::text::textfield::Type::PRESENTATION_FOOTER )
395 SvxFooterField();
396 virtual SvxFieldData* Clone() const override;
397 virtual bool operator==( const SvxFieldData& ) const override;
400 /** this field is used as a placeholder for a header&footer in impress. The actual
401 value is stored at the page */
402 class EDITENG_DLLPUBLIC SvxDateTimeField final: public SvxFieldData
404 public:
405 SV_DECL_PERSIST1( SvxDateTimeField, SvxFieldData, css::text::textfield::Type::PRESENTATION_DATE_TIME )
406 SvxDateTimeField();
408 static OUString GetFormatted( Date& rDate, tools::Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
410 virtual SvxFieldData* Clone() const override;
411 virtual bool operator==( const SvxFieldData& ) const override;
415 #endif
417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */