xref: /trunk/main/editeng/source/uno/unofield.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 <com/sun/star/util/DateTime.hpp>
27cdf0e10cSrcweir #include <com/sun/star/text/FilenameDisplayFormat.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/NoSupportException.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir #include <vos/mutex.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <rtl/uuid.h>
34cdf0e10cSrcweir #include <rtl/memory.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <editeng/eeitem.hxx>
37cdf0e10cSrcweir #include <editeng/flditem.hxx>
38cdf0e10cSrcweir #include <editeng/measfld.hxx>
39cdf0e10cSrcweir #include <editeng/unofield.hxx>
40cdf0e10cSrcweir #include <editeng/unotext.hxx>
41cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using namespace ::rtl;
44cdf0e10cSrcweir using namespace ::vos;
45cdf0e10cSrcweir using namespace ::cppu;
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #define QUERYINT( xint ) \
49cdf0e10cSrcweir 	if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
50cdf0e10cSrcweir 		aAny <<= uno::Reference< xint >(this)
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #define WID_DATE	0
54cdf0e10cSrcweir #define WID_BOOL1	1
55cdf0e10cSrcweir #define WID_BOOL2	2
56cdf0e10cSrcweir #define WID_INT32	3
57cdf0e10cSrcweir #define WID_INT16	4
58cdf0e10cSrcweir #define WID_STRING1	5
59cdf0e10cSrcweir #define WID_STRING2	6
60cdf0e10cSrcweir #define WID_STRING3	7
61cdf0e10cSrcweir 
62cdf0e10cSrcweir class SvxUnoFieldData_Impl
63cdf0e10cSrcweir {
64cdf0e10cSrcweir public:
65cdf0e10cSrcweir 	sal_Bool	mbBoolean1;
66cdf0e10cSrcweir 	sal_Bool	mbBoolean2;
67cdf0e10cSrcweir 	sal_Int32	mnInt32;
68cdf0e10cSrcweir 	sal_Int16	mnInt16;
69cdf0e10cSrcweir 	OUString	msString1;
70cdf0e10cSrcweir 	OUString	msString2;
71cdf0e10cSrcweir 	OUString	msString3;
72cdf0e10cSrcweir 	util::DateTime maDateTime;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	OUString	msPresentation;
75cdf0e10cSrcweir };
76cdf0e10cSrcweir 
ImplGetFieldItemPropertySet(sal_Int32 mnId)77cdf0e10cSrcweir const SfxItemPropertySet* ImplGetFieldItemPropertySet( sal_Int32 mnId )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir     static SfxItemPropertyMapEntry aExDateTimeFieldPropertyMap_Impl[] =
80cdf0e10cSrcweir 	{
81cdf0e10cSrcweir 		{ MAP_CHAR_LEN("DateTime"),			WID_DATE,		&::getCppuType((const util::DateTime*)0),		0, 0 },
82cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsFixed"),			WID_BOOL1,		&::getBooleanCppuType(),				0, 0 },
83cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsDate"),			WID_BOOL2,		&::getBooleanCppuType(),				0, 0 },
84cdf0e10cSrcweir 		{ MAP_CHAR_LEN("NumberFormat"),		WID_INT32,		&::getCppuType((const sal_Int16*)0),	0, 0 },
85cdf0e10cSrcweir 		{0,0,0,0,0,0}
86cdf0e10cSrcweir 	};
87cdf0e10cSrcweir     static SfxItemPropertySet aExDateTimeFieldPropertySet_Impl(aExDateTimeFieldPropertyMap_Impl);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     static SfxItemPropertyMapEntry aDateTimeFieldPropertyMap_Impl[] =
90cdf0e10cSrcweir 	{
91cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsDate"),			WID_BOOL2,		&::getBooleanCppuType(),				0, 0 },
92cdf0e10cSrcweir 		{0,0,0,0,0,0}
93cdf0e10cSrcweir 	};
94cdf0e10cSrcweir     static SfxItemPropertySet aDateTimeFieldPropertySet_Impl(aDateTimeFieldPropertyMap_Impl);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     static SfxItemPropertyMapEntry aUrlFieldPropertyMap_Impl[] =
97cdf0e10cSrcweir 	{
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 		{ MAP_CHAR_LEN("Format"),			WID_INT16,		&::getCppuType((const sal_Int16*)0),	0, 0 },
100cdf0e10cSrcweir 		{ MAP_CHAR_LEN("Representation"),	WID_STRING1,	&::getCppuType((const OUString*)0),		0, 0 },
101cdf0e10cSrcweir 		{ MAP_CHAR_LEN("TargetFrame"),		WID_STRING2,	&::getCppuType((const OUString*)0),		0, 0 },
102cdf0e10cSrcweir 		{ MAP_CHAR_LEN("URL"),				WID_STRING3,	&::getCppuType((const OUString*)0),		0, 0 },
103cdf0e10cSrcweir 		{0,0,0,0,0,0}
104cdf0e10cSrcweir 	};
105cdf0e10cSrcweir     static SfxItemPropertySet aUrlFieldPropertySet_Impl(aUrlFieldPropertyMap_Impl);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     static SfxItemPropertyMapEntry aEmptyPropertyMap_Impl[] =
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 		{0,0,0,0,0,0}
110cdf0e10cSrcweir 	};
111cdf0e10cSrcweir     static SfxItemPropertySet aEmptyPropertySet_Impl(aEmptyPropertyMap_Impl);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     static SfxItemPropertyMapEntry aExtFileFieldPropertyMap_Impl[] =
114cdf0e10cSrcweir 	{
115cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsFixed"),				WID_BOOL1,	&::getBooleanCppuType(),				0, 0 },
116cdf0e10cSrcweir 		{ MAP_CHAR_LEN("FileFormat"),			WID_INT16,	&::getCppuType((const sal_Int16*)0),	0, 0 },
117cdf0e10cSrcweir 		{ MAP_CHAR_LEN("CurrentPresentation"),	WID_STRING1,&::getCppuType((const OUString*)0),		0, 0 },
118cdf0e10cSrcweir 		{0,0,0,0,0,0}
119cdf0e10cSrcweir 	};
120cdf0e10cSrcweir     static SfxItemPropertySet aExtFileFieldPropertySet_Impl(aExtFileFieldPropertyMap_Impl);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     static SfxItemPropertyMapEntry aAuthorFieldPropertyMap_Impl[] =
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsFixed"),				WID_BOOL1,	&::getBooleanCppuType(),				0, 0 },
125cdf0e10cSrcweir 		{ MAP_CHAR_LEN("CurrentPresentation"),	WID_STRING1,&::getCppuType((const OUString*)0),		0, 0 },
126cdf0e10cSrcweir 		{ MAP_CHAR_LEN("Content"),				WID_STRING2,&::getCppuType((const OUString*)0),		0, 0 },
127cdf0e10cSrcweir 		{ MAP_CHAR_LEN("AuthorFormat"),			WID_INT16,	&::getCppuType((const sal_Int16*)0),	0, 0 },
128cdf0e10cSrcweir 		{ MAP_CHAR_LEN("FullName"),				WID_BOOL2,	&::getBooleanCppuType(),				0, 0 },
129cdf0e10cSrcweir 		{0,0,0,0,0,0}
130cdf0e10cSrcweir 	};
131cdf0e10cSrcweir     static SfxItemPropertySet aAuthorFieldPropertySet_Impl(aAuthorFieldPropertyMap_Impl);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     static SfxItemPropertyMapEntry aMeasureFieldPropertyMap_Impl[] =
134cdf0e10cSrcweir 	{
135cdf0e10cSrcweir 		{ MAP_CHAR_LEN("Kind"),					WID_INT16,	&::getCppuType((const sal_Int16*)0),	0, 0 },
136cdf0e10cSrcweir 		{0,0,0,0,0,0}
137cdf0e10cSrcweir 	};
138cdf0e10cSrcweir     static SfxItemPropertySet aMeasureFieldPropertySet_Impl(aMeasureFieldPropertyMap_Impl);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	switch( mnId )
141cdf0e10cSrcweir 	{
142cdf0e10cSrcweir 	case ID_EXT_DATEFIELD:
143cdf0e10cSrcweir 	case ID_EXT_TIMEFIELD:
144cdf0e10cSrcweir 		return &aExDateTimeFieldPropertySet_Impl;
145cdf0e10cSrcweir 	case ID_URLFIELD:
146cdf0e10cSrcweir 		return &aUrlFieldPropertySet_Impl;
147cdf0e10cSrcweir 	case ID_DATEFIELD:
148cdf0e10cSrcweir 	case ID_TIMEFIELD:
149cdf0e10cSrcweir 		return &aDateTimeFieldPropertySet_Impl;
150cdf0e10cSrcweir 	case ID_EXT_FILEFIELD:
151cdf0e10cSrcweir 		return &aExtFileFieldPropertySet_Impl;
152cdf0e10cSrcweir 	case ID_AUTHORFIELD:
153cdf0e10cSrcweir 		return &aAuthorFieldPropertySet_Impl;
154cdf0e10cSrcweir 	case ID_MEASUREFIELD:
155cdf0e10cSrcweir 		return &aMeasureFieldPropertySet_Impl;
156cdf0e10cSrcweir //	case ID_PAGEFIELD:
157cdf0e10cSrcweir //	case ID_PAGESFIELD:
158cdf0e10cSrcweir //	case ID_FILEFIELD:
159cdf0e10cSrcweir //	case ID_TABLEFIELD:
160cdf0e10cSrcweir //	case ID_HEADERFIELD:
161cdf0e10cSrcweir //	case ID_FOOTERFIELD:
162cdf0e10cSrcweir //	case ID_DATETIMEFIELD::
163cdf0e10cSrcweir 	default:
164cdf0e10cSrcweir 		return &aEmptyPropertySet_Impl;
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir static sal_Char const* aFieldItemNameMap_Impl[] =
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	"Date",
171cdf0e10cSrcweir 	"URL",
172cdf0e10cSrcweir 	"Page",
173cdf0e10cSrcweir 	"Pages",
174cdf0e10cSrcweir 	"Time",
175cdf0e10cSrcweir 	"File",
176cdf0e10cSrcweir 	"Table",
177cdf0e10cSrcweir 	"ExtTime",
178cdf0e10cSrcweir 	"ExtFile",
179cdf0e10cSrcweir 	"Author",
180cdf0e10cSrcweir 	"Measure",
181cdf0e10cSrcweir 	"ExtDate",
182cdf0e10cSrcweir 	"Header",
183cdf0e10cSrcweir 	"Footer",
184cdf0e10cSrcweir 	"DateTime",
185cdf0e10cSrcweir 	"Unknown"
186cdf0e10cSrcweir };
187cdf0e10cSrcweir 
188cdf0e10cSrcweir /* conversion routines */
189cdf0e10cSrcweir 
getFileNameDisplayFormat(SvxFileFormat nFormat)190cdf0e10cSrcweir static sal_Int16 getFileNameDisplayFormat( SvxFileFormat nFormat )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	switch( nFormat )
193cdf0e10cSrcweir 	{
194cdf0e10cSrcweir 	case SVXFILEFORMAT_NAME_EXT:	return text::FilenameDisplayFormat::NAME_AND_EXT;
195cdf0e10cSrcweir 	case SVXFILEFORMAT_FULLPATH:	return text::FilenameDisplayFormat::FULL;
196cdf0e10cSrcweir 	case SVXFILEFORMAT_PATH:	return text::FilenameDisplayFormat::PATH;
197cdf0e10cSrcweir //	case SVXFILEFORMAT_NAME:
198cdf0e10cSrcweir 	default: return text::FilenameDisplayFormat::NAME;
199cdf0e10cSrcweir 	}
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
setFileNameDisplayFormat(sal_Int16 nFormat)202cdf0e10cSrcweir static SvxFileFormat setFileNameDisplayFormat( sal_Int16 nFormat )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir 	switch( nFormat )
205cdf0e10cSrcweir 	{
206cdf0e10cSrcweir 	case text::FilenameDisplayFormat::FULL:	return SVXFILEFORMAT_FULLPATH;
207cdf0e10cSrcweir 	case text::FilenameDisplayFormat::PATH:	return SVXFILEFORMAT_PATH;
208cdf0e10cSrcweir 	case text::FilenameDisplayFormat::NAME:	return SVXFILEFORMAT_NAME;
209cdf0e10cSrcweir //	case text::FilenameDisplayFormat::NAME_AND_EXT:
210cdf0e10cSrcweir 	default:
211cdf0e10cSrcweir 		return SVXFILEFORMAT_NAME_EXT;
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
getDate(sal_uLong nDate)215cdf0e10cSrcweir static util::DateTime getDate( sal_uLong nDate )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	util::DateTime aDate;
218cdf0e10cSrcweir 	memset( &aDate, 0, sizeof( util::DateTime ) );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	Date aTempDate( nDate );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	aDate.Day = aTempDate.GetDay();
223cdf0e10cSrcweir     aDate.Month = aTempDate.GetMonth();
224cdf0e10cSrcweir     aDate.Year = aTempDate.GetYear();
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	return aDate;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
setDate(util::DateTime & rDate)229cdf0e10cSrcweir inline Date setDate( util::DateTime& rDate )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	return Date( rDate.Day, rDate.Month, rDate.Year );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
getTime(long nTime)234cdf0e10cSrcweir static util::DateTime getTime( long nTime )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir 	util::DateTime aTime;
237cdf0e10cSrcweir 	memset( &aTime, 0, sizeof( util::DateTime ) );
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	Time aTempTime( nTime );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	aTime.HundredthSeconds = aTempTime.Get100Sec();
242cdf0e10cSrcweir 	aTime.Seconds = aTempTime.GetSec();
243cdf0e10cSrcweir 	aTime.Minutes = aTempTime.GetMin();
244cdf0e10cSrcweir 	aTime.Hours = aTempTime.GetHour();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	return aTime;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
setTime(util::DateTime & rDate)249cdf0e10cSrcweir inline Time setTime( util::DateTime& rDate )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir 	return Time( rDate.Hours, rDate.Minutes, rDate.Seconds, rDate.HundredthSeconds  );
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir // ====================================================================
255cdf0e10cSrcweir // class SvxUnoTextField
256cdf0e10cSrcweir // ====================================================================
257cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextField );
258cdf0e10cSrcweir 
SvxUnoTextField(sal_Int32 nServiceId)259cdf0e10cSrcweir SvxUnoTextField::SvxUnoTextField( sal_Int32 nServiceId ) throw()
260cdf0e10cSrcweir :	OComponentHelper( getMutex() )
261cdf0e10cSrcweir ,	mpPropSet(NULL)
262cdf0e10cSrcweir ,	mnServiceId(nServiceId)
263cdf0e10cSrcweir ,	mpImpl( new SvxUnoFieldData_Impl )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir 	mpPropSet = ImplGetFieldItemPropertySet(mnServiceId);
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	memset( &(mpImpl->maDateTime), 0, sizeof( util::DateTime ) );
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 	switch( nServiceId )
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 	case ID_EXT_DATEFIELD:
272cdf0e10cSrcweir 	case ID_DATEFIELD:
273cdf0e10cSrcweir 		mpImpl->mbBoolean2 = sal_True;
274cdf0e10cSrcweir 		mpImpl->mnInt32 = SVXDATEFORMAT_STDSMALL;
275cdf0e10cSrcweir 		mpImpl->mbBoolean1 = sal_False;
276cdf0e10cSrcweir 		break;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 	case ID_EXT_TIMEFIELD:
279cdf0e10cSrcweir 	case ID_TIMEFIELD:
280cdf0e10cSrcweir 		mpImpl->mbBoolean2 = sal_False;
281cdf0e10cSrcweir 		mpImpl->mbBoolean1 = sal_False;
282cdf0e10cSrcweir 		mpImpl->mnInt32 = SVXTIMEFORMAT_STANDARD;
283cdf0e10cSrcweir 		break;
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	case ID_URLFIELD:
286cdf0e10cSrcweir 		mpImpl->mnInt16 = SVXURLFORMAT_REPR;
287cdf0e10cSrcweir 		break;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	case ID_EXT_FILEFIELD:
290cdf0e10cSrcweir 		mpImpl->mbBoolean1 = sal_False;
291cdf0e10cSrcweir 		mpImpl->mnInt16 = text::FilenameDisplayFormat::FULL;
292cdf0e10cSrcweir 		break;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	case ID_AUTHORFIELD:
295cdf0e10cSrcweir 		mpImpl->mnInt16 = SVXAUTHORFORMAT_FULLNAME;
296cdf0e10cSrcweir 		mpImpl->mbBoolean1 = sal_False;
297cdf0e10cSrcweir 		mpImpl->mbBoolean2 = sal_True;
298cdf0e10cSrcweir 		break;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	case ID_MEASUREFIELD:
301cdf0e10cSrcweir 		mpImpl->mnInt16 = SDRMEASUREFIELD_VALUE;
302cdf0e10cSrcweir 		break;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	default:
305cdf0e10cSrcweir 		mpImpl->mbBoolean1 = sal_False;
306cdf0e10cSrcweir 		mpImpl->mbBoolean2 = sal_False;
307cdf0e10cSrcweir 		mpImpl->mnInt32 = 0;
308cdf0e10cSrcweir 		mpImpl->mnInt16 = 0;
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	}
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
SvxUnoTextField(uno::Reference<text::XTextRange> xAnchor,const OUString & rPresentation,const SvxFieldData * pData)313cdf0e10cSrcweir SvxUnoTextField::SvxUnoTextField( uno::Reference< text::XTextRange > xAnchor, const OUString& rPresentation, const SvxFieldData* pData ) throw()
314cdf0e10cSrcweir :	OComponentHelper( getMutex() )
315cdf0e10cSrcweir ,	mxAnchor( xAnchor )
316cdf0e10cSrcweir ,	mpPropSet(NULL)
317cdf0e10cSrcweir ,	mnServiceId(ID_UNKNOWN)
318cdf0e10cSrcweir ,	mpImpl( new SvxUnoFieldData_Impl )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir 	DBG_ASSERT(pData, "pFieldData == NULL! [CL]" );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	mpImpl->msPresentation = rPresentation;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	if(pData)
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		mnServiceId = GetFieldId(pData);
327cdf0e10cSrcweir 		DBG_ASSERT(mnServiceId != ID_UNKNOWN, "unknown SvxFieldData! [CL]");
328cdf0e10cSrcweir 		if(mnServiceId != ID_UNKNOWN)
329cdf0e10cSrcweir 		{
330cdf0e10cSrcweir 			// extract field properties from data class
331cdf0e10cSrcweir 			switch( mnServiceId )
332cdf0e10cSrcweir 			{
333cdf0e10cSrcweir 			case ID_DATEFIELD:
334cdf0e10cSrcweir 			case ID_EXT_DATEFIELD:
335cdf0e10cSrcweir                 {
336cdf0e10cSrcweir                     mpImpl->mbBoolean2 = sal_True;
337cdf0e10cSrcweir                     // #i35416# for variable date field, don't use invalid "0000-00-00" date,
338cdf0e10cSrcweir                     // use current date instead
339cdf0e10cSrcweir                     sal_Bool bFixed = ((SvxDateField*)pData)->GetType() == SVXDATETYPE_FIX;
340cdf0e10cSrcweir                     mpImpl->maDateTime = getDate( bFixed ?
341cdf0e10cSrcweir                                             ((SvxDateField*)pData)->GetFixDate() :
342cdf0e10cSrcweir                                             Date().GetDate() );
343cdf0e10cSrcweir                     mpImpl->mnInt32 = ((SvxDateField*)pData)->GetFormat();
344cdf0e10cSrcweir                     mpImpl->mbBoolean1 = bFixed;
345cdf0e10cSrcweir                 }
346cdf0e10cSrcweir 				break;
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 			case ID_TIMEFIELD:
349cdf0e10cSrcweir 				mpImpl->mbBoolean2 = sal_False;
350cdf0e10cSrcweir 				mpImpl->mbBoolean1 = sal_False;
351cdf0e10cSrcweir 				mpImpl->mnInt32 = SVXTIMEFORMAT_STANDARD;
352cdf0e10cSrcweir 				break;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 			case ID_EXT_TIMEFIELD:
355cdf0e10cSrcweir 				mpImpl->mbBoolean2 = sal_False;
356cdf0e10cSrcweir 				mpImpl->maDateTime = getTime( ((SvxExtTimeField*)pData)->GetFixTime() );
357cdf0e10cSrcweir 				mpImpl->mbBoolean1 = ((SvxExtTimeField*)pData)->GetType() == SVXTIMETYPE_FIX;
358cdf0e10cSrcweir 				mpImpl->mnInt32 = ((SvxExtTimeField*)pData)->GetFormat();
359cdf0e10cSrcweir 				break;
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 			case ID_URLFIELD:
362cdf0e10cSrcweir 				mpImpl->msString1 = ((SvxURLField*)pData)->GetRepresentation();
363cdf0e10cSrcweir 				mpImpl->msString2 = ((SvxURLField*)pData)->GetTargetFrame();
364cdf0e10cSrcweir 				mpImpl->msString3 = ((SvxURLField*)pData)->GetURL();
365cdf0e10cSrcweir 				mpImpl->mnInt16 = sal::static_int_cast< sal_Int16 >(
366cdf0e10cSrcweir                     ((SvxURLField*)pData)->GetFormat());
367cdf0e10cSrcweir 				break;
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 			case ID_EXT_FILEFIELD:
370cdf0e10cSrcweir 				mpImpl->msString1 = ((SvxExtFileField*)pData)->GetFile();
371cdf0e10cSrcweir 				mpImpl->mbBoolean1 = ((SvxExtFileField*)pData)->GetType() == SVXFILETYPE_FIX;
372cdf0e10cSrcweir 				mpImpl->mnInt16 = getFileNameDisplayFormat(((SvxExtFileField*)pData)->GetFormat());
373cdf0e10cSrcweir 				break;
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 			case ID_AUTHORFIELD:
376cdf0e10cSrcweir 				mpImpl->msString1  = ((SvxAuthorField*)pData)->GetFormatted();
377cdf0e10cSrcweir 				mpImpl->msString2  = ((SvxAuthorField*)pData)->GetFormatted();
378cdf0e10cSrcweir 				mpImpl->mnInt16	   = sal::static_int_cast< sal_Int16 >(
379cdf0e10cSrcweir                     ((SvxAuthorField*)pData)->GetFormat());
380cdf0e10cSrcweir 				mpImpl->mbBoolean1 = ((SvxAuthorField*)pData)->GetType() == SVXAUTHORTYPE_FIX;
381cdf0e10cSrcweir 				mpImpl->mbBoolean2 = ((SvxAuthorField*)pData)->GetFormat() != SVXAUTHORFORMAT_SHORTNAME;
382cdf0e10cSrcweir 				break;
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 			case ID_MEASUREFIELD:
385cdf0e10cSrcweir 				mpImpl->mnInt16		= sal::static_int_cast< sal_Int16 >(((SdrMeasureField*)pData)->GetMeasureFieldKind());
386cdf0e10cSrcweir 				break;
387cdf0e10cSrcweir 			}
388cdf0e10cSrcweir 		}
389cdf0e10cSrcweir 	}
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	mpPropSet = ImplGetFieldItemPropertySet(mnServiceId);
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
~SvxUnoTextField()394cdf0e10cSrcweir SvxUnoTextField::~SvxUnoTextField() throw()
395cdf0e10cSrcweir {
396cdf0e10cSrcweir 	delete mpImpl;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
CreateFieldData() const399cdf0e10cSrcweir SvxFieldData* SvxUnoTextField::CreateFieldData() const throw()
400cdf0e10cSrcweir {
401cdf0e10cSrcweir 	SvxFieldData* pData = NULL;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	switch( mnServiceId )
404cdf0e10cSrcweir 	{
405cdf0e10cSrcweir 	case ID_TIMEFIELD:
406cdf0e10cSrcweir 	case ID_EXT_TIMEFIELD:
407cdf0e10cSrcweir 	case ID_DATEFIELD:
408cdf0e10cSrcweir 	case ID_EXT_DATEFIELD:
409cdf0e10cSrcweir 	{
410cdf0e10cSrcweir 		if( mpImpl->mbBoolean2 ) // IsDate?
411cdf0e10cSrcweir 		{
412cdf0e10cSrcweir 			Date aDate( setDate( mpImpl->maDateTime ) );
413cdf0e10cSrcweir 			pData = new SvxDateField( aDate, mpImpl->mbBoolean1?SVXDATETYPE_FIX:SVXDATETYPE_VAR );
414cdf0e10cSrcweir 			if( mpImpl->mnInt32 >= SVXDATEFORMAT_APPDEFAULT && mpImpl->mnInt32 <= SVXDATEFORMAT_F )
415cdf0e10cSrcweir 				((SvxDateField*)pData)->SetFormat( (SvxDateFormat)mpImpl->mnInt32 );
416cdf0e10cSrcweir 		}
417cdf0e10cSrcweir 		else
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 			if( mnServiceId != ID_TIMEFIELD && mnServiceId != ID_DATEFIELD )
420cdf0e10cSrcweir 			{
421cdf0e10cSrcweir 				Time aTime( setTime( mpImpl->maDateTime ) );
422cdf0e10cSrcweir 				pData = new SvxExtTimeField( aTime, mpImpl->mbBoolean1?SVXTIMETYPE_FIX:SVXTIMETYPE_VAR );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 				if( mpImpl->mnInt32 >= SVXTIMEFORMAT_APPDEFAULT && mpImpl->mnInt32 <= SVXTIMEFORMAT_AM_HMSH )
425cdf0e10cSrcweir 					((SvxExtTimeField*)pData)->SetFormat( (SvxTimeFormat)mpImpl->mnInt32 );
426cdf0e10cSrcweir 			}
427cdf0e10cSrcweir 			else
428cdf0e10cSrcweir 			{
429cdf0e10cSrcweir 				pData = new SvxTimeField();
430cdf0e10cSrcweir 			}
431cdf0e10cSrcweir 		}
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 		break;
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	case ID_URLFIELD:
437cdf0e10cSrcweir 		pData = new SvxURLField( mpImpl->msString3, mpImpl->msString1, mpImpl->msString1.getLength() ? SVXURLFORMAT_REPR : SVXURLFORMAT_URL );
438cdf0e10cSrcweir 		((SvxURLField*)pData)->SetTargetFrame( mpImpl->msString2 );
439cdf0e10cSrcweir 		if( mpImpl->mnInt16 >= SVXURLFORMAT_APPDEFAULT && mpImpl->mnInt16 <= SVXURLFORMAT_REPR )
440cdf0e10cSrcweir 			((SvxURLField*)pData)->SetFormat( (SvxURLFormat)mpImpl->mnInt16 );
441cdf0e10cSrcweir 		break;
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	case ID_PAGEFIELD:
444cdf0e10cSrcweir 		pData = new SvxPageField();
445cdf0e10cSrcweir 		break;
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 	case ID_PAGESFIELD:
448cdf0e10cSrcweir 		pData = new SvxPagesField();
449cdf0e10cSrcweir 		break;
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 	case ID_FILEFIELD:
452cdf0e10cSrcweir 		pData = new SvxFileField();
453cdf0e10cSrcweir 		break;
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 	case ID_TABLEFIELD:
456cdf0e10cSrcweir 		pData = new SvxTableField();
457cdf0e10cSrcweir 		break;
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 	case ID_EXT_FILEFIELD:
460cdf0e10cSrcweir 	{
461cdf0e10cSrcweir         // #92009# pass fixed attribute to constructor
462cdf0e10cSrcweir 		pData = new SvxExtFileField( mpImpl->msString1,
463cdf0e10cSrcweir                                      mpImpl->mbBoolean1 ? SVXFILETYPE_FIX : SVXFILETYPE_VAR,
464cdf0e10cSrcweir                                      setFileNameDisplayFormat(mpImpl->mnInt16 ) );
465cdf0e10cSrcweir 		break;
466cdf0e10cSrcweir 	}
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	case ID_AUTHORFIELD:
469cdf0e10cSrcweir 	{
470cdf0e10cSrcweir 		::rtl::OUString aContent;
471cdf0e10cSrcweir 		String aFirstName;
472cdf0e10cSrcweir 		String aLastName;
473cdf0e10cSrcweir 		String aEmpty;
474cdf0e10cSrcweir 
475cdf0e10cSrcweir         // do we have CurrentPresentation given?
476cdf0e10cSrcweir         // mimic behaviour of writer, which means:
477cdf0e10cSrcweir         // prefer CurrentPresentation over Content
478cdf0e10cSrcweir         // if both are given.
479cdf0e10cSrcweir         if( mpImpl->msString1.getLength() )
480cdf0e10cSrcweir             aContent = mpImpl->msString1;
481cdf0e10cSrcweir         else
482cdf0e10cSrcweir             aContent = mpImpl->msString2;
483cdf0e10cSrcweir 
484cdf0e10cSrcweir         sal_Int32 nPos = aContent.lastIndexOf( sal_Char(' '), 0 );
485cdf0e10cSrcweir         if( nPos > 0 )
486cdf0e10cSrcweir         {
487cdf0e10cSrcweir             aFirstName = aContent.copy( 0, nPos );
488cdf0e10cSrcweir             aLastName = aContent.copy( nPos + 1 );
489cdf0e10cSrcweir         }
490cdf0e10cSrcweir         else
491cdf0e10cSrcweir         {
492cdf0e10cSrcweir             aLastName = aContent;
493cdf0e10cSrcweir         }
494cdf0e10cSrcweir 
495cdf0e10cSrcweir         // #92009# pass fixed attribute to constructor
496cdf0e10cSrcweir         pData = new SvxAuthorField( aFirstName, aLastName, aEmpty,
497cdf0e10cSrcweir                                     mpImpl->mbBoolean1 ? SVXAUTHORTYPE_FIX : SVXAUTHORTYPE_VAR );
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 		if( !mpImpl->mbBoolean2 )
500cdf0e10cSrcweir 		{
501cdf0e10cSrcweir 			((SvxAuthorField*)pData)->SetFormat( SVXAUTHORFORMAT_SHORTNAME );
502cdf0e10cSrcweir 		}
503cdf0e10cSrcweir 		else if( mpImpl->mnInt16 >= SVXAUTHORFORMAT_FULLNAME || mpImpl->mnInt16 <= SVXAUTHORFORMAT_SHORTNAME )
504cdf0e10cSrcweir 		{
505cdf0e10cSrcweir 			((SvxAuthorField*)pData)->SetFormat( (SvxAuthorFormat) mpImpl->mnInt16 );
506cdf0e10cSrcweir 		}
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 		break;
509cdf0e10cSrcweir 	}
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 	case ID_MEASUREFIELD:
512cdf0e10cSrcweir 	{
513cdf0e10cSrcweir 		SdrMeasureFieldKind eKind = SDRMEASUREFIELD_VALUE;
514cdf0e10cSrcweir 		if( mpImpl->mnInt16 == (sal_Int16)SDRMEASUREFIELD_UNIT || mpImpl->mnInt16 == (sal_Int16)SDRMEASUREFIELD_ROTA90BLANCS )
515cdf0e10cSrcweir 			eKind = (SdrMeasureFieldKind) mpImpl->mnInt16;
516cdf0e10cSrcweir 		pData = new SdrMeasureField( eKind);
517cdf0e10cSrcweir 		break;
518cdf0e10cSrcweir 	}
519cdf0e10cSrcweir 	case ID_HEADERFIELD:
520cdf0e10cSrcweir 		pData = new SvxHeaderField();
521cdf0e10cSrcweir 		break;
522cdf0e10cSrcweir 	case ID_FOOTERFIELD:
523cdf0e10cSrcweir 		pData = new SvxFooterField();
524cdf0e10cSrcweir 		break;
525cdf0e10cSrcweir 	case ID_DATETIMEFIELD:
526cdf0e10cSrcweir 		pData = new SvxDateTimeField();
527cdf0e10cSrcweir 		break;
528cdf0e10cSrcweir 	};
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 	return pData;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir // uno::XInterface
queryAggregation(const uno::Type & rType)534cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextField::queryAggregation( const uno::Type & rType )
535cdf0e10cSrcweir 	throw(uno::RuntimeException)
536cdf0e10cSrcweir {
537cdf0e10cSrcweir 	uno::Any aAny;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 	QUERYINT( beans::XPropertySet );
540cdf0e10cSrcweir 	else QUERYINT( text::XTextContent );
541cdf0e10cSrcweir 	else QUERYINT( text::XTextField );
542cdf0e10cSrcweir 	else QUERYINT( lang::XServiceInfo );
543cdf0e10cSrcweir 	else QUERYINT( lang::XUnoTunnel );
544cdf0e10cSrcweir 	else
545cdf0e10cSrcweir 		return OComponentHelper::queryAggregation( rType );
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 	return aAny;
548cdf0e10cSrcweir }
549cdf0e10cSrcweir 
550cdf0e10cSrcweir // XTypeProvider
551cdf0e10cSrcweir 
getTypes()552cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxUnoTextField::getTypes()
553cdf0e10cSrcweir 	throw (uno::RuntimeException)
554cdf0e10cSrcweir {
555cdf0e10cSrcweir 	if( maTypeSequence.getLength() == 0 )
556cdf0e10cSrcweir 	{
557cdf0e10cSrcweir 		maTypeSequence = OComponentHelper::getTypes();
558cdf0e10cSrcweir 		sal_Int32 nOldCount = maTypeSequence.getLength();
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 		maTypeSequence.realloc( nOldCount + 4 ); // !DANGER! keep this updated
561cdf0e10cSrcweir 		uno::Type* pTypes = &maTypeSequence.getArray()[nOldCount];
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 		*pTypes++ = ::getCppuType(( const uno::Reference< text::XTextField >*)0);
564cdf0e10cSrcweir 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
565cdf0e10cSrcweir 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
566cdf0e10cSrcweir 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
567cdf0e10cSrcweir 	}
568cdf0e10cSrcweir 	return maTypeSequence;
569cdf0e10cSrcweir }
570cdf0e10cSrcweir 
getImplementationId()571cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextField::getImplementationId()
572cdf0e10cSrcweir 	throw (uno::RuntimeException)
573cdf0e10cSrcweir {
574cdf0e10cSrcweir 	static uno::Sequence< sal_Int8 > aId;
575cdf0e10cSrcweir 	if( aId.getLength() == 0 )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		aId.realloc( 16 );
578cdf0e10cSrcweir 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
579cdf0e10cSrcweir 	}
580cdf0e10cSrcweir 	return aId;
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
queryInterface(const uno::Type & rType)583cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextField::queryInterface( const uno::Type & rType )
584cdf0e10cSrcweir 	throw(uno::RuntimeException)
585cdf0e10cSrcweir {
586cdf0e10cSrcweir 	return OComponentHelper::queryInterface(rType);
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
acquire()589cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::acquire() throw( )
590cdf0e10cSrcweir {
591cdf0e10cSrcweir 	OComponentHelper::acquire();
592cdf0e10cSrcweir }
593cdf0e10cSrcweir 
release()594cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::release() throw( )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir 	OComponentHelper::release();
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir // Interface text::XTextField
getPresentation(sal_Bool bShowCommand)600cdf0e10cSrcweir OUString SAL_CALL SvxUnoTextField::getPresentation( sal_Bool bShowCommand )
601cdf0e10cSrcweir 	throw(uno::RuntimeException)
602cdf0e10cSrcweir {
603cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	if(bShowCommand)
606cdf0e10cSrcweir 	{
607cdf0e10cSrcweir 		DBG_ASSERT( ((sal_uInt32)mnServiceId) < ID_UNKNOWN, "Unknown field type" );
608cdf0e10cSrcweir 		return OUString::createFromAscii( aFieldItemNameMap_Impl[(((sal_uInt32)mnServiceId) > ID_UNKNOWN)? ID_UNKNOWN : mnServiceId ] );
609cdf0e10cSrcweir 	}
610cdf0e10cSrcweir 	else
611cdf0e10cSrcweir 	{
612cdf0e10cSrcweir 		return mpImpl->msPresentation;
613cdf0e10cSrcweir 	}
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
616cdf0e10cSrcweir // Interface text::XTextContent
attach(const uno::Reference<text::XTextRange> & xTextRange)617cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::attach( const uno::Reference< text::XTextRange >& xTextRange )
618cdf0e10cSrcweir 	throw(lang::IllegalArgumentException, uno::RuntimeException)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir 	SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xTextRange );
621cdf0e10cSrcweir 	if(pRange == NULL)
622cdf0e10cSrcweir 		throw lang::IllegalArgumentException();
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 	SvxFieldData* pData = CreateFieldData();
625cdf0e10cSrcweir 	if( pData )
626cdf0e10cSrcweir 		pRange->attachField( pData );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 	delete pData;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir 
getAnchor()631cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextField::getAnchor()
632cdf0e10cSrcweir 	throw(uno::RuntimeException)
633cdf0e10cSrcweir {
634cdf0e10cSrcweir 	return mxAnchor;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir 
637cdf0e10cSrcweir // lang::XComponent
dispose()638cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::dispose()
639cdf0e10cSrcweir 	throw(uno::RuntimeException)
640cdf0e10cSrcweir {
641cdf0e10cSrcweir 	OComponentHelper::dispose();
642cdf0e10cSrcweir }
643cdf0e10cSrcweir 
addEventListener(const uno::Reference<lang::XEventListener> & xListener)644cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
645cdf0e10cSrcweir 	throw(uno::RuntimeException)
646cdf0e10cSrcweir {
647cdf0e10cSrcweir 	OComponentHelper::addEventListener(xListener);
648cdf0e10cSrcweir }
649cdf0e10cSrcweir 
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)650cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::removeEventListener( const uno::Reference< lang::XEventListener >& aListener )
651cdf0e10cSrcweir 	throw(uno::RuntimeException)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir 	OComponentHelper::removeEventListener(aListener);
654cdf0e10cSrcweir }
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 
657cdf0e10cSrcweir // Interface beans::XPropertySet
getPropertySetInfo()658cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL SvxUnoTextField::getPropertySetInfo(  )
659cdf0e10cSrcweir 	throw(uno::RuntimeException)
660cdf0e10cSrcweir {
661cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
662cdf0e10cSrcweir 	return mpPropSet->getPropertySetInfo();
663cdf0e10cSrcweir }
664cdf0e10cSrcweir 
setPropertyValue(const OUString & aPropertyName,const uno::Any & aValue)665cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
666cdf0e10cSrcweir 	throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
667cdf0e10cSrcweir {
668cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 	if( mpImpl == NULL )
671cdf0e10cSrcweir 		throw uno::RuntimeException();
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMap()->getByName( aPropertyName );
674cdf0e10cSrcweir 	if ( !pMap )
675cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	switch( pMap->nWID )
678cdf0e10cSrcweir 	{
679cdf0e10cSrcweir 	case WID_DATE:
680cdf0e10cSrcweir 		if(aValue >>= mpImpl->maDateTime)
681cdf0e10cSrcweir 			return;
682cdf0e10cSrcweir 		break;
683cdf0e10cSrcweir 	case WID_BOOL1:
684cdf0e10cSrcweir 		if(aValue >>= mpImpl->mbBoolean1)
685cdf0e10cSrcweir 			return;
686cdf0e10cSrcweir 		break;
687cdf0e10cSrcweir 	case WID_BOOL2:
688cdf0e10cSrcweir 		if(aValue >>= mpImpl->mbBoolean2)
689cdf0e10cSrcweir 			return;
690cdf0e10cSrcweir 		break;
691cdf0e10cSrcweir 	case WID_INT16:
692cdf0e10cSrcweir 		if(aValue >>= mpImpl->mnInt16)
693cdf0e10cSrcweir 			return;
694cdf0e10cSrcweir 		break;
695cdf0e10cSrcweir 	case WID_INT32:
696cdf0e10cSrcweir 		if(aValue >>= mpImpl->mnInt32)
697cdf0e10cSrcweir 			return;
698cdf0e10cSrcweir 		break;
699cdf0e10cSrcweir 	case WID_STRING1:
700cdf0e10cSrcweir 		if(aValue >>= mpImpl->msString1)
701cdf0e10cSrcweir 			return;
702cdf0e10cSrcweir 		break;
703cdf0e10cSrcweir 	case WID_STRING2:
704cdf0e10cSrcweir 		if(aValue >>= mpImpl->msString2)
705cdf0e10cSrcweir 			return;
706cdf0e10cSrcweir 		break;
707cdf0e10cSrcweir 	case WID_STRING3:
708cdf0e10cSrcweir 		if(aValue >>= mpImpl->msString3)
709cdf0e10cSrcweir 			return;
710cdf0e10cSrcweir 		break;
711cdf0e10cSrcweir 	}
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 	throw lang::IllegalArgumentException();
714cdf0e10cSrcweir 
715cdf0e10cSrcweir /*
716cdf0e10cSrcweir 	case WID_FORMAT:
717cdf0e10cSrcweir 		{
718cdf0e10cSrcweir 		sal_Int32 nFormat;
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 		switch( mnId )
721cdf0e10cSrcweir 		{
722cdf0e10cSrcweir 		case ID_DATEFIELD:
723cdf0e10cSrcweir 		{
724cdf0e10cSrcweir 			SvxDateField* pDate = PTR_CAST( SvxDateField, aFieldItem.GetField() );
725cdf0e10cSrcweir 			if(pDate)
726cdf0e10cSrcweir 				pDate->SetFormat( (SvxDateFormat)nFormat );
727cdf0e10cSrcweir 			break;
728cdf0e10cSrcweir 		}
729cdf0e10cSrcweir 		case ID_URLFIELD:
730cdf0e10cSrcweir 		{
731cdf0e10cSrcweir 			SvxURLField* pURL = PTR_CAST( SvxURLField, aFieldItem.GetField() );
732cdf0e10cSrcweir 			if(pURL)
733cdf0e10cSrcweir 				pURL->SetFormat( (SvxURLFormat)nFormat );
734cdf0e10cSrcweir 			break;
735cdf0e10cSrcweir 		}
736cdf0e10cSrcweir 		case ID_EXT_TIMEFIELD:
737cdf0e10cSrcweir 		{
738cdf0e10cSrcweir 			SvxExtTimeField* pTime = PTR_CAST( SvxExtTimeField, aFieldItem.GetField() );
739cdf0e10cSrcweir 			if(pTime)
740cdf0e10cSrcweir 				pTime->SetFormat( (SvxTimeFormat)nFormat );
741cdf0e10cSrcweir 			break;
742cdf0e10cSrcweir 		}
743cdf0e10cSrcweir 		case ID_EXT_FILEFIELD:
744cdf0e10cSrcweir 		{
745cdf0e10cSrcweir 			SvxExtFileField* pFile = PTR_CAST( SvxExtFileField, aFieldItem.GetField() );
746cdf0e10cSrcweir 			if(pFile)
747cdf0e10cSrcweir 				pFile->SetFormat( (SvxFileFormat)nFormat );
748cdf0e10cSrcweir 			break;
749cdf0e10cSrcweir 		}
750cdf0e10cSrcweir 		case ID_AUTHORFIELD:
751cdf0e10cSrcweir 		{
752cdf0e10cSrcweir 			SvxAuthorField* pAuthor = PTR_CAST( SvxAuthorField, aFieldItem.GetField() );
753cdf0e10cSrcweir 			if(pAuthor)
754cdf0e10cSrcweir 				pAuthor->SetFormat( (SvxAuthorFormat)nFormat );
755cdf0e10cSrcweir 			break;
756cdf0e10cSrcweir 		}
757cdf0e10cSrcweir 		default:
758cdf0e10cSrcweir 			throw beans::UnknownPropertyException();
759cdf0e10cSrcweir 		}
760cdf0e10cSrcweir 		}
761cdf0e10cSrcweir 		break;
762cdf0e10cSrcweir 	case WID_FIX:
763cdf0e10cSrcweir 		{
764cdf0e10cSrcweir 		if( aValue.hasValue() || aValue.getValueType() != ::getCppuBooleanType() )
765cdf0e10cSrcweir 			throw lang::IllegalArgumentException();
766cdf0e10cSrcweir 		sal_Bool bFix( *(sal_Bool*)aValue.getValue() );
767cdf0e10cSrcweir 		switch( mnId )
768cdf0e10cSrcweir 		{
769cdf0e10cSrcweir 		case ID_EXT_TIMEFIELD:
770cdf0e10cSrcweir 		{
771cdf0e10cSrcweir 			SvxExtTimeField* pTime = PTR_CAST( SvxExtTimeField, aFieldItem.GetField() );
772cdf0e10cSrcweir 			if(pTime)
773cdf0e10cSrcweir 				pTime->SetType( (SvxTimeType)bFix?SVXTIMETYPE_FIX:SVXTIMETYPE_VAR );
774cdf0e10cSrcweir 			break;
775cdf0e10cSrcweir 		}
776cdf0e10cSrcweir 		case ID_DATEFIELD:
777cdf0e10cSrcweir 		{
778cdf0e10cSrcweir 			SvxDateField* pDate = PTR_CAST( SvxDateField, aFieldItem.GetField() );
779cdf0e10cSrcweir 			if(pDate)
780cdf0e10cSrcweir 				pDate->SetType( (SvxDateType)bFix?SVXDATETYPE_FIX:SVXDATETYPE_VAR );
781cdf0e10cSrcweir 			break;
782cdf0e10cSrcweir 		}
783cdf0e10cSrcweir 		case ID_EXT_FILEFIELD:
784cdf0e10cSrcweir 		{
785cdf0e10cSrcweir 			SvxExtFileField* pFile = PTR_CAST( SvxExtFileField, aFieldItem.GetField() );
786cdf0e10cSrcweir 			if(pFile)
787cdf0e10cSrcweir 				pFile->SetType( (SvxFileType)bFix?SVXFILETYPE_FIX:SVXFILETYPE_VAR );
788cdf0e10cSrcweir 			break;
789cdf0e10cSrcweir 		}
790cdf0e10cSrcweir 		case ID_AUTHORFIELD:
791cdf0e10cSrcweir 		{
792cdf0e10cSrcweir 			SvxAuthorField* pAuthor = PTR_CAST( SvxAuthorField, aFieldItem.GetField() );
793cdf0e10cSrcweir 			if(pAuthor)
794cdf0e10cSrcweir 				pAuthor->SetType( (SvxAuthorType)bFix?SVXAUTHORTYPE_FIX:SVXAUTHORTYPE_VAR );
795cdf0e10cSrcweir 			break;
796cdf0e10cSrcweir 		}
797cdf0e10cSrcweir 		default:
798cdf0e10cSrcweir 			throw beans::UnknownPropertyException();
799cdf0e10cSrcweir 		}
800cdf0e10cSrcweir 		}
801cdf0e10cSrcweir 		break;
802cdf0e10cSrcweir 	case WID_PRES:
803cdf0e10cSrcweir 	case WID_URL:
804cdf0e10cSrcweir 	case WID_TARGET:
805cdf0e10cSrcweir 	{
806cdf0e10cSrcweir 		SvxURLField* pURL = PTR_CAST( SvxURLField, aFieldItem.GetField() );
807cdf0e10cSrcweir 		if(pURL)
808cdf0e10cSrcweir 		{
809cdf0e10cSrcweir 			OUString aUnoStr;
810cdf0e10cSrcweir 			if(!(aValue >>= aUnoStr))
811cdf0e10cSrcweir 				throw lang::IllegalArgumentException();
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 			switch( pMap->nWID )
814cdf0e10cSrcweir 			{
815cdf0e10cSrcweir 			case WID_PRES:
816cdf0e10cSrcweir 				pURL->SetRepresentation( aUnoStr );
817cdf0e10cSrcweir 				break;
818cdf0e10cSrcweir 			case WID_URL:
819cdf0e10cSrcweir 				pURL->SetURL( aUnoStr );
820cdf0e10cSrcweir 				break;
821cdf0e10cSrcweir 			case WID_TARGET:
822cdf0e10cSrcweir 				pURL->SetTargetFrame( aUnoStr );
823cdf0e10cSrcweir 				break;
824cdf0e10cSrcweir 			}
825cdf0e10cSrcweir 		}
826cdf0e10cSrcweir 		break;
827cdf0e10cSrcweir 	}
828cdf0e10cSrcweir 	}
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 	SfxItemSet aSet = pForwarder->GetAttribs( GetSelection() );
831cdf0e10cSrcweir 	aSet.Put( aFieldItem );
832cdf0e10cSrcweir */
833cdf0e10cSrcweir }
834cdf0e10cSrcweir 
getPropertyValue(const OUString & PropertyName)835cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextField::getPropertyValue( const OUString& PropertyName )
836cdf0e10cSrcweir 	throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
837cdf0e10cSrcweir {
838cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 	uno::Any aValue;
841cdf0e10cSrcweir 
842cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMap()->getByName( PropertyName );
843cdf0e10cSrcweir 	if ( !pMap )
844cdf0e10cSrcweir 		throw beans::UnknownPropertyException();
845cdf0e10cSrcweir 
846cdf0e10cSrcweir 	switch( pMap->nWID )
847cdf0e10cSrcweir 	{
848cdf0e10cSrcweir 	case WID_DATE:
849cdf0e10cSrcweir 		aValue <<= mpImpl->maDateTime;
850cdf0e10cSrcweir 		break;
851cdf0e10cSrcweir 	case WID_BOOL1:
852cdf0e10cSrcweir 		aValue <<= mpImpl->mbBoolean1;
853cdf0e10cSrcweir 		break;
854cdf0e10cSrcweir 	case WID_BOOL2:
855cdf0e10cSrcweir 		aValue <<= mpImpl->mbBoolean2;
856cdf0e10cSrcweir 		break;
857cdf0e10cSrcweir 	case WID_INT16:
858cdf0e10cSrcweir 		aValue <<= mpImpl->mnInt16;
859cdf0e10cSrcweir 		break;
860cdf0e10cSrcweir 	case WID_INT32:
861cdf0e10cSrcweir 		aValue <<= mpImpl->mnInt32;
862cdf0e10cSrcweir 		break;
863cdf0e10cSrcweir 	case WID_STRING1:
864cdf0e10cSrcweir 		aValue <<= mpImpl->msString1;
865cdf0e10cSrcweir 		break;
866cdf0e10cSrcweir 	case WID_STRING2:
867cdf0e10cSrcweir 		aValue <<= mpImpl->msString2;
868cdf0e10cSrcweir 		break;
869cdf0e10cSrcweir 	case WID_STRING3:
870cdf0e10cSrcweir 		aValue <<= mpImpl->msString3;
871cdf0e10cSrcweir 		break;
872cdf0e10cSrcweir 	}
873cdf0e10cSrcweir 
874cdf0e10cSrcweir 	return aValue;
875cdf0e10cSrcweir 
876cdf0e10cSrcweir /*
877cdf0e10cSrcweir 	switch(pMap->nWID)
878cdf0e10cSrcweir 	{
879cdf0e10cSrcweir 	case WID_FORMAT:
880cdf0e10cSrcweir 		switch( mnId )
881cdf0e10cSrcweir 		{
882cdf0e10cSrcweir 		case ID_DATEFIELD:
883cdf0e10cSrcweir 		{
884cdf0e10cSrcweir 			SvxDateField* pDate = PTR_CAST( SvxDateField, pFieldItem->GetField() );
885cdf0e10cSrcweir 			if(pDate)
886cdf0e10cSrcweir 				aValue <<= (sal_Int32)pDate->GetFormat();
887cdf0e10cSrcweir 			break;
888cdf0e10cSrcweir 		}
889cdf0e10cSrcweir 		case ID_URLFIELD:
890cdf0e10cSrcweir 		{
891cdf0e10cSrcweir 			SvxURLField* pURL = PTR_CAST( SvxURLField, pFieldItem->GetField() );
892cdf0e10cSrcweir 			if(pURL)
893cdf0e10cSrcweir 				aValue <<= (sal_Int32)pURL->GetFormat();
894cdf0e10cSrcweir 			break;
895cdf0e10cSrcweir 		}
896cdf0e10cSrcweir 		case ID_EXT_TIMEFIELD:
897cdf0e10cSrcweir 		{
898cdf0e10cSrcweir 			SvxExtTimeField* pTime = PTR_CAST( SvxExtTimeField, pFieldItem->GetField() );
899cdf0e10cSrcweir 			if(pTime)
900cdf0e10cSrcweir 				aValue <<= (sal_Int32)pTime->GetFormat();
901cdf0e10cSrcweir 			break;
902cdf0e10cSrcweir 		}
903cdf0e10cSrcweir 		case ID_EXT_FILEFIELD:
904cdf0e10cSrcweir 		{
905cdf0e10cSrcweir 			SvxExtFileField* pFile = PTR_CAST( SvxExtFileField, pFieldItem->GetField() );
906cdf0e10cSrcweir 			if(pFile)
907cdf0e10cSrcweir 				aValue <<= (sal_Int32)pFile->GetFormat();
908cdf0e10cSrcweir 			break;
909cdf0e10cSrcweir 		}
910cdf0e10cSrcweir 		case ID_AUTHORFIELD:
911cdf0e10cSrcweir 		{
912cdf0e10cSrcweir 			SvxAuthorField* pAuthor = PTR_CAST( SvxAuthorField, pFieldItem->GetField() );
913cdf0e10cSrcweir 			if(pAuthor)
914cdf0e10cSrcweir 				aValue <<= (sal_Int32)pAuthor->GetFormat();
915cdf0e10cSrcweir 			break;
916cdf0e10cSrcweir 		}
917cdf0e10cSrcweir 		default:
918cdf0e10cSrcweir 			throw beans::UnknownPropertyException();
919cdf0e10cSrcweir 		}
920cdf0e10cSrcweir 		break;
921cdf0e10cSrcweir 	case WID_FIX:
922cdf0e10cSrcweir 		{
923cdf0e10cSrcweir 			sal_Bool bFix = sal_False;
924cdf0e10cSrcweir 		switch( mnId )
925cdf0e10cSrcweir 		{
926cdf0e10cSrcweir 		case ID_EXT_TIMEFIELD:
927cdf0e10cSrcweir 		{
928cdf0e10cSrcweir 			SvxExtTimeField* pTime = PTR_CAST( SvxExtTimeField, pFieldItem->GetField() );
929cdf0e10cSrcweir 			if(pTime)
930cdf0e10cSrcweir 				bFix = pTime->GetType() == SVXTIMETYPE_FIX;
931cdf0e10cSrcweir 			break;
932cdf0e10cSrcweir 		}
933cdf0e10cSrcweir 		case ID_DATEFIELD:
934cdf0e10cSrcweir 		{
935cdf0e10cSrcweir 			SvxDateField* pDate = PTR_CAST( SvxDateField, pFieldItem->GetField() );
936cdf0e10cSrcweir 			if(pDate)
937cdf0e10cSrcweir 				bFix = pDate->GetType() == SVXDATETYPE_FIX;
938cdf0e10cSrcweir 			break;
939cdf0e10cSrcweir 		}
940cdf0e10cSrcweir 		case ID_EXT_FILEFIELD:
941cdf0e10cSrcweir 		{
942cdf0e10cSrcweir 			SvxExtFileField* pFile = PTR_CAST( SvxExtFileField, pFieldItem->GetField() );
943cdf0e10cSrcweir 			if(pFile)
944cdf0e10cSrcweir 				bFix = pFile->GetType() == SVXFILETYPE_FIX;
945cdf0e10cSrcweir 			break;
946cdf0e10cSrcweir 		}
947cdf0e10cSrcweir 		case ID_AUTHORFIELD:
948cdf0e10cSrcweir 		{
949cdf0e10cSrcweir 			SvxAuthorField* pAuthor = PTR_CAST( SvxAuthorField, pFieldItem->GetField() );
950cdf0e10cSrcweir 			if(pAuthor)
951cdf0e10cSrcweir 				bFix = pAuthor->GetType() == SVXAUTHORTYPE_FIX;
952cdf0e10cSrcweir 			break;
953cdf0e10cSrcweir 		}
954cdf0e10cSrcweir 		default:
955cdf0e10cSrcweir 			throw beans::UnknownPropertyException();
956cdf0e10cSrcweir 		}
957cdf0e10cSrcweir 		aValue.setValue( &bFix, ::getCppuBooleanType() );
958cdf0e10cSrcweir 		}
959cdf0e10cSrcweir 		break;
960cdf0e10cSrcweir 	case WID_PRES:
961cdf0e10cSrcweir 	case WID_URL:
962cdf0e10cSrcweir 	case WID_TARGET:
963cdf0e10cSrcweir 	{
964cdf0e10cSrcweir 		SvxURLField* pURL = PTR_CAST( SvxURLField, pFieldItem->GetField() );
965cdf0e10cSrcweir 		if(pURL)
966cdf0e10cSrcweir 		{
967cdf0e10cSrcweir 			OUString aStr;
968cdf0e10cSrcweir 			switch( pMap->nWID )
969cdf0e10cSrcweir 			{
970cdf0e10cSrcweir 			case WID_PRES:
971cdf0e10cSrcweir 				aStr = pURL->GetRepresentation();
972cdf0e10cSrcweir 				break;
973cdf0e10cSrcweir 			case WID_URL:
974cdf0e10cSrcweir 				aStr = pURL->GetURL();
975cdf0e10cSrcweir 				break;
976cdf0e10cSrcweir 			case WID_TARGET:
977cdf0e10cSrcweir 				aStr = pURL->GetTargetFrame();
978cdf0e10cSrcweir 				break;
979cdf0e10cSrcweir 			}
980cdf0e10cSrcweir 			aValue <<= aStr;
981cdf0e10cSrcweir 		}
982cdf0e10cSrcweir 		break;
983cdf0e10cSrcweir 	}
984cdf0e10cSrcweir 	case WID_FCOLOR:
985cdf0e10cSrcweir 	case WID_TCOLOR:
986cdf0e10cSrcweir 	{
987cdf0e10cSrcweir 		Color* pFColor = NULL;
988cdf0e10cSrcweir 		Color* pTColor = NULL;
989cdf0e10cSrcweir 		const ESelection aSel = GetSelection();
990cdf0e10cSrcweir 
991cdf0e10cSrcweir 		pForwarder->CalcFieldValue( *pFieldItem, aSel.nStartPara, aSel.nStartPos, pTColor, pFColor );
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 		if( pMap->nWID == WID_FCOLOR )
994cdf0e10cSrcweir 			aValue <<= (sal_Int32)pFColor->GetColor();
995cdf0e10cSrcweir 		else
996cdf0e10cSrcweir 			aValue <<= (sal_Int32)pTColor->GetColor();
997cdf0e10cSrcweir 		break;
998cdf0e10cSrcweir 
999cdf0e10cSrcweir 		delete pTColor;
1000cdf0e10cSrcweir 		delete pFColor;
1001cdf0e10cSrcweir 	}
1002cdf0e10cSrcweir 	}
1003cdf0e10cSrcweir 	return aValue;
1004cdf0e10cSrcweir */
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1007cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::addPropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1008cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::removePropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1009cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::addVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1010cdf0e10cSrcweir void SAL_CALL SvxUnoTextField::removeVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir // OComponentHelper
disposing()1013cdf0e10cSrcweir void SvxUnoTextField::disposing()
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir 	// nothing to do
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir 
GetFieldId(const SvxFieldData * pFieldData) const1018cdf0e10cSrcweir sal_Int32 SvxUnoTextField::GetFieldId( const SvxFieldData* pFieldData ) const throw()
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir 	if( pFieldData->ISA( SvxURLField ) )
1021cdf0e10cSrcweir 		return ID_URLFIELD;
1022cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxPageField ) )
1023cdf0e10cSrcweir 		return ID_PAGEFIELD;
1024cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxPagesField ) )
1025cdf0e10cSrcweir 		return ID_PAGESFIELD;
1026cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxTimeField )	)
1027cdf0e10cSrcweir 		return ID_TIMEFIELD;
1028cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxFileField )	)
1029cdf0e10cSrcweir 		return ID_FILEFIELD;
1030cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxTableField ) )
1031cdf0e10cSrcweir 		return ID_TABLEFIELD;
1032cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxExtTimeField ) )
1033cdf0e10cSrcweir 		return ID_EXT_TIMEFIELD;
1034cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxExtFileField ) )
1035cdf0e10cSrcweir 		return ID_EXT_FILEFIELD;
1036cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxAuthorField ) )
1037cdf0e10cSrcweir 		return ID_AUTHORFIELD;
1038cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxDateField ) )
1039cdf0e10cSrcweir 		return ID_EXT_DATEFIELD;
1040cdf0e10cSrcweir 	else if( pFieldData->ISA( SdrMeasureField )	)
1041cdf0e10cSrcweir 		return ID_MEASUREFIELD;
1042cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxHeaderField ) )
1043cdf0e10cSrcweir 		return ID_HEADERFIELD;
1044cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxFooterField ) )
1045cdf0e10cSrcweir 		return ID_FOOTERFIELD;
1046cdf0e10cSrcweir 	else if( pFieldData->ISA( SvxDateTimeField ) )
1047cdf0e10cSrcweir 		return ID_DATETIMEFIELD;
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 	return ID_UNKNOWN;
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir // lang::XServiceInfo
getImplementationName()1053cdf0e10cSrcweir OUString SAL_CALL SvxUnoTextField::getImplementationName() throw(uno::RuntimeException)
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir 	return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextField"));
1056cdf0e10cSrcweir }
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir static const sal_Char* pOldServiceNames[] =
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir 	"com.sun.star.text.TextField.DateTime",
1061cdf0e10cSrcweir 	"com.sun.star.text.TextField.URL",
1062cdf0e10cSrcweir 	"com.sun.star.text.TextField.PageNumber",
1063cdf0e10cSrcweir 	"com.sun.star.text.TextField.PageCount",
1064cdf0e10cSrcweir 	"com.sun.star.text.TextField.DateTime",
1065cdf0e10cSrcweir 	"com.sun.star.text.TextField.DocInfo.Title",	// SvxFileField is used for title
1066cdf0e10cSrcweir 	"com.sun.star.text.TextField.SheetName",
1067cdf0e10cSrcweir 	"com.sun.star.text.TextField.DateTime",
1068cdf0e10cSrcweir 	"com.sun.star.text.TextField.FileName",
1069cdf0e10cSrcweir 	"com.sun.star.text.TextField.Author",
1070cdf0e10cSrcweir 	"com.sun.star.text.TextField.Measure",
1071cdf0e10cSrcweir 	"com.sun.star.text.TextField.DateTime",
1072cdf0e10cSrcweir 	"com.sun.star.presentation.TextField.Header",
1073cdf0e10cSrcweir 	"com.sun.star.presentation.TextField.Footer",
1074cdf0e10cSrcweir 	"com.sun.star.presentation.TextField.DateTime"
1075cdf0e10cSrcweir };
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir static const sal_Char* pNewServiceNames[] =
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir     "com.sun.star.text.textfield.DateTime",
1080cdf0e10cSrcweir     "com.sun.star.text.textfield.URL",
1081cdf0e10cSrcweir     "com.sun.star.text.textfield.PageNumber",
1082cdf0e10cSrcweir     "com.sun.star.text.textfield.PageCount",
1083cdf0e10cSrcweir     "com.sun.star.text.textfield.DateTime",
1084cdf0e10cSrcweir     "com.sun.star.text.textfield.docinfo.Title",    // SvxFileField is used for title
1085cdf0e10cSrcweir     "com.sun.star.text.textfield.SheetName",
1086cdf0e10cSrcweir     "com.sun.star.text.textfield.DateTime",
1087cdf0e10cSrcweir     "com.sun.star.text.textfield.FileName",
1088cdf0e10cSrcweir     "com.sun.star.text.textfield.Author",
1089cdf0e10cSrcweir     "com.sun.star.text.textfield.Measure",
1090cdf0e10cSrcweir     "com.sun.star.text.textfield.DateTime",
1091cdf0e10cSrcweir     "com.sun.star.presentation.textfield.Header",
1092cdf0e10cSrcweir     "com.sun.star.presentation.textfield.Footer",
1093cdf0e10cSrcweir     "com.sun.star.presentation.textfield.DateTime"
1094cdf0e10cSrcweir };
1095cdf0e10cSrcweir 
getSupportedServiceNames()1096cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoTextField::getSupportedServiceNames()
1097cdf0e10cSrcweir 	throw(uno::RuntimeException)
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir     uno::Sequence< OUString > aSeq( 4 );
1100cdf0e10cSrcweir 	OUString* pServices = aSeq.getArray();
1101cdf0e10cSrcweir     pServices[0] = OUString::createFromAscii( pNewServiceNames[mnServiceId] );
1102cdf0e10cSrcweir     pServices[1] = OUString::createFromAscii( pOldServiceNames[mnServiceId] );
1103cdf0e10cSrcweir     pServices[2] = OUString::createFromAscii( "com.sun.star.text.TextContent" ),
1104cdf0e10cSrcweir     pServices[3] = OUString::createFromAscii( "com.sun.star.text.TextField" );
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir 	return aSeq;
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir 
supportsService(const OUString & ServiceName)1109cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoTextField::supportsService( const OUString& ServiceName ) throw( uno::RuntimeException )
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir 
SvxUnoTextCreateTextField(const::rtl::OUString & ServiceSpecifier)1114cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SvxUnoTextCreateTextField( const ::rtl::OUString& ServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir 	uno::Reference< uno::XInterface > xRet;
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 	const OUString aTextFieldPrexit( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.textfield.") );
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir 	// #i93308# up to OOo 3.2 we used this wrong namespace name with the capital T & F. This is
1121cdf0e10cSrcweir 	// fixed since OOo 3.2 but for compatibility we will still provide support for the wrong notation.
1122cdf0e10cSrcweir 	const OUString aTextFieldPrexit2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.") );
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 	if( (ServiceSpecifier.compareTo( aTextFieldPrexit, aTextFieldPrexit.getLength() ) == 0) ||
1125cdf0e10cSrcweir 	    (ServiceSpecifier.compareTo( aTextFieldPrexit2, aTextFieldPrexit2.getLength() ) == 0) )
1126cdf0e10cSrcweir 	{
1127cdf0e10cSrcweir 		OUString aFieldType( ServiceSpecifier.copy( aTextFieldPrexit.getLength() ) );
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 		sal_Int32 nId = ID_UNKNOWN;
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 		if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DateTime") ) )
1132cdf0e10cSrcweir 		{
1133cdf0e10cSrcweir 			nId = ID_DATEFIELD;
1134cdf0e10cSrcweir 		}
1135cdf0e10cSrcweir 		else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("URL") ) )
1136cdf0e10cSrcweir 		{
1137cdf0e10cSrcweir 			nId = ID_URLFIELD;
1138cdf0e10cSrcweir 		}
1139cdf0e10cSrcweir 		else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("PageNumber") ) )
1140cdf0e10cSrcweir 		{
1141cdf0e10cSrcweir 			nId = ID_PAGEFIELD;
1142cdf0e10cSrcweir 		}
1143cdf0e10cSrcweir 		else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("PageCount") ) )
1144cdf0e10cSrcweir 		{
1145cdf0e10cSrcweir 			nId = ID_PAGESFIELD;
1146cdf0e10cSrcweir 		}
1147cdf0e10cSrcweir 		else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SheetName") ) )
1148cdf0e10cSrcweir 		{
1149cdf0e10cSrcweir 			nId = ID_TABLEFIELD;
1150cdf0e10cSrcweir 		}
1151cdf0e10cSrcweir 		else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FileName") ) )
1152cdf0e10cSrcweir 		{
1153cdf0e10cSrcweir 			nId = ID_EXT_FILEFIELD;
1154cdf0e10cSrcweir 		}
1155cdf0e10cSrcweir         else if (aFieldType.equalsAsciiL(
1156cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM("docinfo.Title") ) ||
1157cdf0e10cSrcweir                  aFieldType.equalsAsciiL(
1158cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM("DocInfo.Title") ) )
1159cdf0e10cSrcweir 		{
1160cdf0e10cSrcweir 			nId = ID_FILEFIELD;
1161cdf0e10cSrcweir 		}
1162cdf0e10cSrcweir 		else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Author") ) )
1163cdf0e10cSrcweir 		{
1164cdf0e10cSrcweir 			nId = ID_AUTHORFIELD;
1165cdf0e10cSrcweir 		}
1166cdf0e10cSrcweir 		else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Measure") ) )
1167cdf0e10cSrcweir 		{
1168cdf0e10cSrcweir 			nId = ID_MEASUREFIELD;
1169cdf0e10cSrcweir 		}
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 		if( nId != ID_UNKNOWN )
1172cdf0e10cSrcweir 			xRet = (::cppu::OWeakObject * )new SvxUnoTextField( nId );
1173cdf0e10cSrcweir 	}
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir 	return xRet;
1176cdf0e10cSrcweir }
1177