xref: /aoo42x/main/svl/source/numbers/zforscan.cxx (revision 86e1cf34)
140df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
340df464eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
440df464eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
540df464eSAndrew Rist  * distributed with this work for additional information
640df464eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
740df464eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
840df464eSAndrew Rist  * "License"); you may not use this file except in compliance
940df464eSAndrew Rist  * with the License.  You may obtain a copy of the License at
1040df464eSAndrew Rist  *
1140df464eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1240df464eSAndrew Rist  *
1340df464eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1440df464eSAndrew Rist  * software distributed under the License is distributed on an
1540df464eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1640df464eSAndrew Rist  * KIND, either express or implied.  See the License for the
1740df464eSAndrew Rist  * specific language governing permissions and limitations
1840df464eSAndrew Rist  * under the License.
1940df464eSAndrew Rist  *
2040df464eSAndrew Rist  *************************************************************/
2140df464eSAndrew Rist 
2240df464eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir #ifndef GCC
27cdf0e10cSrcweir #endif
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <stdlib.h>
30cdf0e10cSrcweir #include <tools/debug.hxx>
31cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
32cdf0e10cSrcweir #include <unotools/charclass.hxx>
33cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
34cdf0e10cSrcweir #include <unotools/numberformatcodewrapper.hxx>
35cdf0e10cSrcweir #include <rtl/instance.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <svl/zforlist.hxx>
38cdf0e10cSrcweir #include <svl/zformat.hxx>
39cdf0e10cSrcweir #include <unotools/digitgroupingiterator.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #define _ZFORSCAN_CXX
42cdf0e10cSrcweir #include "zforscan.hxx"
43cdf0e10cSrcweir #undef _ZFORSCAN_CXX
44cdf0e10cSrcweir #include <svl/nfsymbol.hxx>
45cdf0e10cSrcweir using namespace svt;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir const sal_Unicode cNonBreakingSpace = 0xA0;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace
50cdf0e10cSrcweir {
51cdf0e10cSrcweir     struct ImplEnglishColors
52cdf0e10cSrcweir     {
operator ()__anonbbbfc86d0111::ImplEnglishColors53cdf0e10cSrcweir         const String* operator()()
54cdf0e10cSrcweir         {
55cdf0e10cSrcweir             static const String aEnglishColors[NF_MAX_DEFAULT_COLORS] =
56cdf0e10cSrcweir             {
57cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "BLACK" ) ),
58cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "BLUE" ) ),
59cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "GREEN" ) ),
60cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "CYAN" ) ),
61cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "RED" ) ),
62cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "MAGENTA" ) ),
63cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "BROWN" ) ),
64cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "GREY" ) ),
65cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "YELLOW" ) ),
66cdf0e10cSrcweir                 String( RTL_CONSTASCII_USTRINGPARAM( "WHITE" ) )
67cdf0e10cSrcweir             };
68cdf0e10cSrcweir             return &aEnglishColors[0];
69cdf0e10cSrcweir         }
70cdf0e10cSrcweir     };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     struct theEnglishColors
73cdf0e10cSrcweir             : public rtl::StaticAggregate< const String, ImplEnglishColors> {};
74cdf0e10cSrcweir 
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
ImpSvNumberformatScan(SvNumberFormatter * pFormatterP)77cdf0e10cSrcweir ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	pFormatter = pFormatterP;
80cdf0e10cSrcweir 	bConvertMode = sal_False;
81cdf0e10cSrcweir 	//! All keywords MUST be UPPERCASE!
82cdf0e10cSrcweir 	sKeyword[NF_KEY_E].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"E" ) );		// Exponent
83cdf0e10cSrcweir 	sKeyword[NF_KEY_AMPM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"AM/PM" ) );	// AM/PM
84cdf0e10cSrcweir 	sKeyword[NF_KEY_AP].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"A/P" ) );		// AM/PM short
85cdf0e10cSrcweir 	sKeyword[NF_KEY_MI].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"M" ) );		// Minute
86cdf0e10cSrcweir 	sKeyword[NF_KEY_MMI].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"MM" ) );		// Minute 02
87cdf0e10cSrcweir 	sKeyword[NF_KEY_S].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"S" ) );		// Second
88cdf0e10cSrcweir 	sKeyword[NF_KEY_SS].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"SS" ) );		// Second 02
89cdf0e10cSrcweir 	sKeyword[NF_KEY_Q].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"Q" ) );		// Quarter short 'Q'
90cdf0e10cSrcweir 	sKeyword[NF_KEY_QQ].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"QQ" ) );		// Quarter long
91cdf0e10cSrcweir 	sKeyword[NF_KEY_NN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"NN" ) );		// Day of week short
92cdf0e10cSrcweir 	sKeyword[NF_KEY_NNN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"NNN" ) );		// Day of week long
93cdf0e10cSrcweir 	sKeyword[NF_KEY_NNNN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"NNNN" ) );		// Day of week long incl. separator
94cdf0e10cSrcweir 	sKeyword[NF_KEY_WW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"WW" ) );		// Week of year
95cdf0e10cSrcweir 	sKeyword[NF_KEY_CCC].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"CCC" ) );		// Currency abbreviation
96cdf0e10cSrcweir     bKeywordsNeedInit = sal_True;   // locale dependent keywords
97cdf0e10cSrcweir     bCompatCurNeedInit = sal_True;  // locale dependent compatibility currency strings
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	StandardColor[0]  =  Color(COL_BLACK);
100cdf0e10cSrcweir 	StandardColor[1]  =  Color(COL_LIGHTBLUE);
101cdf0e10cSrcweir 	StandardColor[2]  =  Color(COL_LIGHTGREEN);
102cdf0e10cSrcweir 	StandardColor[3]  =  Color(COL_LIGHTCYAN);
103cdf0e10cSrcweir 	StandardColor[4]  =  Color(COL_LIGHTRED);
104cdf0e10cSrcweir 	StandardColor[5]  =  Color(COL_LIGHTMAGENTA);
105cdf0e10cSrcweir 	StandardColor[6]  =  Color(COL_BROWN);
106cdf0e10cSrcweir 	StandardColor[7]  =  Color(COL_GRAY);
107cdf0e10cSrcweir 	StandardColor[8]  =  Color(COL_YELLOW);
108cdf0e10cSrcweir 	StandardColor[9]  =  Color(COL_WHITE);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	pNullDate = new Date(30,12,1899);
111cdf0e10cSrcweir 	nStandardPrec = 2;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	sErrStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "###" ) );
114cdf0e10cSrcweir 	Reset();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
~ImpSvNumberformatScan()117cdf0e10cSrcweir ImpSvNumberformatScan::~ImpSvNumberformatScan()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	delete pNullDate;
120cdf0e10cSrcweir 	Reset();
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
ChangeIntl()124cdf0e10cSrcweir void ImpSvNumberformatScan::ChangeIntl()
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     bKeywordsNeedInit = sal_True;
127cdf0e10cSrcweir     bCompatCurNeedInit = sal_True;
128cdf0e10cSrcweir     // may be initialized by InitSpecialKeyword()
129cdf0e10cSrcweir     sKeyword[NF_KEY_TRUE].Erase();
130cdf0e10cSrcweir     sKeyword[NF_KEY_FALSE].Erase();
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
InitSpecialKeyword(NfKeywordIndex eIdx) const134cdf0e10cSrcweir void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     switch ( eIdx )
137cdf0e10cSrcweir     {
138cdf0e10cSrcweir         case NF_KEY_TRUE :
139cdf0e10cSrcweir             ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE] =
140cdf0e10cSrcweir                 pFormatter->GetCharClass()->upper(
141cdf0e10cSrcweir                 pFormatter->GetLocaleData()->getTrueWord() );
142cdf0e10cSrcweir             if ( !sKeyword[NF_KEY_TRUE].Len() )
143cdf0e10cSrcweir             {
144cdf0e10cSrcweir                 DBG_ERRORFILE( "InitSpecialKeyword: TRUE_WORD?" );
145cdf0e10cSrcweir                 ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "sal_True" ) );
146cdf0e10cSrcweir             }
147cdf0e10cSrcweir         break;
148cdf0e10cSrcweir         case NF_KEY_FALSE :
149cdf0e10cSrcweir             ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE] =
150cdf0e10cSrcweir                 pFormatter->GetCharClass()->upper(
151cdf0e10cSrcweir                 pFormatter->GetLocaleData()->getFalseWord() );
152cdf0e10cSrcweir             if ( !sKeyword[NF_KEY_FALSE].Len() )
153cdf0e10cSrcweir             {
154cdf0e10cSrcweir                 DBG_ERRORFILE( "InitSpecialKeyword: FALSE_WORD?" );
155cdf0e10cSrcweir                 ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "sal_False" ) );
156cdf0e10cSrcweir             }
157cdf0e10cSrcweir         break;
158cdf0e10cSrcweir         default:
159cdf0e10cSrcweir             DBG_ERRORFILE( "InitSpecialKeyword: unknown request" );
160cdf0e10cSrcweir     }
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 
InitCompatCur() const164cdf0e10cSrcweir void ImpSvNumberformatScan::InitCompatCur() const
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     ImpSvNumberformatScan* pThis = (ImpSvNumberformatScan*)this;
167cdf0e10cSrcweir     // currency symbol for old style ("automatic") compatibility format codes
168cdf0e10cSrcweir     pFormatter->GetCompatibilityCurrency( pThis->sCurSymbol, pThis->sCurAbbrev );
169cdf0e10cSrcweir     // currency symbol upper case
170cdf0e10cSrcweir     pThis->sCurString = pFormatter->GetCharClass()->upper( sCurSymbol );
171cdf0e10cSrcweir     bCompatCurNeedInit = sal_False;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 
InitKeywords() const175cdf0e10cSrcweir void ImpSvNumberformatScan::InitKeywords() const
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     if ( !bKeywordsNeedInit )
178cdf0e10cSrcweir         return ;
179cdf0e10cSrcweir     ((ImpSvNumberformatScan*)this)->SetDependentKeywords();
180cdf0e10cSrcweir     bKeywordsNeedInit = sal_False;
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 
184cdf0e10cSrcweir /** Extract the name of General, Standard, Whatever, ignoring leading modifiers
185cdf0e10cSrcweir     such as [NatNum1]. */
lcl_extractStandardGeneralName(const::rtl::OUString & rCode)186cdf0e10cSrcweir static String lcl_extractStandardGeneralName( const ::rtl::OUString & rCode )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     String aStr;
189cdf0e10cSrcweir     const sal_Unicode* p = rCode.getStr();
190cdf0e10cSrcweir     const sal_Unicode* const pStop = p + rCode.getLength();
191cdf0e10cSrcweir     const sal_Unicode* pBeg = p;    // name begins here
192cdf0e10cSrcweir     bool bMod = false;
193cdf0e10cSrcweir     bool bDone = false;
194cdf0e10cSrcweir     while (p < pStop && !bDone)
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir         switch (*p)
197cdf0e10cSrcweir         {
198cdf0e10cSrcweir             case '[':
199cdf0e10cSrcweir                 bMod = true;
200cdf0e10cSrcweir                 break;
201cdf0e10cSrcweir             case ']':
202cdf0e10cSrcweir                 if (bMod)
203cdf0e10cSrcweir                 {
204cdf0e10cSrcweir                     bMod = false;
205cdf0e10cSrcweir                     pBeg = p+1;
206cdf0e10cSrcweir                 }
207cdf0e10cSrcweir                 // else: would be a locale data error, easily to be spotted in
208cdf0e10cSrcweir                 // UI dialog
209cdf0e10cSrcweir                 break;
210cdf0e10cSrcweir             case ';':
211cdf0e10cSrcweir                 if (!bMod)
212cdf0e10cSrcweir                 {
213cdf0e10cSrcweir                     bDone = true;
214cdf0e10cSrcweir                     --p;    // put back, increment by one follows
215cdf0e10cSrcweir                 }
216cdf0e10cSrcweir                 break;
217cdf0e10cSrcweir         }
218cdf0e10cSrcweir         ++p;
219cdf0e10cSrcweir         if (bMod)
220cdf0e10cSrcweir             pBeg = p;
221cdf0e10cSrcweir     }
222cdf0e10cSrcweir     if (pBeg < p)
223cdf0e10cSrcweir         aStr = rCode.copy( pBeg - rCode.getStr(), p - pBeg);
224cdf0e10cSrcweir     return aStr;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 
SetDependentKeywords()228cdf0e10cSrcweir void ImpSvNumberformatScan::SetDependentKeywords()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	using namespace ::com::sun::star;
231cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 	const CharClass* pCharClass = pFormatter->GetCharClass();
234cdf0e10cSrcweir 	const LocaleDataWrapper* pLocaleData = pFormatter->GetLocaleData();
235cdf0e10cSrcweir 	// #80023# be sure to generate keywords for the loaded Locale, not for the
236cdf0e10cSrcweir 	// requested Locale, otherwise number format codes might not match
237cdf0e10cSrcweir 	lang::Locale aLoadedLocale = pLocaleData->getLoadedLocale();
238cdf0e10cSrcweir 	LanguageType eLang = MsLangId::convertLocaleToLanguage( aLoadedLocale );
239cdf0e10cSrcweir 	NumberFormatCodeWrapper aNumberFormatCode( pFormatter->GetServiceManager(), aLoadedLocale );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     i18n::NumberFormatCode aFormat = aNumberFormatCode.getFormatCode( NF_NUMBER_STANDARD );
242cdf0e10cSrcweir 	sNameStandardFormat = lcl_extractStandardGeneralName( aFormat.Code);
243cdf0e10cSrcweir 	sKeyword[NF_KEY_GENERAL] = pCharClass->upper( sNameStandardFormat );
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	// preset new calendar keywords
246cdf0e10cSrcweir 	sKeyword[NF_KEY_AAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"AAA" ) );
247cdf0e10cSrcweir 	sKeyword[NF_KEY_AAAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"AAAA" ) );
248cdf0e10cSrcweir 	sKeyword[NF_KEY_EC].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"E" ) );
249cdf0e10cSrcweir 	sKeyword[NF_KEY_EEC].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"EE" ) );
250cdf0e10cSrcweir 	sKeyword[NF_KEY_G].AssignAscii( RTL_CONSTASCII_STRINGPARAM(		"G" ) );
251cdf0e10cSrcweir 	sKeyword[NF_KEY_GG].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"GG" ) );
252cdf0e10cSrcweir 	sKeyword[NF_KEY_GGG].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"GGG" ) );
253cdf0e10cSrcweir 	sKeyword[NF_KEY_R].AssignAscii( RTL_CONSTASCII_STRINGPARAM(		"R" ) );
254cdf0e10cSrcweir 	sKeyword[NF_KEY_RR].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"RR" ) );
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     // Thai T NatNum special. Other locale's small letter 't' results in upper
257cdf0e10cSrcweir     // case comparison not matching but length does in conversion mode. Ugly.
258cdf0e10cSrcweir     if (eLang == LANGUAGE_THAI)
259cdf0e10cSrcweir         sKeyword[NF_KEY_THAI_T].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T"));
260cdf0e10cSrcweir     else
261cdf0e10cSrcweir         sKeyword[NF_KEY_THAI_T].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "t"));
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 	switch ( eLang )
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir 		case LANGUAGE_GERMAN:
266cdf0e10cSrcweir 		case LANGUAGE_GERMAN_SWISS:
267cdf0e10cSrcweir 		case LANGUAGE_GERMAN_AUSTRIAN:
268cdf0e10cSrcweir 		case LANGUAGE_GERMAN_LUXEMBOURG:
269cdf0e10cSrcweir 		case LANGUAGE_GERMAN_LIECHTENSTEIN:
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir 			//! all capital letters
272cdf0e10cSrcweir 			sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"M" ) ); 			// month 1
273cdf0e10cSrcweir 			sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"MM" ) );			// month 01
274cdf0e10cSrcweir 			sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"MMM" ) );		// month Jan
275cdf0e10cSrcweir 			sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"MMMM" ) );	// month Januar
276cdf0e10cSrcweir 			sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"MMMMM" ) );// month J
277cdf0e10cSrcweir 			sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"H" ) ); 			// hour 2
278cdf0e10cSrcweir 			sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"HH" ) );			// hour 02
279cdf0e10cSrcweir 			sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"T" ) );
280cdf0e10cSrcweir 			sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"TT" ) );
281cdf0e10cSrcweir 			sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"TTT" ) );
282cdf0e10cSrcweir 			sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"TTTT" ) );
283cdf0e10cSrcweir 			sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"JJ" ) );
284cdf0e10cSrcweir 			sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"JJJJ" ) );
285cdf0e10cSrcweir 			sKeyword[NF_KEY_BOOLEAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"LOGISCH" ) );
286cdf0e10cSrcweir 			sKeyword[NF_KEY_COLOR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"FARBE" ) );
287cdf0e10cSrcweir 			sKeyword[NF_KEY_BLACK].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"SCHWARZ" ) );
288cdf0e10cSrcweir 			sKeyword[NF_KEY_BLUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"BLAU" ) );
289cdf0e10cSrcweir 			sKeyword[NF_KEY_GREEN] = UniString( "GR" "\xDC" "N", RTL_TEXTENCODING_ISO_8859_1 );
290cdf0e10cSrcweir 			sKeyword[NF_KEY_CYAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"CYAN" ) );
291cdf0e10cSrcweir 			sKeyword[NF_KEY_RED].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"ROT" ) );
292cdf0e10cSrcweir 			sKeyword[NF_KEY_MAGENTA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"MAGENTA" ) );
293cdf0e10cSrcweir 			sKeyword[NF_KEY_BROWN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"BRAUN" ) );
294cdf0e10cSrcweir 			sKeyword[NF_KEY_GREY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"GRAU" ) );
295cdf0e10cSrcweir 			sKeyword[NF_KEY_YELLOW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"GELB" ) );
296cdf0e10cSrcweir 			sKeyword[NF_KEY_WHITE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"WEISS" ) );
297cdf0e10cSrcweir 		}
298cdf0e10cSrcweir 		break;
299cdf0e10cSrcweir 		default:
300cdf0e10cSrcweir 		{
301cdf0e10cSrcweir 			// day
302cdf0e10cSrcweir 			switch ( eLang )
303cdf0e10cSrcweir 			{
304cdf0e10cSrcweir 				case LANGUAGE_ITALIAN       :
305cdf0e10cSrcweir 				case LANGUAGE_ITALIAN_SWISS :
306cdf0e10cSrcweir 					sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "G" ) );
307cdf0e10cSrcweir 					sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GG" ) );
308cdf0e10cSrcweir 					sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGG" ) );
309cdf0e10cSrcweir 					sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGGG" ) );
310cdf0e10cSrcweir 					// must exchange the era code, same as Xcl
311cdf0e10cSrcweir 					sKeyword[NF_KEY_G].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "X" ) );
312cdf0e10cSrcweir 					sKeyword[NF_KEY_GG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "XX" ) );
313cdf0e10cSrcweir 					sKeyword[NF_KEY_GGG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
314cdf0e10cSrcweir 				break;
315cdf0e10cSrcweir 				case LANGUAGE_FRENCH            :
316cdf0e10cSrcweir 				case LANGUAGE_FRENCH_BELGIAN    :
317cdf0e10cSrcweir 				case LANGUAGE_FRENCH_CANADIAN   :
318cdf0e10cSrcweir 				case LANGUAGE_FRENCH_SWISS      :
319cdf0e10cSrcweir 				case LANGUAGE_FRENCH_LUXEMBOURG :
320cdf0e10cSrcweir 				case LANGUAGE_FRENCH_MONACO		:
321cdf0e10cSrcweir 					sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "J" ) );
322cdf0e10cSrcweir 					sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
323cdf0e10cSrcweir 					sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJ" ) );
324cdf0e10cSrcweir 					sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
325cdf0e10cSrcweir 				break;
326cdf0e10cSrcweir 				case LANGUAGE_FINNISH :
327cdf0e10cSrcweir 					sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "P" ) );
328cdf0e10cSrcweir 					sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PP" ) );
329cdf0e10cSrcweir 					sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PPP" ) );
330cdf0e10cSrcweir 					sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PPPP" ) );
331cdf0e10cSrcweir 				break;
332cdf0e10cSrcweir 				default:
333cdf0e10cSrcweir 					sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D" ) );
334cdf0e10cSrcweir 					sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DD" ) );
335cdf0e10cSrcweir 					sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDD" ) );
336cdf0e10cSrcweir 					sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDDD" ) );
337cdf0e10cSrcweir 			}
338cdf0e10cSrcweir 			// month
339cdf0e10cSrcweir 			switch ( eLang )
340cdf0e10cSrcweir 			{
341cdf0e10cSrcweir 				case LANGUAGE_FINNISH :
342cdf0e10cSrcweir 					sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "K" ) );
343cdf0e10cSrcweir 					sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KK" ) );
344cdf0e10cSrcweir 					sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKK" ) );
345cdf0e10cSrcweir 					sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKKK" ) );
346cdf0e10cSrcweir 					sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKKKK" ) );
347cdf0e10cSrcweir 				break;
348cdf0e10cSrcweir 				default:
349cdf0e10cSrcweir 					sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "M" ) );
350cdf0e10cSrcweir 					sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MM" ) );
351cdf0e10cSrcweir 					sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMM" ) );
352cdf0e10cSrcweir 					sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMM" ) );
353cdf0e10cSrcweir 					sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMMM" ) );
354cdf0e10cSrcweir 			}
355cdf0e10cSrcweir 			// year
356cdf0e10cSrcweir 			switch ( eLang )
357cdf0e10cSrcweir 			{
358cdf0e10cSrcweir 				case LANGUAGE_ITALIAN       :
359cdf0e10cSrcweir 				case LANGUAGE_ITALIAN_SWISS :
360cdf0e10cSrcweir 				case LANGUAGE_FRENCH            :
361cdf0e10cSrcweir 				case LANGUAGE_FRENCH_BELGIAN    :
362cdf0e10cSrcweir 				case LANGUAGE_FRENCH_CANADIAN   :
363cdf0e10cSrcweir 				case LANGUAGE_FRENCH_SWISS      :
364cdf0e10cSrcweir 				case LANGUAGE_FRENCH_LUXEMBOURG :
365cdf0e10cSrcweir 				case LANGUAGE_FRENCH_MONACO		:
366cdf0e10cSrcweir 				case LANGUAGE_PORTUGUESE           :
367cdf0e10cSrcweir 				case LANGUAGE_PORTUGUESE_BRAZILIAN :
368cdf0e10cSrcweir 				case LANGUAGE_SPANISH_MODERN      :
369cdf0e10cSrcweir 				case LANGUAGE_SPANISH_DATED       :
370cdf0e10cSrcweir 				case LANGUAGE_SPANISH_MEXICAN     :
371cdf0e10cSrcweir 				case LANGUAGE_SPANISH_GUATEMALA   :
372cdf0e10cSrcweir 				case LANGUAGE_SPANISH_COSTARICA   :
373cdf0e10cSrcweir 				case LANGUAGE_SPANISH_PANAMA      :
374cdf0e10cSrcweir 				case LANGUAGE_SPANISH_DOMINICAN_REPUBLIC :
375cdf0e10cSrcweir 				case LANGUAGE_SPANISH_VENEZUELA   :
376cdf0e10cSrcweir 				case LANGUAGE_SPANISH_COLOMBIA    :
377cdf0e10cSrcweir 				case LANGUAGE_SPANISH_PERU        :
378cdf0e10cSrcweir 				case LANGUAGE_SPANISH_ARGENTINA   :
379cdf0e10cSrcweir 				case LANGUAGE_SPANISH_ECUADOR     :
380cdf0e10cSrcweir 				case LANGUAGE_SPANISH_CHILE       :
381cdf0e10cSrcweir 				case LANGUAGE_SPANISH_URUGUAY     :
382cdf0e10cSrcweir 				case LANGUAGE_SPANISH_PARAGUAY    :
383cdf0e10cSrcweir 				case LANGUAGE_SPANISH_BOLIVIA     :
384cdf0e10cSrcweir 				case LANGUAGE_SPANISH_EL_SALVADOR :
385cdf0e10cSrcweir 				case LANGUAGE_SPANISH_HONDURAS    :
386cdf0e10cSrcweir 				case LANGUAGE_SPANISH_NICARAGUA   :
387cdf0e10cSrcweir 				case LANGUAGE_SPANISH_PUERTO_RICO :
388cdf0e10cSrcweir 					sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AA" ) );
389cdf0e10cSrcweir 					sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AAAA" ) );
390cdf0e10cSrcweir 					// must exchange the day of week name code, same as Xcl
391cdf0e10cSrcweir 					sKeyword[NF_KEY_AAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"OOO" ) );
392cdf0e10cSrcweir 					sKeyword[NF_KEY_AAAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM(	"OOOO" ) );
393cdf0e10cSrcweir 				break;
394cdf0e10cSrcweir 				case LANGUAGE_DUTCH         :
395cdf0e10cSrcweir 				case LANGUAGE_DUTCH_BELGIAN :
396cdf0e10cSrcweir 					sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
397cdf0e10cSrcweir 					sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
398cdf0e10cSrcweir 				break;
399cdf0e10cSrcweir 				case LANGUAGE_FINNISH :
400cdf0e10cSrcweir 					sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "VV" ) );
401cdf0e10cSrcweir 					sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "VVVV" ) );
402cdf0e10cSrcweir 				break;
403cdf0e10cSrcweir 				default:
404cdf0e10cSrcweir 					sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YY" ) );
405cdf0e10cSrcweir 					sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YYYY" ) );
406cdf0e10cSrcweir 			}
407cdf0e10cSrcweir 			// hour
408cdf0e10cSrcweir 			switch ( eLang )
409cdf0e10cSrcweir 			{
410cdf0e10cSrcweir 				case LANGUAGE_DUTCH         :
411cdf0e10cSrcweir 				case LANGUAGE_DUTCH_BELGIAN :
412cdf0e10cSrcweir 					sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "U" ) );
413cdf0e10cSrcweir 					sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "UU" ) );
414cdf0e10cSrcweir 				break;
415cdf0e10cSrcweir 				case LANGUAGE_FINNISH :
416cdf0e10cSrcweir 				case LANGUAGE_SWEDISH         :
417cdf0e10cSrcweir 				case LANGUAGE_SWEDISH_FINLAND :
418cdf0e10cSrcweir 				case LANGUAGE_DANISH :
419cdf0e10cSrcweir 				case LANGUAGE_NORWEGIAN         :
420cdf0e10cSrcweir 				case LANGUAGE_NORWEGIAN_BOKMAL  :
421cdf0e10cSrcweir 				case LANGUAGE_NORWEGIAN_NYNORSK :
422cdf0e10cSrcweir 					sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T" ) );
423cdf0e10cSrcweir 					sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TT" ) );
424cdf0e10cSrcweir 				break;
425cdf0e10cSrcweir 				default:
426cdf0e10cSrcweir 					sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "H" ) );
427cdf0e10cSrcweir 					sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "HH" ) );
428cdf0e10cSrcweir 			}
429cdf0e10cSrcweir 			// boolean
430cdf0e10cSrcweir 			sKeyword[NF_KEY_BOOLEAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BOOLEAN" ) );
431cdf0e10cSrcweir 			// colours
432cdf0e10cSrcweir 			sKeyword[NF_KEY_COLOR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"COLOR" ) );
433cdf0e10cSrcweir 			sKeyword[NF_KEY_BLACK].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"BLACK" ) );
434cdf0e10cSrcweir 			sKeyword[NF_KEY_BLUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"BLUE" ) );
435cdf0e10cSrcweir 			sKeyword[NF_KEY_GREEN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"GREEN" ) );
436cdf0e10cSrcweir 			sKeyword[NF_KEY_CYAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"CYAN" ) );
437cdf0e10cSrcweir 			sKeyword[NF_KEY_RED].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"RED" ) );
438cdf0e10cSrcweir 			sKeyword[NF_KEY_MAGENTA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"MAGENTA" ) );
439cdf0e10cSrcweir 			sKeyword[NF_KEY_BROWN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"BROWN" ) );
440cdf0e10cSrcweir 			sKeyword[NF_KEY_GREY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 		"GREY" ) );
441cdf0e10cSrcweir 			sKeyword[NF_KEY_YELLOW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"YELLOW" ) );
442cdf0e10cSrcweir 			sKeyword[NF_KEY_WHITE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( 	"WHITE" ) );
443cdf0e10cSrcweir 		}
444cdf0e10cSrcweir 		break;
445cdf0e10cSrcweir 	}
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 	// boolean keyords
448cdf0e10cSrcweir     InitSpecialKeyword( NF_KEY_TRUE );
449cdf0e10cSrcweir     InitSpecialKeyword( NF_KEY_FALSE );
450cdf0e10cSrcweir 
451cdf0e10cSrcweir     // compatibility currency strings
452cdf0e10cSrcweir     InitCompatCur();
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 
ChangeNullDate(sal_uInt16 nDay,sal_uInt16 nMonth,sal_uInt16 nYear)456cdf0e10cSrcweir void ImpSvNumberformatScan::ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear)
457cdf0e10cSrcweir {
458cdf0e10cSrcweir 	if ( pNullDate )
459cdf0e10cSrcweir 		*pNullDate = Date(nDay, nMonth, nYear);
460cdf0e10cSrcweir 	else
461cdf0e10cSrcweir 		pNullDate = new Date(nDay, nMonth, nYear);
462cdf0e10cSrcweir }
463cdf0e10cSrcweir 
ChangeStandardPrec(sal_uInt16 nPrec)464cdf0e10cSrcweir void ImpSvNumberformatScan::ChangeStandardPrec(sal_uInt16 nPrec)
465cdf0e10cSrcweir {
466cdf0e10cSrcweir 	nStandardPrec = nPrec;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
GetColor(String & sStr)469cdf0e10cSrcweir Color* ImpSvNumberformatScan::GetColor(String& sStr)
470cdf0e10cSrcweir {
471cdf0e10cSrcweir 	String sString = pFormatter->GetCharClass()->upper(sStr);
472cdf0e10cSrcweir     const NfKeywordTable & rKeyword = GetKeywords();
473cdf0e10cSrcweir 	size_t i = 0;
474cdf0e10cSrcweir 	while (i < NF_MAX_DEFAULT_COLORS &&
475cdf0e10cSrcweir            sString != rKeyword[NF_KEY_FIRSTCOLOR+i] )
476cdf0e10cSrcweir 		i++;
477cdf0e10cSrcweir     if ( i >= NF_MAX_DEFAULT_COLORS )
478cdf0e10cSrcweir     {
479cdf0e10cSrcweir         const String* pEnglishColors = theEnglishColors::get();
480cdf0e10cSrcweir         size_t j = 0;
481cdf0e10cSrcweir         while ( j < NF_MAX_DEFAULT_COLORS &&
482cdf0e10cSrcweir                 sString != pEnglishColors[j] )
483cdf0e10cSrcweir             ++j;
484cdf0e10cSrcweir         if ( j < NF_MAX_DEFAULT_COLORS )
485cdf0e10cSrcweir             i = j;
486cdf0e10cSrcweir     }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir     Color* pResult = NULL;
489cdf0e10cSrcweir 	if (i >= NF_MAX_DEFAULT_COLORS)
490cdf0e10cSrcweir 	{
491cdf0e10cSrcweir         const String& rColorWord = rKeyword[NF_KEY_COLOR];
492cdf0e10cSrcweir 		xub_StrLen nPos = sString.Match(rColorWord);
493cdf0e10cSrcweir 		if (nPos > 0)
494cdf0e10cSrcweir 		{
495cdf0e10cSrcweir 			sStr.Erase(0, nPos);
496cdf0e10cSrcweir 			sStr.EraseLeadingChars();
497cdf0e10cSrcweir 			sStr.EraseTrailingChars();
498cdf0e10cSrcweir 			if (bConvertMode)
499cdf0e10cSrcweir 			{
500cdf0e10cSrcweir 				pFormatter->ChangeIntl(eNewLnge);
501cdf0e10cSrcweir                 sStr.Insert( GetKeywords()[NF_KEY_COLOR], 0 );  // Color -> FARBE
502cdf0e10cSrcweir 				pFormatter->ChangeIntl(eTmpLnge);
503cdf0e10cSrcweir 			}
504cdf0e10cSrcweir 			else
505cdf0e10cSrcweir 				sStr.Insert(rColorWord,0);
506cdf0e10cSrcweir 			sString.Erase(0, nPos);
507cdf0e10cSrcweir 			sString.EraseLeadingChars();
508cdf0e10cSrcweir 			sString.EraseTrailingChars();
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 			if ( CharClass::isAsciiNumeric( sString ) )
511cdf0e10cSrcweir 			{
512cdf0e10cSrcweir 				long nIndex = sString.ToInt32();
513cdf0e10cSrcweir 				if (nIndex > 0 && nIndex <= 64)
514cdf0e10cSrcweir 					pResult = pFormatter->GetUserDefColor((sal_uInt16)nIndex-1);
515cdf0e10cSrcweir 			}
516cdf0e10cSrcweir 		}
517cdf0e10cSrcweir 	}
518cdf0e10cSrcweir 	else
519cdf0e10cSrcweir 	{
520cdf0e10cSrcweir 		sStr.Erase();
521cdf0e10cSrcweir 		if (bConvertMode)
522cdf0e10cSrcweir 		{
523cdf0e10cSrcweir 			pFormatter->ChangeIntl(eNewLnge);
524cdf0e10cSrcweir             sStr = GetKeywords()[NF_KEY_FIRSTCOLOR+i];           // red -> rot
525cdf0e10cSrcweir 			pFormatter->ChangeIntl(eTmpLnge);
526cdf0e10cSrcweir 		}
527cdf0e10cSrcweir 		else
528cdf0e10cSrcweir             sStr = rKeyword[NF_KEY_FIRSTCOLOR+i];
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 		pResult = &(StandardColor[i]);
531cdf0e10cSrcweir 	}
532cdf0e10cSrcweir     return pResult;
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 
GetKeyWord(const String & sSymbol,xub_StrLen nPos)536cdf0e10cSrcweir short ImpSvNumberformatScan::GetKeyWord( const String& sSymbol, xub_StrLen nPos )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir 	String sString = pFormatter->GetCharClass()->toUpper( sSymbol, nPos, sSymbol.Len() - nPos );
539cdf0e10cSrcweir     const NfKeywordTable & rKeyword = GetKeywords();
540cdf0e10cSrcweir 	// #77026# for the Xcl perverts: the GENERAL keyword is recognized anywhere
541cdf0e10cSrcweir     if ( sString.Search( rKeyword[NF_KEY_GENERAL] ) == 0 )
542cdf0e10cSrcweir 		return NF_KEY_GENERAL;
543cdf0e10cSrcweir 	//! MUST be a reverse search to find longer strings first
544cdf0e10cSrcweir 	short i = NF_KEYWORD_ENTRIES_COUNT-1;
545cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
546cdf0e10cSrcweir     for ( ; i > NF_KEY_LASTKEYWORD_SO5; --i )
547cdf0e10cSrcweir     {
548cdf0e10cSrcweir         bFound = sString.Search(rKeyword[i]) == 0;
549cdf0e10cSrcweir         if ( bFound )
550cdf0e10cSrcweir         {
551cdf0e10cSrcweir             break;
552cdf0e10cSrcweir         }
553cdf0e10cSrcweir     }
554cdf0e10cSrcweir 	// new keywords take precedence over old keywords
555cdf0e10cSrcweir 	if ( !bFound )
556cdf0e10cSrcweir 	{	// skip the gap of colors et al between new and old keywords and search on
557cdf0e10cSrcweir 		i = NF_KEY_LASTKEYWORD;
558cdf0e10cSrcweir         while ( i > 0 && sString.Search(rKeyword[i]) != 0 )
559cdf0e10cSrcweir 			i--;
560cdf0e10cSrcweir         if ( i > NF_KEY_LASTOLDKEYWORD && sString != rKeyword[i] )
561cdf0e10cSrcweir 		{	// found something, but maybe it's something else?
562cdf0e10cSrcweir 			// e.g. new NNN is found in NNNN, for NNNN we must search on
563cdf0e10cSrcweir 			short j = i - 1;
564cdf0e10cSrcweir             while ( j > 0 && sString.Search(rKeyword[j]) != 0 )
565cdf0e10cSrcweir 				j--;
566cdf0e10cSrcweir             if ( j && rKeyword[j].Len() > rKeyword[i].Len() )
567cdf0e10cSrcweir 				return j;
568cdf0e10cSrcweir 		}
569cdf0e10cSrcweir 	}
570cdf0e10cSrcweir     // The Thai T NatNum modifier during Xcl import.
571cdf0e10cSrcweir     if (i == 0 && bConvertMode && sString.GetChar(0) == 'T' && eTmpLnge ==
572cdf0e10cSrcweir             LANGUAGE_ENGLISH_US && MsLangId::getRealLanguage( eNewLnge) ==
573cdf0e10cSrcweir             LANGUAGE_THAI)
574cdf0e10cSrcweir         i = NF_KEY_THAI_T;
575cdf0e10cSrcweir 	return i;		// 0 => not found
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir //---------------------------------------------------------------------------
579cdf0e10cSrcweir // Next_Symbol
580cdf0e10cSrcweir //---------------------------------------------------------------------------
581cdf0e10cSrcweir // Zerlegt die Eingabe in Symbole fuer die weitere
582cdf0e10cSrcweir // Verarbeitung (Turing-Maschine).
583cdf0e10cSrcweir //---------------------------------------------------------------------------
584cdf0e10cSrcweir // Ausgangs Zustand = SsStart
585cdf0e10cSrcweir //---------------+-------------------+-----------------------+---------------
586cdf0e10cSrcweir // Alter Zustand | gelesenes Zeichen | Aktion                | Neuer Zustand
587cdf0e10cSrcweir //---------------+-------------------+-----------------------+---------------
588cdf0e10cSrcweir // SsStart       | Buchstabe         | Symbol=Zeichen        | SsGetWord
589cdf0e10cSrcweir //               |    "              | Typ = String          | SsGetString
590cdf0e10cSrcweir //               |    \              | Typ = String          | SsGetChar
591cdf0e10cSrcweir //               |    *              | Typ = Star            | SsGetStar
592cdf0e10cSrcweir //               |    _              | Typ = Blank           | SsGetBlank
593cdf0e10cSrcweir //               | @ # 0 ? / . , % [ | Symbol = Zeichen;     |
594cdf0e10cSrcweir //               | ] ' Blank         | Typ = Steuerzeichen   | SsStop
595cdf0e10cSrcweir //               | $ - + ( ) :       | Typ    = String;      |
596cdf0e10cSrcweir //               | |                 | Typ    = Comment      | SsStop
597cdf0e10cSrcweir //               | Sonst             | Symbol = Zeichen      | SsStop
598cdf0e10cSrcweir //---------------|-------------------+-----------------------+---------------
599cdf0e10cSrcweir // SsGetChar     | Sonst             | Symbol=Zeichen        | SsStop
600cdf0e10cSrcweir //---------------+-------------------+-----------------------+---------------
601cdf0e10cSrcweir // GetString     | "                 |                       | SsStop
602cdf0e10cSrcweir //               | Sonst             | Symbol+=Zeichen       | GetString
603cdf0e10cSrcweir //---------------+-------------------+-----------------------+---------------
604cdf0e10cSrcweir // SsGetWord     | Buchstabe         | Symbol += Zeichen     |
605cdf0e10cSrcweir //               | + -        (E+ E-)| Symbol += Zeichen     | SsStop
606cdf0e10cSrcweir //               | /          (AM/PM)| Symbol += Zeichen     |
607cdf0e10cSrcweir //               | Sonst             | Pos--, if Key Typ=Word| SsStop
608cdf0e10cSrcweir //---------------+-------------------+-----------------------+---------------
609cdf0e10cSrcweir // SsGetStar     | Sonst             | Symbol+=Zeichen       | SsStop
610cdf0e10cSrcweir //               |                   | markiere Sonderfall * |
611cdf0e10cSrcweir //---------------+-------------------+-----------------------+---------------
612cdf0e10cSrcweir // SsGetBlank    | Sonst             | Symbol+=Zeichen       | SsStop
613cdf0e10cSrcweir //               |                   | markiere Sonderfall _ |
614cdf0e10cSrcweir //---------------+-------------------+-----------------------+---------------
615cdf0e10cSrcweir // Wurde im State SsGetWord ein Schluesselwort erkannt (auch als
616cdf0e10cSrcweir // Anfangsteilwort des Symbols)
617cdf0e10cSrcweir // so werden die restlichen Buchstaben zurueckgeschrieben !!
618cdf0e10cSrcweir 
619cdf0e10cSrcweir enum ScanState
620cdf0e10cSrcweir {
621cdf0e10cSrcweir 	SsStop      = 0,
622cdf0e10cSrcweir 	SsStart     = 1,
623cdf0e10cSrcweir 	SsGetChar   = 2,
624cdf0e10cSrcweir 	SsGetString = 3,
625cdf0e10cSrcweir 	SsGetWord   = 4,
626cdf0e10cSrcweir 	SsGetStar   = 5,
627cdf0e10cSrcweir 	SsGetBlank  = 6
628cdf0e10cSrcweir };
629cdf0e10cSrcweir 
Next_Symbol(const String & rStr,xub_StrLen & nPos,String & sSymbol)630cdf0e10cSrcweir short ImpSvNumberformatScan::Next_Symbol( const String& rStr,
631cdf0e10cSrcweir 			xub_StrLen& nPos, String& sSymbol )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir     if ( bKeywordsNeedInit )
634cdf0e10cSrcweir         InitKeywords();
635cdf0e10cSrcweir 	const CharClass* pChrCls = pFormatter->GetCharClass();
636cdf0e10cSrcweir 	const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
637cdf0e10cSrcweir 	const xub_StrLen nStart = nPos;
638cdf0e10cSrcweir 	short eType = 0;
639cdf0e10cSrcweir 	ScanState eState = SsStart;
640cdf0e10cSrcweir 	sSymbol.Erase();
641cdf0e10cSrcweir 	while ( nPos < rStr.Len() && eState != SsStop )
642cdf0e10cSrcweir 	{
643cdf0e10cSrcweir 		sal_Unicode cToken = rStr.GetChar( nPos++ );
644cdf0e10cSrcweir 		switch (eState)
645cdf0e10cSrcweir 		{
646cdf0e10cSrcweir 			case SsStart:
647cdf0e10cSrcweir 			{
648cdf0e10cSrcweir 				// Fetch any currency longer than one character and don't get
649cdf0e10cSrcweir 				// confused later on by "E/" or other combinations of letters
650cdf0e10cSrcweir                 // and meaningful symbols. Necessary for old automatic currency.
651cdf0e10cSrcweir                 // #96158# But don't do it if we're starting a "[...]" section,
652cdf0e10cSrcweir                 // for example a "[$...]" new currency symbol to not parse away
653cdf0e10cSrcweir                 // "$U" (symbol) of "[$UYU]" (abbreviation).
654cdf0e10cSrcweir                 if ( nCurrPos != STRING_NOTFOUND && sCurString.Len() > 1 &&
655cdf0e10cSrcweir                         nPos-1 + sCurString.Len() <= rStr.Len() &&
656cdf0e10cSrcweir                         !(nPos > 1 && rStr.GetChar( nPos-2 ) == '[') )
657cdf0e10cSrcweir 				{
658cdf0e10cSrcweir                     String aTest( rStr.Copy( nPos-1, sCurString.Len() ) );
659cdf0e10cSrcweir 					pChrCls->toUpper( aTest );
660cdf0e10cSrcweir                     if ( aTest == sCurString )
661cdf0e10cSrcweir 					{
662cdf0e10cSrcweir                         sSymbol = rStr.Copy( --nPos, sCurString.Len() );
663cdf0e10cSrcweir 						nPos = nPos + sSymbol.Len();
664cdf0e10cSrcweir 						eState = SsStop;
665cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_STRING;
666cdf0e10cSrcweir 						return eType;
667cdf0e10cSrcweir 					}
668cdf0e10cSrcweir 				}
669cdf0e10cSrcweir 				switch (cToken)
670cdf0e10cSrcweir 				{
671cdf0e10cSrcweir 					case '#':
672cdf0e10cSrcweir 					case '0':
673cdf0e10cSrcweir 					case '?':
674cdf0e10cSrcweir 					case '%':
675cdf0e10cSrcweir 					case '@':
676cdf0e10cSrcweir 					case '[':
677cdf0e10cSrcweir 					case ']':
678cdf0e10cSrcweir 					case ',':
679cdf0e10cSrcweir 					case '.':
680cdf0e10cSrcweir 					case '/':
681cdf0e10cSrcweir 					case '\'':
682cdf0e10cSrcweir 					case ' ':
683cdf0e10cSrcweir 					case ':':
684cdf0e10cSrcweir 					case '-':
685cdf0e10cSrcweir 					{
686cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_DEL;
687cdf0e10cSrcweir 						sSymbol += cToken;
688cdf0e10cSrcweir 						eState = SsStop;
689cdf0e10cSrcweir 					}
690cdf0e10cSrcweir 					break;
691cdf0e10cSrcweir 					case '*':
692cdf0e10cSrcweir 					{
693cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_STAR;
694cdf0e10cSrcweir 						sSymbol += cToken;
695cdf0e10cSrcweir 						eState = SsGetStar;
696cdf0e10cSrcweir 					}
697cdf0e10cSrcweir 					break;
698cdf0e10cSrcweir 					case '_':
699cdf0e10cSrcweir 					{
700cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_BLANK;
701cdf0e10cSrcweir 						sSymbol += cToken;
702cdf0e10cSrcweir 						eState = SsGetBlank;
703cdf0e10cSrcweir 					}
704cdf0e10cSrcweir 					break;
705cdf0e10cSrcweir #if NF_COMMENT_IN_FORMATSTRING
706cdf0e10cSrcweir 					case '{':
707cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_COMMENT;
708cdf0e10cSrcweir 						eState = SsStop;
709cdf0e10cSrcweir 						sSymbol.Append( rStr.GetBuffer() + (nPos-1), rStr.Len() - (nPos-1) );
710cdf0e10cSrcweir 						nPos = rStr.Len();
711cdf0e10cSrcweir 					break;
712cdf0e10cSrcweir #endif
713cdf0e10cSrcweir 					case '"':
714cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_STRING;
715cdf0e10cSrcweir 						eState = SsGetString;
716cdf0e10cSrcweir 						sSymbol += cToken;
717cdf0e10cSrcweir 					break;
718cdf0e10cSrcweir 					case '\\':
719cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_STRING;
720cdf0e10cSrcweir 						eState = SsGetChar;
721cdf0e10cSrcweir 						sSymbol += cToken;
722cdf0e10cSrcweir 					break;
723cdf0e10cSrcweir 					case '$':
724cdf0e10cSrcweir 					case '+':
725cdf0e10cSrcweir 					case '(':
726cdf0e10cSrcweir 					case ')':
727cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_STRING;
728cdf0e10cSrcweir 						eState = SsStop;
729cdf0e10cSrcweir 						sSymbol += cToken;
730cdf0e10cSrcweir 					break;
731cdf0e10cSrcweir 					default :
732cdf0e10cSrcweir 					{
733cdf0e10cSrcweir                         if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cToken) ||
734cdf0e10cSrcweir                                 StringEqualsChar( pFormatter->GetNumThousandSep(), cToken) ||
735cdf0e10cSrcweir                                 StringEqualsChar( pFormatter->GetDateSep(), cToken) ||
736cdf0e10cSrcweir                                 StringEqualsChar( pLoc->getTimeSep(), cToken) ||
737cdf0e10cSrcweir                                 StringEqualsChar( pLoc->getTime100SecSep(), cToken))
738cdf0e10cSrcweir                         {
739cdf0e10cSrcweir                             // Another separator than pre-known ASCII
740cdf0e10cSrcweir                             eType = NF_SYMBOLTYPE_DEL;
741cdf0e10cSrcweir                             sSymbol += cToken;
742cdf0e10cSrcweir                             eState = SsStop;
743cdf0e10cSrcweir                         }
744cdf0e10cSrcweir                         else if ( pChrCls->isLetter( rStr, nPos-1 ) )
745cdf0e10cSrcweir 						{
746cdf0e10cSrcweir 							short nTmpType = GetKeyWord( rStr, nPos-1 );
747cdf0e10cSrcweir 							if ( nTmpType )
748cdf0e10cSrcweir 							{
749cdf0e10cSrcweir 								sal_Bool bCurrency = sal_False;
750cdf0e10cSrcweir 								// "Automatic" currency may start with keyword,
751cdf0e10cSrcweir 								// like "R" (Rand) and 'R' (era)
752cdf0e10cSrcweir 								if ( nCurrPos != STRING_NOTFOUND &&
753cdf0e10cSrcweir                                     nPos-1 + sCurString.Len() <= rStr.Len() &&
754cdf0e10cSrcweir                                     sCurString.Search( sKeyword[nTmpType] ) == 0 )
755cdf0e10cSrcweir 								{
756cdf0e10cSrcweir                                     String aTest( rStr.Copy( nPos-1, sCurString.Len() ) );
757cdf0e10cSrcweir 									pChrCls->toUpper( aTest );
758cdf0e10cSrcweir                                     if ( aTest == sCurString )
759cdf0e10cSrcweir 										bCurrency = sal_True;
760cdf0e10cSrcweir 								}
761cdf0e10cSrcweir 								if ( bCurrency )
762cdf0e10cSrcweir 								{
763cdf0e10cSrcweir 									eState = SsGetWord;
764cdf0e10cSrcweir 									sSymbol += cToken;
765cdf0e10cSrcweir 								}
766cdf0e10cSrcweir 								else
767cdf0e10cSrcweir 								{
768cdf0e10cSrcweir 									eType = nTmpType;
769cdf0e10cSrcweir 									xub_StrLen nLen = sKeyword[eType].Len();
770cdf0e10cSrcweir 									sSymbol = rStr.Copy( nPos-1, nLen );
771cdf0e10cSrcweir 									if ( eType == NF_KEY_E || IsAmbiguousE( eType ) )
772cdf0e10cSrcweir 									{
773cdf0e10cSrcweir 										sal_Unicode cNext = rStr.GetChar(nPos);
774cdf0e10cSrcweir 										switch ( cNext )
775cdf0e10cSrcweir 										{
776cdf0e10cSrcweir 											case '+' :
777cdf0e10cSrcweir 											case '-' :	// E+ E- combine to one symbol
778cdf0e10cSrcweir 												sSymbol += cNext;
779cdf0e10cSrcweir 												eType = NF_KEY_E;
780cdf0e10cSrcweir 												nPos++;
781cdf0e10cSrcweir 											break;
782cdf0e10cSrcweir 											case '0' :
783cdf0e10cSrcweir 											case '#' :	// scientific E without sign
784cdf0e10cSrcweir 												eType = NF_KEY_E;
785cdf0e10cSrcweir 											break;
786cdf0e10cSrcweir 										}
787cdf0e10cSrcweir 									}
788cdf0e10cSrcweir 									nPos--;
789cdf0e10cSrcweir 									nPos = nPos + nLen;
790cdf0e10cSrcweir 									eState = SsStop;
791cdf0e10cSrcweir 								}
792cdf0e10cSrcweir 							}
793cdf0e10cSrcweir 							else
794cdf0e10cSrcweir 							{
795cdf0e10cSrcweir 								eState = SsGetWord;
796cdf0e10cSrcweir 								sSymbol += cToken;
797cdf0e10cSrcweir 							}
798cdf0e10cSrcweir 						}
799cdf0e10cSrcweir 						else
800cdf0e10cSrcweir 						{
801cdf0e10cSrcweir 							eType = NF_SYMBOLTYPE_STRING;
802cdf0e10cSrcweir 							eState = SsStop;
803cdf0e10cSrcweir 							sSymbol += cToken;
804cdf0e10cSrcweir 						}
805cdf0e10cSrcweir 					}
806cdf0e10cSrcweir 					break;
807cdf0e10cSrcweir 				}
808cdf0e10cSrcweir 			}
809cdf0e10cSrcweir 			break;
810cdf0e10cSrcweir 			case SsGetChar:
811cdf0e10cSrcweir 			{
812cdf0e10cSrcweir 				sSymbol += cToken;
813cdf0e10cSrcweir 				eState = SsStop;
814cdf0e10cSrcweir 			}
815cdf0e10cSrcweir 			break;
816cdf0e10cSrcweir 			case SsGetString:
817cdf0e10cSrcweir 			{
818cdf0e10cSrcweir 				if (cToken == '"')
819cdf0e10cSrcweir 					eState = SsStop;
820cdf0e10cSrcweir 				sSymbol += cToken;
821cdf0e10cSrcweir 			}
822cdf0e10cSrcweir 			break;
823cdf0e10cSrcweir 			case SsGetWord:
824cdf0e10cSrcweir 			{
825cdf0e10cSrcweir 				if ( pChrCls->isLetter( rStr, nPos-1 ) )
826cdf0e10cSrcweir 				{
827cdf0e10cSrcweir 					short nTmpType = GetKeyWord( rStr, nPos-1 );
828cdf0e10cSrcweir 					if ( nTmpType )
829cdf0e10cSrcweir 					{	// beginning of keyword, stop scan and put back
830cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_STRING;
831cdf0e10cSrcweir 						eState = SsStop;
832cdf0e10cSrcweir 						nPos--;
833cdf0e10cSrcweir 					}
834cdf0e10cSrcweir 					else
835cdf0e10cSrcweir 						sSymbol += cToken;
836cdf0e10cSrcweir 				}
837cdf0e10cSrcweir 				else
838cdf0e10cSrcweir 				{
839cdf0e10cSrcweir 					sal_Bool bDontStop = sal_False;
840cdf0e10cSrcweir 					switch (cToken)
841cdf0e10cSrcweir 					{
842cdf0e10cSrcweir 						case '/':						// AM/PM, A/P
843cdf0e10cSrcweir 						{
844cdf0e10cSrcweir 							sal_Unicode cNext = rStr.GetChar(nPos);
845cdf0e10cSrcweir 							if ( cNext == 'P' || cNext == 'p' )
846cdf0e10cSrcweir 							{
847cdf0e10cSrcweir 								xub_StrLen nLen = sSymbol.Len();
848cdf0e10cSrcweir 								if ( 1 <= nLen
849cdf0e10cSrcweir 										&& (sSymbol.GetChar(0) == 'A' || sSymbol.GetChar(0) == 'a')
850cdf0e10cSrcweir 										&& (nLen == 1 || (nLen == 2
851cdf0e10cSrcweir 											&& (sSymbol.GetChar(1) == 'M' || sSymbol.GetChar(1) == 'm')
852cdf0e10cSrcweir 											&& (rStr.GetChar(nPos+1) == 'M' || rStr.GetChar(nPos+1) == 'm'))) )
853cdf0e10cSrcweir 								{
854cdf0e10cSrcweir 									sSymbol += cToken;
855cdf0e10cSrcweir 									bDontStop = sal_True;
856cdf0e10cSrcweir 								}
857cdf0e10cSrcweir 							}
858cdf0e10cSrcweir 						}
859cdf0e10cSrcweir 						break;
860cdf0e10cSrcweir 					}
861cdf0e10cSrcweir 					// anything not recognized will stop the scan
862cdf0e10cSrcweir 					if ( eState != SsStop && !bDontStop )
863cdf0e10cSrcweir 					{
864cdf0e10cSrcweir 						eState = SsStop;
865cdf0e10cSrcweir 						nPos--;
866cdf0e10cSrcweir 						eType = NF_SYMBOLTYPE_STRING;
867cdf0e10cSrcweir 					}
868cdf0e10cSrcweir 				}
869cdf0e10cSrcweir 			}
870cdf0e10cSrcweir 			break;
871cdf0e10cSrcweir 			case SsGetStar:
872cdf0e10cSrcweir 			{
873cdf0e10cSrcweir 				eState = SsStop;
874cdf0e10cSrcweir 				sSymbol += cToken;
875*86e1cf34SPedro Giffuni 				nRepPos = (nPos - nStart) - 1;	// every time > 0!!
876cdf0e10cSrcweir 			}
877cdf0e10cSrcweir 			break;
878cdf0e10cSrcweir 			case SsGetBlank:
879cdf0e10cSrcweir 			{
880cdf0e10cSrcweir 				eState = SsStop;
881cdf0e10cSrcweir 				sSymbol += cToken;
882cdf0e10cSrcweir 			}
883cdf0e10cSrcweir 			break;
884cdf0e10cSrcweir 			default:
885cdf0e10cSrcweir 			break;
886cdf0e10cSrcweir 		}									// of switch
887cdf0e10cSrcweir 	} 										// of while
888cdf0e10cSrcweir 	if (eState == SsGetWord)
889cdf0e10cSrcweir 		eType = NF_SYMBOLTYPE_STRING;
890cdf0e10cSrcweir 	return eType;
891cdf0e10cSrcweir }
892cdf0e10cSrcweir 
Symbol_Division(const String & rString)893cdf0e10cSrcweir xub_StrLen ImpSvNumberformatScan::Symbol_Division(const String& rString)
894cdf0e10cSrcweir {
895cdf0e10cSrcweir 	nCurrPos = STRING_NOTFOUND;
896cdf0e10cSrcweir 													// Ist Waehrung im Spiel?
897cdf0e10cSrcweir 	String sString = pFormatter->GetCharClass()->upper(rString);
898cdf0e10cSrcweir 	xub_StrLen nCPos = 0;
899cdf0e10cSrcweir 	while (nCPos != STRING_NOTFOUND)
900cdf0e10cSrcweir 	{
901cdf0e10cSrcweir         nCPos = sString.Search(GetCurString(),nCPos);
902cdf0e10cSrcweir 		if (nCPos != STRING_NOTFOUND)
903cdf0e10cSrcweir 		{
904cdf0e10cSrcweir 			// in Quotes?
905cdf0e10cSrcweir 			xub_StrLen nQ = SvNumberformat::GetQuoteEnd( sString, nCPos );
906cdf0e10cSrcweir 			if ( nQ == STRING_NOTFOUND )
907cdf0e10cSrcweir 			{
908cdf0e10cSrcweir 				sal_Unicode c;
909cdf0e10cSrcweir 				if ( nCPos == 0 ||
910cdf0e10cSrcweir 					((c = sString.GetChar(xub_StrLen(nCPos-1))) != '"'
911cdf0e10cSrcweir 							&& c != '\\') )			// dm kann durch "dm
912cdf0e10cSrcweir 				{                   				// \d geschuetzt werden
913cdf0e10cSrcweir 					nCurrPos = nCPos;
914cdf0e10cSrcweir 					nCPos = STRING_NOTFOUND;		// Abbruch
915cdf0e10cSrcweir 				}
916cdf0e10cSrcweir 				else
917cdf0e10cSrcweir 					nCPos++;						// weitersuchen
918cdf0e10cSrcweir 			}
919cdf0e10cSrcweir 			else
920cdf0e10cSrcweir 				nCPos = nQ + 1;						// weitersuchen
921cdf0e10cSrcweir 		}
922cdf0e10cSrcweir 	}
923cdf0e10cSrcweir 	nAnzStrings = 0;
924cdf0e10cSrcweir 	sal_Bool bStar = sal_False;					// wird bei '*'Detektion gesetzt
925cdf0e10cSrcweir 	Reset();
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 	xub_StrLen nPos = 0;
928cdf0e10cSrcweir 	const xub_StrLen nLen = rString.Len();
929cdf0e10cSrcweir 	while (nPos < nLen && nAnzStrings < NF_MAX_FORMAT_SYMBOLS)
930cdf0e10cSrcweir 	{
931cdf0e10cSrcweir 		nTypeArray[nAnzStrings] = Next_Symbol(rString, nPos, sStrArray[nAnzStrings]);
932cdf0e10cSrcweir 		if (nTypeArray[nAnzStrings] == NF_SYMBOLTYPE_STAR)
933cdf0e10cSrcweir 		{								// Ueberwachung des '*'
934cdf0e10cSrcweir 			if (bStar)
935cdf0e10cSrcweir 				return nPos;		// Fehler: doppelter '*'
936cdf0e10cSrcweir 			else
937cdf0e10cSrcweir 				bStar = sal_True;
938cdf0e10cSrcweir 		}
939cdf0e10cSrcweir 		nAnzStrings++;
940cdf0e10cSrcweir 	}
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 	return 0;						// 0 => ok
943cdf0e10cSrcweir }
944cdf0e10cSrcweir 
SkipStrings(sal_uInt16 & i,xub_StrLen & nPos)945cdf0e10cSrcweir void ImpSvNumberformatScan::SkipStrings(sal_uInt16& i, xub_StrLen& nPos)
946cdf0e10cSrcweir {
947cdf0e10cSrcweir 	while (i < nAnzStrings && (   nTypeArray[i] == NF_SYMBOLTYPE_STRING
948cdf0e10cSrcweir 							   || nTypeArray[i] == NF_SYMBOLTYPE_BLANK
949cdf0e10cSrcweir 							   || nTypeArray[i] == NF_SYMBOLTYPE_STAR) )
950cdf0e10cSrcweir 	{
951cdf0e10cSrcweir 		nPos = nPos + sStrArray[i].Len();
952cdf0e10cSrcweir 		i++;
953cdf0e10cSrcweir 	}
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 
PreviousKeyword(sal_uInt16 i)957cdf0e10cSrcweir sal_uInt16 ImpSvNumberformatScan::PreviousKeyword(sal_uInt16 i)
958cdf0e10cSrcweir {
959cdf0e10cSrcweir 	short res = 0;
960cdf0e10cSrcweir 	if (i > 0 && i < nAnzStrings)
961cdf0e10cSrcweir 	{
962cdf0e10cSrcweir 		i--;
963cdf0e10cSrcweir 		while (i > 0 && nTypeArray[i] <= 0)
964cdf0e10cSrcweir 			i--;
965cdf0e10cSrcweir 		if (nTypeArray[i] > 0)
966cdf0e10cSrcweir 			res = nTypeArray[i];
967cdf0e10cSrcweir 	}
968cdf0e10cSrcweir 	return res;
969cdf0e10cSrcweir }
970cdf0e10cSrcweir 
NextKeyword(sal_uInt16 i)971cdf0e10cSrcweir sal_uInt16 ImpSvNumberformatScan::NextKeyword(sal_uInt16 i)
972cdf0e10cSrcweir {
973cdf0e10cSrcweir 	short res = 0;
974cdf0e10cSrcweir 	if (i < nAnzStrings-1)
975cdf0e10cSrcweir 	{
976cdf0e10cSrcweir 		i++;
977cdf0e10cSrcweir 		while (i < nAnzStrings-1 && nTypeArray[i] <= 0)
978cdf0e10cSrcweir 			i++;
979cdf0e10cSrcweir 		if (nTypeArray[i] > 0)
980cdf0e10cSrcweir 			res = nTypeArray[i];
981cdf0e10cSrcweir 	}
982cdf0e10cSrcweir 	return res;
983cdf0e10cSrcweir }
984cdf0e10cSrcweir 
PreviousType(sal_uInt16 i)985cdf0e10cSrcweir short ImpSvNumberformatScan::PreviousType( sal_uInt16 i )
986cdf0e10cSrcweir {
987cdf0e10cSrcweir 	if ( i > 0 && i < nAnzStrings )
988cdf0e10cSrcweir 	{
989cdf0e10cSrcweir 		do
990cdf0e10cSrcweir 		{
991cdf0e10cSrcweir 			i--;
992cdf0e10cSrcweir 		} while ( i > 0 && nTypeArray[i] == NF_SYMBOLTYPE_EMPTY );
993cdf0e10cSrcweir 		return nTypeArray[i];
994cdf0e10cSrcweir 	}
995cdf0e10cSrcweir 	return 0;
996cdf0e10cSrcweir }
997cdf0e10cSrcweir 
PreviousChar(sal_uInt16 i)998cdf0e10cSrcweir sal_Unicode ImpSvNumberformatScan::PreviousChar(sal_uInt16 i)
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir 	sal_Unicode res = ' ';
1001cdf0e10cSrcweir 	if (i > 0 && i < nAnzStrings)
1002cdf0e10cSrcweir 	{
1003cdf0e10cSrcweir 		i--;
1004cdf0e10cSrcweir 		while (i > 0 && ( 	nTypeArray[i] == NF_SYMBOLTYPE_EMPTY
1005cdf0e10cSrcweir 						 || nTypeArray[i] == NF_SYMBOLTYPE_STRING
1006cdf0e10cSrcweir 						 || nTypeArray[i] == NF_SYMBOLTYPE_STAR
1007cdf0e10cSrcweir 						 || nTypeArray[i] == NF_SYMBOLTYPE_BLANK ) )
1008cdf0e10cSrcweir 			i--;
1009cdf0e10cSrcweir 		if (sStrArray[i].Len() > 0)
1010cdf0e10cSrcweir 			res = sStrArray[i].GetChar(xub_StrLen(sStrArray[i].Len()-1));
1011cdf0e10cSrcweir 	}
1012cdf0e10cSrcweir 	return res;
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir 
NextChar(sal_uInt16 i)1015cdf0e10cSrcweir sal_Unicode ImpSvNumberformatScan::NextChar(sal_uInt16 i)
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir 	sal_Unicode res = ' ';
1018cdf0e10cSrcweir 	if (i < nAnzStrings-1)
1019cdf0e10cSrcweir 	{
1020cdf0e10cSrcweir 		i++;
1021cdf0e10cSrcweir 		while (i < nAnzStrings-1 &&
1022cdf0e10cSrcweir 			   (   nTypeArray[i] == NF_SYMBOLTYPE_EMPTY
1023cdf0e10cSrcweir 				|| nTypeArray[i] == NF_SYMBOLTYPE_STRING
1024cdf0e10cSrcweir 				|| nTypeArray[i] == NF_SYMBOLTYPE_STAR
1025cdf0e10cSrcweir 				|| nTypeArray[i] == NF_SYMBOLTYPE_BLANK))
1026cdf0e10cSrcweir 			i++;
1027cdf0e10cSrcweir 		if (sStrArray[i].Len() > 0)
1028cdf0e10cSrcweir 			res = sStrArray[i].GetChar(0);
1029cdf0e10cSrcweir 	}
1030cdf0e10cSrcweir 	return res;
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir 
IsLastBlankBeforeFrac(sal_uInt16 i)1033cdf0e10cSrcweir sal_Bool ImpSvNumberformatScan::IsLastBlankBeforeFrac(sal_uInt16 i)
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir 	sal_Bool res = sal_True;
1036cdf0e10cSrcweir 	if (i < nAnzStrings-1)
1037cdf0e10cSrcweir 	{
1038cdf0e10cSrcweir 		sal_Bool bStop = sal_False;
1039cdf0e10cSrcweir 		i++;
1040cdf0e10cSrcweir 		while (i < nAnzStrings-1 && !bStop)
1041cdf0e10cSrcweir 		{
1042cdf0e10cSrcweir 			i++;
1043cdf0e10cSrcweir 			if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
1044cdf0e10cSrcweir 					sStrArray[i].GetChar(0) == '/')
1045cdf0e10cSrcweir 				bStop = sal_True;
1046cdf0e10cSrcweir 			else if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
1047cdf0e10cSrcweir 					sStrArray[i].GetChar(0) == ' ')
1048cdf0e10cSrcweir 				res = sal_False;
1049cdf0e10cSrcweir 		}
1050cdf0e10cSrcweir 		if (!bStop)									// kein '/'
1051cdf0e10cSrcweir 			res = sal_False;
1052cdf0e10cSrcweir 	}
1053cdf0e10cSrcweir 	else
1054cdf0e10cSrcweir 		res = sal_False;								// kein '/' mehr
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 	return res;
1057cdf0e10cSrcweir }
1058cdf0e10cSrcweir 
Reset()1059cdf0e10cSrcweir void ImpSvNumberformatScan::Reset()
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir 	nAnzStrings = 0;
1062cdf0e10cSrcweir 	nAnzResStrings = 0;
1063cdf0e10cSrcweir #if 0
1064cdf0e10cSrcweir // ER 20.06.97 14:05   nicht noetig, wenn nAnzStrings beachtet wird
1065cdf0e10cSrcweir 	for (size_t i = 0; i < NF_MAX_FORMAT_SYMBOLS; i++)
1066cdf0e10cSrcweir 	{
1067cdf0e10cSrcweir 		sStrArray[i].Erase();
1068cdf0e10cSrcweir 		nTypeArray[i] = 0;
1069cdf0e10cSrcweir 	}
1070cdf0e10cSrcweir #endif
1071cdf0e10cSrcweir 	eScannedType = NUMBERFORMAT_UNDEFINED;
1072cdf0e10cSrcweir 	nRepPos = 0;
1073cdf0e10cSrcweir 	bExp = sal_False;
1074cdf0e10cSrcweir 	bThousand = sal_False;
1075cdf0e10cSrcweir 	nThousand = 0;
1076cdf0e10cSrcweir 	bDecSep = sal_False;
1077cdf0e10cSrcweir 	nDecPos =  -1;
1078cdf0e10cSrcweir 	nExpPos = (sal_uInt16) -1;
1079cdf0e10cSrcweir 	nBlankPos = (sal_uInt16) -1;
1080cdf0e10cSrcweir 	nCntPre = 0;
1081cdf0e10cSrcweir 	nCntPost = 0;
1082cdf0e10cSrcweir 	nCntExp = 0;
1083cdf0e10cSrcweir 	bFrac = sal_False;
1084cdf0e10cSrcweir 	bBlank = sal_False;
1085cdf0e10cSrcweir     nNatNumModifier = 0;
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir 
Is100SecZero(sal_uInt16 i,sal_Bool bHadDecSep)1089cdf0e10cSrcweir sal_Bool ImpSvNumberformatScan::Is100SecZero( sal_uInt16 i, sal_Bool bHadDecSep )
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir     sal_uInt16 nIndexPre = PreviousKeyword( i );
1092cdf0e10cSrcweir     return (nIndexPre == NF_KEY_S || nIndexPre == NF_KEY_SS)
1093cdf0e10cSrcweir             && (bHadDecSep                 // S, SS ','
1094cdf0e10cSrcweir             || (i>0 && nTypeArray[i-1] == NF_SYMBOLTYPE_STRING));
1095cdf0e10cSrcweir                 // SS"any"00  take "any" as a valid decimal separator
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 
ScanType(const String &)1099cdf0e10cSrcweir xub_StrLen ImpSvNumberformatScan::ScanType(const String&)
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir 	const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 	xub_StrLen nPos = 0;
1104cdf0e10cSrcweir     sal_uInt16 i = 0;
1105cdf0e10cSrcweir     short eNewType;
1106cdf0e10cSrcweir     sal_Bool bMatchBracket = sal_False;
1107cdf0e10cSrcweir     bool bHaveGeneral = false;      // if General/Standard encountered
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir     SkipStrings(i, nPos);
1110cdf0e10cSrcweir 	while (i < nAnzStrings)
1111cdf0e10cSrcweir 	{
1112cdf0e10cSrcweir         if (nTypeArray[i] > 0)
1113cdf0e10cSrcweir         {                                       // keyword
1114cdf0e10cSrcweir 			switch (nTypeArray[i])
1115cdf0e10cSrcweir 			{
1116cdf0e10cSrcweir 				case NF_KEY_E:			 				// E
1117cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_SCIENTIFIC;
1118cdf0e10cSrcweir 				break;
1119cdf0e10cSrcweir 				case NF_KEY_AMPM:		 				// AM,A,PM,P
1120cdf0e10cSrcweir 				case NF_KEY_AP:
1121cdf0e10cSrcweir 				case NF_KEY_H:							// H
1122cdf0e10cSrcweir 				case NF_KEY_HH:							// HH
1123cdf0e10cSrcweir 				case NF_KEY_S:							// S
1124cdf0e10cSrcweir 				case NF_KEY_SS:							// SS
1125cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_TIME;
1126cdf0e10cSrcweir 				break;
1127cdf0e10cSrcweir 				case NF_KEY_M:			 				// M
1128cdf0e10cSrcweir 				case NF_KEY_MM:			 				// MM
1129cdf0e10cSrcweir                 {                                       // minute or month
1130cdf0e10cSrcweir 					sal_uInt16 nIndexPre = PreviousKeyword(i);
1131cdf0e10cSrcweir 					sal_uInt16 nIndexNex = NextKeyword(i);
1132cdf0e10cSrcweir 					sal_Unicode cChar = PreviousChar(i);
1133cdf0e10cSrcweir 					if (nIndexPre == NF_KEY_H	|| 	// H
1134cdf0e10cSrcweir 						nIndexPre == NF_KEY_HH	|| 	// HH
1135cdf0e10cSrcweir 						nIndexNex == NF_KEY_S	|| 	// S
1136cdf0e10cSrcweir 						nIndexNex == NF_KEY_SS	||  // SS
1137cdf0e10cSrcweir 						cChar == '['  )     // [M
1138cdf0e10cSrcweir 					{
1139cdf0e10cSrcweir 						eNewType = NUMBERFORMAT_TIME;
1140cdf0e10cSrcweir 						nTypeArray[i] -= 2;			// 6 -> 4, 7 -> 5
1141cdf0e10cSrcweir 					}
1142cdf0e10cSrcweir 					else
1143cdf0e10cSrcweir 						eNewType = NUMBERFORMAT_DATE;
1144cdf0e10cSrcweir 				}
1145cdf0e10cSrcweir 				break;
1146cdf0e10cSrcweir 				case NF_KEY_MMM:				// MMM
1147cdf0e10cSrcweir 				case NF_KEY_MMMM:				// MMMM
1148cdf0e10cSrcweir 				case NF_KEY_MMMMM:				// MMMMM
1149cdf0e10cSrcweir 				case NF_KEY_Q:					// Q
1150cdf0e10cSrcweir 				case NF_KEY_QQ:					// QQ
1151cdf0e10cSrcweir 				case NF_KEY_D:					// D
1152cdf0e10cSrcweir 				case NF_KEY_DD:					// DD
1153cdf0e10cSrcweir 				case NF_KEY_DDD:				// DDD
1154cdf0e10cSrcweir 				case NF_KEY_DDDD:				// DDDD
1155cdf0e10cSrcweir 				case NF_KEY_YY:					// YY
1156cdf0e10cSrcweir 				case NF_KEY_YYYY:				// YYYY
1157cdf0e10cSrcweir 				case NF_KEY_NN:					// NN
1158cdf0e10cSrcweir 				case NF_KEY_NNN:				// NNN
1159cdf0e10cSrcweir 				case NF_KEY_NNNN:				// NNNN
1160cdf0e10cSrcweir 				case NF_KEY_WW :				// WW
1161cdf0e10cSrcweir 				case NF_KEY_AAA :				// AAA
1162cdf0e10cSrcweir 				case NF_KEY_AAAA :				// AAAA
1163cdf0e10cSrcweir 				case NF_KEY_EC :				// E
1164cdf0e10cSrcweir 				case NF_KEY_EEC :				// EE
1165cdf0e10cSrcweir 				case NF_KEY_G :					// G
1166cdf0e10cSrcweir 				case NF_KEY_GG :				// GG
1167cdf0e10cSrcweir 				case NF_KEY_GGG :				// GGG
1168cdf0e10cSrcweir 				case NF_KEY_R :					// R
1169cdf0e10cSrcweir 				case NF_KEY_RR :				// RR
1170cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_DATE;
1171cdf0e10cSrcweir 				break;
1172cdf0e10cSrcweir 				case NF_KEY_CCC:				// CCC
1173cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_CURRENCY;
1174cdf0e10cSrcweir 				break;
1175cdf0e10cSrcweir 				case NF_KEY_GENERAL:			// Standard
1176cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_NUMBER;
1177cdf0e10cSrcweir                     bHaveGeneral = true;
1178cdf0e10cSrcweir 				break;
1179cdf0e10cSrcweir 				default:
1180cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_UNDEFINED;
1181cdf0e10cSrcweir 				break;
1182cdf0e10cSrcweir 			}
1183cdf0e10cSrcweir 		}
1184cdf0e10cSrcweir         else
1185cdf0e10cSrcweir         {                                       // control character
1186cdf0e10cSrcweir 			switch ( sStrArray[i].GetChar(0) )
1187cdf0e10cSrcweir 			{
1188cdf0e10cSrcweir 				case '#':
1189cdf0e10cSrcweir 				case '?':
1190cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_NUMBER;
1191cdf0e10cSrcweir 				break;
1192cdf0e10cSrcweir 				case '0':
1193cdf0e10cSrcweir 				{
1194cdf0e10cSrcweir                     if ( (eScannedType & NUMBERFORMAT_TIME) == NUMBERFORMAT_TIME )
1195cdf0e10cSrcweir 					{
1196cdf0e10cSrcweir                         if ( Is100SecZero( i, bDecSep ) )
1197cdf0e10cSrcweir                         {
1198cdf0e10cSrcweir                             bDecSep = sal_True;                 // subsequent 0's
1199cdf0e10cSrcweir 							eNewType = NUMBERFORMAT_TIME;
1200cdf0e10cSrcweir                         }
1201cdf0e10cSrcweir 						else
1202cdf0e10cSrcweir                             return nPos;                    // Error
1203cdf0e10cSrcweir 					}
1204cdf0e10cSrcweir 					else
1205cdf0e10cSrcweir 						eNewType = NUMBERFORMAT_NUMBER;
1206cdf0e10cSrcweir 				}
1207cdf0e10cSrcweir 				break;
1208cdf0e10cSrcweir 				case '%':
1209cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_PERCENT;
1210cdf0e10cSrcweir 				break;
1211cdf0e10cSrcweir 				case '/':
1212cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_FRACTION;
1213cdf0e10cSrcweir 				break;
1214cdf0e10cSrcweir 				case '[':
1215cdf0e10cSrcweir 				{
1216cdf0e10cSrcweir 					if ( i < nAnzStrings-1 &&
1217cdf0e10cSrcweir 							nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
1218cdf0e10cSrcweir 							sStrArray[i+1].GetChar(0) == '$' )
1219cdf0e10cSrcweir 					{	// as of SV_NUMBERFORMATTER_VERSION_NEW_CURR
1220cdf0e10cSrcweir 						eNewType = NUMBERFORMAT_CURRENCY;
1221cdf0e10cSrcweir                         bMatchBracket = sal_True;
1222cdf0e10cSrcweir 					}
1223cdf0e10cSrcweir 					else if ( i < nAnzStrings-1 &&
1224cdf0e10cSrcweir 							nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
1225cdf0e10cSrcweir 							sStrArray[i+1].GetChar(0) == '~' )
1226cdf0e10cSrcweir 					{	// as of SV_NUMBERFORMATTER_VERSION_CALENDAR
1227cdf0e10cSrcweir 						eNewType = NUMBERFORMAT_DATE;
1228cdf0e10cSrcweir                         bMatchBracket = sal_True;
1229cdf0e10cSrcweir 					}
1230cdf0e10cSrcweir 					else
1231cdf0e10cSrcweir 					{
1232cdf0e10cSrcweir 						sal_uInt16 nIndexNex = NextKeyword(i);
1233cdf0e10cSrcweir 						if (nIndexNex == NF_KEY_H	|| 	// H
1234cdf0e10cSrcweir 							nIndexNex == NF_KEY_HH	|| 	// HH
1235cdf0e10cSrcweir 							nIndexNex == NF_KEY_M	|| 	// M
1236cdf0e10cSrcweir 							nIndexNex == NF_KEY_MM	|| 	// MM
1237cdf0e10cSrcweir 							nIndexNex == NF_KEY_S	|| 	// S
1238cdf0e10cSrcweir 							nIndexNex == NF_KEY_SS   )	// SS
1239cdf0e10cSrcweir 							eNewType = NUMBERFORMAT_TIME;
1240cdf0e10cSrcweir 						else
1241cdf0e10cSrcweir                             return nPos;                // Error
1242cdf0e10cSrcweir 					}
1243cdf0e10cSrcweir 				}
1244cdf0e10cSrcweir 				break;
1245cdf0e10cSrcweir 				case '@':
1246cdf0e10cSrcweir 					eNewType = NUMBERFORMAT_TEXT;
1247cdf0e10cSrcweir 				break;
1248cdf0e10cSrcweir 				default:
1249cdf0e10cSrcweir                     if ( sStrArray[i] == pLoc->getTime100SecSep() )
1250cdf0e10cSrcweir                         bDecSep = sal_True;                     // for SS,0
1251cdf0e10cSrcweir                     eNewType = NUMBERFORMAT_UNDEFINED;
1252cdf0e10cSrcweir 				break;
1253cdf0e10cSrcweir 			}
1254cdf0e10cSrcweir 		}
1255cdf0e10cSrcweir 		if (eScannedType == NUMBERFORMAT_UNDEFINED)
1256cdf0e10cSrcweir 			eScannedType = eNewType;
1257cdf0e10cSrcweir 		else if (eScannedType == NUMBERFORMAT_TEXT || eNewType == NUMBERFORMAT_TEXT)
1258cdf0e10cSrcweir 			eScannedType = NUMBERFORMAT_TEXT;				// Text bleibt immer Text
1259cdf0e10cSrcweir 		else if (eNewType == NUMBERFORMAT_UNDEFINED)
1260cdf0e10cSrcweir 		{											// bleibt wie bisher
1261cdf0e10cSrcweir 		}
1262cdf0e10cSrcweir 		else if (eScannedType != eNewType)
1263cdf0e10cSrcweir 		{
1264cdf0e10cSrcweir 			switch (eScannedType)
1265cdf0e10cSrcweir 			{
1266cdf0e10cSrcweir 				case NUMBERFORMAT_DATE:
1267cdf0e10cSrcweir 				{
1268cdf0e10cSrcweir 					switch (eNewType)
1269cdf0e10cSrcweir 					{
1270cdf0e10cSrcweir 						case NUMBERFORMAT_TIME:
1271cdf0e10cSrcweir 							eScannedType = NUMBERFORMAT_DATETIME;
1272cdf0e10cSrcweir 						break;
1273cdf0e10cSrcweir 						case NUMBERFORMAT_FRACTION: 		// DD/MM
1274cdf0e10cSrcweir 						break;
1275cdf0e10cSrcweir 						default:
1276cdf0e10cSrcweir 						{
1277cdf0e10cSrcweir 							if (nCurrPos != STRING_NOTFOUND)
1278cdf0e10cSrcweir 								eScannedType = NUMBERFORMAT_UNDEFINED;
1279cdf0e10cSrcweir                             else if ( sStrArray[i] != pFormatter->GetDateSep() )
1280cdf0e10cSrcweir 								return nPos;
1281cdf0e10cSrcweir 						}
1282cdf0e10cSrcweir 					}
1283cdf0e10cSrcweir 				}
1284cdf0e10cSrcweir 				break;
1285cdf0e10cSrcweir 				case NUMBERFORMAT_TIME:
1286cdf0e10cSrcweir 				{
1287cdf0e10cSrcweir 					switch (eNewType)
1288cdf0e10cSrcweir 					{
1289cdf0e10cSrcweir 						case NUMBERFORMAT_DATE:
1290cdf0e10cSrcweir 							eScannedType = NUMBERFORMAT_DATETIME;
1291cdf0e10cSrcweir 						break;
1292cdf0e10cSrcweir 						case NUMBERFORMAT_FRACTION: 		// MM/SS
1293cdf0e10cSrcweir 						break;
1294cdf0e10cSrcweir 						default:
1295cdf0e10cSrcweir 						{
1296cdf0e10cSrcweir 							if (nCurrPos != STRING_NOTFOUND)
1297cdf0e10cSrcweir 								eScannedType = NUMBERFORMAT_UNDEFINED;
1298cdf0e10cSrcweir 							else if ( sStrArray[i] != pLoc->getTimeSep() )
1299cdf0e10cSrcweir 								return nPos;
1300cdf0e10cSrcweir 						}
1301cdf0e10cSrcweir 					}
1302cdf0e10cSrcweir 				}
1303cdf0e10cSrcweir 				break;
1304cdf0e10cSrcweir 				case NUMBERFORMAT_DATETIME:
1305cdf0e10cSrcweir 				{
1306cdf0e10cSrcweir 					switch (eNewType)
1307cdf0e10cSrcweir 					{
1308cdf0e10cSrcweir 						case NUMBERFORMAT_TIME:
1309cdf0e10cSrcweir 						case NUMBERFORMAT_DATE:
1310cdf0e10cSrcweir 						break;
1311cdf0e10cSrcweir 						case NUMBERFORMAT_FRACTION: 		// DD/MM
1312cdf0e10cSrcweir 						break;
1313cdf0e10cSrcweir 						default:
1314cdf0e10cSrcweir 						{
1315cdf0e10cSrcweir 							if (nCurrPos != STRING_NOTFOUND)
1316cdf0e10cSrcweir 								eScannedType = NUMBERFORMAT_UNDEFINED;
1317cdf0e10cSrcweir                             else if ( sStrArray[i] != pFormatter->GetDateSep()
1318cdf0e10cSrcweir 								   && sStrArray[i] != pLoc->getTimeSep() )
1319cdf0e10cSrcweir 								return nPos;
1320cdf0e10cSrcweir 						}
1321cdf0e10cSrcweir 					}
1322cdf0e10cSrcweir 				}
1323cdf0e10cSrcweir 				break;
1324cdf0e10cSrcweir 				case NUMBERFORMAT_PERCENT:
1325cdf0e10cSrcweir 				{
1326cdf0e10cSrcweir 					switch (eNewType)
1327cdf0e10cSrcweir 					{
1328cdf0e10cSrcweir 						case NUMBERFORMAT_NUMBER:	// nur Zahl nach Prozent
1329cdf0e10cSrcweir 						break;
1330cdf0e10cSrcweir 						default:
1331cdf0e10cSrcweir 							return nPos;
1332cdf0e10cSrcweir 					}
1333cdf0e10cSrcweir 				}
1334cdf0e10cSrcweir 				break;
1335cdf0e10cSrcweir 				case NUMBERFORMAT_SCIENTIFIC:
1336cdf0e10cSrcweir 				{
1337cdf0e10cSrcweir 					switch (eNewType)
1338cdf0e10cSrcweir 					{
1339cdf0e10cSrcweir 						case NUMBERFORMAT_NUMBER:	// nur Zahl nach E
1340cdf0e10cSrcweir 						break;
1341cdf0e10cSrcweir 						default:
1342cdf0e10cSrcweir 							return nPos;
1343cdf0e10cSrcweir 					}
1344cdf0e10cSrcweir 				}
1345cdf0e10cSrcweir 				break;
1346cdf0e10cSrcweir 				case NUMBERFORMAT_NUMBER:
1347cdf0e10cSrcweir 				{
1348cdf0e10cSrcweir 					switch (eNewType)
1349cdf0e10cSrcweir 					{
1350cdf0e10cSrcweir 						case NUMBERFORMAT_SCIENTIFIC:
1351cdf0e10cSrcweir 						case NUMBERFORMAT_PERCENT:
1352cdf0e10cSrcweir 						case NUMBERFORMAT_FRACTION:
1353cdf0e10cSrcweir 						case NUMBERFORMAT_CURRENCY:
1354cdf0e10cSrcweir 							eScannedType = eNewType;
1355cdf0e10cSrcweir 						break;
1356cdf0e10cSrcweir 						default:
1357cdf0e10cSrcweir 							if (nCurrPos != STRING_NOTFOUND)
1358cdf0e10cSrcweir 								eScannedType = NUMBERFORMAT_UNDEFINED;
1359cdf0e10cSrcweir 							else
1360cdf0e10cSrcweir 								return nPos;
1361cdf0e10cSrcweir 					}
1362cdf0e10cSrcweir 				}
1363cdf0e10cSrcweir 				break;
1364cdf0e10cSrcweir 				case NUMBERFORMAT_FRACTION:
1365cdf0e10cSrcweir 				{
1366cdf0e10cSrcweir 					switch (eNewType)
1367cdf0e10cSrcweir 					{
1368cdf0e10cSrcweir 						case NUMBERFORMAT_NUMBER:			// nur Zahl nach Bruch
1369cdf0e10cSrcweir 						break;
1370cdf0e10cSrcweir 						default:
1371cdf0e10cSrcweir 							return nPos;
1372cdf0e10cSrcweir 					}
1373cdf0e10cSrcweir 				}
1374cdf0e10cSrcweir 				break;
1375cdf0e10cSrcweir 				default:
1376cdf0e10cSrcweir 				break;
1377cdf0e10cSrcweir 			}
1378cdf0e10cSrcweir 		}
1379cdf0e10cSrcweir 		nPos = nPos + sStrArray[i].Len();			// Korrekturposition
1380cdf0e10cSrcweir 		i++;
1381cdf0e10cSrcweir         if ( bMatchBracket )
1382cdf0e10cSrcweir         {   // no type detection inside of matching brackets if [$...], [~...]
1383cdf0e10cSrcweir             while ( bMatchBracket && i < nAnzStrings )
1384cdf0e10cSrcweir             {
1385cdf0e10cSrcweir                 if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL
1386cdf0e10cSrcweir                         && sStrArray[i].GetChar(0) == ']' )
1387cdf0e10cSrcweir                     bMatchBracket = sal_False;
1388cdf0e10cSrcweir                 else
1389cdf0e10cSrcweir                     nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1390cdf0e10cSrcweir                 nPos = nPos + sStrArray[i].Len();
1391cdf0e10cSrcweir                 i++;
1392cdf0e10cSrcweir             }
1393cdf0e10cSrcweir             if ( bMatchBracket )
1394cdf0e10cSrcweir                 return nPos;    // missing closing bracket at end of code
1395cdf0e10cSrcweir         }
1396cdf0e10cSrcweir 		SkipStrings(i, nPos);
1397cdf0e10cSrcweir 	}
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir 	if ((eScannedType == NUMBERFORMAT_NUMBER || eScannedType == NUMBERFORMAT_UNDEFINED)
1400cdf0e10cSrcweir 		 && nCurrPos != STRING_NOTFOUND && !bHaveGeneral)
1401cdf0e10cSrcweir 		eScannedType = NUMBERFORMAT_CURRENCY;	// old "automatic" currency
1402cdf0e10cSrcweir 	if (eScannedType == NUMBERFORMAT_UNDEFINED)
1403cdf0e10cSrcweir 		eScannedType = NUMBERFORMAT_DEFINED;
1404cdf0e10cSrcweir 	return 0;								// Alles ok
1405cdf0e10cSrcweir }
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 
InsertSymbol(sal_uInt16 & nPos,svt::NfSymbolType eType,const String & rStr)1408cdf0e10cSrcweir bool ImpSvNumberformatScan::InsertSymbol( sal_uInt16 & nPos, svt::NfSymbolType eType, const String& rStr )
1409cdf0e10cSrcweir {
1410cdf0e10cSrcweir     if (nAnzStrings >= NF_MAX_FORMAT_SYMBOLS || nPos > nAnzStrings)
1411cdf0e10cSrcweir         return false;
1412cdf0e10cSrcweir     ++nAnzResStrings;
1413cdf0e10cSrcweir     if (nPos > 0 && nTypeArray[nPos-1] == NF_SYMBOLTYPE_EMPTY)
1414cdf0e10cSrcweir         --nPos;     // reuse position
1415cdf0e10cSrcweir     else
1416cdf0e10cSrcweir     {
1417cdf0e10cSrcweir         ++nAnzStrings;
1418cdf0e10cSrcweir         for (size_t i = nAnzStrings; i > nPos; --i)
1419cdf0e10cSrcweir         {
1420cdf0e10cSrcweir             nTypeArray[i] = nTypeArray[i-1];
1421cdf0e10cSrcweir             sStrArray[i] = sStrArray[i-1];
1422cdf0e10cSrcweir         }
1423cdf0e10cSrcweir     }
1424cdf0e10cSrcweir     nTypeArray[nPos] = static_cast<short>(eType);
1425cdf0e10cSrcweir     sStrArray[nPos] = rStr;
1426cdf0e10cSrcweir     return true;
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir 
1429cdf0e10cSrcweir 
FinalScanGetCalendar(xub_StrLen & nPos,sal_uInt16 & i,sal_uInt16 & rAnzResStrings)1430cdf0e10cSrcweir int ImpSvNumberformatScan::FinalScanGetCalendar( xub_StrLen& nPos, sal_uInt16& i,
1431cdf0e10cSrcweir 			sal_uInt16& rAnzResStrings )
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir 	if ( sStrArray[i].GetChar(0) == '[' &&
1434cdf0e10cSrcweir 			i < nAnzStrings-1 &&
1435cdf0e10cSrcweir 			nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
1436cdf0e10cSrcweir 			sStrArray[i+1].GetChar(0) == '~' )
1437cdf0e10cSrcweir 	{	// [~calendarID]
1438cdf0e10cSrcweir 		// as of SV_NUMBERFORMATTER_VERSION_CALENDAR
1439cdf0e10cSrcweir 		nPos = nPos + sStrArray[i].Len();			// [
1440cdf0e10cSrcweir 		nTypeArray[i] = NF_SYMBOLTYPE_CALDEL;
1441cdf0e10cSrcweir 		nPos = nPos + sStrArray[++i].Len();		// ~
1442cdf0e10cSrcweir 		sStrArray[i-1] += sStrArray[i];		// [~
1443cdf0e10cSrcweir 		nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1444cdf0e10cSrcweir 		rAnzResStrings--;
1445cdf0e10cSrcweir 		if ( ++i >= nAnzStrings )
1446cdf0e10cSrcweir 			return -1;		// error
1447cdf0e10cSrcweir 		nPos = nPos + sStrArray[i].Len();			// calendarID
1448cdf0e10cSrcweir 		String& rStr = sStrArray[i];
1449cdf0e10cSrcweir 		nTypeArray[i] = NF_SYMBOLTYPE_CALENDAR;	// convert
1450cdf0e10cSrcweir 		i++;
1451cdf0e10cSrcweir 		while ( i < nAnzStrings &&
1452cdf0e10cSrcweir 				sStrArray[i].GetChar(0) != ']' )
1453cdf0e10cSrcweir 		{
1454cdf0e10cSrcweir 			nPos = nPos + sStrArray[i].Len();
1455cdf0e10cSrcweir 			rStr += sStrArray[i];
1456cdf0e10cSrcweir 			nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1457cdf0e10cSrcweir 			rAnzResStrings--;
1458cdf0e10cSrcweir 			i++;
1459cdf0e10cSrcweir 		}
1460cdf0e10cSrcweir 		if ( rStr.Len() && i < nAnzStrings &&
1461cdf0e10cSrcweir 				sStrArray[i].GetChar(0) == ']' )
1462cdf0e10cSrcweir 		{
1463cdf0e10cSrcweir 			nTypeArray[i] = NF_SYMBOLTYPE_CALDEL;
1464cdf0e10cSrcweir 			nPos = nPos + sStrArray[i].Len();
1465cdf0e10cSrcweir 			i++;
1466cdf0e10cSrcweir 		}
1467cdf0e10cSrcweir 		else
1468cdf0e10cSrcweir 			return -1;		// error
1469cdf0e10cSrcweir 		return 1;
1470cdf0e10cSrcweir 	}
1471cdf0e10cSrcweir 	return 0;
1472cdf0e10cSrcweir }
1473cdf0e10cSrcweir 
FinalScan(String & rString,String & rComment)1474cdf0e10cSrcweir xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString, String& rComment )
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir 	const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir 	// save values for convert mode
1479cdf0e10cSrcweir     String sOldDecSep       = pFormatter->GetNumDecimalSep();
1480cdf0e10cSrcweir     String sOldThousandSep  = pFormatter->GetNumThousandSep();
1481cdf0e10cSrcweir     String sOldDateSep      = pFormatter->GetDateSep();
1482cdf0e10cSrcweir 	String sOldTimeSep		= pLoc->getTimeSep();
1483cdf0e10cSrcweir     String sOldTime100SecSep= pLoc->getTime100SecSep();
1484cdf0e10cSrcweir     String sOldCurSymbol    = GetCurSymbol();
1485cdf0e10cSrcweir     String sOldCurString    = GetCurString();
1486cdf0e10cSrcweir     sal_Unicode cOldKeyH    = sKeyword[NF_KEY_H].GetChar(0);
1487cdf0e10cSrcweir     sal_Unicode cOldKeyMI   = sKeyword[NF_KEY_MI].GetChar(0);
1488cdf0e10cSrcweir     sal_Unicode cOldKeyS    = sKeyword[NF_KEY_S].GetChar(0);
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir 	// If the group separator is a Non-Breaking Space (French) continue with a
1491cdf0e10cSrcweir 	// normal space instead so queries on space work correctly.
1492cdf0e10cSrcweir 	// The format string is adjusted to allow both.
1493cdf0e10cSrcweir 	// For output of the format code string the LocaleData characters are used.
1494cdf0e10cSrcweir 	if ( sOldThousandSep.GetChar(0) == cNonBreakingSpace && sOldThousandSep.Len() == 1 )
1495cdf0e10cSrcweir 		sOldThousandSep = ' ';
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir 	// change locale data et al
1498cdf0e10cSrcweir 	if (bConvertMode)
1499cdf0e10cSrcweir     {
1500cdf0e10cSrcweir 		pFormatter->ChangeIntl(eNewLnge);
1501cdf0e10cSrcweir         //! pointer may have changed
1502cdf0e10cSrcweir         pLoc = pFormatter->GetLocaleData();
1503cdf0e10cSrcweir         //! init new keywords
1504cdf0e10cSrcweir         InitKeywords();
1505cdf0e10cSrcweir     }
1506cdf0e10cSrcweir 	const CharClass* pChrCls = pFormatter->GetCharClass();
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir     xub_StrLen nPos = 0;                    // error correction position
1509cdf0e10cSrcweir     sal_uInt16 i = 0;                           // symbol loop counter
1510cdf0e10cSrcweir     sal_uInt16 nCounter = 0;                    // counts digits
1511cdf0e10cSrcweir     nAnzResStrings = nAnzStrings;           // counts remaining symbols
1512cdf0e10cSrcweir     bDecSep = sal_False;                        // reset in case already used in TypeCheck
1513cdf0e10cSrcweir     bool bThaiT = false;                    // Thai T NatNum modifier present
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir 	switch (eScannedType)
1516cdf0e10cSrcweir 	{
1517cdf0e10cSrcweir 		case NUMBERFORMAT_TEXT:
1518cdf0e10cSrcweir 		case NUMBERFORMAT_DEFINED:
1519cdf0e10cSrcweir 		{
1520cdf0e10cSrcweir 			while (i < nAnzStrings)
1521cdf0e10cSrcweir 			{
1522cdf0e10cSrcweir 				switch (nTypeArray[i])
1523cdf0e10cSrcweir 				{
1524cdf0e10cSrcweir 					case NF_SYMBOLTYPE_BLANK:
1525cdf0e10cSrcweir 					case NF_SYMBOLTYPE_STAR:
1526cdf0e10cSrcweir 					break;
1527cdf0e10cSrcweir 					case NF_SYMBOLTYPE_COMMENT:
1528cdf0e10cSrcweir 					{
1529cdf0e10cSrcweir 						String& rStr = sStrArray[i];
1530cdf0e10cSrcweir 						nPos = nPos + rStr.Len();
1531cdf0e10cSrcweir 						SvNumberformat::EraseCommentBraces( rStr );
1532cdf0e10cSrcweir 						rComment += rStr;
1533cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1534cdf0e10cSrcweir 						nAnzResStrings--;
1535cdf0e10cSrcweir 					}
1536cdf0e10cSrcweir 					break;
1537cdf0e10cSrcweir 					case NF_KEY_GENERAL :	// #77026# "General" is the same as "@"
1538cdf0e10cSrcweir 					break;
1539cdf0e10cSrcweir 					default:
1540cdf0e10cSrcweir 					{
1541cdf0e10cSrcweir 						if ( nTypeArray[i] != NF_SYMBOLTYPE_DEL ||
1542cdf0e10cSrcweir 								sStrArray[i].GetChar(0) != '@' )
1543cdf0e10cSrcweir 							nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1544cdf0e10cSrcweir 					}
1545cdf0e10cSrcweir 					break;
1546cdf0e10cSrcweir 				}
1547cdf0e10cSrcweir 				nPos = nPos + sStrArray[i].Len();
1548cdf0e10cSrcweir 				i++;
1549cdf0e10cSrcweir 			}										// of while
1550cdf0e10cSrcweir 		}
1551cdf0e10cSrcweir 		break;
1552cdf0e10cSrcweir 		case NUMBERFORMAT_NUMBER:
1553cdf0e10cSrcweir 		case NUMBERFORMAT_PERCENT:
1554cdf0e10cSrcweir 		case NUMBERFORMAT_CURRENCY:
1555cdf0e10cSrcweir 		case NUMBERFORMAT_SCIENTIFIC:
1556cdf0e10cSrcweir 		case NUMBERFORMAT_FRACTION:
1557cdf0e10cSrcweir 		{
1558cdf0e10cSrcweir 			sal_Unicode cThousandFill = ' ';
1559cdf0e10cSrcweir 			while (i < nAnzStrings)
1560cdf0e10cSrcweir 			{
1561cdf0e10cSrcweir 				if (eScannedType == NUMBERFORMAT_FRACTION &&  	// special case
1562cdf0e10cSrcweir 					nTypeArray[i] == NF_SYMBOLTYPE_DEL && 			// # ### #/#
1563cdf0e10cSrcweir 					StringEqualsChar( sOldThousandSep, ' ' ) && // e.g. France or Sweden
1564cdf0e10cSrcweir 					StringEqualsChar( sStrArray[i], ' ' ) &&
1565cdf0e10cSrcweir 					!bFrac                          &&
1566cdf0e10cSrcweir 					IsLastBlankBeforeFrac(i) )
1567cdf0e10cSrcweir 				{
1568cdf0e10cSrcweir 					nTypeArray[i] = NF_SYMBOLTYPE_STRING;			// del->string
1569cdf0e10cSrcweir 				}                                               // kein Taus.p.
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir 				if (nTypeArray[i] == NF_SYMBOLTYPE_BLANK	||
1573cdf0e10cSrcweir 					nTypeArray[i] == NF_SYMBOLTYPE_STAR	||
1574cdf0e10cSrcweir 					nTypeArray[i] == NF_KEY_CCC			||	// CCC
1575cdf0e10cSrcweir 					nTypeArray[i] == NF_KEY_GENERAL )		// Standard
1576cdf0e10cSrcweir 				{
1577cdf0e10cSrcweir 					if (nTypeArray[i] == NF_KEY_GENERAL)
1578cdf0e10cSrcweir 					{
1579cdf0e10cSrcweir 						nThousand = FLAG_STANDARD_IN_FORMAT;
1580cdf0e10cSrcweir 						if ( bConvertMode )
1581cdf0e10cSrcweir 							sStrArray[i] = sNameStandardFormat;
1582cdf0e10cSrcweir 					}
1583cdf0e10cSrcweir 					nPos = nPos + sStrArray[i].Len();
1584cdf0e10cSrcweir 					i++;
1585cdf0e10cSrcweir 				}
1586cdf0e10cSrcweir 				else if (nTypeArray[i] == NF_SYMBOLTYPE_STRING ||  // Strings oder
1587cdf0e10cSrcweir 						 nTypeArray[i] > 0) 					// Keywords
1588cdf0e10cSrcweir 				{
1589cdf0e10cSrcweir 					if (eScannedType == NUMBERFORMAT_SCIENTIFIC &&
1590cdf0e10cSrcweir 							 nTypeArray[i] == NF_KEY_E) 		// E+
1591cdf0e10cSrcweir 					{
1592cdf0e10cSrcweir 						if (bExp) 								// doppelt
1593cdf0e10cSrcweir 							return nPos;
1594cdf0e10cSrcweir 						bExp = sal_True;
1595cdf0e10cSrcweir 						nExpPos = i;
1596cdf0e10cSrcweir 						if (bDecSep)
1597cdf0e10cSrcweir 							nCntPost = nCounter;
1598cdf0e10cSrcweir 						else
1599cdf0e10cSrcweir 							nCntPre = nCounter;
1600cdf0e10cSrcweir 						nCounter = 0;
1601cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_EXP;
1602cdf0e10cSrcweir 					}
1603cdf0e10cSrcweir 					else if (eScannedType == NUMBERFORMAT_FRACTION &&
1604cdf0e10cSrcweir 							 sStrArray[i].GetChar(0) == ' ')
1605cdf0e10cSrcweir 					{
1606cdf0e10cSrcweir 						if (!bBlank && !bFrac)	// nicht doppelt oder hinter /
1607cdf0e10cSrcweir 						{
1608cdf0e10cSrcweir 							if (bDecSep && nCounter > 0)	// Nachkommastellen
1609cdf0e10cSrcweir 								return nPos;				// Fehler
1610cdf0e10cSrcweir 							bBlank = sal_True;
1611cdf0e10cSrcweir 							nBlankPos = i;
1612cdf0e10cSrcweir 							nCntPre = nCounter;
1613cdf0e10cSrcweir 							nCounter = 0;
1614cdf0e10cSrcweir 						}
1615cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_FRACBLANK;
1616cdf0e10cSrcweir 					}
1617cdf0e10cSrcweir                     else if (nTypeArray[i] == NF_KEY_THAI_T)
1618cdf0e10cSrcweir                     {
1619cdf0e10cSrcweir                         bThaiT = true;
1620cdf0e10cSrcweir                         sStrArray[i] = sKeyword[nTypeArray[i]];
1621cdf0e10cSrcweir                     }
1622cdf0e10cSrcweir 					else
1623cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1624cdf0e10cSrcweir 					nPos = nPos + sStrArray[i].Len();
1625cdf0e10cSrcweir 					i++;
1626cdf0e10cSrcweir 				}
1627cdf0e10cSrcweir 				else if (nTypeArray[i] == NF_SYMBOLTYPE_DEL)
1628cdf0e10cSrcweir 				{
1629cdf0e10cSrcweir 					sal_Unicode cHere = sStrArray[i].GetChar(0);
1630cdf0e10cSrcweir                     // Handle not pre-known separators in switch.
1631cdf0e10cSrcweir                     sal_Unicode cSimplified;
1632cdf0e10cSrcweir                     if (StringEqualsChar( pFormatter->GetNumThousandSep(), cHere))
1633cdf0e10cSrcweir                         cSimplified = ',';
1634cdf0e10cSrcweir                     else if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cHere))
1635cdf0e10cSrcweir                         cSimplified = '.';
1636cdf0e10cSrcweir                     else
1637cdf0e10cSrcweir                         cSimplified = cHere;
1638cdf0e10cSrcweir 					switch ( cSimplified )
1639cdf0e10cSrcweir 					{
1640cdf0e10cSrcweir 						case '#':
1641cdf0e10cSrcweir 						case '0':
1642cdf0e10cSrcweir 						case '?':
1643cdf0e10cSrcweir 						{
1644cdf0e10cSrcweir 							if (nThousand > 0)					// #... #
1645cdf0e10cSrcweir 								return nPos;					// Fehler
1646cdf0e10cSrcweir 							else if (bFrac && cHere == '0')
1647cdf0e10cSrcweir 								return nPos;					// 0 im Nenner
1648cdf0e10cSrcweir 							nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
1649cdf0e10cSrcweir 							String& rStr = sStrArray[i];
1650cdf0e10cSrcweir 							nPos = nPos + rStr.Len();
1651cdf0e10cSrcweir 							i++;
1652cdf0e10cSrcweir 							nCounter++;
1653cdf0e10cSrcweir 							while (i < nAnzStrings &&
1654cdf0e10cSrcweir 								(sStrArray[i].GetChar(0) == '#' ||
1655cdf0e10cSrcweir 									sStrArray[i].GetChar(0) == '0' ||
1656cdf0e10cSrcweir 									sStrArray[i].GetChar(0) == '?')
1657cdf0e10cSrcweir 								)
1658cdf0e10cSrcweir 							{
1659cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
1660cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();
1661cdf0e10cSrcweir 								nCounter++;
1662cdf0e10cSrcweir 								i++;
1663cdf0e10cSrcweir 							}
1664cdf0e10cSrcweir 						}
1665cdf0e10cSrcweir 						break;
1666cdf0e10cSrcweir 						case '-':
1667cdf0e10cSrcweir 						{
1668cdf0e10cSrcweir                             if ( bDecSep && nDecPos+1 == i &&
1669cdf0e10cSrcweir 									nTypeArray[nDecPos] == NF_SYMBOLTYPE_DECSEP )
1670cdf0e10cSrcweir                             {   // "0.--"
1671cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
1672cdf0e10cSrcweir 								String& rStr = sStrArray[i];
1673cdf0e10cSrcweir 								nPos = nPos + rStr.Len();
1674cdf0e10cSrcweir 								i++;
1675cdf0e10cSrcweir 								nCounter++;
1676cdf0e10cSrcweir 								while (i < nAnzStrings &&
1677cdf0e10cSrcweir 										(sStrArray[i].GetChar(0) == '-') )
1678cdf0e10cSrcweir 								{
1679cdf0e10cSrcweir                                     // If more than two dashes are present in
1680cdf0e10cSrcweir                                     // currency formats the last dash will be
1681cdf0e10cSrcweir                                     // interpreted literally as a minus sign.
1682cdf0e10cSrcweir                                     // Has to be this ugly. Period.
1683cdf0e10cSrcweir                                     if ( eScannedType == NUMBERFORMAT_CURRENCY
1684cdf0e10cSrcweir                                             && rStr.Len() >= 2 &&
1685cdf0e10cSrcweir                                             (i == nAnzStrings-1 ||
1686cdf0e10cSrcweir                                             sStrArray[i+1].GetChar(0) != '-') )
1687cdf0e10cSrcweir                                         break;
1688cdf0e10cSrcweir 									rStr += sStrArray[i];
1689cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1690cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1691cdf0e10cSrcweir 									nAnzResStrings--;
1692cdf0e10cSrcweir 									nCounter++;
1693cdf0e10cSrcweir 									i++;
1694cdf0e10cSrcweir 								}
1695cdf0e10cSrcweir 							}
1696cdf0e10cSrcweir 							else
1697cdf0e10cSrcweir 							{
1698cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1699cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();
1700cdf0e10cSrcweir 								i++;
1701cdf0e10cSrcweir 							}
1702cdf0e10cSrcweir 						}
1703cdf0e10cSrcweir 						break;
1704cdf0e10cSrcweir 						case '.':
1705cdf0e10cSrcweir 						case ',':
1706cdf0e10cSrcweir 						case '\'':
1707cdf0e10cSrcweir 						case ' ':
1708cdf0e10cSrcweir 						{
1709cdf0e10cSrcweir 							sal_Unicode cSep = cHere;	// remember
1710cdf0e10cSrcweir 							if ( StringEqualsChar( sOldThousandSep, cSep ) )
1711cdf0e10cSrcweir 							{
1712cdf0e10cSrcweir 								// previous char with skip empty
1713cdf0e10cSrcweir 								sal_Unicode cPre = PreviousChar(i);
1714cdf0e10cSrcweir 								sal_Unicode cNext;
1715cdf0e10cSrcweir 								if (bExp || bBlank || bFrac)
1716cdf0e10cSrcweir 								{	// after E, / or ' '
1717cdf0e10cSrcweir 									if ( !StringEqualsChar( sOldThousandSep, ' ' ) )
1718cdf0e10cSrcweir 									{
1719cdf0e10cSrcweir 										nPos = nPos + sStrArray[i].Len();
1720cdf0e10cSrcweir 										nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1721cdf0e10cSrcweir 										nAnzResStrings--;
1722cdf0e10cSrcweir 										i++; 				// eat it
1723cdf0e10cSrcweir 									}
1724cdf0e10cSrcweir 									else
1725cdf0e10cSrcweir 										nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1726cdf0e10cSrcweir 								}
1727cdf0e10cSrcweir 								else if (i > 0 && i < nAnzStrings-1   &&
1728cdf0e10cSrcweir 									(cPre == '#' || cPre == '0')      &&
1729cdf0e10cSrcweir 									((cNext = NextChar(i)) == '#' || cNext == '0')
1730cdf0e10cSrcweir 									)					// #,#
1731cdf0e10cSrcweir 								{
1732cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1733cdf0e10cSrcweir 									if (!bThousand)					// only once
1734cdf0e10cSrcweir                                     {
1735cdf0e10cSrcweir 										bThousand = sal_True;
1736cdf0e10cSrcweir 										cThousandFill = sStrArray[i+1].GetChar(0);
1737cdf0e10cSrcweir 									}
1738cdf0e10cSrcweir                                     // Eat it, will be reinserted at proper
1739cdf0e10cSrcweir                                     // grouping positions further down.
1740cdf0e10cSrcweir                                     nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1741cdf0e10cSrcweir                                     nAnzResStrings--;
1742cdf0e10cSrcweir 									i++;
1743cdf0e10cSrcweir 								}
1744cdf0e10cSrcweir 								else if (i > 0 && (cPre == '#' || cPre == '0')
1745cdf0e10cSrcweir 									&& PreviousType(i) == NF_SYMBOLTYPE_DIGIT
1746cdf0e10cSrcweir 									&& nThousand < FLAG_STANDARD_IN_FORMAT )
1747cdf0e10cSrcweir 								{									// #,,,,
1748cdf0e10cSrcweir 									if ( StringEqualsChar( sOldThousandSep, ' ' ) )
1749cdf0e10cSrcweir 									{	// strange, those French..
1750cdf0e10cSrcweir 										sal_Bool bFirst = sal_True;
1751cdf0e10cSrcweir 										String& rStr = sStrArray[i];
1752cdf0e10cSrcweir                                         //  set a hard Non-Breaking Space or ConvertMode
1753cdf0e10cSrcweir                                         const String& rSepF = pFormatter->GetNumThousandSep();
1754cdf0e10cSrcweir 										while ( i < nAnzStrings
1755cdf0e10cSrcweir 											&& sStrArray[i] == sOldThousandSep
1756cdf0e10cSrcweir 											&& StringEqualsChar( sOldThousandSep, NextChar(i) ) )
1757cdf0e10cSrcweir 										{	// last was a space or another space
1758cdf0e10cSrcweir 											// is following => separator
1759cdf0e10cSrcweir 											nPos = nPos + sStrArray[i].Len();
1760cdf0e10cSrcweir 											if ( bFirst )
1761cdf0e10cSrcweir 											{
1762cdf0e10cSrcweir 												bFirst = sal_False;
1763cdf0e10cSrcweir 												rStr = rSepF;
1764cdf0e10cSrcweir 												nTypeArray[i] = NF_SYMBOLTYPE_THSEP;
1765cdf0e10cSrcweir 											}
1766cdf0e10cSrcweir 											else
1767cdf0e10cSrcweir 											{
1768cdf0e10cSrcweir 												rStr += rSepF;
1769cdf0e10cSrcweir 												nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1770cdf0e10cSrcweir 												nAnzResStrings--;
1771cdf0e10cSrcweir 											}
1772cdf0e10cSrcweir 											nThousand++;
1773cdf0e10cSrcweir 											i++;
1774cdf0e10cSrcweir 										}
1775cdf0e10cSrcweir 										if ( i < nAnzStrings-1
1776cdf0e10cSrcweir 											&& sStrArray[i] == sOldThousandSep )
1777cdf0e10cSrcweir 										{	// something following last space
1778cdf0e10cSrcweir 											// => space if currency contained,
1779cdf0e10cSrcweir 											// else separator
1780cdf0e10cSrcweir 											nPos = nPos + sStrArray[i].Len();
1781cdf0e10cSrcweir 											if ( (nPos <= nCurrPos &&
1782cdf0e10cSrcweir 													nCurrPos < nPos + sStrArray[i+1].Len())
1783cdf0e10cSrcweir 												|| nTypeArray[i+1] == NF_KEY_CCC
1784cdf0e10cSrcweir 												|| (i < nAnzStrings-2 &&
1785cdf0e10cSrcweir 												sStrArray[i+1].GetChar(0) == '[' &&
1786cdf0e10cSrcweir 												sStrArray[i+2].GetChar(0) == '$') )
1787cdf0e10cSrcweir 											{
1788cdf0e10cSrcweir 												nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1789cdf0e10cSrcweir 											}
1790cdf0e10cSrcweir 											else
1791cdf0e10cSrcweir 											{
1792cdf0e10cSrcweir 												if ( bFirst )
1793cdf0e10cSrcweir 												{
1794cdf0e10cSrcweir 													bFirst = sal_False;
1795cdf0e10cSrcweir 													rStr = rSepF;
1796cdf0e10cSrcweir 													nTypeArray[i] = NF_SYMBOLTYPE_THSEP;
1797cdf0e10cSrcweir 												}
1798cdf0e10cSrcweir 												else
1799cdf0e10cSrcweir 												{
1800cdf0e10cSrcweir 													rStr += rSepF;
1801cdf0e10cSrcweir 													nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1802cdf0e10cSrcweir 													nAnzResStrings--;
1803cdf0e10cSrcweir 												}
1804cdf0e10cSrcweir 												nThousand++;
1805cdf0e10cSrcweir 											}
1806cdf0e10cSrcweir 											i++;
1807cdf0e10cSrcweir 										}
1808cdf0e10cSrcweir 									}
1809cdf0e10cSrcweir 									else
1810cdf0e10cSrcweir 									{
1811cdf0e10cSrcweir                                         do
1812cdf0e10cSrcweir                                         {
1813cdf0e10cSrcweir                                             nThousand++;
1814cdf0e10cSrcweir                                             nTypeArray[i] = NF_SYMBOLTYPE_THSEP;
1815cdf0e10cSrcweir                                             nPos = nPos + sStrArray[i].Len();
1816cdf0e10cSrcweir                                             sStrArray[i] = pFormatter->GetNumThousandSep();
1817cdf0e10cSrcweir                                             i++;
1818cdf0e10cSrcweir                                         } while (i < nAnzStrings &&
1819cdf0e10cSrcweir                                                 sStrArray[i] == sOldThousandSep);
1820cdf0e10cSrcweir 									}
1821cdf0e10cSrcweir 								}
1822cdf0e10cSrcweir 								else 					// any grsep
1823cdf0e10cSrcweir 								{
1824cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1825cdf0e10cSrcweir 									String& rStr = sStrArray[i];
1826cdf0e10cSrcweir 									nPos = nPos + rStr.Len();
1827cdf0e10cSrcweir 									i++;
1828cdf0e10cSrcweir 									while ( i < nAnzStrings &&
1829cdf0e10cSrcweir 										sStrArray[i] == sOldThousandSep )
1830cdf0e10cSrcweir 									{
1831cdf0e10cSrcweir 										rStr += sStrArray[i];
1832cdf0e10cSrcweir 										nPos = nPos + sStrArray[i].Len();
1833cdf0e10cSrcweir 										nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1834cdf0e10cSrcweir 										nAnzResStrings--;
1835cdf0e10cSrcweir 										i++;
1836cdf0e10cSrcweir 									}
1837cdf0e10cSrcweir 								}
1838cdf0e10cSrcweir 							}
1839cdf0e10cSrcweir 							else if ( StringEqualsChar( sOldDecSep, cSep ) )
1840cdf0e10cSrcweir 							{
1841cdf0e10cSrcweir 								if (bBlank || bFrac)    // . behind / or ' '
1842cdf0e10cSrcweir 									return nPos;		// error
1843cdf0e10cSrcweir 								else if (bExp)			// behind E
1844cdf0e10cSrcweir 								{
1845cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1846cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1847cdf0e10cSrcweir 									nAnzResStrings--;
1848cdf0e10cSrcweir 									i++; 				// eat it
1849cdf0e10cSrcweir 								}
1850cdf0e10cSrcweir 								else if (bDecSep)		// any .
1851cdf0e10cSrcweir 								{
1852cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1853cdf0e10cSrcweir 									String& rStr = sStrArray[i];
1854cdf0e10cSrcweir 									nPos = nPos + rStr.Len();
1855cdf0e10cSrcweir 									i++;
1856cdf0e10cSrcweir 									while ( i < nAnzStrings &&
1857cdf0e10cSrcweir 										sStrArray[i] == sOldDecSep )
1858cdf0e10cSrcweir 									{
1859cdf0e10cSrcweir 										rStr += sStrArray[i];
1860cdf0e10cSrcweir 										nPos = nPos + sStrArray[i].Len();
1861cdf0e10cSrcweir 										nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1862cdf0e10cSrcweir 										nAnzResStrings--;
1863cdf0e10cSrcweir 										i++;
1864cdf0e10cSrcweir 									}
1865cdf0e10cSrcweir 								}
1866cdf0e10cSrcweir 								else
1867cdf0e10cSrcweir 								{
1868cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1869cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_DECSEP;
1870cdf0e10cSrcweir                                     sStrArray[i] = pFormatter->GetNumDecimalSep();
1871cdf0e10cSrcweir 									bDecSep = sal_True;
1872cdf0e10cSrcweir 									nDecPos = i;
1873cdf0e10cSrcweir 									nCntPre = nCounter;
1874cdf0e10cSrcweir 									nCounter = 0;
1875cdf0e10cSrcweir 
1876cdf0e10cSrcweir 									i++;
1877cdf0e10cSrcweir 								}
1878cdf0e10cSrcweir 							} 							// of else = DecSep
1879cdf0e10cSrcweir 							else						// . without meaning
1880cdf0e10cSrcweir 							{
1881cdf0e10cSrcweir 								if (cSep == ' ' &&
1882cdf0e10cSrcweir 									eScannedType == NUMBERFORMAT_FRACTION &&
1883cdf0e10cSrcweir 									StringEqualsChar( sStrArray[i], ' ' ) )
1884cdf0e10cSrcweir 								{
1885cdf0e10cSrcweir 									if (!bBlank && !bFrac)	// no dups
1886cdf0e10cSrcweir 									{	                    // or behind /
1887cdf0e10cSrcweir 										if (bDecSep && nCounter > 0)// dec.
1888cdf0e10cSrcweir 											return nPos;			// error
1889cdf0e10cSrcweir 										bBlank = sal_True;
1890cdf0e10cSrcweir 										nBlankPos = i;
1891cdf0e10cSrcweir 										nCntPre = nCounter;
1892cdf0e10cSrcweir 										nCounter = 0;
1893cdf0e10cSrcweir 									}
1894cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1895cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1896cdf0e10cSrcweir 								}
1897cdf0e10cSrcweir 								else
1898cdf0e10cSrcweir 								{
1899cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1900cdf0e10cSrcweir 									String& rStr = sStrArray[i];
1901cdf0e10cSrcweir 									nPos = nPos + rStr.Len();
1902cdf0e10cSrcweir 									i++;
1903cdf0e10cSrcweir 									while (i < nAnzStrings &&
1904cdf0e10cSrcweir 										StringEqualsChar( sStrArray[i], cSep ) )
1905cdf0e10cSrcweir 									{
1906cdf0e10cSrcweir 										rStr += sStrArray[i];
1907cdf0e10cSrcweir 										nPos = nPos + sStrArray[i].Len();
1908cdf0e10cSrcweir 										nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1909cdf0e10cSrcweir 										nAnzResStrings--;
1910cdf0e10cSrcweir 										i++;
1911cdf0e10cSrcweir 									}
1912cdf0e10cSrcweir 								}
1913cdf0e10cSrcweir 							}
1914cdf0e10cSrcweir 						}
1915cdf0e10cSrcweir 						break;
1916cdf0e10cSrcweir 						case '/':
1917cdf0e10cSrcweir 						{
1918cdf0e10cSrcweir 							if (eScannedType == NUMBERFORMAT_FRACTION)
1919cdf0e10cSrcweir 							{
1920cdf0e10cSrcweir 								if ( i == 0 ||
1921cdf0e10cSrcweir 										(nTypeArray[i-1] != NF_SYMBOLTYPE_DIGIT &&
1922cdf0e10cSrcweir 									 	nTypeArray[i-1] != NF_SYMBOLTYPE_EMPTY) )
1923cdf0e10cSrcweir 									return nPos ? nPos : 1;	// /? not allowed
1924cdf0e10cSrcweir 								else if (!bFrac || (bDecSep && nCounter > 0))
1925cdf0e10cSrcweir 								{
1926cdf0e10cSrcweir 									bFrac = sal_True;
1927cdf0e10cSrcweir 									nCntPost = nCounter;
1928cdf0e10cSrcweir 									nCounter = 0;
1929cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_FRAC;
1930cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1931cdf0e10cSrcweir 									i++;
1932cdf0e10cSrcweir 								}
1933cdf0e10cSrcweir 								else 				// / doppelt od. , imZaehl
1934cdf0e10cSrcweir 									return nPos;	// Fehler
1935cdf0e10cSrcweir 							}
1936cdf0e10cSrcweir 							else
1937cdf0e10cSrcweir 							{
1938cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_STRING;
1939cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();
1940cdf0e10cSrcweir 								i++;
1941cdf0e10cSrcweir 							}
1942cdf0e10cSrcweir 						}
1943cdf0e10cSrcweir 						break;
1944cdf0e10cSrcweir 						case '[' :
1945cdf0e10cSrcweir 						{
1946cdf0e10cSrcweir 							if ( eScannedType == NUMBERFORMAT_CURRENCY &&
1947cdf0e10cSrcweir 									i < nAnzStrings-1 &&
1948cdf0e10cSrcweir 									nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
1949cdf0e10cSrcweir 									sStrArray[i+1].GetChar(0) == '$' )
1950cdf0e10cSrcweir 							{	// [$DM-xxx]
1951cdf0e10cSrcweir 								// ab SV_NUMBERFORMATTER_VERSION_NEW_CURR
1952cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();			// [
1953cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL;
1954cdf0e10cSrcweir 								nPos = nPos + sStrArray[++i].Len();		// $
1955cdf0e10cSrcweir 								sStrArray[i-1] += sStrArray[i];		// [$
1956cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1957cdf0e10cSrcweir 								nAnzResStrings--;
1958cdf0e10cSrcweir 								if ( ++i >= nAnzStrings )
1959cdf0e10cSrcweir 									return nPos;		// Fehler
1960cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();			// DM
1961cdf0e10cSrcweir 								String& rStr = sStrArray[i];
1962cdf0e10cSrcweir 								String* pStr = &sStrArray[i];
1963cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_CURRENCY;	// wandeln
1964cdf0e10cSrcweir 								sal_Bool bHadDash = sal_False;
1965cdf0e10cSrcweir 								i++;
1966cdf0e10cSrcweir 								while ( i < nAnzStrings &&
1967cdf0e10cSrcweir 										sStrArray[i].GetChar(0) != ']' )
1968cdf0e10cSrcweir 								{
1969cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1970cdf0e10cSrcweir 									if ( bHadDash )
1971cdf0e10cSrcweir 									{
1972cdf0e10cSrcweir 										*pStr += sStrArray[i];
1973cdf0e10cSrcweir 										nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1974cdf0e10cSrcweir 										nAnzResStrings--;
1975cdf0e10cSrcweir 									}
1976cdf0e10cSrcweir 									else
1977cdf0e10cSrcweir 									{
1978cdf0e10cSrcweir 										if ( sStrArray[i].GetChar(0) == '-' )
1979cdf0e10cSrcweir 										{
1980cdf0e10cSrcweir 											bHadDash = sal_True;
1981cdf0e10cSrcweir 											pStr = &sStrArray[i];
1982cdf0e10cSrcweir 											nTypeArray[i] = NF_SYMBOLTYPE_CURREXT;
1983cdf0e10cSrcweir 										}
1984cdf0e10cSrcweir 										else
1985cdf0e10cSrcweir 										{
1986cdf0e10cSrcweir 											*pStr += sStrArray[i];
1987cdf0e10cSrcweir 											nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
1988cdf0e10cSrcweir 											nAnzResStrings--;
1989cdf0e10cSrcweir 										}
1990cdf0e10cSrcweir 									}
1991cdf0e10cSrcweir 									i++;
1992cdf0e10cSrcweir 								}
1993cdf0e10cSrcweir 								if ( rStr.Len() && i < nAnzStrings &&
1994cdf0e10cSrcweir 										sStrArray[i].GetChar(0) == ']' )
1995cdf0e10cSrcweir 								{
1996cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL;
1997cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
1998cdf0e10cSrcweir 									i++;
1999cdf0e10cSrcweir 								}
2000cdf0e10cSrcweir 								else
2001cdf0e10cSrcweir 									return nPos;		// Fehler
2002cdf0e10cSrcweir 							}
2003cdf0e10cSrcweir 							else
2004cdf0e10cSrcweir 							{
2005cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2006cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();
2007cdf0e10cSrcweir 								i++;
2008cdf0e10cSrcweir 							}
2009cdf0e10cSrcweir 						}
2010cdf0e10cSrcweir 						break;
2011cdf0e10cSrcweir 						default:					// andere Dels
2012cdf0e10cSrcweir 						{
2013cdf0e10cSrcweir                             if (eScannedType == NUMBERFORMAT_PERCENT &&
2014cdf0e10cSrcweir                                     cHere == '%')
2015cdf0e10cSrcweir                                 nTypeArray[i] = NF_SYMBOLTYPE_PERCENT;
2016cdf0e10cSrcweir                             else
2017cdf0e10cSrcweir                                 nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2018cdf0e10cSrcweir 							nPos = nPos + sStrArray[i].Len();
2019cdf0e10cSrcweir 							i++;
2020cdf0e10cSrcweir 						}
2021cdf0e10cSrcweir 						break;
2022cdf0e10cSrcweir 					}								// of switch (Del)
2023cdf0e10cSrcweir 				}									// of else Del
2024cdf0e10cSrcweir 				else if ( nTypeArray[i] == NF_SYMBOLTYPE_COMMENT )
2025cdf0e10cSrcweir 				{
2026cdf0e10cSrcweir 					String& rStr = sStrArray[i];
2027cdf0e10cSrcweir 					nPos = nPos + rStr.Len();
2028cdf0e10cSrcweir 					SvNumberformat::EraseCommentBraces( rStr );
2029cdf0e10cSrcweir 					rComment += rStr;
2030cdf0e10cSrcweir 					nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2031cdf0e10cSrcweir 					nAnzResStrings--;
2032cdf0e10cSrcweir 					i++;
2033cdf0e10cSrcweir 				}
2034cdf0e10cSrcweir 				else
2035cdf0e10cSrcweir 				{
2036cdf0e10cSrcweir 					DBG_ERRORFILE( "unknown NF_SYMBOLTYPE_..." );
2037cdf0e10cSrcweir 					nPos = nPos + sStrArray[i].Len();
2038cdf0e10cSrcweir 					i++;
2039cdf0e10cSrcweir 				}
2040cdf0e10cSrcweir 			}                                  		// of while
2041cdf0e10cSrcweir 			if (eScannedType == NUMBERFORMAT_FRACTION)
2042cdf0e10cSrcweir 			{
2043cdf0e10cSrcweir 				if (bFrac)
2044cdf0e10cSrcweir 					nCntExp = nCounter;
2045cdf0e10cSrcweir 				else if (bBlank)
2046cdf0e10cSrcweir 					nCntPost = nCounter;
2047cdf0e10cSrcweir 				else
2048cdf0e10cSrcweir 					nCntPre = nCounter;
2049cdf0e10cSrcweir 			}
2050cdf0e10cSrcweir 			else
2051cdf0e10cSrcweir 			{
2052cdf0e10cSrcweir 				if (bExp)
2053cdf0e10cSrcweir 					nCntExp = nCounter;
2054cdf0e10cSrcweir 				else if (bDecSep)
2055cdf0e10cSrcweir 					nCntPost = nCounter;
2056cdf0e10cSrcweir 				else
2057cdf0e10cSrcweir 					nCntPre = nCounter;
2058cdf0e10cSrcweir 			}
2059cdf0e10cSrcweir 			if (bThousand)                          // Expansion of grouping separators
2060cdf0e10cSrcweir 			{
2061cdf0e10cSrcweir 				sal_uInt16 nMaxPos;
2062cdf0e10cSrcweir 				if (bFrac)
2063cdf0e10cSrcweir 				{
2064cdf0e10cSrcweir 					if (bBlank)
2065cdf0e10cSrcweir 						nMaxPos = nBlankPos;
2066cdf0e10cSrcweir 					else
2067cdf0e10cSrcweir 						nMaxPos = 0;				// no grouping
2068cdf0e10cSrcweir 				}
2069cdf0e10cSrcweir 				else if (bDecSep)					// decimal separator present
2070cdf0e10cSrcweir 					nMaxPos = nDecPos;
2071cdf0e10cSrcweir 				else if (bExp)						// 'E' exponent present
2072cdf0e10cSrcweir 					nMaxPos = nExpPos;
2073cdf0e10cSrcweir 				else								// up to end
2074cdf0e10cSrcweir 					nMaxPos = i;
2075cdf0e10cSrcweir                 // Insert separators at proper positions.
2076cdf0e10cSrcweir                 xub_StrLen nCount = 0;
2077cdf0e10cSrcweir                 utl::DigitGroupingIterator aGrouping( pLoc->getDigitGrouping());
2078cdf0e10cSrcweir                 size_t nFirstDigitSymbol = nMaxPos;
2079cdf0e10cSrcweir                 size_t nFirstGroupingSymbol = nMaxPos;
2080cdf0e10cSrcweir                 i = nMaxPos;
2081cdf0e10cSrcweir                 while (i-- > 0)
2082cdf0e10cSrcweir                 {
2083cdf0e10cSrcweir                     if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT)
2084cdf0e10cSrcweir                     {
2085cdf0e10cSrcweir                         nFirstDigitSymbol = i;
2086cdf0e10cSrcweir                         nCount = nCount + sStrArray[i].Len();   // MSC converts += to int and then warns, so ...
2087cdf0e10cSrcweir                         // Insert separator only if not leftmost symbol.
2088cdf0e10cSrcweir                         if (i > 0 && nCount >= aGrouping.getPos())
2089cdf0e10cSrcweir                         {
2090cdf0e10cSrcweir                             DBG_ASSERT( sStrArray[i].Len() == 1,
2091cdf0e10cSrcweir                                     "ImpSvNumberformatScan::FinalScan: combined digits in group separator insertion");
2092cdf0e10cSrcweir                             if (!InsertSymbol( i, NF_SYMBOLTYPE_THSEP,
2093cdf0e10cSrcweir                                         pFormatter->GetNumThousandSep()))
2094cdf0e10cSrcweir                                 // nPos isn't correct here, but signals error
2095cdf0e10cSrcweir                                 return nPos;
2096cdf0e10cSrcweir                             // i may have been decremented by 1
2097cdf0e10cSrcweir                             nFirstDigitSymbol = i + 1;
2098cdf0e10cSrcweir                             nFirstGroupingSymbol = i;
2099cdf0e10cSrcweir                             aGrouping.advance();
2100cdf0e10cSrcweir                         }
2101cdf0e10cSrcweir                     }
2102cdf0e10cSrcweir                 }
2103cdf0e10cSrcweir                 // Generated something like "string",000; remove separator again.
2104cdf0e10cSrcweir                 if (nFirstGroupingSymbol < nFirstDigitSymbol)
2105cdf0e10cSrcweir                 {
2106cdf0e10cSrcweir                     nTypeArray[nFirstGroupingSymbol] = NF_SYMBOLTYPE_EMPTY;
2107cdf0e10cSrcweir                     nAnzResStrings--;
2108cdf0e10cSrcweir                 }
2109cdf0e10cSrcweir             }
2110cdf0e10cSrcweir             // Combine digits into groups to save memory (Info will be copied
2111cdf0e10cSrcweir             // later, taking only non-empty symbols).
2112cdf0e10cSrcweir             for (i = 0; i < nAnzStrings; ++i)
2113cdf0e10cSrcweir             {
2114cdf0e10cSrcweir                 if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT)
2115cdf0e10cSrcweir                 {
2116cdf0e10cSrcweir                     String& rStr = sStrArray[i];
2117cdf0e10cSrcweir                     while (++i < nAnzStrings &&
2118cdf0e10cSrcweir                             nTypeArray[i] == NF_SYMBOLTYPE_DIGIT)
2119cdf0e10cSrcweir                     {
2120cdf0e10cSrcweir                         rStr += sStrArray[i];
2121cdf0e10cSrcweir                         nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2122cdf0e10cSrcweir                         nAnzResStrings--;
2123cdf0e10cSrcweir                     }
2124cdf0e10cSrcweir                 }
2125cdf0e10cSrcweir             }
2126cdf0e10cSrcweir 		}
2127cdf0e10cSrcweir 		break;										// of NUMBERFORMAT_NUMBER
2128cdf0e10cSrcweir 		case NUMBERFORMAT_DATE:
2129cdf0e10cSrcweir 		{
2130cdf0e10cSrcweir 			while (i < nAnzStrings)
2131cdf0e10cSrcweir 			{
2132cdf0e10cSrcweir 				switch (nTypeArray[i])
2133cdf0e10cSrcweir 				{
2134cdf0e10cSrcweir 					case NF_SYMBOLTYPE_BLANK:
2135cdf0e10cSrcweir 					case NF_SYMBOLTYPE_STAR:
2136cdf0e10cSrcweir 					case NF_SYMBOLTYPE_STRING:
2137cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2138cdf0e10cSrcweir 						i++;
2139cdf0e10cSrcweir 					break;
2140cdf0e10cSrcweir 					case NF_SYMBOLTYPE_COMMENT:
2141cdf0e10cSrcweir 					{
2142cdf0e10cSrcweir 						String& rStr = sStrArray[i];
2143cdf0e10cSrcweir 						nPos = nPos + rStr.Len();
2144cdf0e10cSrcweir 						SvNumberformat::EraseCommentBraces( rStr );
2145cdf0e10cSrcweir 						rComment += rStr;
2146cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2147cdf0e10cSrcweir 						nAnzResStrings--;
2148cdf0e10cSrcweir 						i++;
2149cdf0e10cSrcweir 					}
2150cdf0e10cSrcweir 					break;
2151cdf0e10cSrcweir 					case NF_SYMBOLTYPE_DEL:
2152cdf0e10cSrcweir 					{
2153cdf0e10cSrcweir 						int nCalRet;
2154cdf0e10cSrcweir 						if (sStrArray[i] == sOldDateSep)
2155cdf0e10cSrcweir 						{
2156cdf0e10cSrcweir 							nTypeArray[i] = NF_SYMBOLTYPE_DATESEP;
2157cdf0e10cSrcweir 							nPos = nPos + sStrArray[i].Len();
2158cdf0e10cSrcweir                             if (bConvertMode)
2159cdf0e10cSrcweir                                 sStrArray[i] = pFormatter->GetDateSep();
2160cdf0e10cSrcweir 							i++;
2161cdf0e10cSrcweir 						}
2162cdf0e10cSrcweir 						else if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 )
2163cdf0e10cSrcweir 						{
2164cdf0e10cSrcweir 							if ( nCalRet < 0  )
2165cdf0e10cSrcweir 								return nPos;		// error
2166cdf0e10cSrcweir 						}
2167cdf0e10cSrcweir 						else
2168cdf0e10cSrcweir 						{
2169cdf0e10cSrcweir 							nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2170cdf0e10cSrcweir 							nPos = nPos + sStrArray[i].Len();
2171cdf0e10cSrcweir 							i++;
2172cdf0e10cSrcweir 						}
2173cdf0e10cSrcweir 					}
2174cdf0e10cSrcweir 					break;
2175cdf0e10cSrcweir                     case NF_KEY_THAI_T :
2176cdf0e10cSrcweir                         bThaiT = true;
2177cdf0e10cSrcweir                         // fall thru
2178cdf0e10cSrcweir 					case NF_KEY_M:							// M
2179cdf0e10cSrcweir 					case NF_KEY_MM:							// MM
2180cdf0e10cSrcweir 					case NF_KEY_MMM:						// MMM
2181cdf0e10cSrcweir 					case NF_KEY_MMMM:						// MMMM
2182cdf0e10cSrcweir 					case NF_KEY_MMMMM:						// MMMMM
2183cdf0e10cSrcweir 					case NF_KEY_Q:							// Q
2184cdf0e10cSrcweir 					case NF_KEY_QQ:							// QQ
2185cdf0e10cSrcweir 					case NF_KEY_D:							// D
2186cdf0e10cSrcweir 					case NF_KEY_DD:							// DD
2187cdf0e10cSrcweir 					case NF_KEY_DDD:						// DDD
2188cdf0e10cSrcweir 					case NF_KEY_DDDD:						// DDDD
2189cdf0e10cSrcweir 					case NF_KEY_YY:							// YY
2190cdf0e10cSrcweir 					case NF_KEY_YYYY:						// YYYY
2191cdf0e10cSrcweir 					case NF_KEY_NN:							// NN
2192cdf0e10cSrcweir 					case NF_KEY_NNN:						// NNN
2193cdf0e10cSrcweir 					case NF_KEY_NNNN:						// NNNN
2194cdf0e10cSrcweir 					case NF_KEY_WW :						// WW
2195cdf0e10cSrcweir 					case NF_KEY_AAA :						// AAA
2196cdf0e10cSrcweir 					case NF_KEY_AAAA :						// AAAA
2197cdf0e10cSrcweir 					case NF_KEY_EC :						// E
2198cdf0e10cSrcweir 					case NF_KEY_EEC :						// EE
2199cdf0e10cSrcweir 					case NF_KEY_G :							// G
2200cdf0e10cSrcweir 					case NF_KEY_GG :						// GG
2201cdf0e10cSrcweir 					case NF_KEY_GGG :						// GGG
2202cdf0e10cSrcweir 					case NF_KEY_R :							// R
2203cdf0e10cSrcweir 					case NF_KEY_RR :						// RR
2204cdf0e10cSrcweir 						sStrArray[i] = sKeyword[nTypeArray[i]];	// tTtT -> TTTT
2205cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2206cdf0e10cSrcweir 						i++;
2207cdf0e10cSrcweir 					break;
2208cdf0e10cSrcweir 					default:							// andere Keywords
2209cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2210cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2211cdf0e10cSrcweir 						i++;
2212cdf0e10cSrcweir 					break;
2213cdf0e10cSrcweir 				}
2214cdf0e10cSrcweir 			}										// of while
2215cdf0e10cSrcweir 		}
2216cdf0e10cSrcweir 		break;										// of NUMBERFORMAT_DATE
2217cdf0e10cSrcweir 		case NUMBERFORMAT_TIME:
2218cdf0e10cSrcweir 		{
2219cdf0e10cSrcweir 			while (i < nAnzStrings)
2220cdf0e10cSrcweir 			{
2221cdf0e10cSrcweir 				switch (nTypeArray[i])
2222cdf0e10cSrcweir 				{
2223cdf0e10cSrcweir 					case NF_SYMBOLTYPE_BLANK:
2224cdf0e10cSrcweir 					case NF_SYMBOLTYPE_STAR:
2225cdf0e10cSrcweir 					{
2226cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2227cdf0e10cSrcweir 						i++;
2228cdf0e10cSrcweir 					}
2229cdf0e10cSrcweir 					break;
2230cdf0e10cSrcweir 					case NF_SYMBOLTYPE_DEL:
2231cdf0e10cSrcweir 					{
2232cdf0e10cSrcweir 						switch( sStrArray[i].GetChar(0) )
2233cdf0e10cSrcweir 						{
2234cdf0e10cSrcweir 							case '0':
2235cdf0e10cSrcweir 							{
2236cdf0e10cSrcweir                                 if ( Is100SecZero( i, bDecSep ) )
2237cdf0e10cSrcweir 								{
2238cdf0e10cSrcweir                                     bDecSep = sal_True;
2239cdf0e10cSrcweir 									nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
2240cdf0e10cSrcweir 									String& rStr = sStrArray[i];
2241cdf0e10cSrcweir 									i++;
2242cdf0e10cSrcweir 									nPos = nPos + sStrArray[i].Len();
2243cdf0e10cSrcweir 									nCounter++;
2244cdf0e10cSrcweir 									while (i < nAnzStrings &&
2245cdf0e10cSrcweir 										   sStrArray[i].GetChar(0) == '0')
2246cdf0e10cSrcweir 									{
2247cdf0e10cSrcweir 										rStr += sStrArray[i];
2248cdf0e10cSrcweir 										nPos = nPos + sStrArray[i].Len();
2249cdf0e10cSrcweir 										nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2250cdf0e10cSrcweir 										nAnzResStrings--;
2251cdf0e10cSrcweir 										nCounter++;
2252cdf0e10cSrcweir 										i++;
2253cdf0e10cSrcweir 									}
2254cdf0e10cSrcweir 								}
2255cdf0e10cSrcweir 								else
2256cdf0e10cSrcweir 									return nPos;
2257cdf0e10cSrcweir 							}
2258cdf0e10cSrcweir 							break;
2259cdf0e10cSrcweir 							case '#':
2260cdf0e10cSrcweir 							case '?':
2261cdf0e10cSrcweir 								return nPos;
2262cdf0e10cSrcweir 							case '[':
2263cdf0e10cSrcweir 							{
2264cdf0e10cSrcweir 								if (bThousand)				// doppelt
2265cdf0e10cSrcweir 									return nPos;
2266cdf0e10cSrcweir 								bThousand = sal_True;			// bei Time frei
2267cdf0e10cSrcweir 								sal_Unicode cChar = pChrCls->upper( NextChar(i) ).GetChar(0);
2268cdf0e10cSrcweir 								if ( cChar == cOldKeyH )
2269cdf0e10cSrcweir 									nThousand = 1;		// H
2270cdf0e10cSrcweir 								else if ( cChar == cOldKeyMI )
2271cdf0e10cSrcweir 									nThousand = 2;		// M
2272cdf0e10cSrcweir 								else if ( cChar == cOldKeyS )
2273cdf0e10cSrcweir 									nThousand = 3;		// S
2274cdf0e10cSrcweir 								else
2275cdf0e10cSrcweir 									return nPos;
2276cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();
2277cdf0e10cSrcweir 								i++;
2278cdf0e10cSrcweir 							}
2279cdf0e10cSrcweir                             break;
2280cdf0e10cSrcweir 							case ']':
2281cdf0e10cSrcweir 							{
2282cdf0e10cSrcweir 								if (!bThousand)				// kein [ vorher
2283cdf0e10cSrcweir 									return nPos;
2284cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();
2285cdf0e10cSrcweir 								i++;
2286cdf0e10cSrcweir 							}
2287cdf0e10cSrcweir 							break;
2288cdf0e10cSrcweir 							default:
2289cdf0e10cSrcweir 							{
2290cdf0e10cSrcweir 								nPos = nPos + sStrArray[i].Len();
2291cdf0e10cSrcweir                                 if ( sStrArray[i] == sOldTimeSep )
2292cdf0e10cSrcweir                                 {
2293cdf0e10cSrcweir                                     nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP;
2294cdf0e10cSrcweir                                     if ( bConvertMode )
2295cdf0e10cSrcweir                                         sStrArray[i] = pLoc->getTimeSep();
2296cdf0e10cSrcweir                                 }
2297cdf0e10cSrcweir                                 else if ( sStrArray[i] == sOldTime100SecSep )
2298cdf0e10cSrcweir                                 {
2299cdf0e10cSrcweir                                     bDecSep = sal_True;
2300cdf0e10cSrcweir                                     nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP;
2301cdf0e10cSrcweir                                     if ( bConvertMode )
2302cdf0e10cSrcweir                                         sStrArray[i] = pLoc->getTime100SecSep();
2303cdf0e10cSrcweir                                 }
2304cdf0e10cSrcweir                                 else
2305cdf0e10cSrcweir                                     nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2306cdf0e10cSrcweir 								i++;
2307cdf0e10cSrcweir 							}
2308cdf0e10cSrcweir 							break;
2309cdf0e10cSrcweir 						}
2310cdf0e10cSrcweir 					}
2311cdf0e10cSrcweir 					break;
2312cdf0e10cSrcweir 					case NF_SYMBOLTYPE_STRING:
2313cdf0e10cSrcweir 					{
2314cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2315cdf0e10cSrcweir 						i++;
2316cdf0e10cSrcweir 					}
2317cdf0e10cSrcweir 					break;
2318cdf0e10cSrcweir 					case NF_SYMBOLTYPE_COMMENT:
2319cdf0e10cSrcweir 					{
2320cdf0e10cSrcweir 						String& rStr = sStrArray[i];
2321cdf0e10cSrcweir 						nPos = nPos + rStr.Len();
2322cdf0e10cSrcweir 						SvNumberformat::EraseCommentBraces( rStr );
2323cdf0e10cSrcweir 						rComment += rStr;
2324cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2325cdf0e10cSrcweir 						nAnzResStrings--;
2326cdf0e10cSrcweir 						i++;
2327cdf0e10cSrcweir 					}
2328cdf0e10cSrcweir 					break;
2329cdf0e10cSrcweir 					case NF_KEY_AMPM:						// AM/PM
2330cdf0e10cSrcweir 					case NF_KEY_AP:							// A/P
2331cdf0e10cSrcweir 					{
2332cdf0e10cSrcweir 						bExp = sal_True;					// missbraucht fuer A/P
2333cdf0e10cSrcweir 						sStrArray[i] = sKeyword[nTypeArray[i]];	// tTtT -> TTTT
2334cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2335cdf0e10cSrcweir 						i++;
2336cdf0e10cSrcweir 					}
2337cdf0e10cSrcweir 					break;
2338cdf0e10cSrcweir                     case NF_KEY_THAI_T :
2339cdf0e10cSrcweir                         bThaiT = true;
2340cdf0e10cSrcweir                         // fall thru
2341cdf0e10cSrcweir 					case NF_KEY_MI:							// M
2342cdf0e10cSrcweir 					case NF_KEY_MMI:						// MM
2343cdf0e10cSrcweir 					case NF_KEY_H:							// H
2344cdf0e10cSrcweir 					case NF_KEY_HH:							// HH
2345cdf0e10cSrcweir 					case NF_KEY_S:							// S
2346cdf0e10cSrcweir 					case NF_KEY_SS:							// SS
2347cdf0e10cSrcweir 					{
2348cdf0e10cSrcweir 						sStrArray[i] = sKeyword[nTypeArray[i]];	// tTtT -> TTTT
2349cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2350cdf0e10cSrcweir 						i++;
2351cdf0e10cSrcweir 					}
2352cdf0e10cSrcweir 					break;
2353cdf0e10cSrcweir 					default:							// andere Keywords
2354cdf0e10cSrcweir 					{
2355cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2356cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2357cdf0e10cSrcweir 						i++;
2358cdf0e10cSrcweir 					}
2359cdf0e10cSrcweir 					break;
2360cdf0e10cSrcweir 				}
2361cdf0e10cSrcweir 			}                   					// of while
2362cdf0e10cSrcweir 			nCntPost = nCounter;					// Zaehler der Nullen
2363cdf0e10cSrcweir 			if (bExp)
2364cdf0e10cSrcweir 				nCntExp = 1;						// merkt AM/PM
2365cdf0e10cSrcweir 		}
2366cdf0e10cSrcweir 		break;										// of NUMBERFORMAT_TIME
2367cdf0e10cSrcweir 		case NUMBERFORMAT_DATETIME:
2368cdf0e10cSrcweir 		{
2369cdf0e10cSrcweir             sal_Bool bTimePart = sal_False;
2370cdf0e10cSrcweir 			while (i < nAnzStrings)
2371cdf0e10cSrcweir 			{
2372cdf0e10cSrcweir 				switch (nTypeArray[i])
2373cdf0e10cSrcweir 				{
2374cdf0e10cSrcweir 					case NF_SYMBOLTYPE_BLANK:
2375cdf0e10cSrcweir 					case NF_SYMBOLTYPE_STAR:
2376cdf0e10cSrcweir 					case NF_SYMBOLTYPE_STRING:
2377cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2378cdf0e10cSrcweir 						i++;
2379cdf0e10cSrcweir 					break;
2380cdf0e10cSrcweir 					case NF_SYMBOLTYPE_COMMENT:
2381cdf0e10cSrcweir 					{
2382cdf0e10cSrcweir 						String& rStr = sStrArray[i];
2383cdf0e10cSrcweir 						nPos = nPos + rStr.Len();
2384cdf0e10cSrcweir 						SvNumberformat::EraseCommentBraces( rStr );
2385cdf0e10cSrcweir 						rComment += rStr;
2386cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2387cdf0e10cSrcweir 						nAnzResStrings--;
2388cdf0e10cSrcweir 						i++;
2389cdf0e10cSrcweir 					}
2390cdf0e10cSrcweir 					break;
2391cdf0e10cSrcweir 					case NF_SYMBOLTYPE_DEL:
2392cdf0e10cSrcweir 					{
2393cdf0e10cSrcweir 						int nCalRet;
2394cdf0e10cSrcweir                         if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 )
2395cdf0e10cSrcweir 						{
2396cdf0e10cSrcweir 							if ( nCalRet < 0  )
2397cdf0e10cSrcweir 								return nPos;		// error
2398cdf0e10cSrcweir 						}
2399cdf0e10cSrcweir 						else
2400cdf0e10cSrcweir 						{
2401cdf0e10cSrcweir                             switch( sStrArray[i].GetChar(0) )
2402cdf0e10cSrcweir                             {
2403cdf0e10cSrcweir                                 case '0':
2404cdf0e10cSrcweir                                 {
2405cdf0e10cSrcweir                                     if ( bTimePart && Is100SecZero( i, bDecSep ) )
2406cdf0e10cSrcweir                                     {
2407cdf0e10cSrcweir                                         bDecSep = sal_True;
2408cdf0e10cSrcweir                                         nTypeArray[i] = NF_SYMBOLTYPE_DIGIT;
2409cdf0e10cSrcweir                                         String& rStr = sStrArray[i];
2410cdf0e10cSrcweir                                         i++;
2411cdf0e10cSrcweir                                         nPos = nPos + sStrArray[i].Len();
2412cdf0e10cSrcweir                                         nCounter++;
2413cdf0e10cSrcweir                                         while (i < nAnzStrings &&
2414cdf0e10cSrcweir                                             sStrArray[i].GetChar(0) == '0')
2415cdf0e10cSrcweir                                         {
2416cdf0e10cSrcweir                                             rStr += sStrArray[i];
2417cdf0e10cSrcweir                                             nPos = nPos + sStrArray[i].Len();
2418cdf0e10cSrcweir                                             nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2419cdf0e10cSrcweir                                             nAnzResStrings--;
2420cdf0e10cSrcweir                                             nCounter++;
2421cdf0e10cSrcweir                                             i++;
2422cdf0e10cSrcweir                                         }
2423cdf0e10cSrcweir                                     }
2424cdf0e10cSrcweir                                     else
2425cdf0e10cSrcweir                                         return nPos;
2426cdf0e10cSrcweir                                 }
2427cdf0e10cSrcweir                                 break;
2428cdf0e10cSrcweir                                 case '#':
2429cdf0e10cSrcweir                                 case '?':
2430cdf0e10cSrcweir                                     return nPos;
2431cdf0e10cSrcweir                                 default:
2432cdf0e10cSrcweir                                 {
2433cdf0e10cSrcweir                                     nPos = nPos + sStrArray[i].Len();
2434cdf0e10cSrcweir                                     if (bTimePart)
2435cdf0e10cSrcweir                                     {
2436cdf0e10cSrcweir                                         if ( sStrArray[i] == sOldTimeSep )
2437cdf0e10cSrcweir                                         {
2438cdf0e10cSrcweir                                             nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP;
2439cdf0e10cSrcweir                                             if ( bConvertMode )
2440cdf0e10cSrcweir                                                 sStrArray[i] = pLoc->getTimeSep();
2441cdf0e10cSrcweir                                         }
2442cdf0e10cSrcweir                                         else if ( sStrArray[i] == sOldTime100SecSep )
2443cdf0e10cSrcweir                                         {
2444cdf0e10cSrcweir                                             bDecSep = sal_True;
2445cdf0e10cSrcweir                                             nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP;
2446cdf0e10cSrcweir                                             if ( bConvertMode )
2447cdf0e10cSrcweir                                                 sStrArray[i] = pLoc->getTime100SecSep();
2448cdf0e10cSrcweir                                         }
2449cdf0e10cSrcweir                                         else
2450cdf0e10cSrcweir                                             nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2451cdf0e10cSrcweir                                     }
2452cdf0e10cSrcweir                                     else
2453cdf0e10cSrcweir                                     {
2454cdf0e10cSrcweir                                         if ( sStrArray[i] == sOldDateSep )
2455cdf0e10cSrcweir                                         {
2456cdf0e10cSrcweir                                             nTypeArray[i] = NF_SYMBOLTYPE_DATESEP;
2457cdf0e10cSrcweir                                             if (bConvertMode)
2458cdf0e10cSrcweir                                                 sStrArray[i] = pFormatter->GetDateSep();
2459cdf0e10cSrcweir                                         }
2460cdf0e10cSrcweir                                         else
2461cdf0e10cSrcweir                                             nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2462cdf0e10cSrcweir                                     }
2463cdf0e10cSrcweir                                     i++;
2464cdf0e10cSrcweir                                 }
2465cdf0e10cSrcweir                             }
2466cdf0e10cSrcweir 						}
2467cdf0e10cSrcweir 					}
2468cdf0e10cSrcweir 					break;
2469cdf0e10cSrcweir 					case NF_KEY_AMPM:						// AM/PM
2470cdf0e10cSrcweir 					case NF_KEY_AP:							// A/P
2471cdf0e10cSrcweir 					{
2472cdf0e10cSrcweir                         bTimePart = sal_True;
2473cdf0e10cSrcweir 						bExp = sal_True;					// missbraucht fuer A/P
2474cdf0e10cSrcweir 						sStrArray[i] = sKeyword[nTypeArray[i]];	// tTtT -> TTTT
2475cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2476cdf0e10cSrcweir 						i++;
2477cdf0e10cSrcweir 					}
2478cdf0e10cSrcweir 					break;
2479cdf0e10cSrcweir 					case NF_KEY_MI:							// M
2480cdf0e10cSrcweir 					case NF_KEY_MMI:						// MM
2481cdf0e10cSrcweir 					case NF_KEY_H:							// H
2482cdf0e10cSrcweir 					case NF_KEY_HH:							// HH
2483cdf0e10cSrcweir 					case NF_KEY_S:							// S
2484cdf0e10cSrcweir 					case NF_KEY_SS:							// SS
2485cdf0e10cSrcweir                         bTimePart = sal_True;
2486cdf0e10cSrcweir 						sStrArray[i] = sKeyword[nTypeArray[i]];	// tTtT -> TTTT
2487cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2488cdf0e10cSrcweir 						i++;
2489cdf0e10cSrcweir 					break;
2490cdf0e10cSrcweir 					case NF_KEY_M:							// M
2491cdf0e10cSrcweir 					case NF_KEY_MM:							// MM
2492cdf0e10cSrcweir 					case NF_KEY_MMM:						// MMM
2493cdf0e10cSrcweir 					case NF_KEY_MMMM:						// MMMM
2494cdf0e10cSrcweir 					case NF_KEY_MMMMM:						// MMMMM
2495cdf0e10cSrcweir 					case NF_KEY_Q:							// Q
2496cdf0e10cSrcweir 					case NF_KEY_QQ:							// QQ
2497cdf0e10cSrcweir 					case NF_KEY_D:							// D
2498cdf0e10cSrcweir 					case NF_KEY_DD:							// DD
2499cdf0e10cSrcweir 					case NF_KEY_DDD:						// DDD
2500cdf0e10cSrcweir 					case NF_KEY_DDDD:						// DDDD
2501cdf0e10cSrcweir 					case NF_KEY_YY:							// YY
2502cdf0e10cSrcweir 					case NF_KEY_YYYY:						// YYYY
2503cdf0e10cSrcweir 					case NF_KEY_NN:							// NN
2504cdf0e10cSrcweir 					case NF_KEY_NNN:						// NNN
2505cdf0e10cSrcweir 					case NF_KEY_NNNN:						// NNNN
2506cdf0e10cSrcweir 					case NF_KEY_WW :						// WW
2507cdf0e10cSrcweir 					case NF_KEY_AAA :						// AAA
2508cdf0e10cSrcweir 					case NF_KEY_AAAA :						// AAAA
2509cdf0e10cSrcweir 					case NF_KEY_EC :						// E
2510cdf0e10cSrcweir 					case NF_KEY_EEC :						// EE
2511cdf0e10cSrcweir 					case NF_KEY_G :							// G
2512cdf0e10cSrcweir 					case NF_KEY_GG :						// GG
2513cdf0e10cSrcweir 					case NF_KEY_GGG :						// GGG
2514cdf0e10cSrcweir 					case NF_KEY_R :							// R
2515cdf0e10cSrcweir 					case NF_KEY_RR :						// RR
2516cdf0e10cSrcweir                         bTimePart = sal_False;
2517cdf0e10cSrcweir 						sStrArray[i] = sKeyword[nTypeArray[i]];	// tTtT -> TTTT
2518cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2519cdf0e10cSrcweir 						i++;
2520cdf0e10cSrcweir 					break;
2521cdf0e10cSrcweir                     case NF_KEY_THAI_T :
2522cdf0e10cSrcweir                         bThaiT = true;
2523cdf0e10cSrcweir 						sStrArray[i] = sKeyword[nTypeArray[i]];
2524cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2525cdf0e10cSrcweir 						i++;
2526cdf0e10cSrcweir 					break;
2527cdf0e10cSrcweir 					default:							// andere Keywords
2528cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_STRING;
2529cdf0e10cSrcweir 						nPos = nPos + sStrArray[i].Len();
2530cdf0e10cSrcweir 						i++;
2531cdf0e10cSrcweir 					break;
2532cdf0e10cSrcweir 				}
2533cdf0e10cSrcweir 			}										// of while
2534cdf0e10cSrcweir             nCntPost = nCounter;                    // decimals (100th seconds)
2535cdf0e10cSrcweir 			if (bExp)
2536cdf0e10cSrcweir 				nCntExp = 1;						// merkt AM/PM
2537cdf0e10cSrcweir 		}
2538cdf0e10cSrcweir 		break;										// of NUMBERFORMAT_DATETIME
2539cdf0e10cSrcweir 		default:
2540cdf0e10cSrcweir 		break;
2541cdf0e10cSrcweir 	}
2542cdf0e10cSrcweir 	if (eScannedType == NUMBERFORMAT_SCIENTIFIC &&
2543cdf0e10cSrcweir 		(nCntPre + nCntPost == 0 || nCntExp == 0))
2544cdf0e10cSrcweir 		return nPos;
2545cdf0e10cSrcweir 	else if (eScannedType == NUMBERFORMAT_FRACTION && (nCntExp > 8 || nCntExp == 0))
2546cdf0e10cSrcweir 		return nPos;
2547cdf0e10cSrcweir 
2548cdf0e10cSrcweir     if (bThaiT && !GetNatNumModifier())
2549cdf0e10cSrcweir         SetNatNumModifier(1);
2550cdf0e10cSrcweir 
2551cdf0e10cSrcweir 	if ( bConvertMode )
2552cdf0e10cSrcweir 	{	// strings containing keywords of the target locale must be quoted, so
2553cdf0e10cSrcweir 		// the user sees the difference and is able to edit the format string
2554cdf0e10cSrcweir 		for ( i=0; i < nAnzStrings; i++ )
2555cdf0e10cSrcweir 		{
2556cdf0e10cSrcweir 			if ( nTypeArray[i] == NF_SYMBOLTYPE_STRING &&
2557cdf0e10cSrcweir 					sStrArray[i].GetChar(0) != '\"' )
2558cdf0e10cSrcweir 			{
2559cdf0e10cSrcweir 				if ( bConvertSystemToSystem && eScannedType == NUMBERFORMAT_CURRENCY )
2560cdf0e10cSrcweir 				{	// don't stringize automatic currency, will be converted
2561cdf0e10cSrcweir                     if ( sStrArray[i] == sOldCurSymbol )
2562cdf0e10cSrcweir 						continue;	// for
2563cdf0e10cSrcweir 					// DM might be splitted into D and M
2564cdf0e10cSrcweir                     if ( sStrArray[i].Len() < sOldCurSymbol.Len() &&
2565cdf0e10cSrcweir 							pChrCls->toUpper( sStrArray[i], 0, 1 ).GetChar(0) ==
2566cdf0e10cSrcweir 							sOldCurString.GetChar(0) )
2567cdf0e10cSrcweir 					{
2568cdf0e10cSrcweir 						String aTmp( sStrArray[i] );
2569cdf0e10cSrcweir 						sal_uInt16 j = i + 1;
2570cdf0e10cSrcweir                         while ( aTmp.Len() < sOldCurSymbol.Len() &&
2571cdf0e10cSrcweir 								j < nAnzStrings &&
2572cdf0e10cSrcweir 								nTypeArray[j] == NF_SYMBOLTYPE_STRING )
2573cdf0e10cSrcweir 						{
2574cdf0e10cSrcweir 							aTmp += sStrArray[j++];
2575cdf0e10cSrcweir 						}
2576cdf0e10cSrcweir 						if ( pChrCls->upper( aTmp ) == sOldCurString )
2577cdf0e10cSrcweir 						{
2578cdf0e10cSrcweir 							sStrArray[i++] = aTmp;
2579cdf0e10cSrcweir 							for ( ; i<j; i++ )
2580cdf0e10cSrcweir 							{
2581cdf0e10cSrcweir 								nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2582cdf0e10cSrcweir 								nAnzResStrings--;
2583cdf0e10cSrcweir 							}
2584cdf0e10cSrcweir 							i = j - 1;
2585cdf0e10cSrcweir 							continue;	// for
2586cdf0e10cSrcweir 						}
2587cdf0e10cSrcweir 					}
2588cdf0e10cSrcweir 				}
2589cdf0e10cSrcweir 				String& rStr = sStrArray[i];
2590cdf0e10cSrcweir 				xub_StrLen nLen = rStr.Len();
2591cdf0e10cSrcweir 				for ( xub_StrLen j=0; j<nLen; j++ )
2592cdf0e10cSrcweir 				{
2593cdf0e10cSrcweir 					if ( (j == 0 || rStr.GetChar(j-1) != '\\') && GetKeyWord( rStr, j ) )
2594cdf0e10cSrcweir 					{
2595cdf0e10cSrcweir 						rStr.Insert( '\"', 0 );
2596cdf0e10cSrcweir 						rStr += '\"';
2597cdf0e10cSrcweir 						break;	// for
2598cdf0e10cSrcweir 					}
2599cdf0e10cSrcweir 				}
2600cdf0e10cSrcweir 			}
2601cdf0e10cSrcweir 		}
2602cdf0e10cSrcweir 	}
2603cdf0e10cSrcweir 	// concatenate strings, remove quotes for output, and rebuild the format string
2604cdf0e10cSrcweir 	rString.Erase();
2605cdf0e10cSrcweir 	i = 0;
2606cdf0e10cSrcweir 	while (i < nAnzStrings)
2607cdf0e10cSrcweir 	{
2608cdf0e10cSrcweir 		switch ( nTypeArray[i] )
2609cdf0e10cSrcweir 		{
2610cdf0e10cSrcweir 			case NF_SYMBOLTYPE_STRING :
2611cdf0e10cSrcweir 			{
2612cdf0e10cSrcweir 				xub_StrLen nStringPos = rString.Len();
2613cdf0e10cSrcweir 				xub_StrLen nArrPos = 0;
2614cdf0e10cSrcweir 				sal_uInt16 iPos = i;
2615cdf0e10cSrcweir 				do
2616cdf0e10cSrcweir 				{
2617cdf0e10cSrcweir                     if (sStrArray[i].Len() == 2 &&
2618cdf0e10cSrcweir                             sStrArray[i].GetChar(0) == '\\')
2619cdf0e10cSrcweir                     {
2620cdf0e10cSrcweir                         // Unescape some simple forms of symbols even in the UI
2621cdf0e10cSrcweir                         // visible string to prevent duplicates that differ
2622cdf0e10cSrcweir                         // only in notation, originating from import.
2623cdf0e10cSrcweir                         // e.g. YYYY-MM-DD and YYYY\-MM\-DD are identical,
2624cdf0e10cSrcweir                         // but 0\ 000 0 and 0 000 0 in a French locale are not.
2625cdf0e10cSrcweir                         sal_Unicode c = sStrArray[i].GetChar(1);
2626cdf0e10cSrcweir                         switch (c)
2627cdf0e10cSrcweir                         {
2628cdf0e10cSrcweir                             case '+':
2629cdf0e10cSrcweir                             case '-':
2630cdf0e10cSrcweir                                 rString += c;
2631cdf0e10cSrcweir                                 break;
2632cdf0e10cSrcweir                             case ' ':
2633cdf0e10cSrcweir                             case '.':
2634cdf0e10cSrcweir                             case '/':
2635cdf0e10cSrcweir                                 if (((eScannedType & NUMBERFORMAT_DATE) == 0)
2636cdf0e10cSrcweir                                         && (StringEqualsChar(
2637cdf0e10cSrcweir                                                 pFormatter->GetNumThousandSep(),
2638cdf0e10cSrcweir                                                 c) || StringEqualsChar(
2639cdf0e10cSrcweir                                                     pFormatter->GetNumDecimalSep(),
2640cdf0e10cSrcweir                                                     c) || (c == ' ' &&
2641cdf0e10cSrcweir                                                         StringEqualsChar(
2642cdf0e10cSrcweir                                                             pFormatter->GetNumThousandSep(),
2643cdf0e10cSrcweir                                                             cNonBreakingSpace))))
2644cdf0e10cSrcweir                                     rString += sStrArray[i];
2645cdf0e10cSrcweir                                 else if ((eScannedType & NUMBERFORMAT_DATE) &&
2646cdf0e10cSrcweir                                         StringEqualsChar(
2647cdf0e10cSrcweir                                             pFormatter->GetDateSep(), c))
2648cdf0e10cSrcweir                                     rString += sStrArray[i];
2649cdf0e10cSrcweir                                 else if ((eScannedType & NUMBERFORMAT_TIME) &&
2650cdf0e10cSrcweir                                         (StringEqualsChar( pLoc->getTimeSep(),
2651cdf0e10cSrcweir                                                            c) ||
2652cdf0e10cSrcweir                                          StringEqualsChar(
2653cdf0e10cSrcweir                                              pLoc->getTime100SecSep(), c)))
2654cdf0e10cSrcweir                                     rString += sStrArray[i];
2655cdf0e10cSrcweir                                 else if (eScannedType & NUMBERFORMAT_FRACTION)
2656cdf0e10cSrcweir                                     rString += sStrArray[i];
2657cdf0e10cSrcweir                                 else
2658cdf0e10cSrcweir                                     rString += c;
2659cdf0e10cSrcweir                                 break;
2660cdf0e10cSrcweir                             default:
2661cdf0e10cSrcweir                                 rString += sStrArray[i];
2662cdf0e10cSrcweir                         }
2663cdf0e10cSrcweir                     }
2664cdf0e10cSrcweir                     else
2665cdf0e10cSrcweir                         rString += sStrArray[i];
2666cdf0e10cSrcweir 					if ( RemoveQuotes( sStrArray[i] ) > 0 )
2667cdf0e10cSrcweir 					{	// update currency up to quoted string
2668cdf0e10cSrcweir 						if ( eScannedType == NUMBERFORMAT_CURRENCY )
2669cdf0e10cSrcweir 						{	// dM -> DM  or  DM -> $  in old automatic
2670cdf0e10cSrcweir 							// currency formats, oh my ..., why did we ever
2671cdf0e10cSrcweir 							// introduce them?
2672cdf0e10cSrcweir 							String aTmp( pChrCls->toUpper(
2673cdf0e10cSrcweir 								sStrArray[iPos], nArrPos,
2674cdf0e10cSrcweir 								sStrArray[iPos].Len()-nArrPos ) );
2675cdf0e10cSrcweir 							xub_StrLen nCPos = aTmp.Search( sOldCurString );
2676cdf0e10cSrcweir 							if ( nCPos != STRING_NOTFOUND )
2677cdf0e10cSrcweir 							{
2678cdf0e10cSrcweir 								const String& rCur =
2679cdf0e10cSrcweir 									bConvertMode && bConvertSystemToSystem ?
2680cdf0e10cSrcweir                                     GetCurSymbol() : sOldCurSymbol;
2681cdf0e10cSrcweir 								sStrArray[iPos].Replace( nArrPos+nCPos,
2682cdf0e10cSrcweir 									sOldCurString.Len(), rCur );
2683cdf0e10cSrcweir 								rString.Replace( nStringPos+nCPos,
2684cdf0e10cSrcweir 									sOldCurString.Len(), rCur );
2685cdf0e10cSrcweir 							}
2686cdf0e10cSrcweir 							nStringPos = rString.Len();
2687cdf0e10cSrcweir 							if ( iPos == i )
2688cdf0e10cSrcweir 								nArrPos = sStrArray[iPos].Len();
2689cdf0e10cSrcweir 							else
2690cdf0e10cSrcweir 								nArrPos = sStrArray[iPos].Len() + sStrArray[i].Len();
2691cdf0e10cSrcweir 						}
2692cdf0e10cSrcweir 					}
2693cdf0e10cSrcweir 					if ( iPos != i )
2694cdf0e10cSrcweir 					{
2695cdf0e10cSrcweir 						sStrArray[iPos] += sStrArray[i];
2696cdf0e10cSrcweir 						nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2697cdf0e10cSrcweir 						nAnzResStrings--;
2698cdf0e10cSrcweir 					}
2699cdf0e10cSrcweir 					i++;
2700cdf0e10cSrcweir 				} while ( i < nAnzStrings && nTypeArray[i] == NF_SYMBOLTYPE_STRING );
2701cdf0e10cSrcweir 				if ( i < nAnzStrings )
2702cdf0e10cSrcweir 					i--;	// enter switch on next symbol again
2703cdf0e10cSrcweir 				if ( eScannedType == NUMBERFORMAT_CURRENCY && nStringPos < rString.Len() )
2704cdf0e10cSrcweir 				{	// same as above, since last RemoveQuotes
2705cdf0e10cSrcweir 					String aTmp( pChrCls->toUpper(
2706cdf0e10cSrcweir 						sStrArray[iPos], nArrPos,
2707cdf0e10cSrcweir 						sStrArray[iPos].Len()-nArrPos ) );
2708cdf0e10cSrcweir 					xub_StrLen nCPos = aTmp.Search( sOldCurString );
2709cdf0e10cSrcweir 					if ( nCPos != STRING_NOTFOUND )
2710cdf0e10cSrcweir 					{
2711cdf0e10cSrcweir 						const String& rCur =
2712cdf0e10cSrcweir 							bConvertMode && bConvertSystemToSystem ?
2713cdf0e10cSrcweir                             GetCurSymbol() : sOldCurSymbol;
2714cdf0e10cSrcweir 						sStrArray[iPos].Replace( nArrPos+nCPos,
2715cdf0e10cSrcweir 							sOldCurString.Len(), rCur );
2716cdf0e10cSrcweir 						rString.Replace( nStringPos+nCPos,
2717cdf0e10cSrcweir 							sOldCurString.Len(), rCur );
2718cdf0e10cSrcweir 					}
2719cdf0e10cSrcweir 				}
2720cdf0e10cSrcweir 			}
2721cdf0e10cSrcweir 			break;
2722cdf0e10cSrcweir 			case NF_SYMBOLTYPE_CURRENCY :
2723cdf0e10cSrcweir 			{
2724cdf0e10cSrcweir 				rString += sStrArray[i];
2725cdf0e10cSrcweir 				RemoveQuotes( sStrArray[i] );
2726cdf0e10cSrcweir 			}
2727cdf0e10cSrcweir 			break;
2728cdf0e10cSrcweir             case NF_KEY_THAI_T:
2729cdf0e10cSrcweir                 if (bThaiT && GetNatNumModifier() == 1)
2730cdf0e10cSrcweir                 {   // Remove T from format code, will be replaced with a [NatNum1] prefix.
2731cdf0e10cSrcweir                     nTypeArray[i] = NF_SYMBOLTYPE_EMPTY;
2732cdf0e10cSrcweir                     nAnzResStrings--;
2733cdf0e10cSrcweir                 }
2734cdf0e10cSrcweir                 else
2735cdf0e10cSrcweir                     rString += sStrArray[i];
2736cdf0e10cSrcweir             break;
2737cdf0e10cSrcweir 			case NF_SYMBOLTYPE_EMPTY :
2738cdf0e10cSrcweir 				// nothing
2739cdf0e10cSrcweir 			break;
2740cdf0e10cSrcweir 			default:
2741cdf0e10cSrcweir 				rString += sStrArray[i];
2742cdf0e10cSrcweir 		}
2743cdf0e10cSrcweir 		i++;
2744cdf0e10cSrcweir 	}
2745cdf0e10cSrcweir 	return 0;
2746cdf0e10cSrcweir }
2747cdf0e10cSrcweir 
2748cdf0e10cSrcweir 
RemoveQuotes(String & rStr)2749cdf0e10cSrcweir xub_StrLen ImpSvNumberformatScan::RemoveQuotes( String& rStr )
2750cdf0e10cSrcweir {
2751cdf0e10cSrcweir 	if ( rStr.Len() > 1 )
2752cdf0e10cSrcweir 	{
2753cdf0e10cSrcweir 		sal_Unicode c = rStr.GetChar(0);
2754cdf0e10cSrcweir 		xub_StrLen n;
2755cdf0e10cSrcweir 		if ( c == '"' && rStr.GetChar( (n = xub_StrLen(rStr.Len()-1)) ) == '"' )
2756cdf0e10cSrcweir 		{
2757cdf0e10cSrcweir 			rStr.Erase(n,1);
2758cdf0e10cSrcweir 			rStr.Erase(0,1);
2759cdf0e10cSrcweir 			return 2;
2760cdf0e10cSrcweir 		}
2761cdf0e10cSrcweir 		else if ( c == '\\' )
2762cdf0e10cSrcweir 		{
2763cdf0e10cSrcweir 			rStr.Erase(0,1);
2764cdf0e10cSrcweir 			return 1;
2765cdf0e10cSrcweir 		}
2766cdf0e10cSrcweir 	}
2767cdf0e10cSrcweir 	return 0;
2768cdf0e10cSrcweir }
2769cdf0e10cSrcweir 
2770cdf0e10cSrcweir 
ScanFormat(String & rString,String & rComment)2771cdf0e10cSrcweir xub_StrLen ImpSvNumberformatScan::ScanFormat( String& rString, String& rComment )
2772cdf0e10cSrcweir {
2773cdf0e10cSrcweir 	xub_StrLen res = Symbol_Division(rString);	//lexikalische Analyse
2774cdf0e10cSrcweir 	if (!res)
2775cdf0e10cSrcweir 		res = ScanType(rString);            // Erkennung des Formattyps
2776cdf0e10cSrcweir 	if (!res)
2777cdf0e10cSrcweir 		res = FinalScan( rString, rComment );	// Typabhaengige Endanalyse
2778cdf0e10cSrcweir 	return res;								// res = Kontrollposition
2779cdf0e10cSrcweir 											// res = 0 => Format ok
2780cdf0e10cSrcweir }
2781cdf0e10cSrcweir 
CopyInfo(ImpSvNumberformatInfo * pInfo,sal_uInt16 nAnz)2782cdf0e10cSrcweir void ImpSvNumberformatScan::CopyInfo(ImpSvNumberformatInfo* pInfo, sal_uInt16 nAnz)
2783cdf0e10cSrcweir {
2784cdf0e10cSrcweir 	size_t i,j;
2785cdf0e10cSrcweir 	j = 0;
2786cdf0e10cSrcweir 	i = 0;
2787cdf0e10cSrcweir 	while (i < nAnz && j < NF_MAX_FORMAT_SYMBOLS)
2788cdf0e10cSrcweir 	{
2789cdf0e10cSrcweir 		if (nTypeArray[j] != NF_SYMBOLTYPE_EMPTY)
2790cdf0e10cSrcweir 		{
2791cdf0e10cSrcweir 			pInfo->sStrArray[i]  = sStrArray[j];
2792cdf0e10cSrcweir 			pInfo->nTypeArray[i] = nTypeArray[j];
2793cdf0e10cSrcweir 			i++;
2794cdf0e10cSrcweir 		}
2795cdf0e10cSrcweir 		j++;
2796cdf0e10cSrcweir 	}
2797cdf0e10cSrcweir 	pInfo->eScannedType = eScannedType;
2798cdf0e10cSrcweir 	pInfo->bThousand    = bThousand;
2799cdf0e10cSrcweir 	pInfo->nThousand    = nThousand;
2800cdf0e10cSrcweir 	pInfo->nCntPre      = nCntPre;
2801cdf0e10cSrcweir 	pInfo->nCntPost     = nCntPost;
2802cdf0e10cSrcweir 	pInfo->nCntExp      = nCntExp;
2803cdf0e10cSrcweir }
2804cdf0e10cSrcweir 
2805cdf0e10cSrcweir 
2806