xref: /aoo42x/main/sw/source/ui/fldui/fldmgr.cxx (revision 69a74367)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <cmdid.h>
28 #include <hintids.hxx>
29 #include <svl/stritem.hxx>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
33 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
34 #include <com/sun/star/style/NumberingType.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/sdbc/XConnection.hpp>
37 #include <com/sun/star/sdbc/XDataSource.hpp>
38 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
39 #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
40 #include <comphelper/processfactory.hxx>
41 #include <editeng/unolingu.hxx>
42 #include <unotools/localedatawrapper.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <sfx2/objsh.hxx>
45 #include <sfx2/linkmgr.hxx>
46 #include <sfx2/app.hxx>
47 #include <basic/basmgr.hxx>
48 #include <editeng/langitem.hxx>
49 #include <svl/macitem.hxx>
50 #include <basic/sbmod.hxx>
51 #include <fmtrfmrk.hxx>
52 #include <basic/sbmeth.hxx>
53 #include <basic/sbx.hxx>
54 #include <svl/zforlist.hxx>
55 #include <svl/zformat.hxx>
56 #include <vcl/mnemonic.hxx>
57 #include <view.hxx>
58 #include <wrtsh.hxx>		// Actives Fenster
59 #include <doc.hxx>		// Actives Fenster
60 #include <docsh.hxx>		// Actives Fenster
61 #include <swmodule.hxx>
62 #include <charatr.hxx>
63 #include <fmtinfmt.hxx>
64 #include <cellatr.hxx>
65 #include <dbmgr.hxx>
66 #include <shellres.hxx>
67 #include <fldbas.hxx>
68 #include <docufld.hxx>
69 #include <chpfld.hxx>
70 #include <ddefld.hxx>
71 #include <expfld.hxx>
72 #include <reffld.hxx>
73 #include <usrfld.hxx>
74 #include <dbfld.hxx>
75 #include <authfld.hxx>
76 #include <flddat.hxx>
77 #include <fldmgr.hxx>
78 #include <crsskip.hxx>
79 #include <flddropdown.hxx>
80 #include <fldui.hrc>
81 #include <tox.hxx>
82 
83 using rtl::OUString;
84 using namespace com::sun::star::uno;
85 using namespace com::sun::star::container;
86 using namespace com::sun::star::lang;
87 using namespace com::sun::star::beans;
88 using namespace com::sun::star::text;
89 using namespace com::sun::star::style;
90 using namespace com::sun::star::sdbc;
91 using namespace ::com::sun::star;
92 using namespace nsSwDocInfoSubType;
93 
94 /*--------------------------------------------------------------------
95 	Beschreibung: Gruppen der Felder
96  --------------------------------------------------------------------*/
97 enum
98 {
99 	GRP_DOC_BEGIN	=  0,
100 	GRP_DOC_END   	=  GRP_DOC_BEGIN + 11,
101 
102 	GRP_FKT_BEGIN 	=  GRP_DOC_END,
103     GRP_FKT_END     =  GRP_FKT_BEGIN + 8,
104 
105 	GRP_REF_BEGIN 	=  GRP_FKT_END,
106 	GRP_REF_END   	=  GRP_REF_BEGIN + 2,
107 
108 	GRP_REG_BEGIN 	=  GRP_REF_END,
109 	GRP_REG_END     =  GRP_REG_BEGIN + 1,
110 
111 	GRP_DB_BEGIN  	=  GRP_REG_END,
112 	GRP_DB_END    	=  GRP_DB_BEGIN  + 5,
113 
114 	GRP_VAR_BEGIN 	=  GRP_DB_END,
115 	GRP_VAR_END   	=  GRP_VAR_BEGIN + 9
116 };
117 
118 enum
119 {
120 	GRP_WEB_DOC_BEGIN	=  0,
121 	GRP_WEB_DOC_END   	=  GRP_WEB_DOC_BEGIN + 9,
122 
123 	GRP_WEB_FKT_BEGIN 	=  GRP_WEB_DOC_END + 2,
124 	GRP_WEB_FKT_END   	=  GRP_WEB_FKT_BEGIN + 0,	// Die Gruppe ist leer!
125 
126 	GRP_WEB_REF_BEGIN 	=  GRP_WEB_FKT_END + 6,		// Die Gruppe ist leer!
127 	GRP_WEB_REF_END   	=  GRP_WEB_REF_BEGIN + 0,
128 
129 	GRP_WEB_REG_BEGIN 	=  GRP_WEB_REF_END + 2,
130 	GRP_WEB_REG_END     =  GRP_WEB_REG_BEGIN + 1,
131 
132 	GRP_WEB_DB_BEGIN  	=  GRP_WEB_REG_END,			// Die Gruppe ist leer!
133 	GRP_WEB_DB_END    	=  GRP_WEB_DB_BEGIN  + 0,
134 
135 	GRP_WEB_VAR_BEGIN 	=  GRP_WEB_DB_END + 5,
136 	GRP_WEB_VAR_END   	=  GRP_WEB_VAR_BEGIN + 1
137 };
138 
139 /*--------------------------------------------------------------------
140 	Beschreibung: Formate in der richtigen Reihenfolge
141  --------------------------------------------------------------------*/
142 static const sal_uInt16 __FAR_DATA aSetFmt[] =
143 {
144 // die Reihenfolge muss zu Beginn mit den ResourceIds fuer FMT_SETVAR_???
145 // uebereinstimmen
146 	0,
147 	0
148 };
149 
150 static const sal_uInt16 __FAR_DATA aGetFmt[] =
151 {
152 // die Reihenfolge muss zu Beginn mit den ResourceIds fuer FMT_GETVAR_???
153 // uebereinstimmen
154 	0
155 };
156 
157 static const sal_uInt16 __FAR_DATA aUsrFmt[] =
158 {
159 // die Reihenfolge muss zu Beginn mit den ResourceIds fuer FMT_SETVAR_???
160 // uebereinstimmen
161 	0,
162 	nsSwExtendedSubType::SUB_CMD
163 };
164 
165 static const sal_uInt16 __FAR_DATA aDBFmt[] =
166 {
167 // die Reihenfolge muss zu Beginn mit den ResourceIds fuer FMT_DBFLD_???
168 // uebereinstimmen
169 	nsSwExtendedSubType::SUB_OWN_FMT
170 };
171 
172 static const sal_uInt16 VF_COUNT		= sizeof(aGetFmt) / sizeof(sal_uInt16);
173 static const sal_uInt16 VF_USR_COUNT	= sizeof(aUsrFmt) / sizeof(sal_uInt16);
174 static const sal_uInt16 VF_DB_COUNT		= sizeof(aDBFmt)  / sizeof(sal_uInt16);
175 
176 /*--------------------------------------------------------------------
177 	Beschreibung: Feldtypen und Subtypes
178  --------------------------------------------------------------------*/
179 struct SwFldPack
180 {
181 	sal_uInt16  nTypeId;
182 
183 	sal_uInt16	nSubTypeStart;
184 	sal_uInt16  nSubTypeEnd;
185 
186 	sal_uLong	nFmtBegin;
187 	sal_uLong	nFmtEnd;
188 };
189 
190 /*--------------------------------------------------------------------
191 	Beschreibung: Strings und Formate
192  --------------------------------------------------------------------*/
193 static const SwFldPack __FAR_DATA aSwFlds[] =
194 {
195 	// Dokument
196 	{ TYP_EXTUSERFLD,	 	FLD_EU_BEGIN,	 	FLD_EU_END,	    0,     				0 },
197 	{ TYP_AUTHORFLD,	 	0,					0,				FMT_AUTHOR_BEGIN,	FMT_AUTHOR_END },
198 	{ TYP_DATEFLD,			FLD_DATE_BEGIN,		FLD_DATE_END,	0,					0 },
199 	{ TYP_TIMEFLD,			FLD_TIME_BEGIN,		FLD_TIME_END,	0,					0 },
200 	{ TYP_PAGENUMBERFLD,	0,					0,				FMT_NUM_BEGIN,   	FMT_NUM_END-1 },
201 	{ TYP_NEXTPAGEFLD,		0,					0,				FMT_NUM_BEGIN,		FMT_NUM_END },
202 	{ TYP_PREVPAGEFLD,		0,					0,				FMT_NUM_BEGIN,		FMT_NUM_END },
203 	{ TYP_FILENAMEFLD,		0,					0,				FMT_FF_BEGIN,    	FMT_FF_END },
204 	{ TYP_DOCSTATFLD,	 	FLD_STAT_BEGIN,		FLD_STAT_END,	FMT_NUM_BEGIN,		FMT_NUM_END-1 },
205 
206 	{ TYP_CHAPTERFLD,	 	0,					0,				FMT_CHAPTER_BEGIN, 	FMT_CHAPTER_END },
207 	{ TYP_TEMPLNAMEFLD,		0,					0,				FMT_FF_BEGIN,    	FMT_FF_END },
208 
209 	// Funktion
210 	{ TYP_CONDTXTFLD,	 	0,					0,				0,					0 },
211     { TYP_DROPDOWN,       	0,                  0,              0,                  0 },
212 	{ TYP_INPUTFLD,			FLD_INPUT_BEGIN,	FLD_INPUT_END,	0,   				0 },
213 	{ TYP_MACROFLD,			0,					0,				0,					0 },
214 	{ TYP_JUMPEDITFLD, 		0,					0,				FMT_MARK_BEGIN,		FMT_MARK_END },
215 	{ TYP_COMBINED_CHARS,	0,					0,				0,					0 },
216 	{ TYP_HIDDENTXTFLD,		0,					0,				0,					0 },
217 	{ TYP_HIDDENPARAFLD, 	0,			   		0,				0,					0 },
218 
219 	// Referenzen
220 	{ TYP_SETREFFLD,	 	0,					0,				0,					0 },
221 	{ TYP_GETREFFLD,	 	0,					0,				FMT_REF_BEGIN,		FMT_REF_END },
222 
223 	// Ablage
224 	{ TYP_DOCINFOFLD,	 	0,					0,				FMT_REG_BEGIN, 		FMT_REG_END },
225 
226 	// Datenbank
227 	{ TYP_DBFLD,		 	0,					0,				FMT_DBFLD_BEGIN,	FMT_DBFLD_END },
228 	{ TYP_DBNEXTSETFLD,		0,					0,				0,					0 },
229 	{ TYP_DBNUMSETFLD,		0,					0,				0,					0 },
230 	{ TYP_DBSETNUMBERFLD, 	0,					0,				FMT_NUM_BEGIN,	    FMT_NUM_END-2 },
231 	{ TYP_DBNAMEFLD, 	 	0,					0,				0,					0 },
232 
233 	// Variablen
234 	{ TYP_SETFLD,		 	0,					0,				FMT_SETVAR_BEGIN,   FMT_SETVAR_END },
235 
236 	{ TYP_GETFLD,		 	0,					0, 				FMT_GETVAR_BEGIN,	FMT_GETVAR_END },
237 	{ TYP_DDEFLD,		 	0,					0,				FMT_DDE_BEGIN, 		FMT_DDE_END },
238 	{ TYP_FORMELFLD,  		0,					0,				FMT_GETVAR_BEGIN,	FMT_GETVAR_END },
239 	{ TYP_INPUTFLD,			FLD_INPUT_BEGIN,	FLD_INPUT_END,	0,   				0 },
240 	{ TYP_SEQFLD,		 	0,					0,				FMT_NUM_BEGIN,		FMT_NUM_END-2 },
241 	{ TYP_SETREFPAGEFLD,	FLD_PAGEREF_BEGIN,	FLD_PAGEREF_END,0,   				0 },
242 	{ TYP_GETREFPAGEFLD,	0,					0,				FMT_NUM_BEGIN,   	FMT_NUM_END-1 },
243 	{ TYP_USERFLD,			0,					0,				FMT_USERVAR_BEGIN,	FMT_USERVAR_END }
244 };
245 
246 /*--------------------------------------------------------------------
247 	Beschreibung: Zugriff auf die Shell
248  --------------------------------------------------------------------*/
249 
250 static SwWrtShell* lcl_GetShell()
251 {
252 	SwView* pView;
253 	if ( 0 != (pView = ::GetActiveView()) )
254 		return pView->GetWrtShellPtr();
255 	DBG_ERROR("no current shell found!");
256 	return 0;
257 }
258 
259 inline sal_uInt16 GetPackCount() {	return sizeof(aSwFlds) / sizeof(SwFldPack); }
260 
261 /*--------------------------------------------------------------------
262 	Beschreibung: FieldManager regelt das Einfuegen und Updaten
263 				  von Feldern
264  --------------------------------------------------------------------*/
265 
266 SwFldMgr::SwFldMgr(SwWrtShell* pSh ) :
267 	pModule(0),
268 	pMacroItem(0),
269     pWrtShell(pSh),
270     bEvalExp(sal_True)
271 {
272 	// aktuelles Feld ermitteln falls vorhanden
273 	GetCurFld();
274 }
275 
276 
277 SwFldMgr::~SwFldMgr()
278 {
279 }
280 
281 /*--------------------------------------------------------------------
282 	Beschreibung: RefMark ueber Namen organisieren
283  --------------------------------------------------------------------*/
284 
285 sal_Bool  SwFldMgr::CanInsertRefMark( const String& rStr )
286 {
287     sal_Bool bRet = sal_False;
288     SwWrtShell *pSh = pWrtShell ? pWrtShell : lcl_GetShell();
289     DBG_ASSERT(pSh, "no SwWrtShell found");
290     if(pSh)
291     {
292         sal_uInt16 nCnt = pSh->GetCrsrCnt();
293 
294         // der letzte Crsr muss keine aufgespannte Selektion
295         if( 1 < nCnt && !pSh->SwCrsrShell::HasSelection() )
296             --nCnt;
297 
298         bRet =  2 > nCnt && 0 == pSh->GetRefMark( rStr );
299     }
300     return bRet;
301 }
302 
303 /*--------------------------------------------------------------------
304 	Beschreibung: Zugriff ueber ResIds
305  --------------------------------------------------------------------*/
306 
307 void SwFldMgr::RemoveFldType(sal_uInt16 nResId, const String& rName )
308 {
309     SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
310     DBG_ASSERT(pSh, "no SwWrtShell found");
311     if( pSh )
312         pSh->RemoveFldType(nResId, rName);
313 }
314 
315 sal_uInt16 SwFldMgr::GetFldTypeCount(sal_uInt16 nResId) const
316 {
317     SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
318     DBG_ASSERT(pSh, "no SwWrtShell found");
319     return pSh ? pSh->GetFldTypeCount(nResId) : 0;
320 }
321 
322 
323 SwFieldType* SwFldMgr::GetFldType(sal_uInt16 nResId, sal_uInt16 nId) const
324 {
325     SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
326     DBG_ASSERT(pSh, "no SwWrtShell found");
327     return pSh ? pSh->GetFldType(nId, nResId) : 0;
328 }
329 
330 
331 SwFieldType* SwFldMgr::GetFldType(sal_uInt16 nResId, const String& rName) const
332 {
333     SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell();
334     DBG_ASSERT(pSh, "no SwWrtShell found");
335     return pSh ? pSh->GetFldType(nResId, rName) : 0;
336 }
337 
338 
339 /*--------------------------------------------------------------------
340 	Beschreibung: Aktuelles Feld ermitteln
341  --------------------------------------------------------------------*/
342 SwField* SwFldMgr::GetCurFld()
343 {
344 	SwWrtShell *pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
345 	if ( pSh )
346 		pCurFld = pSh->GetCurFld( true );
347 	else
348 		pCurFld = NULL;
349 
350 	// Strings und Format initialisieren
351 	//
352 	aCurPar1.Erase();
353 	aCurPar2.Erase();
354 	sCurFrame.Erase();
355 	nCurFmt = 0;
356 
357 	if(!pCurFld)
358 		return 0;
359 
360 	// Aktuelle Werte aufbereiten Parameter 1 und Parameter 2
361 	// als auch das Format ermitteln
362 	//
363 	const sal_uInt16 nTypeId = pCurFld->GetTypeId();
364 
365 	nCurFmt  	= pCurFld->GetFormat();
366 	aCurPar1 	= pCurFld->GetPar1();
367 	aCurPar2 	= pCurFld->GetPar2();
368 
369 	switch( nTypeId )
370 	{
371 		case TYP_PAGENUMBERFLD:
372 		case TYP_NEXTPAGEFLD:
373 		case TYP_PREVPAGEFLD:
374 		case TYP_GETREFPAGEFLD:
375 			if( nCurFmt == SVX_NUM_PAGEDESC )
376 				nCurFmt -= 2;
377 			break;
378 	}
379 	return pCurFld;
380 }
381 
382 /*--------------------------------------------------------------------
383 	Beschreibung: Gruppen-Bereich liefern
384  --------------------------------------------------------------------*/
385 
386 
387 const SwFldGroupRgn& SwFldMgr::GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const
388 {
389 static SwFldGroupRgn __READONLY_DATA aRanges[] =
390 {
391 	{ /* Dokument	*/ 	GRP_DOC_BEGIN, 	GRP_DOC_END },
392 	{ /* Funktionen	*/ 	GRP_FKT_BEGIN,  GRP_FKT_END },
393 	{ /* Referenzen	*/ 	GRP_REF_BEGIN,  GRP_REF_END },
394 	{ /* Ablage		*/ 	GRP_REG_BEGIN,  GRP_REG_END },
395 	{ /* DB			*/	GRP_DB_BEGIN,	GRP_DB_END },
396 	{ /* User		*/	GRP_VAR_BEGIN,	GRP_VAR_END }
397 };
398 static SwFldGroupRgn __READONLY_DATA aWebRanges[] =
399 {
400 	{ /* Dokument	*/ 	GRP_WEB_DOC_BEGIN, 	GRP_WEB_DOC_END },
401 	{ /* Funktionen	*/ 	GRP_WEB_FKT_BEGIN,  GRP_WEB_FKT_END },
402 	{ /* Referenzen	*/ 	GRP_WEB_REF_BEGIN,  GRP_WEB_REF_END },
403 	{ /* Ablage		*/ 	GRP_WEB_REG_BEGIN,  GRP_WEB_REG_END },
404 	{ /* DB			*/	GRP_WEB_DB_BEGIN,	GRP_WEB_DB_END },
405 	{ /* User		*/	GRP_WEB_VAR_BEGIN,	GRP_WEB_VAR_END }
406 };
407 
408 	if (bHtmlMode)
409 		return aWebRanges[(sal_uInt16)nGrpId];
410 	else
411 		return aRanges[(sal_uInt16)nGrpId];
412 }
413 
414 /*--------------------------------------------------------------------
415 	Beschreibung: GroupId bestimmen
416  --------------------------------------------------------------------*/
417 
418 sal_uInt16 SwFldMgr::GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType) const
419 {
420 	if (nTypeId == TYP_SETINPFLD)
421 		nTypeId = TYP_SETFLD;
422 
423 	if (nTypeId == TYP_INPUTFLD && (nSubType & INP_USR))
424 		nTypeId = TYP_USERFLD;
425 
426 	if (nTypeId == TYP_FIXDATEFLD)
427 		nTypeId = TYP_DATEFLD;
428 
429 	if (nTypeId == TYP_FIXTIMEFLD)
430 		nTypeId = TYP_TIMEFLD;
431 
432 	for (sal_uInt16 i = GRP_DOC; i <= GRP_VAR; i++)
433 	{
434 		const SwFldGroupRgn& rRange = GetGroupRange(bHtmlMode, i);
435 		for (sal_uInt16 nPos = rRange.nStart; nPos < rRange.nEnd; nPos++)
436 		{
437 			if (aSwFlds[nPos].nTypeId == nTypeId)
438 				return i;
439 		}
440 	}
441 	return USHRT_MAX;
442 }
443 
444 /*--------------------------------------------------------------------
445 	Beschreibung: Namen zur TypeId ermitteln
446 				  ZUGRIFF ueber TYP_....
447  --------------------------------------------------------------------*/
448 
449 
450 sal_uInt16 SwFldMgr::GetTypeId(sal_uInt16 nPos)
451 {
452 	ASSERT(nPos < ::GetPackCount(), "unzulaessige Pos");
453 	return aSwFlds[ nPos ].nTypeId;
454 }
455 
456 
457 const String& SwFldMgr::GetTypeStr(sal_uInt16 nPos)
458 {
459 	ASSERT(nPos < ::GetPackCount(), "unzulaessige TypeId");
460 
461 	sal_uInt16 nFldWh = aSwFlds[ nPos ].nTypeId;
462 
463 	// Sonderbehandlung fuer Datum/Zeit Felder (ohne var/fix)
464 	if( TYP_DATEFLD == nFldWh )
465 	{
466 		static String g_aDate( SW_RES( STR_DATEFLD ) );
467 		return g_aDate;
468 	}
469 	if( TYP_TIMEFLD == nFldWh )
470 	{
471 		static String g_aTime( SW_RES( STR_TIMEFLD ) );
472 		return g_aTime;
473 	}
474 
475 	return SwFieldType::GetTypeStr( nFldWh );
476 }
477 
478 /*--------------------------------------------------------------------
479 	Beschreibung: Pos in der Liste bestimmen
480  --------------------------------------------------------------------*/
481 
482 
483 sal_uInt16 SwFldMgr::GetPos(sal_uInt16 nTypeId)
484 {
485 	switch( nTypeId )
486 	{
487 		case TYP_FIXDATEFLD:		nTypeId = TYP_DATEFLD;		break;
488 		case TYP_FIXTIMEFLD:      	nTypeId = TYP_TIMEFLD;		break;
489 		case TYP_SETINPFLD:      	nTypeId = TYP_SETFLD;		break;
490 		case TYP_USRINPFLD:      	nTypeId = TYP_USERFLD;		break;
491 	}
492 
493 	for(sal_uInt16 i = 0; i < GetPackCount(); i++)
494 		if(aSwFlds[i].nTypeId == nTypeId)
495 			return i;
496 
497 	return USHRT_MAX;
498 }
499 
500 /*--------------------------------------------------------------------
501 	Beschreibung: Subtypen eines Feldes lokalisieren
502  --------------------------------------------------------------------*/
503 
504 sal_Bool SwFldMgr::GetSubTypes(sal_uInt16 nTypeId, SvStringsDtor& rToFill)
505 {
506     sal_Bool bRet = sal_False;
507     SwWrtShell *pSh = pWrtShell ? pWrtShell : lcl_GetShell();
508     DBG_ASSERT(pSh, "no SwWrtShell found");
509     if(pSh)
510     {
511         const sal_uInt16 nPos = GetPos(nTypeId);
512 
513         switch(nTypeId)
514         {
515             case TYP_SETREFFLD:
516             case TYP_GETREFFLD:
517             {
518                 // Referenzen sind keine Felder
519                 pSh->GetRefMarks( &rToFill );
520                 break;
521             }
522             case TYP_MACROFLD:
523             {
524                 break;
525             }
526             case TYP_INPUTFLD:
527             {   String* pNew = new SW_RESSTR(aSwFlds[nPos].nSubTypeStart);
528                 rToFill.Insert(pNew, rToFill.Count());
529                 // Weiter bei generischen Typen
530             }
531             case TYP_DDEFLD:
532             case TYP_SEQFLD:
533             case TYP_FORMELFLD:
534             case TYP_GETFLD:
535             case TYP_SETFLD:
536             case TYP_USERFLD:
537             {
538 
539                 const sal_uInt16 nCount = pSh->GetFldTypeCount();
540                 for(sal_uInt16 i = 0; i < nCount; ++i)
541                 {
542                     SwFieldType* pFldType = pSh->GetFldType( i );
543                     const sal_uInt16 nWhich = pFldType->Which();
544 
545                     if((nTypeId == TYP_DDEFLD && pFldType->Which() == RES_DDEFLD) ||
546 
547                        (nTypeId == TYP_USERFLD && nWhich == RES_USERFLD) ||
548 
549                        (nTypeId == TYP_GETFLD && nWhich == RES_SETEXPFLD &&
550                         !(((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
551 
552                        (nTypeId == TYP_SETFLD && nWhich == RES_SETEXPFLD &&
553                         !(((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
554 
555                        (nTypeId == TYP_SEQFLD && nWhich == RES_SETEXPFLD  &&
556                        (((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
557 
558                        ((nTypeId == TYP_INPUTFLD || nTypeId == TYP_FORMELFLD) &&
559                          (nWhich == RES_USERFLD ||
560                           (nWhich == RES_SETEXPFLD &&
561                           !(((SwSetExpFieldType*)pFldType)->GetType() & nsSwGetSetExpType::GSE_SEQ))) ) )
562                     {
563                         String* pNew = new String(pFldType->GetName());
564                         rToFill.Insert(pNew, rToFill.Count());
565                     }
566                 }
567                 break;
568             }
569             case TYP_DBNEXTSETFLD:
570             case TYP_DBNUMSETFLD:
571             case TYP_DBNAMEFLD:
572             case TYP_DBSETNUMBERFLD:
573                 break;
574 
575             default:
576             {
577                 // statische SubTypes
578                 if(nPos != USHRT_MAX)
579                 {
580                     sal_uInt16 nCount;
581                     if (nTypeId == TYP_DOCINFOFLD)
582                         nCount = DI_SUBTYPE_END - DI_SUBTYPE_BEGIN;
583                     else
584                         nCount = aSwFlds[nPos].nSubTypeEnd - aSwFlds[nPos].nSubTypeStart;
585 
586                     for(sal_uInt16 i = 0; i < nCount; ++i)
587                     {
588                         String* pNew;
589                         if (nTypeId == TYP_DOCINFOFLD)
590                         {
591                             if ( i == DI_CUSTOM )
592                                 pNew = new String( String(SW_RES( STR_CUSTOM )) );
593 							else
594                                 pNew = new String(*ViewShell::GetShellRes()->aDocInfoLst[i]);
595                         }
596                         else
597                             pNew = new SW_RESSTR(aSwFlds[nPos].nSubTypeStart + i);
598 
599                         rToFill.Insert(pNew, rToFill.Count());
600                     }
601                 }
602             }
603         }
604         bRet = sal_True;
605     }
606     return bRet;
607 }
608 
609 /*--------------------------------------------------------------------
610 	Beschreibung: Format ermitteln
611 				  ZUGRIFF ueber TYP_....
612  --------------------------------------------------------------------*/
613 
614 
615 sal_uInt16 SwFldMgr::GetFormatCount(sal_uInt16 nTypeId, sal_Bool bIsText, sal_Bool bHtmlMode) const
616 {
617 	ASSERT(nTypeId < TYP_END, "unzulaessige TypeId");
618 
619 	{
620 		const sal_uInt16 nPos = GetPos(nTypeId);
621 
622 		if(nPos == USHRT_MAX || (bHtmlMode && nTypeId == TYP_SETFLD))
623 			return 0;
624 
625 		sal_uLong nStart = aSwFlds[nPos].nFmtBegin;
626 		sal_uLong nEnd   = aSwFlds[nPos].nFmtEnd;
627 
628 		if (bIsText && nEnd - nStart >= 2)
629 			return 2;
630 
631 		if (nTypeId == TYP_FILENAMEFLD)
632 			nEnd -= 2;	// Kein Bereich oder Vorlage
633 
634 		switch(nStart)
635 		{
636 			case FMT_GETVAR_BEGIN:
637 			case FMT_SETVAR_BEGIN:	return VF_COUNT;
638 			case FMT_USERVAR_BEGIN:	return VF_USR_COUNT;
639 			case FMT_DBFLD_BEGIN:	return VF_DB_COUNT;
640 			case FMT_NUM_BEGIN:
641 			{
642 				sal_uInt16 nCount = (sal_uInt16)(nEnd - nStart);
643 				GetNumberingInfo();
644                 if(xNumberingInfo.is())
645 				{
646 					Sequence<sal_Int16> aTypes = xNumberingInfo->getSupportedNumberingTypes();
647 					const sal_Int16* pTypes = aTypes.getConstArray();
648 					for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
649 					{
650 						sal_Int16 nCurrent = pTypes[nType];
651 						//skip all values below or equal to CHARS_LOWER_LETTER_N
652 						if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
653 						{
654                             // #i28073# it's not necessarily a sorted sequence
655                             ++nCount;
656 						}
657 					}
658 				}
659 				return nCount;
660 			}
661 
662 		}
663 		return (sal_uInt16)(nEnd - nStart);
664 	}
665 }
666 
667 /*--------------------------------------------------------------------
668 	Beschreibung:	FormatString zu einem Typ ermitteln
669  --------------------------------------------------------------------*/
670 
671 
672 String SwFldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const
673 {
674 	String aRet;
675 	ASSERT(nTypeId < TYP_END, "unzulaessige TypeId");
676 
677 	const sal_uInt16 nPos = GetPos(nTypeId);
678 
679 	if(nPos == USHRT_MAX)
680 		return aRet;
681 
682 	sal_uLong nStart;
683 
684 	nStart = aSwFlds[nPos].nFmtBegin;
685 
686 	if (TYP_AUTHORFLD == nTypeId|| TYP_FILENAMEFLD == nTypeId)
687 		nFormatId &= ~FF_FIXED;		// Fixed-Flag ausmaskieren
688 
689 	if((nStart + nFormatId) < aSwFlds[nPos].nFmtEnd)
690 		aRet = SW_RESSTR((sal_uInt16)(nStart + nFormatId));
691 	else if( FMT_NUM_BEGIN == nStart)
692 	{
693 		if(xNumberingInfo.is())
694 		{
695 			Sequence<sal_Int16> aTypes = xNumberingInfo->getSupportedNumberingTypes();
696 			const sal_Int16* pTypes = aTypes.getConstArray();
697             sal_Int32 nOffset = aSwFlds[nPos].nFmtEnd - nStart;
698             sal_Int32 nValidEntry = 0;
699             for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
700 			{
701 				sal_Int16 nCurrent = pTypes[nType];
702 				if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
703 				{
704                     if(nValidEntry == ((sal_Int32)nFormatId) - nOffset)
705                     {
706                         aRet = xNumberingInfo->getNumberingIdentifier( pTypes[nType] );
707                         break;
708                     }
709                     ++nValidEntry;
710 				}
711 			}
712 		}
713 	}
714 
715 	return aRet;
716 }
717 
718 /*--------------------------------------------------------------------
719 	Beschreibung:	FormatId aus Pseudo-ID ermitteln
720  --------------------------------------------------------------------*/
721 
722 sal_uInt16 SwFldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const
723 {
724 	sal_uInt16 nId = (sal_uInt16)nFormatId;
725 
726 	switch( nTypeId )
727 	{
728 	case TYP_DOCINFOFLD:
729 		switch( aSwFlds[ GetPos( nTypeId ) ].nFmtBegin + nFormatId )
730 		{
731 		case FMT_REG_AUTHOR:	nId = DI_SUB_AUTHOR;	break;
732 		case FMT_REG_TIME:		nId = DI_SUB_TIME;		break;
733 		case FMT_REG_DATE:		nId = DI_SUB_DATE;		break;
734 		}
735 		break;
736 
737 	case TYP_PAGENUMBERFLD:
738 	case TYP_NEXTPAGEFLD:
739 	case TYP_PREVPAGEFLD:
740 	case TYP_DOCSTATFLD:
741 	case TYP_DBSETNUMBERFLD:
742 	case TYP_SEQFLD:
743 	case TYP_GETREFPAGEFLD:
744 	{
745 		sal_uInt16 nPos = GetPos( nTypeId );
746 		sal_uLong nBegin = aSwFlds[ nPos ].nFmtBegin;
747 		sal_uLong nEnd = aSwFlds[nPos].nFmtEnd;
748 		if((nBegin + nFormatId) < nEnd)
749 		{
750 			switch( nBegin + nFormatId )
751 			{
752 			case FMT_NUM_ABC:				nId = SVX_NUM_CHARS_UPPER_LETTER;	break;
753 			case FMT_NUM_SABC:				nId = SVX_NUM_CHARS_LOWER_LETTER;	break;
754 			case FMT_NUM_ROMAN:             nId = SVX_NUM_ROMAN_UPPER;			break;
755 			case FMT_NUM_SROMAN:			nId = SVX_NUM_ROMAN_LOWER;			break;
756 			case FMT_NUM_ARABIC:            nId = SVX_NUM_ARABIC;				break;
757 			case FMT_NUM_PAGEDESC: 			nId = SVX_NUM_PAGEDESC; 			break;
758 			case FMT_NUM_PAGESPECIAL:		nId = SVX_NUM_CHAR_SPECIAL;			break;
759 			case FMT_NUM_ABC_N:				nId = SVX_NUM_CHARS_UPPER_LETTER_N; break;
760 			case FMT_NUM_SABC_N:			nId = SVX_NUM_CHARS_LOWER_LETTER_N;	break;
761 			}
762 		}
763 		else if(xNumberingInfo.is())
764 		{
765 			Sequence<sal_Int16> aTypes = xNumberingInfo->getSupportedNumberingTypes();
766 			const sal_Int16* pTypes = aTypes.getConstArray();
767             sal_Int32 nOffset = nEnd - nBegin;
768             sal_Int32 nValidEntry = 0;
769             for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
770             {
771                 sal_Int16 nCurrent = pTypes[nType];
772                 if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
773                 {
774                     if(nValidEntry == ((sal_Int32)nFormatId) - nOffset)
775                     {
776                         nId = pTypes[nType];
777                         break;
778                     }
779                     ++nValidEntry;
780                 }
781             }
782         }
783 	}
784 	break;
785 	case TYP_DDEFLD:
786 		switch ( aSwFlds[ GetPos( nTypeId ) ].nFmtBegin + nFormatId )
787 		{
788         case FMT_DDE_NORMAL:    nId = sfx2::LINKUPDATE_ONCALL; break;
789         case FMT_DDE_HOT:       nId = sfx2::LINKUPDATE_ALWAYS; break;
790 		}
791 		break;
792 	}
793 
794 	return nId;
795 
796 }
797 
798 /*--------------------------------------------------------------------
799 	Beschreibung: Traveling
800  --------------------------------------------------------------------*/
801 
802 
803 sal_Bool SwFldMgr::GoNextPrev( sal_Bool bNext, SwFieldType* pTyp )
804 {
805 	SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
806     if(!pSh)
807         return sal_False;
808 
809 	if( !pTyp && pCurFld )
810 	{
811 		const sal_uInt16 nTypeId = pCurFld->GetTypeId();
812 		if( TYP_SETINPFLD == nTypeId || TYP_USRINPFLD == nTypeId )
813 			pTyp = pSh->GetFldType( 0, RES_INPUTFLD );
814 		else
815 			pTyp = pCurFld->GetTyp();
816 	}
817 
818 	if (pTyp && pTyp->Which() == RES_DBFLD)
819 	{
820 		// Fuer Feldbefehl-bearbeiten (alle DB-Felder anspringen)
821 		return pSh->MoveFldType( 0, (bNext ? true : false), RES_DBFLD );
822 	}
823 
824     return (pTyp && pSh)
825            ? pSh->MoveFldType( pTyp, (bNext ? true : false) )
826            : sal_False;
827 }
828 
829 /*--------------------------------------------------------------------
830 	Beschreibung: Feldtypen einfuegen
831  --------------------------------------------------------------------*/
832 
833 
834 void SwFldMgr::InsertFldType(SwFieldType& rType)
835 {
836     SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
837     DBG_ASSERT(pSh, "no SwWrtShell found");
838     if(pSh)
839         pSh->InsertFldType(rType);
840 }
841 
842 /*--------------------------------------------------------------------
843 	Beschreibung: Aktuelle TypeId ermitteln
844  --------------------------------------------------------------------*/
845 
846 
847 sal_uInt16 SwFldMgr::GetCurTypeId() const
848 {
849     return pCurFld ? pCurFld->GetTypeId() : USHRT_MAX;
850 }
851 
852 /*--------------------------------------------------------------------
853 	Beschreibung: Ueber String  Feld einfuegen oder Update
854  --------------------------------------------------------------------*/
855 
856 
857 sal_Bool SwFldMgr::InsertFld(  const SwInsertFld_Data& rData )
858 {
859     SwField* pFld   = 0;
860 	sal_Bool bExp = sal_False;
861 	sal_Bool bTbl = sal_False;
862 	sal_Bool bPageVar = sal_False;
863     sal_uLong nFormatId = rData.nFormatId;
864     sal_uInt16 nSubType = rData.nSubType;
865     sal_Unicode cSeparator = rData.cSeparator;
866     SwWrtShell* pCurShell = rData.pSh;
867     if(!pCurShell)
868         pCurShell = pWrtShell ? pWrtShell : ::lcl_GetShell();
869     DBG_ASSERT(pCurShell, "no SwWrtShell found");
870     if(!pCurShell)
871         return sal_False;
872 
873     switch(rData.nTypeId)
874 	{   // ACHTUNG dieses Feld wird ueber einen gesonderten Dialog eingefuegt
875 		case TYP_POSTITFLD:
876 		{
877 			SwPostItFieldType* pType = (SwPostItFieldType*)pCurShell->GetFldType(0, RES_POSTITFLD);
878 			pFld = new SwPostItField(pType, rData.sPar1, rData.sPar2, DateTime());
879 			break;
880 		}
881 		case TYP_SCRIPTFLD:
882 		{
883 			SwScriptFieldType* pType =
884                 (SwScriptFieldType*)pCurShell->GetFldType(0, RES_SCRIPTFLD);
885             pFld = new SwScriptField(pType, rData.sPar1, rData.sPar2, (sal_Bool)nFormatId);
886 			break;
887 		}
888 		case TYP_COMBINED_CHARS:
889 		{
890 			SwCombinedCharFieldType* pType = (SwCombinedCharFieldType*)
891                                 pCurShell->GetFldType( 0, RES_COMBINED_CHARS );
892             pFld = new SwCombinedCharField( pType, rData.sPar1 );
893 		}
894 		break;
895 		case TYP_AUTHORITY:
896 		{
897 			SwAuthorityFieldType* pType =
898                 (SwAuthorityFieldType*)pCurShell->GetFldType(0, RES_AUTHORITY);
899 			if(!pType)
900 			{
901 				pType =
902                     (SwAuthorityFieldType*)pCurShell->InsertFldType(
903                                     SwAuthorityFieldType(pCurShell->GetDoc()));
904 			}
905             pFld = new SwAuthorityField(pType, rData.sPar1);
906 		}
907 		break;
908 		case TYP_DATEFLD:
909 		case TYP_TIMEFLD:
910 		{
911             sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.nTypeId == TYP_DATEFLD ? DATEFLD : TIMEFLD);
912             nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD;
913 
914 			SwDateTimeFieldType* pTyp =
915                 (SwDateTimeFieldType*)pCurShell->GetFldType(0, RES_DATETIMEFLD);
916             pFld = new SwDateTimeField(pTyp, nSub, nFormatId);
917             pFld->SetPar2(rData.sPar2);
918 			break;
919 		}
920 		case TYP_FILENAMEFLD:
921 		{
922 			SwFileNameFieldType* pTyp =
923                 (SwFileNameFieldType*)pCurShell->GetFldType(0, RES_FILENAMEFLD);
924             pFld = new SwFileNameField(pTyp, nFormatId);
925 			break;
926 		}
927 		case TYP_TEMPLNAMEFLD:
928 		{
929 			SwTemplNameFieldType* pTyp =
930                 (SwTemplNameFieldType*)pCurShell->GetFldType(0, RES_TEMPLNAMEFLD);
931             pFld = new SwTemplNameField(pTyp, nFormatId);
932 			break;
933 		}
934 		case TYP_CHAPTERFLD:
935         {
936             sal_uInt16 nByte = (sal_uInt16)rData.sPar2.ToInt32();
937 			SwChapterFieldType* pTyp =
938                 (SwChapterFieldType*)pCurShell->GetFldType(0, RES_CHAPTERFLD);
939             pFld = new SwChapterField(pTyp, nFormatId);
940 			nByte = Max(sal_uInt16(1), nByte);
941 			nByte = Min(nByte, sal_uInt16(MAXLEVEL));
942 			nByte -= 1;
943 			((SwChapterField*)pFld)->SetLevel((sal_uInt8)nByte);
944 			break;
945 		}
946 		case TYP_NEXTPAGEFLD:
947 		case TYP_PREVPAGEFLD:
948 		case TYP_PAGENUMBERFLD:
949 		{
950             short nOff  = (short)rData.sPar2.ToInt32();
951 
952             if(rData.nTypeId == TYP_NEXTPAGEFLD)
953 			{
954                 if( SVX_NUM_CHAR_SPECIAL == nFormatId )
955 					nOff = 1;
956 				else
957 					nOff += 1;
958                 nSubType = PG_NEXT;
959 			}
960             else if(rData.nTypeId == TYP_PREVPAGEFLD)
961 			{
962                 if( SVX_NUM_CHAR_SPECIAL == nFormatId )
963 					nOff = -1;
964 				else
965 					nOff -= 1;
966                 nSubType =  PG_PREV;
967 			}
968 			else
969                 nSubType = PG_RANDOM;
970 
971 			SwPageNumberFieldType* pTyp =
972                 (SwPageNumberFieldType*)pCurShell->GetFldType(0, RES_PAGENUMBERFLD);
973             pFld = new SwPageNumberField(pTyp, nSubType, nFormatId, nOff);
974 
975             if( SVX_NUM_CHAR_SPECIAL == nFormatId &&
976                 ( PG_PREV == nSubType || PG_NEXT == nSubType ) )
977                 ((SwPageNumberField*)pFld)->SetUserString( rData.sPar2 );
978 			break;
979 		}
980 		case TYP_DOCSTATFLD:
981 		{	SwDocStatFieldType* pTyp =
982                 (SwDocStatFieldType*)pCurShell->GetFldType(0, RES_DOCSTATFLD);
983             pFld = new SwDocStatField(pTyp, nSubType, nFormatId);
984 			break;
985 		}
986 		case TYP_AUTHORFLD:
987 		{	SwAuthorFieldType* pTyp =
988                 (SwAuthorFieldType*)pCurShell->GetFldType(0, RES_AUTHORFLD);
989             pFld = new SwAuthorField(pTyp, nFormatId);
990 			break;
991 		}
992 		case TYP_CONDTXTFLD:
993 		case TYP_HIDDENTXTFLD:
994 		{
995 			SwHiddenTxtFieldType* pTyp =
996                 (SwHiddenTxtFieldType*)pCurShell->GetFldType(0, RES_HIDDENTXTFLD);
997             pFld = new SwHiddenTxtField(pTyp, sal_True, rData.sPar1, rData.sPar2, sal_False, rData.nTypeId);
998 			bExp = sal_True;
999 			break;
1000 		}
1001 		case TYP_HIDDENPARAFLD:
1002 		{
1003 			SwHiddenParaFieldType* pTyp =
1004                 (SwHiddenParaFieldType*)pCurShell->GetFldType(0, RES_HIDDENPARAFLD);
1005             pFld = new SwHiddenParaField(pTyp, rData.sPar1);
1006 			bExp = sal_True;
1007 			break;
1008 		}
1009 		case TYP_SETREFFLD:
1010 		{
1011             if( rData.sPar1.Len() > 0 && CanInsertRefMark( rData.sPar1 ) )
1012 			{
1013                 pCurShell->SetAttrItem( SwFmtRefMark( rData.sPar1 ) );
1014 				return sal_True;
1015 			}
1016 			return sal_False;
1017 		}
1018 		case TYP_GETREFFLD:
1019 		{
1020 			SwGetRefFieldType* pTyp =
1021                 (SwGetRefFieldType*)pCurShell->GetFldType(0, RES_GETREFFLD);
1022             sal_uInt16 nSeqNo = (sal_uInt16)rData.sPar2.ToInt32();
1023             pFld = new SwGetRefField(pTyp, rData.sPar1, nSubType, nSeqNo, nFormatId);
1024 			bExp = sal_True;
1025 			break;
1026 		}
1027 		case TYP_DDEFLD:
1028 		{
1029 			//JP 28.08.95: DDE-Topics/-Items koennen Blanks in ihren
1030 			//				Namen haben! Wird hier noch nicht beachtet.
1031             String sCmd( rData.sPar2 );
1032             sal_uInt16 nTmpPos = sCmd.SearchAndReplace( ' ', sfx2::cTokenSeperator );
1033             sCmd.SearchAndReplace( ' ', sfx2::cTokenSeperator, nTmpPos );
1034 
1035             SwDDEFieldType aType( rData.sPar1, sCmd, (sal_uInt16) nFormatId );
1036             SwDDEFieldType* pTyp = (SwDDEFieldType*) pCurShell->InsertFldType( aType );
1037 			pFld = new SwDDEField( pTyp );
1038 			break;
1039 		}
1040 		case TYP_MACROFLD:
1041 		{
1042 			SwMacroFieldType* pTyp =
1043 				(SwMacroFieldType*)pCurShell->GetFldType(0, RES_MACROFLD);
1044 
1045 			pFld = new SwMacroField(pTyp, rData.sPar1, rData.sPar2);
1046 
1047 			break;
1048 		}
1049 		case TYP_INTERNETFLD:
1050 		{
1051             SwFmtINetFmt aFmt( rData.sPar1, sCurFrame );
1052 			if( pMacroItem )
1053 				aFmt.SetMacroTbl( &pMacroItem->GetMacroTable() );
1054             return pCurShell->InsertURL( aFmt, rData.sPar2 );
1055 		}
1056 		case TYP_JUMPEDITFLD:
1057 		{
1058 			SwJumpEditFieldType* pTyp =
1059                 (SwJumpEditFieldType*)pCurShell->GetFldType(0, RES_JUMPEDITFLD);
1060 
1061             pFld = new SwJumpEditField(pTyp, nFormatId, rData.sPar1, rData.sPar2 );
1062 			break;
1063 		}
1064 		case TYP_DOCINFOFLD:
1065 		{
1066             SwDocInfoFieldType* pTyp = (SwDocInfoFieldType*)pCurShell->GetFldType(
1067 											0, RES_DOCINFOFLD );
1068             pFld = new SwDocInfoField(pTyp, nSubType, rData.sPar1, nFormatId);
1069 			break;
1070 		}
1071 		case TYP_EXTUSERFLD:
1072 		{
1073             SwExtUserFieldType* pTyp = (SwExtUserFieldType*)pCurShell->GetFldType(
1074 											0, RES_EXTUSERFLD);
1075             pFld = new SwExtUserField(pTyp, nSubType, nFormatId);
1076 			break;
1077 		}
1078 		case TYP_DBFLD:
1079 		{
1080 			SwDBData aDBData;
1081 			String sPar1;
1082 
1083             if (rData.sPar1.Search(DB_DELIM) == STRING_NOTFOUND)
1084 			{
1085                 aDBData = pCurShell->GetDBData();
1086                 sPar1 = rData.sPar1;
1087 			}
1088 			else
1089 			{
1090                 aDBData.sDataSource = rData.sPar1.GetToken(0, DB_DELIM);
1091                 aDBData.sCommand = rData.sPar1.GetToken(1, DB_DELIM);
1092                 aDBData.nCommandType = rData.sPar1.GetToken(2, DB_DELIM).ToInt32();
1093                 sPar1 = rData.sPar1.GetToken(3, DB_DELIM);
1094 			}
1095 
1096             if(aDBData.sDataSource.getLength() && pCurShell->GetDBData() != aDBData)
1097                 pCurShell->ChgDBData(aDBData);
1098 
1099             SwDBFieldType* pTyp = (SwDBFieldType*)pCurShell->InsertFldType(
1100                     SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) );
1101 			pFld = new SwDBField(pTyp);
1102             pFld->SetSubType(nSubType);
1103 
1104             if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // Datenbankformat ermitteln
1105 			{
1106                 Reference< XDataSource> xSource;
1107                 rData.aDBDataSource >>= xSource;
1108                 Reference<XConnection> xConnection;
1109                 rData.aDBConnection >>= xConnection;
1110                 Reference<XPropertySet> xColumn;
1111                 rData.aDBColumn >>= xColumn;
1112                 if(xColumn.is())
1113                 {
1114                     nFormatId = pCurShell->GetNewDBMgr()->GetColumnFmt(xSource, xConnection, xColumn,
1115                                         pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1116                 }
1117                 else
1118                     nFormatId = pCurShell->GetNewDBMgr()->GetColumnFmt(
1119                                         aDBData.sDataSource, aDBData.sCommand, sPar1,
1120                                         pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1121 			}
1122             pFld->ChangeFormat( nFormatId );
1123 
1124 			bExp = sal_True;
1125 			break;
1126 		}
1127 		case TYP_DBSETNUMBERFLD:
1128 		case TYP_DBNUMSETFLD:
1129 		case TYP_DBNEXTSETFLD:
1130 		case TYP_DBNAMEFLD:
1131 		{
1132 			sal_uInt16 nPos, nTablePos, nCmdTypePos, nExpPos;
1133 			String sPar1;
1134 			SwDBData aDBData;
1135 
1136             // DBName aus rData.sPar1 extrahieren. Format: DBName.TableName.CommandType.ExpStrg
1137             if ((nTablePos = rData.sPar1.Search(DB_DELIM)) != STRING_NOTFOUND)
1138                 aDBData.sDataSource = rData.sPar1.Copy(0, nTablePos++);
1139             if ((nCmdTypePos = rData.sPar1.Search(DB_DELIM, nTablePos)) != STRING_NOTFOUND)
1140 			{
1141                 aDBData.sCommand = rData.sPar1.Copy(nTablePos, nCmdTypePos++ - nTablePos);
1142 			}
1143             if ((nExpPos = rData.sPar1.Search(DB_DELIM, nCmdTypePos)) != STRING_NOTFOUND)
1144 			{
1145                 aDBData.nCommandType = rData.sPar1.Copy(nCmdTypePos, nExpPos++ - nCmdTypePos).ToInt32();
1146 			}
1147 			if (nExpPos != STRING_NOTFOUND)
1148 				nPos = nExpPos;
1149 			else if (nTablePos != STRING_NOTFOUND)
1150 				nPos = nTablePos;
1151 			else
1152 				nPos = 0;
1153             sPar1 = rData.sPar1.Copy(nPos);
1154 
1155             if (aDBData.sDataSource.getLength() && pCurShell->GetDBData() != aDBData)
1156                 pCurShell->ChgDBData(aDBData);
1157 
1158             switch(rData.nTypeId)
1159 			{
1160 				case TYP_DBNAMEFLD:
1161 				{
1162 					SwDBNameFieldType* pTyp =
1163                         (SwDBNameFieldType*)pCurShell->GetFldType(0, RES_DBNAMEFLD);
1164 					pFld = new SwDBNameField(pTyp, aDBData);
1165 
1166 					break;
1167 				}
1168 				case TYP_DBNEXTSETFLD:
1169 				{
1170                     SwDBNextSetFieldType* pTyp = (SwDBNextSetFieldType*)pCurShell->GetFldType(
1171 													0, RES_DBNEXTSETFLD);
1172                     pFld = new SwDBNextSetField(pTyp, sPar1, rData.sPar2, aDBData);
1173 					bExp = sal_True;
1174 					break;
1175 				}
1176 				case TYP_DBNUMSETFLD:
1177 				{
1178                     SwDBNumSetFieldType* pTyp = (SwDBNumSetFieldType*)pCurShell->GetFldType(
1179 													0, RES_DBNUMSETFLD);
1180                     pFld = new SwDBNumSetField( pTyp, sPar1, rData.sPar2, aDBData);
1181 					bExp = sal_True;
1182 					break;
1183 				}
1184 				case TYP_DBSETNUMBERFLD:
1185 				{
1186 					SwDBSetNumberFieldType* pTyp = (SwDBSetNumberFieldType*)
1187                                                 pCurShell->GetFldType(0, RES_DBSETNUMBERFLD);
1188                     pFld = new SwDBSetNumberField( pTyp, aDBData, nFormatId);
1189 					bExp = sal_True;
1190 					break;
1191 				}
1192 			}
1193 			break;
1194 		}
1195 		case TYP_USERFLD:
1196 		{
1197 			SwUserFieldType* pTyp =
1198                 (SwUserFieldType*)pCurShell->GetFldType(RES_USERFLD, rData.sPar1);
1199 
1200 			// nur wenn vorhanden
1201 			if(!pTyp)
1202 			{
1203                 pTyp = (SwUserFieldType*)pCurShell->InsertFldType(
1204                         SwUserFieldType(pCurShell->GetDoc(), rData.sPar1));
1205 			}
1206             if (pTyp->GetContent(nFormatId) != rData.sPar2)
1207                 pTyp->SetContent(rData.sPar2, nFormatId);
1208             pFld = new SwUserField(pTyp, 0, nFormatId);
1209             if (pFld->GetSubType() != nSubType)
1210                 pFld->SetSubType(nSubType);
1211 			bTbl = sal_True;
1212 			break;
1213 		}
1214 		case TYP_INPUTFLD:
1215 		{
1216             if ((nSubType & 0x00ff) == INP_VAR)
1217 			{
1218 				SwSetExpFieldType* pTyp = (SwSetExpFieldType*)
1219                                     pCurShell->GetFldType(RES_SETEXPFLD, rData.sPar1);
1220 
1221 				// kein Experssion Type mit dem Namen vorhanden -> anlegen
1222 				if(pTyp)
1223 				{
1224 					SwSetExpField* pExpFld =
1225                         new SwSetExpField(pTyp, aEmptyStr, nFormatId);
1226 
1227 					// Typ vom SwSetExpFieldType nicht veraendern:
1228 					sal_uInt16 nOldSubType = pExpFld->GetSubType();
1229                     pExpFld->SetSubType(nOldSubType | (nSubType & 0xff00));
1230 
1231                     pExpFld->SetPromptText(rData.sPar2);
1232 					pExpFld->SetInputFlag(sal_True) ;
1233 					bExp = sal_True;
1234 					pFld = pExpFld;
1235 				}
1236 				else
1237 					return sal_False;
1238 			}
1239 			else
1240 			{
1241                 SwInputFieldType* pTyp =
1242                     (SwInputFieldType*)pCurShell->GetFldType(0, RES_INPUTFLD);
1243 
1244                 SwInputField* pInpFld =
1245                     new SwInputField( pTyp, rData.sPar1, rData.sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId);
1246                 pFld = pInpFld;
1247             }
1248 
1249 			// Dialog starten
1250 			//
1251             pCurShell->StartInputFldDlg(pFld, sal_False, rData.pParent);
1252 			break;
1253 		}
1254 		case TYP_SETFLD:
1255 		{
1256             if (!rData.sPar2.Len())   // Leere Variablen sind nicht erlaubt
1257 				return sal_False;
1258 
1259             SwSetExpFieldType* pTyp = (SwSetExpFieldType*)pCurShell->InsertFldType(
1260                     SwSetExpFieldType(pCurShell->GetDoc(), rData.sPar1) );
1261 
1262             SwSetExpField* pExpFld = new SwSetExpField( pTyp, rData.sPar2, nFormatId);
1263             pExpFld->SetSubType(nSubType);
1264             pExpFld->SetPar2(rData.sPar2);
1265 			bExp = sal_True;
1266 			pFld = pExpFld;
1267 			break;
1268 		}
1269 		case TYP_SEQFLD:
1270 		{
1271             SwSetExpFieldType* pTyp = (SwSetExpFieldType*)pCurShell->InsertFldType(
1272                     SwSetExpFieldType(pCurShell->GetDoc(), rData.sPar1, nsSwGetSetExpType::GSE_SEQ));
1273 
1274             sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff);
1275 
1276 			pTyp->SetOutlineLvl(nLevel);
1277             if (nLevel != 0x7f && cSeparator == 0)
1278                 cSeparator = '.';
1279 
1280             pTyp->SetDelimiter(cSeparator);
1281             SwSetExpField* pExpFld = new SwSetExpField(pTyp, rData.sPar2, nFormatId);
1282 			bExp = sal_True;
1283 			pFld = pExpFld;
1284             nSubType = nsSwGetSetExpType::GSE_SEQ;
1285 			break;
1286 		}
1287 		case TYP_GETFLD:
1288 		{
1289 			// gibt es ein entprechendes SetField
1290 			SwSetExpFieldType* pSetTyp = (SwSetExpFieldType*)
1291                                     pCurShell->GetFldType(RES_SETEXPFLD, rData.sPar1);
1292 
1293 			if(pSetTyp)
1294 			{
1295                 SwGetExpFieldType* pTyp = (SwGetExpFieldType*)pCurShell->GetFldType(
1296 												0, RES_GETEXPFLD);
1297                 pFld = new SwGetExpField(pTyp, rData.sPar1, pSetTyp->GetType(), nFormatId);
1298                 pFld->SetSubType(nSubType | pSetTyp->GetType());
1299 				bExp = sal_True;
1300 			}
1301 			else
1302 				return sal_False;
1303 			break;
1304 		}
1305 		case TYP_FORMELFLD:
1306 		{
1307             if(pCurShell->GetFrmType(0,sal_False) & FRMTYPE_TABLE)
1308 			{
1309                 pCurShell->StartAllAction();
1310 
1311                 SvNumberFormatter* pFormatter = pCurShell->GetDoc()->GetNumberFormatter();
1312                 const SvNumberformat* pEntry = pFormatter->GetEntry(nFormatId);
1313 
1314 				if (pEntry)
1315 				{
1316 					SfxStringItem aFormat(FN_NUMBER_FORMAT, pEntry->GetFormatstring());
1317                     pCurShell->GetView().GetViewFrame()->GetDispatcher()->
1318 						Execute(FN_NUMBER_FORMAT, SFX_CALLMODE_SYNCHRON, &aFormat, 0L);
1319 				}
1320 
1321                 SfxItemSet aBoxSet( pCurShell->GetAttrPool(),
1322 								RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
1323 
1324                 String sFml( rData.sPar2 );
1325 				if( sFml.EraseLeadingChars().Len() &&
1326 					'=' == sFml.GetChar( 0 ) )
1327 					sFml.Erase( 0, 1 );
1328 
1329 				aBoxSet.Put( SwTblBoxFormula( sFml ));
1330                 pCurShell->SetTblBoxFormulaAttrs( aBoxSet );
1331                 pCurShell->UpdateTable();
1332 
1333                 pCurShell->EndAllAction();
1334 				return sal_True;
1335 
1336 /*				// In der Tabelle Tabellenformeln einfuegen
1337                 SwTblFieldType* pTyp = (SwTblFieldType*)pCurShell->GetFldType(
1338 														0, RES_TABLEFLD);
1339                 pFld = new SwTblField(pTyp, rData.sPar2, nsSwGetSetExpType::GSE_EXPR, nFormatId);
1340 				bTbl = sal_True;*/
1341 			}
1342 			else
1343 			{
1344 				SwGetExpFieldType* pTyp = (SwGetExpFieldType*)
1345                                             pCurShell->GetFldType(0, RES_GETEXPFLD);
1346                 pFld = new SwGetExpField(pTyp, rData.sPar2, nsSwGetSetExpType::GSE_FORMULA, nFormatId);
1347                 pFld->SetSubType(nSubType);
1348 				bExp = sal_True;
1349 			}
1350 			break;
1351 		}
1352 		case TYP_SETREFPAGEFLD:
1353 			pFld = new SwRefPageSetField( (SwRefPageSetFieldType*)
1354                                 pCurShell->GetFldType( 0, RES_REFPAGESETFLD ),
1355                                 (short)rData.sPar2.ToInt32(), 0 != nSubType  );
1356 			bPageVar = sal_True;
1357 			break;
1358 
1359 		case TYP_GETREFPAGEFLD:
1360 			pFld = new SwRefPageGetField( (SwRefPageGetFieldType*)
1361                             pCurShell->GetFldType( 0, RES_REFPAGEGETFLD ), nFormatId );
1362 			bPageVar = sal_True;
1363 			break;
1364         case TYP_DROPDOWN :
1365         {
1366             pFld = new SwDropDownField(pCurShell->GetFldType( 0, RES_DROPDOWN ));
1367             xub_StrLen nTokenCount = rData.sPar2.Len() ? rData.sPar2.GetTokenCount(DB_DELIM) : 0;
1368             Sequence<OUString> aEntries(nTokenCount);
1369             OUString* pArray = aEntries.getArray();
1370             for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++)
1371                 pArray[nToken] = rData.sPar2.GetToken(nToken, DB_DELIM);
1372             ((SwDropDownField*)pFld)->SetItems(aEntries);
1373             ((SwDropDownField*)pFld)->SetName(rData.sPar1);
1374         }
1375         break;
1376 		default:
1377 		{	ASSERT(!this, "Falscher Feldtyp");
1378 			return sal_False;
1379 		}
1380 	}
1381 	ASSERT(pFld, "Feld nicht vorhanden");
1382 
1383 
1384      //the auto language flag has to be set prior to the language!
1385      pFld->SetAutomaticLanguage(rData.bIsAutomaticLanguage);
1386      sal_uInt16 nLang = GetCurrLanguage();
1387      pFld->SetLanguage(nLang);
1388 
1389 	// Einfuegen
1390     pCurShell->StartAllAction();
1391 
1392     pCurShell->Insert(*pFld);
1393 
1394 	if(bExp && bEvalExp)
1395         pCurShell->UpdateExpFlds(sal_True);
1396 
1397 	if(bTbl)
1398 	{
1399         pCurShell->Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
1400         pCurShell->UpdateFlds(*pFld);
1401         pCurShell->Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
1402 	}
1403 	else if( bPageVar )
1404         ((SwRefPageGetFieldType*)pCurShell->GetFldType( 0, RES_REFPAGEGETFLD ))->UpdateFlds();
1405     else if( TYP_GETREFFLD == rData.nTypeId )
1406 		pFld->GetTyp()->ModifyNotification( 0, 0 );
1407 
1408 	// temporaeres Feld loeschen
1409 	delete pFld;
1410 
1411     pCurShell->EndAllAction();
1412 	return sal_True;
1413 }
1414 
1415 /*--------------------------------------------------------------------
1416 	Beschreibung: Felder Update
1417  --------------------------------------------------------------------*/
1418 
1419 
1420 void SwFldMgr::UpdateCurFld(sal_uLong nFormat,
1421 							const String& rPar1,
1422 							const String& rPar2,
1423                             SwField * _pTmpFld) // #111840#
1424 {
1425 	// Format aendern
1426 	ASSERT(pCurFld, "kein Feld an der CursorPos");
1427 
1428     bool bDelete = false;
1429     SwField *pTmpFld;		// mb: fixed memory leak
1430     if (NULL != _pTmpFld)
1431     {
1432         pTmpFld = _pTmpFld;
1433     }
1434     else
1435     {
1436         pTmpFld = pCurFld->CopyField();
1437         bDelete = true;
1438     }
1439 
1440 	SwFieldType* pType   = pTmpFld->GetTyp();
1441 	const sal_uInt16 nTypeId = pTmpFld->GetTypeId();
1442 
1443     SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
1444     DBG_ASSERT(pSh, "no SwWrtShell found");
1445     if(!pSh)
1446         return;
1447     pSh->StartAllAction();
1448 
1449 	sal_Bool bSetPar2 = sal_True;
1450 	sal_Bool bSetPar1 = sal_True;
1451 	String sPar1( rPar1 );
1452 	String sPar2( rPar2 );
1453 
1454 	// Order to Format
1455 	switch( nTypeId )
1456 	{
1457 		case TYP_DDEFLD:
1458 		{
1459 			//JP 28.08.95: DDE-Topics/-Items koennen Blanks in ihren
1460 			//				Namen haben! Wird hier noch nicht beachtet.
1461             sal_uInt16 nTmpPos = sPar2.SearchAndReplace( ' ', sfx2::cTokenSeperator );
1462             sPar2.SearchAndReplace( ' ', sfx2::cTokenSeperator, nTmpPos );
1463 			break;
1464 		}
1465 
1466 		case TYP_CHAPTERFLD:
1467 		{
1468             sal_uInt16 nByte = (sal_uInt16)rPar2.ToInt32();
1469 			nByte = Max(sal_uInt16(1), nByte);
1470 			nByte = Min(nByte, sal_uInt16(MAXLEVEL));
1471 			nByte -= 1;
1472 			((SwChapterField*)pTmpFld)->SetLevel((sal_uInt8)nByte);
1473 			bSetPar2 = sal_False;
1474 			break;
1475 		}
1476 
1477 		case TYP_SCRIPTFLD:
1478 			((SwScriptField*)pTmpFld)->SetCodeURL((sal_Bool)nFormat);
1479 			break;
1480 
1481 		case TYP_NEXTPAGEFLD:
1482 			if( SVX_NUM_CHAR_SPECIAL == nFormat )
1483 			{
1484 				((SwPageNumberField*)pCurFld)->SetUserString( sPar2 );
1485 				sPar2 = '1';
1486 			}
1487 			else
1488 			{
1489 				if( nFormat + 2 == SVX_NUM_PAGEDESC )
1490 					nFormat = SVX_NUM_PAGEDESC;
1491                 short nOff = (short)sPar2.ToInt32();
1492 				nOff += 1;
1493 				sPar2 = String::CreateFromInt32(nOff);
1494 			}
1495 			break;
1496 
1497 		case TYP_PREVPAGEFLD:
1498 			if( SVX_NUM_CHAR_SPECIAL == nFormat )
1499 			{
1500 				((SwPageNumberField*)pCurFld)->SetUserString( sPar2 );
1501 				sPar2 = String::CreateFromAscii(
1502                     RTL_CONSTASCII_STRINGPARAM("-1"));
1503 			}
1504 			else
1505 			{
1506 				if( nFormat + 2 == SVX_NUM_PAGEDESC )
1507 					nFormat = SVX_NUM_PAGEDESC;
1508                 short nOff = (short)sPar2.ToInt32();
1509 				nOff -= 1;
1510 				sPar2 = String::CreateFromInt32(nOff);
1511 			}
1512 			break;
1513 
1514 		case TYP_PAGENUMBERFLD:
1515 		case TYP_GETREFPAGEFLD:
1516 			if( nFormat + 2 == SVX_NUM_PAGEDESC )
1517 				nFormat = SVX_NUM_PAGEDESC;
1518 			break;
1519 
1520 		case TYP_GETREFFLD:
1521 			{
1522 				bSetPar2 = sal_False;
1523                 ((SwGetRefField*)pTmpFld)->SetSubType( (sal_uInt16)rPar2.ToInt32() );
1524 				sal_uInt16 nPos = rPar2.Search( '|' );
1525 				if( STRING_NOTFOUND != nPos )
1526                     ((SwGetRefField*)pTmpFld)->SetSeqNo( (sal_uInt16)rPar2.Copy( nPos + 1 ).ToInt32());
1527 			}
1528 			break;
1529 		case TYP_DROPDOWN:
1530 		{
1531             xub_StrLen nTokenCount = sPar2.Len() ? sPar2.GetTokenCount(DB_DELIM) : 0;
1532             Sequence<OUString> aEntries(nTokenCount);
1533             OUString* pArray = aEntries.getArray();
1534             for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++)
1535                 pArray[nToken] = sPar2.GetToken(nToken, DB_DELIM);
1536             ((SwDropDownField*)pTmpFld)->SetItems(aEntries);
1537             ((SwDropDownField*)pTmpFld)->SetName(sPar1);
1538 			bSetPar1 = bSetPar2 = sal_False;
1539 		}
1540 		break;
1541         case TYP_AUTHORITY :
1542         {
1543             //#i99069# changes to a bibliography field should change the field type
1544             SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpFld);
1545             SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
1546             SwAuthEntry aTempEntry;
1547             for( sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i )
1548                 aTempEntry.SetAuthorField( (ToxAuthorityField)i,
1549                                 rPar1.GetToken( i, TOX_STYLE_DELIMITER ));
1550             if( pAuthorityType->ChangeEntryContent( &aTempEntry ) )
1551             {
1552                 pType->UpdateFlds();
1553                 pSh->SetModified();
1554             }
1555 
1556             if( aTempEntry.GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
1557                 pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
1558                 bSetPar1 = sal_False; //otherwise it's a new or changed entry, the field needs to be updated
1559             bSetPar2 = sal_False;
1560         }
1561         break;
1562 	}
1563 
1564 	// Format setzen
1565 	// Format wegen NumberFormatter vor SetPar2 einstellen!
1566 	pTmpFld->ChangeFormat(nFormat);
1567 
1568 	if(bSetPar1)
1569 		pTmpFld->SetPar1( sPar1 );
1570 	if( bSetPar2 )
1571 		pTmpFld->SetPar2( sPar2 );
1572 
1573 	// Update anschmeissen
1574 	if(nTypeId == TYP_DDEFLD ||
1575 	   nTypeId == TYP_USERFLD ||
1576 	   nTypeId == TYP_USRINPFLD)
1577 	{
1578 		pType->UpdateFlds();
1579         pSh->SetModified();
1580 	}
1581 	else {
1582 		// mb: #32157
1583         pSh->SwEditShell::UpdateFlds(*pTmpFld);
1584 		GetCurFld();
1585 	}
1586 
1587     if (bDelete)
1588         delete pTmpFld;
1589 
1590     pSh->EndAllAction();
1591 }
1592 
1593 /*--------------------------------------------------------------------
1594 	Beschreibung: ExpressionFields explizit evaluieren
1595  --------------------------------------------------------------------*/
1596 void SwFldMgr::EvalExpFlds(SwWrtShell* pSh)
1597 {
1598 	if (pSh == NULL)
1599 		pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
1600 
1601 	if(pSh)
1602 	{
1603 		pSh->StartAllAction();
1604 		pSh->UpdateExpFlds(sal_True);
1605 		pSh->EndAllAction();
1606 	}
1607 }
1608 sal_uInt16 SwFldMgr::GetCurrLanguage() const
1609 {
1610 	SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
1611 	if( pSh )
1612 		return pSh->GetCurLang();
1613 	return SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() );
1614 }
1615 
1616 void SwFieldType::_GetFldName()
1617 {
1618 	// mba: this is an awful mess; a fix is available, but too much for 3.4 -> applay plaster
1619 	static const sal_uInt16 coFldCnt = 43;
1620 
1621 	static sal_uInt16 __READONLY_DATA coFldNms[ coFldCnt ] = {
1622 		FLD_DATE_STD,
1623 		FLD_TIME_STD,
1624 		STR_FILENAMEFLD,
1625 		STR_DBNAMEFLD,
1626 		STR_CHAPTERFLD,
1627 		STR_PAGENUMBERFLD,
1628 		STR_DOCSTATFLD,
1629 		STR_AUTHORFLD,
1630 		STR_SETFLD,
1631 		STR_GETFLD,
1632 		STR_FORMELFLD,
1633 		STR_HIDDENTXTFLD,
1634 		STR_SETREFFLD,
1635 		STR_GETREFFLD,
1636 		STR_DDEFLD,
1637 		STR_MACROFLD,
1638 		STR_INPUTFLD,
1639 		STR_HIDDENPARAFLD,
1640 		STR_DOCINFOFLD,
1641 		STR_DBFLD,
1642 		STR_USERFLD,
1643 		STR_POSTITFLD,
1644 		STR_TEMPLNAMEFLD,
1645 		STR_SEQFLD,
1646 		STR_DBNEXTSETFLD,
1647 		STR_DBNUMSETFLD,
1648 		STR_DBSETNUMBERFLD,
1649 		STR_CONDTXTFLD,
1650 		STR_NEXTPAGEFLD,
1651 		STR_PREVPAGEFLD,
1652 		STR_EXTUSERFLD,
1653 		FLD_DATE_FIX,
1654 		FLD_TIME_FIX,
1655 		STR_SETINPUTFLD,
1656 		STR_USRINPUTFLD,
1657 		STR_SETREFPAGEFLD,
1658 		STR_GETREFPAGEFLD,
1659 		STR_INTERNETFLD,
1660 		STR_JUMPEDITFLD,
1661 		STR_SCRIPTFLD,
1662 		STR_AUTHORITY,
1663         STR_COMBINED_CHARS,
1664         STR_DROPDOWN
1665 	};
1666 
1667 	// Infos fuer Felder einfuegen
1668 	SwFieldType::pFldNames = new SvStringsDtor( (sal_uInt8)coFldCnt, 2 );
1669 	for( sal_uInt16 nIdx = 0; nIdx < coFldCnt; ++nIdx )
1670 	{
1671 		String* pTmp = new SW_RESSTR( coFldNms[ nIdx ] );
1672         pTmp->Assign( MnemonicGenerator::EraseAllMnemonicChars( *pTmp ) );
1673 		SwFieldType::pFldNames->Insert(pTmp, nIdx );
1674 	}
1675 }
1676 
1677 /*--------------------------------------------------------------------
1678 	Beschreibung:
1679  --------------------------------------------------------------------*/
1680 
1681 sal_Bool SwFldMgr::ChooseMacro(const String&)
1682 {
1683     sal_Bool bRet = sal_False;
1684 
1685     // choose script dialog
1686     ::rtl::OUString aScriptURL = SfxApplication::ChooseScript();
1687 
1688     // the script selector dialog returns a valid script URL
1689     if ( aScriptURL.getLength() != 0 )
1690     {
1691         SetMacroPath( aScriptURL );
1692         bRet = sal_True;
1693     }
1694 
1695     return bRet;
1696 }
1697 
1698 void SwFldMgr::SetMacroPath(const String& rPath)
1699 {
1700     sMacroPath = rPath;
1701     sMacroName = rPath;
1702 
1703     // try to set sMacroName member variable by parsing the macro path
1704     // using the new URI parsing services
1705 
1706     Reference< XMultiServiceFactory > xSMgr =
1707         ::comphelper::getProcessServiceFactory();
1708 
1709     Reference< uri::XUriReferenceFactory >
1710         xFactory( xSMgr->createInstance(
1711             ::rtl::OUString::createFromAscii(
1712                 "com.sun.star.uri.UriReferenceFactory" ) ), UNO_QUERY );
1713 
1714     if ( xFactory.is() )
1715     {
1716         Reference< uri::XVndSunStarScriptUrl >
1717             xUrl( xFactory->parse( sMacroPath ), UNO_QUERY );
1718 
1719         if ( xUrl.is() )
1720         {
1721             sMacroName = xUrl->getName();
1722         }
1723     }
1724 }
1725 
1726 /*--------------------------------------------------------------------
1727 	Beschreibung:
1728  --------------------------------------------------------------------*/
1729 
1730 sal_uLong SwFldMgr::GetDefaultFormat(sal_uInt16 nTypeId, sal_Bool bIsText, SvNumberFormatter* pFormatter, double* pVal)
1731 {
1732 	double fValue;
1733 	short  nDefFormat;
1734 
1735 	switch (nTypeId)
1736 	{
1737 		case TYP_TIMEFLD:
1738 		case TYP_DATEFLD:
1739 		{
1740 			Date aDate;
1741 			Date* pNullDate = pFormatter->GetNullDate();
1742 
1743 			fValue = aDate - *pNullDate;
1744 
1745 			Time aTime;
1746 
1747 			sal_uLong nNumFmtTime = (sal_uLong)aTime.GetSec() + (sal_uLong)aTime.GetMin() * 60L +
1748 						  (sal_uLong)aTime.GetHour() * 3600L;
1749 
1750 			fValue += (double)nNumFmtTime / 86400.0;
1751 
1752 			nDefFormat = (nTypeId == TYP_DATEFLD) ? NUMBERFORMAT_DATE : NUMBERFORMAT_TIME;
1753 		}
1754 		break;
1755 
1756 		default:
1757 			if (bIsText)
1758 			{
1759 				fValue = 0.0;
1760 				nDefFormat = NUMBERFORMAT_TEXT;
1761 			}
1762 			else
1763 			{
1764 				fValue = 0.0;
1765 				nDefFormat = NUMBERFORMAT_ALL;
1766 			}
1767 			break;
1768 	}
1769 
1770 	if (pVal)
1771 		*pVal = fValue;
1772 
1773 	return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
1774 }
1775 
1776 /* -----------------------------01.03.01 16:46--------------------------------
1777 
1778  ---------------------------------------------------------------------------*/
1779 Reference<XNumberingTypeInfo> SwFldMgr::GetNumberingInfo() const
1780 {
1781 	if(!xNumberingInfo.is())
1782 	{
1783 		Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
1784 		Reference < XInterface > xI = xMSF->createInstance(
1785 			::rtl::OUString::createFromAscii(
1786 							"com.sun.star.text.DefaultNumberingProvider" ));
1787 		Reference<XDefaultNumberingProvider> xDefNum(xI, UNO_QUERY);
1788 		DBG_ASSERT(xDefNum.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\"");
1789 		((SwFldMgr*)this)->xNumberingInfo = Reference<XNumberingTypeInfo>(xDefNum, UNO_QUERY);
1790 	}
1791 	return xNumberingInfo;
1792 }
1793