xref: /aoo41x/main/sw/source/ui/fldui/fldmgr.cxx (revision dec99bbd)
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 
lcl_GetShell()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 
GetPackCount()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 
SwFldMgr(SwWrtShell * pSh)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 
~SwFldMgr()277cdf0e10cSrcweir SwFldMgr::~SwFldMgr()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir /*--------------------------------------------------------------------
282cdf0e10cSrcweir 	Beschreibung: RefMark ueber Namen organisieren
283cdf0e10cSrcweir  --------------------------------------------------------------------*/
284cdf0e10cSrcweir 
CanInsertRefMark(const String & rStr)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 
RemoveFldType(sal_uInt16 nResId,const String & rName)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 
GetFldTypeCount(sal_uInt16 nResId) const315cdf0e10cSrcweir 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 
GetFldType(sal_uInt16 nResId,sal_uInt16 nId) const323cdf0e10cSrcweir 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 
GetFldType(sal_uInt16 nResId,const String & rName) const331cdf0e10cSrcweir 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  --------------------------------------------------------------------*/
GetCurFld()342cdf0e10cSrcweir SwField* SwFldMgr::GetCurFld()
343cdf0e10cSrcweir {
344cdf0e10cSrcweir 	SwWrtShell *pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
345cdf0e10cSrcweir 	if ( pSh )
34669a74367SOliver-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 
GetGroupRange(sal_Bool bHtmlMode,sal_uInt16 nGrpId) const387cdf0e10cSrcweir 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 
GetGroup(sal_Bool bHtmlMode,sal_uInt16 nTypeId,sal_uInt16 nSubType) const418cdf0e10cSrcweir 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 
GetTypeId(sal_uInt16 nPos)450cdf0e10cSrcweir sal_uInt16 SwFldMgr::GetTypeId(sal_uInt16 nPos)
451cdf0e10cSrcweir {
452cdf0e10cSrcweir 	ASSERT(nPos < ::GetPackCount(), "unzulaessige Pos");
453cdf0e10cSrcweir 	return aSwFlds[ nPos ].nTypeId;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 
GetTypeStr(sal_uInt16 nPos)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 
GetPos(sal_uInt16 nTypeId)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 
GetSubTypes(sal_uInt16 nTypeId,SvStringsDtor & rToFill)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 
GetFormatCount(sal_uInt16 nTypeId,sal_Bool bIsText,sal_Bool bHtmlMode) const615cdf0e10cSrcweir 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 
GetFormatStr(sal_uInt16 nTypeId,sal_uLong nFormatId) const672cdf0e10cSrcweir 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 
GetFormatId(sal_uInt16 nTypeId,sal_uLong nFormatId) const722cdf0e10cSrcweir 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 
GoNextPrev(sal_Bool bNext,SwFieldType * pTyp)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)
82169a74367SOliver-Rainer Wittmann 		return pSh->MoveFldType( 0, (bNext ? true : false), RES_DBFLD );
822cdf0e10cSrcweir 	}
823cdf0e10cSrcweir 
82469a74367SOliver-Rainer Wittmann     return (pTyp && pSh)
82569a74367SOliver-Rainer Wittmann            ? pSh->MoveFldType( pTyp, (bNext ? true : false) )
82669a74367SOliver-Rainer Wittmann            : sal_False;
827cdf0e10cSrcweir }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir /*--------------------------------------------------------------------
830cdf0e10cSrcweir 	Beschreibung: Feldtypen einfuegen
831cdf0e10cSrcweir  --------------------------------------------------------------------*/
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 
InsertFldType(SwFieldType & rType)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 
GetCurTypeId() const847cdf0e10cSrcweir 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 
InsertFld(const SwInsertFld_Data & rData)8573b32dd21SOliver-Rainer Wittmann sal_Bool SwFldMgr::InsertFld(
858*dec99bbdSOliver-Rainer Wittmann     const SwInsertFld_Data& rData )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir     SwField* pFld   = 0;
8613b32dd21SOliver-Rainer Wittmann     sal_Bool bExp = sal_False;
8623b32dd21SOliver-Rainer Wittmann     sal_Bool bTbl = sal_False;
8633b32dd21SOliver-Rainer Wittmann     sal_Bool bPageVar = sal_False;
864cdf0e10cSrcweir     sal_uLong nFormatId = rData.nFormatId;
865cdf0e10cSrcweir     sal_uInt16 nSubType = rData.nSubType;
866cdf0e10cSrcweir     sal_Unicode cSeparator = rData.cSeparator;
867cdf0e10cSrcweir     SwWrtShell* pCurShell = rData.pSh;
868cdf0e10cSrcweir     if(!pCurShell)
869cdf0e10cSrcweir         pCurShell = pWrtShell ? pWrtShell : ::lcl_GetShell();
870cdf0e10cSrcweir     DBG_ASSERT(pCurShell, "no SwWrtShell found");
871cdf0e10cSrcweir     if(!pCurShell)
872cdf0e10cSrcweir         return sal_False;
873cdf0e10cSrcweir 
874cdf0e10cSrcweir     switch(rData.nTypeId)
8753b32dd21SOliver-Rainer Wittmann     {
8763b32dd21SOliver-Rainer Wittmann     case TYP_POSTITFLD:
8773b32dd21SOliver-Rainer Wittmann         {
8783b32dd21SOliver-Rainer Wittmann             SwPostItFieldType* pType = (SwPostItFieldType*)pCurShell->GetFldType(0, RES_POSTITFLD);
879*dec99bbdSOliver-Rainer Wittmann             SwPostItField* pPostItField =
880*dec99bbdSOliver-Rainer Wittmann                 new SwPostItField(
881*dec99bbdSOliver-Rainer Wittmann                     pType,
882*dec99bbdSOliver-Rainer Wittmann                     rData.sPar2, // content
883*dec99bbdSOliver-Rainer Wittmann                     rData.sPar1, // author
884*dec99bbdSOliver-Rainer Wittmann                     aEmptyStr, // author's initials
885*dec99bbdSOliver-Rainer Wittmann                     aEmptyStr, // name
886*dec99bbdSOliver-Rainer Wittmann                     DateTime() );
887*dec99bbdSOliver-Rainer Wittmann             pFld = pPostItField;
8883b32dd21SOliver-Rainer Wittmann         }
889*dec99bbdSOliver-Rainer Wittmann         break;
8903b32dd21SOliver-Rainer Wittmann 
891*dec99bbdSOliver-Rainer Wittmann     case TYP_SCRIPTFLD:
892*dec99bbdSOliver-Rainer Wittmann         {
893*dec99bbdSOliver-Rainer Wittmann             SwScriptFieldType* pType =
894cdf0e10cSrcweir                 (SwScriptFieldType*)pCurShell->GetFldType(0, RES_SCRIPTFLD);
895cdf0e10cSrcweir             pFld = new SwScriptField(pType, rData.sPar1, rData.sPar2, (sal_Bool)nFormatId);
896*dec99bbdSOliver-Rainer Wittmann             break;
897*dec99bbdSOliver-Rainer Wittmann         }
898*dec99bbdSOliver-Rainer Wittmann 
899*dec99bbdSOliver-Rainer Wittmann     case TYP_COMBINED_CHARS:
900*dec99bbdSOliver-Rainer Wittmann         {
901*dec99bbdSOliver-Rainer Wittmann             SwCombinedCharFieldType* pType = (SwCombinedCharFieldType*)
902*dec99bbdSOliver-Rainer Wittmann                 pCurShell->GetFldType( 0, RES_COMBINED_CHARS );
903cdf0e10cSrcweir             pFld = new SwCombinedCharField( pType, rData.sPar1 );
904*dec99bbdSOliver-Rainer Wittmann         }
905*dec99bbdSOliver-Rainer Wittmann         break;
906*dec99bbdSOliver-Rainer Wittmann 
907*dec99bbdSOliver-Rainer Wittmann     case TYP_AUTHORITY:
908*dec99bbdSOliver-Rainer Wittmann         {
909*dec99bbdSOliver-Rainer Wittmann             SwAuthorityFieldType* pType =
910cdf0e10cSrcweir                 (SwAuthorityFieldType*)pCurShell->GetFldType(0, RES_AUTHORITY);
911*dec99bbdSOliver-Rainer Wittmann             if(!pType)
912*dec99bbdSOliver-Rainer Wittmann             {
913*dec99bbdSOliver-Rainer Wittmann                 pType =
914cdf0e10cSrcweir                     (SwAuthorityFieldType*)pCurShell->InsertFldType(
915*dec99bbdSOliver-Rainer Wittmann                     SwAuthorityFieldType(pCurShell->GetDoc()));
916*dec99bbdSOliver-Rainer Wittmann             }
917cdf0e10cSrcweir             pFld = new SwAuthorityField(pType, rData.sPar1);
918*dec99bbdSOliver-Rainer Wittmann         }
919*dec99bbdSOliver-Rainer Wittmann         break;
920*dec99bbdSOliver-Rainer Wittmann 
921*dec99bbdSOliver-Rainer Wittmann     case TYP_DATEFLD:
922*dec99bbdSOliver-Rainer Wittmann     case TYP_TIMEFLD:
923*dec99bbdSOliver-Rainer Wittmann         {
924cdf0e10cSrcweir             sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.nTypeId == TYP_DATEFLD ? DATEFLD : TIMEFLD);
925cdf0e10cSrcweir             nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD;
926cdf0e10cSrcweir 
927*dec99bbdSOliver-Rainer Wittmann             SwDateTimeFieldType* pTyp =
928cdf0e10cSrcweir                 (SwDateTimeFieldType*)pCurShell->GetFldType(0, RES_DATETIMEFLD);
929cdf0e10cSrcweir             pFld = new SwDateTimeField(pTyp, nSub, nFormatId);
930cdf0e10cSrcweir             pFld->SetPar2(rData.sPar2);
931*dec99bbdSOliver-Rainer Wittmann             break;
932*dec99bbdSOliver-Rainer Wittmann         }
933*dec99bbdSOliver-Rainer Wittmann 
934*dec99bbdSOliver-Rainer Wittmann     case TYP_FILENAMEFLD:
935*dec99bbdSOliver-Rainer Wittmann         {
936*dec99bbdSOliver-Rainer Wittmann             SwFileNameFieldType* pTyp =
937cdf0e10cSrcweir                 (SwFileNameFieldType*)pCurShell->GetFldType(0, RES_FILENAMEFLD);
938cdf0e10cSrcweir             pFld = new SwFileNameField(pTyp, nFormatId);
939*dec99bbdSOliver-Rainer Wittmann             break;
940*dec99bbdSOliver-Rainer Wittmann         }
941*dec99bbdSOliver-Rainer Wittmann 
942*dec99bbdSOliver-Rainer Wittmann     case TYP_TEMPLNAMEFLD:
943*dec99bbdSOliver-Rainer Wittmann         {
944*dec99bbdSOliver-Rainer Wittmann             SwTemplNameFieldType* pTyp =
945cdf0e10cSrcweir                 (SwTemplNameFieldType*)pCurShell->GetFldType(0, RES_TEMPLNAMEFLD);
946cdf0e10cSrcweir             pFld = new SwTemplNameField(pTyp, nFormatId);
947*dec99bbdSOliver-Rainer Wittmann             break;
948*dec99bbdSOliver-Rainer Wittmann         }
949*dec99bbdSOliver-Rainer Wittmann 
950*dec99bbdSOliver-Rainer Wittmann     case TYP_CHAPTERFLD:
951cdf0e10cSrcweir         {
952cdf0e10cSrcweir             sal_uInt16 nByte = (sal_uInt16)rData.sPar2.ToInt32();
953*dec99bbdSOliver-Rainer Wittmann             SwChapterFieldType* pTyp =
954cdf0e10cSrcweir                 (SwChapterFieldType*)pCurShell->GetFldType(0, RES_CHAPTERFLD);
955cdf0e10cSrcweir             pFld = new SwChapterField(pTyp, nFormatId);
956*dec99bbdSOliver-Rainer Wittmann             nByte = Max(sal_uInt16(1), nByte);
957*dec99bbdSOliver-Rainer Wittmann             nByte = Min(nByte, sal_uInt16(MAXLEVEL));
958*dec99bbdSOliver-Rainer Wittmann             nByte -= 1;
959*dec99bbdSOliver-Rainer Wittmann             ((SwChapterField*)pFld)->SetLevel((sal_uInt8)nByte);
960*dec99bbdSOliver-Rainer Wittmann             break;
961*dec99bbdSOliver-Rainer Wittmann         }
962*dec99bbdSOliver-Rainer Wittmann 
963*dec99bbdSOliver-Rainer Wittmann     case TYP_NEXTPAGEFLD:
964*dec99bbdSOliver-Rainer Wittmann     case TYP_PREVPAGEFLD:
965*dec99bbdSOliver-Rainer Wittmann     case TYP_PAGENUMBERFLD:
966*dec99bbdSOliver-Rainer Wittmann         {
967cdf0e10cSrcweir             short nOff  = (short)rData.sPar2.ToInt32();
968cdf0e10cSrcweir 
969cdf0e10cSrcweir             if(rData.nTypeId == TYP_NEXTPAGEFLD)
970*dec99bbdSOliver-Rainer Wittmann             {
971cdf0e10cSrcweir                 if( SVX_NUM_CHAR_SPECIAL == nFormatId )
972*dec99bbdSOliver-Rainer Wittmann                     nOff = 1;
973*dec99bbdSOliver-Rainer Wittmann                 else
974*dec99bbdSOliver-Rainer Wittmann                     nOff += 1;
975cdf0e10cSrcweir                 nSubType = PG_NEXT;
976*dec99bbdSOliver-Rainer Wittmann             }
977cdf0e10cSrcweir             else if(rData.nTypeId == TYP_PREVPAGEFLD)
978*dec99bbdSOliver-Rainer Wittmann             {
979cdf0e10cSrcweir                 if( SVX_NUM_CHAR_SPECIAL == nFormatId )
980*dec99bbdSOliver-Rainer Wittmann                     nOff = -1;
981*dec99bbdSOliver-Rainer Wittmann                 else
982*dec99bbdSOliver-Rainer Wittmann                     nOff -= 1;
983cdf0e10cSrcweir                 nSubType =  PG_PREV;
984*dec99bbdSOliver-Rainer Wittmann             }
985*dec99bbdSOliver-Rainer Wittmann             else
986cdf0e10cSrcweir                 nSubType = PG_RANDOM;
987cdf0e10cSrcweir 
988*dec99bbdSOliver-Rainer Wittmann             SwPageNumberFieldType* pTyp =
989cdf0e10cSrcweir                 (SwPageNumberFieldType*)pCurShell->GetFldType(0, RES_PAGENUMBERFLD);
990cdf0e10cSrcweir             pFld = new SwPageNumberField(pTyp, nSubType, nFormatId, nOff);
991cdf0e10cSrcweir 
992cdf0e10cSrcweir             if( SVX_NUM_CHAR_SPECIAL == nFormatId &&
993cdf0e10cSrcweir                 ( PG_PREV == nSubType || PG_NEXT == nSubType ) )
994cdf0e10cSrcweir                 ((SwPageNumberField*)pFld)->SetUserString( rData.sPar2 );
995*dec99bbdSOliver-Rainer Wittmann             break;
996*dec99bbdSOliver-Rainer Wittmann         }
997*dec99bbdSOliver-Rainer Wittmann 
998*dec99bbdSOliver-Rainer Wittmann     case TYP_DOCSTATFLD:
999*dec99bbdSOliver-Rainer Wittmann         {
1000*dec99bbdSOliver-Rainer Wittmann             SwDocStatFieldType* pTyp =
1001cdf0e10cSrcweir                 (SwDocStatFieldType*)pCurShell->GetFldType(0, RES_DOCSTATFLD);
1002cdf0e10cSrcweir             pFld = new SwDocStatField(pTyp, nSubType, nFormatId);
1003*dec99bbdSOliver-Rainer Wittmann             break;
1004*dec99bbdSOliver-Rainer Wittmann         }
1005*dec99bbdSOliver-Rainer Wittmann 
1006*dec99bbdSOliver-Rainer Wittmann     case TYP_AUTHORFLD:
1007*dec99bbdSOliver-Rainer Wittmann         {
1008*dec99bbdSOliver-Rainer Wittmann             SwAuthorFieldType* pTyp =
1009cdf0e10cSrcweir                 (SwAuthorFieldType*)pCurShell->GetFldType(0, RES_AUTHORFLD);
1010cdf0e10cSrcweir             pFld = new SwAuthorField(pTyp, nFormatId);
1011*dec99bbdSOliver-Rainer Wittmann             break;
1012*dec99bbdSOliver-Rainer Wittmann         }
1013*dec99bbdSOliver-Rainer Wittmann 
1014*dec99bbdSOliver-Rainer Wittmann     case TYP_CONDTXTFLD:
1015*dec99bbdSOliver-Rainer Wittmann     case TYP_HIDDENTXTFLD:
1016*dec99bbdSOliver-Rainer Wittmann         {
1017*dec99bbdSOliver-Rainer Wittmann             SwHiddenTxtFieldType* pTyp =
1018cdf0e10cSrcweir                 (SwHiddenTxtFieldType*)pCurShell->GetFldType(0, RES_HIDDENTXTFLD);
1019cdf0e10cSrcweir             pFld = new SwHiddenTxtField(pTyp, sal_True, rData.sPar1, rData.sPar2, sal_False, rData.nTypeId);
1020*dec99bbdSOliver-Rainer Wittmann             bExp = sal_True;
1021*dec99bbdSOliver-Rainer Wittmann             break;
1022*dec99bbdSOliver-Rainer Wittmann         }
1023*dec99bbdSOliver-Rainer Wittmann 
1024*dec99bbdSOliver-Rainer Wittmann     case TYP_HIDDENPARAFLD:
1025*dec99bbdSOliver-Rainer Wittmann         {
1026*dec99bbdSOliver-Rainer Wittmann             SwHiddenParaFieldType* pTyp =
1027cdf0e10cSrcweir                 (SwHiddenParaFieldType*)pCurShell->GetFldType(0, RES_HIDDENPARAFLD);
1028cdf0e10cSrcweir             pFld = new SwHiddenParaField(pTyp, rData.sPar1);
1029*dec99bbdSOliver-Rainer Wittmann             bExp = sal_True;
1030*dec99bbdSOliver-Rainer Wittmann             break;
1031*dec99bbdSOliver-Rainer Wittmann         }
1032*dec99bbdSOliver-Rainer Wittmann 
1033*dec99bbdSOliver-Rainer Wittmann     case TYP_SETREFFLD:
1034*dec99bbdSOliver-Rainer Wittmann         {
1035cdf0e10cSrcweir             if( rData.sPar1.Len() > 0 && CanInsertRefMark( rData.sPar1 ) )
1036*dec99bbdSOliver-Rainer Wittmann             {
103769a74367SOliver-Rainer Wittmann                 pCurShell->SetAttrItem( SwFmtRefMark( rData.sPar1 ) );
1038*dec99bbdSOliver-Rainer Wittmann                 return sal_True;
1039*dec99bbdSOliver-Rainer Wittmann             }
1040*dec99bbdSOliver-Rainer Wittmann             return sal_False;
1041*dec99bbdSOliver-Rainer Wittmann         }
1042*dec99bbdSOliver-Rainer Wittmann 
1043*dec99bbdSOliver-Rainer Wittmann     case TYP_GETREFFLD:
1044*dec99bbdSOliver-Rainer Wittmann         {
1045*dec99bbdSOliver-Rainer Wittmann             SwGetRefFieldType* pTyp =
1046cdf0e10cSrcweir                 (SwGetRefFieldType*)pCurShell->GetFldType(0, RES_GETREFFLD);
1047cdf0e10cSrcweir             sal_uInt16 nSeqNo = (sal_uInt16)rData.sPar2.ToInt32();
1048cdf0e10cSrcweir             pFld = new SwGetRefField(pTyp, rData.sPar1, nSubType, nSeqNo, nFormatId);
1049*dec99bbdSOliver-Rainer Wittmann             bExp = sal_True;
1050*dec99bbdSOliver-Rainer Wittmann             break;
1051*dec99bbdSOliver-Rainer Wittmann         }
1052*dec99bbdSOliver-Rainer Wittmann 
1053*dec99bbdSOliver-Rainer Wittmann     case TYP_DDEFLD:
1054*dec99bbdSOliver-Rainer Wittmann         {
1055*dec99bbdSOliver-Rainer Wittmann             //JP 28.08.95: DDE-Topics/-Items koennen Blanks in ihren
1056*dec99bbdSOliver-Rainer Wittmann             //				Namen haben! Wird hier noch nicht beachtet.
1057cdf0e10cSrcweir             String sCmd( rData.sPar2 );
1058cdf0e10cSrcweir             sal_uInt16 nTmpPos = sCmd.SearchAndReplace( ' ', sfx2::cTokenSeperator );
1059cdf0e10cSrcweir             sCmd.SearchAndReplace( ' ', sfx2::cTokenSeperator, nTmpPos );
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir             SwDDEFieldType aType( rData.sPar1, sCmd, (sal_uInt16) nFormatId );
1062cdf0e10cSrcweir             SwDDEFieldType* pTyp = (SwDDEFieldType*) pCurShell->InsertFldType( aType );
1063*dec99bbdSOliver-Rainer Wittmann             pFld = new SwDDEField( pTyp );
1064*dec99bbdSOliver-Rainer Wittmann             break;
1065*dec99bbdSOliver-Rainer Wittmann         }
1066cdf0e10cSrcweir 
1067*dec99bbdSOliver-Rainer Wittmann     case TYP_MACROFLD:
1068*dec99bbdSOliver-Rainer Wittmann         {
1069*dec99bbdSOliver-Rainer Wittmann             SwMacroFieldType* pTyp =
1070*dec99bbdSOliver-Rainer Wittmann                 (SwMacroFieldType*)pCurShell->GetFldType(0, RES_MACROFLD);
1071cdf0e10cSrcweir 
1072*dec99bbdSOliver-Rainer Wittmann             pFld = new SwMacroField(pTyp, rData.sPar1, rData.sPar2);
1073*dec99bbdSOliver-Rainer Wittmann 
1074*dec99bbdSOliver-Rainer Wittmann             break;
1075*dec99bbdSOliver-Rainer Wittmann         }
1076*dec99bbdSOliver-Rainer Wittmann 
1077*dec99bbdSOliver-Rainer Wittmann     case TYP_INTERNETFLD:
1078*dec99bbdSOliver-Rainer Wittmann         {
1079cdf0e10cSrcweir             SwFmtINetFmt aFmt( rData.sPar1, sCurFrame );
1080*dec99bbdSOliver-Rainer Wittmann             if( pMacroItem )
1081*dec99bbdSOliver-Rainer Wittmann                 aFmt.SetMacroTbl( &pMacroItem->GetMacroTable() );
1082cdf0e10cSrcweir             return pCurShell->InsertURL( aFmt, rData.sPar2 );
1083*dec99bbdSOliver-Rainer Wittmann         }
1084*dec99bbdSOliver-Rainer Wittmann 
1085*dec99bbdSOliver-Rainer Wittmann     case TYP_JUMPEDITFLD:
1086*dec99bbdSOliver-Rainer Wittmann         {
1087*dec99bbdSOliver-Rainer Wittmann             SwJumpEditFieldType* pTyp =
1088cdf0e10cSrcweir                 (SwJumpEditFieldType*)pCurShell->GetFldType(0, RES_JUMPEDITFLD);
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir             pFld = new SwJumpEditField(pTyp, nFormatId, rData.sPar1, rData.sPar2 );
1091*dec99bbdSOliver-Rainer Wittmann             break;
1092*dec99bbdSOliver-Rainer Wittmann         }
1093*dec99bbdSOliver-Rainer Wittmann 
1094*dec99bbdSOliver-Rainer Wittmann     case TYP_DOCINFOFLD:
1095*dec99bbdSOliver-Rainer Wittmann         {
1096cdf0e10cSrcweir             SwDocInfoFieldType* pTyp = (SwDocInfoFieldType*)pCurShell->GetFldType(
1097*dec99bbdSOliver-Rainer Wittmann                 0, RES_DOCINFOFLD );
1098cdf0e10cSrcweir             pFld = new SwDocInfoField(pTyp, nSubType, rData.sPar1, nFormatId);
1099*dec99bbdSOliver-Rainer Wittmann             break;
1100*dec99bbdSOliver-Rainer Wittmann         }
1101*dec99bbdSOliver-Rainer Wittmann 
1102*dec99bbdSOliver-Rainer Wittmann     case TYP_EXTUSERFLD:
1103*dec99bbdSOliver-Rainer Wittmann         {
1104cdf0e10cSrcweir             SwExtUserFieldType* pTyp = (SwExtUserFieldType*)pCurShell->GetFldType(
1105*dec99bbdSOliver-Rainer Wittmann                 0, RES_EXTUSERFLD);
1106cdf0e10cSrcweir             pFld = new SwExtUserField(pTyp, nSubType, nFormatId);
1107*dec99bbdSOliver-Rainer Wittmann             break;
1108*dec99bbdSOliver-Rainer Wittmann         }
1109*dec99bbdSOliver-Rainer Wittmann 
1110*dec99bbdSOliver-Rainer Wittmann     case TYP_DBFLD:
1111*dec99bbdSOliver-Rainer Wittmann         {
1112*dec99bbdSOliver-Rainer Wittmann             SwDBData aDBData;
1113*dec99bbdSOliver-Rainer Wittmann             String sPar1;
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir             if (rData.sPar1.Search(DB_DELIM) == STRING_NOTFOUND)
1116*dec99bbdSOliver-Rainer Wittmann             {
1117cdf0e10cSrcweir                 aDBData = pCurShell->GetDBData();
1118cdf0e10cSrcweir                 sPar1 = rData.sPar1;
1119*dec99bbdSOliver-Rainer Wittmann             }
1120*dec99bbdSOliver-Rainer Wittmann             else
1121*dec99bbdSOliver-Rainer Wittmann             {
1122cdf0e10cSrcweir                 aDBData.sDataSource = rData.sPar1.GetToken(0, DB_DELIM);
1123cdf0e10cSrcweir                 aDBData.sCommand = rData.sPar1.GetToken(1, DB_DELIM);
1124cdf0e10cSrcweir                 aDBData.nCommandType = rData.sPar1.GetToken(2, DB_DELIM).ToInt32();
1125cdf0e10cSrcweir                 sPar1 = rData.sPar1.GetToken(3, DB_DELIM);
1126*dec99bbdSOliver-Rainer Wittmann             }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir             if(aDBData.sDataSource.getLength() && pCurShell->GetDBData() != aDBData)
1129cdf0e10cSrcweir                 pCurShell->ChgDBData(aDBData);
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir             SwDBFieldType* pTyp = (SwDBFieldType*)pCurShell->InsertFldType(
1132*dec99bbdSOliver-Rainer Wittmann                 SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) );
1133*dec99bbdSOliver-Rainer Wittmann             pFld = new SwDBField(pTyp);
1134cdf0e10cSrcweir             pFld->SetSubType(nSubType);
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir             if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // Datenbankformat ermitteln
1137*dec99bbdSOliver-Rainer Wittmann             {
1138cdf0e10cSrcweir                 Reference< XDataSource> xSource;
1139cdf0e10cSrcweir                 rData.aDBDataSource >>= xSource;
1140cdf0e10cSrcweir                 Reference<XConnection> xConnection;
1141cdf0e10cSrcweir                 rData.aDBConnection >>= xConnection;
1142cdf0e10cSrcweir                 Reference<XPropertySet> xColumn;
1143cdf0e10cSrcweir                 rData.aDBColumn >>= xColumn;
1144cdf0e10cSrcweir                 if(xColumn.is())
1145cdf0e10cSrcweir                 {
1146cdf0e10cSrcweir                     nFormatId = pCurShell->GetNewDBMgr()->GetColumnFmt(xSource, xConnection, xColumn,
1147*dec99bbdSOliver-Rainer Wittmann                         pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1148cdf0e10cSrcweir                 }
1149cdf0e10cSrcweir                 else
1150cdf0e10cSrcweir                     nFormatId = pCurShell->GetNewDBMgr()->GetColumnFmt(
1151*dec99bbdSOliver-Rainer Wittmann                     aDBData.sDataSource, aDBData.sCommand, sPar1,
1152*dec99bbdSOliver-Rainer Wittmann                     pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1153*dec99bbdSOliver-Rainer Wittmann             }
1154cdf0e10cSrcweir             pFld->ChangeFormat( nFormatId );
1155cdf0e10cSrcweir 
1156*dec99bbdSOliver-Rainer Wittmann             bExp = sal_True;
1157*dec99bbdSOliver-Rainer Wittmann             break;
1158*dec99bbdSOliver-Rainer Wittmann         }
1159*dec99bbdSOliver-Rainer Wittmann 
1160*dec99bbdSOliver-Rainer Wittmann     case TYP_DBSETNUMBERFLD:
1161*dec99bbdSOliver-Rainer Wittmann     case TYP_DBNUMSETFLD:
1162*dec99bbdSOliver-Rainer Wittmann     case TYP_DBNEXTSETFLD:
1163*dec99bbdSOliver-Rainer Wittmann     case TYP_DBNAMEFLD:
1164*dec99bbdSOliver-Rainer Wittmann         {
1165*dec99bbdSOliver-Rainer Wittmann             sal_uInt16 nPos, nTablePos, nCmdTypePos, nExpPos;
1166*dec99bbdSOliver-Rainer Wittmann             String sPar1;
1167*dec99bbdSOliver-Rainer Wittmann             SwDBData aDBData;
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir             // DBName aus rData.sPar1 extrahieren. Format: DBName.TableName.CommandType.ExpStrg
1170cdf0e10cSrcweir             if ((nTablePos = rData.sPar1.Search(DB_DELIM)) != STRING_NOTFOUND)
1171cdf0e10cSrcweir                 aDBData.sDataSource = rData.sPar1.Copy(0, nTablePos++);
1172cdf0e10cSrcweir             if ((nCmdTypePos = rData.sPar1.Search(DB_DELIM, nTablePos)) != STRING_NOTFOUND)
1173*dec99bbdSOliver-Rainer Wittmann             {
1174cdf0e10cSrcweir                 aDBData.sCommand = rData.sPar1.Copy(nTablePos, nCmdTypePos++ - nTablePos);
1175*dec99bbdSOliver-Rainer Wittmann             }
1176cdf0e10cSrcweir             if ((nExpPos = rData.sPar1.Search(DB_DELIM, nCmdTypePos)) != STRING_NOTFOUND)
1177*dec99bbdSOliver-Rainer Wittmann             {
1178cdf0e10cSrcweir                 aDBData.nCommandType = rData.sPar1.Copy(nCmdTypePos, nExpPos++ - nCmdTypePos).ToInt32();
1179*dec99bbdSOliver-Rainer Wittmann             }
1180*dec99bbdSOliver-Rainer Wittmann             if (nExpPos != STRING_NOTFOUND)
1181*dec99bbdSOliver-Rainer Wittmann                 nPos = nExpPos;
1182*dec99bbdSOliver-Rainer Wittmann             else if (nTablePos != STRING_NOTFOUND)
1183*dec99bbdSOliver-Rainer Wittmann                 nPos = nTablePos;
1184*dec99bbdSOliver-Rainer Wittmann             else
1185*dec99bbdSOliver-Rainer Wittmann                 nPos = 0;
1186cdf0e10cSrcweir             sPar1 = rData.sPar1.Copy(nPos);
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir             if (aDBData.sDataSource.getLength() && pCurShell->GetDBData() != aDBData)
1189cdf0e10cSrcweir                 pCurShell->ChgDBData(aDBData);
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir             switch(rData.nTypeId)
1192*dec99bbdSOliver-Rainer Wittmann             {
1193*dec99bbdSOliver-Rainer Wittmann             case TYP_DBNAMEFLD:
1194*dec99bbdSOliver-Rainer Wittmann                 {
1195*dec99bbdSOliver-Rainer Wittmann                     SwDBNameFieldType* pTyp =
1196cdf0e10cSrcweir                         (SwDBNameFieldType*)pCurShell->GetFldType(0, RES_DBNAMEFLD);
1197*dec99bbdSOliver-Rainer Wittmann                     pFld = new SwDBNameField(pTyp, aDBData);
1198cdf0e10cSrcweir 
1199*dec99bbdSOliver-Rainer Wittmann                     break;
1200*dec99bbdSOliver-Rainer Wittmann                 }
1201*dec99bbdSOliver-Rainer Wittmann             case TYP_DBNEXTSETFLD:
1202*dec99bbdSOliver-Rainer Wittmann                 {
1203cdf0e10cSrcweir                     SwDBNextSetFieldType* pTyp = (SwDBNextSetFieldType*)pCurShell->GetFldType(
1204*dec99bbdSOliver-Rainer Wittmann                         0, RES_DBNEXTSETFLD);
1205cdf0e10cSrcweir                     pFld = new SwDBNextSetField(pTyp, sPar1, rData.sPar2, aDBData);
1206*dec99bbdSOliver-Rainer Wittmann                     bExp = sal_True;
1207*dec99bbdSOliver-Rainer Wittmann                     break;
1208*dec99bbdSOliver-Rainer Wittmann                 }
1209*dec99bbdSOliver-Rainer Wittmann             case TYP_DBNUMSETFLD:
1210*dec99bbdSOliver-Rainer Wittmann                 {
1211cdf0e10cSrcweir                     SwDBNumSetFieldType* pTyp = (SwDBNumSetFieldType*)pCurShell->GetFldType(
1212*dec99bbdSOliver-Rainer Wittmann                         0, RES_DBNUMSETFLD);
1213cdf0e10cSrcweir                     pFld = new SwDBNumSetField( pTyp, sPar1, rData.sPar2, aDBData);
1214*dec99bbdSOliver-Rainer Wittmann                     bExp = sal_True;
1215*dec99bbdSOliver-Rainer Wittmann                     break;
1216*dec99bbdSOliver-Rainer Wittmann                 }
1217*dec99bbdSOliver-Rainer Wittmann             case TYP_DBSETNUMBERFLD:
1218*dec99bbdSOliver-Rainer Wittmann                 {
1219*dec99bbdSOliver-Rainer Wittmann                     SwDBSetNumberFieldType* pTyp = (SwDBSetNumberFieldType*)
1220*dec99bbdSOliver-Rainer Wittmann                         pCurShell->GetFldType(0, RES_DBSETNUMBERFLD);
1221cdf0e10cSrcweir                     pFld = new SwDBSetNumberField( pTyp, aDBData, nFormatId);
1222*dec99bbdSOliver-Rainer Wittmann                     bExp = sal_True;
1223*dec99bbdSOliver-Rainer Wittmann                     break;
1224*dec99bbdSOliver-Rainer Wittmann                 }
1225*dec99bbdSOliver-Rainer Wittmann             }
1226*dec99bbdSOliver-Rainer Wittmann             break;
1227*dec99bbdSOliver-Rainer Wittmann         }
1228*dec99bbdSOliver-Rainer Wittmann 
1229*dec99bbdSOliver-Rainer Wittmann     case TYP_USERFLD:
1230*dec99bbdSOliver-Rainer Wittmann         {
1231*dec99bbdSOliver-Rainer Wittmann             SwUserFieldType* pTyp =
1232cdf0e10cSrcweir                 (SwUserFieldType*)pCurShell->GetFldType(RES_USERFLD, rData.sPar1);
1233cdf0e10cSrcweir 
1234*dec99bbdSOliver-Rainer Wittmann             // nur wenn vorhanden
1235*dec99bbdSOliver-Rainer Wittmann             if(!pTyp)
1236*dec99bbdSOliver-Rainer Wittmann             {
1237cdf0e10cSrcweir                 pTyp = (SwUserFieldType*)pCurShell->InsertFldType(
1238*dec99bbdSOliver-Rainer Wittmann                     SwUserFieldType(pCurShell->GetDoc(), rData.sPar1));
1239*dec99bbdSOliver-Rainer Wittmann             }
1240cdf0e10cSrcweir             if (pTyp->GetContent(nFormatId) != rData.sPar2)
1241cdf0e10cSrcweir                 pTyp->SetContent(rData.sPar2, nFormatId);
1242cdf0e10cSrcweir             pFld = new SwUserField(pTyp, 0, nFormatId);
1243cdf0e10cSrcweir             if (pFld->GetSubType() != nSubType)
1244cdf0e10cSrcweir                 pFld->SetSubType(nSubType);
1245*dec99bbdSOliver-Rainer Wittmann             bTbl = sal_True;
1246*dec99bbdSOliver-Rainer Wittmann             break;
1247*dec99bbdSOliver-Rainer Wittmann         }
1248*dec99bbdSOliver-Rainer Wittmann 
1249*dec99bbdSOliver-Rainer Wittmann     case TYP_INPUTFLD:
1250*dec99bbdSOliver-Rainer Wittmann         {
1251cdf0e10cSrcweir             if ((nSubType & 0x00ff) == INP_VAR)
1252*dec99bbdSOliver-Rainer Wittmann             {
1253*dec99bbdSOliver-Rainer Wittmann                 SwSetExpFieldType* pTyp = (SwSetExpFieldType*)
1254*dec99bbdSOliver-Rainer Wittmann                     pCurShell->GetFldType(RES_SETEXPFLD, rData.sPar1);
1255cdf0e10cSrcweir 
1256*dec99bbdSOliver-Rainer Wittmann                 // kein Experssion Type mit dem Namen vorhanden -> anlegen
1257*dec99bbdSOliver-Rainer Wittmann                 if(pTyp)
1258*dec99bbdSOliver-Rainer Wittmann                 {
1259*dec99bbdSOliver-Rainer Wittmann                     SwSetExpField* pExpFld =
1260cdf0e10cSrcweir                         new SwSetExpField(pTyp, aEmptyStr, nFormatId);
1261cdf0e10cSrcweir 
1262*dec99bbdSOliver-Rainer Wittmann                     // Typ vom SwSetExpFieldType nicht veraendern:
1263*dec99bbdSOliver-Rainer Wittmann                     sal_uInt16 nOldSubType = pExpFld->GetSubType();
1264cdf0e10cSrcweir                     pExpFld->SetSubType(nOldSubType | (nSubType & 0xff00));
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir                     pExpFld->SetPromptText(rData.sPar2);
1267*dec99bbdSOliver-Rainer Wittmann                     pExpFld->SetInputFlag(sal_True) ;
1268*dec99bbdSOliver-Rainer Wittmann                     bExp = sal_True;
1269*dec99bbdSOliver-Rainer Wittmann                     pFld = pExpFld;
1270*dec99bbdSOliver-Rainer Wittmann                 }
1271*dec99bbdSOliver-Rainer Wittmann                 else
1272*dec99bbdSOliver-Rainer Wittmann                     return sal_False;
1273*dec99bbdSOliver-Rainer Wittmann             }
1274*dec99bbdSOliver-Rainer Wittmann             else
1275*dec99bbdSOliver-Rainer Wittmann             {
127669a74367SOliver-Rainer Wittmann                 SwInputFieldType* pTyp =
1277cdf0e10cSrcweir                     (SwInputFieldType*)pCurShell->GetFldType(0, RES_INPUTFLD);
1278cdf0e10cSrcweir 
127969a74367SOliver-Rainer Wittmann                 SwInputField* pInpFld =
128069a74367SOliver-Rainer Wittmann                     new SwInputField( pTyp, rData.sPar1, rData.sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId);
128169a74367SOliver-Rainer Wittmann                 pFld = pInpFld;
128269a74367SOliver-Rainer Wittmann             }
1283cdf0e10cSrcweir 
1284*dec99bbdSOliver-Rainer Wittmann             // Dialog starten
1285*dec99bbdSOliver-Rainer Wittmann             //
1286cdf0e10cSrcweir             pCurShell->StartInputFldDlg(pFld, sal_False, rData.pParent);
1287*dec99bbdSOliver-Rainer Wittmann             break;
1288*dec99bbdSOliver-Rainer Wittmann         }
1289*dec99bbdSOliver-Rainer Wittmann 
1290*dec99bbdSOliver-Rainer Wittmann     case TYP_SETFLD:
1291*dec99bbdSOliver-Rainer Wittmann         {
1292cdf0e10cSrcweir             if (!rData.sPar2.Len())   // Leere Variablen sind nicht erlaubt
1293*dec99bbdSOliver-Rainer Wittmann                 return sal_False;
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir             SwSetExpFieldType* pTyp = (SwSetExpFieldType*)pCurShell->InsertFldType(
1296*dec99bbdSOliver-Rainer Wittmann                 SwSetExpFieldType(pCurShell->GetDoc(), rData.sPar1) );
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir             SwSetExpField* pExpFld = new SwSetExpField( pTyp, rData.sPar2, nFormatId);
1299cdf0e10cSrcweir             pExpFld->SetSubType(nSubType);
1300cdf0e10cSrcweir             pExpFld->SetPar2(rData.sPar2);
1301*dec99bbdSOliver-Rainer Wittmann             bExp = sal_True;
1302*dec99bbdSOliver-Rainer Wittmann             pFld = pExpFld;
1303*dec99bbdSOliver-Rainer Wittmann             break;
1304*dec99bbdSOliver-Rainer Wittmann         }
1305*dec99bbdSOliver-Rainer Wittmann 
1306*dec99bbdSOliver-Rainer Wittmann     case TYP_SEQFLD:
1307*dec99bbdSOliver-Rainer Wittmann         {
1308cdf0e10cSrcweir             SwSetExpFieldType* pTyp = (SwSetExpFieldType*)pCurShell->InsertFldType(
1309*dec99bbdSOliver-Rainer Wittmann                 SwSetExpFieldType(pCurShell->GetDoc(), rData.sPar1, nsSwGetSetExpType::GSE_SEQ));
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir             sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff);
1312cdf0e10cSrcweir 
1313*dec99bbdSOliver-Rainer Wittmann             pTyp->SetOutlineLvl(nLevel);
1314cdf0e10cSrcweir             if (nLevel != 0x7f && cSeparator == 0)
1315cdf0e10cSrcweir                 cSeparator = '.';
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir             pTyp->SetDelimiter(cSeparator);
1318cdf0e10cSrcweir             SwSetExpField* pExpFld = new SwSetExpField(pTyp, rData.sPar2, nFormatId);
1319*dec99bbdSOliver-Rainer Wittmann             bExp = sal_True;
1320*dec99bbdSOliver-Rainer Wittmann             pFld = pExpFld;
1321cdf0e10cSrcweir             nSubType = nsSwGetSetExpType::GSE_SEQ;
1322*dec99bbdSOliver-Rainer Wittmann             break;
1323*dec99bbdSOliver-Rainer Wittmann         }
1324cdf0e10cSrcweir 
1325*dec99bbdSOliver-Rainer Wittmann     case TYP_GETFLD:
1326*dec99bbdSOliver-Rainer Wittmann         {
1327*dec99bbdSOliver-Rainer Wittmann             // gibt es ein entprechendes SetField
1328*dec99bbdSOliver-Rainer Wittmann             SwSetExpFieldType* pSetTyp = (SwSetExpFieldType*)
1329*dec99bbdSOliver-Rainer Wittmann                 pCurShell->GetFldType(RES_SETEXPFLD, rData.sPar1);
1330*dec99bbdSOliver-Rainer Wittmann 
1331*dec99bbdSOliver-Rainer Wittmann             if(pSetTyp)
1332*dec99bbdSOliver-Rainer Wittmann             {
1333cdf0e10cSrcweir                 SwGetExpFieldType* pTyp = (SwGetExpFieldType*)pCurShell->GetFldType(
1334*dec99bbdSOliver-Rainer Wittmann                     0, RES_GETEXPFLD);
1335cdf0e10cSrcweir                 pFld = new SwGetExpField(pTyp, rData.sPar1, pSetTyp->GetType(), nFormatId);
1336cdf0e10cSrcweir                 pFld->SetSubType(nSubType | pSetTyp->GetType());
1337*dec99bbdSOliver-Rainer Wittmann                 bExp = sal_True;
1338*dec99bbdSOliver-Rainer Wittmann             }
1339*dec99bbdSOliver-Rainer Wittmann             else
1340*dec99bbdSOliver-Rainer Wittmann                 return sal_False;
1341*dec99bbdSOliver-Rainer Wittmann             break;
1342*dec99bbdSOliver-Rainer Wittmann         }
1343*dec99bbdSOliver-Rainer Wittmann 
1344*dec99bbdSOliver-Rainer Wittmann     case TYP_FORMELFLD:
1345*dec99bbdSOliver-Rainer Wittmann         {
1346cdf0e10cSrcweir             if(pCurShell->GetFrmType(0,sal_False) & FRMTYPE_TABLE)
1347*dec99bbdSOliver-Rainer Wittmann             {
1348cdf0e10cSrcweir                 pCurShell->StartAllAction();
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir                 SvNumberFormatter* pFormatter = pCurShell->GetDoc()->GetNumberFormatter();
1351cdf0e10cSrcweir                 const SvNumberformat* pEntry = pFormatter->GetEntry(nFormatId);
1352cdf0e10cSrcweir 
1353*dec99bbdSOliver-Rainer Wittmann                 if (pEntry)
1354*dec99bbdSOliver-Rainer Wittmann                 {
1355*dec99bbdSOliver-Rainer Wittmann                     SfxStringItem aFormat(FN_NUMBER_FORMAT, pEntry->GetFormatstring());
1356cdf0e10cSrcweir                     pCurShell->GetView().GetViewFrame()->GetDispatcher()->
1357*dec99bbdSOliver-Rainer Wittmann                         Execute(FN_NUMBER_FORMAT, SFX_CALLMODE_SYNCHRON, &aFormat, 0L);
1358*dec99bbdSOliver-Rainer Wittmann                 }
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir                 SfxItemSet aBoxSet( pCurShell->GetAttrPool(),
1361*dec99bbdSOliver-Rainer Wittmann                     RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir                 String sFml( rData.sPar2 );
1364*dec99bbdSOliver-Rainer Wittmann                 if( sFml.EraseLeadingChars().Len() &&
1365*dec99bbdSOliver-Rainer Wittmann                     '=' == sFml.GetChar( 0 ) )
1366*dec99bbdSOliver-Rainer Wittmann                     sFml.Erase( 0, 1 );
1367cdf0e10cSrcweir 
1368*dec99bbdSOliver-Rainer Wittmann                 aBoxSet.Put( SwTblBoxFormula( sFml ));
1369cdf0e10cSrcweir                 pCurShell->SetTblBoxFormulaAttrs( aBoxSet );
1370cdf0e10cSrcweir                 pCurShell->UpdateTable();
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir                 pCurShell->EndAllAction();
1373*dec99bbdSOliver-Rainer Wittmann                 return sal_True;
1374cdf0e10cSrcweir 
1375*dec99bbdSOliver-Rainer Wittmann                 /*				// In der Tabelle Tabellenformeln einfuegen
1376cdf0e10cSrcweir                 SwTblFieldType* pTyp = (SwTblFieldType*)pCurShell->GetFldType(
1377*dec99bbdSOliver-Rainer Wittmann                 0, RES_TABLEFLD);
1378cdf0e10cSrcweir                 pFld = new SwTblField(pTyp, rData.sPar2, nsSwGetSetExpType::GSE_EXPR, nFormatId);
1379*dec99bbdSOliver-Rainer Wittmann                 bTbl = sal_True;*/
1380*dec99bbdSOliver-Rainer Wittmann             }
1381*dec99bbdSOliver-Rainer Wittmann             else
1382*dec99bbdSOliver-Rainer Wittmann             {
1383*dec99bbdSOliver-Rainer Wittmann                 SwGetExpFieldType* pTyp = (SwGetExpFieldType*)
1384*dec99bbdSOliver-Rainer Wittmann                     pCurShell->GetFldType(0, RES_GETEXPFLD);
1385cdf0e10cSrcweir                 pFld = new SwGetExpField(pTyp, rData.sPar2, nsSwGetSetExpType::GSE_FORMULA, nFormatId);
1386cdf0e10cSrcweir                 pFld->SetSubType(nSubType);
1387*dec99bbdSOliver-Rainer Wittmann                 bExp = sal_True;
1388*dec99bbdSOliver-Rainer Wittmann             }
1389*dec99bbdSOliver-Rainer Wittmann             break;
1390*dec99bbdSOliver-Rainer Wittmann         }
1391cdf0e10cSrcweir 
1392*dec99bbdSOliver-Rainer Wittmann     case TYP_SETREFPAGEFLD:
1393*dec99bbdSOliver-Rainer Wittmann         pFld = new SwRefPageSetField( (SwRefPageSetFieldType*)
1394*dec99bbdSOliver-Rainer Wittmann             pCurShell->GetFldType( 0, RES_REFPAGESETFLD ),
1395*dec99bbdSOliver-Rainer Wittmann             (short)rData.sPar2.ToInt32(), 0 != nSubType  );
1396*dec99bbdSOliver-Rainer Wittmann         bPageVar = sal_True;
1397*dec99bbdSOliver-Rainer Wittmann         break;
1398*dec99bbdSOliver-Rainer Wittmann 
1399*dec99bbdSOliver-Rainer Wittmann     case TYP_GETREFPAGEFLD:
1400*dec99bbdSOliver-Rainer Wittmann         pFld = new SwRefPageGetField( (SwRefPageGetFieldType*)
1401*dec99bbdSOliver-Rainer Wittmann             pCurShell->GetFldType( 0, RES_REFPAGEGETFLD ), nFormatId );
1402*dec99bbdSOliver-Rainer Wittmann         bPageVar = sal_True;
1403*dec99bbdSOliver-Rainer Wittmann         break;
1404*dec99bbdSOliver-Rainer Wittmann 
1405*dec99bbdSOliver-Rainer Wittmann     case TYP_DROPDOWN :
1406cdf0e10cSrcweir         {
1407cdf0e10cSrcweir             pFld = new SwDropDownField(pCurShell->GetFldType( 0, RES_DROPDOWN ));
1408cdf0e10cSrcweir             xub_StrLen nTokenCount = rData.sPar2.Len() ? rData.sPar2.GetTokenCount(DB_DELIM) : 0;
1409cdf0e10cSrcweir             Sequence<OUString> aEntries(nTokenCount);
1410cdf0e10cSrcweir             OUString* pArray = aEntries.getArray();
1411cdf0e10cSrcweir             for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++)
1412cdf0e10cSrcweir                 pArray[nToken] = rData.sPar2.GetToken(nToken, DB_DELIM);
1413cdf0e10cSrcweir             ((SwDropDownField*)pFld)->SetItems(aEntries);
1414cdf0e10cSrcweir             ((SwDropDownField*)pFld)->SetName(rData.sPar1);
1415cdf0e10cSrcweir         }
1416cdf0e10cSrcweir         break;
1417cdf0e10cSrcweir 
1418*dec99bbdSOliver-Rainer Wittmann     default:
1419*dec99bbdSOliver-Rainer Wittmann         {
1420*dec99bbdSOliver-Rainer Wittmann             ASSERT(!this, "Falscher Feldtyp");
1421*dec99bbdSOliver-Rainer Wittmann             return sal_False;
1422*dec99bbdSOliver-Rainer Wittmann         }
1423*dec99bbdSOliver-Rainer Wittmann     }
1424*dec99bbdSOliver-Rainer Wittmann     ASSERT(pFld, "Feld nicht vorhanden");
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 
1427*dec99bbdSOliver-Rainer Wittmann     //the auto language flag has to be set prior to the language!
1428*dec99bbdSOliver-Rainer Wittmann     pFld->SetAutomaticLanguage(rData.bIsAutomaticLanguage);
1429*dec99bbdSOliver-Rainer Wittmann     sal_uInt16 nLang = GetCurrLanguage();
1430*dec99bbdSOliver-Rainer Wittmann     pFld->SetLanguage(nLang);
1431cdf0e10cSrcweir 
1432*dec99bbdSOliver-Rainer Wittmann     // Einfuegen
1433*dec99bbdSOliver-Rainer Wittmann     pCurShell->StartAllAction();
14343b32dd21SOliver-Rainer Wittmann 
1435*dec99bbdSOliver-Rainer Wittmann     pCurShell->Insert( *pFld );
1436cdf0e10cSrcweir 
1437*dec99bbdSOliver-Rainer Wittmann     if(bExp && bEvalExp)
1438cdf0e10cSrcweir         pCurShell->UpdateExpFlds(sal_True);
1439cdf0e10cSrcweir 
1440*dec99bbdSOliver-Rainer Wittmann     if(bTbl)
1441*dec99bbdSOliver-Rainer Wittmann     {
1442cdf0e10cSrcweir         pCurShell->Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
1443cdf0e10cSrcweir         pCurShell->UpdateFlds(*pFld);
1444cdf0e10cSrcweir         pCurShell->Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
1445*dec99bbdSOliver-Rainer Wittmann     }
1446*dec99bbdSOliver-Rainer Wittmann     else if( bPageVar )
1447cdf0e10cSrcweir         ((SwRefPageGetFieldType*)pCurShell->GetFldType( 0, RES_REFPAGEGETFLD ))->UpdateFlds();
1448cdf0e10cSrcweir     else if( TYP_GETREFFLD == rData.nTypeId )
1449*dec99bbdSOliver-Rainer Wittmann         pFld->GetTyp()->ModifyNotification( 0, 0 );
1450cdf0e10cSrcweir 
1451*dec99bbdSOliver-Rainer Wittmann     // temporaeres Feld loeschen
1452*dec99bbdSOliver-Rainer Wittmann     delete pFld;
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir     pCurShell->EndAllAction();
1455*dec99bbdSOliver-Rainer Wittmann     return sal_True;
1456cdf0e10cSrcweir }
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir /*--------------------------------------------------------------------
1459cdf0e10cSrcweir 	Beschreibung: Felder Update
1460cdf0e10cSrcweir  --------------------------------------------------------------------*/
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir 
UpdateCurFld(sal_uLong nFormat,const String & rPar1,const String & rPar2,SwField * _pTmpFld)1463cdf0e10cSrcweir void SwFldMgr::UpdateCurFld(sal_uLong nFormat,
1464cdf0e10cSrcweir 							const String& rPar1,
1465cdf0e10cSrcweir 							const String& rPar2,
1466cdf0e10cSrcweir                             SwField * _pTmpFld) // #111840#
1467cdf0e10cSrcweir {
1468cdf0e10cSrcweir 	// Format aendern
1469cdf0e10cSrcweir 	ASSERT(pCurFld, "kein Feld an der CursorPos");
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir     bool bDelete = false;
1472cdf0e10cSrcweir     SwField *pTmpFld;		// mb: fixed memory leak
1473cdf0e10cSrcweir     if (NULL != _pTmpFld)
1474cdf0e10cSrcweir     {
1475cdf0e10cSrcweir         pTmpFld = _pTmpFld;
1476cdf0e10cSrcweir     }
1477cdf0e10cSrcweir     else
1478cdf0e10cSrcweir     {
1479cdf0e10cSrcweir         pTmpFld = pCurFld->CopyField();
1480cdf0e10cSrcweir         bDelete = true;
1481cdf0e10cSrcweir     }
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir 	SwFieldType* pType   = pTmpFld->GetTyp();
1484cdf0e10cSrcweir 	const sal_uInt16 nTypeId = pTmpFld->GetTypeId();
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir     SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
1487cdf0e10cSrcweir     DBG_ASSERT(pSh, "no SwWrtShell found");
1488cdf0e10cSrcweir     if(!pSh)
1489cdf0e10cSrcweir         return;
1490cdf0e10cSrcweir     pSh->StartAllAction();
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 	sal_Bool bSetPar2 = sal_True;
1493cdf0e10cSrcweir 	sal_Bool bSetPar1 = sal_True;
1494cdf0e10cSrcweir 	String sPar1( rPar1 );
1495cdf0e10cSrcweir 	String sPar2( rPar2 );
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir 	// Order to Format
1498cdf0e10cSrcweir 	switch( nTypeId )
1499cdf0e10cSrcweir 	{
1500cdf0e10cSrcweir 		case TYP_DDEFLD:
1501cdf0e10cSrcweir 		{
1502cdf0e10cSrcweir 			//JP 28.08.95: DDE-Topics/-Items koennen Blanks in ihren
1503cdf0e10cSrcweir 			//				Namen haben! Wird hier noch nicht beachtet.
1504cdf0e10cSrcweir             sal_uInt16 nTmpPos = sPar2.SearchAndReplace( ' ', sfx2::cTokenSeperator );
1505cdf0e10cSrcweir             sPar2.SearchAndReplace( ' ', sfx2::cTokenSeperator, nTmpPos );
1506cdf0e10cSrcweir 			break;
1507cdf0e10cSrcweir 		}
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir 		case TYP_CHAPTERFLD:
1510cdf0e10cSrcweir 		{
1511cdf0e10cSrcweir             sal_uInt16 nByte = (sal_uInt16)rPar2.ToInt32();
1512cdf0e10cSrcweir 			nByte = Max(sal_uInt16(1), nByte);
1513cdf0e10cSrcweir 			nByte = Min(nByte, sal_uInt16(MAXLEVEL));
1514cdf0e10cSrcweir 			nByte -= 1;
1515cdf0e10cSrcweir 			((SwChapterField*)pTmpFld)->SetLevel((sal_uInt8)nByte);
1516cdf0e10cSrcweir 			bSetPar2 = sal_False;
1517cdf0e10cSrcweir 			break;
1518cdf0e10cSrcweir 		}
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 		case TYP_SCRIPTFLD:
1521cdf0e10cSrcweir 			((SwScriptField*)pTmpFld)->SetCodeURL((sal_Bool)nFormat);
1522cdf0e10cSrcweir 			break;
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir 		case TYP_NEXTPAGEFLD:
1525cdf0e10cSrcweir 			if( SVX_NUM_CHAR_SPECIAL == nFormat )
1526cdf0e10cSrcweir 			{
1527cdf0e10cSrcweir 				((SwPageNumberField*)pCurFld)->SetUserString( sPar2 );
1528cdf0e10cSrcweir 				sPar2 = '1';
1529cdf0e10cSrcweir 			}
1530cdf0e10cSrcweir 			else
1531cdf0e10cSrcweir 			{
1532cdf0e10cSrcweir 				if( nFormat + 2 == SVX_NUM_PAGEDESC )
1533cdf0e10cSrcweir 					nFormat = SVX_NUM_PAGEDESC;
1534cdf0e10cSrcweir                 short nOff = (short)sPar2.ToInt32();
1535cdf0e10cSrcweir 				nOff += 1;
1536cdf0e10cSrcweir 				sPar2 = String::CreateFromInt32(nOff);
1537cdf0e10cSrcweir 			}
1538cdf0e10cSrcweir 			break;
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir 		case TYP_PREVPAGEFLD:
1541cdf0e10cSrcweir 			if( SVX_NUM_CHAR_SPECIAL == nFormat )
1542cdf0e10cSrcweir 			{
1543cdf0e10cSrcweir 				((SwPageNumberField*)pCurFld)->SetUserString( sPar2 );
1544cdf0e10cSrcweir 				sPar2 = String::CreateFromAscii(
1545cdf0e10cSrcweir                     RTL_CONSTASCII_STRINGPARAM("-1"));
1546cdf0e10cSrcweir 			}
1547cdf0e10cSrcweir 			else
1548cdf0e10cSrcweir 			{
1549cdf0e10cSrcweir 				if( nFormat + 2 == SVX_NUM_PAGEDESC )
1550cdf0e10cSrcweir 					nFormat = SVX_NUM_PAGEDESC;
1551cdf0e10cSrcweir                 short nOff = (short)sPar2.ToInt32();
1552cdf0e10cSrcweir 				nOff -= 1;
1553cdf0e10cSrcweir 				sPar2 = String::CreateFromInt32(nOff);
1554cdf0e10cSrcweir 			}
1555cdf0e10cSrcweir 			break;
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir 		case TYP_PAGENUMBERFLD:
1558cdf0e10cSrcweir 		case TYP_GETREFPAGEFLD:
1559cdf0e10cSrcweir 			if( nFormat + 2 == SVX_NUM_PAGEDESC )
1560cdf0e10cSrcweir 				nFormat = SVX_NUM_PAGEDESC;
1561cdf0e10cSrcweir 			break;
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir 		case TYP_GETREFFLD:
1564cdf0e10cSrcweir 			{
1565cdf0e10cSrcweir 				bSetPar2 = sal_False;
1566cdf0e10cSrcweir                 ((SwGetRefField*)pTmpFld)->SetSubType( (sal_uInt16)rPar2.ToInt32() );
1567cdf0e10cSrcweir 				sal_uInt16 nPos = rPar2.Search( '|' );
1568cdf0e10cSrcweir 				if( STRING_NOTFOUND != nPos )
1569cdf0e10cSrcweir                     ((SwGetRefField*)pTmpFld)->SetSeqNo( (sal_uInt16)rPar2.Copy( nPos + 1 ).ToInt32());
1570cdf0e10cSrcweir 			}
1571cdf0e10cSrcweir 			break;
1572cdf0e10cSrcweir 		case TYP_DROPDOWN:
1573cdf0e10cSrcweir 		{
1574cdf0e10cSrcweir             xub_StrLen nTokenCount = sPar2.Len() ? sPar2.GetTokenCount(DB_DELIM) : 0;
1575cdf0e10cSrcweir             Sequence<OUString> aEntries(nTokenCount);
1576cdf0e10cSrcweir             OUString* pArray = aEntries.getArray();
1577cdf0e10cSrcweir             for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++)
1578cdf0e10cSrcweir                 pArray[nToken] = sPar2.GetToken(nToken, DB_DELIM);
1579cdf0e10cSrcweir             ((SwDropDownField*)pTmpFld)->SetItems(aEntries);
1580cdf0e10cSrcweir             ((SwDropDownField*)pTmpFld)->SetName(sPar1);
1581cdf0e10cSrcweir 			bSetPar1 = bSetPar2 = sal_False;
1582cdf0e10cSrcweir 		}
1583cdf0e10cSrcweir 		break;
1584cdf0e10cSrcweir         case TYP_AUTHORITY :
1585cdf0e10cSrcweir         {
1586cdf0e10cSrcweir             //#i99069# changes to a bibliography field should change the field type
1587cdf0e10cSrcweir             SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpFld);
1588cdf0e10cSrcweir             SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
1589cdf0e10cSrcweir             SwAuthEntry aTempEntry;
1590cdf0e10cSrcweir             for( sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i )
1591cdf0e10cSrcweir                 aTempEntry.SetAuthorField( (ToxAuthorityField)i,
1592cdf0e10cSrcweir                                 rPar1.GetToken( i, TOX_STYLE_DELIMITER ));
1593cdf0e10cSrcweir             if( pAuthorityType->ChangeEntryContent( &aTempEntry ) )
1594cdf0e10cSrcweir             {
1595cdf0e10cSrcweir                 pType->UpdateFlds();
1596cdf0e10cSrcweir                 pSh->SetModified();
1597cdf0e10cSrcweir             }
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir             if( aTempEntry.GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
1600cdf0e10cSrcweir                 pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
1601cdf0e10cSrcweir                 bSetPar1 = sal_False; //otherwise it's a new or changed entry, the field needs to be updated
1602cdf0e10cSrcweir             bSetPar2 = sal_False;
1603cdf0e10cSrcweir         }
1604cdf0e10cSrcweir         break;
1605cdf0e10cSrcweir 	}
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir 	// Format setzen
1608cdf0e10cSrcweir 	// Format wegen NumberFormatter vor SetPar2 einstellen!
1609cdf0e10cSrcweir 	pTmpFld->ChangeFormat(nFormat);
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir 	if(bSetPar1)
1612cdf0e10cSrcweir 		pTmpFld->SetPar1( sPar1 );
1613cdf0e10cSrcweir 	if( bSetPar2 )
1614cdf0e10cSrcweir 		pTmpFld->SetPar2( sPar2 );
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir 	// Update anschmeissen
1617cdf0e10cSrcweir 	if(nTypeId == TYP_DDEFLD ||
1618cdf0e10cSrcweir 	   nTypeId == TYP_USERFLD ||
1619cdf0e10cSrcweir 	   nTypeId == TYP_USRINPFLD)
1620cdf0e10cSrcweir 	{
1621cdf0e10cSrcweir 		pType->UpdateFlds();
1622cdf0e10cSrcweir         pSh->SetModified();
1623cdf0e10cSrcweir 	}
1624cdf0e10cSrcweir 	else {
1625cdf0e10cSrcweir 		// mb: #32157
1626cdf0e10cSrcweir         pSh->SwEditShell::UpdateFlds(*pTmpFld);
1627cdf0e10cSrcweir 		GetCurFld();
1628cdf0e10cSrcweir 	}
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir     if (bDelete)
1631cdf0e10cSrcweir         delete pTmpFld;
1632cdf0e10cSrcweir 
1633cdf0e10cSrcweir     pSh->EndAllAction();
1634cdf0e10cSrcweir }
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir /*--------------------------------------------------------------------
1637cdf0e10cSrcweir 	Beschreibung: ExpressionFields explizit evaluieren
1638cdf0e10cSrcweir  --------------------------------------------------------------------*/
EvalExpFlds(SwWrtShell * pSh)1639cdf0e10cSrcweir void SwFldMgr::EvalExpFlds(SwWrtShell* pSh)
1640cdf0e10cSrcweir {
1641cdf0e10cSrcweir 	if (pSh == NULL)
1642cdf0e10cSrcweir 		pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir 	if(pSh)
1645cdf0e10cSrcweir 	{
1646cdf0e10cSrcweir 		pSh->StartAllAction();
1647cdf0e10cSrcweir 		pSh->UpdateExpFlds(sal_True);
1648cdf0e10cSrcweir 		pSh->EndAllAction();
1649cdf0e10cSrcweir 	}
1650cdf0e10cSrcweir }
GetCurrLanguage() const1651cdf0e10cSrcweir sal_uInt16 SwFldMgr::GetCurrLanguage() const
1652cdf0e10cSrcweir {
1653cdf0e10cSrcweir 	SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell();
1654cdf0e10cSrcweir 	if( pSh )
1655cdf0e10cSrcweir 		return pSh->GetCurLang();
1656cdf0e10cSrcweir 	return SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() );
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir 
_GetFldName()1659cdf0e10cSrcweir void SwFieldType::_GetFldName()
1660cdf0e10cSrcweir {
166115ad9f6bSMathias Bauer 	// mba: this is an awful mess; a fix is available, but too much for 3.4 -> applay plaster
166215ad9f6bSMathias Bauer 	static const sal_uInt16 coFldCnt = 43;
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir 	static sal_uInt16 __READONLY_DATA coFldNms[ coFldCnt ] = {
1665cdf0e10cSrcweir 		FLD_DATE_STD,
1666cdf0e10cSrcweir 		FLD_TIME_STD,
1667cdf0e10cSrcweir 		STR_FILENAMEFLD,
1668cdf0e10cSrcweir 		STR_DBNAMEFLD,
1669cdf0e10cSrcweir 		STR_CHAPTERFLD,
1670cdf0e10cSrcweir 		STR_PAGENUMBERFLD,
1671cdf0e10cSrcweir 		STR_DOCSTATFLD,
1672cdf0e10cSrcweir 		STR_AUTHORFLD,
1673cdf0e10cSrcweir 		STR_SETFLD,
1674cdf0e10cSrcweir 		STR_GETFLD,
1675cdf0e10cSrcweir 		STR_FORMELFLD,
1676cdf0e10cSrcweir 		STR_HIDDENTXTFLD,
1677cdf0e10cSrcweir 		STR_SETREFFLD,
1678cdf0e10cSrcweir 		STR_GETREFFLD,
1679cdf0e10cSrcweir 		STR_DDEFLD,
1680cdf0e10cSrcweir 		STR_MACROFLD,
1681cdf0e10cSrcweir 		STR_INPUTFLD,
1682cdf0e10cSrcweir 		STR_HIDDENPARAFLD,
1683cdf0e10cSrcweir 		STR_DOCINFOFLD,
1684cdf0e10cSrcweir 		STR_DBFLD,
1685cdf0e10cSrcweir 		STR_USERFLD,
1686cdf0e10cSrcweir 		STR_POSTITFLD,
1687cdf0e10cSrcweir 		STR_TEMPLNAMEFLD,
1688cdf0e10cSrcweir 		STR_SEQFLD,
1689cdf0e10cSrcweir 		STR_DBNEXTSETFLD,
1690cdf0e10cSrcweir 		STR_DBNUMSETFLD,
1691cdf0e10cSrcweir 		STR_DBSETNUMBERFLD,
1692cdf0e10cSrcweir 		STR_CONDTXTFLD,
1693cdf0e10cSrcweir 		STR_NEXTPAGEFLD,
1694cdf0e10cSrcweir 		STR_PREVPAGEFLD,
1695cdf0e10cSrcweir 		STR_EXTUSERFLD,
1696cdf0e10cSrcweir 		FLD_DATE_FIX,
1697cdf0e10cSrcweir 		FLD_TIME_FIX,
1698cdf0e10cSrcweir 		STR_SETINPUTFLD,
1699cdf0e10cSrcweir 		STR_USRINPUTFLD,
1700cdf0e10cSrcweir 		STR_SETREFPAGEFLD,
1701cdf0e10cSrcweir 		STR_GETREFPAGEFLD,
1702cdf0e10cSrcweir 		STR_INTERNETFLD,
1703cdf0e10cSrcweir 		STR_JUMPEDITFLD,
1704cdf0e10cSrcweir 		STR_SCRIPTFLD,
1705cdf0e10cSrcweir 		STR_AUTHORITY,
1706cdf0e10cSrcweir         STR_COMBINED_CHARS,
1707cdf0e10cSrcweir         STR_DROPDOWN
1708cdf0e10cSrcweir 	};
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir 	// Infos fuer Felder einfuegen
1711cdf0e10cSrcweir 	SwFieldType::pFldNames = new SvStringsDtor( (sal_uInt8)coFldCnt, 2 );
1712cdf0e10cSrcweir 	for( sal_uInt16 nIdx = 0; nIdx < coFldCnt; ++nIdx )
1713cdf0e10cSrcweir 	{
1714cdf0e10cSrcweir 		String* pTmp = new SW_RESSTR( coFldNms[ nIdx ] );
1715cdf0e10cSrcweir         pTmp->Assign( MnemonicGenerator::EraseAllMnemonicChars( *pTmp ) );
1716cdf0e10cSrcweir 		SwFieldType::pFldNames->Insert(pTmp, nIdx );
1717cdf0e10cSrcweir 	}
1718cdf0e10cSrcweir }
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir /*--------------------------------------------------------------------
1721cdf0e10cSrcweir 	Beschreibung:
1722cdf0e10cSrcweir  --------------------------------------------------------------------*/
1723cdf0e10cSrcweir 
ChooseMacro(const String &)1724cdf0e10cSrcweir sal_Bool SwFldMgr::ChooseMacro(const String&)
1725cdf0e10cSrcweir {
1726cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir     // choose script dialog
1729cdf0e10cSrcweir     ::rtl::OUString aScriptURL = SfxApplication::ChooseScript();
1730cdf0e10cSrcweir 
1731cdf0e10cSrcweir     // the script selector dialog returns a valid script URL
1732cdf0e10cSrcweir     if ( aScriptURL.getLength() != 0 )
1733cdf0e10cSrcweir     {
1734cdf0e10cSrcweir         SetMacroPath( aScriptURL );
1735cdf0e10cSrcweir         bRet = sal_True;
1736cdf0e10cSrcweir     }
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir     return bRet;
1739cdf0e10cSrcweir }
1740cdf0e10cSrcweir 
SetMacroPath(const String & rPath)1741cdf0e10cSrcweir void SwFldMgr::SetMacroPath(const String& rPath)
1742cdf0e10cSrcweir {
1743cdf0e10cSrcweir     sMacroPath = rPath;
1744cdf0e10cSrcweir     sMacroName = rPath;
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir     // try to set sMacroName member variable by parsing the macro path
1747cdf0e10cSrcweir     // using the new URI parsing services
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir     Reference< XMultiServiceFactory > xSMgr =
1750cdf0e10cSrcweir         ::comphelper::getProcessServiceFactory();
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir     Reference< uri::XUriReferenceFactory >
1753cdf0e10cSrcweir         xFactory( xSMgr->createInstance(
1754cdf0e10cSrcweir             ::rtl::OUString::createFromAscii(
1755cdf0e10cSrcweir                 "com.sun.star.uri.UriReferenceFactory" ) ), UNO_QUERY );
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir     if ( xFactory.is() )
1758cdf0e10cSrcweir     {
1759cdf0e10cSrcweir         Reference< uri::XVndSunStarScriptUrl >
1760cdf0e10cSrcweir             xUrl( xFactory->parse( sMacroPath ), UNO_QUERY );
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir         if ( xUrl.is() )
1763cdf0e10cSrcweir         {
1764cdf0e10cSrcweir             sMacroName = xUrl->getName();
1765cdf0e10cSrcweir         }
1766cdf0e10cSrcweir     }
1767cdf0e10cSrcweir }
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir /*--------------------------------------------------------------------
1770cdf0e10cSrcweir 	Beschreibung:
1771cdf0e10cSrcweir  --------------------------------------------------------------------*/
1772cdf0e10cSrcweir 
GetDefaultFormat(sal_uInt16 nTypeId,sal_Bool bIsText,SvNumberFormatter * pFormatter,double * pVal)1773cdf0e10cSrcweir sal_uLong SwFldMgr::GetDefaultFormat(sal_uInt16 nTypeId, sal_Bool bIsText, SvNumberFormatter* pFormatter, double* pVal)
1774cdf0e10cSrcweir {
1775cdf0e10cSrcweir 	double fValue;
1776cdf0e10cSrcweir 	short  nDefFormat;
1777cdf0e10cSrcweir 
1778cdf0e10cSrcweir 	switch (nTypeId)
1779cdf0e10cSrcweir 	{
1780cdf0e10cSrcweir 		case TYP_TIMEFLD:
1781cdf0e10cSrcweir 		case TYP_DATEFLD:
1782cdf0e10cSrcweir 		{
1783cdf0e10cSrcweir 			Date aDate;
1784cdf0e10cSrcweir 			Date* pNullDate = pFormatter->GetNullDate();
1785cdf0e10cSrcweir 
1786cdf0e10cSrcweir 			fValue = aDate - *pNullDate;
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir 			Time aTime;
1789cdf0e10cSrcweir 
1790cdf0e10cSrcweir 			sal_uLong nNumFmtTime = (sal_uLong)aTime.GetSec() + (sal_uLong)aTime.GetMin() * 60L +
1791cdf0e10cSrcweir 						  (sal_uLong)aTime.GetHour() * 3600L;
1792cdf0e10cSrcweir 
1793cdf0e10cSrcweir 			fValue += (double)nNumFmtTime / 86400.0;
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir 			nDefFormat = (nTypeId == TYP_DATEFLD) ? NUMBERFORMAT_DATE : NUMBERFORMAT_TIME;
1796cdf0e10cSrcweir 		}
1797cdf0e10cSrcweir 		break;
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir 		default:
1800cdf0e10cSrcweir 			if (bIsText)
1801cdf0e10cSrcweir 			{
1802cdf0e10cSrcweir 				fValue = 0.0;
1803cdf0e10cSrcweir 				nDefFormat = NUMBERFORMAT_TEXT;
1804cdf0e10cSrcweir 			}
1805cdf0e10cSrcweir 			else
1806cdf0e10cSrcweir 			{
1807cdf0e10cSrcweir 				fValue = 0.0;
1808cdf0e10cSrcweir 				nDefFormat = NUMBERFORMAT_ALL;
1809cdf0e10cSrcweir 			}
1810cdf0e10cSrcweir 			break;
1811cdf0e10cSrcweir 	}
1812cdf0e10cSrcweir 
1813cdf0e10cSrcweir 	if (pVal)
1814cdf0e10cSrcweir 		*pVal = fValue;
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 	return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir 
1819cdf0e10cSrcweir /* -----------------------------01.03.01 16:46--------------------------------
1820cdf0e10cSrcweir 
1821cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetNumberingInfo() const1822cdf0e10cSrcweir Reference<XNumberingTypeInfo> SwFldMgr::GetNumberingInfo() const
1823cdf0e10cSrcweir {
1824cdf0e10cSrcweir 	if(!xNumberingInfo.is())
1825cdf0e10cSrcweir 	{
1826cdf0e10cSrcweir 		Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
1827cdf0e10cSrcweir 		Reference < XInterface > xI = xMSF->createInstance(
1828cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(
1829cdf0e10cSrcweir 							"com.sun.star.text.DefaultNumberingProvider" ));
1830cdf0e10cSrcweir 		Reference<XDefaultNumberingProvider> xDefNum(xI, UNO_QUERY);
1831cdf0e10cSrcweir 		DBG_ASSERT(xDefNum.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\"");
1832cdf0e10cSrcweir 		((SwFldMgr*)this)->xNumberingInfo = Reference<XNumberingTypeInfo>(xDefNum, UNO_QUERY);
1833cdf0e10cSrcweir 	}
1834cdf0e10cSrcweir 	return xNumberingInfo;
1835cdf0e10cSrcweir }
1836