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