Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVX_FLDITEM_HXX
29 : : #define _SVX_FLDITEM_HXX
30 : :
31 : : #include <i18npool/lang.h>
32 : : #include <tools/time.hxx>
33 : : #include <tools/date.hxx>
34 : : #include <svl/poolitem.hxx>
35 : : #include <tools/pstm.hxx>
36 : : #include "editeng/editengdllapi.h"
37 : :
38 : : #include <com/sun/star/text/textfield/Type.hpp>
39 : :
40 : : namespace com { namespace sun { namespace star { namespace text {
41 : :
42 : : class XTextContent;
43 : :
44 : : }}}}
45 : :
46 : : class SvNumberFormatter;
47 : : class MetaAction;
48 : :
49 : : // class SvxFieldItem ---------------------------------------------------
50 : :
51 : :
52 : :
53 : 4511 : class EDITENG_DLLPUBLIC SvxFieldData : public SvPersistBase
54 : : {
55 : : public:
56 : : static const sal_Int32 UNKNOWN_FIELD;
57 : :
58 : : static SvxFieldData* Create(const com::sun::star::uno::Reference<com::sun::star::text::XTextContent>& xContent);
59 : :
60 : 135 : SV_DECL_PERSIST1( SvxFieldData, SvPersistBase, com::sun::star::text::textfield::Type::UNSPECIFIED)
61 : :
62 : : SvxFieldData();
63 : : virtual ~SvxFieldData();
64 : :
65 : : virtual SvxFieldData* Clone() const;
66 : : virtual int operator==( const SvxFieldData& ) const;
67 : :
68 : : virtual MetaAction* createBeginComment() const;
69 : : virtual MetaAction* createEndComment() const;
70 : : };
71 : :
72 : : /**
73 : : * This item stores a field (SvxFieldData). The field is controlled by or
74 : : * belongs to the item. The field itself is determined by a derivation from
75 : : * SvxFieldData (RTTI)
76 : : */
77 : : class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem
78 : : {
79 : : private:
80 : : SvxFieldData* pField;
81 : :
82 : : EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId );
83 : :
84 : : public:
85 : : TYPEINFO();
86 : :
87 : : SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId );
88 : : SvxFieldItem( const SvxFieldItem& rItem );
89 : : ~SvxFieldItem();
90 : :
91 : : virtual int operator==( const SfxPoolItem& ) const;
92 : : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
93 : : virtual SfxPoolItem* Create( SvStream&, sal_uInt16 nVer ) const;
94 : : virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const;
95 : :
96 : 80518 : const SvxFieldData* GetField() const { return pField; }
97 : : static SvClassManager& GetClassManager();
98 : : };
99 : :
100 : : // =================================================================
101 : : // The following are the derivatives of SvxFieldData ...
102 : : // =================================================================
103 : :
104 : : enum SvxDateType { SVXDATETYPE_FIX, SVXDATETYPE_VAR };
105 : : enum SvxDateFormat { SVXDATEFORMAT_APPDEFAULT = 0, // Set as in App
106 : : SVXDATEFORMAT_SYSTEM, // Set as in System
107 : : SVXDATEFORMAT_STDSMALL,
108 : : SVXDATEFORMAT_STDBIG,
109 : : SVXDATEFORMAT_A, // 13.02.96
110 : : SVXDATEFORMAT_B, // 13.02.1996
111 : : SVXDATEFORMAT_C, // 13.Feb 1996
112 : : SVXDATEFORMAT_D, // 13.February 1996
113 : : SVXDATEFORMAT_E, // Tue, 13.February 1996
114 : : SVXDATEFORMAT_F // Tuesday, 13.February 1996
115 : : };
116 : :
117 [ - + ]: 10834 : class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
118 : : {
119 : : sal_uInt32 nFixDate;
120 : : SvxDateType eType;
121 : : SvxDateFormat eFormat;
122 : :
123 : : public:
124 : 165 : SV_DECL_PERSIST1( SvxDateField, SvxFieldData, com::sun::star::text::textfield::Type::DATE )
125 : :
126 : : SvxDateField();
127 : : SvxDateField( const Date& rDate,
128 : : SvxDateType eType = SVXDATETYPE_VAR,
129 : : SvxDateFormat eFormat = SVXDATEFORMAT_STDSMALL );
130 : :
131 : 0 : sal_uInt32 GetFixDate() const { return nFixDate; }
132 : 0 : void SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); }
133 : :
134 : 8 : SvxDateType GetType() const { return eType; }
135 : 0 : void SetType( SvxDateType eTp ) { eType = eTp; }
136 : :
137 : 8 : SvxDateFormat GetFormat() const { return eFormat; }
138 : 11 : void SetFormat( SvxDateFormat eFmt ) { eFormat = eFmt; }
139 : :
140 : : // If eLanguage==LANGUAGE_DONTKNOW the language/country
141 : : // used in number formatter initialization is taken.
142 : : rtl::OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
143 : : static rtl::OUString GetFormatted( Date& rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
144 : :
145 : : virtual SvxFieldData* Clone() const;
146 : : virtual int operator==( const SvxFieldData& ) const;
147 : :
148 : : virtual MetaAction* createBeginComment() const;
149 : : };
150 : :
151 : :
152 : : enum SvxURLFormat { SVXURLFORMAT_APPDEFAULT = 0, // Set as in App
153 : : SVXURLFORMAT_URL, // Represent URL
154 : : SVXURLFORMAT_REPR // Constitute repraesentation
155 : : };
156 : :
157 [ - + ]: 784 : class EDITENG_DLLPUBLIC SvxURLField : public SvxFieldData
158 : : {
159 : : private:
160 : : SvxURLFormat eFormat;
161 : : rtl::OUString aURL; // URL-Address
162 : : rtl::OUString aRepresentation; // What is shown
163 : : rtl::OUString aTargetFrame; // In what Frame
164 : :
165 : : public:
166 : 377 : SV_DECL_PERSIST1( SvxURLField, SvxFieldData, com::sun::star::text::textfield::Type::URL )
167 : :
168 : : SvxURLField();
169 : : SvxURLField( const rtl::OUString& rURL, const rtl::OUString& rRepres, SvxURLFormat eFmt = SVXURLFORMAT_URL );
170 : :
171 : 121 : const rtl::OUString& GetURL() const { return aURL; }
172 : 12 : void SetURL( const rtl::OUString& rURL ) { aURL = rURL; }
173 : :
174 : 121 : const rtl::OUString& GetRepresentation() const { return aRepresentation; }
175 : 12 : void SetRepresentation( const rtl::OUString& rRep ) { aRepresentation= rRep; }
176 : :
177 : 18 : const rtl::OUString& GetTargetFrame() const { return aTargetFrame; }
178 : 8 : void SetTargetFrame( const rtl::OUString& rFrm ) { aTargetFrame = rFrm; }
179 : :
180 : 101 : SvxURLFormat GetFormat() const { return eFormat; }
181 : 0 : void SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
182 : :
183 : : virtual SvxFieldData* Clone() const;
184 : : virtual int operator==( const SvxFieldData& ) const;
185 : :
186 : : virtual MetaAction* createBeginComment() const;
187 : : };
188 : :
189 [ - + ]: 16029 : class EDITENG_DLLPUBLIC SvxPageField : public SvxFieldData
190 : : {
191 : : public:
192 : 1187 : SV_DECL_PERSIST1( SvxPageField, SvxFieldData, com::sun::star::text::textfield::Type::PAGE )
193 : : SvxPageField();
194 : :
195 : : virtual SvxFieldData* Clone() const;
196 : : virtual int operator==( const SvxFieldData& ) const;
197 : :
198 : : virtual MetaAction* createBeginComment() const;
199 : : };
200 : :
201 [ - + ]: 6850 : class EDITENG_DLLPUBLIC SvxPagesField : public SvxFieldData
202 : : {
203 : : public:
204 : 81 : SV_DECL_PERSIST1( SvxPagesField, SvxFieldData, com::sun::star::text::textfield::Type::PAGES )
205 : : SvxPagesField();
206 : :
207 : : virtual SvxFieldData* Clone() const;
208 : : virtual int operator==( const SvxFieldData& ) const;
209 : : };
210 : :
211 [ - + ]: 5856 : class EDITENG_DLLPUBLIC SvxTimeField : public SvxFieldData
212 : : {
213 : : public:
214 : 237 : SV_DECL_PERSIST1( SvxTimeField, SvxFieldData, com::sun::star::text::textfield::Type::TIME )
215 : : SvxTimeField();
216 : :
217 : : virtual SvxFieldData* Clone() const;
218 : : virtual int operator==( const SvxFieldData& ) const;
219 : :
220 : : virtual MetaAction* createBeginComment() const;
221 : : };
222 : :
223 [ - + ]: 7036 : class EDITENG_DLLPUBLIC SvxFileField : public SvxFieldData
224 : : {
225 : : public:
226 : 81 : SV_DECL_PERSIST1( SvxFileField, SvxFieldData, com::sun::star::text::textfield::Type::DOCINFO_TITLE )
227 : : SvxFileField();
228 : :
229 : : virtual SvxFieldData* Clone() const;
230 : : virtual int operator==( const SvxFieldData& ) const;
231 : : };
232 : :
233 [ - + ]: 15295 : class EDITENG_DLLPUBLIC SvxTableField : public SvxFieldData
234 : : {
235 : : int mnTab;
236 : : public:
237 : 1085 : SV_DECL_PERSIST1( SvxTableField, SvxFieldData, com::sun::star::text::textfield::Type::TABLE )
238 : : SvxTableField();
239 : : SvxTableField(int nTab);
240 : :
241 : : void SetTab(int nTab);
242 : : int GetTab() const;
243 : :
244 : : virtual SvxFieldData* Clone() const;
245 : : virtual int operator==( const SvxFieldData& ) const;
246 : : };
247 : :
248 : :
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
262 : : };
263 : :
264 [ - + ]: 2245 : class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData
265 : : {
266 : : private:
267 : : sal_uInt32 nFixTime;
268 : : SvxTimeType eType;
269 : : SvxTimeFormat eFormat;
270 : :
271 : : public:
272 : 135 : SV_DECL_PERSIST1( SvxExtTimeField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_TIME )
273 : : SvxExtTimeField();
274 : : SvxExtTimeField( const Time& rTime,
275 : : SvxTimeType eType = SVXTIMETYPE_VAR,
276 : : SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD );
277 : :
278 : 0 : sal_uInt32 GetFixTime() const { return nFixTime; }
279 : 0 : void SetFixTime( const Time& rTime ) { nFixTime = rTime.GetTime(); }
280 : :
281 : 0 : SvxTimeType GetType() const { return eType; }
282 : 0 : void SetType( SvxTimeType eTp ) { eType = eTp; }
283 : :
284 : 0 : SvxTimeFormat GetFormat() const { return eFormat; }
285 : 3 : void SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; }
286 : :
287 : : // If eLanguage==LANGUAGE_DONTKNOW the language/country
288 : : // used in number formatter initialization is taken.
289 : : rtl::OUString GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
290 : : static rtl::OUString GetFormatted( Time& rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
291 : :
292 : : virtual SvxFieldData* Clone() const;
293 : : virtual int operator==( const SvxFieldData& ) const;
294 : :
295 : : virtual MetaAction* createBeginComment() const;
296 : : };
297 : :
298 : :
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
304 : : };
305 : :
306 : :
307 : :
308 [ - + ]: 66 : class EDITENG_DLLPUBLIC SvxExtFileField : public SvxFieldData
309 : : {
310 : : private:
311 : : rtl::OUString aFile;
312 : : SvxFileType eType;
313 : : SvxFileFormat eFormat;
314 : :
315 : : public:
316 : 135 : SV_DECL_PERSIST1( SvxExtFileField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_FILE )
317 : : SvxExtFileField();
318 : : SvxExtFileField( const rtl::OUString& rString,
319 : : SvxFileType eType = SVXFILETYPE_VAR,
320 : : SvxFileFormat eFormat = SVXFILEFORMAT_FULLPATH );
321 : :
322 : 0 : rtl::OUString GetFile() const { return aFile; }
323 : 0 : void SetFile( const rtl::OUString& rString ) { aFile = rString; }
324 : :
325 : 0 : SvxFileType GetType() const { return eType; }
326 : 0 : void SetType( SvxFileType eTp ) { eType = eTp; }
327 : :
328 : 0 : SvxFileFormat GetFormat() const { return eFormat; }
329 : 0 : void SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; }
330 : :
331 : : rtl::OUString GetFormatted() const;
332 : :
333 : : virtual SvxFieldData* Clone() const;
334 : : virtual int operator==( const SvxFieldData& ) const;
335 : : };
336 : :
337 : :
338 : : enum SvxAuthorType { SVXAUTHORTYPE_FIX, SVXAUTHORTYPE_VAR };
339 : : enum SvxAuthorFormat { SVXAUTHORFORMAT_FULLNAME = 0, // full name
340 : : SVXAUTHORFORMAT_NAME, // Only Last name
341 : : SVXAUTHORFORMAT_FIRSTNAME, // Only first name
342 : : SVXAUTHORFORMAT_SHORTNAME // Initials
343 : : };
344 : :
345 [ # # ]: 0 : class EDITENG_DLLPUBLIC SvxAuthorField : public SvxFieldData
346 : : {
347 : : private:
348 : : rtl::OUString aName;
349 : : rtl::OUString aFirstName;
350 : : rtl::OUString aShortName;
351 : : SvxAuthorType eType;
352 : : SvxAuthorFormat eFormat;
353 : :
354 : : public:
355 : 135 : SV_DECL_PERSIST1( SvxAuthorField, SvxFieldData, com::sun::star::text::textfield::Type::AUTHOR )
356 : : SvxAuthorField();
357 : : SvxAuthorField(
358 : : const rtl::OUString& rFirstName,
359 : : const rtl::OUString& rLastName,
360 : : const rtl::OUString& rShortName,
361 : : SvxAuthorType eType = SVXAUTHORTYPE_VAR,
362 : : SvxAuthorFormat eFormat = SVXAUTHORFORMAT_FULLNAME );
363 : :
364 : : rtl::OUString GetName() const { return aName; }
365 : : void SetName( const rtl::OUString& rString ) { aName = rString; }
366 : :
367 : : rtl::OUString GetFirstName() const { return aFirstName; }
368 : : void SetFirstName( const rtl::OUString& rString ) { aFirstName = rString; }
369 : :
370 : : rtl::OUString GetShortName() const { return aShortName; }
371 : : void SetShortName( const rtl::OUString& rString ) { aShortName = rString; }
372 : :
373 : 0 : SvxAuthorType GetType() const { return eType; }
374 : 0 : void SetType( SvxAuthorType eTp ) { eType = eTp; }
375 : :
376 : 0 : SvxAuthorFormat GetFormat() const { return eFormat; }
377 : 0 : void SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; }
378 : :
379 : : rtl::OUString GetFormatted() const;
380 : :
381 : : virtual SvxFieldData* Clone() const;
382 : : virtual int operator==( const SvxFieldData& ) const;
383 : : };
384 : :
385 : : /** this field is used as a placeholder for a header&footer in impress. The actual
386 : : value is stored at the page */
387 [ - + ]: 666 : class EDITENG_DLLPUBLIC SvxHeaderField : public SvxFieldData
388 : : {
389 : : public:
390 : 151 : SV_DECL_PERSIST1( SvxHeaderField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_HEADER )
391 : : SvxHeaderField();
392 : :
393 : : virtual SvxFieldData* Clone() const;
394 : : virtual int operator==( const SvxFieldData& ) const;
395 : : };
396 : :
397 : : /** this field is used as a placeholder for a header&footer in impress. The actual
398 : : value is stored at the page */
399 [ - + ]: 1006 : class EDITENG_DLLPUBLIC SvxFooterField : public SvxFieldData
400 : : {
401 : : public:
402 : 159 : SV_DECL_PERSIST1( SvxFooterField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_FOOTER )
403 : : SvxFooterField();
404 : : virtual SvxFieldData* Clone() const;
405 : : virtual int operator==( const SvxFieldData& ) const;
406 : : };
407 : :
408 : : /** this field is used as a placeholder for a header&footer in impress. The actual
409 : : value is stored at the page */
410 [ - + ]: 994 : class EDITENG_DLLPUBLIC SvxDateTimeField : public SvxFieldData
411 : : {
412 : : public:
413 : 159 : SV_DECL_PERSIST1( SvxDateTimeField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_DATE_TIME )
414 : : SvxDateTimeField();
415 : :
416 : : static rtl::OUString GetFormatted( Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
417 : :
418 : : virtual SvxFieldData* Clone() const;
419 : : virtual int operator==( const SvxFieldData& ) const;
420 : : };
421 : :
422 : :
423 : :
424 : :
425 : : #endif
426 : :
427 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|