xref: /aoo41x/main/editeng/source/items/flditem.cxx (revision 190118d0)
1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*190118d0SAndrew Rist  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19*190118d0SAndrew Rist  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir #include <vcl/metaact.hxx>
27cdf0e10cSrcweir #include <svl/zforlist.hxx>
28cdf0e10cSrcweir #include <tools/urlobj.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #define _SVX_FLDITEM_CXX
31cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <editeng/flditem.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <editeng/measfld.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir // #90477#
38cdf0e10cSrcweir #include <tools/tenccvt.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define FRAME_MARKER	(sal_uInt32)0x21981357
41cdf0e10cSrcweir #define CHARSET_MARKER	(FRAME_MARKER+1)
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // -----------------------------------------------------------------------
44cdf0e10cSrcweir 
45cdf0e10cSrcweir TYPEINIT1( SvxFieldItem, SfxPoolItem );
46cdf0e10cSrcweir 
47cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxFieldData, SvPersistBase );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir // -----------------------------------------------------------------------
50cdf0e10cSrcweir 
SvxFieldData()51cdf0e10cSrcweir SvxFieldData::SvxFieldData()
52cdf0e10cSrcweir {
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // -----------------------------------------------------------------------
56cdf0e10cSrcweir 
~SvxFieldData()57cdf0e10cSrcweir SvxFieldData::~SvxFieldData()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // -----------------------------------------------------------------------
62cdf0e10cSrcweir 
Clone() const63cdf0e10cSrcweir SvxFieldData* SvxFieldData::Clone() const
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	return new SvxFieldData;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
68cdf0e10cSrcweir // -----------------------------------------------------------------------
69cdf0e10cSrcweir 
operator ==(const SvxFieldData & rFld) const70cdf0e10cSrcweir int SvxFieldData::operator==( const SvxFieldData& rFld ) const
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	DBG_ASSERT( Type() == rFld.Type(), "==: Verschiedene Typen" );
73cdf0e10cSrcweir 	(void)rFld;
74cdf0e10cSrcweir 	return sal_True;	// Basicklasse immer gleich.
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir // -----------------------------------------------------------------------
78cdf0e10cSrcweir 
Load(SvPersistStream &)79cdf0e10cSrcweir void SvxFieldData::Load( SvPersistStream & /*rStm*/ )
80cdf0e10cSrcweir {
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir // -----------------------------------------------------------------------
84cdf0e10cSrcweir 
Save(SvPersistStream &)85cdf0e10cSrcweir void SvxFieldData::Save( SvPersistStream & /*rStm*/ )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
createBeginComment() const90cdf0e10cSrcweir MetaAction* SvxFieldData::createBeginComment() const
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
createEndComment() const95cdf0e10cSrcweir MetaAction* SvxFieldData::createEndComment() const
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	return new MetaCommentAction( "FIELD_SEQ_END" );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // -----------------------------------------------------------------------
101cdf0e10cSrcweir 
SvxFieldItem(SvxFieldData * pFld,const sal_uInt16 nId)102cdf0e10cSrcweir SvxFieldItem::SvxFieldItem( SvxFieldData* pFld, const sal_uInt16 nId ) :
103cdf0e10cSrcweir 	SfxPoolItem( nId )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	pField = pFld;	// gehoert direkt dem Item
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir // -----------------------------------------------------------------------
109cdf0e10cSrcweir 
SvxFieldItem(const SvxFieldData & rField,const sal_uInt16 nId)110cdf0e10cSrcweir SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) :
111cdf0e10cSrcweir 	SfxPoolItem( nId )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	pField = rField.Clone();
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // -----------------------------------------------------------------------
117cdf0e10cSrcweir 
SvxFieldItem(const SvxFieldItem & rItem)118cdf0e10cSrcweir SvxFieldItem::SvxFieldItem( const SvxFieldItem& rItem ) :
119cdf0e10cSrcweir 	SfxPoolItem	( rItem )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	pField = rItem.GetField() ? rItem.GetField()->Clone() : 0;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir // -----------------------------------------------------------------------
125cdf0e10cSrcweir 
~SvxFieldItem()126cdf0e10cSrcweir SvxFieldItem::~SvxFieldItem()
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	delete pField;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir // -----------------------------------------------------------------------
132cdf0e10cSrcweir 
Clone(SfxItemPool *) const133cdf0e10cSrcweir SfxPoolItem* SvxFieldItem::Clone( SfxItemPool* ) const
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	return new SvxFieldItem(*this);
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // -----------------------------------------------------------------------
139cdf0e10cSrcweir 
Create(SvStream & rStrm,sal_uInt16) const140cdf0e10cSrcweir SfxPoolItem* SvxFieldItem::Create( SvStream& rStrm, sal_uInt16 ) const
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	SvxFieldData* pData = 0;
143cdf0e10cSrcweir 	SvPersistStream aPStrm( GetClassManager(), &rStrm );
144cdf0e10cSrcweir 	aPStrm >> pData;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	if( aPStrm.IsEof() )
147cdf0e10cSrcweir 		aPStrm.SetError( SVSTREAM_GENERALERROR );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	if ( aPStrm.GetError() == ERRCODE_IO_NOFACTORY )
150cdf0e10cSrcweir 		aPStrm.ResetError();	// Eigentlich einen Code, dass nicht alle Attr gelesen wurden...
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	return new SvxFieldItem( pData, Which() );
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir // -----------------------------------------------------------------------
156cdf0e10cSrcweir 
Store(SvStream & rStrm,sal_uInt16) const157cdf0e10cSrcweir SvStream& SvxFieldItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
158cdf0e10cSrcweir {
159cdf0e10cSrcweir 	DBG_ASSERT( pField, "SvxFieldItem::Store: Feld?!" );
160cdf0e10cSrcweir 	SvPersistStream aPStrm( GetClassManager(), &rStrm );
161cdf0e10cSrcweir 	// Das ResetError in der obigen Create-Methode gab es in 3.1 noch nicht,
162cdf0e10cSrcweir 	// deshalb duerfen beim 3.x-Export neuere Items nicht gespeichert werden!
163cdf0e10cSrcweir 	if ( ( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_31 ) && pField &&
164cdf0e10cSrcweir 			pField->GetClassId() == 50 /* SdrMeasureField */ )
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir 		// SvxFieldData reicht nicht, weil auch nicht am ClassMgr angemeldet
167cdf0e10cSrcweir 		SvxURLField aDummyData;
168cdf0e10cSrcweir 		aPStrm << &aDummyData;
169cdf0e10cSrcweir 	}
170cdf0e10cSrcweir 	else
171cdf0e10cSrcweir 		aPStrm << pField;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	return rStrm;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir // -----------------------------------------------------------------------
177cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rItem) const178cdf0e10cSrcweir int SvxFieldItem::operator==( const SfxPoolItem& rItem ) const
179cdf0e10cSrcweir {
180cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	const SvxFieldData* pOtherFld = ((const SvxFieldItem&)rItem).GetField();
183cdf0e10cSrcweir 	if ( !pField && !pOtherFld )
184cdf0e10cSrcweir 		return sal_True;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	if ( ( !pField && pOtherFld ) || ( pField && !pOtherFld ) )
187cdf0e10cSrcweir 		return sal_False;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	return ( ( pField->Type() == pOtherFld->Type() )
190cdf0e10cSrcweir 				&& ( *pField == *pOtherFld ) );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir // =================================================================
194cdf0e10cSrcweir // Es folgen die Ableitungen von SvxFieldData...
195cdf0e10cSrcweir // =================================================================
196cdf0e10cSrcweir 
197cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxDateField, SvxFieldData );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir // -----------------------------------------------------------------------
200cdf0e10cSrcweir 
SvxDateField()201cdf0e10cSrcweir SvxDateField::SvxDateField()
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	nFixDate = Date().GetDate();
204cdf0e10cSrcweir 	eType = SVXDATETYPE_VAR;
205cdf0e10cSrcweir 	eFormat = SVXDATEFORMAT_STDSMALL;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir // -----------------------------------------------------------------------
209cdf0e10cSrcweir 
SvxDateField(const Date & rDate,SvxDateType eT,SvxDateFormat eF)210cdf0e10cSrcweir SvxDateField::SvxDateField( const Date& rDate, SvxDateType eT, SvxDateFormat eF )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	nFixDate = rDate.GetDate();
213cdf0e10cSrcweir 	eType = eT;
214cdf0e10cSrcweir 	eFormat = eF;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir // -----------------------------------------------------------------------
218cdf0e10cSrcweir 
Clone() const219cdf0e10cSrcweir SvxFieldData* SvxDateField::Clone() const
220cdf0e10cSrcweir {
221cdf0e10cSrcweir 	return new SvxDateField( *this );
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir // -----------------------------------------------------------------------
225cdf0e10cSrcweir 
operator ==(const SvxFieldData & rOther) const226cdf0e10cSrcweir int SvxDateField::operator==( const SvxFieldData& rOther ) const
227cdf0e10cSrcweir {
228cdf0e10cSrcweir 	if ( rOther.Type() != Type() )
229cdf0e10cSrcweir 		return sal_False;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	const SvxDateField& rOtherFld = (const SvxDateField&) rOther;
232cdf0e10cSrcweir 	return ( ( nFixDate == rOtherFld.nFixDate ) &&
233cdf0e10cSrcweir 				( eType == rOtherFld.eType ) &&
234cdf0e10cSrcweir 				( eFormat == rOtherFld.eFormat ) );
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir // -----------------------------------------------------------------------
238cdf0e10cSrcweir 
Load(SvPersistStream & rStm)239cdf0e10cSrcweir void SvxDateField::Load( SvPersistStream & rStm )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	sal_uInt16 nType, nFormat;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	rStm >> nFixDate;
244cdf0e10cSrcweir 	rStm >> nType;
245cdf0e10cSrcweir 	rStm >> nFormat;
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	eType = (SvxDateType)nType;
248cdf0e10cSrcweir 	eFormat= (SvxDateFormat)nFormat;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir // -----------------------------------------------------------------------
252cdf0e10cSrcweir 
Save(SvPersistStream & rStm)253cdf0e10cSrcweir void SvxDateField::Save( SvPersistStream & rStm )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir 	rStm << nFixDate;
256cdf0e10cSrcweir 	rStm << (sal_uInt16)eType;
257cdf0e10cSrcweir 	rStm << (sal_uInt16)eFormat;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir // -----------------------------------------------------------------------
261cdf0e10cSrcweir 
GetFormatted(SvNumberFormatter & rFormatter,LanguageType eLang) const262cdf0e10cSrcweir String SvxDateField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     Date aDate; // current date
265cdf0e10cSrcweir 	if ( eType == SVXDATETYPE_FIX )
266cdf0e10cSrcweir 		aDate.SetDate( nFixDate );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	return GetFormatted( aDate, eFormat, rFormatter, eLang );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
GetFormatted(Date & aDate,SvxDateFormat eFormat,SvNumberFormatter & rFormatter,LanguageType eLang)271cdf0e10cSrcweir String SvxDateField::GetFormatted( Date& aDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir 	if ( eFormat == SVXDATEFORMAT_SYSTEM )
274cdf0e10cSrcweir 	{
275cdf0e10cSrcweir 		DBG_ERROR( "SVXDATEFORMAT_SYSTEM nicht implementiert!" );
276cdf0e10cSrcweir 		eFormat = SVXDATEFORMAT_STDSMALL;
277cdf0e10cSrcweir 	}
278cdf0e10cSrcweir 	else if ( eFormat == SVXDATEFORMAT_APPDEFAULT )
279cdf0e10cSrcweir 	{
280cdf0e10cSrcweir 		DBG_ERROR( "SVXDATEFORMAT_APPDEFAULT: Woher nehmen?" );
281cdf0e10cSrcweir 		eFormat = SVXDATEFORMAT_STDSMALL;
282cdf0e10cSrcweir 	}
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     sal_uLong nFormatKey;
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	switch( eFormat )
287cdf0e10cSrcweir 	{
288cdf0e10cSrcweir 		case SVXDATEFORMAT_STDSMALL:
289cdf0e10cSrcweir             // short
290cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang );
291cdf0e10cSrcweir 		break;
292cdf0e10cSrcweir 		case SVXDATEFORMAT_STDBIG:
293cdf0e10cSrcweir             // long
294cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_LONG, eLang );
295cdf0e10cSrcweir 		break;
296cdf0e10cSrcweir 		case SVXDATEFORMAT_A:
297cdf0e10cSrcweir 			// 13.02.96
298cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYY, eLang );
299cdf0e10cSrcweir 		break;
300cdf0e10cSrcweir 		case SVXDATEFORMAT_B:
301cdf0e10cSrcweir 			// 13.02.1996
302cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
303cdf0e10cSrcweir 		break;
304cdf0e10cSrcweir 		case SVXDATEFORMAT_C:
305cdf0e10cSrcweir             // 13. Feb 1996
306cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMYYYY, eLang );
307cdf0e10cSrcweir 		break;
308cdf0e10cSrcweir 		case SVXDATEFORMAT_D:
309cdf0e10cSrcweir             // 13. Februar 1996
310cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMMYYYY, eLang );
311cdf0e10cSrcweir 		break;
312cdf0e10cSrcweir 		case SVXDATEFORMAT_E:
313cdf0e10cSrcweir             // Die, 13. Februar 1996
314cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNDMMMMYYYY, eLang );
315cdf0e10cSrcweir 		break;
316cdf0e10cSrcweir 		case SVXDATEFORMAT_F:
317cdf0e10cSrcweir             // Dienstag, 13. Februar 1996
318cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY, eLang );
319cdf0e10cSrcweir 		break;
320cdf0e10cSrcweir         default:
321cdf0e10cSrcweir             nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_DATE, eLang );
322cdf0e10cSrcweir 	}
323cdf0e10cSrcweir 
324cdf0e10cSrcweir     double fDiffDate = aDate - *(rFormatter.GetNullDate());
325cdf0e10cSrcweir     String aStr;
326cdf0e10cSrcweir    	Color* pColor = NULL;
327cdf0e10cSrcweir     rFormatter.GetOutputString( fDiffDate, nFormatKey, aStr, &pColor );
328cdf0e10cSrcweir     return aStr;
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
createBeginComment() const331cdf0e10cSrcweir MetaAction* SvxDateField::createBeginComment() const
332cdf0e10cSrcweir {
333cdf0e10cSrcweir 	return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxURLField, SvxFieldData );
337cdf0e10cSrcweir 
338cdf0e10cSrcweir // -----------------------------------------------------------------------
339cdf0e10cSrcweir 
SvxURLField()340cdf0e10cSrcweir SvxURLField::SvxURLField()
341cdf0e10cSrcweir {
342cdf0e10cSrcweir 	eFormat = SVXURLFORMAT_URL;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir // -----------------------------------------------------------------------
346cdf0e10cSrcweir 
SvxURLField(const XubString & rURL,const XubString & rRepres,SvxURLFormat eFmt)347cdf0e10cSrcweir SvxURLField::SvxURLField( const XubString& rURL, const XubString& rRepres, SvxURLFormat eFmt )
348cdf0e10cSrcweir 	: aURL( rURL ), aRepresentation( rRepres )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir 	eFormat = eFmt;
351cdf0e10cSrcweir }
352cdf0e10cSrcweir 
353cdf0e10cSrcweir // -----------------------------------------------------------------------
354cdf0e10cSrcweir 
Clone() const355cdf0e10cSrcweir SvxFieldData* SvxURLField::Clone() const
356cdf0e10cSrcweir {
357cdf0e10cSrcweir 	return new SvxURLField( *this );
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir // -----------------------------------------------------------------------
361cdf0e10cSrcweir 
operator ==(const SvxFieldData & rOther) const362cdf0e10cSrcweir int SvxURLField::operator==( const SvxFieldData& rOther ) const
363cdf0e10cSrcweir {
364cdf0e10cSrcweir 	if ( rOther.Type() != Type() )
365cdf0e10cSrcweir 		return sal_False;
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 	const SvxURLField& rOtherFld = (const SvxURLField&) rOther;
368cdf0e10cSrcweir 	return ( ( eFormat == rOtherFld.eFormat ) &&
369cdf0e10cSrcweir 				( aURL == rOtherFld.aURL ) &&
370cdf0e10cSrcweir 				( aRepresentation == rOtherFld.aRepresentation ) &&
371cdf0e10cSrcweir 				( aTargetFrame == rOtherFld.aTargetFrame ) );
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir // -----------------------------------------------------------------------
375cdf0e10cSrcweir 
write_unicode(SvPersistStream & rStm,const String & rString)376cdf0e10cSrcweir static void write_unicode( SvPersistStream & rStm, const String& rString )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir 	sal_uInt16 nL = rString.Len();
379cdf0e10cSrcweir 	rStm << nL;
380cdf0e10cSrcweir 	rStm.Write( rString.GetBuffer(), nL*sizeof(sal_Unicode) );
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
read_unicode(SvPersistStream & rStm,String & rString)383cdf0e10cSrcweir static void read_unicode( SvPersistStream & rStm, String& rString )
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 	sal_uInt16 nL = 0;
386cdf0e10cSrcweir 	rStm >> nL;
387cdf0e10cSrcweir 	if ( nL )
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		rString.AllocBuffer( nL );
390cdf0e10cSrcweir 		rStm.Read( rString.GetBufferAccess(), nL*sizeof(sal_Unicode) );
391cdf0e10cSrcweir 		rString.ReleaseBufferAccess( nL );
392cdf0e10cSrcweir 	}
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
Load(SvPersistStream & rStm)395cdf0e10cSrcweir void SvxURLField::Load( SvPersistStream & rStm )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir 	sal_uInt16 nFormat = 0;
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 	rStm >> nFormat;
400cdf0e10cSrcweir 	eFormat= (SvxURLFormat)nFormat;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 	read_unicode( rStm, aURL );
403cdf0e10cSrcweir 	read_unicode( rStm, aRepresentation );
404cdf0e10cSrcweir 	read_unicode( rStm, aTargetFrame );
405cdf0e10cSrcweir }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir // -----------------------------------------------------------------------
408cdf0e10cSrcweir 
Save(SvPersistStream & rStm)409cdf0e10cSrcweir void SvxURLField::Save( SvPersistStream & rStm )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir 	rStm << (sal_uInt16)eFormat;
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 	write_unicode( rStm, aURL );
414cdf0e10cSrcweir 	write_unicode( rStm, aRepresentation );
415cdf0e10cSrcweir 	write_unicode( rStm, aTargetFrame );
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
createBeginComment() const418cdf0e10cSrcweir MetaAction* SvxURLField::createBeginComment() const
419cdf0e10cSrcweir {
420cdf0e10cSrcweir     // #i46618# Adding target URL to metafile comment
421cdf0e10cSrcweir 	return new MetaCommentAction( "FIELD_SEQ_BEGIN",
422cdf0e10cSrcweir                                   0,
423cdf0e10cSrcweir                                   reinterpret_cast<const sal_uInt8*>(aURL.GetBuffer()),
424cdf0e10cSrcweir                                   2*aURL.Len() );
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir // =================================================================
428cdf0e10cSrcweir // Die Felder, die aus Calc ausgebaut wurden:
429cdf0e10cSrcweir // =================================================================
430cdf0e10cSrcweir 
431cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxPageField, SvxFieldData );
432cdf0e10cSrcweir 
Clone() const433cdf0e10cSrcweir SvxFieldData* __EXPORT SvxPageField::Clone() const
434cdf0e10cSrcweir {
435cdf0e10cSrcweir 	return new SvxPageField;		// leer
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const438cdf0e10cSrcweir int __EXPORT SvxPageField::operator==( const SvxFieldData& rCmp ) const
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxPageField) );
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
Load(SvPersistStream &)443cdf0e10cSrcweir void __EXPORT SvxPageField::Load( SvPersistStream & /*rStm*/ )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
Save(SvPersistStream &)447cdf0e10cSrcweir void __EXPORT SvxPageField::Save( SvPersistStream & /*rStm*/ )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir }
450cdf0e10cSrcweir 
createBeginComment() const451cdf0e10cSrcweir MetaAction* SvxPageField::createBeginComment() const
452cdf0e10cSrcweir {
453cdf0e10cSrcweir     return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageField" );
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 
457cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxPagesField, SvxFieldData );
458cdf0e10cSrcweir 
Clone() const459cdf0e10cSrcweir SvxFieldData* __EXPORT SvxPagesField::Clone() const
460cdf0e10cSrcweir {
461cdf0e10cSrcweir 	return new SvxPagesField;	// leer
462cdf0e10cSrcweir }
463cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const464cdf0e10cSrcweir int __EXPORT SvxPagesField::operator==( const SvxFieldData& rCmp ) const
465cdf0e10cSrcweir {
466cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxPagesField) );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
Load(SvPersistStream &)469cdf0e10cSrcweir void __EXPORT SvxPagesField::Load( SvPersistStream & /*rStm*/ )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir }
472cdf0e10cSrcweir 
Save(SvPersistStream &)473cdf0e10cSrcweir void __EXPORT SvxPagesField::Save( SvPersistStream & /*rStm*/ )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
477cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxTimeField, SvxFieldData );
478cdf0e10cSrcweir 
Clone() const479cdf0e10cSrcweir SvxFieldData* __EXPORT SvxTimeField::Clone() const
480cdf0e10cSrcweir {
481cdf0e10cSrcweir 	return new SvxTimeField;	// leer
482cdf0e10cSrcweir }
483cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const484cdf0e10cSrcweir int __EXPORT SvxTimeField::operator==( const SvxFieldData& rCmp ) const
485cdf0e10cSrcweir {
486cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxTimeField) );
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
Load(SvPersistStream &)489cdf0e10cSrcweir void __EXPORT SvxTimeField::Load( SvPersistStream & /*rStm*/ )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
Save(SvPersistStream &)493cdf0e10cSrcweir void __EXPORT SvxTimeField::Save( SvPersistStream & /*rStm*/ )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir }
496cdf0e10cSrcweir 
createBeginComment() const497cdf0e10cSrcweir MetaAction* SvxTimeField::createBeginComment() const
498cdf0e10cSrcweir {
499cdf0e10cSrcweir 	return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxFileField, SvxFieldData );
503cdf0e10cSrcweir 
Clone() const504cdf0e10cSrcweir SvxFieldData* __EXPORT SvxFileField::Clone() const
505cdf0e10cSrcweir {
506cdf0e10cSrcweir 	return new SvxFileField;	// leer
507cdf0e10cSrcweir }
508cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const509cdf0e10cSrcweir int __EXPORT SvxFileField::operator==( const SvxFieldData& rCmp ) const
510cdf0e10cSrcweir {
511cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxFileField) );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir 
Load(SvPersistStream &)514cdf0e10cSrcweir void __EXPORT SvxFileField::Load( SvPersistStream & /*rStm*/ )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
Save(SvPersistStream &)518cdf0e10cSrcweir void __EXPORT SvxFileField::Save( SvPersistStream & /*rStm*/ )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxTableField, SvxFieldData );
523cdf0e10cSrcweir 
Clone() const524cdf0e10cSrcweir SvxFieldData* __EXPORT SvxTableField::Clone() const
525cdf0e10cSrcweir {
526cdf0e10cSrcweir 	return new SvxTableField;	// leer
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const529cdf0e10cSrcweir int __EXPORT SvxTableField::operator==( const SvxFieldData& rCmp ) const
530cdf0e10cSrcweir {
531cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxTableField) );
532cdf0e10cSrcweir }
533cdf0e10cSrcweir 
Load(SvPersistStream &)534cdf0e10cSrcweir void __EXPORT SvxTableField::Load( SvPersistStream & /*rStm*/ )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
Save(SvPersistStream &)538cdf0e10cSrcweir void __EXPORT SvxTableField::Save( SvPersistStream & /*rStm*/ )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir }
541cdf0e10cSrcweir 
542cdf0e10cSrcweir //----------------------------------------------------------------------------
543cdf0e10cSrcweir //		SvxExtTimeField
544cdf0e10cSrcweir //----------------------------------------------------------------------------
545cdf0e10cSrcweir 
546cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxExtTimeField, SvxFieldData );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir //----------------------------------------------------------------------------
549cdf0e10cSrcweir 
SvxExtTimeField()550cdf0e10cSrcweir SvxExtTimeField::SvxExtTimeField()
551cdf0e10cSrcweir {
552cdf0e10cSrcweir 	nFixTime = Time().GetTime();
553cdf0e10cSrcweir 	eType = SVXTIMETYPE_VAR;
554cdf0e10cSrcweir 	eFormat = SVXTIMEFORMAT_STANDARD;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir //----------------------------------------------------------------------------
558cdf0e10cSrcweir 
SvxExtTimeField(const Time & rTime,SvxTimeType eT,SvxTimeFormat eF)559cdf0e10cSrcweir SvxExtTimeField::SvxExtTimeField( const Time& rTime, SvxTimeType eT, SvxTimeFormat eF )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir 	nFixTime = rTime.GetTime();
562cdf0e10cSrcweir 	eType = eT;
563cdf0e10cSrcweir 	eFormat = eF;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir //----------------------------------------------------------------------------
567cdf0e10cSrcweir 
Clone() const568cdf0e10cSrcweir SvxFieldData* SvxExtTimeField::Clone() const
569cdf0e10cSrcweir {
570cdf0e10cSrcweir 	return new SvxExtTimeField( *this );
571cdf0e10cSrcweir }
572cdf0e10cSrcweir 
573cdf0e10cSrcweir //----------------------------------------------------------------------------
574cdf0e10cSrcweir 
operator ==(const SvxFieldData & rOther) const575cdf0e10cSrcweir int SvxExtTimeField::operator==( const SvxFieldData& rOther ) const
576cdf0e10cSrcweir {
577cdf0e10cSrcweir 	if ( rOther.Type() != Type() )
578cdf0e10cSrcweir 		return sal_False;
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 	const SvxExtTimeField& rOtherFld = (const SvxExtTimeField&) rOther;
581cdf0e10cSrcweir 	return ( ( nFixTime == rOtherFld.nFixTime ) &&
582cdf0e10cSrcweir 				( eType == rOtherFld.eType ) &&
583cdf0e10cSrcweir 				( eFormat == rOtherFld.eFormat ) );
584cdf0e10cSrcweir }
585cdf0e10cSrcweir 
586cdf0e10cSrcweir //----------------------------------------------------------------------------
587cdf0e10cSrcweir 
Load(SvPersistStream & rStm)588cdf0e10cSrcweir void SvxExtTimeField::Load( SvPersistStream & rStm )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir 	sal_uInt16 nType, nFormat;
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 	rStm >> nFixTime;
593cdf0e10cSrcweir 	rStm >> nType;
594cdf0e10cSrcweir 	rStm >> nFormat;
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	eType = (SvxTimeType) nType;
597cdf0e10cSrcweir 	eFormat= (SvxTimeFormat) nFormat;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir //----------------------------------------------------------------------------
601cdf0e10cSrcweir 
Save(SvPersistStream & rStm)602cdf0e10cSrcweir void SvxExtTimeField::Save( SvPersistStream & rStm )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	rStm << nFixTime;
605cdf0e10cSrcweir 	rStm << (sal_uInt16) eType;
606cdf0e10cSrcweir 	rStm << (sal_uInt16) eFormat;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
609cdf0e10cSrcweir //----------------------------------------------------------------------------
610cdf0e10cSrcweir 
GetFormatted(SvNumberFormatter & rFormatter,LanguageType eLang) const611cdf0e10cSrcweir String SvxExtTimeField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const
612cdf0e10cSrcweir {
613cdf0e10cSrcweir     Time aTime; // current time
614cdf0e10cSrcweir 	if ( eType == SVXTIMETYPE_FIX )
615cdf0e10cSrcweir 		aTime.SetTime( nFixTime );
616cdf0e10cSrcweir 	return GetFormatted( aTime, eFormat, rFormatter, eLang );
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
GetFormatted(Time & aTime,SvxTimeFormat eFormat,SvNumberFormatter & rFormatter,LanguageType eLang)619cdf0e10cSrcweir String SvxExtTimeField::GetFormatted( Time& aTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir 	switch( eFormat )
622cdf0e10cSrcweir 	{
623cdf0e10cSrcweir         case SVXTIMEFORMAT_SYSTEM :
624cdf0e10cSrcweir             DBG_ERROR( "SVXTIMEFORMAT_SYSTEM: not implemented" );
625cdf0e10cSrcweir             eFormat = SVXTIMEFORMAT_STANDARD;
626cdf0e10cSrcweir         break;
627cdf0e10cSrcweir         case SVXTIMEFORMAT_APPDEFAULT :
628cdf0e10cSrcweir             DBG_ERROR( "SVXTIMEFORMAT_APPDEFAULT: not implemented" );
629cdf0e10cSrcweir             eFormat = SVXTIMEFORMAT_STANDARD;
630cdf0e10cSrcweir         break;
631cdf0e10cSrcweir         default: ;//prevent warning
632cdf0e10cSrcweir     }
633cdf0e10cSrcweir 
634cdf0e10cSrcweir     sal_uInt32 nFormatKey;
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 	switch( eFormat )
637cdf0e10cSrcweir 	{
638cdf0e10cSrcweir 		case SVXTIMEFORMAT_12_HM:
639cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMAMPM, eLang );
640cdf0e10cSrcweir 		break;
641cdf0e10cSrcweir         case SVXTIMEFORMAT_12_HMSH:
642cdf0e10cSrcweir         {   // no builtin format available, try to insert or reuse
643cdf0e10cSrcweir             String aFormatCode( RTL_CONSTASCII_USTRINGPARAM( "HH:MM:SS.00 AM/PM" ) );
644cdf0e10cSrcweir             xub_StrLen nCheckPos;
645cdf0e10cSrcweir             short nType;
646cdf0e10cSrcweir             /*sal_Bool bInserted = */rFormatter.PutandConvertEntry( aFormatCode,
647cdf0e10cSrcweir                 nCheckPos, nType, nFormatKey, LANGUAGE_ENGLISH_US, eLang );
648cdf0e10cSrcweir             DBG_ASSERT( nCheckPos == 0, "SVXTIMEFORMAT_12_HMSH: could not insert format code" );
649cdf0e10cSrcweir             if ( nCheckPos )
650cdf0e10cSrcweir                 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
651cdf0e10cSrcweir         }
652cdf0e10cSrcweir         break;
653cdf0e10cSrcweir 		case SVXTIMEFORMAT_24_HM:
654cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMM, eLang );
655cdf0e10cSrcweir 		break;
656cdf0e10cSrcweir 		case SVXTIMEFORMAT_24_HMSH:
657cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
658cdf0e10cSrcweir 		break;
659cdf0e10cSrcweir 		case SVXTIMEFORMAT_12_HMS:
660cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSSAMPM, eLang );
661cdf0e10cSrcweir 		break;
662cdf0e10cSrcweir 		case SVXTIMEFORMAT_24_HMS:
663cdf0e10cSrcweir             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSS, eLang );
664cdf0e10cSrcweir 		break;
665cdf0e10cSrcweir 		case SVXTIMEFORMAT_STANDARD:
666cdf0e10cSrcweir         default:
667cdf0e10cSrcweir             nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_TIME, eLang );
668cdf0e10cSrcweir 	}
669cdf0e10cSrcweir 
670cdf0e10cSrcweir     double fFracTime = aTime.GetTimeInDays();
671cdf0e10cSrcweir     String aStr;
672cdf0e10cSrcweir    	Color* pColor = NULL;
673cdf0e10cSrcweir     rFormatter.GetOutputString( fFracTime, nFormatKey, aStr, &pColor );
674cdf0e10cSrcweir     return aStr;
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
createBeginComment() const677cdf0e10cSrcweir MetaAction* SvxExtTimeField::createBeginComment() const
678cdf0e10cSrcweir {
679cdf0e10cSrcweir 	return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
680cdf0e10cSrcweir }
681cdf0e10cSrcweir 
682cdf0e10cSrcweir //----------------------------------------------------------------------------
683cdf0e10cSrcweir //		SvxExtFileField
684cdf0e10cSrcweir //----------------------------------------------------------------------------
685cdf0e10cSrcweir 
686cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxExtFileField, SvxFieldData );
687cdf0e10cSrcweir 
688cdf0e10cSrcweir //----------------------------------------------------------------------------
689cdf0e10cSrcweir 
SvxExtFileField()690cdf0e10cSrcweir SvxExtFileField::SvxExtFileField()
691cdf0e10cSrcweir {
692cdf0e10cSrcweir 	eType = SVXFILETYPE_VAR;
693cdf0e10cSrcweir 	eFormat = SVXFILEFORMAT_FULLPATH;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir //----------------------------------------------------------------------------
697cdf0e10cSrcweir 
SvxExtFileField(const XubString & rStr,SvxFileType eT,SvxFileFormat eF)698cdf0e10cSrcweir SvxExtFileField::SvxExtFileField( const XubString& rStr, SvxFileType eT, SvxFileFormat eF )
699cdf0e10cSrcweir {
700cdf0e10cSrcweir 	aFile = rStr;
701cdf0e10cSrcweir 	eType = eT;
702cdf0e10cSrcweir 	eFormat = eF;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir 
705cdf0e10cSrcweir //----------------------------------------------------------------------------
706cdf0e10cSrcweir 
Clone() const707cdf0e10cSrcweir SvxFieldData* SvxExtFileField::Clone() const
708cdf0e10cSrcweir {
709cdf0e10cSrcweir 	return new SvxExtFileField( *this );
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir //----------------------------------------------------------------------------
713cdf0e10cSrcweir 
operator ==(const SvxFieldData & rOther) const714cdf0e10cSrcweir int SvxExtFileField::operator==( const SvxFieldData& rOther ) const
715cdf0e10cSrcweir {
716cdf0e10cSrcweir 	if ( rOther.Type() != Type() )
717cdf0e10cSrcweir 		return sal_False;
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 	const SvxExtFileField& rOtherFld = (const SvxExtFileField&) rOther;
720cdf0e10cSrcweir 	return ( ( aFile == rOtherFld.aFile ) &&
721cdf0e10cSrcweir 				( eType == rOtherFld.eType ) &&
722cdf0e10cSrcweir 				( eFormat == rOtherFld.eFormat ) );
723cdf0e10cSrcweir }
724cdf0e10cSrcweir 
725cdf0e10cSrcweir //----------------------------------------------------------------------------
726cdf0e10cSrcweir 
Load(SvPersistStream & rStm)727cdf0e10cSrcweir void SvxExtFileField::Load( SvPersistStream & rStm )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir 	sal_uInt16 nType, nFormat;
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 	// UNICODE: rStm >> aFile;
732cdf0e10cSrcweir 	rStm.ReadByteString(aFile);
733cdf0e10cSrcweir 
734cdf0e10cSrcweir 	rStm >> nType;
735cdf0e10cSrcweir 	rStm >> nFormat;
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 	eType = (SvxFileType) nType;
738cdf0e10cSrcweir 	eFormat= (SvxFileFormat) nFormat;
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir //----------------------------------------------------------------------------
742cdf0e10cSrcweir 
Save(SvPersistStream & rStm)743cdf0e10cSrcweir void SvxExtFileField::Save( SvPersistStream & rStm )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir 	// UNICODE: rStm << aFile;
746cdf0e10cSrcweir 	rStm.WriteByteString(aFile);
747cdf0e10cSrcweir 
748cdf0e10cSrcweir 	rStm << (sal_uInt16) eType;
749cdf0e10cSrcweir 	rStm << (sal_uInt16) eFormat;
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir //----------------------------------------------------------------------------
753cdf0e10cSrcweir 
GetFormatted() const754cdf0e10cSrcweir XubString SvxExtFileField::GetFormatted() const
755cdf0e10cSrcweir {
756cdf0e10cSrcweir 	XubString aString;
757cdf0e10cSrcweir 
758cdf0e10cSrcweir 	INetURLObject aURLObj( aFile );
759cdf0e10cSrcweir 
760cdf0e10cSrcweir     if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
761cdf0e10cSrcweir     {
762cdf0e10cSrcweir         // invalid? try to interpret string as system file name
763cdf0e10cSrcweir         String aURLStr;
764cdf0e10cSrcweir 
765cdf0e10cSrcweir         ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile, aURLStr );
766cdf0e10cSrcweir 
767cdf0e10cSrcweir         aURLObj.SetURL( aURLStr );
768cdf0e10cSrcweir     }
769cdf0e10cSrcweir 
770cdf0e10cSrcweir     // #92009# Be somewhat liberate when trying to
771cdf0e10cSrcweir     // get formatted content out of the FileField
772cdf0e10cSrcweir     if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
773cdf0e10cSrcweir     {
774cdf0e10cSrcweir         // still not valid? Then output as is
775cdf0e10cSrcweir         aString = aFile;
776cdf0e10cSrcweir     }
777cdf0e10cSrcweir 	else if( INET_PROT_FILE == aURLObj.GetProtocol() )
778cdf0e10cSrcweir 	{
779cdf0e10cSrcweir 		switch( eFormat )
780cdf0e10cSrcweir 		{
781cdf0e10cSrcweir 			case SVXFILEFORMAT_FULLPATH:
782cdf0e10cSrcweir 				aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT);
783cdf0e10cSrcweir 			break;
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 			case SVXFILEFORMAT_PATH:
786cdf0e10cSrcweir                 aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false);
787cdf0e10cSrcweir                 // #101742# Leave trailing slash at the pathname
788cdf0e10cSrcweir                 aURLObj.setFinalSlash();
789cdf0e10cSrcweir 				aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT);
790cdf0e10cSrcweir 			break;
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 			case SVXFILEFORMAT_NAME:
793cdf0e10cSrcweir 				aString = aURLObj.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
794cdf0e10cSrcweir 			break;
795cdf0e10cSrcweir 
796cdf0e10cSrcweir 			case SVXFILEFORMAT_NAME_EXT:
797cdf0e10cSrcweir 				aString = aURLObj.getName(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
798cdf0e10cSrcweir 			break;
799cdf0e10cSrcweir 		}
800cdf0e10cSrcweir 	}
801cdf0e10cSrcweir 	else
802cdf0e10cSrcweir 	{
803cdf0e10cSrcweir 		switch( eFormat )
804cdf0e10cSrcweir 		{
805cdf0e10cSrcweir 			case SVXFILEFORMAT_FULLPATH:
806cdf0e10cSrcweir 				aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
807cdf0e10cSrcweir 			break;
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 			case SVXFILEFORMAT_PATH:
810cdf0e10cSrcweir                 aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false);
811cdf0e10cSrcweir                 // #101742# Leave trailing slash at the pathname
812cdf0e10cSrcweir                 aURLObj.setFinalSlash();
813cdf0e10cSrcweir 				aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
814cdf0e10cSrcweir 			break;
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 			case SVXFILEFORMAT_NAME:
817cdf0e10cSrcweir 				aString = aURLObj.getBase();
818cdf0e10cSrcweir 			break;
819cdf0e10cSrcweir 
820cdf0e10cSrcweir 			case SVXFILEFORMAT_NAME_EXT:
821cdf0e10cSrcweir 				aString = aURLObj.getName();
822cdf0e10cSrcweir 			break;
823cdf0e10cSrcweir 		}
824cdf0e10cSrcweir 	}
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 	return( aString );
827cdf0e10cSrcweir }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir //----------------------------------------------------------------------------
830cdf0e10cSrcweir //		SvxAuthorField
831cdf0e10cSrcweir //----------------------------------------------------------------------------
832cdf0e10cSrcweir 
833cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxAuthorField, SvxFieldData );
834cdf0e10cSrcweir 
835cdf0e10cSrcweir //----------------------------------------------------------------------------
836cdf0e10cSrcweir 
SvxAuthorField()837cdf0e10cSrcweir SvxAuthorField::SvxAuthorField()
838cdf0e10cSrcweir {
839cdf0e10cSrcweir 	eType = SVXAUTHORTYPE_VAR;
840cdf0e10cSrcweir 	eFormat = SVXAUTHORFORMAT_FULLNAME;
841cdf0e10cSrcweir }
842cdf0e10cSrcweir 
843cdf0e10cSrcweir //----------------------------------------------------------------------------
844cdf0e10cSrcweir 
SvxAuthorField(const XubString & rFirstName,const XubString & rLastName,const XubString & rShortName,SvxAuthorType eT,SvxAuthorFormat eF)845cdf0e10cSrcweir SvxAuthorField::SvxAuthorField( const XubString& rFirstName,
846cdf0e10cSrcweir                                 const XubString& rLastName,
847cdf0e10cSrcweir                                 const XubString& rShortName,
848cdf0e10cSrcweir 									SvxAuthorType eT, SvxAuthorFormat eF )
849cdf0e10cSrcweir {
850cdf0e10cSrcweir     aName      = rLastName;
851cdf0e10cSrcweir     aFirstName = rFirstName;
852cdf0e10cSrcweir     aShortName = rShortName;
853cdf0e10cSrcweir 	eType   = eT;
854cdf0e10cSrcweir 	eFormat = eF;
855cdf0e10cSrcweir }
856cdf0e10cSrcweir 
857cdf0e10cSrcweir //----------------------------------------------------------------------------
858cdf0e10cSrcweir 
Clone() const859cdf0e10cSrcweir SvxFieldData* SvxAuthorField::Clone() const
860cdf0e10cSrcweir {
861cdf0e10cSrcweir 	return new SvxAuthorField( *this );
862cdf0e10cSrcweir }
863cdf0e10cSrcweir 
864cdf0e10cSrcweir //----------------------------------------------------------------------------
865cdf0e10cSrcweir 
operator ==(const SvxFieldData & rOther) const866cdf0e10cSrcweir int SvxAuthorField::operator==( const SvxFieldData& rOther ) const
867cdf0e10cSrcweir {
868cdf0e10cSrcweir 	if ( rOther.Type() != Type() )
869cdf0e10cSrcweir 		return sal_False;
870cdf0e10cSrcweir 
871cdf0e10cSrcweir 	const SvxAuthorField& rOtherFld = (const SvxAuthorField&) rOther;
872cdf0e10cSrcweir 	return ( ( aName == rOtherFld.aName ) &&
873cdf0e10cSrcweir 				( aFirstName == rOtherFld.aFirstName ) &&
874cdf0e10cSrcweir 				( aShortName == rOtherFld.aShortName ) &&
875cdf0e10cSrcweir 				( eType == rOtherFld.eType ) &&
876cdf0e10cSrcweir 				( eFormat == rOtherFld.eFormat ) );
877cdf0e10cSrcweir }
878cdf0e10cSrcweir 
879cdf0e10cSrcweir //----------------------------------------------------------------------------
880cdf0e10cSrcweir 
Load(SvPersistStream & rStm)881cdf0e10cSrcweir void SvxAuthorField::Load( SvPersistStream & rStm )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir 	sal_uInt16 nType = 0, nFormat = 0;
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 	read_unicode( rStm, aName );
886cdf0e10cSrcweir 	read_unicode( rStm, aFirstName );
887cdf0e10cSrcweir 	read_unicode( rStm, aShortName );
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 	rStm >> nType;
890cdf0e10cSrcweir 	rStm >> nFormat;
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 	eType = (SvxAuthorType) nType;
893cdf0e10cSrcweir 	eFormat= (SvxAuthorFormat) nFormat;
894cdf0e10cSrcweir }
895cdf0e10cSrcweir 
896cdf0e10cSrcweir //----------------------------------------------------------------------------
897cdf0e10cSrcweir 
Save(SvPersistStream & rStm)898cdf0e10cSrcweir void SvxAuthorField::Save( SvPersistStream & rStm )
899cdf0e10cSrcweir {
900cdf0e10cSrcweir 	write_unicode( rStm, aName );
901cdf0e10cSrcweir 	write_unicode( rStm, aFirstName );
902cdf0e10cSrcweir 	write_unicode( rStm, aShortName );
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 	rStm << (sal_uInt16) eType;
905cdf0e10cSrcweir 	rStm << (sal_uInt16) eFormat;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir //----------------------------------------------------------------------------
909cdf0e10cSrcweir 
GetFormatted() const910cdf0e10cSrcweir XubString SvxAuthorField::GetFormatted() const
911cdf0e10cSrcweir {
912cdf0e10cSrcweir 	XubString aString;
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 	switch( eFormat )
915cdf0e10cSrcweir 	{
916cdf0e10cSrcweir 		case SVXAUTHORFORMAT_FULLNAME:
917cdf0e10cSrcweir 			aString  = aFirstName;
918cdf0e10cSrcweir 			aString += sal_Unicode(' ');
919cdf0e10cSrcweir 			aString += aName;
920cdf0e10cSrcweir 		break;
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 		case SVXAUTHORFORMAT_NAME:
923cdf0e10cSrcweir 			aString = aName;
924cdf0e10cSrcweir 		break;
925cdf0e10cSrcweir 
926cdf0e10cSrcweir 		case SVXAUTHORFORMAT_FIRSTNAME:
927cdf0e10cSrcweir 			aString = aFirstName;
928cdf0e10cSrcweir 		break;
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 		case SVXAUTHORFORMAT_SHORTNAME:
931cdf0e10cSrcweir 			aString = aShortName;
932cdf0e10cSrcweir 		break;
933cdf0e10cSrcweir 	}
934cdf0e10cSrcweir 
935cdf0e10cSrcweir 	return( aString );
936cdf0e10cSrcweir }
937cdf0e10cSrcweir 
938cdf0e10cSrcweir static SvClassManager* pClassMgr=0;
939cdf0e10cSrcweir 
GetClassManager()940cdf0e10cSrcweir SvClassManager&	SvxFieldItem::GetClassManager()
941cdf0e10cSrcweir {
942cdf0e10cSrcweir 	if ( !pClassMgr )
943cdf0e10cSrcweir 	{
944cdf0e10cSrcweir 		pClassMgr = new SvClassManager;
945cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxFieldData );
946cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxURLField );
947cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxDateField );
948cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxPageField );
949cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxTimeField );
950cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxExtTimeField );
951cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxExtFileField );
952cdf0e10cSrcweir 		pClassMgr->SV_CLASS_REGISTER( SvxAuthorField );
953cdf0e10cSrcweir 	}
954cdf0e10cSrcweir 
955cdf0e10cSrcweir 	return *pClassMgr;
956cdf0e10cSrcweir }
957cdf0e10cSrcweir 
958cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
959cdf0e10cSrcweir 
960cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxHeaderField, SvxFieldData );
961cdf0e10cSrcweir 
Clone() const962cdf0e10cSrcweir SvxFieldData* __EXPORT SvxHeaderField::Clone() const
963cdf0e10cSrcweir {
964cdf0e10cSrcweir 	return new SvxHeaderField;		// leer
965cdf0e10cSrcweir }
966cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const967cdf0e10cSrcweir int __EXPORT SvxHeaderField::operator==( const SvxFieldData& rCmp ) const
968cdf0e10cSrcweir {
969cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxHeaderField) );
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
Load(SvPersistStream &)972cdf0e10cSrcweir void __EXPORT SvxHeaderField::Load( SvPersistStream & /*rStm*/ )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir }
975cdf0e10cSrcweir 
Save(SvPersistStream &)976cdf0e10cSrcweir void __EXPORT SvxHeaderField::Save( SvPersistStream & /*rStm*/ )
977cdf0e10cSrcweir {
978cdf0e10cSrcweir }
979cdf0e10cSrcweir 
980cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
981cdf0e10cSrcweir 
982cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxFooterField, SvxFieldData );
983cdf0e10cSrcweir 
Clone() const984cdf0e10cSrcweir SvxFieldData* __EXPORT SvxFooterField::Clone() const
985cdf0e10cSrcweir {
986cdf0e10cSrcweir 	return new SvxFooterField;		// leer
987cdf0e10cSrcweir }
988cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const989cdf0e10cSrcweir int __EXPORT SvxFooterField::operator==( const SvxFieldData& rCmp ) const
990cdf0e10cSrcweir {
991cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxFooterField) );
992cdf0e10cSrcweir }
993cdf0e10cSrcweir 
Load(SvPersistStream &)994cdf0e10cSrcweir void __EXPORT SvxFooterField::Load( SvPersistStream & /*rStm*/ )
995cdf0e10cSrcweir {
996cdf0e10cSrcweir }
997cdf0e10cSrcweir 
Save(SvPersistStream &)998cdf0e10cSrcweir void __EXPORT SvxFooterField::Save( SvPersistStream & /*rStm*/ )
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxDateTimeField, SvxFieldData );
1005cdf0e10cSrcweir 
Clone() const1006cdf0e10cSrcweir SvxFieldData* __EXPORT SvxDateTimeField::Clone() const
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir 	return new SvxDateTimeField;		// leer
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir 
operator ==(const SvxFieldData & rCmp) const1011cdf0e10cSrcweir int __EXPORT SvxDateTimeField::operator==( const SvxFieldData& rCmp ) const
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir 	return ( rCmp.Type() == TYPE(SvxDateTimeField) );
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir 
Load(SvPersistStream &)1016cdf0e10cSrcweir void __EXPORT SvxDateTimeField::Load( SvPersistStream & /*rStm*/ )
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
Save(SvPersistStream &)1020cdf0e10cSrcweir void __EXPORT SvxDateTimeField::Save( SvPersistStream & /*rStm*/ )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir 
GetFormatted(Date & rDate,Time & rTime,int eFormat,SvNumberFormatter & rFormatter,LanguageType eLanguage)1024cdf0e10cSrcweir String SvxDateTimeField::GetFormatted( Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage )
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir 	String aRet;
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 	SvxDateFormat eDateFormat = (SvxDateFormat)(eFormat & 0x0f);
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir 	if(eDateFormat)
1031cdf0e10cSrcweir 	{
1032cdf0e10cSrcweir 		aRet = SvxDateField::GetFormatted( rDate, eDateFormat, rFormatter, eLanguage );
1033cdf0e10cSrcweir 	}
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir 	SvxTimeFormat eTimeFormat = (SvxTimeFormat)((eFormat >> 4) & 0x0f);
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 	if(eTimeFormat)
1038cdf0e10cSrcweir 	{
1039cdf0e10cSrcweir 		if(aRet.Len())
1040cdf0e10cSrcweir 			aRet += sal_Unicode(' ');
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir 		aRet += SvxExtTimeField::GetFormatted( rTime, eTimeFormat, rFormatter, eLanguage );
1043cdf0e10cSrcweir 	}
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir 	return aRet;
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir 
1048