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