1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unofield.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <swtypes.hxx>
43 #include <unoprnms.hxx>
45 #include <unocoll.hxx>
46 #include <svx/linkmgr.hxx>
47 #include <docstat.hxx>
50 #include <comphelper/types.hxx>
51 #include <comphelper/processfactory.hxx>
52 #include <com/sun/star/util/Time.hpp>
53 #include <com/sun/star/util/DateTimeRange.hpp>
54 #include <com/sun/star/util/DateTime.hpp>
55 #include <com/sun/star/util/Date.hpp>
56 #include <com/sun/star/beans/XFastPropertySet.hpp>
57 #include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
58 #include <com/sun/star/beans/PropertyAttribute.hpp>
59 #include <com/sun/star/beans/XPropertyContainer.hpp>
61 //undef to prevent error (from sfx2/docfile.cxx)
63 #include <com/sun/star/text/SetVariableType.hpp>
64 #include <com/sun/star/text/WrapTextMode.hpp>
65 #include <com/sun/star/text/TextContentAnchorType.hpp>
66 #include <com/sun/star/text/PageNumberType.hpp>
67 #include <unofield.hxx>
68 #include <unocrsr.hxx>
69 #include <authfld.hxx>
73 #include <docufld.hxx>
76 #include <flddropdown.hxx>
77 #include <poolfmt.hxx>
78 #include <poolfmt.hrc>
79 #include <pagedesc.hxx>
83 #include <SwStyleNameMapper.hxx>
84 #include <swunohelper.hxx>
85 #include <unofldmid.h>
86 #include <scriptinfo.hxx>
87 #include <tools/datetime.hxx>
88 #include <tools/urlobj.hxx>
89 #include <svx/dataaccessdescriptor.hxx>
90 #define _SVSTDARR_STRINGS
91 #include <svtools/svstdarr.hxx>
92 #include <vos/mutex.hxx>
93 #include <vcl/svapp.hxx>
94 #include <textapi.hxx>
95 #include <svx/outliner.hxx>
97 #include <fmtmeta.hxx> // MetaFieldManager
99 using ::rtl::OUString
;
100 using namespace ::com::sun::star
;
101 using namespace nsSwDocInfoSubType
;
103 #define COM_TEXT_FLDMASTER "com.sun.star.text.FieldMaster."
105 // case-corrected version of the first part for the service names (see #i67811)
106 #define COM_TEXT_FLDMASTER_CC "com.sun.star.text.fieldmaster."
108 // note: this thing is indexed as an array, so do not insert/remove entries!
109 static const sal_uInt16 aDocInfoSubTypeFromService
[] =
111 DI_CHANGE
| DI_SUB_AUTHOR
, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_AUTHOR
112 DI_CHANGE
| DI_SUB_DATE
, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME
113 DI_EDIT
| DI_SUB_TIME
, //PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME
114 DI_COMMENT
, //PROPERTY_MAP_FLDTYP_DOCINFO_DESCRIPTION
115 DI_CREATE
| DI_SUB_AUTHOR
, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_AUTHOR
116 DI_CREATE
| DI_SUB_DATE
, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME
121 DI_CUSTOM
, //PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM
122 DI_PRINT
| DI_SUB_AUTHOR
, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_AUTHOR
123 DI_PRINT
| DI_SUB_DATE
, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_DATE_TIME
124 DI_KEYS
, //PROPERTY_MAP_FLDTYP_DOCINFO_KEY_WORDS
125 DI_THEMA
, //PROPERTY_MAP_FLDTYP_DOCINFO_SUBJECT
126 DI_TITEL
, //PROPERTY_MAP_FLDTYP_DOCINFO_TITLE
127 DI_DOCNO
//PROPERTY_MAP_FLDTYP_DOCINFO_REVISION
129 struct ServiceIdResId
134 static const ServiceIdResId aServiceToRes
[] =
136 {RES_DATETIMEFLD
, SW_SERVICE_FIELDTYPE_DATETIME
},
137 {RES_USERFLD
, SW_SERVICE_FIELDTYPE_USER
},
138 {RES_SETEXPFLD
, SW_SERVICE_FIELDTYPE_SET_EXP
} ,
139 {RES_GETEXPFLD
, SW_SERVICE_FIELDTYPE_GET_EXP
} ,
140 {RES_FILENAMEFLD
, SW_SERVICE_FIELDTYPE_FILE_NAME
},
141 {RES_PAGENUMBERFLD
, SW_SERVICE_FIELDTYPE_PAGE_NUM
} ,
142 {RES_AUTHORFLD
, SW_SERVICE_FIELDTYPE_AUTHOR
} ,
143 {RES_CHAPTERFLD
, SW_SERVICE_FIELDTYPE_CHAPTER
},
144 {RES_GETREFFLD
, SW_SERVICE_FIELDTYPE_GET_REFERENCE
} ,
145 {RES_HIDDENTXTFLD
, SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT
},
146 {RES_POSTITFLD
, SW_SERVICE_FIELDTYPE_ANNOTATION
} ,
147 {RES_INPUTFLD
, SW_SERVICE_FIELDTYPE_INPUT
},
148 {RES_MACROFLD
, SW_SERVICE_FIELDTYPE_MACRO
},
149 {RES_DDEFLD
, SW_SERVICE_FIELDTYPE_DDE
},
150 {RES_HIDDENPARAFLD
, SW_SERVICE_FIELDTYPE_HIDDEN_PARA
} ,
151 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOC_INFO
},
152 {RES_TEMPLNAMEFLD
, SW_SERVICE_FIELDTYPE_TEMPLATE_NAME
},
153 {RES_EXTUSERFLD
, SW_SERVICE_FIELDTYPE_USER_EXT
},
154 {RES_REFPAGESETFLD
, SW_SERVICE_FIELDTYPE_REF_PAGE_SET
} ,
155 {RES_REFPAGEGETFLD
, SW_SERVICE_FIELDTYPE_REF_PAGE_GET
} ,
156 {RES_JUMPEDITFLD
, SW_SERVICE_FIELDTYPE_JUMP_EDIT
},
157 {RES_SCRIPTFLD
, SW_SERVICE_FIELDTYPE_SCRIPT
} ,
158 {RES_DBNEXTSETFLD
, SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET
},
159 {RES_DBNUMSETFLD
, SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET
},
160 {RES_DBSETNUMBERFLD
, SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM
} ,
161 {RES_DBFLD
, SW_SERVICE_FIELDTYPE_DATABASE
} ,
162 {RES_DBNAMEFLD
, SW_SERVICE_FIELDTYPE_DATABASE_NAME
},
163 {RES_DOCSTATFLD
, SW_SERVICE_FIELDTYPE_PAGE_COUNT
},
164 {RES_DOCSTATFLD
, SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT
},
165 {RES_DOCSTATFLD
, SW_SERVICE_FIELDTYPE_WORD_COUNT
},
166 {RES_DOCSTATFLD
, SW_SERVICE_FIELDTYPE_CHARACTER_COUNT
},
167 {RES_DOCSTATFLD
, SW_SERVICE_FIELDTYPE_TABLE_COUNT
},
168 {RES_DOCSTATFLD
, SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT
},
169 {RES_DOCSTATFLD
, SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT
},
170 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR
},
171 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME
},
172 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME
},
173 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION
},
174 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR
},
175 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME
},
176 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM
},
177 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR
},
178 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME
},
179 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS
},
180 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT
},
181 {RES_DOCINFOFLD
, SW_SERVICE_FIELDTYPE_DOCINFO_TITLE
},
182 {RES_INPUTFLD
, SW_SERVICE_FIELDTYPE_INPUT_USER
},
183 {RES_HIDDENTXTFLD
, SW_SERVICE_FIELDTYPE_HIDDEN_TEXT
},
184 {RES_AUTHORITY
, SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY
},
185 {RES_COMBINED_CHARS
, SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS
},
186 {RES_DROPDOWN
, SW_SERVICE_FIELDTYPE_DROPDOWN
},
187 {RES_TABLEFLD
, SW_SERVICE_FIELDTYPE_TABLE_FORMULA
},
188 {USHRT_MAX
, USHRT_MAX
}
190 //-----------------------------------------------------------------
191 sal_uInt16
lcl_ServiceIdToResId(sal_uInt16 nServiceId
)
193 const ServiceIdResId
* pMap
= aServiceToRes
;
194 while( USHRT_MAX
!= pMap
->nServiceId
&& nServiceId
!= pMap
->nServiceId
)
197 if( USHRT_MAX
== pMap
->nServiceId
)
198 DBG_ERROR("service id not found");
202 //-----------------------------------------------------------------
203 sal_uInt16
lcl_GetServiceForField( const SwField
& rFld
)
205 sal_uInt16 nWhich
= rFld
.Which(), nSrvId
= USHRT_MAX
;
206 //special handling for some fields
210 if( INP_USR
== (rFld
.GetSubType() & 0x00ff) )
211 nSrvId
= SW_SERVICE_FIELDTYPE_INPUT_USER
;
216 USHORT nSubType
= rFld
.GetSubType();
217 switch( (nSubType
& 0xff))
220 nSrvId
= ((nSubType
&0x300) == DI_SUB_AUTHOR
)
221 ? SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR
222 : SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME
;
225 nSrvId
= ((nSubType
&0x300) == DI_SUB_AUTHOR
)
226 ? SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR
227 : SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME
;
230 nSrvId
= ((nSubType
&0x300) == DI_SUB_AUTHOR
)
231 ? SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR
232 : SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME
;
234 case DI_EDIT
: nSrvId
= SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME
;break;
235 case DI_COMMENT
:nSrvId
= SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION
;break;
236 case DI_KEYS
: nSrvId
= SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS
;break;
237 case DI_THEMA
: nSrvId
= SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT
; break;
238 case DI_TITEL
: nSrvId
= SW_SERVICE_FIELDTYPE_DOCINFO_TITLE
; break;
239 case DI_DOCNO
: nSrvId
= SW_SERVICE_FIELDTYPE_DOCINFO_REVISION
; break;
240 case DI_CUSTOM
: nSrvId
= SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM
; break;
245 case RES_HIDDENTXTFLD
:
246 nSrvId
= TYP_CONDTXTFLD
== rFld
.GetSubType()
247 ? SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT
248 : SW_SERVICE_FIELDTYPE_HIDDEN_TEXT
;
253 switch( rFld
.GetSubType() )
255 case DS_PAGE
: nSrvId
= SW_SERVICE_FIELDTYPE_PAGE_COUNT
; break;
256 case DS_PARA
: nSrvId
= SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT
; break;
257 case DS_WORD
: nSrvId
= SW_SERVICE_FIELDTYPE_WORD_COUNT
; break;
258 case DS_CHAR
: nSrvId
= SW_SERVICE_FIELDTYPE_CHARACTER_COUNT
; break;
259 case DS_TBL
: nSrvId
= SW_SERVICE_FIELDTYPE_TABLE_COUNT
; break;
260 case DS_GRF
: nSrvId
= SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT
; break;
261 case DS_OLE
: nSrvId
= SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT
; break;
266 if( USHRT_MAX
== nSrvId
)
268 for( const ServiceIdResId
* pMap
= aServiceToRes
;
269 USHRT_MAX
!= pMap
->nResId
; ++pMap
)
270 if( nWhich
== pMap
->nResId
)
272 nSrvId
= pMap
->nServiceId
;
277 if( USHRT_MAX
== nSrvId
)
278 DBG_ERROR("resid not found");
283 sal_uInt16
lcl_GetPropMapIdForFieldType( USHORT nWhich
)
288 case RES_USERFLD
: nId
= PROPERTY_MAP_FLDMSTR_USER
; break;
289 case RES_DBFLD
: nId
= PROPERTY_MAP_FLDMSTR_DATABASE
; break;
290 case RES_SETEXPFLD
: nId
= PROPERTY_MAP_FLDMSTR_SET_EXP
; break;
291 case RES_DDEFLD
: nId
= PROPERTY_MAP_FLDMSTR_DDE
; break;
292 case RES_AUTHORITY
: nId
= PROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY
; break;
293 default: nId
= PROPERTY_MAP_FLDMSTR_DUMMY0
;
299 USHORT
GetFieldTypeMId( const OUString
& rProperty
, const SwFieldType
& rTyp
)
301 USHORT nId
= lcl_GetPropMapIdForFieldType( rTyp
.Which() );
302 const SfxItemPropertySet
* pSet
= aSwMapProvider
.GetPropertySet( nId
);
307 const SfxItemPropertySimpleEntry
* pEntry
= pSet
->getPropertyMap()->getByName(rProperty
);
308 nId
= pEntry
? pEntry
->nWID
: USHRT_MAX
;
313 USHORT
lcl_GetPropertyMapOfService( USHORT nServiceId
)
318 case SW_SERVICE_FIELDTYPE_DATETIME
: nRet
= PROPERTY_MAP_FLDTYP_DATETIME
; break;
319 case SW_SERVICE_FIELDTYPE_USER
: nRet
= PROPERTY_MAP_FLDTYP_USER
; break;
320 case SW_SERVICE_FIELDTYPE_SET_EXP
: nRet
= PROPERTY_MAP_FLDTYP_SET_EXP
; break;
321 case SW_SERVICE_FIELDTYPE_GET_EXP
: nRet
= PROPERTY_MAP_FLDTYP_GET_EXP
; break;
322 case SW_SERVICE_FIELDTYPE_FILE_NAME
: nRet
= PROPERTY_MAP_FLDTYP_FILE_NAME
; break;
323 case SW_SERVICE_FIELDTYPE_PAGE_NUM
: nRet
= PROPERTY_MAP_FLDTYP_PAGE_NUM
; break;
324 case SW_SERVICE_FIELDTYPE_AUTHOR
: nRet
= PROPERTY_MAP_FLDTYP_AUTHOR
; break;
325 case SW_SERVICE_FIELDTYPE_CHAPTER
: nRet
= PROPERTY_MAP_FLDTYP_CHAPTER
; break;
326 case SW_SERVICE_FIELDTYPE_GET_REFERENCE
: nRet
= PROPERTY_MAP_FLDTYP_GET_REFERENCE
; break;
327 case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT
: nRet
= PROPERTY_MAP_FLDTYP_CONDITIONED_TEXT
; break;
328 case SW_SERVICE_FIELDTYPE_ANNOTATION
: nRet
= PROPERTY_MAP_FLDTYP_ANNOTATION
; break;
329 case SW_SERVICE_FIELDTYPE_INPUT_USER
:
330 case SW_SERVICE_FIELDTYPE_INPUT
: nRet
= PROPERTY_MAP_FLDTYP_INPUT
; break;
331 case SW_SERVICE_FIELDTYPE_MACRO
: nRet
= PROPERTY_MAP_FLDTYP_MACRO
; break;
332 case SW_SERVICE_FIELDTYPE_DDE
: nRet
= PROPERTY_MAP_FLDTYP_DDE
; break;
333 case SW_SERVICE_FIELDTYPE_HIDDEN_PARA
: nRet
= PROPERTY_MAP_FLDTYP_HIDDEN_PARA
; break;
334 case SW_SERVICE_FIELDTYPE_DOC_INFO
: nRet
= PROPERTY_MAP_FLDTYP_DOC_INFO
; break;
335 case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME
: nRet
= PROPERTY_MAP_FLDTYP_TEMPLATE_NAME
; break;
336 case SW_SERVICE_FIELDTYPE_USER_EXT
: nRet
= PROPERTY_MAP_FLDTYP_USER_EXT
; break;
337 case SW_SERVICE_FIELDTYPE_REF_PAGE_SET
: nRet
= PROPERTY_MAP_FLDTYP_REF_PAGE_SET
; break;
338 case SW_SERVICE_FIELDTYPE_REF_PAGE_GET
: nRet
= PROPERTY_MAP_FLDTYP_REF_PAGE_GET
; break;
339 case SW_SERVICE_FIELDTYPE_JUMP_EDIT
: nRet
= PROPERTY_MAP_FLDTYP_JUMP_EDIT
; break;
340 case SW_SERVICE_FIELDTYPE_SCRIPT
: nRet
= PROPERTY_MAP_FLDTYP_SCRIPT
; break;
341 case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET
: nRet
= PROPERTY_MAP_FLDTYP_DATABASE_NEXT_SET
; break;
342 case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET
: nRet
= PROPERTY_MAP_FLDTYP_DATABASE_NUM_SET
; break;
343 case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM
: nRet
= PROPERTY_MAP_FLDTYP_DATABASE_SET_NUM
; break;
344 case SW_SERVICE_FIELDTYPE_DATABASE
: nRet
= PROPERTY_MAP_FLDTYP_DATABASE
; break;
345 case SW_SERVICE_FIELDTYPE_DATABASE_NAME
: nRet
= PROPERTY_MAP_FLDTYP_DATABASE_NAME
; break;
346 case SW_SERVICE_FIELDTYPE_TABLE_FORMULA
: nRet
= PROPERTY_MAP_FLDTYP_TABLE_FORMULA
; break;
347 case SW_SERVICE_FIELDTYPE_PAGE_COUNT
:
348 case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT
:
349 case SW_SERVICE_FIELDTYPE_WORD_COUNT
:
350 case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT
:
351 case SW_SERVICE_FIELDTYPE_TABLE_COUNT
:
352 case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT
:
353 case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT
: nRet
= PROPERTY_MAP_FLDTYP_DOCSTAT
; break;
354 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR
:
355 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR
:
356 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR
: nRet
= PROPERTY_MAP_FLDTYP_DOCINFO_AUTHOR
; break;
357 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME
:
358 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME
:
359 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME
: nRet
= PROPERTY_MAP_FLDTYP_DOCINFO_DATE_TIME
; break;
360 case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME
: nRet
= PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME
; break;
361 case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM
: nRet
= PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM
; break;
362 case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION
:
363 case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS
:
364 case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT
:
365 case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE
: nRet
= PROPERTY_MAP_FLDTYP_DOCINFO_MISC
; break;
366 case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION
: nRet
= PROPERTY_MAP_FLDTYP_DOCINFO_REVISION
; break;
367 case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY
: nRet
= PROPERTY_MAP_FLDTYP_BIBLIOGRAPHY
; break;
368 case SW_SERVICE_FIELDTYPE_DUMMY_0
:
369 case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS
: nRet
= PROPERTY_MAP_FLDTYP_COMBINED_CHARACTERS
; break;
370 case SW_SERVICE_FIELDTYPE_DROPDOWN
: nRet
= PROPERTY_MAP_FLDTYP_DROPDOWN
; break;
371 case SW_SERVICE_FIELDTYPE_DUMMY_4
:
372 case SW_SERVICE_FIELDTYPE_DUMMY_5
:
373 case SW_SERVICE_FIELDTYPE_DUMMY_6
:
374 case SW_SERVICE_FIELDTYPE_DUMMY_7
:
375 nRet
= PROPERTY_MAP_FLDTYP_DUMMY_0
; break;
376 case SW_SERVICE_FIELDMASTER_USER
: nRet
= PROPERTY_MAP_FLDMSTR_USER
; break;
377 case SW_SERVICE_FIELDMASTER_DDE
: nRet
= PROPERTY_MAP_FLDMSTR_DDE
; break;
378 case SW_SERVICE_FIELDMASTER_SET_EXP
: nRet
= PROPERTY_MAP_FLDMSTR_SET_EXP
; break;
379 case SW_SERVICE_FIELDMASTER_DATABASE
: nRet
= PROPERTY_MAP_FLDMSTR_DATABASE
; break;
380 case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY
: nRet
= PROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY
; break;
381 case SW_SERVICE_FIELDMASTER_DUMMY2
:
382 case SW_SERVICE_FIELDMASTER_DUMMY3
:
383 case SW_SERVICE_FIELDMASTER_DUMMY4
:
384 case SW_SERVICE_FIELDMASTER_DUMMY5
: nRet
= PROPERTY_MAP_FLDMSTR_DUMMY0
; break;
385 case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT
: nRet
= PROPERTY_MAP_FLDTYP_HIDDEN_TEXT
; break;
387 DBG_ERROR( "wrong service id" );
393 /******************************************************************
395 ******************************************************************/
396 TYPEINIT1(SwXFieldMaster
, SwClient
);
397 /* -----------------------------13.03.00 12:15--------------------------------
399 ---------------------------------------------------------------------------*/
400 const uno::Sequence
< sal_Int8
> & SwXFieldMaster::getUnoTunnelId()
402 static uno::Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
405 /* -----------------------------10.03.00 18:04--------------------------------
407 ---------------------------------------------------------------------------*/
408 sal_Int64 SAL_CALL
SwXFieldMaster::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
409 throw(uno::RuntimeException
)
411 if( rId
.getLength() == 16
412 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
413 rId
.getConstArray(), 16 ) )
415 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
419 /* -----------------------------06.04.00 13:22--------------------------------
421 ---------------------------------------------------------------------------*/
422 OUString
SwXFieldMaster::getImplementationName(void) throw( uno::RuntimeException
)
424 return C2U("SwXFieldMaster");
426 /* -----------------------------06.04.00 13:22--------------------------------
428 ---------------------------------------------------------------------------*/
429 BOOL
SwXFieldMaster::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
431 sal_Bool bRet
= sal_False
;
432 if(rServiceName
.equalsAsciiL(
433 RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextFieldMaster")))
437 const sal_Char
* pEntry
;
440 case RES_USERFLD
: pEntry
= "User"; break;
441 case RES_DBFLD
: pEntry
= "Database"; break;
442 case RES_SETEXPFLD
: pEntry
= "SetExpression"; break;
443 case RES_DDEFLD
: pEntry
= "DDE"; break;
444 case RES_AUTHORITY
: pEntry
= "Bibliography"; break;
449 ByteString
aTmp( RTL_CONSTASCII_STRINGPARAM(
450 "com.sun.star.text.fieldmaster."));
451 aTmp
.Append( pEntry
);
452 bRet
= rServiceName
.equalsAsciiL(aTmp
.GetBuffer(), aTmp
.Len());
457 /* -----------------------------06.04.00 13:22--------------------------------
459 ---------------------------------------------------------------------------*/
460 uno::Sequence
< OUString
> SwXFieldMaster::getSupportedServiceNames(void) throw( uno::RuntimeException
)
462 uno::Sequence
< OUString
> aRet(2);
463 OUString
* pArray
= aRet
.getArray();
464 pArray
[0] = C2U("com.sun.star.text.TextFieldMaster");
466 const sal_Char
* pEntry1
;
469 case RES_USERFLD
: pEntry1
= "User"; break;
470 case RES_DBFLD
: pEntry1
= "Database"; break;
471 case RES_SETEXPFLD
: pEntry1
= "SetExpression"; break;
472 case RES_DDEFLD
: pEntry1
= "DDE"; break;
473 case RES_AUTHORITY
: pEntry1
= "Bibliography"; break;
474 default: pEntry1
= 0;
479 s
.AppendAscii( "com.sun.star.text.fieldmaster." ).AppendAscii( pEntry1
);
484 /*-- 14.12.98 11:08:33---------------------------------------------------
486 -----------------------------------------------------------------------*/
487 SwXFieldMaster::SwXFieldMaster(SwDoc
* pDoc
, sal_uInt16 nResId
) :
488 aLstnrCntnr( (XPropertySet
*)this),
491 m_bIsDescriptor(sal_True
),
497 pDoc
->GetPageDescFromPool(RES_POOLPAGE_STANDARD
)->Add(this);
499 /*-- 14.12.98 11:08:33---------------------------------------------------
501 -----------------------------------------------------------------------*/
502 SwXFieldMaster::SwXFieldMaster(SwFieldType
& rType
, SwDoc
* pDoc
) :
504 aLstnrCntnr( (XPropertySet
*)this),
505 nResTypeId(rType
.Which()),
507 m_bIsDescriptor(sal_False
),
514 /*-- 14.12.98 11:08:34---------------------------------------------------
516 -----------------------------------------------------------------------*/
517 SwXFieldMaster::~SwXFieldMaster()
521 /*-- 14.12.98 11:08:35---------------------------------------------------
523 -----------------------------------------------------------------------*/
524 uno::Reference
< beans::XPropertySetInfo
> SwXFieldMaster::getPropertySetInfo(void)
525 throw( uno::RuntimeException
)
527 vos::OGuard
aGuard(Application::GetSolarMutex());
528 uno::Reference
< beans::XPropertySetInfo
> aRef
=
529 aSwMapProvider
.GetPropertySet(
530 lcl_GetPropMapIdForFieldType( nResTypeId
) )->getPropertySetInfo();
533 /*-- 14.12.98 11:08:35---------------------------------------------------
535 -----------------------------------------------------------------------*/
536 void SwXFieldMaster::setPropertyValue( const OUString
& rPropertyName
,
537 const uno::Any
& rValue
)
538 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
,
539 lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
541 vos::OGuard
aGuard(Application::GetSolarMutex());
542 SwFieldType
* pType
= GetFldType(sal_True
);
545 sal_Bool bSetValue
= sal_True
;
546 if( rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_SUB_TYPE
)))
548 const SvStringsDtor
& rExtraArr
= SwStyleNameMapper::GetExtraUINameArray();
549 String sTypeName
= pType
->GetName();
550 static sal_uInt16 nIds
[] =
552 RES_POOLCOLL_LABEL_DRAWING
- RES_POOLCOLL_EXTRA_BEGIN
,
553 RES_POOLCOLL_LABEL_ABB
- RES_POOLCOLL_EXTRA_BEGIN
,
554 RES_POOLCOLL_LABEL_TABLE
- RES_POOLCOLL_EXTRA_BEGIN
,
555 RES_POOLCOLL_LABEL_FRAME
- RES_POOLCOLL_EXTRA_BEGIN
,
558 for(const sal_uInt16
* pIds
= nIds
; *pIds
; ++pIds
)
560 if(sTypeName
== *rExtraArr
[ *pIds
] )
562 bSetValue
= sal_False
;
569 // nothing special to be done here for the properties
570 // UNO_NAME_DATA_BASE_NAME and UNO_NAME_DATA_BASE_URL.
571 // We just call PutValue (empty string is allowed).
572 // Thus the last property set will be used as Data Source.
574 USHORT nMId
= GetFieldTypeMId( rPropertyName
, *pType
);
575 if( USHRT_MAX
!= nMId
)
576 pType
->PutValue( rValue
, nMId
);
578 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
581 else if(!pType
&& m_pDoc
&&
582 ( rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NAME
))) )
586 String
sTypeName(uTmp
);
587 SwFieldType
* pType2
= m_pDoc
->GetFldType(nResTypeId
, sTypeName
, sal_False
);
589 String
sTable(SW_RES(STR_POOLCOLL_LABEL_TABLE
));
590 String
sDrawing(SW_RES(STR_POOLCOLL_LABEL_DRAWING
));
591 String
sFrame(SW_RES(STR_POOLCOLL_LABEL_FRAME
));
592 String
sIllustration(SW_RES(STR_POOLCOLL_LABEL_ABB
));
595 (RES_SETEXPFLD
== nResTypeId
&&
596 ( sTypeName
== sTable
|| sTypeName
== sDrawing
||
597 sTypeName
== sFrame
|| sTypeName
== sIllustration
)))
599 throw lang::IllegalArgumentException();
607 SwUserFieldType
aType(m_pDoc
, sTypeName
);
608 pType2
= m_pDoc
->InsertFldType(aType
);
609 ((SwUserFieldType
*)pType2
)->SetContent(sParam1
);
610 ((SwUserFieldType
*)pType2
)->SetValue(fParam1
);
611 ((SwUserFieldType
*)pType2
)->SetType(bParam1
? nsSwGetSetExpType::GSE_EXPR
: nsSwGetSetExpType::GSE_STRING
);
616 SwDDEFieldType
aType(sTypeName
, sParam1
,
617 sal::static_int_cast
< USHORT
>(bParam1
? sfx2::LINKUPDATE_ALWAYS
: sfx2::LINKUPDATE_ONCALL
));
618 pType2
= m_pDoc
->InsertFldType(aType
);
623 SwSetExpFieldType
aType(m_pDoc
, sTypeName
);
625 aType
.SetDelimiter( sParam1
.GetChar(0));
626 if(nParam1
> -1 && nParam1
< MAXLEVEL
)
627 aType
.SetOutlineLvl(nParam1
);
628 pType2
= m_pDoc
->InsertFldType(aType
);
633 ::GetString( rValue
, sParam3
);
634 pType
= GetFldType();
641 m_bIsDescriptor
= sal_False
;
644 throw uno::RuntimeException();
647 DBG_ASSERT(pType2
, "kein FieldType gefunden!" );
654 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CONTENT
)))
655 ::GetString( rValue
, sParam1
);
656 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_VALUE
)))
658 if(rValue
.getValueType() != ::getCppuType(static_cast<const double*>(0)))
659 throw lang::IllegalArgumentException();
660 fParam1
= *(double*)rValue
.getValue();
662 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_EXPRESSION
)))
664 if(rValue
.getValueType() != ::getBooleanCppuType())
665 throw lang::IllegalArgumentException();
666 bParam1
= *(sal_Bool
*)rValue
.getValue();
671 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME
)))
672 ::GetString( rValue
, sParam1
);
673 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_TABLE_NAME
)))
674 ::GetString( rValue
, sParam2
);
675 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COLUMN_NAME
)))
676 ::GetString( rValue
, sParam3
);
677 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COMMAND_TYPE
)))
679 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL
)))
680 ::GetString( rValue
, sParam5
);
682 if((sParam1
.Len() || sParam5
.Len())
683 && sParam2
.Len() && sParam3
.Len())
687 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NUMBERING_SEPARATOR
)))
688 ::GetString( rValue
, sParam1
);
689 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAPTER_NUMBERING_LEVEL
)))
694 USHORT nPart
= rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DDE_COMMAND_TYPE
)) ? 0 :
695 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DDE_COMMAND_FILE
)) ? 1 :
696 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DDE_COMMAND_ELEMENT
)) ? 2 :
697 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_AUTOMATIC_UPDATE
)) ? 3 : USHRT_MAX
;
702 (sParam1
= sfx2::cTokenSeperator
)
703 += sfx2::cTokenSeperator
;
705 sParam1
.SetToken( nPart
, sfx2::cTokenSeperator
,
706 ::GetString( rValue
, sTmp
));
709 bParam1
= *(sal_Bool
*)rValue
.getValue();
713 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
717 /* -----------------------------30.03.01 14:40--------------------------------
719 ---------------------------------------------------------------------------*/
720 SwFieldType
* SwXFieldMaster::GetFldType(sal_Bool bDontCreate
) const
722 if(!bDontCreate
&& RES_DBFLD
== nResTypeId
&& m_bIsDescriptor
&& m_pDoc
)
727 svx::ODataAccessDescriptor aAcc
;
728 if( sParam1
.Len() > 0 )
729 aAcc
[ svx::daDataSource
] <<= OUString(sParam1
); // DataBaseName
730 else if( sParam5
.Len() > 0 )
731 aAcc
[ svx::daDatabaseLocation
] <<= OUString(sParam5
); // DataBaseURL
732 aData
.sDataSource
= aAcc
.getDataSource();
734 aData
.sCommand
= sParam2
;
735 aData
.nCommandType
= nParam2
;
736 SwDBFieldType
aType(m_pDoc
, sParam3
, aData
);
737 SwFieldType
* pType
= m_pDoc
->InsertFldType(aType
);
738 SwXFieldMaster
* pThis
= ((SwXFieldMaster
*)this);
740 pThis
->m_bIsDescriptor
= sal_False
;
745 return (SwFieldType
*)GetRegisteredIn();
748 /*-- 14.12.98 11:08:36---------------------------------------------------
750 -----------------------------------------------------------------------*/
751 typedef SwFmtFld
* SwFmtFldPtr
;
752 SV_DECL_PTRARR(SwDependentFields
, SwFmtFldPtr
, 5, 5)
753 SV_IMPL_PTRARR(SwDependentFields
, SwFmtFldPtr
)
755 uno::Any
SwXFieldMaster::getPropertyValue(const OUString
& rPropertyName
)
756 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
758 vos::OGuard
aGuard(Application::GetSolarMutex());
760 SwFieldType
* pType
= GetFldType(sal_True
);
761 if( rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_INSTANCE_NAME
)) )
765 SwXTextFieldMasters::getInstanceName(*pType
, sName
);
766 aRet
<<= OUString(sName
);
770 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NAME
) ))
772 aRet
<<= SwXFieldMaster::GetProgrammaticName(*pType
, *GetDoc());
774 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DEPENDENT_TEXT_FIELDS
)) )
776 //fill all text fields into a sequence
777 SwClientIter
aIter( *pType
);
778 SwDependentFields aFldArr
;
779 SwFmtFldPtr pFld
= (SwFmtFld
*)aIter
.First( TYPE( SwFmtFld
));
782 if(pFld
->IsFldInDoc())
783 aFldArr
.Insert(pFld
, aFldArr
.Count());
784 pFld
= (SwFmtFld
*)aIter
.Next();
786 uno::Sequence
<uno::Reference
<text::XDependentTextField
> > aRetSeq(aFldArr
.Count());
787 uno::Reference
<text::XDependentTextField
>* pRetSeq
= aRetSeq
.getArray();
788 for(USHORT i
= 0; i
< aFldArr
.Count(); i
++)
790 pFld
= aFldArr
.GetObject(i
);
791 SwXTextField
* pInsert
= CreateSwXTextField(*GetDoc(), *pFld
);
793 pRetSeq
[i
] = uno::Reference
<text::XDependentTextField
>(pInsert
);
799 //TODO: Properties fuer die uebrigen Feldtypen einbauen
800 USHORT nMId
= GetFieldTypeMId( rPropertyName
, *pType
);
801 if( USHRT_MAX
!= nMId
)
803 pType
->QueryValue( aRet
, nMId
);
805 if( rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME
)) ||
806 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL
)))
808 OUString aDataSource
;
809 aRet
>>= aDataSource
;
812 OUString
*pStr
= 0; // only one of this properties will return
813 // a non-empty string.
815 aObj
.SetURL( aDataSource
);
816 BOOL bIsURL
= aObj
.GetProtocol() != INET_PROT_NOT_VALID
;
817 if (bIsURL
&& rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL
)))
818 pStr
= &aDataSource
; // DataBaseURL
819 else if (!bIsURL
&& rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME
)))
820 pStr
= &aDataSource
; // DataBaseName
827 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
831 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COMMAND_TYPE
)) )
837 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COMMAND_TYPE
)) )
839 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DEPENDENT_TEXT_FIELDS
)) )
841 uno::Sequence
<uno::Reference
<text::XDependentTextField
> > aRetSeq(0);
846 const String
* pStr
= 0;
848 switch ( nResTypeId
)
851 if( rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CONTENT
)) )
853 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_VALUE
)))
855 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_EXPRESSION
)))
856 aRet
.setValue(&bParam1
, ::getBooleanCppuType());
859 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME
)) ||
860 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL
)))
862 pStr
= 0; // only one of this properties will return
863 // a non-empty string.
865 aObj
.SetURL( sParam5
); // SetSmartURL
866 BOOL bIsURL
= aObj
.GetProtocol() != INET_PROT_NOT_VALID
;
867 if (bIsURL
&& rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL
)))
868 pStr
= &sParam5
; // DataBaseURL
869 else if ( rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME
)))
870 pStr
= &sParam1
; // DataBaseName
872 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_TABLE_NAME
)))
874 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COLUMN_NAME
)))
878 if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NUMBERING_SEPARATOR
)))
880 else if(rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAPTER_NUMBERING_LEVEL
)))
885 USHORT nPart
= rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DDE_COMMAND_TYPE
)) ? 0 :
886 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DDE_COMMAND_FILE
)) ? 1 :
887 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DDE_COMMAND_ELEMENT
)) ? 2 :
888 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_AUTOMATIC_UPDATE
)) ? 3 : USHRT_MAX
;
890 pStr
= &(sStr
= sParam1
.GetToken(nPart
, sfx2::cTokenSeperator
));
892 aRet
.setValue(&bParam1
, ::getBooleanCppuType());
896 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
900 aRet
<<= OUString( *pStr
);
905 /*-- 14.12.98 11:08:36---------------------------------------------------
907 -----------------------------------------------------------------------*/
908 void SwXFieldMaster::addPropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
910 DBG_WARNING("not implemented");
912 /*-- 14.12.98 11:08:36---------------------------------------------------
914 -----------------------------------------------------------------------*/
915 void SwXFieldMaster::removePropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
917 DBG_WARNING("not implemented");
919 /*-- 14.12.98 11:08:37---------------------------------------------------
921 -----------------------------------------------------------------------*/
922 void SwXFieldMaster::addVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
924 DBG_WARNING("not implemented");
926 /*-- 14.12.98 11:08:37---------------------------------------------------
928 -----------------------------------------------------------------------*/
929 void SwXFieldMaster::removeVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
931 DBG_WARNING("not implemented");
934 /*-- 25.02.99 11:01:57---------------------------------------------------
936 -----------------------------------------------------------------------*/
937 void SwXFieldMaster::dispose(void) throw( uno::RuntimeException
)
939 vos::OGuard
aGuard(Application::GetSolarMutex());
940 SwFieldType
* pFldType
= GetFldType(sal_True
);
943 sal_uInt16 nTypeIdx
= USHRT_MAX
;
944 const SwFldTypes
* pTypes
= GetDoc()->GetFldTypes();
945 for( sal_uInt16 i
= 0; i
< pTypes
->Count(); i
++ )
947 if((*pTypes
)[i
] == pFldType
)
951 // zuerst alle Felder loeschen
952 SwClientIter
aIter( *pFldType
);
953 SwFmtFld
* pFld
= (SwFmtFld
*)aIter
.First( TYPE( SwFmtFld
));
957 SwTxtFld
*pTxtFld
= pFld
->GetTxtFld();
958 if(pTxtFld
&& pTxtFld
->GetTxtNode().GetNodes().IsDocNodes() )
960 SwTxtNode
& rTxtNode
= (SwTxtNode
&)*pTxtFld
->GetpTxtNode();
961 SwPaM
aPam(rTxtNode
, *pTxtFld
->GetStart());
964 GetDoc()->DeleteAndJoin(aPam
);
966 pFld
= (SwFmtFld
*)aIter
.Next();
968 // dann den FieldType loeschen
969 GetDoc()->RemoveFldType(nTypeIdx
);
972 throw uno::RuntimeException();
974 /*-- 25.02.99 11:02:00---------------------------------------------------
976 -----------------------------------------------------------------------*/
977 void SwXFieldMaster::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
978 throw( uno::RuntimeException
)
980 if(!GetRegisteredIn())
981 throw uno::RuntimeException();
982 aLstnrCntnr
.AddListener(aListener
);
984 /*-- 25.02.99 11:02:02---------------------------------------------------
986 -----------------------------------------------------------------------*/
987 void SwXFieldMaster::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
988 throw( uno::RuntimeException
)
990 if(!GetRegisteredIn() || !aLstnrCntnr
.RemoveListener(aListener
))
991 throw uno::RuntimeException();
994 /*-- 14.12.98 11:08:38---------------------------------------------------
996 -----------------------------------------------------------------------*/
997 void SwXFieldMaster::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
999 ClientModify(this, pOld
, pNew
);
1000 if(!GetRegisteredIn())
1002 aLstnrCntnr
.Disposing();
1006 /* -----------------------------06.11.00 09:44--------------------------------
1008 const Programmatic2UIName_Impl* lcl_GetFieldNameTable()
1010 static BOOL bInitialized = FALSE;
1011 static Programmatic2UIName_Impl aFieldNames[5];
1014 bInitialized = TRUE;
1016 aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_ABB ));
1017 aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_ABB));
1018 aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_TABLE ));
1019 aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_TABLE));
1020 aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_FRAME));
1021 aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_FRAME));
1022 aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_DRAWING ));
1023 aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_DRAWING));
1025 return &aFieldNames[0];
1027 ---------------------------------------------------------------------------*/
1028 /* -----------------------------06.11.00 10:26--------------------------------
1030 ---------------------------------------------------------------------------*/
1031 OUString
SwXFieldMaster::GetProgrammaticName(const SwFieldType
& rType
, SwDoc
& rDoc
)
1033 OUString
sRet(rType
.GetName());
1034 if(RES_SETEXPFLD
== rType
.Which())
1036 const SwFldTypes
* pTypes
= rDoc
.GetFldTypes();
1037 for( sal_uInt16 i
= 0; i
<= INIT_FLDTYPES
; i
++ )
1039 if((*pTypes
)[i
] == &rType
)
1041 sRet
= SwStyleNameMapper::GetProgName ( sRet
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
1048 /* -----------------------------06.11.00 14:12--------------------------------
1050 ---------------------------------------------------------------------------*/
1051 OUString
SwXFieldMaster::LocalizeFormula(
1052 const SwSetExpField
& rFld
,
1053 const OUString
& rFormula
,
1056 const OUString
sTypeName(rFld
.GetTyp()->GetName());
1057 OUString sProgName
= SwStyleNameMapper::GetProgName(sTypeName
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
1058 if(sProgName
!= sTypeName
)
1060 OUString sSource
= bQuery
? sTypeName
: sProgName
;
1061 OUString sDest
= bQuery
? sProgName
: sTypeName
;
1062 if(!rFormula
.compareTo(sSource
, sSource
.getLength()))
1064 OUString sTmpFormula
= sDest
;
1065 sTmpFormula
+= rFormula
.copy(sSource
.getLength());
1073 SwXTextField
* CreateSwXTextField(SwDoc
& rDoc
, SwFmtFld
const& rFmt
)
1075 SwClientIter
aIter(*rFmt
.GetFld()->GetTyp());
1076 SwXTextField
* pField
= 0;
1077 SwXTextField
* pTemp
=
1078 static_cast<SwXTextField
*>(aIter
.First( TYPE(SwXTextField
) ));
1081 if (pTemp
->GetFldFmt() == &rFmt
)
1086 pTemp
= static_cast<SwXTextField
*>(aIter
.Next());
1088 return pField
? pField
: new SwXTextField( rFmt
, &rDoc
);
1091 /******************************************************************
1093 ******************************************************************/
1094 struct SwFieldProperties_Impl
1104 uno::Sequence
<beans::PropertyValue
> aPropSeq
;
1105 uno::Sequence
<OUString
> aStrings
;
1106 util::DateTime
* pDateTime
;
1110 sal_uInt16 nUSHORT1
;
1111 sal_uInt16 nUSHORT2
;
1114 sal_Bool bFormatIsDefault
;
1120 SwFieldProperties_Impl():
1129 bFormatIsDefault(sal_True
),
1133 bBool4(sal_True
) //Automatic language
1135 ~SwFieldProperties_Impl()
1140 TYPEINIT1(SwXTextField
, SwClient
);
1141 /* -----------------------------13.03.00 12:15--------------------------------
1143 ---------------------------------------------------------------------------*/
1144 const uno::Sequence
< sal_Int8
> & SwXTextField::getUnoTunnelId()
1146 static uno::Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
1149 /* -----------------------------10.03.00 18:04--------------------------------
1151 ---------------------------------------------------------------------------*/
1152 sal_Int64 SAL_CALL
SwXTextField::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
1153 throw(uno::RuntimeException
)
1155 if( rId
.getLength() == 16
1156 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1157 rId
.getConstArray(), 16 ) )
1159 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
1163 /*-- 14.12.98 11:37:14---------------------------------------------------
1165 -----------------------------------------------------------------------*/
1167 SwXTextField::SwXTextField(sal_uInt16 nServiceId
, SwDoc
* pDoc
) :
1168 aLstnrCntnr( (XTextContent
*)this),
1172 m_bIsDescriptor(nServiceId
!= USHRT_MAX
),
1173 m_bCallUpdate(sal_False
),
1174 m_nServiceId(nServiceId
),
1175 m_pProps(new SwFieldProperties_Impl
)
1177 //Set visible as default!
1178 if(SW_SERVICE_FIELDTYPE_SET_EXP
== nServiceId
||
1179 SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM
== nServiceId
||
1180 SW_SERVICE_FIELDTYPE_DATABASE
== nServiceId
||
1181 SW_SERVICE_FIELDTYPE_DATABASE_NAME
== nServiceId
)
1182 m_pProps
->bBool2
= sal_True
;
1183 else if(SW_SERVICE_FIELDTYPE_TABLE_FORMULA
== nServiceId
)
1184 m_pProps
->bBool1
= sal_True
;
1185 if(SW_SERVICE_FIELDTYPE_SET_EXP
== nServiceId
)
1186 m_pProps
->nUSHORT2
= USHRT_MAX
;
1189 /*-- 14.12.98 11:37:15---------------------------------------------------
1191 -----------------------------------------------------------------------*/
1192 SwXTextField::SwXTextField(const SwFmtFld
& rFmt
, SwDoc
* pDc
) :
1193 aLstnrCntnr( (XTextContent
*)this),
1197 m_bIsDescriptor(sal_False
),
1198 m_bCallUpdate(sal_False
),
1199 m_nServiceId( lcl_GetServiceForField( *pFmtFld
->GetFld() ) ),
1202 pDc
->GetUnoCallBack()->Add(this);
1204 /*-- 14.12.98 11:37:15---------------------------------------------------
1206 -----------------------------------------------------------------------*/
1207 SwXTextField::~SwXTextField()
1209 if ( m_pTextObject
)
1211 m_pTextObject
->DisposeEditSource();
1212 m_pTextObject
->release();
1217 /*-- 14.12.98 11:37:16---------------------------------------------------
1219 -----------------------------------------------------------------------*/
1220 void SwXTextField::attachTextFieldMaster(const uno::Reference
< beans::XPropertySet
> & xFieldMaster
)
1221 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1223 vos::OGuard
aGuard(Application::GetSolarMutex());
1224 if(!m_bIsDescriptor
)
1225 throw uno::RuntimeException();
1226 uno::Reference
< lang::XUnoTunnel
> xMasterTunnel(xFieldMaster
, uno::UNO_QUERY
);
1227 if (!xMasterTunnel
.is())
1228 throw lang::IllegalArgumentException();
1229 SwXFieldMaster
* pMaster
= reinterpret_cast< SwXFieldMaster
* >(
1230 sal::static_int_cast
< sal_IntPtr
>( xMasterTunnel
->getSomething( SwXFieldMaster::getUnoTunnelId()) ));
1232 SwFieldType
* pFieldType
= pMaster
? pMaster
->GetFldType() : 0;
1233 if(pFieldType
&& pFieldType
->Which() == lcl_ServiceIdToResId(m_nServiceId
))
1235 m_sTypeName
= pFieldType
->GetName();
1236 pFieldType
->Add( &m_aFieldTypeClient
);
1239 throw lang::IllegalArgumentException();
1242 /*-- 14.12.98 11:37:16---------------------------------------------------
1244 -----------------------------------------------------------------------*/
1245 uno::Reference
< beans::XPropertySet
> SwXTextField::getTextFieldMaster(void) throw( uno::RuntimeException
)
1247 vos::OGuard
aGuard(Application::GetSolarMutex());
1248 SwFieldType
* pType
= 0;
1249 if( m_bIsDescriptor
&& m_aFieldTypeClient
.GetRegisteredIn() )
1251 pType
= (SwFieldType
*)m_aFieldTypeClient
.GetRegisteredIn();
1255 if(!GetRegisteredIn())
1256 throw uno::RuntimeException();
1257 pType
= pFmtFld
->GetFld()->GetTyp();
1259 SwXFieldMaster
* pMaster
= (SwXFieldMaster
*)
1260 SwClientIter(*pType
).First(TYPE(SwXFieldMaster
));
1262 pMaster
= new SwXFieldMaster(*pType
, GetDoc());
1266 /*-- 14.12.98 11:37:16---------------------------------------------------
1268 -----------------------------------------------------------------------*/
1269 OUString
SwXTextField::getPresentation(sal_Bool bShowCommand
) throw( uno::RuntimeException
)
1271 vos::OGuard
aGuard(Application::GetSolarMutex());
1273 const SwField
* pField
= GetField();
1275 sRet
= pField
->GetCntnt(bShowCommand
);
1277 throw uno::RuntimeException();
1280 /* -----------------18.02.99 13:39-------------------
1282 * --------------------------------------------------*/
1283 void SwXTextField::attachToRange(
1284 const uno::Reference
< text::XTextRange
> & xTextRange
)
1285 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1287 vos::OGuard
aGuard(Application::GetSolarMutex());
1288 if(!m_bIsDescriptor
)
1289 throw uno::RuntimeException();
1290 uno::Reference
<lang::XUnoTunnel
> xRangeTunnel( xTextRange
, uno::UNO_QUERY
);
1291 SwXTextRange
* pRange
= 0;
1292 OTextCursorHelper
* pCursor
= 0;
1293 if(xRangeTunnel
.is())
1295 pRange
= reinterpret_cast< SwXTextRange
* >(
1296 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( SwXTextRange::getUnoTunnelId()) ));
1297 pCursor
= reinterpret_cast< OTextCursorHelper
* >(
1298 sal::static_int_cast
< sal_IntPtr
>( xRangeTunnel
->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
1301 SwDoc
* pDoc
= pRange
? (SwDoc
*)pRange
->GetDoc() : pCursor
? (SwDoc
*)pCursor
->GetDoc() : 0;
1302 //wurde ein FieldMaster attached, dann ist das Dokument schon festgelegt!
1303 if(pDoc
&& (!m_pDoc
|| m_pDoc
== pDoc
))
1305 SwUnoInternalPaM
aPam(*pDoc
);
1306 //das muss jetzt sal_True liefern
1307 SwXTextRange::XTextRangeToSwPaM(aPam
, xTextRange
);
1309 switch(m_nServiceId
)
1311 case SW_SERVICE_FIELDTYPE_ANNOTATION
:
1313 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_POSTITFLD
);
1316 if (m_pProps
->pDateTime
)
1318 aDateTime
.SetYear(m_pProps
->pDateTime
->Year
);
1319 aDateTime
.SetMonth(m_pProps
->pDateTime
->Month
);
1320 aDateTime
.SetDay(m_pProps
->pDateTime
->Day
);
1321 aDateTime
.SetHour(m_pProps
->pDateTime
->Hours
);
1322 aDateTime
.SetMin(m_pProps
->pDateTime
->Minutes
);
1323 aDateTime
.SetSec(m_pProps
->pDateTime
->Seconds
);
1325 pFld
= new SwPostItField((SwPostItFieldType
*)pFldType
,
1326 m_pProps
->sPar1
, m_pProps
->sPar2
,aDateTime
);
1327 if ( m_pTextObject
)
1329 ((SwPostItField
*)pFld
)->SetTextObject( m_pTextObject
->CreateText() );
1330 ((SwPostItField
*)pFld
)->SetPar2(m_pTextObject
->GetText());
1334 case SW_SERVICE_FIELDTYPE_SCRIPT
:
1336 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_SCRIPTFLD
);
1337 pFld
= new SwScriptField((SwScriptFieldType
*)pFldType
,
1338 m_pProps
->sPar1
, m_pProps
->sPar2
,
1342 case SW_SERVICE_FIELDTYPE_DATETIME
:
1344 sal_uInt16 nSub
= 0;
1345 if(m_pProps
->bBool1
)
1347 if(m_pProps
->bBool2
)
1351 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_DATETIMEFLD
);
1352 pFld
= new SwDateTimeField((SwDateTimeFieldType
*)pFldType
,
1353 nSub
, m_pProps
->nFormat
);
1354 if(m_pProps
->fDouble
> 0.)
1355 ((SwDateTimeField
*)pFld
)->SetValue( m_pProps
->fDouble
);
1356 if(m_pProps
->pDateTime
)
1358 uno::Any aVal
; aVal
<<= *m_pProps
->pDateTime
;
1359 pFld
->PutValue( aVal
, FIELD_PROP_DATE_TIME
);
1361 ((SwDateTimeField
*)pFld
)->SetOffset(m_pProps
->nSubType
);
1364 case SW_SERVICE_FIELDTYPE_FILE_NAME
:
1366 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_FILENAMEFLD
);
1367 sal_Int32 nFormat
= m_pProps
->nFormat
;
1368 if(m_pProps
->bBool2
)
1369 nFormat
|= FF_FIXED
;
1370 pFld
= new SwFileNameField((SwFileNameFieldType
*)pFldType
, nFormat
);
1371 if(m_pProps
->sPar3
.Len())
1372 ((SwFileNameField
*)pFld
)->SetExpansion(m_pProps
->sPar3
);
1373 uno::Any
aFormat(&m_pProps
->nFormat
, ::getCppuType(&m_pProps
->nFormat
));
1374 pFld
->PutValue( aFormat
, FIELD_PROP_FORMAT
);
1377 case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME
:
1379 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_TEMPLNAMEFLD
);
1380 pFld
= new SwTemplNameField((SwTemplNameFieldType
*)pFldType
,
1382 uno::Any
aFormat(&m_pProps
->nFormat
, ::getCppuType(&m_pProps
->nFormat
));
1383 pFld
->PutValue(aFormat
, FIELD_PROP_FORMAT
);
1386 case SW_SERVICE_FIELDTYPE_CHAPTER
:
1388 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_CHAPTERFLD
);
1389 pFld
= new SwChapterField((SwChapterFieldType
*)pFldType
, m_pProps
->nUSHORT1
);
1390 ((SwChapterField
*)pFld
)->SetLevel(m_pProps
->nByte1
);
1391 uno::Any aVal
; aVal
<<= (sal_Int16
)m_pProps
->nUSHORT1
;
1392 pFld
->PutValue(aVal
, FIELD_PROP_USHORT1
);
1395 case SW_SERVICE_FIELDTYPE_AUTHOR
:
1397 long nFormat
= m_pProps
->bBool1
? AF_NAME
: AF_SHORTCUT
;
1398 if(m_pProps
->bBool2
)
1399 nFormat
|= AF_FIXED
;
1401 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_AUTHORFLD
);
1402 pFld
= new SwAuthorField((SwAuthorFieldType
*)pFldType
, nFormat
);
1403 ((SwAuthorField
*)pFld
)->SetExpansion(m_pProps
->sPar1
);
1406 case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT
:
1407 case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT
:
1409 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_HIDDENTXTFLD
);
1410 pFld
= new SwHiddenTxtField(((SwHiddenTxtFieldType
*)pFldType
),
1412 m_pProps
->sPar2
, m_pProps
->sPar3
,
1413 static_cast< USHORT
>(SW_SERVICE_FIELDTYPE_HIDDEN_TEXT
== m_nServiceId
?
1414 TYP_HIDDENTXTFLD
: TYP_CONDTXTFLD
));
1415 ((SwHiddenTxtField
*)pFld
)->SetValue(m_pProps
->bBool1
);
1416 uno::Any aVal
; aVal
<<= (OUString
)m_pProps
->sPar4
;
1417 pFld
->PutValue(aVal
, FIELD_PROP_PAR4
);
1420 case SW_SERVICE_FIELDTYPE_HIDDEN_PARA
:
1422 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_HIDDENPARAFLD
);
1423 pFld
= new SwHiddenParaField((SwHiddenParaFieldType
*)pFldType
,
1425 ((SwHiddenParaField
*)pFld
)->SetHidden(m_pProps
->bBool1
);
1428 case SW_SERVICE_FIELDTYPE_GET_REFERENCE
:
1430 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_GETREFFLD
);
1431 pFld
= new SwGetRefField((SwGetRefFieldType
*)pFldType
,
1436 if(m_pProps
->sPar3
.Len())
1437 ((SwGetRefField
*)pFld
)->SetExpand(m_pProps
->sPar3
);
1438 uno::Any aVal
; aVal
<<=(sal_Int16
)m_pProps
->nUSHORT1
;
1439 pFld
->PutValue(aVal
, FIELD_PROP_USHORT1
);
1440 aVal
<<=(sal_Int16
)m_pProps
->nUSHORT2
;
1441 pFld
->PutValue(aVal
, FIELD_PROP_USHORT2
);
1442 aVal
<<=(sal_Int16
)m_pProps
->nSHORT1
;
1443 pFld
->PutValue(aVal
, FIELD_PROP_SHORT1
);
1446 case SW_SERVICE_FIELDTYPE_JUMP_EDIT
:
1448 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_JUMPEDITFLD
);
1449 pFld
= new SwJumpEditField((SwJumpEditFieldType
*)pFldType
,
1450 m_pProps
->nUSHORT1
, m_pProps
->sPar2
, m_pProps
->sPar1
);
1453 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR
:
1454 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME
:
1455 case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME
:
1456 case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION
:
1457 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR
:
1458 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME
:
1459 case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM
:
1460 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR
:
1461 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME
:
1462 case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS
:
1463 case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT
:
1464 case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE
:
1465 case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION
:
1466 case SW_SERVICE_FIELDTYPE_DOC_INFO
:
1468 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_DOCINFOFLD
);
1469 sal_uInt16 nSubType
= aDocInfoSubTypeFromService
[
1470 m_nServiceId
- SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR
];
1471 if( SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME
== m_nServiceId
||
1472 SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME
== m_nServiceId
||
1473 SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME
== m_nServiceId
||
1474 SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME
== m_nServiceId
)
1476 if(m_pProps
->bBool2
) //IsDate
1479 nSubType
|= DI_SUB_DATE
;
1484 nSubType
|= DI_SUB_TIME
;
1487 if(m_pProps
->bBool1
)
1488 nSubType
|= DI_SUB_FIXED
;
1489 pFld
= new SwDocInfoField((SwDocInfoFieldType
*)pFldType
, nSubType
, m_pProps
->sPar4
, m_pProps
->nFormat
);
1490 if(m_pProps
->sPar3
.Len())
1491 ((SwDocInfoField
*)pFld
)->SetExpansion(m_pProps
->sPar3
);
1494 case SW_SERVICE_FIELDTYPE_USER_EXT
:
1496 sal_Int32 nFormat
= 0;
1497 if(m_pProps
->bBool1
)
1500 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_EXTUSERFLD
);
1501 pFld
= new SwExtUserField((SwExtUserFieldType
*)pFldType
, m_pProps
->nUSHORT1
, nFormat
);
1502 ((SwExtUserField
*)pFld
)->SetExpansion(m_pProps
->sPar1
);
1505 case SW_SERVICE_FIELDTYPE_USER
:
1507 SwFieldType
* pFldType
= pDoc
->GetFldType(RES_USERFLD
, m_sTypeName
, sal_True
);
1509 throw uno::RuntimeException();
1510 USHORT nUserSubType
= m_pProps
->bBool1
? nsSwExtendedSubType::SUB_INVISIBLE
: 0;
1511 if(m_pProps
->bBool2
)
1512 nUserSubType
|= nsSwExtendedSubType::SUB_CMD
;
1513 if(m_pProps
->bFormatIsDefault
&&
1514 nsSwGetSetExpType::GSE_STRING
== ((SwUserFieldType
*)pFldType
)->GetType())
1515 m_pProps
->nFormat
= -1;
1516 pFld
= new SwUserField((SwUserFieldType
*)pFldType
,
1521 case SW_SERVICE_FIELDTYPE_REF_PAGE_SET
:
1523 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_REFPAGESETFLD
);
1524 pFld
= new SwRefPageSetField( (SwRefPageSetFieldType
*)pFldType
,
1529 case SW_SERVICE_FIELDTYPE_REF_PAGE_GET
:
1531 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_REFPAGEGETFLD
);
1532 pFld
= new SwRefPageGetField( (SwRefPageGetFieldType
*)pFldType
,
1533 m_pProps
->nUSHORT1
);
1534 ((SwRefPageGetField
*)pFld
)->SetText(m_pProps
->sPar1
);
1537 case SW_SERVICE_FIELDTYPE_PAGE_NUM
:
1539 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_PAGENUMBERFLD
);
1540 pFld
= new SwPageNumberField((SwPageNumberFieldType
*)pFldType
,
1543 m_pProps
->nUSHORT1
);
1544 ((SwPageNumberField
*)pFld
)->SetUserString(m_pProps
->sPar1
);
1545 uno::Any aVal
; aVal
<<= m_pProps
->nSubType
;
1546 pFld
->PutValue( aVal
, FIELD_PROP_SUBTYPE
);
1549 case SW_SERVICE_FIELDTYPE_DDE
:
1551 SwFieldType
* pFldType
= pDoc
->GetFldType(RES_DDEFLD
, m_sTypeName
, sal_True
);
1553 throw uno::RuntimeException();
1554 pFld
= new SwDDEField( (SwDDEFieldType
*)pFldType
);
1557 case SW_SERVICE_FIELDTYPE_DATABASE_NAME
:
1559 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_DBNAMEFLD
);
1561 aData
.sDataSource
= m_pProps
->sPar1
;
1562 aData
.sCommand
= m_pProps
->sPar2
;
1563 aData
.nCommandType
= m_pProps
->nSHORT1
;
1564 pFld
= new SwDBNameField((SwDBNameFieldType
*)pFldType
, aData
);
1565 sal_uInt16 nSubType
= pFld
->GetSubType();
1566 if(m_pProps
->bBool2
)
1567 nSubType
&= ~nsSwExtendedSubType::SUB_INVISIBLE
;
1569 nSubType
|= nsSwExtendedSubType::SUB_INVISIBLE
;
1570 pFld
->SetSubType(nSubType
);
1573 case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET
:
1576 aData
.sDataSource
= m_pProps
->sPar1
;
1577 aData
.sCommand
= m_pProps
->sPar2
;
1578 aData
.nCommandType
= m_pProps
->nSHORT1
;
1579 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_DBNEXTSETFLD
);
1580 pFld
= new SwDBNextSetField((SwDBNextSetFieldType
*)pFldType
,
1581 m_pProps
->sPar3
, aEmptyStr
,
1585 case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET
:
1588 aData
.sDataSource
= m_pProps
->sPar1
;
1589 aData
.sCommand
= m_pProps
->sPar2
;
1590 aData
.nCommandType
= m_pProps
->nSHORT1
;
1591 pFld
= new SwDBNumSetField( (SwDBNumSetFieldType
*)
1592 pDoc
->GetSysFldType(RES_DBNUMSETFLD
),
1594 String::CreateFromInt32(m_pProps
->nFormat
),
1598 case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM
:
1601 aData
.sDataSource
= m_pProps
->sPar1
;
1602 aData
.sCommand
= m_pProps
->sPar2
;
1603 aData
.nCommandType
= m_pProps
->nSHORT1
;
1604 pFld
= new SwDBSetNumberField((SwDBSetNumberFieldType
*)
1605 pDoc
->GetSysFldType(RES_DBSETNUMBERFLD
),
1607 m_pProps
->nUSHORT1
);
1608 ((SwDBSetNumberField
*)pFld
)->SetSetNumber(m_pProps
->nFormat
);
1609 sal_uInt16 nSubType
= pFld
->GetSubType();
1610 if(m_pProps
->bBool2
)
1611 nSubType
&= ~nsSwExtendedSubType::SUB_INVISIBLE
;
1613 nSubType
|= nsSwExtendedSubType::SUB_INVISIBLE
;
1614 pFld
->SetSubType(nSubType
);
1617 case SW_SERVICE_FIELDTYPE_DATABASE
:
1619 SwFieldType
* pFldType
= pDoc
->GetFldType(RES_DBFLD
, m_sTypeName
, sal_False
);
1621 throw uno::RuntimeException();
1622 pFld
= new SwDBField((SwDBFieldType
*)pFldType
, m_pProps
->nFormat
);
1623 ((SwDBField
*)pFld
)->InitContent(m_pProps
->sPar1
);
1624 sal_uInt16 nSubType
= pFld
->GetSubType();
1625 if(m_pProps
->bBool2
)
1626 nSubType
&= ~nsSwExtendedSubType::SUB_INVISIBLE
;
1628 nSubType
|= nsSwExtendedSubType::SUB_INVISIBLE
;
1629 pFld
->SetSubType(nSubType
);
1632 case SW_SERVICE_FIELDTYPE_SET_EXP
:
1634 SwFieldType
* pFldType
= pDoc
->GetFldType(RES_SETEXPFLD
, m_sTypeName
, sal_True
);
1636 throw uno::RuntimeException();
1637 //#93192# detect the field type's sub type and set an appropriate number format
1638 if(m_pProps
->bFormatIsDefault
&&
1639 nsSwGetSetExpType::GSE_STRING
== ((SwSetExpFieldType
*)pFldType
)->GetType())
1640 m_pProps
->nFormat
= -1;
1641 pFld
= new SwSetExpField((SwSetExpFieldType
*)pFldType
,
1643 m_pProps
->nUSHORT2
!= USHRT_MAX
? //#i79471# the field can have a number format or a number_ing_ format
1644 m_pProps
->nUSHORT2
: m_pProps
->nFormat
);
1646 sal_uInt16 nSubType
= pFld
->GetSubType();
1647 if(m_pProps
->bBool2
)
1648 nSubType
&= ~nsSwExtendedSubType::SUB_INVISIBLE
;
1650 nSubType
|= nsSwExtendedSubType::SUB_INVISIBLE
;
1651 if(m_pProps
->bBool3
)
1652 nSubType
|= nsSwExtendedSubType::SUB_CMD
;
1654 nSubType
&= ~nsSwExtendedSubType::SUB_CMD
;
1655 pFld
->SetSubType(nSubType
);
1656 ((SwSetExpField
*)pFld
)->SetSeqNumber( m_pProps
->nUSHORT1
);
1657 ((SwSetExpField
*)pFld
)->SetInputFlag(m_pProps
->bBool1
);
1658 ((SwSetExpField
*)pFld
)->SetPromptText(m_pProps
->sPar3
);
1659 if(m_pProps
->sPar4
.Len())
1660 ((SwSetExpField
*)pFld
)->ChgExpStr(m_pProps
->sPar4
);
1664 case SW_SERVICE_FIELDTYPE_GET_EXP
:
1666 sal_uInt16 nSubType
;
1667 switch(m_pProps
->nSubType
)
1669 case text::SetVariableType::STRING
: nSubType
= nsSwGetSetExpType::GSE_STRING
; break;
1670 case text::SetVariableType::VAR
: nSubType
= nsSwGetSetExpType::GSE_EXPR
; break;
1671 //case text::SetVariableType::SEQUENCE: nSubType = nsSwGetSetExpType::GSE_SEQ; break;
1672 case text::SetVariableType::FORMULA
: nSubType
= nsSwGetSetExpType::GSE_FORMULA
; break;
1674 DBG_ERROR("wrong value");
1675 nSubType
= nsSwGetSetExpType::GSE_EXPR
;
1677 //make sure the SubType matches the field type
1678 SwFieldType
* pSetExpFld
= pDoc
->GetFldType(RES_SETEXPFLD
, m_pProps
->sPar1
, sal_False
);
1679 bool bSetGetExpFieldUninitialized
= false;
1682 if( nSubType
!= nsSwGetSetExpType::GSE_STRING
&&
1683 static_cast< SwSetExpFieldType
* >(pSetExpFld
)->GetType() == nsSwGetSetExpType::GSE_STRING
)
1684 nSubType
= nsSwGetSetExpType::GSE_STRING
;
1687 bSetGetExpFieldUninitialized
= true; // #i82544#
1689 if(m_pProps
->bBool2
)
1690 nSubType
|= nsSwExtendedSubType::SUB_CMD
;
1692 nSubType
&= ~nsSwExtendedSubType::SUB_CMD
;
1693 pFld
= new SwGetExpField((SwGetExpFieldType
*)
1694 pDoc
->GetSysFldType(RES_GETEXPFLD
),
1695 m_pProps
->sPar1
, nSubType
, m_pProps
->nFormat
);
1696 //TODO: SubType auswerten!
1697 if(m_pProps
->sPar4
.Len())
1698 ((SwGetExpField
*)pFld
)->ChgExpStr(m_pProps
->sPar4
);
1700 if( bSetGetExpFieldUninitialized
)
1701 ((SwGetExpField
*)pFld
)->SetLateInitialization();
1704 case SW_SERVICE_FIELDTYPE_INPUT_USER
:
1705 case SW_SERVICE_FIELDTYPE_INPUT
:
1707 SwFieldType
* pFldType
= pDoc
->GetFldType(RES_INPUTFLD
, m_sTypeName
, sal_True
);
1709 throw uno::RuntimeException();
1710 USHORT nInpSubType
= sal::static_int_cast
< USHORT
>(SW_SERVICE_FIELDTYPE_INPUT_USER
== m_nServiceId
? INP_USR
: INP_TXT
);
1711 SwInputField
* pTxtField
=
1712 new SwInputField((SwInputFieldType
*)pFldType
,
1713 m_pProps
->sPar1
, m_pProps
->sPar2
,
1715 pTxtField
->SetHelp(m_pProps
->sPar3
);
1716 pTxtField
->SetToolTip(m_pProps
->sPar4
);
1721 case SW_SERVICE_FIELDTYPE_MACRO
:
1723 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_MACROFLD
);
1726 // support for Scripting Framework macros
1727 if (m_pProps
->sPar4
.Len() != 0)
1729 aName
= m_pProps
->sPar4
;
1733 SwMacroField::CreateMacroString(
1734 aName
, m_pProps
->sPar1
, m_pProps
->sPar3
);
1736 pFld
= new SwMacroField((SwMacroFieldType
*)pFldType
, aName
,
1740 case SW_SERVICE_FIELDTYPE_PAGE_COUNT
:
1741 case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT
:
1742 case SW_SERVICE_FIELDTYPE_WORD_COUNT
:
1743 case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT
:
1744 case SW_SERVICE_FIELDTYPE_TABLE_COUNT
:
1745 case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT
:
1746 case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT
:
1748 sal_uInt16 nSubType
= DS_PAGE
;
1749 switch(m_nServiceId
)
1751 // case SW_SERVICE_FIELDTYPE_PAGE_COUNT : break;
1752 case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT
: nSubType
= DS_PARA
;break;
1753 case SW_SERVICE_FIELDTYPE_WORD_COUNT
: nSubType
= DS_WORD
;break;
1754 case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT
: nSubType
= DS_CHAR
;break;
1755 case SW_SERVICE_FIELDTYPE_TABLE_COUNT
: nSubType
= DS_TBL
;break;
1756 case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT
: nSubType
= DS_GRF
;break;
1757 case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT
: nSubType
= DS_OLE
;break;
1759 SwFieldType
* pFldType
= pDoc
->GetSysFldType(RES_DOCSTATFLD
);
1760 pFld
= new SwDocStatField((SwDocStatFieldType
*)pFldType
, nSubType
, m_pProps
->nUSHORT2
);
1763 case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY
:
1764 pFld
= new SwAuthorityField( (SwAuthorityFieldType
*)
1765 pDoc
->InsertFldType(SwAuthorityFieldType(pDoc
)),
1767 if(m_pProps
->aPropSeq
.getLength())
1769 uno::Any aVal
; aVal
<<= m_pProps
->aPropSeq
;
1770 pFld
->PutValue( aVal
, FIELD_PROP_PROP_SEQ
);
1773 case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS
:
1775 pFld
= new SwCombinedCharField( (SwCombinedCharFieldType
*)
1776 pDoc
->GetSysFldType(RES_COMBINED_CHARS
),
1779 case SW_SERVICE_FIELDTYPE_DROPDOWN
:
1780 pFld
= new SwDropDownField
1781 ((SwDropDownFieldType
*)
1782 pDoc
->GetSysFldType(RES_DROPDOWN
));
1784 ((SwDropDownField
*) pFld
)->SetItems(m_pProps
->aStrings
);
1785 ((SwDropDownField
*) pFld
)->SetSelectedItem(m_pProps
->sPar1
);
1786 ((SwDropDownField
*) pFld
)->SetName(m_pProps
->sPar2
);
1787 ((SwDropDownField
*) pFld
)->SetHelp(m_pProps
->sPar3
);
1788 ((SwDropDownField
*) pFld
)->SetToolTip(m_pProps
->sPar4
);
1791 case SW_SERVICE_FIELDTYPE_TABLE_FORMULA
:
1795 USHORT nType
= nsSwGetSetExpType::GSE_FORMULA
;
1796 if(m_pProps
->bBool1
)
1798 nType
|= nsSwExtendedSubType::SUB_CMD
;
1799 if(m_pProps
->bFormatIsDefault
)
1800 m_pProps
->nFormat
= -1;
1802 pFld
= new SwTblField( (SwTblFieldType
*)
1803 pDoc
->GetSysFldType(RES_TABLEFLD
),
1807 ((SwTblField
*)pFld
)->ChgExpStr(m_pProps
->sPar1
);
1810 default: DBG_ERROR("was ist das fuer ein Typ?");
1814 pFld
->SetAutomaticLanguage(!m_pProps
->bBool4
);
1815 SwFmtFld
aFmt( *pFld
);
1817 UnoActionContext
aCont(pDoc
);
1818 SwTxtAttr
* pTxtAttr
= 0;
1820 pDoc
->DeleteAndJoin(aPam
);
1822 SwXTextCursor
const*const pTextCursor(
1823 dynamic_cast<SwXTextCursor
*>(pCursor
));
1824 const bool bForceExpandHints( (pTextCursor
)
1825 ? pTextCursor
->IsAtEndOfMeta() : false );
1826 const SetAttrMode nInsertFlags
= (bForceExpandHints
)
1827 ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND
1828 : nsSetAttrMode::SETATTR_DEFAULT
;
1830 pDoc
->InsertPoolItem(aPam
, aFmt
, nInsertFlags
);
1832 pTxtAttr
= aPam
.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
1833 aPam
.GetPoint()->nContent
.GetIndex()-1, RES_TXTATR_FIELD
);
1835 // was passiert mit dem Update der Felder ? (siehe fldmgr.cxx)
1838 const SwFmtFld
& rFld
= pTxtAttr
->GetFld();
1845 m_pDoc
->GetUnoCallBack()->Add(this);
1846 m_bIsDescriptor
= sal_False
;
1847 if(m_aFieldTypeClient
.GetRegisteredIn())
1848 const_cast<SwModify
*>(m_aFieldTypeClient
.GetRegisteredIn())->Remove(&m_aFieldTypeClient
);
1854 throw lang::IllegalArgumentException();
1856 /*-- 14.12.98 11:37:18---------------------------------------------------
1858 -----------------------------------------------------------------------*/
1859 void SwXTextField::attach(const uno::Reference
< text::XTextRange
> & xTextRange
)
1860 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
1862 vos::OGuard
aGuard(Application::GetSolarMutex());
1863 attachToRange( xTextRange
);
1865 /*-- 14.12.98 11:37:18---------------------------------------------------
1867 -----------------------------------------------------------------------*/
1868 uno::Reference
< text::XTextRange
> SwXTextField::getAnchor(void) throw( uno::RuntimeException
)
1870 vos::OGuard
aGuard(Application::GetSolarMutex());
1871 uno::Reference
< text::XTextRange
> aRef
;
1872 SwField
* pField
= (SwField
*)GetField();
1875 const SwTxtFld
* pTxtFld
= pFmtFld
->GetTxtFld();
1877 throw uno::RuntimeException();
1878 const SwTxtNode
& rTxtNode
= pTxtFld
->GetTxtNode();
1880 SwPaM
aPam(rTxtNode
, *pTxtFld
->GetStart() + 1, rTxtNode
, *pTxtFld
->GetStart());
1882 aRef
= SwXTextRange::CreateTextRangeFromPosition(m_pDoc
,
1883 *aPam
.GetPoint(), aPam
.GetMark());
1888 /*-- 14.12.98 11:37:18---------------------------------------------------
1890 -----------------------------------------------------------------------*/
1891 void SwXTextField::dispose(void) throw( uno::RuntimeException
)
1893 vos::OGuard
aGuard(Application::GetSolarMutex());
1894 SwField
* pField
= (SwField
*)GetField();
1897 UnoActionContext
aContext(GetDoc());
1898 const SwTxtFld
* pTxtFld
= pFmtFld
->GetTxtFld();
1899 SwTxtNode
& rTxtNode
= (SwTxtNode
&)*pTxtFld
->GetpTxtNode();
1900 SwPaM
aPam(rTxtNode
, *pTxtFld
->GetStart());
1903 GetDoc()->DeleteAndJoin(aPam
);
1906 if ( m_pTextObject
)
1908 m_pTextObject
->DisposeEditSource();
1909 m_pTextObject
->release();
1913 /*-- 14.12.98 11:37:18---------------------------------------------------
1915 -----------------------------------------------------------------------*/
1916 void SwXTextField::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
1918 if(!GetRegisteredIn())
1919 throw uno::RuntimeException();
1920 aLstnrCntnr
.AddListener(aListener
);
1922 /*-- 14.12.98 11:37:18---------------------------------------------------
1924 -----------------------------------------------------------------------*/
1925 void SwXTextField::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
1927 if(!GetRegisteredIn() || !aLstnrCntnr
.RemoveListener(aListener
))
1928 throw uno::RuntimeException();
1930 /*-- 14.12.98 11:37:19---------------------------------------------------
1932 -----------------------------------------------------------------------*/
1933 uno::Reference
< beans::XPropertySetInfo
> SwXTextField::getPropertySetInfo(void)
1934 throw( uno::RuntimeException
)
1936 vos::OGuard
aGuard(Application::GetSolarMutex());
1938 uno::Reference
< beans::XPropertySetInfo
> aRef
;
1939 if(m_nServiceId
!= USHRT_MAX
)
1941 const SfxItemPropertySet
* pPropSet
= aSwMapProvider
.GetPropertySet(
1942 lcl_GetPropertyMapOfService( m_nServiceId
));
1943 uno::Reference
< beans::XPropertySetInfo
> xInfo
= pPropSet
->getPropertySetInfo();
1944 // extend PropertySetInfo!
1945 const uno::Sequence
<beans::Property
> aPropSeq
= xInfo
->getProperties();
1946 aRef
= new SfxExtItemPropertySetInfo(
1947 aSwMapProvider
.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS
),
1951 throw uno::RuntimeException();
1954 /*-- 14.12.98 11:37:19---------------------------------------------------
1956 -----------------------------------------------------------------------*/
1957 void SwXTextField::setPropertyValue(const OUString
& rPropertyName
, const uno::Any
& rValue
)
1958 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
,
1959 lang::WrappedTargetException
, uno::RuntimeException
)
1961 vos::OGuard
aGuard(Application::GetSolarMutex());
1962 SwField
* pField
= (SwField
*)GetField();
1963 const SfxItemPropertySet
* _pPropSet
= aSwMapProvider
.GetPropertySet(
1964 lcl_GetPropertyMapOfService( m_nServiceId
));
1965 const SfxItemPropertySimpleEntry
* pEntry
= _pPropSet
->getPropertyMap()->getByName(rPropertyName
);
1968 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1969 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
1970 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
1974 // Sonderbehandlung Serienbrieffeld
1975 sal_uInt16 nWhich
= pField
->Which();
1976 if( RES_DBFLD
== nWhich
&&
1977 (rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME
)) ||
1978 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL
))||
1979 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_TABLE_NAME
))||
1980 rPropertyName
.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COLUMN_NAME
))))
1982 // hier muss ein neuer Feldtyp angelegt werden und
1983 // das Feld an den neuen Typ umgehaengt werden
1984 DBG_WARNING("not implemented");
1989 SwDoc
* pDoc
= GetDoc();
1993 const SwTxtFld
* pTxtFld
= pFmtFld
->GetTxtFld();
1995 throw uno::RuntimeException();
1996 SwPosition
aPosition( pTxtFld
->GetTxtNode() );
1997 aPosition
.nContent
= *pTxtFld
->GetStart();
1998 pDoc
->PutValueToField( aPosition
, rValue
, pEntry
->nWID
);
2002 pField
->PutValue( rValue
, pEntry
->nWID
);
2004 //#i100374# notify SwPostIt about new field content
2005 if (RES_POSTITFLD
== nWhich
&& pFmtFld
)
2007 const_cast<SwFmtFld
*>(pFmtFld
)->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED
));
2010 //#114571# changes of the expanded string have to be notified
2012 if(RES_DBFLD
== nWhich
&& pFmtFld
->GetTxtFld())
2014 pFmtFld
->GetTxtFld()->Expand();
2017 //#i100374# changing a document field should set the modify flag
2018 SwDoc
* pDoc
= GetDoc();
2020 pDoc
->SetModified();
2027 switch(pEntry
->nWID
)
2029 case FIELD_PROP_PAR1
:
2030 pStr
= &m_pProps
->sPar1
;
2032 case FIELD_PROP_PAR2
:
2033 pStr
= &m_pProps
->sPar2
;
2035 case FIELD_PROP_PAR3
:
2036 pStr
= &m_pProps
->sPar3
;
2038 case FIELD_PROP_PAR4
:
2039 pStr
= &m_pProps
->sPar4
;
2041 case FIELD_PROP_FORMAT
:
2042 rValue
>>= m_pProps
->nFormat
;
2043 m_pProps
->bFormatIsDefault
= sal_False
;
2045 case FIELD_PROP_SUBTYPE
:
2046 m_pProps
->nSubType
= SWUnoHelper::GetEnumAsInt32( rValue
);
2048 case FIELD_PROP_BYTE1
:
2049 rValue
>>= m_pProps
->nByte1
;
2051 case FIELD_PROP_BOOL1
:
2052 pBool
= &m_pProps
->bBool1
;
2054 case FIELD_PROP_BOOL2
:
2055 pBool
= &m_pProps
->bBool2
;
2057 case FIELD_PROP_BOOL3
:
2058 pBool
= &m_pProps
->bBool3
;
2060 case FIELD_PROP_BOOL4
:
2061 pBool
= &m_pProps
->bBool4
;
2063 case FIELD_PROP_DATE
:
2065 if(rValue
.getValueType() != ::getCppuType(static_cast<const util::Date
*>(0)))
2066 throw lang::IllegalArgumentException();
2068 util::Date aTemp
= *(const util::Date
*)rValue
.getValue();
2069 m_pProps
->aDate
= Date(aTemp
.Day
, aTemp
.Month
, aTemp
.Year
);
2072 case FIELD_PROP_USHORT1
:
2073 case FIELD_PROP_USHORT2
:
2077 if( FIELD_PROP_USHORT1
== pEntry
->nWID
)
2078 m_pProps
->nUSHORT1
= nVal
;
2080 m_pProps
->nUSHORT2
= nVal
;
2083 case FIELD_PROP_SHORT1
:
2084 rValue
>>= m_pProps
->nSHORT1
;
2086 case FIELD_PROP_DOUBLE
:
2087 if(rValue
.getValueType() != ::getCppuType(static_cast<const double*>(0)))
2088 throw lang::IllegalArgumentException();
2089 m_pProps
->fDouble
= *(double*)rValue
.getValue();
2092 case FIELD_PROP_DATE_TIME
:
2093 if(!m_pProps
->pDateTime
)
2094 m_pProps
->pDateTime
= new util::DateTime
;
2095 rValue
>>= (*m_pProps
->pDateTime
);
2097 case FIELD_PROP_PROP_SEQ
:
2098 rValue
>>= m_pProps
->aPropSeq
;
2100 case FIELD_PROP_STRINGS
:
2101 rValue
>>= m_pProps
->aStrings
;
2105 ::GetString( rValue
, *pStr
);
2108 if( rValue
.getValueType() == getCppuBooleanType() )
2109 *pBool
= *(sal_Bool
*)rValue
.getValue();
2111 throw lang::IllegalArgumentException();
2115 throw uno::RuntimeException();
2117 /*-- 14.12.98 11:37:19---------------------------------------------------
2119 -----------------------------------------------------------------------*/
2120 uno::Any
SwXTextField::getPropertyValue(const OUString
& rPropertyName
)
2121 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
2123 vos::OGuard
aGuard(Application::GetSolarMutex());
2125 const SwField
* pField
= GetField();
2126 const SfxItemPropertySet
* _pPropSet
= aSwMapProvider
.GetPropertySet(
2127 lcl_GetPropertyMapOfService( m_nServiceId
));
2128 const SfxItemPropertySimpleEntry
* pEntry
= _pPropSet
->getPropertyMap()->getByName(rPropertyName
);
2131 const SfxItemPropertySet
* _pParaPropSet
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_PARAGRAPH_EXTENSIONS
);
2132 pEntry
= _pParaPropSet
->getPropertyMap()->getByName(rPropertyName
);
2135 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2137 switch( pEntry
->nWID
)
2139 case FN_UNO_TEXT_WRAP
:
2140 aRet
<<= text::WrapTextMode_NONE
;
2142 case FN_UNO_ANCHOR_TYPE
:
2143 aRet
<<= text::TextContentAnchorType_AS_CHARACTER
;
2145 case FN_UNO_ANCHOR_TYPES
:
2147 uno::Sequence
<text::TextContentAnchorType
> aTypes(1);
2148 text::TextContentAnchorType
* pArray
= aTypes
.getArray();
2149 pArray
[0] = text::TextContentAnchorType_AS_CHARACTER
;
2150 aRet
.setValue(&aTypes
, ::getCppuType(static_cast<uno::Sequence
<text::TextContentAnchorType
>*>(0)));
2157 if (FIELD_PROP_IS_FIELD_USED
== pEntry
->nWID
||
2158 FIELD_PROP_IS_FIELD_DISPLAYED
== pEntry
->nWID
)
2160 sal_Bool bIsFieldUsed
= sal_False
;
2161 sal_Bool bIsFieldDisplayed
= sal_False
;
2163 // in order to have the information about fields
2164 // correctly evaluated the document needs a layout
2165 // (has to be already formatted)
2166 SwDoc
*pDoc
= GetDoc();
2167 ViewShell
*pViewShell
= 0;
2168 SwEditShell
*pEditShell
= pDoc
? pDoc
->GetEditShell( &pViewShell
) : 0;
2170 pEditShell
->CalcLayout();
2171 else if (pViewShell
) // a page preview has no SwEditShell it should only have a view shell
2172 pViewShell
->CalcLayout();
2174 throw uno::RuntimeException();
2176 // get text node for the text field
2177 const SwFmtFld
*pFldFmt
= GetFldFmt();
2178 const SwTxtFld
* pTxtFld
= pFldFmt
? pFmtFld
->GetTxtFld() : 0;
2180 throw uno::RuntimeException();
2181 const SwTxtNode
& rTxtNode
= pTxtFld
->GetTxtNode();
2183 // skip fields that are currently not in the document
2184 // e.g. fields in undo or redo array
2185 if (rTxtNode
.GetNodes().IsDocNodes())
2187 sal_Bool bFrame
= 0 != rTxtNode
.FindLayoutRect().Width(); // oder so
2188 sal_Bool bHidden
= rTxtNode
.IsHidden();
2191 xub_StrLen nHiddenStart
;
2192 xub_StrLen nHiddenEnd
;
2194 SwPosition
aPosition( pTxtFld
->GetTxtNode() );
2195 aPosition
.nContent
= *pTxtFld
->GetStart();
2197 bHidden
= SwScriptInfo::GetBoundsOfHiddenRange( pTxtFld
->GetTxtNode(),
2198 *pTxtFld
->GetStart(),
2199 nHiddenStart
, nHiddenEnd
);
2202 // !bFrame && !bHidden: aller Wahrscheinlichkeit handelt es
2203 // sich um ein Feld in einem unbenutzten Seitenstyle
2205 // bHidden: Feld ist versteckt
2206 // FME: Problem: Verstecktes Feld in unbenutzter Seitenvorlage =>
2207 // bIsFieldUsed = true
2208 // bIsFieldDisplayed = false
2209 bIsFieldUsed
= bFrame
|| bHidden
;
2210 bIsFieldDisplayed
= bIsFieldUsed
&& !bHidden
;
2212 sal_Bool bRetVal
= (FIELD_PROP_IS_FIELD_USED
== pEntry
->nWID
) ?
2213 bIsFieldUsed
: bIsFieldDisplayed
;
2214 aRet
.setValue( &bRetVal
, ::getCppuBooleanType() );
2217 pField
->QueryValue( aRet
, pEntry
->nWID
);
2219 else if( m_pProps
) // currently just a descriptor...
2221 switch(pEntry
->nWID
)
2223 case FIELD_PROP_TEXT
:
2227 SwTextAPIEditSource
* pObj
= new SwTextAPIEditSource( m_pDoc
);
2228 m_pTextObject
= new SwTextAPIObject( pObj
);
2229 m_pTextObject
->acquire();
2232 uno::Reference
< text::XText
> xText( m_pTextObject
);
2236 case FIELD_PROP_PAR1
:
2237 aRet
<<= OUString(m_pProps
->sPar1
);
2239 case FIELD_PROP_PAR2
:
2240 aRet
<<= OUString(m_pProps
->sPar2
);
2242 case FIELD_PROP_PAR3
:
2243 aRet
<<= OUString(m_pProps
->sPar3
);
2245 case FIELD_PROP_PAR4
:
2246 aRet
<<= OUString(m_pProps
->sPar4
);
2248 case FIELD_PROP_FORMAT
:
2249 aRet
<<= m_pProps
->nFormat
;
2251 case FIELD_PROP_SUBTYPE
:
2252 aRet
<<= m_pProps
->nSubType
;
2254 case FIELD_PROP_BYTE1
:
2255 aRet
<<= m_pProps
->nByte1
;
2257 case FIELD_PROP_BOOL1
:
2258 aRet
.setValue(&m_pProps
->bBool1
, ::getCppuBooleanType());
2260 case FIELD_PROP_BOOL2
:
2261 aRet
.setValue(&m_pProps
->bBool2
, ::getCppuBooleanType());
2263 case FIELD_PROP_BOOL3
:
2264 aRet
.setValue(&m_pProps
->bBool3
, ::getCppuBooleanType());
2266 case FIELD_PROP_BOOL4
:
2267 aRet
.setValue(&m_pProps
->bBool4
, ::getCppuBooleanType());
2269 case FIELD_PROP_DATE
:
2270 aRet
.setValue(&m_pProps
->aDate
, ::getCppuType(static_cast<const util::Date
*>(0)));
2272 case FIELD_PROP_USHORT1
:
2273 aRet
<<= (sal_Int16
)m_pProps
->nUSHORT1
;
2275 case FIELD_PROP_USHORT2
:
2276 aRet
<<= (sal_Int16
)m_pProps
->nUSHORT2
;
2278 case FIELD_PROP_SHORT1
:
2279 aRet
<<= m_pProps
->nSHORT1
;
2281 case FIELD_PROP_DOUBLE
:
2282 aRet
<<= m_pProps
->fDouble
;
2284 case FIELD_PROP_DATE_TIME
:
2285 if(m_pProps
->pDateTime
)
2286 aRet
<<= (*m_pProps
->pDateTime
);
2288 case FIELD_PROP_PROP_SEQ
:
2289 aRet
<<= m_pProps
->aPropSeq
;
2291 case FIELD_PROP_STRINGS
:
2292 aRet
<<= m_pProps
->aStrings
;
2294 case FIELD_PROP_IS_FIELD_USED
:
2295 case FIELD_PROP_IS_FIELD_DISPLAYED
:
2296 aRet
.setValue( sal_False
, ::getCppuBooleanType() );
2301 throw uno::RuntimeException();
2305 /*-- 14.12.98 11:37:20---------------------------------------------------
2307 -----------------------------------------------------------------------*/
2308 void SwXTextField::addPropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
2310 DBG_WARNING("not implemented");
2312 /*-- 14.12.98 11:37:20---------------------------------------------------
2314 -----------------------------------------------------------------------*/
2315 void SwXTextField::removePropertyChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
2317 DBG_WARNING("not implemented");
2319 /*-- 14.12.98 11:37:20---------------------------------------------------
2321 -----------------------------------------------------------------------*/
2322 void SwXTextField::addVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
2324 DBG_WARNING("not implemented");
2326 /*-- 14.12.98 11:37:20---------------------------------------------------
2328 -----------------------------------------------------------------------*/
2329 void SwXTextField::removeVetoableChangeListener(const OUString
& /*PropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
2331 DBG_WARNING("not implemented");
2333 /* -----------------------------23.03.01 13:15--------------------------------
2335 ---------------------------------------------------------------------------*/
2336 void SwXTextField::update( ) throw (uno::RuntimeException
)
2338 vos::OGuard
aGuard(Application::GetSolarMutex());
2339 const SwField
* pFld
= GetField();
2342 switch(pFld
->Which())
2344 case RES_DATETIMEFLD
:
2345 ((SwDateTimeField
*)pFld
)->SetDateTime( ::DateTime() );
2348 case RES_EXTUSERFLD
:
2350 SwExtUserField
* pExtUserFld
= (SwExtUserField
*)pFld
;
2351 pExtUserFld
->SetExpansion( ((SwExtUserFieldType
*)pFld
->GetTyp())->Expand(
2352 pExtUserFld
->GetSubType(),
2353 pExtUserFld
->GetFormat() ) );
2359 SwAuthorField
* pAuthorFld
= (SwAuthorField
*)pFld
;
2360 pAuthorFld
->SetExpansion( ((SwAuthorFieldType
*)pFld
->GetTyp())->Expand(
2361 pAuthorFld
->GetFormat() ) );
2365 case RES_FILENAMEFLD
:
2367 SwFileNameField
* pFileNameFld
= (SwFileNameField
*)pFld
;
2368 pFileNameFld
->SetExpansion( ((SwFileNameFieldType
*)pFld
->GetTyp())->Expand(
2369 pFileNameFld
->GetFormat() ) );
2373 case RES_DOCINFOFLD
:
2375 SwDocInfoField
* pDocInfFld
= (SwDocInfoField
*)pFld
;
2376 pDocInfFld
->SetExpansion( ((SwDocInfoFieldType
*)pFld
->GetTyp())->Expand(
2377 pDocInfFld
->GetSubType(),
2378 pDocInfFld
->GetFormat(),
2379 pDocInfFld
->GetLanguage(),
2380 pDocInfFld
->GetName() ) );
2384 // --> FME 2004-10-06 #116480#
2385 // Text formatting has to be triggered.
2386 const_cast<SwFmtFld
*>(pFmtFld
)->Modify( 0, 0 );
2390 m_bCallUpdate
= sal_True
;
2392 /* -----------------19.03.99 14:11-------------------
2394 * --------------------------------------------------*/
2395 OUString
SwXTextField::getImplementationName(void) throw( uno::RuntimeException
)
2397 return C2U("SwXTextField");
2399 /* -----------------19.03.99 14:11-------------------
2401 * --------------------------------------------------*/
2403 static OUString
OldNameToNewName_Impl( const OUString
&rOld
)
2405 static OUString
aOldNamePart1( OUString::createFromAscii(".TextField.DocInfo.") );
2406 static OUString
aOldNamePart2( OUString::createFromAscii(".TextField.") );
2407 static OUString
aNewNamePart1( OUString::createFromAscii(".textfield.docinfo.") );
2408 static OUString
aNewNamePart2( OUString::createFromAscii(".textfield.") );
2409 OUString
sServiceNameCC( rOld
);
2410 sal_Int32 nIdx
= sServiceNameCC
.indexOf( aOldNamePart1
);
2412 sServiceNameCC
= sServiceNameCC
.replaceAt( nIdx
, aOldNamePart1
.getLength(), aNewNamePart1
);
2413 nIdx
= sServiceNameCC
.indexOf( aOldNamePart2
);
2415 sServiceNameCC
= sServiceNameCC
.replaceAt( nIdx
, aOldNamePart2
.getLength(), aNewNamePart2
);
2416 return sServiceNameCC
;
2419 sal_Bool
SwXTextField::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2421 OUString sServiceName
= SwXServiceProvider::GetProviderName(m_nServiceId
);
2423 // case-corected version of service-name (see #i67811)
2424 // (need to supply both because of compatibility to older versions)
2425 OUString
sServiceNameCC( OldNameToNewName_Impl( sServiceName
) );
2427 return sServiceName
== rServiceName
|| sServiceNameCC
== rServiceName
||
2428 rServiceName
.equalsAsciiL(
2429 RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextContent"));
2431 /* -----------------19.03.99 14:11-------------------
2433 * --------------------------------------------------*/
2434 uno::Sequence
< OUString
> SwXTextField::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2436 OUString sServiceName
= SwXServiceProvider::GetProviderName(m_nServiceId
);
2438 // case-corected version of service-name (see #i67811)
2439 // (need to supply both because of compatibility to older versions)
2440 OUString
sServiceNameCC( OldNameToNewName_Impl( sServiceName
) );
2441 sal_Int32 nLen
= sServiceName
== sServiceNameCC
? 2 : 3;
2443 uno::Sequence
< OUString
> aRet( nLen
);
2444 OUString
* pArray
= aRet
.getArray();
2445 *pArray
++ = sServiceName
;
2447 *pArray
++ = sServiceNameCC
;
2448 *pArray
++ = C2U("com.sun.star.text.TextContent");
2452 void SwXTextField::Invalidate()
2454 if (GetRegisteredIn())
2456 ((SwModify
*)GetRegisteredIn())->Remove(this);
2457 aLstnrCntnr
.Disposing();
2463 /* -----------------14.12.98 12:00-------------------
2465 * --------------------------------------------------*/
2466 void SwXTextField::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
2468 switch( pOld
? pOld
->Which() : 0 )
2470 case RES_REMOVE_UNO_OBJECT
:
2471 case RES_OBJECTDYING
:
2472 if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem
*)pOld
)->pObject
)
2477 // wurden wir an das neue umgehaengt und wird das alte geloscht?
2478 if( ((SwFmtChg
*)pNew
)->pChangedFmt
== GetRegisteredIn() &&
2479 ((SwFmtChg
*)pOld
)->pChangedFmt
->IsFmtInDTOR() )
2482 case RES_FIELD_DELETED
:
2483 if( (void*)pFmtFld
== ((SwPtrMsgPoolItem
*)pOld
)->pObject
)
2488 /*-- 14.12.98 11:37:21---------------------------------------------------
2490 -----------------------------------------------------------------------*/
2491 const SwField
* SwXTextField::GetField() const
2493 if(GetRegisteredIn() && pFmtFld
)
2494 return pFmtFld
->GetFld();
2498 /******************************************************************
2500 ******************************************************************/
2501 /******************************************************************
2502 * SwXTextFieldMasters
2503 ******************************************************************/
2504 /* -----------------------------06.04.00 13:22--------------------------------
2506 ---------------------------------------------------------------------------*/
2507 OUString
SwXTextFieldMasters::getImplementationName(void) throw( uno::RuntimeException
)
2509 return C2U("SwXTextFieldMasters");
2511 /* -----------------------------06.04.00 13:22--------------------------------
2513 ---------------------------------------------------------------------------*/
2514 BOOL
SwXTextFieldMasters::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2516 return rServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
2517 "com.sun.star.text.TextFieldMasters" ));
2519 /* -----------------------------06.04.00 13:22--------------------------------
2521 ---------------------------------------------------------------------------*/
2522 uno::Sequence
< OUString
> SwXTextFieldMasters::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2524 uno::Sequence
< OUString
> aRet(1);
2525 OUString
* pArray
= aRet
.getArray();
2526 pArray
[0] = C2U("com.sun.star.text.TextFieldMasters");
2529 /*-- 21.12.98 10:37:14---------------------------------------------------
2531 -----------------------------------------------------------------------*/
2532 SwXTextFieldMasters::SwXTextFieldMasters(SwDoc
* _pDoc
) :
2533 SwUnoCollection(_pDoc
)
2536 /*-- 21.12.98 10:37:32---------------------------------------------------
2538 -----------------------------------------------------------------------*/
2539 SwXTextFieldMasters::~SwXTextFieldMasters()
2543 /*-- 21.12.98 10:37:33---------------------------------------------------
2544 Iteration ueber nicht-Standard Feldtypen
2545 USER/SETEXP/DDE/DATABASE
2546 Der Name ist demnach:
2547 "com.sun.star.text.fieldmaster.User" + <Feltypname>
2548 "com.sun.star.text.fieldmaster.DDE" + <Feltypname>
2549 "com.sun.star.text.fieldmaster.SetExpression" + <Feltypname>
2550 "com.sun.star.text.fieldmaster.DataBase" + <Feltypname>
2552 Falls wir grosszuegig werden wollen, dann koennte man com.sun.star.text
2553 auch optional weglassen
2554 -----------------------------------------------------------------------*/
2556 sal_uInt16
lcl_GetIdByName( String
& rName
, String
& rTypeName
)
2558 if( rName
.EqualsAscii( COM_TEXT_FLDMASTER
, 0, RTL_CONSTASCII_LENGTH(COM_TEXT_FLDMASTER
))
2559 || rName
.EqualsAscii( COM_TEXT_FLDMASTER_CC
, 0, RTL_CONSTASCII_LENGTH(COM_TEXT_FLDMASTER_CC
)))
2562 sal_uInt16 nResId
= USHRT_MAX
;
2563 xub_StrLen nFound
= 0;
2564 rTypeName
= rName
.GetToken( 0, '.', nFound
);
2565 if(rTypeName
.EqualsAscii("User"))
2566 nResId
= RES_USERFLD
;
2567 else if(rTypeName
.EqualsAscii("DDE"))
2568 nResId
= RES_DDEFLD
;
2569 else if(rTypeName
.EqualsAscii("SetExpression"))
2571 nResId
= RES_SETEXPFLD
;
2573 String
sFldTypName( rName
.GetToken( 1, '.' ));
2574 String
sUIName( SwStyleNameMapper::GetSpecialExtraUIName( sFldTypName
) );
2576 if( sUIName
!= sFldTypName
)
2577 rName
.SetToken( 1, '.', sUIName
);
2579 else if(rTypeName
.EqualsAscii("DataBase"))
2581 rName
.Erase( 0, RTL_CONSTASCII_LENGTH( "DataBase." ));
2582 USHORT nDotCount
= rName
.GetTokenCount('.');
2583 if( 2 <= nDotCount
)
2586 //rName.SearchAndReplace('.', DB_DELIM);
2587 //rName.SetChar( rName.SearchBackward( '.' ), DB_DELIM );
2589 rName
.InsertAscii( "DataBase.", 0 );
2593 else if( rTypeName
.EqualsAscii("Bibliography"))
2594 nResId
= RES_AUTHORITY
;
2598 //-----------------------------------------------------------------------------
2599 uno::Any
SwXTextFieldMasters::getByName(const OUString
& rName
)
2600 throw( container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
2602 vos::OGuard
aGuard(Application::GetSolarMutex());
2604 throw uno::RuntimeException();
2606 String
sName(rName
), sTypeName
;
2607 sal_uInt16 nResId
= lcl_GetIdByName( sName
, sTypeName
);
2608 if( USHRT_MAX
== nResId
)
2609 throw container::NoSuchElementException();
2611 sName
.Erase(0, sTypeName
.Len()+1);
2612 SwFieldType
* pType
= GetDoc()->GetFldType(nResId
, sName
, sal_True
);
2614 throw container::NoSuchElementException();
2615 SwXFieldMaster
* pMaster
= (SwXFieldMaster
*)
2616 SwClientIter(*pType
).First(TYPE(SwXFieldMaster
));
2618 pMaster
= new SwXFieldMaster(*pType
, GetDoc());
2619 uno::Reference
< beans::XPropertySet
> aRef
= pMaster
;
2620 uno::Any
aRet(&aRef
, ::getCppuType( static_cast<const uno::Reference
<beans::XPropertySet
>* >(0)));
2623 /*-- 06.03.2001 11:29:34,5-------------------------------------------------
2625 -----------------------------------------------------------------------*/
2626 sal_Bool
SwXTextFieldMasters::getInstanceName(
2627 const SwFieldType
& rFldType
, String
& rName
)
2629 sal_Bool bRet
= sal_True
;
2630 switch( rFldType
.Which() )
2633 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( COM_TEXT_FLDMASTER_CC
));
2634 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "User."));
2635 rName
+= rFldType
.GetName();
2638 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( COM_TEXT_FLDMASTER_CC
));
2639 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "DDE."));
2640 rName
+= rFldType
.GetName();
2644 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( COM_TEXT_FLDMASTER_CC
));
2645 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "SetExpression."));
2646 rName
+= String( SwStyleNameMapper::GetSpecialExtraProgName( rFldType
.GetName() ) );
2651 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( COM_TEXT_FLDMASTER_CC
));
2652 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "DataBase."));
2653 String
sDBName(rFldType
.GetName());
2654 sDBName
.SearchAndReplaceAll(DB_DELIM
, '.');
2660 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( COM_TEXT_FLDMASTER_CC
));
2661 rName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "Bibliography"));
2672 /*-- 21.12.98 10:37:33---------------------------------------------------
2674 -----------------------------------------------------------------------*/
2675 uno::Sequence
< OUString
> SwXTextFieldMasters::getElementNames(void)
2676 throw( uno::RuntimeException
)
2678 vos::OGuard
aGuard(Application::GetSolarMutex());
2680 throw uno::RuntimeException();
2682 const SwFldTypes
* pFldTypes
= GetDoc()->GetFldTypes();
2683 sal_uInt16 nCount
= pFldTypes
->Count();
2685 SvStrings aFldNames
;
2686 String
* pString
= new String();
2689 for( i
= 0; i
< nCount
; i
++)
2691 SwFieldType
& rFldType
= *((*pFldTypes
)[i
]);
2693 if (SwXTextFieldMasters::getInstanceName(rFldType
, *pString
))
2695 aFldNames
.Insert(pString
, aFldNames
.Count());
2696 pString
= new String();
2701 uno::Sequence
< OUString
> aSeq(aFldNames
.Count());
2702 OUString
* pArray
= aSeq
.getArray();
2703 for(i
= 0; i
< aFldNames
.Count();i
++)
2705 pArray
[i
] = *aFldNames
.GetObject(i
);
2707 aFldNames
.DeleteAndDestroy(0, aFldNames
.Count());
2712 /*-- 21.12.98 10:37:33---------------------------------------------------
2714 -----------------------------------------------------------------------*/
2715 sal_Bool
SwXTextFieldMasters::hasByName(const OUString
& rName
) throw( uno::RuntimeException
)
2717 vos::OGuard
aGuard(Application::GetSolarMutex());
2719 throw uno::RuntimeException();
2721 String
sName(rName
), sTypeName
;
2722 sal_uInt16 nResId
= lcl_GetIdByName( sName
, sTypeName
);
2723 sal_Bool bRet
= sal_False
;
2724 if( USHRT_MAX
!= nResId
)
2726 sName
.Erase(0, sTypeName
.Len()+1);
2727 bRet
= USHRT_MAX
!= nResId
&& 0 != GetDoc()->GetFldType(nResId
, sName
, sal_True
);
2731 /*-- 21.12.98 10:37:34---------------------------------------------------
2733 -----------------------------------------------------------------------*/
2734 uno::Type
SwXTextFieldMasters::getElementType(void) throw( uno::RuntimeException
)
2736 return ::getCppuType(static_cast<const uno::Reference
<beans::XPropertySet
>*>(0));
2739 /*-- 21.12.98 10:37:34---------------------------------------------------
2741 -----------------------------------------------------------------------*/
2742 sal_Bool
SwXTextFieldMasters::hasElements(void) throw( uno::RuntimeException
)
2744 vos::OGuard
aGuard(Application::GetSolarMutex());
2746 throw uno::RuntimeException();
2750 /******************************************************************
2752 ******************************************************************/
2753 /* -----------------------------06.04.00 13:24--------------------------------
2755 ---------------------------------------------------------------------------*/
2756 OUString
SwXTextFieldTypes::getImplementationName(void) throw( uno::RuntimeException
)
2758 return C2U("SwXTextFieldTypes");
2760 /* -----------------------------06.04.00 13:24--------------------------------
2762 ---------------------------------------------------------------------------*/
2763 BOOL
SwXTextFieldTypes::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2765 return rServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
2766 "com.sun.star.text.TextFields" ));
2768 /* -----------------------------06.04.00 13:24--------------------------------
2770 ---------------------------------------------------------------------------*/
2771 uno::Sequence
< OUString
> SwXTextFieldTypes::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2773 uno::Sequence
< OUString
> aRet(1);
2774 OUString
* pArray
= aRet
.getArray();
2775 pArray
[0] = C2U("com.sun.star.text.TextFields");
2778 /*-- 21.12.98 10:35:15---------------------------------------------------
2780 -----------------------------------------------------------------------*/
2781 SwXTextFieldTypes::SwXTextFieldTypes(SwDoc
* _pDoc
) :
2782 SwUnoCollection (_pDoc
),
2783 aRefreshCont ( static_cast< XEnumerationAccess
* >(this) )
2786 /*-- 21.12.98 10:35:16---------------------------------------------------
2788 -----------------------------------------------------------------------*/
2789 SwXTextFieldTypes::~SwXTextFieldTypes()
2792 /*-- 11.07.02 14:25:00---------------------------------------------------
2794 -----------------------------------------------------------------------*/
2795 void SwXTextFieldTypes::Invalidate()
2797 SwUnoCollection::Invalidate();
2798 aRefreshCont
.Disposing();
2800 /*-- 21.12.98 10:35:17---------------------------------------------------
2802 -----------------------------------------------------------------------*/
2803 uno::Reference
< container::XEnumeration
> SwXTextFieldTypes::createEnumeration(void)
2804 throw( uno::RuntimeException
)
2806 vos::OGuard
aGuard(Application::GetSolarMutex());
2808 throw uno::RuntimeException();
2809 return new SwXFieldEnumeration(GetDoc());
2812 /*-- 21.12.98 10:35:17---------------------------------------------------
2814 -----------------------------------------------------------------------*/
2815 uno::Type
SwXTextFieldTypes::getElementType(void) throw( uno::RuntimeException
)
2817 return ::getCppuType(static_cast<const uno::Reference
<text::XDependentTextField
>*>(0));
2819 /*-- 21.12.98 10:35:17---------------------------------------------------
2821 -----------------------------------------------------------------------*/
2822 sal_Bool
SwXTextFieldTypes::hasElements(void) throw( uno::RuntimeException
)
2824 vos::OGuard
aGuard(Application::GetSolarMutex());
2826 throw uno::RuntimeException();
2830 /* -----------------24.02.99 16:19-------------------
2832 * --------------------------------------------------*/
2833 void SwXTextFieldTypes::refresh(void) throw( uno::RuntimeException
)
2835 vos::OGuard
aGuard(Application::GetSolarMutex());
2837 throw uno::RuntimeException();
2838 UnoActionContext
aContext(GetDoc());
2840 GetDoc()->UpdateDocStat(aDocStat
);
2841 GetDoc()->UpdateFlds(0, sal_False
);
2843 // call refresh listeners
2844 aRefreshCont
.Refreshed();
2846 /* -----------------24.02.99 16:19-------------------
2848 * --------------------------------------------------*/
2849 void SwXTextFieldTypes::addRefreshListener(const uno::Reference
< util::XRefreshListener
> & l
)
2850 throw( uno::RuntimeException
)
2852 ::vos::OGuard
aGuard(Application::GetSolarMutex());
2854 throw uno::RuntimeException();
2855 aRefreshCont
.AddListener ( reinterpret_cast < const uno::Reference
< lang::XEventListener
> &> ( l
));
2857 /* -----------------24.02.99 16:19-------------------
2859 * --------------------------------------------------*/
2860 void SwXTextFieldTypes::removeRefreshListener(const uno::Reference
< util::XRefreshListener
> & l
)
2861 throw( uno::RuntimeException
)
2863 ::vos::OGuard
aGuard(Application::GetSolarMutex());
2864 if ( !IsValid() || !aRefreshCont
.RemoveListener ( reinterpret_cast < const uno::Reference
< lang::XEventListener
> &> ( l
) ) )
2865 throw uno::RuntimeException();
2867 /******************************************************************
2868 * SwXFieldEnumeration
2869 ******************************************************************/
2870 /* -----------------------------06.04.00 13:25--------------------------------
2872 ---------------------------------------------------------------------------*/
2873 OUString
SwXFieldEnumeration::getImplementationName(void) throw( uno::RuntimeException
)
2875 return C2U("SwXFieldEnumeration");
2877 /* -----------------------------06.04.00 13:25--------------------------------
2879 ---------------------------------------------------------------------------*/
2880 BOOL
SwXFieldEnumeration::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
2882 return rServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
2883 "com.sun.star.text.FieldEnumeration" ));
2885 /* -----------------------------06.04.00 13:25--------------------------------
2887 ---------------------------------------------------------------------------*/
2888 uno::Sequence
< OUString
> SwXFieldEnumeration::getSupportedServiceNames(void) throw( uno::RuntimeException
)
2890 uno::Sequence
< OUString
> aRet(1);
2891 OUString
* pArray
= aRet
.getArray();
2892 pArray
[0] = C2U("com.sun.star.text.FieldEnumeration");
2895 /* -----------------21.12.98 14:57-------------------
2897 * --------------------------------------------------*/
2898 SwXFieldEnumeration::SwXFieldEnumeration(SwDoc
* pDc
) :
2902 pDoc
->GetPageDescFromPool(RES_POOLPAGE_STANDARD
)->Add(this);
2905 sal_Int32 nSize
= 32;
2906 aItems
.realloc( nSize
);
2907 uno::Reference
< text::XTextField
> *pItems
= aItems
.getArray();
2908 sal_Int32 nFillPos
= 0;
2910 const SwFldTypes
* pFldTypes
= pDoc
->GetFldTypes();
2911 sal_uInt16 nCount
= pFldTypes
->Count();
2912 for(sal_uInt16 nType
= 0; nType
< nCount
; ++nType
)
2914 const SwFieldType
*pCurType
= pFldTypes
->GetObject(nType
);
2916 SwClientIter
aIter( *(SwFieldType
*)pCurType
);
2917 const SwFmtFld
* pCurFldFmt
= (SwFmtFld
*)aIter
.First( TYPE( SwFmtFld
));
2920 const SwTxtFld
*pTxtFld
= pCurFldFmt
->GetTxtFld();
2921 // skip fields that are currently not in the document
2922 // e.g. fields in undo or redo array
2923 BOOL bSkip
= !pTxtFld
||
2924 !pTxtFld
->GetpTxtNode()->GetNodes().IsDocNodes();
2926 pItems
[ nFillPos
++ ] = new SwXTextField(*pCurFldFmt
, pDoc
);
2927 pCurFldFmt
= (SwFmtFld
*)aIter
.Next();
2929 // enlarge sequence if necessary
2930 if (aItems
.getLength() == nFillPos
)
2932 aItems
.realloc( 2 * aItems
.getLength() );
2933 pItems
= aItems
.getArray();
2937 // now handle meta-fields, which are not SwFields
2938 const ::std::vector
< uno::Reference
<text::XTextField
> > MetaFields(
2939 pDc
->GetMetaFieldManager().getMetaFields() );
2940 for (size_t i
= 0; i
< MetaFields
.size(); ++i
)
2942 pItems
[ nFillPos
] = MetaFields
[i
];
2946 // enlarge sequence if necessary
2947 if (aItems
.getLength() == nFillPos
)
2949 aItems
.realloc( 2 * aItems
.getLength() );
2950 pItems
= aItems
.getArray();
2953 // resize sequence to actual used size
2954 aItems
.realloc( nFillPos
);
2956 /*-- 21.12.98 14:57:23---------------------------------------------------
2958 -----------------------------------------------------------------------*/
2959 SwXFieldEnumeration::~SwXFieldEnumeration()
2963 /*-- 21.12.98 14:57:42---------------------------------------------------
2965 -----------------------------------------------------------------------*/
2966 sal_Bool
SwXFieldEnumeration::hasMoreElements(void)
2967 throw( uno::RuntimeException
)
2969 vos::OGuard
aGuard(Application::GetSolarMutex());
2970 return nNextIndex
< aItems
.getLength();
2972 /*-- 21.12.98 14:57:42---------------------------------------------------
2974 -----------------------------------------------------------------------*/
2975 uno::Any
SwXFieldEnumeration::nextElement(void)
2976 throw( container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
2978 vos::OGuard
aGuard(Application::GetSolarMutex());
2980 if (!(nNextIndex
< aItems
.getLength()))
2981 throw container::NoSuchElementException();
2983 #if OSL_DEBUG_LEVEL > 1
2984 uno::Reference
< text::XTextField
> *pItems
= aItems
.getArray();
2987 uno::Reference
< text::XTextField
> &rxFld
= aItems
.getArray()[ nNextIndex
++ ];
2988 uno::Any
aRet(&rxFld
, ::getCppuType(static_cast<const uno::Reference
<text::XTextField
>*>(0)));
2989 rxFld
= 0; // free memory for item that is not longer used
2992 /* -----------------21.12.98 15:08-------------------
2994 * --------------------------------------------------*/
2995 void SwXFieldEnumeration::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
2997 ClientModify(this, pOld
, pNew
);
2998 if(!GetRegisteredIn())
3003 String
& GetString( const uno::Any
& rAny
, String
& rStr
)
3007 rStr
= String( aStr
);