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