LibreOffice Module editeng (master) 1
flditem.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_EDITENG_FLDITEM_HXX
20#define INCLUDED_EDITENG_FLDITEM_HXX
21
22#include <i18nlangtag/lang.h>
23#include <tools/time.hxx>
24#include <tools/date.hxx>
25#include <svl/poolitem.hxx>
27
28#include <com/sun/star/text/textfield/Type.hpp>
29
30namespace com::sun::star::text {
31 class XTextContent;
32}
33
35class MetaAction;
36
37// class SvxFieldItem ---------------------------------------------------
38
39
41{
42public:
43
44 static SvxFieldData* Create(const css::uno::Reference<css::text::XTextContent>& xContent);
45
46 static constexpr auto CLASS_ID = css::text::textfield::Type::UNSPECIFIED;
47 virtual sal_Int32 GetClassId() const { return CLASS_ID; }
48
50 virtual ~SvxFieldData();
51
52 SvxFieldData(SvxFieldData const &) = default;
54 SvxFieldData & operator =(SvxFieldData const &) = default;
55 SvxFieldData & operator =(SvxFieldData &&) = default;
56
57 virtual std::unique_ptr<SvxFieldData> Clone() const;
58 virtual bool operator==( const SvxFieldData& ) const;
59
60 virtual MetaAction* createBeginComment() const;
61 static MetaAction* createEndComment();
62};
63
70{
71 std::unique_ptr<SvxFieldData> mpField;
72public:
73 SvxFieldItem( std::unique_ptr<SvxFieldData> pField, const sal_uInt16 nId );
74 SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId );
75 SvxFieldItem( const SvxFieldItem& rItem );
76 virtual ~SvxFieldItem() override;
77
78 virtual bool operator==( const SfxPoolItem& ) const override;
79 virtual SvxFieldItem* Clone( SfxItemPool *pPool = nullptr ) const override;
80
81 const SvxFieldData* GetField() const { return mpField.get(); }
82};
83
84
85// The following are the derivatives of SvxFieldData ...
86
87
88enum class SvxDateType { Fix, Var };
89enum class SvxDateFormat {
90 AppDefault = 0, // Set as in App
91 System, // Set as in System
93 StdBig,
94 A, // 13.02.96
95 B, // 13.02.1996
96 C, // 13.Feb 1996
97 D, // 13.February 1996
98 E, // Tue, 13.February 1996
99 F // Tuesday, 13.February 1996
100};
101
103{
104 sal_Int32 nFixDate;
107
108public:
109 static constexpr auto CLASS_ID = css::text::textfield::Type::DATE;
110 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
111
112 SvxDateField();
113 explicit SvxDateField( const Date& rDate,
114 SvxDateType eType,
116
117 sal_Int32 GetFixDate() const { return nFixDate; }
118 void SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); }
119
120 SvxDateType GetType() const { return eType; }
121 void SetType( SvxDateType eTp ) { eType = eTp; }
122
123 SvxDateFormat GetFormat() const { return eFormat; }
124 void SetFormat( SvxDateFormat eFmt ) { eFormat = eFmt; }
125
126 // If eLanguage==LANGUAGE_DONTKNOW the language/country
127 // used in number formatter initialization is taken.
128 OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
129 static OUString GetFormatted( Date const & rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
130
131 virtual std::unique_ptr<SvxFieldData> Clone() const override;
132 virtual bool operator==( const SvxFieldData& ) const override;
133
134 virtual MetaAction* createBeginComment() const override;
135};
136
137
138enum class SvxURLFormat {
139 AppDefault = 0, // Set as in App
140 Url, // Represent URL
141 Repr // Constitute representation
142};
143
145{
146private:
148 OUString aURL; // URL-Address
149 OUString aRepresentation; // What is shown
150 OUString aTargetFrame; // In what Frame
151
152public:
153 static constexpr auto CLASS_ID = css::text::textfield::Type::URL;
154 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
155
156 SvxURLField();
157 SvxURLField( OUString aURL, OUString aRepres, SvxURLFormat eFmt = SvxURLFormat::Url );
158
159 const OUString& GetURL() const { return aURL; }
160 void SetURL( const OUString& rURL ) { aURL = rURL; }
161
162 const OUString& GetRepresentation() const { return aRepresentation; }
163 void SetRepresentation( const OUString& rRep ) { aRepresentation= rRep; }
164
165 const OUString& GetTargetFrame() const { return aTargetFrame; }
166 void SetTargetFrame( const OUString& rFrm ) { aTargetFrame = rFrm; }
167
168 SvxURLFormat GetFormat() const { return eFormat; }
169 void SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
170
171 virtual std::unique_ptr<SvxFieldData> Clone() const override;
172 virtual bool operator==( const SvxFieldData& ) const override;
173
174 virtual MetaAction* createBeginComment() const override;
175};
176
178{
179public:
180 virtual sal_Int32 GetClassId() const override { return css::text::textfield::Type::PAGE; }
181 SvxPageField();
182
183 virtual std::unique_ptr<SvxFieldData> Clone() const override;
184 virtual bool operator==( const SvxFieldData& ) const override;
185
186 virtual MetaAction* createBeginComment() const override;
187};
188
190{
191public:
192 static constexpr auto CLASS_ID = css::text::textfield::Type::PAGE_NAME;
193 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
195
196 virtual std::unique_ptr<SvxFieldData> Clone() const override;
197 virtual bool operator==( const SvxFieldData& ) const override;
198
199 virtual MetaAction* createBeginComment() const override;
200};
201
203{
204public:
205 static constexpr auto CLASS_ID = css::text::textfield::Type::PAGES;
206 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
208
209 virtual std::unique_ptr<SvxFieldData> Clone() const override;
210 virtual bool operator==( const SvxFieldData& ) const override;
211};
212
214{
215public:
216 static constexpr auto CLASS_ID = css::text::textfield::Type::TIME;
217 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
218 SvxTimeField();
219
220 virtual std::unique_ptr<SvxFieldData> Clone() const override;
221 virtual bool operator==( const SvxFieldData& ) const override;
222
223 virtual MetaAction* createBeginComment() const override;
224};
225
227{
228public:
229 static constexpr auto CLASS_ID = css::text::textfield::Type::DOCINFO_TITLE;
230 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
231 SvxFileField();
232
233 virtual std::unique_ptr<SvxFieldData> Clone() const override;
234 virtual bool operator==( const SvxFieldData& ) const override;
235};
236
238{
239 int mnTab;
240public:
241 static constexpr auto CLASS_ID = css::text::textfield::Type::TABLE;
242 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
244 explicit SvxTableField(int nTab);
245
246 void SetTab(int nTab);
247 int GetTab() const { return mnTab;}
248
249 virtual std::unique_ptr<SvxFieldData> Clone() const override;
250 virtual bool operator==( const SvxFieldData& ) const override;
251};
252
253
254enum class SvxTimeType {
255 Fix,
256 Var
257};
258enum class SvxTimeFormat {
259 AppDefault = 0, // Set as in App
260 System, // Set as in System
261 Standard,
262 HH24_MM, // 13:49
263 HH24_MM_SS, // 13:49:38
264 HH24_MM_SS_00, // 13:49:38.78
265 HH12_MM, // 01:49
266 HH12_MM_SS, // 01:49:38
267 HH12_MM_SS_00, // 01:49:38.78
268 HH12_MM_AMPM, // 01:49 PM
269 HH12_MM_SS_AMPM, // 01:49:38 PM
270 HH12_MM_SS_00_AMPM // 01:49:38.78 PM
271};
272
274{
275private:
276 sal_Int64 m_nFixTime;
279
280public:
281 static constexpr auto CLASS_ID = css::text::textfield::Type::EXTENDED_TIME;
282 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
284 explicit SvxExtTimeField( const tools::Time& rTime,
285 SvxTimeType eType,
287
288 sal_Int64 GetFixTime() const { return m_nFixTime; }
289 void SetFixTime( const tools::Time& rTime ) { m_nFixTime = rTime.GetTime(); }
290
291 SvxTimeType GetType() const { return eType; }
292 void SetType( SvxTimeType eTp ) { eType = eTp; }
293
294 SvxTimeFormat GetFormat() const { return eFormat; }
295 void SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; }
296
297 // If eLanguage==LANGUAGE_DONTKNOW the language/country
298 // used in number formatter initialization is taken.
299 OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
300 static OUString GetFormatted( tools::Time const & rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
301
302 virtual std::unique_ptr<SvxFieldData> Clone() const override;
303 virtual bool operator==( const SvxFieldData& ) const override;
304
305 virtual MetaAction* createBeginComment() const override;
306};
307
308
309enum class SvxFileType {
310 Fix,
311 Var
312};
313enum class SvxFileFormat {
314 NameAndExt = 0, // File name with Extension
315 PathFull, // full path
316 PathOnly, // only path
317 NameOnly // only file name
318};
319
320
322{
323private:
324 OUString aFile;
327
328public:
329 static constexpr auto CLASS_ID = css::text::textfield::Type::EXTENDED_FILE;
330 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
332 explicit SvxExtFileField( const OUString& rString,
335
336 const OUString& GetFile() const { return aFile; }
337 void SetFile( const OUString& rString ) { aFile = rString; }
338
339 SvxFileType GetType() const { return eType; }
340 void SetType( SvxFileType eTp ) { eType = eTp; }
341
342 SvxFileFormat GetFormat() const { return eFormat; }
343 void SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; }
344
345 OUString GetFormatted() const;
346
347 virtual std::unique_ptr<SvxFieldData> Clone() const override;
348 virtual bool operator==( const SvxFieldData& ) const override;
349};
350
351
352enum class SvxAuthorType {
353 Fix, Var
354};
355enum class SvxAuthorFormat {
356 FullName, // full name
357 LastName, // Only Last name
358 FirstName, // Only first name
359 ShortName // Initials
360};
361
363{
364private:
365 OUString aName;
366 OUString aFirstName;
367 OUString aShortName;
370
371public:
372 static constexpr auto CLASS_ID = css::text::textfield::Type::AUTHOR;
373 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
375 const OUString& rFirstName,
376 const OUString& rLastName,
377 const OUString& rShortName,
380
381 SvxAuthorType GetType() const { return eType; }
382 void SetType( SvxAuthorType eTp ) { eType = eTp; }
383
384 SvxAuthorFormat GetFormat() const { return eFormat; }
385 void SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; }
386
387 OUString GetFormatted() const;
388
389 virtual std::unique_ptr<SvxFieldData> Clone() const override;
390 virtual bool operator==( const SvxFieldData& ) const override;
391};
392
396{
397public:
398 static constexpr auto CLASS_ID = css::text::textfield::Type::PRESENTATION_HEADER;
399 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
401
402 virtual std::unique_ptr<SvxFieldData> Clone() const override;
403 virtual bool operator==( const SvxFieldData& ) const override;
404};
405
409{
410public:
411 static constexpr auto CLASS_ID = css::text::textfield::Type::PRESENTATION_FOOTER;
412 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
414 virtual std::unique_ptr<SvxFieldData> Clone() const override;
415 virtual bool operator==( const SvxFieldData& ) const override;
416};
417
421{
422public:
423 static constexpr auto CLASS_ID = css::text::textfield::Type::PRESENTATION_DATE_TIME;
424 virtual sal_Int32 GetClassId() const override { return CLASS_ID; }
426
427 static OUString GetFormatted( Date const & rDate, tools::Time const & rTime,
428 SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat,
429 SvNumberFormatter& rFormatter, LanguageType eLanguage );
430
431 virtual std::unique_ptr<SvxFieldData> Clone() const override;
432 virtual bool operator==( const SvxFieldData& ) const override;
433};
434
435
436#endif
437
438/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetDate() const
void SetType(SvxAuthorType eTp)
Definition: flditem.hxx:382
SvxAuthorType GetType() const
Definition: flditem.hxx:381
SvxAuthorType eType
Definition: flditem.hxx:368
void SetFormat(SvxAuthorFormat eFmt)
Definition: flditem.hxx:385
OUString aName
Definition: flditem.hxx:365
OUString aFirstName
Definition: flditem.hxx:366
SvxAuthorFormat eFormat
Definition: flditem.hxx:369
OUString aShortName
Definition: flditem.hxx:367
SvxAuthorFormat GetFormat() const
Definition: flditem.hxx:384
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:373
void SetFixDate(const Date &rDate)
Definition: flditem.hxx:118
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:110
SvxDateType eType
Definition: flditem.hxx:105
SvxDateFormat GetFormat() const
Definition: flditem.hxx:123
sal_Int32 GetFixDate() const
Definition: flditem.hxx:117
sal_Int32 nFixDate
Definition: flditem.hxx:104
void SetType(SvxDateType eTp)
Definition: flditem.hxx:121
SvxDateFormat eFormat
Definition: flditem.hxx:106
void SetFormat(SvxDateFormat eFmt)
Definition: flditem.hxx:124
SvxDateType GetType() const
Definition: flditem.hxx:120
this field is used as a placeholder for a header&footer in impress.
Definition: flditem.hxx:421
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:424
const OUString & GetFile() const
Definition: flditem.hxx:336
void SetFile(const OUString &rString)
Definition: flditem.hxx:337
SvxFileType eType
Definition: flditem.hxx:325
SvxFileFormat eFormat
Definition: flditem.hxx:326
OUString aFile
Definition: flditem.hxx:324
SvxFileType GetType() const
Definition: flditem.hxx:339
SvxFileFormat GetFormat() const
Definition: flditem.hxx:342
void SetType(SvxFileType eTp)
Definition: flditem.hxx:340
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:330
void SetFormat(SvxFileFormat eFmt)
Definition: flditem.hxx:343
sal_Int64 m_nFixTime
Definition: flditem.hxx:276
void SetFormat(SvxTimeFormat eFmt)
Definition: flditem.hxx:295
void SetFixTime(const tools::Time &rTime)
Definition: flditem.hxx:289
SvxTimeFormat eFormat
Definition: flditem.hxx:278
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:282
SvxTimeType eType
Definition: flditem.hxx:277
sal_Int64 GetFixTime() const
Definition: flditem.hxx:288
SvxTimeFormat GetFormat() const
Definition: flditem.hxx:294
SvxTimeType GetType() const
Definition: flditem.hxx:291
void SetType(SvxTimeType eTp)
Definition: flditem.hxx:292
SvxFieldData(SvxFieldData const &)=default
SvxFieldData(SvxFieldData &&)=default
virtual sal_Int32 GetClassId() const
Definition: flditem.hxx:47
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
std::unique_ptr< SvxFieldData > mpField
Definition: flditem.hxx:71
const SvxFieldData * GetField() const
Definition: flditem.hxx:81
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:230
this field is used as a placeholder for a header&footer in impress.
Definition: flditem.hxx:409
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:412
this field is used as a placeholder for a header&footer in impress.
Definition: flditem.hxx:396
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:399
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:180
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:193
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:206
int GetTab() const
Definition: flditem.hxx:247
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:242
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:217
const OUString & GetRepresentation() const
Definition: flditem.hxx:162
SvxURLFormat GetFormat() const
Definition: flditem.hxx:168
void SetFormat(SvxURLFormat eFmt)
Definition: flditem.hxx:169
virtual sal_Int32 GetClassId() const override
Definition: flditem.hxx:154
void SetTargetFrame(const OUString &rFrm)
Definition: flditem.hxx:166
const OUString & GetTargetFrame() const
Definition: flditem.hxx:165
void SetURL(const OUString &rURL)
Definition: flditem.hxx:160
OUString aTargetFrame
Definition: flditem.hxx:150
const OUString & GetURL() const
Definition: flditem.hxx:159
OUString aURL
Definition: flditem.hxx:148
void SetRepresentation(const OUString &rRep)
Definition: flditem.hxx:163
SvxURLFormat eFormat
Definition: flditem.hxx:147
OUString aRepresentation
Definition: flditem.hxx:149
sal_Int64 GetTime() const
URL aURL
bool operator==(const EditLine &r1, const EditLine &r2)
Definition: editdoc.cxx:978
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
SvxAuthorFormat
Definition: flditem.hxx:355
SvxFileType
Definition: flditem.hxx:309
SvxURLFormat
Definition: flditem.hxx:138
SvxFileFormat
Definition: flditem.hxx:313
SvxTimeFormat
Definition: flditem.hxx:258
SvxAuthorType
Definition: flditem.hxx:352
SvxTimeType
Definition: flditem.hxx:254
SvxDateType
Definition: flditem.hxx:88
SvxDateFormat
Definition: flditem.hxx:89
DocumentType eType
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
const sal_uInt8 A
#define C