xref: /aoo41x/main/sw/source/core/sw3io/sw3convert.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <stdlib.h>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <stdio.h>
32cdf0e10cSrcweir #include "hintids.hxx"
33cdf0e10cSrcweir #include <tools/resid.hxx>
34cdf0e10cSrcweir #include <svl/macitem.hxx>
35cdf0e10cSrcweir #include <svl/zforlist.hxx>
36cdf0e10cSrcweir #include <svl/zformat.hxx>
37cdf0e10cSrcweir #include <svl/urihelper.hxx>
38cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #ifndef _SVSTDARR_USHORTS_DECL
41cdf0e10cSrcweir #define _SVSTDARR_USHORTS
42cdf0e10cSrcweir #include <svl/svstdarr.hxx>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
45cdf0e10cSrcweir #include <editeng/tstpitem.hxx>
46cdf0e10cSrcweir #include <fmtinfmt.hxx>
47cdf0e10cSrcweir #include <fmtfld.hxx>
48cdf0e10cSrcweir #include <frmatr.hxx>
49cdf0e10cSrcweir #include "doc.hxx"
50cdf0e10cSrcweir #include "docary.hxx"
51cdf0e10cSrcweir #include "fldbas.hxx"
52cdf0e10cSrcweir #include "flddat.hxx"
53cdf0e10cSrcweir #include "docufld.hxx"
54cdf0e10cSrcweir #include "chpfld.hxx"
55cdf0e10cSrcweir #include "ddefld.hxx"
56cdf0e10cSrcweir #include "expfld.hxx"
57cdf0e10cSrcweir #include "reffld.hxx"
58cdf0e10cSrcweir #include "usrfld.hxx"
59cdf0e10cSrcweir #include "dbfld.hxx"
60cdf0e10cSrcweir #include "txtfld.hxx"
61cdf0e10cSrcweir #include "ndtxt.hxx"
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //really used ids from old sw3ids.hxx
64cdf0e10cSrcweir #define SWG_INETBROWSER 0x000e      // URL-Grf-Nodes, Browse-Flag, Format-Ums.
65cdf0e10cSrcweir #define SWG_NEWFIELDS   0x0200      // Felder mit Numberformatter-Zahlenformat
66cdf0e10cSrcweir #define SWG_EXPORT40    0x0110      // Version fuer 4.0-Export ab 5.0
67cdf0e10cSrcweir 
68cdf0e10cSrcweir using namespace nsSwDocInfoSubType;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //#include "poolfmt.hxx"        // fuer InSetExpField
72cdf0e10cSrcweir //#include "poolfmt.hrc"        // fuer InSetExpField
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //#if !defined(UNX) && !defined(MSC) && !defined(PPC) && !defined(CSET) && !defined(__MWERKS__) && !defined(WTC)
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //#define FIELDFNTAB_SIZE 37
77cdf0e10cSrcweir //#if FIELDFNTAB_SIZE != RES_FIELDS_END - RES_FIELDS_BEGIN
78cdf0e10cSrcweir //#error Feld-Tabelle ist ungueltigt. Wurden neue Hint-IDs zugefuegt ??
79cdf0e10cSrcweir //#endif
80cdf0e10cSrcweir 
81cdf0e10cSrcweir //#endif
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //#define SWG_AUTHORITY_ENTRY_LCL   'E'
84cdf0e10cSrcweir 
85cdf0e10cSrcweir //sal_Char __FAR_DATA sSW3IO_FixedField[] = "FixedExport";
86cdf0e10cSrcweir //sal_Char __FAR_DATA sSW3IO_AuthorityField[] = "AuthorityExport";
87cdf0e10cSrcweir /* #108791# */
88cdf0e10cSrcweir //sal_Char __FAR_DATA sSW3IO_DropDownField[] = "DropDownExport";
89cdf0e10cSrcweir 
90cdf0e10cSrcweir struct OldFormats
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	NfIndexTableOffset	eFormatIdx;
93cdf0e10cSrcweir 	sal_uInt16				nOldFormat;
94cdf0e10cSrcweir };
95cdf0e10cSrcweir 
96cdf0e10cSrcweir static OldFormats aOldDateFmt40[] =
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	// Datumsfelder:
99cdf0e10cSrcweir 	{ NF_DATE_SYSTEM_SHORT,			DFF_SSYS },		// Kurzes Systemdatum
100cdf0e10cSrcweir 	{ NF_DATE_SYSTEM_LONG,			DFF_LSYS },		// Langes Systemdatum
101cdf0e10cSrcweir 	{ NF_DATE_SYS_DDMMYY,				DFF_DMY },        // 06.10.64
102cdf0e10cSrcweir 	{ NF_DATE_SYS_DDMMYYYY,			DFF_DMYY },		// 06.10.1964
103cdf0e10cSrcweir 	{ NF_DATE_SYS_DMMMYY,				DFF_DMMY },		// 06. Okt 64
104cdf0e10cSrcweir 	{ NF_DATE_SYS_DMMMYYYY,			DFF_DMMYY },		// 06. Okt 1964
105cdf0e10cSrcweir 	{ NF_DATE_DIN_DMMMMYYYY,			DFF_DMMMYY },		// 06. Oktober 1964
106cdf0e10cSrcweir 	{ NF_DATE_DIN_DMMMMYYYY,			DFF_DMMMY },		// 06. Oktober 64
107cdf0e10cSrcweir 	{ NF_DATE_SYS_NNDMMMYY,			DFF_DDMMY },		// Di, 06. Okt 64
108cdf0e10cSrcweir 	{ NF_DATE_SYS_NNDMMMMYYYY,		DFF_DDMMMY },		// Di, 06. Oktober 64
109cdf0e10cSrcweir 	{ NF_DATE_SYS_NNDMMMMYYYY,		DFF_DDMMMYY },	// Di, 06. Oktober 1964
110cdf0e10cSrcweir 	{ NF_DATE_SYS_NNNNDMMMMYYYY,		DFF_DDDMMMYY },	// Dienstag, 06. Oktober 1964
111cdf0e10cSrcweir 	{ NF_DATE_SYS_NNNNDMMMMYYYY,		DFF_DDDMMMY },	// Dienstag, 06. Oktober 64
112cdf0e10cSrcweir 	{ NF_DATE_SYS_MMYY,				DFF_MY },			// 10.64
113cdf0e10cSrcweir 	{ NF_DATE_DIN_MMDD,				DFF_MD },			// 10-06
114cdf0e10cSrcweir 	{ NF_DATE_DIN_YYMMDD,				DFF_YMD },		// 64-10-06
115cdf0e10cSrcweir 	{ NF_DATE_DIN_YYYYMMDD,			DFF_YYMD },		// 1964-10-06
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	{ NF_NUMERIC_START,				0  }				// Tabellenende
118cdf0e10cSrcweir };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir static OldFormats aOldDateFmt30[] =
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	// Datumsfelder:
123cdf0e10cSrcweir 	{ NF_DATE_SYSTEM_SHORT,			DFF_SSYS },		// Kurzes Systemdatum
124cdf0e10cSrcweir 	{ NF_DATE_SYSTEM_LONG,			DFF_LSYS },		// Langes Systemdatum
125cdf0e10cSrcweir 	{ NF_DATE_SYS_DDMMYY,				DFF_DMY },        // 06.10.64
126cdf0e10cSrcweir 	{ NF_DATE_SYS_DDMMYYYY,			DFF_DMYY },		// 06.10.1964
127cdf0e10cSrcweir 	{ NF_DATE_SYS_DMMMYY,				DFF_DMMY },		// 06. Okt 64
128cdf0e10cSrcweir 	{ NF_DATE_SYS_DMMMYYYY,			4 /*DFF_DMMYY*/ },	// 06. Okt 1964
129cdf0e10cSrcweir 	{ NF_DATE_DIN_DMMMMYYYY,			5 /*DFF_DMMMYY*/ },	// 06. Oktober 1964
130cdf0e10cSrcweir 	{ NF_DATE_DIN_DMMMMYYYY,			5 /*DFF_DMMMY*/ },	// 06. Oktober 64
131cdf0e10cSrcweir 	{ NF_DATE_SYS_NNDMMMMYYYY,		6 /*DFF_DDMMMYY*/ },	// Di, 06. Oktober 1964
132cdf0e10cSrcweir 	{ NF_DATE_SYS_NNDMMMYY,			6 /*DFF_DDMMY*/ },	// Di, 06. Okt 64
133cdf0e10cSrcweir 	{ NF_DATE_SYS_NNDMMMMYYYY,		6 /*DFF_DDMMMY*/ },	// Di, 06. Oktober 64
134cdf0e10cSrcweir 	{ NF_DATE_SYS_NNNNDMMMMYYYY,		7 /*DFF_DDDMMMYY*/ },	// Dienstag, 06. Oktober 1964
135cdf0e10cSrcweir 	{ NF_DATE_SYS_NNNNDMMMMYYYY,		7 /*DFF_DDDMMMY*/ },	// Dienstag, 06. Oktober 64
136cdf0e10cSrcweir 	{ NF_DATE_SYS_MMYY,				2 /*DFF_MY*/ },		// 10.64
137cdf0e10cSrcweir 	{ NF_DATE_DIN_MMDD,				DFF_MD },			// 10-06
138cdf0e10cSrcweir 	{ NF_DATE_DIN_YYMMDD,				DFF_YMD },		// 64-10-06
139cdf0e10cSrcweir 	{ NF_DATE_DIN_YYYYMMDD,			DFF_YYMD },		// 1964-10-06
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	{ NF_NUMERIC_START,				0  }				// Tabellenende
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir static OldFormats aOldTimeFmt[] =
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	// Zeitfelder:
147cdf0e10cSrcweir 	{ NF_TIME_HHMMSS,					TF_SYSTEM },		// Systemzeit
148cdf0e10cSrcweir 	{ NF_TIME_HHMM,					TF_SSMM_24 },		// 23:25
149cdf0e10cSrcweir 	{ NF_TIME_HHMMAMPM,				TF_SSMM_12 },		// 11:25 PM
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	{ NF_NUMERIC_START,				0 }				// Tabellenende
152cdf0e10cSrcweir };
153cdf0e10cSrcweir 
154cdf0e10cSrcweir static OldFormats aOldGetSetExpFmt40[] =
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	{ NF_TEXT,						VVF_CMD },		// Kommando anzeigen
157cdf0e10cSrcweir 	{ NF_TEXT,						VVF_INVISIBLE },	// unsichtbar
158cdf0e10cSrcweir 	{ NF_PERCENT_INT,					VVF_XXP },		// 1234%
159cdf0e10cSrcweir 	{ NF_PERCENT_DEC2,				VVF_XX_XXP },   	// 1.234,56%
160cdf0e10cSrcweir 	{ NF_TEXT,						VVF_CLEAR },		// ???
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	{ NF_NUMBER_SYSTEM,				VVF_SYS }, 		// Zahlenformat aus der
163cdf0e10cSrcweir 													// Systemeinstellung
164cdf0e10cSrcweir 	{ NF_NUMBER_INT,					VVF_X },			// 1234
165cdf0e10cSrcweir 	{ NF_NUMBER_DEC2,					VVF_X_X },   		// 1234,5
166cdf0e10cSrcweir 	{ NF_NUMBER_DEC2,					VVF_X_XX },   	// 1245,56
167cdf0e10cSrcweir 	{ NF_NUMBER_1000DEC2,				VVF_XX_XX },   	// 1.234,56
168cdf0e10cSrcweir 	{ NF_NUMBER_1000DEC2,				VVF_XX_X },   	// 1.234,5
169cdf0e10cSrcweir 	{ NF_NUMBER_1000DEC2,				VVF_XX_XXX },		// 1.234,567
170cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2,			VVF_SYS_CUR },	// W?hrungsformat aus der
171cdf0e10cSrcweir 													// Systemeinstellung
172cdf0e10cSrcweir 													// (1.234,00 DM)
173cdf0e10cSrcweir 	{ NF_CURRENCY_1000INT,			VVF_X_CUR },		// 1234 DM
174cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2,			VVF_XX_XX_CUR },  // 1234,56 DM 1234,00 DM
175cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2_DASHED,	VVF_XX_X0_CUR },  // 1234,56 DM 1234,-- DM
176cdf0e10cSrcweir 	{ NF_CURRENCY_1000INT,			VVF_CUR_X },   	// DM 1234
177cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2,			VVF_CUR_XX_XX },  // DM 1234,56 DM 1234,00
178cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2_DASHED,	VVF_CUR_XX_X0 },  // DM 1234,56 DM 1234,--
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	{ NF_NUMERIC_START, 				0  }				// Tabellenende
181cdf0e10cSrcweir };
182cdf0e10cSrcweir 
183cdf0e10cSrcweir static OldFormats aOldGetSetExpFmt30[] =
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	{ NF_TEXT,						VVF_CMD },		// Kommando anzeigen
186cdf0e10cSrcweir 	{ NF_TEXT,						VVF_INVISIBLE },	// unsichtbar
187cdf0e10cSrcweir 	{ NF_PERCENT_INT,					VVF_XXP },		// 1234%
188cdf0e10cSrcweir 	{ NF_PERCENT_DEC2,				VVF_XX_XXP },   	// 1.234,56%
189cdf0e10cSrcweir 	{ NF_TEXT,						VVF_CLEAR },		// ???
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	{ NF_NUMBER_SYSTEM,				0x0020 }, 		// Zahlenformat aus der
192cdf0e10cSrcweir 													// Systemeinstellung
193cdf0e10cSrcweir 	{ NF_NUMBER_INT,					0x0080 },			// 1234
194cdf0e10cSrcweir 	{ NF_NUMBER_1000DEC2,				0x0100 },   		// 1.234,56
195cdf0e10cSrcweir 	{ NF_NUMBER_DEC2,					0x0100 },   		// 1234,5
196cdf0e10cSrcweir 	{ NF_NUMBER_DEC2,					0x0100 },  		// 1245,56
197cdf0e10cSrcweir 	{ NF_NUMBER_1000DEC2,				0x0100 },   		// 1.234,5
198cdf0e10cSrcweir 	{ NF_NUMBER_1000DEC2,				0x0100 },			// 1.234,567
199cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2,			0x0200 },			// W?hrungsformat aus der
200cdf0e10cSrcweir 													// Systemeinstellung
201cdf0e10cSrcweir 													// (1.234,00 DM)
202cdf0e10cSrcweir 	{ NF_CURRENCY_1000INT,			0x1000 },			// 1234 DM
203cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2,			0x1000 },  		// 1234,56 DM 1234,00 DM
204cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2_DASHED,	0x1000 },  		// 1234,56 DM 1234,-- DM
205cdf0e10cSrcweir 	{ NF_CURRENCY_1000INT,			0x1000 },   		// DM 1234
206cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2,			0x1000 },  		// DM 1234,56 DM 1234,00
207cdf0e10cSrcweir 	{ NF_CURRENCY_1000DEC2_DASHED,	0x1000 }, 		// DM 1234,56 DM 1234,--
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	{ NF_NUMERIC_START, 				0  }				// Tabellenende
210cdf0e10cSrcweir };
211cdf0e10cSrcweir 
sw3io_ConvertFromOldField(SwDoc & rDoc,sal_uInt16 & rWhich,sal_uInt16 & rSubType,sal_uLong & rFmt,sal_uInt16 nVersion)212cdf0e10cSrcweir SW_DLLPUBLIC void sw3io_ConvertFromOldField( SwDoc& rDoc, sal_uInt16& rWhich,
213cdf0e10cSrcweir 								sal_uInt16& rSubType, sal_uLong &rFmt,
214cdf0e10cSrcweir 								sal_uInt16 nVersion )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	const OldFormats *pOldFmt = 0L;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	switch( rWhich )
219cdf0e10cSrcweir 	{
220cdf0e10cSrcweir 		case RES_DATEFLD:
221cdf0e10cSrcweir 		case RES_FIXDATEFLD:
222cdf0e10cSrcweir 			if( nVersion < SWG_NEWFIELDS )
223cdf0e10cSrcweir 			{
224cdf0e10cSrcweir 				rSubType = DATEFLD;
225cdf0e10cSrcweir 				if( RES_FIXDATEFLD == rWhich )
226cdf0e10cSrcweir 					rSubType |= FIXEDFLD;
227cdf0e10cSrcweir 				rWhich = RES_DATETIMEFLD;
228cdf0e10cSrcweir 				pOldFmt = nVersion<SWG_INETBROWSER ? aOldDateFmt30
229cdf0e10cSrcweir 												   : aOldDateFmt40;
230cdf0e10cSrcweir 			}
231cdf0e10cSrcweir 			break;
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 		case RES_TIMEFLD:
234cdf0e10cSrcweir 		case RES_FIXTIMEFLD:
235cdf0e10cSrcweir 			if( nVersion < SWG_NEWFIELDS )
236cdf0e10cSrcweir 			{
237cdf0e10cSrcweir 				rSubType = TIMEFLD;
238cdf0e10cSrcweir 				if( RES_FIXTIMEFLD == rWhich )
239cdf0e10cSrcweir 					rSubType |= FIXEDFLD;
240cdf0e10cSrcweir 				rWhich = RES_DATETIMEFLD;
241cdf0e10cSrcweir 				pOldFmt = aOldTimeFmt;
242cdf0e10cSrcweir 			}
243cdf0e10cSrcweir 			break;
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 		case RES_DBFLD:
246cdf0e10cSrcweir 			if( nVersion < SWG_NEWFIELDS )
247cdf0e10cSrcweir 			{
248cdf0e10cSrcweir 				rSubType = nsSwExtendedSubType::SUB_OWN_FMT;
249cdf0e10cSrcweir 				pOldFmt = nVersion<SWG_INETBROWSER ? aOldGetSetExpFmt30
250cdf0e10cSrcweir 													: aOldGetSetExpFmt40;
251cdf0e10cSrcweir 			}
252cdf0e10cSrcweir 			break;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 		case RES_TABLEFLD:
255cdf0e10cSrcweir 		case RES_GETEXPFLD:
256cdf0e10cSrcweir 		case RES_SETEXPFLD:
257cdf0e10cSrcweir 		case RES_USERFLD:
258cdf0e10cSrcweir 			if( nVersion < SWG_NEWFIELDS )
259cdf0e10cSrcweir 			{
260cdf0e10cSrcweir 				if( rFmt == VVF_INVISIBLE )
261cdf0e10cSrcweir 				{
262cdf0e10cSrcweir 					rSubType = nsSwExtendedSubType::SUB_INVISIBLE;
263cdf0e10cSrcweir 					rFmt = 0;
264cdf0e10cSrcweir 				}
265cdf0e10cSrcweir 				else if( rFmt == VVF_CMD )
266cdf0e10cSrcweir 				{
267cdf0e10cSrcweir 					rSubType = nsSwExtendedSubType::SUB_CMD;
268cdf0e10cSrcweir 					rFmt = 0;
269cdf0e10cSrcweir 				}
270cdf0e10cSrcweir 				else
271cdf0e10cSrcweir 				{
272cdf0e10cSrcweir 					// Kleiner Hack: Bei Numernkreisen wird das
273cdf0e10cSrcweir 					// unkonvertierte Format noch benoetigt. Wir merken es
274cdf0e10cSrcweir 					// uns voruebergehend mal im Subtyp, sofern es
275cdf0e10cSrcweir 					// ueberhaupt als entsprechendes Format in Frage kommt.
276cdf0e10cSrcweir 					if( RES_SETEXPFLD==rWhich &&
277cdf0e10cSrcweir                         /*rFmt >= (sal_uInt16)SVX_NUM_CHARS_UPPER_LETTER && always true*/
278cdf0e10cSrcweir 						rFmt <= (sal_uInt16)SVX_NUM_BITMAP )
279cdf0e10cSrcweir 					{
280cdf0e10cSrcweir 						rSubType = (sal_uInt16)rFmt;
281cdf0e10cSrcweir 					}
282cdf0e10cSrcweir 					pOldFmt = nVersion<SWG_INETBROWSER ? aOldGetSetExpFmt30
283cdf0e10cSrcweir 													   : aOldGetSetExpFmt40;
284cdf0e10cSrcweir 				}
285cdf0e10cSrcweir 			}
286cdf0e10cSrcweir 			break;
287cdf0e10cSrcweir 		case RES_DOCINFOFLD:
288cdf0e10cSrcweir 			if( nVersion < SWG_NEWFIELDS )
289cdf0e10cSrcweir 			{
290cdf0e10cSrcweir 				switch( rFmt )
291cdf0e10cSrcweir 				{
292cdf0e10cSrcweir 				case RF_AUTHOR:	rSubType = DI_SUB_AUTHOR;	break;
293cdf0e10cSrcweir 				case RF_TIME:	rSubType = DI_SUB_TIME;	break;
294cdf0e10cSrcweir 				case RF_DATE:	rSubType = DI_SUB_DATE;	break;
295cdf0e10cSrcweir 				case RF_ALL:	rSubType = DI_SUB_DATE;	break;
296cdf0e10cSrcweir 				}
297cdf0e10cSrcweir 				rFmt = 0;
298cdf0e10cSrcweir 			}
299cdf0e10cSrcweir 			break;
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	if( pOldFmt )
303cdf0e10cSrcweir 	{
304cdf0e10cSrcweir 		SvNumberFormatter *pFormatter = rDoc.GetNumberFormatter();
305cdf0e10cSrcweir 		sal_uInt16 i = 0;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 		while( pOldFmt[i].eFormatIdx != NF_NUMERIC_START ||
308cdf0e10cSrcweir 			   pOldFmt[i].nOldFormat)
309cdf0e10cSrcweir 		{
310cdf0e10cSrcweir 			if( rFmt == pOldFmt[i].nOldFormat )
311cdf0e10cSrcweir 			{
312cdf0e10cSrcweir 				rFmt = pFormatter->GetFormatIndex(pOldFmt[i].eFormatIdx, LANGUAGE_SYSTEM);
313cdf0e10cSrcweir 				break;
314cdf0e10cSrcweir 			}
315cdf0e10cSrcweir 			i++;
316cdf0e10cSrcweir 		}
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir }
sw3io_ConvertToOldField(const SwField * pFld,sal_uInt16 & rWhich,sal_uLong & rFmt,sal_uLong nFFVersion)319cdf0e10cSrcweir SW_DLLPUBLIC void sw3io_ConvertToOldField( const SwField* pFld, sal_uInt16& rWhich,
320cdf0e10cSrcweir                               sal_uLong& rFmt, sal_uLong nFFVersion )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir     const OldFormats *pOldFmt = 0L;
323cdf0e10cSrcweir     sal_uLong nOldFmt = rFmt;
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     switch( rWhich )
326cdf0e10cSrcweir     {
327cdf0e10cSrcweir         case RES_DOCINFOFLD:
328cdf0e10cSrcweir             if( SOFFICE_FILEFORMAT_40 >= nFFVersion )
329cdf0e10cSrcweir             {
330cdf0e10cSrcweir                 switch (pFld->GetSubType() & 0xff00)
331cdf0e10cSrcweir                 {
332cdf0e10cSrcweir                 case DI_SUB_AUTHOR: rFmt = RF_AUTHOR;   break;
333cdf0e10cSrcweir                 case DI_SUB_TIME:   rFmt = RF_TIME;     break;
334cdf0e10cSrcweir                 case DI_SUB_DATE:   rFmt = RF_DATE;     break;
335cdf0e10cSrcweir                 }
336cdf0e10cSrcweir             }
337cdf0e10cSrcweir             break;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir         case RES_DATETIMEFLD:
340cdf0e10cSrcweir             if( SOFFICE_FILEFORMAT_40 >= nFFVersion )
341cdf0e10cSrcweir             {
342cdf0e10cSrcweir                 sal_uInt16 nSubType = ((SwDateTimeField*) pFld)->GetSubType();
343cdf0e10cSrcweir                 switch( nSubType )
344cdf0e10cSrcweir                 {
345cdf0e10cSrcweir                 case DATEFLD:           rWhich = RES_DATEFLD;       break;
346cdf0e10cSrcweir                 case TIMEFLD:           rWhich = RES_TIMEFLD;       break;
347cdf0e10cSrcweir                 case DATEFLD|FIXEDFLD:  rWhich = RES_FIXDATEFLD;    break;
348cdf0e10cSrcweir                 case TIMEFLD|FIXEDFLD:  rWhich = RES_FIXTIMEFLD;    break;
349cdf0e10cSrcweir                 }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir                 if( nSubType & DATEFLD )
352cdf0e10cSrcweir                 {
353cdf0e10cSrcweir                     rFmt = DFF_DMY;
354cdf0e10cSrcweir                     pOldFmt = aOldDateFmt40;
355cdf0e10cSrcweir                 }
356cdf0e10cSrcweir                 else
357cdf0e10cSrcweir                 {
358cdf0e10cSrcweir                     rFmt = TF_SYSTEM;
359cdf0e10cSrcweir                     pOldFmt = aOldTimeFmt;
360cdf0e10cSrcweir                 }
361cdf0e10cSrcweir             }
362cdf0e10cSrcweir             break;
363cdf0e10cSrcweir 
364cdf0e10cSrcweir         case RES_DBFLD:
365cdf0e10cSrcweir         case RES_TABLEFLD:
366cdf0e10cSrcweir         case RES_GETEXPFLD:
367cdf0e10cSrcweir         case RES_SETEXPFLD:
368cdf0e10cSrcweir         case RES_USERFLD:
369cdf0e10cSrcweir             if( SOFFICE_FILEFORMAT_40 >= nFFVersion )
370cdf0e10cSrcweir             {
371cdf0e10cSrcweir                 sal_uInt16 nSubType = pFld->GetSubType();
372cdf0e10cSrcweir 
373cdf0e10cSrcweir                 if (nSubType & nsSwExtendedSubType::SUB_INVISIBLE)
374cdf0e10cSrcweir                     rFmt = VVF_INVISIBLE;
375cdf0e10cSrcweir                 else if (nSubType & nsSwExtendedSubType::SUB_CMD)
376cdf0e10cSrcweir                     rFmt = VVF_CMD;
377cdf0e10cSrcweir                 else if( !(nsSwGetSetExpType::GSE_SEQ & nSubType) )
378cdf0e10cSrcweir                 {
379cdf0e10cSrcweir                     pOldFmt = aOldGetSetExpFmt40;
380cdf0e10cSrcweir                     rFmt = VVF_SYS;
381cdf0e10cSrcweir                 }
382cdf0e10cSrcweir             }
383cdf0e10cSrcweir             break;
384cdf0e10cSrcweir 
385cdf0e10cSrcweir         case RES_GETREFFLD:
386cdf0e10cSrcweir             if( SOFFICE_FILEFORMAT_31 == nFFVersion )
387cdf0e10cSrcweir             {
388cdf0e10cSrcweir                 switch( rFmt )
389cdf0e10cSrcweir                 {
390cdf0e10cSrcweir                 case REF_PAGE:
391cdf0e10cSrcweir                 case REF_CHAPTER:
392cdf0e10cSrcweir                 case REF_CONTENT:
393cdf0e10cSrcweir                     break;
394cdf0e10cSrcweir 
395cdf0e10cSrcweir                 default:
396cdf0e10cSrcweir                 // case REF_UPDOWN:
397cdf0e10cSrcweir                 // case REF_PAGE_PGDESC:
398cdf0e10cSrcweir                     rFmt = REF_PAGE;
399cdf0e10cSrcweir                     break;
400cdf0e10cSrcweir                 }
401cdf0e10cSrcweir             }
402cdf0e10cSrcweir             break;
403cdf0e10cSrcweir     }
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     if( pOldFmt && nOldFmt )
406cdf0e10cSrcweir     {
407cdf0e10cSrcweir         sal_uInt16 i = 0;
408cdf0e10cSrcweir 
409cdf0e10cSrcweir         SvNumberFormatter *pFormatter = ((SwValueField*)pFld)->GetDoc()->GetNumberFormatter();
410cdf0e10cSrcweir         const SvNumberformat* pEntry = pFormatter->GetEntry( nOldFmt );
411cdf0e10cSrcweir 
412cdf0e10cSrcweir         if( pEntry )
413cdf0e10cSrcweir         {
414cdf0e10cSrcweir             while( pOldFmt[i].eFormatIdx != NF_NUMERIC_START ||
415cdf0e10cSrcweir                    pOldFmt[i].nOldFormat )
416cdf0e10cSrcweir             {
417cdf0e10cSrcweir                 sal_uLong nKey = pFormatter->GetFormatIndex(
418cdf0e10cSrcweir                             pOldFmt[i].eFormatIdx, pEntry->GetLanguage() );
419cdf0e10cSrcweir 
420cdf0e10cSrcweir                 if( nOldFmt == nKey )
421cdf0e10cSrcweir                 {
422cdf0e10cSrcweir                     rFmt = pOldFmt[i].nOldFormat;
423cdf0e10cSrcweir                     break;
424cdf0e10cSrcweir                 }
425cdf0e10cSrcweir                 i++;
426cdf0e10cSrcweir             }
427cdf0e10cSrcweir         }
428cdf0e10cSrcweir     }
429cdf0e10cSrcweir }
430