xref: /trunk/main/editeng/inc/editeng/flditem.hxx (revision 4c5491ea)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_FLDITEM_HXX
24 #define _SVX_FLDITEM_HXX
25 
26 #include <i18npool/lang.h>
27 #include <tools/time.hxx>
28 #include <tools/date.hxx>
29 #include <svl/poolitem.hxx>
30 #include <tools/pstm.hxx>
31 #include "editeng/editengdllapi.h"
32 
33 class SvNumberFormatter;
34 class MetaAction;
35 
36 // class SvxFieldItem ---------------------------------------------------
37 
38 
39 
40 class EDITENG_DLLPUBLIC SvxFieldData : public SvPersistBase
41 {
42 public:
43 							SV_DECL_PERSIST1( SvxFieldData, SvPersistBase, 1 )
44 
45 							SvxFieldData();
46 	virtual 				~SvxFieldData();
47 
48 	virtual SvxFieldData*	Clone() const;
49 	virtual int 			operator==( const SvxFieldData& ) const;
50 
51 	virtual MetaAction* createBeginComment() const;
52 	virtual MetaAction* createEndComment() const;
53 };
54 
55 /*
56 [Beschreibung]
57 In diesem Item wird ein Feld (SvxFieldData) gespeichert.
58 Das Feld gehoert dem Item.
59 Das Feld selbst wird durch eine Ableitung von SvxFieldData bestimmt. (RTTI)
60 */
61 
62 class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem
63 {
64 private:
65 	SvxFieldData*			pField;
66 
67 					EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId );
68 
69 public:
70 			TYPEINFO();
71 
72             SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId  );
73 			SvxFieldItem( const SvxFieldItem& rItem );
74 			~SvxFieldItem();
75 
76 	virtual int 			operator==( const SfxPoolItem& ) const;
77 	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
78 	virtual SfxPoolItem*	Create( SvStream&, sal_uInt16 nVer ) const;
79 	virtual SvStream&		Store( SvStream& , sal_uInt16 nItemVersion ) const;
80 
GetField() const81 	const SvxFieldData*		GetField() const 	{ return pField; }
82 	static SvClassManager&	GetClassManager();
83 };
84 
85 // =================================================================
86 // Es folgen die Ableitungen von SvxFieldData...
87 // =================================================================
88 
89 #define SVX_DATEFIELD		2
90 #define SVX_URLFIELD		3
91 
92 #define SVX_PAGEFIELD		100		// Ex-Calc-Felder
93 #define SVX_PAGESFIELD		101
94 #define SVX_TIMEFIELD		102
95 #define SVX_FILEFIELD		103
96 #define SVX_TABLEFIELD		104
97 #define SVX_EXT_TIMEFIELD	105
98 #define SVX_EXT_FILEFIELD	106
99 #define SVX_AUTHORFIELD		107
100 #define SVX_HEADERFIELD		108
101 #define SVX_FOOTERFIELD		109
102 #define SVX_DATEFIMEFIELD	110
103 
104 #define SVX_USERFIELD		200	// Ab hier eigene Felder, nicht im SVX
105 
106 enum SvxDateType { SVXDATETYPE_FIX, SVXDATETYPE_VAR };
107 enum SvxDateFormat {	SVXDATEFORMAT_APPDEFAULT, 	// Wie in App eingestellt
108 						SVXDATEFORMAT_SYSTEM, 		// Wie im System eingestellt
109 						SVXDATEFORMAT_STDSMALL,
110 						SVXDATEFORMAT_STDBIG,
111 						SVXDATEFORMAT_A,	// 13.02.96
112 						SVXDATEFORMAT_B,	// 13.02.1996
113 						SVXDATEFORMAT_C,	// 13.Feb 1996
114 						SVXDATEFORMAT_D,	// 13.Februar 1996
115 						SVXDATEFORMAT_E,	// Die, 13.Februar 1996
116 						SVXDATEFORMAT_F		// Dienstag, 13.Februar 1996
117 					};
118 
119 class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
120 {
121 	sal_uInt32				nFixDate;
122 	SvxDateType				eType;
123 	SvxDateFormat			eFormat;
124 
125 public:
126 							SV_DECL_PERSIST1( SvxDateField, SvxFieldData, SVX_DATEFIELD )
127 
128 							SvxDateField();
129 							SvxDateField( const Date& rDate,
130 								SvxDateType eType = SVXDATETYPE_VAR,
131 								SvxDateFormat eFormat = SVXDATEFORMAT_STDSMALL );
132 
GetFixDate() const133 	sal_uInt32				GetFixDate() const { return nFixDate; }
SetFixDate(const Date & rDate)134 	void					SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); }
135 
GetType() const136 	SvxDateType				GetType() const { return eType; }
SetType(SvxDateType eTp)137 	void					SetType( SvxDateType eTp ) { eType = eTp; }
138 
GetFormat() const139 	SvxDateFormat			GetFormat() const { return eFormat; }
SetFormat(SvxDateFormat eFmt)140 	void					SetFormat( SvxDateFormat eFmt ) { eFormat = eFmt; }
141 
142                             // deprecated, to be removed
143 	String					GetFormatted( LanguageType eLanguage, LanguageType eFormat ) const;
144                             // use this instead
145                             // If eLanguage==LANGUAGE_DONTKNOW the language/country
146                             // used in number formatter initialization is taken.
147     String                  GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
148     static String			GetFormatted( Date& rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
149 
150 	virtual SvxFieldData*	Clone() const;
151 	virtual int 			operator==( const SvxFieldData& ) const;
152 
153 	virtual MetaAction* createBeginComment() const;
154 };
155 
156 
157 enum SvxURLFormat	{	SVXURLFORMAT_APPDEFAULT, 	// Wie in App eingestellt
158 						SVXURLFORMAT_URL,			// URL darstellen
159 						SVXURLFORMAT_REPR			// Repraesentation darstellen
160 					};
161 
162 class EDITENG_DLLPUBLIC SvxURLField : public SvxFieldData
163 {
164 private:
165 	SvxURLFormat			eFormat;
166 	XubString				aURL;      			// URL-Adresse
167 	XubString				aRepresentation;	// Was wird dargestellt
168 	XubString				aTargetFrame;		// In welchem Frame
169 
170 public:
171 							SV_DECL_PERSIST1( SvxURLField, SvxFieldData, SVX_URLFIELD )
172 
173 							SvxURLField();
174 							SvxURLField( const XubString& rURL, const XubString& rRepres, SvxURLFormat eFmt = SVXURLFORMAT_URL );
175 
GetURL() const176 	const XubString&			GetURL() const { return aURL; }
SetURL(const XubString & rURL)177 	void					SetURL( const XubString& rURL ) { aURL = rURL; }
178 
GetRepresentation() const179 	const XubString&			GetRepresentation() const { return aRepresentation; }
SetRepresentation(const XubString & rRep)180 	void					SetRepresentation( const XubString& rRep ) { aRepresentation= rRep; }
181 
GetTargetFrame() const182 	const XubString&			GetTargetFrame() const { return aTargetFrame; }
SetTargetFrame(const XubString & rFrm)183 	void					SetTargetFrame( const XubString& rFrm ) { aTargetFrame = rFrm; }
184 
GetFormat() const185 	SvxURLFormat			GetFormat() const { return eFormat; }
SetFormat(SvxURLFormat eFmt)186 	void					SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
187 
188 	virtual SvxFieldData*	Clone() const;
189 	virtual int 			operator==( const SvxFieldData& ) const;
190 
191 	virtual MetaAction* createBeginComment() const;
192 };
193 
194 class EDITENG_DLLPUBLIC SvxPageField : public SvxFieldData
195 {
196 public:
SV_DECL_PERSIST1(SvxPageField,SvxFieldData,SVX_PAGEFIELD)197 							SV_DECL_PERSIST1( SvxPageField, SvxFieldData, SVX_PAGEFIELD )
198 							SvxPageField() {}
199 	virtual SvxFieldData*	Clone() const;
200 	virtual int 			operator==( const SvxFieldData& ) const;
201 
202 	virtual MetaAction* createBeginComment() const;
203 };
204 
205 class EDITENG_DLLPUBLIC SvxPagesField : public SvxFieldData
206 {
207 public:
SV_DECL_PERSIST1(SvxPagesField,SvxFieldData,SVX_PAGESFIELD)208 							SV_DECL_PERSIST1( SvxPagesField, SvxFieldData, SVX_PAGESFIELD )
209 							SvxPagesField() {}
210 	virtual SvxFieldData*	Clone() const;
211 	virtual int 			operator==( const SvxFieldData& ) const;
212 };
213 
214 class EDITENG_DLLPUBLIC SvxTimeField : public SvxFieldData
215 {
216 public:
SV_DECL_PERSIST1(SvxTimeField,SvxFieldData,SVX_TIMEFIELD)217 							SV_DECL_PERSIST1( SvxTimeField, SvxFieldData, SVX_TIMEFIELD )
218 							SvxTimeField() {}
219 	virtual SvxFieldData*	Clone() const;
220 	virtual int 			operator==( const SvxFieldData& ) const;
221 
222 	virtual MetaAction* createBeginComment() const;
223 };
224 
225 class EDITENG_DLLPUBLIC SvxFileField : public SvxFieldData
226 {
227 public:
SV_DECL_PERSIST1(SvxFileField,SvxFieldData,SVX_FILEFIELD)228 							SV_DECL_PERSIST1( SvxFileField, SvxFieldData, SVX_FILEFIELD )
229 							SvxFileField() {}
230 	virtual SvxFieldData*	Clone() const;
231 	virtual int 			operator==( const SvxFieldData& ) const;
232 };
233 
234 class EDITENG_DLLPUBLIC SvxTableField : public SvxFieldData
235 {
236 public:
SV_DECL_PERSIST1(SvxTableField,SvxFieldData,SVX_TABLEFIELD)237 							SV_DECL_PERSIST1( SvxTableField, SvxFieldData, SVX_TABLEFIELD )
238 							SvxTableField() {}
239 	virtual SvxFieldData*	Clone() const;
240 	virtual int 			operator==( const SvxFieldData& ) const;
241 };
242 
243 
244 enum SvxTimeType { SVXTIMETYPE_FIX, SVXTIMETYPE_VAR };
245 enum SvxTimeFormat {	SVXTIMEFORMAT_APPDEFAULT, 	// Wie in App eingestellt
246 						SVXTIMEFORMAT_SYSTEM, 		// Wie im System eingestellt
247 						SVXTIMEFORMAT_STANDARD,
248 						SVXTIMEFORMAT_24_HM,	// 13:49
249 						SVXTIMEFORMAT_24_HMS,	// 13:49:38
250 						SVXTIMEFORMAT_24_HMSH,	// 13:49:38.78
251 						SVXTIMEFORMAT_12_HM,	// 01:49
252 						SVXTIMEFORMAT_12_HMS,	// 01:49:38
253 						SVXTIMEFORMAT_12_HMSH,	// 01:49:38.78
254 						SVXTIMEFORMAT_AM_HM,	// 01:49 PM
255 						SVXTIMEFORMAT_AM_HMS,	// 01:49:38 PM
256 						SVXTIMEFORMAT_AM_HMSH	// 01:49:38.78 PM
257 					};
258 
259 class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData
260 {
261 private:
262 	sal_uInt32				nFixTime;
263 	SvxTimeType				eType;
264 	SvxTimeFormat			eFormat;
265 
266 public:
267 							SV_DECL_PERSIST1( SvxExtTimeField, SvxFieldData, SVX_EXT_TIMEFIELD )
268 							SvxExtTimeField();
269 							SvxExtTimeField( const Time& rTime,
270 								SvxTimeType eType = SVXTIMETYPE_VAR,
271 								SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD );
272 
GetFixTime() const273 	sal_uInt32				GetFixTime() const { return nFixTime; }
SetFixTime(const Time & rTime)274 	void					SetFixTime( const Time& rTime ) { nFixTime = rTime.GetTime(); }
275 
GetType() const276 	SvxTimeType				GetType() const { return eType; }
SetType(SvxTimeType eTp)277 	void					SetType( SvxTimeType eTp ) { eType = eTp; }
278 
GetFormat() const279 	SvxTimeFormat			GetFormat() const { return eFormat; }
SetFormat(SvxTimeFormat eFmt)280 	void					SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; }
281 
282                             // deprecated, to be removed
283 	XubString				GetFormatted( LanguageType eLanguage, LanguageType eFormat ) const;
284                             // use this instead
285                             // If eLanguage==LANGUAGE_DONTKNOW the language/country
286                             // used in number formatter initialization is taken.
287     String                  GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
288 	static String           GetFormatted( Time& rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
289 
290 	virtual SvxFieldData*	Clone() const;
291 	virtual int 			operator==( const SvxFieldData& ) const;
292 
293 	virtual MetaAction* createBeginComment() const;
294 };
295 
296 
297 enum SvxFileType { SVXFILETYPE_FIX, SVXFILETYPE_VAR };
298 enum SvxFileFormat {	SVXFILEFORMAT_NAME_EXT,	// Dateiname mit Extension
299 						SVXFILEFORMAT_FULLPATH,	// vollst�ndiger Pfad
300 						SVXFILEFORMAT_PATH,		// nur Pfad
301 						SVXFILEFORMAT_NAME		// nur Dateiname
302 				   };
303 
304 
305 
306 class EDITENG_DLLPUBLIC SvxExtFileField : public SvxFieldData
307 {
308 private:
309 	XubString  				aFile;
310 	SvxFileType				eType;
311 	SvxFileFormat			eFormat;
312 
313 public:
314 							SV_DECL_PERSIST1( SvxExtFileField, SvxFieldData, SVX_EXT_FILEFIELD )
315 							SvxExtFileField();
316 							SvxExtFileField( const XubString& rString,
317 								SvxFileType eType = SVXFILETYPE_VAR,
318 								SvxFileFormat eFormat = SVXFILEFORMAT_FULLPATH );
319 
GetFile() const320 	String  				GetFile() const { return aFile; }
SetFile(const XubString & rString)321 	void					SetFile( const XubString& rString ) { aFile = rString; }
322 
GetType() const323 	SvxFileType				GetType() const { return eType; }
SetType(SvxFileType eTp)324 	void					SetType( SvxFileType eTp ) { eType = eTp; }
325 
GetFormat() const326 	SvxFileFormat			GetFormat() const { return eFormat; }
SetFormat(SvxFileFormat eFmt)327 	void					SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; }
328 
329 	XubString				GetFormatted() const;
330 
331 	virtual SvxFieldData*	Clone() const;
332 	virtual int 			operator==( const SvxFieldData& ) const;
333 };
334 
335 
336 enum SvxAuthorType { SVXAUTHORTYPE_FIX, SVXAUTHORTYPE_VAR };
337 enum SvxAuthorFormat {	SVXAUTHORFORMAT_FULLNAME,	// vollst�ndiger Name
338 						SVXAUTHORFORMAT_NAME,		// nur Nachname
339 						SVXAUTHORFORMAT_FIRSTNAME,	// nur Vorname
340 						SVXAUTHORFORMAT_SHORTNAME	// Initialen
341 					};
342 
343 class EDITENG_DLLPUBLIC SvxAuthorField : public SvxFieldData
344 {
345 private:
346 	XubString		aName;
347 	XubString		aFirstName;
348 	XubString		aShortName;
349 	SvxAuthorType	eType;
350 	SvxAuthorFormat	eFormat;
351 
352 public:
353 							SV_DECL_PERSIST1( SvxAuthorField, SvxFieldData, SVX_AUTHORFIELD )
354 							SvxAuthorField();
355                             SvxAuthorField(
356                                 const XubString& rFirstName,
357                                 const XubString& rLastName,
358                                 const XubString& rShortName,
359 								SvxAuthorType eType = SVXAUTHORTYPE_VAR,
360 								SvxAuthorFormat eFormat = SVXAUTHORFORMAT_FULLNAME );
361 
GetName() const362 	XubString  				GetName() const { return aName; }
SetName(const XubString & rString)363 	void					SetName( const XubString& rString ) { aName = rString; }
364 
GetFirstName() const365 	XubString  				GetFirstName() const { return aFirstName; }
SetFirstName(const XubString & rString)366 	void					SetFirstName( const XubString& rString ) { aFirstName = rString; }
367 
GetShortName() const368 	XubString  				GetShortName() const { return aShortName; }
SetShortName(const XubString & rString)369 	void					SetShortName( const XubString& rString ) { aShortName = rString; }
370 
GetType() const371 	SvxAuthorType			GetType() const { return eType; }
SetType(SvxAuthorType eTp)372 	void					SetType( SvxAuthorType eTp ) { eType = eTp; }
373 
GetFormat() const374 	SvxAuthorFormat			GetFormat() const { return eFormat; }
SetFormat(SvxAuthorFormat eFmt)375 	void					SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; }
376 
377 	XubString				GetFormatted() const;
378 
379 	virtual SvxFieldData*	Clone() const;
380 	virtual int 			operator==( const SvxFieldData& ) const;
381 };
382 
383 /** this field is used as a placeholder for a header&footer in impress. The actual
384 	value is stored at the page */
385 class EDITENG_DLLPUBLIC SvxHeaderField : public SvxFieldData
386 {
387 public:
SV_DECL_PERSIST1(SvxHeaderField,SvxFieldData,SVX_HEADERFIELD)388 							SV_DECL_PERSIST1( SvxHeaderField, SvxFieldData, SVX_HEADERFIELD )
389 							SvxHeaderField() {}
390 	virtual SvxFieldData*	Clone() const;
391 	virtual int 			operator==( const SvxFieldData& ) const;
392 };
393 
394 /** this field is used as a placeholder for a header&footer in impress. The actual
395 	value is stored at the page */
396 class EDITENG_DLLPUBLIC SvxFooterField : public SvxFieldData
397 {
398 public:
SV_DECL_PERSIST1(SvxFooterField,SvxFieldData,SVX_FOOTERFIELD)399 							SV_DECL_PERSIST1( SvxFooterField, SvxFieldData, SVX_FOOTERFIELD )
400 							SvxFooterField() {}
401 	virtual SvxFieldData*	Clone() const;
402 	virtual int 			operator==( const SvxFieldData& ) const;
403 };
404 
405 /** this field is used as a placeholder for a header&footer in impress. The actual
406 	value is stored at the page */
407 class EDITENG_DLLPUBLIC SvxDateTimeField : public SvxFieldData
408 {
409 public:
SV_DECL_PERSIST1(SvxDateTimeField,SvxFieldData,SVX_DATEFIMEFIELD)410 							SV_DECL_PERSIST1( SvxDateTimeField, SvxFieldData, SVX_DATEFIMEFIELD )
411 							SvxDateTimeField() {}
412 
413 	static String           GetFormatted( Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
414 
415 	virtual SvxFieldData*	Clone() const;
416 	virtual int 			operator==( const SvxFieldData& ) const;
417 };
418 
419 
420 
421 
422 #endif
423 
424