/libreoffice-3.6.0.2/svl/source/numbers/zforscan.cxx
C++ | 2747 lines | 2525 code | 69 blank | 153 comment | 630 complexity | 55af38704f2ae0ab1cbc4f5fc13bc5fc MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, AGPL-1.0, BSD-3-Clause-No-Nuclear-License-2014, GPL-3.0, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
- /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
- /*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
- #include <stdlib.h>
- #include <tools/debug.hxx>
- #include <i18npool/mslangid.hxx>
- #include <unotools/charclass.hxx>
- #include <unotools/localedatawrapper.hxx>
- #include <unotools/numberformatcodewrapper.hxx>
- #include <rtl/instance.hxx>
- #include <svl/zforlist.hxx>
- #include <svl/zformat.hxx>
- #include <unotools/digitgroupingiterator.hxx>
- #define _ZFORSCAN_CXX
- #include "zforscan.hxx"
- #undef _ZFORSCAN_CXX
- #include <svl/nfsymbol.hxx>
- using namespace svt;
- const sal_Unicode cNonBreakingSpace = 0xA0;
- namespace
- {
- struct ImplEnglishColors
- {
- const String* operator()()
- {
- static const String aEnglishColors[NF_MAX_DEFAULT_COLORS] =
- {
- String( RTL_CONSTASCII_USTRINGPARAM( "BLACK" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "BLUE" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "GREEN" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "CYAN" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "RED" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "MAGENTA" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "BROWN" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "GREY" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "YELLOW" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "WHITE" ) )
- };
- return &aEnglishColors[0];
- }
- };
- struct theEnglishColors
- : public rtl::StaticAggregate< const String, ImplEnglishColors> {};
- }
- ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
- {
- pFormatter = pFormatterP;
- bConvertMode = false;
- //! All keywords MUST be UPPERCASE!
- sKeyword[NF_KEY_E].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "E" ) ); // Exponent
- sKeyword[NF_KEY_AMPM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AM/PM" ) ); // AM/PM
- sKeyword[NF_KEY_AP].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "A/P" ) ); // AM/PM short
- sKeyword[NF_KEY_MI].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "M" ) ); // Minute
- sKeyword[NF_KEY_MMI].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MM" ) ); // Minute 02
- sKeyword[NF_KEY_S].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "S" ) ); // Second
- sKeyword[NF_KEY_SS].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "SS" ) ); // Second 02
- sKeyword[NF_KEY_Q].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Q" ) ); // Quarter short 'Q'
- sKeyword[NF_KEY_QQ].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "QQ" ) ); // Quarter long
- sKeyword[NF_KEY_NN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NN" ) ); // Day of week short
- sKeyword[NF_KEY_NNN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NNN" ) ); // Day of week long
- sKeyword[NF_KEY_NNNN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "NNNN" ) ); // Day of week long incl. separator
- sKeyword[NF_KEY_WW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "WW" ) ); // Week of year
- sKeyword[NF_KEY_CCC].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "CCC" ) ); // Currency abbreviation
- bKeywordsNeedInit = true; // locale dependent keywords
- bCompatCurNeedInit = true; // locale dependent compatibility currency strings
- StandardColor[0] = Color(COL_BLACK);
- StandardColor[1] = Color(COL_LIGHTBLUE);
- StandardColor[2] = Color(COL_LIGHTGREEN);
- StandardColor[3] = Color(COL_LIGHTCYAN);
- StandardColor[4] = Color(COL_LIGHTRED);
- StandardColor[5] = Color(COL_LIGHTMAGENTA);
- StandardColor[6] = Color(COL_BROWN);
- StandardColor[7] = Color(COL_GRAY);
- StandardColor[8] = Color(COL_YELLOW);
- StandardColor[9] = Color(COL_WHITE);
- pNullDate = new Date(30,12,1899);
- nStandardPrec = 2;
- sErrStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "###" ) );
- Reset();
- }
- ImpSvNumberformatScan::~ImpSvNumberformatScan()
- {
- delete pNullDate;
- Reset();
- }
- void ImpSvNumberformatScan::ChangeIntl()
- {
- bKeywordsNeedInit = true;
- bCompatCurNeedInit = true;
- // may be initialized by InitSpecialKeyword()
- sKeyword[NF_KEY_TRUE].Erase();
- sKeyword[NF_KEY_FALSE].Erase();
- }
- void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const
- {
- switch ( eIdx )
- {
- case NF_KEY_TRUE :
- ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE] =
- pFormatter->GetCharClass()->uppercase(
- pFormatter->GetLocaleData()->getTrueWord() );
- if ( !sKeyword[NF_KEY_TRUE].Len() )
- {
- SAL_WARN( "svl.numbers", "InitSpecialKeyword: TRUE_WORD?" );
- ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_TRUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TRUE" ) );
- }
- break;
- case NF_KEY_FALSE :
- ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE] =
- pFormatter->GetCharClass()->uppercase(
- pFormatter->GetLocaleData()->getFalseWord() );
- if ( !sKeyword[NF_KEY_FALSE].Len() )
- {
- SAL_WARN( "svl.numbers", "InitSpecialKeyword: FALSE_WORD?" );
- ((ImpSvNumberformatScan*)this)->sKeyword[NF_KEY_FALSE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "FALSE" ) );
- }
- break;
- default:
- SAL_WARN( "svl.numbers", "InitSpecialKeyword: unknown request" );
- }
- }
- void ImpSvNumberformatScan::InitCompatCur() const
- {
- ImpSvNumberformatScan* pThis = (ImpSvNumberformatScan*)this;
- // currency symbol for old style ("automatic") compatibility format codes
- pFormatter->GetCompatibilityCurrency( pThis->sCurSymbol, pThis->sCurAbbrev );
- // currency symbol upper case
- pThis->sCurString = pFormatter->GetCharClass()->uppercase( sCurSymbol );
- bCompatCurNeedInit = false;
- }
- void ImpSvNumberformatScan::InitKeywords() const
- {
- if ( !bKeywordsNeedInit )
- return ;
- ((ImpSvNumberformatScan*)this)->SetDependentKeywords();
- bKeywordsNeedInit = false;
- }
- /** Extract the name of General, Standard, Whatever, ignoring leading modifiers
- such as [NatNum1]. */
- static String lcl_extractStandardGeneralName( const ::rtl::OUString & rCode )
- {
- String aStr;
- const sal_Unicode* p = rCode.getStr();
- const sal_Unicode* const pStop = p + rCode.getLength();
- const sal_Unicode* pBeg = p; // name begins here
- bool bMod = false;
- bool bDone = false;
- while (p < pStop && !bDone)
- {
- switch (*p)
- {
- case '[':
- bMod = true;
- break;
- case ']':
- if (bMod)
- {
- bMod = false;
- pBeg = p+1;
- }
- // else: would be a locale data error, easily to be spotted in
- // UI dialog
- break;
- case ';':
- if (!bMod)
- {
- bDone = true;
- --p; // put back, increment by one follows
- }
- break;
- }
- ++p;
- if (bMod)
- pBeg = p;
- }
- if (pBeg < p)
- aStr = rCode.copy( pBeg - rCode.getStr(), p - pBeg);
- return aStr;
- }
- void ImpSvNumberformatScan::SetDependentKeywords()
- {
- using namespace ::com::sun::star;
- using namespace ::com::sun::star::uno;
- const CharClass* pCharClass = pFormatter->GetCharClass();
- const LocaleDataWrapper* pLocaleData = pFormatter->GetLocaleData();
- // #80023# be sure to generate keywords for the loaded Locale, not for the
- // requested Locale, otherwise number format codes might not match
- lang::Locale aLoadedLocale = pLocaleData->getLoadedLocale();
- LanguageType eLang = MsLangId::convertLocaleToLanguage( aLoadedLocale );
- NumberFormatCodeWrapper aNumberFormatCode( pFormatter->GetServiceManager(), aLoadedLocale );
- i18n::NumberFormatCode aFormat = aNumberFormatCode.getFormatCode( NF_NUMBER_STANDARD );
- sNameStandardFormat = lcl_extractStandardGeneralName( aFormat.Code);
- sKeyword[NF_KEY_GENERAL] = pCharClass->uppercase( sNameStandardFormat );
- // preset new calendar keywords
- sKeyword[NF_KEY_AAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AAA" ) );
- sKeyword[NF_KEY_AAAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AAAA" ) );
- sKeyword[NF_KEY_EC].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "E" ) );
- sKeyword[NF_KEY_EEC].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "EE" ) );
- sKeyword[NF_KEY_G].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "G" ) );
- sKeyword[NF_KEY_GG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GG" ) );
- sKeyword[NF_KEY_GGG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGG" ) );
- sKeyword[NF_KEY_R].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "R" ) );
- sKeyword[NF_KEY_RR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "RR" ) );
- // Thai T NatNum special. Other locale's small letter 't' results in upper
- // case comparison not matching but length does in conversion mode. Ugly.
- if (eLang == LANGUAGE_THAI)
- sKeyword[NF_KEY_THAI_T].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T"));
- else
- sKeyword[NF_KEY_THAI_T].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "t"));
- switch ( eLang )
- {
- case LANGUAGE_GERMAN:
- case LANGUAGE_GERMAN_SWISS:
- case LANGUAGE_GERMAN_AUSTRIAN:
- case LANGUAGE_GERMAN_LUXEMBOURG:
- case LANGUAGE_GERMAN_LIECHTENSTEIN:
- {
- //! all capital letters
- sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "M" ) ); // month 1
- sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MM" ) ); // month 01
- sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMM" ) ); // month Jan
- sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMM" ) ); // month Januar
- sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMMM" ) );// month J
- sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "H" ) ); // hour 2
- sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "HH" ) ); // hour 02
- sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T" ) );
- sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TT" ) );
- sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TTT" ) );
- sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TTTT" ) );
- sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
- sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
- sKeyword[NF_KEY_BOOLEAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "LOGISCH" ) );
- sKeyword[NF_KEY_COLOR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "FARBE" ) );
- sKeyword[NF_KEY_BLACK].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "SCHWARZ" ) );
- sKeyword[NF_KEY_BLUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BLAU" ) );
- sKeyword[NF_KEY_GREEN] = UniString( "GR" "\xDC" "N", RTL_TEXTENCODING_ISO_8859_1 );
- sKeyword[NF_KEY_CYAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "CYAN" ) );
- sKeyword[NF_KEY_RED].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "ROT" ) );
- sKeyword[NF_KEY_MAGENTA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MAGENTA" ) );
- sKeyword[NF_KEY_BROWN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BRAUN" ) );
- sKeyword[NF_KEY_GREY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GRAU" ) );
- sKeyword[NF_KEY_YELLOW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GELB" ) );
- sKeyword[NF_KEY_WHITE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "WEISS" ) );
- }
- break;
- default:
- {
- // day
- switch ( eLang )
- {
- case LANGUAGE_ITALIAN :
- case LANGUAGE_ITALIAN_SWISS :
- sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "G" ) );
- sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GG" ) );
- sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGG" ) );
- sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GGGG" ) );
- // must exchange the era code, same as Xcl
- sKeyword[NF_KEY_G].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "X" ) );
- sKeyword[NF_KEY_GG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "XX" ) );
- sKeyword[NF_KEY_GGG].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
- break;
- case LANGUAGE_FRENCH :
- case LANGUAGE_FRENCH_BELGIAN :
- case LANGUAGE_FRENCH_CANADIAN :
- case LANGUAGE_FRENCH_SWISS :
- case LANGUAGE_FRENCH_LUXEMBOURG :
- case LANGUAGE_FRENCH_MONACO :
- sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "J" ) );
- sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
- sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJ" ) );
- sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
- break;
- case LANGUAGE_FINNISH :
- sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "P" ) );
- sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PP" ) );
- sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PPP" ) );
- sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "PPPP" ) );
- break;
- default:
- sKeyword[NF_KEY_D].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D" ) );
- sKeyword[NF_KEY_DD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DD" ) );
- sKeyword[NF_KEY_DDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDD" ) );
- sKeyword[NF_KEY_DDDD].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDDD" ) );
- }
- // month
- switch ( eLang )
- {
- case LANGUAGE_FINNISH :
- sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "K" ) );
- sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KK" ) );
- sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKK" ) );
- sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKKK" ) );
- sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "KKKKK" ) );
- break;
- default:
- sKeyword[NF_KEY_M].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "M" ) );
- sKeyword[NF_KEY_MM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MM" ) );
- sKeyword[NF_KEY_MMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMM" ) );
- sKeyword[NF_KEY_MMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMM" ) );
- sKeyword[NF_KEY_MMMMM].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MMMMM" ) );
- }
- // year
- switch ( eLang )
- {
- case LANGUAGE_ITALIAN :
- case LANGUAGE_ITALIAN_SWISS :
- case LANGUAGE_FRENCH :
- case LANGUAGE_FRENCH_BELGIAN :
- case LANGUAGE_FRENCH_CANADIAN :
- case LANGUAGE_FRENCH_SWISS :
- case LANGUAGE_FRENCH_LUXEMBOURG :
- case LANGUAGE_FRENCH_MONACO :
- case LANGUAGE_PORTUGUESE :
- case LANGUAGE_PORTUGUESE_BRAZILIAN :
- case LANGUAGE_SPANISH_MODERN :
- case LANGUAGE_SPANISH_DATED :
- case LANGUAGE_SPANISH_MEXICAN :
- case LANGUAGE_SPANISH_GUATEMALA :
- case LANGUAGE_SPANISH_COSTARICA :
- case LANGUAGE_SPANISH_PANAMA :
- case LANGUAGE_SPANISH_DOMINICAN_REPUBLIC :
- case LANGUAGE_SPANISH_VENEZUELA :
- case LANGUAGE_SPANISH_COLOMBIA :
- case LANGUAGE_SPANISH_PERU :
- case LANGUAGE_SPANISH_ARGENTINA :
- case LANGUAGE_SPANISH_ECUADOR :
- case LANGUAGE_SPANISH_CHILE :
- case LANGUAGE_SPANISH_URUGUAY :
- case LANGUAGE_SPANISH_PARAGUAY :
- case LANGUAGE_SPANISH_BOLIVIA :
- case LANGUAGE_SPANISH_EL_SALVADOR :
- case LANGUAGE_SPANISH_HONDURAS :
- case LANGUAGE_SPANISH_NICARAGUA :
- case LANGUAGE_SPANISH_PUERTO_RICO :
- sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AA" ) );
- sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "AAAA" ) );
- // must exchange the day of week name code, same as Xcl
- sKeyword[NF_KEY_AAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "OOO" ) );
- sKeyword[NF_KEY_AAAA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "OOOO" ) );
- break;
- case LANGUAGE_DUTCH :
- case LANGUAGE_DUTCH_BELGIAN :
- sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJ" ) );
- sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "JJJJ" ) );
- break;
- case LANGUAGE_FINNISH :
- sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "VV" ) );
- sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "VVVV" ) );
- break;
- default:
- sKeyword[NF_KEY_YY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YY" ) );
- sKeyword[NF_KEY_YYYY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YYYY" ) );
- }
- // hour
- switch ( eLang )
- {
- case LANGUAGE_DUTCH :
- case LANGUAGE_DUTCH_BELGIAN :
- sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "U" ) );
- sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "UU" ) );
- break;
- case LANGUAGE_FINNISH :
- case LANGUAGE_SWEDISH :
- case LANGUAGE_SWEDISH_FINLAND :
- case LANGUAGE_DANISH :
- case LANGUAGE_NORWEGIAN :
- case LANGUAGE_NORWEGIAN_BOKMAL :
- case LANGUAGE_NORWEGIAN_NYNORSK :
- sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "T" ) );
- sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "TT" ) );
- break;
- default:
- sKeyword[NF_KEY_H].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "H" ) );
- sKeyword[NF_KEY_HH].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "HH" ) );
- }
- // boolean
- sKeyword[NF_KEY_BOOLEAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BOOLEAN" ) );
- // colours
- sKeyword[NF_KEY_COLOR].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "COLOR" ) );
- sKeyword[NF_KEY_BLACK].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BLACK" ) );
- sKeyword[NF_KEY_BLUE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BLUE" ) );
- sKeyword[NF_KEY_GREEN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GREEN" ) );
- sKeyword[NF_KEY_CYAN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "CYAN" ) );
- sKeyword[NF_KEY_RED].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "RED" ) );
- sKeyword[NF_KEY_MAGENTA].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "MAGENTA" ) );
- sKeyword[NF_KEY_BROWN].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "BROWN" ) );
- sKeyword[NF_KEY_GREY].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "GREY" ) );
- sKeyword[NF_KEY_YELLOW].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "YELLOW" ) );
- sKeyword[NF_KEY_WHITE].AssignAscii( RTL_CONSTASCII_STRINGPARAM( "WHITE" ) );
- }
- break;
- }
- // boolean keyords
- InitSpecialKeyword( NF_KEY_TRUE );
- InitSpecialKeyword( NF_KEY_FALSE );
- // compatibility currency strings
- InitCompatCur();
- }
- void ImpSvNumberformatScan::ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear)
- {
- if ( pNullDate )
- *pNullDate = Date(nDay, nMonth, nYear);
- else
- pNullDate = new Date(nDay, nMonth, nYear);
- }
- void ImpSvNumberformatScan::ChangeStandardPrec(sal_uInt16 nPrec)
- {
- nStandardPrec = nPrec;
- }
- Color* ImpSvNumberformatScan::GetColor(String& sStr)
- {
- String sString = pFormatter->GetCharClass()->uppercase(sStr);
- const NfKeywordTable & rKeyword = GetKeywords();
- size_t i = 0;
- while (i < NF_MAX_DEFAULT_COLORS &&
- sString != rKeyword[NF_KEY_FIRSTCOLOR+i] )
- i++;
- if ( i >= NF_MAX_DEFAULT_COLORS )
- {
- const String* pEnglishColors = theEnglishColors::get();
- size_t j = 0;
- while ( j < NF_MAX_DEFAULT_COLORS &&
- sString != pEnglishColors[j] )
- ++j;
- if ( j < NF_MAX_DEFAULT_COLORS )
- i = j;
- }
- Color* pResult = NULL;
- if (i >= NF_MAX_DEFAULT_COLORS)
- {
- const String& rColorWord = rKeyword[NF_KEY_COLOR];
- xub_StrLen nPos = sString.Match(rColorWord);
- if (nPos > 0)
- {
- sStr.Erase(0, nPos);
- sStr.EraseLeadingChars();
- sStr.EraseTrailingChars();
- if (bConvertMode)
- {
- pFormatter->ChangeIntl(eNewLnge);
- sStr.Insert( GetKeywords()[NF_KEY_COLOR], 0 ); // Color -> FARBE
- pFormatter->ChangeIntl(eTmpLnge);
- }
- else
- sStr.Insert(rColorWord,0);
- sString.Erase(0, nPos);
- sString.EraseLeadingChars();
- sString.EraseTrailingChars();
- if ( CharClass::isAsciiNumeric( sString ) )
- {
- long nIndex = sString.ToInt32();
- if (nIndex > 0 && nIndex <= 64)
- pResult = pFormatter->GetUserDefColor((sal_uInt16)nIndex-1);
- }
- }
- }
- else
- {
- sStr.Erase();
- if (bConvertMode)
- {
- pFormatter->ChangeIntl(eNewLnge);
- sStr = GetKeywords()[NF_KEY_FIRSTCOLOR+i]; // red -> rot
- pFormatter->ChangeIntl(eTmpLnge);
- }
- else
- sStr = rKeyword[NF_KEY_FIRSTCOLOR+i];
- pResult = &(StandardColor[i]);
- }
- return pResult;
- }
- short ImpSvNumberformatScan::GetKeyWord( const String& sSymbol, xub_StrLen nPos )
- {
- String sString = pFormatter->GetCharClass()->uppercase( sSymbol, nPos, sSymbol.Len() - nPos );
- const NfKeywordTable & rKeyword = GetKeywords();
- // #77026# for the Xcl perverts: the GENERAL keyword is recognized anywhere
- if ( sString.Search( rKeyword[NF_KEY_GENERAL] ) == 0 )
- return NF_KEY_GENERAL;
- //! MUST be a reverse search to find longer strings first
- short i = NF_KEYWORD_ENTRIES_COUNT-1;
- bool bFound = false;
- for ( ; i > NF_KEY_LASTKEYWORD_SO5; --i )
- {
- bFound = sString.Search(rKeyword[i]) == 0;
- if ( bFound )
- {
- break;
- }
- }
- // new keywords take precedence over old keywords
- if ( !bFound )
- { // skip the gap of colors et al between new and old keywords and search on
- i = NF_KEY_LASTKEYWORD;
- while ( i > 0 && sString.Search(rKeyword[i]) != 0 )
- i--;
- if ( i > NF_KEY_LASTOLDKEYWORD && sString != rKeyword[i] )
- { // found something, but maybe it's something else?
- // e.g. new NNN is found in NNNN, for NNNN we must search on
- short j = i - 1;
- while ( j > 0 && sString.Search(rKeyword[j]) != 0 )
- j--;
- if ( j && rKeyword[j].Len() > rKeyword[i].Len() )
- return j;
- }
- }
- // The Thai T NatNum modifier during Xcl import.
- if (i == 0 && bConvertMode && sString.GetChar(0) == 'T' && eTmpLnge ==
- LANGUAGE_ENGLISH_US && MsLangId::getRealLanguage( eNewLnge) ==
- LANGUAGE_THAI)
- i = NF_KEY_THAI_T;
- return i; // 0 => not found
- }
- //---------------------------------------------------------------------------
- // Next_Symbol
- //---------------------------------------------------------------------------
- // Zerlegt die Eingabe in Symbole fuer die weitere
- // Verarbeitung (Turing-Maschine).
- //---------------------------------------------------------------------------
- // Ausgangs Zustand = SsStart
- //---------------+-------------------+-----------------------+---------------
- // Alter Zustand | gelesenes Zeichen | Aktion | Neuer Zustand
- //---------------+-------------------+-----------------------+---------------
- // SsStart | Buchstabe | Symbol=Zeichen | SsGetWord
- // | " | Typ = String | SsGetString
- // | \ | Typ = String | SsGetChar
- // | * | Typ = Star | SsGetStar
- // | _ | Typ = Blank | SsGetBlank
- // | @ # 0 ? / . , % [ | Symbol = Zeichen; |
- // | ] ' Blank | Typ = Steuerzeichen | SsStop
- // | $ - + ( ) : | Typ = String; |
- // | Sonst | Symbol = Zeichen | SsStop
- //---------------|-------------------+-----------------------+---------------
- // SsGetChar | Sonst | Symbol=Zeichen | SsStop
- //---------------+-------------------+-----------------------+---------------
- // GetString | " | | SsStop
- // | Sonst | Symbol+=Zeichen | GetString
- //---------------+-------------------+-----------------------+---------------
- // SsGetWord | Buchstabe | Symbol += Zeichen |
- // | + - (E+ E-)| Symbol += Zeichen | SsStop
- // | / (AM/PM)| Symbol += Zeichen |
- // | Sonst | Pos--, if Key Typ=Word| SsStop
- //---------------+-------------------+-----------------------+---------------
- // SsGetStar | Sonst | Symbol+=Zeichen | SsStop
- // | | markiere Sonderfall * |
- //---------------+-------------------+-----------------------+---------------
- // SsGetBlank | Sonst | Symbol+=Zeichen | SsStop
- // | | markiere Sonderfall _ |
- //---------------+-------------------+-----------------------+---------------
- // Wurde im State SsGetWord ein Schluesselwort erkannt (auch als
- // Anfangsteilwort des Symbols)
- // so werden die restlichen Buchstaben zurueckgeschrieben !!
- enum ScanState
- {
- SsStop = 0,
- SsStart = 1,
- SsGetChar = 2,
- SsGetString = 3,
- SsGetWord = 4,
- SsGetStar = 5,
- SsGetBlank = 6
- };
- short ImpSvNumberformatScan::Next_Symbol( const String& rStr,
- xub_StrLen& nPos, String& sSymbol )
- {
- if ( bKeywordsNeedInit )
- InitKeywords();
- const CharClass* pChrCls = pFormatter->GetCharClass();
- const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
- const xub_StrLen nStart = nPos;
- short eType = 0;
- ScanState eState = SsStart;
- sSymbol.Erase();
- while ( nPos < rStr.Len() && eState != SsStop )
- {
- sal_Unicode cToken = rStr.GetChar( nPos++ );
- switch (eState)
- {
- case SsStart:
- {
- // Fetch any currency longer than one character and don't get
- // confused later on by "E/" or other combinations of letters
- // and meaningful symbols. Necessary for old automatic currency.
- // #96158# But don't do it if we're starting a "[...]" section,
- // for example a "[$...]" new currency symbol to not parse away
- // "$U" (symbol) of "[$UYU]" (abbreviation).
- if ( nCurrPos != STRING_NOTFOUND && sCurString.Len() > 1 &&
- nPos-1 + sCurString.Len() <= rStr.Len() &&
- !(nPos > 1 && rStr.GetChar( nPos-2 ) == '[') )
- {
- String aTest = pChrCls->uppercase( rStr.Copy( nPos-1, sCurString.Len() ) );
- if ( aTest == sCurString )
- {
- sSymbol = rStr.Copy( --nPos, sCurString.Len() );
- nPos = nPos + sSymbol.Len();
- eState = SsStop;
- eType = NF_SYMBOLTYPE_STRING;
- return eType;
- }
- }
- switch (cToken)
- {
- case '#':
- case '0':
- case '?':
- case '%':
- case '@':
- case '[':
- case ']':
- case ',':
- case '.':
- case '/':
- case '\'':
- case ' ':
- case ':':
- case '-':
- {
- eType = NF_SYMBOLTYPE_DEL;
- sSymbol += cToken;
- eState = SsStop;
- }
- break;
- case '*':
- {
- eType = NF_SYMBOLTYPE_STAR;
- sSymbol += cToken;
- eState = SsGetStar;
- }
- break;
- case '_':
- {
- eType = NF_SYMBOLTYPE_BLANK;
- sSymbol += cToken;
- eState = SsGetBlank;
- }
- break;
- case '"':
- eType = NF_SYMBOLTYPE_STRING;
- eState = SsGetString;
- sSymbol += cToken;
- break;
- case '\\':
- eType = NF_SYMBOLTYPE_STRING;
- eState = SsGetChar;
- sSymbol += cToken;
- break;
- case '$':
- case '+':
- case '(':
- case ')':
- eType = NF_SYMBOLTYPE_STRING;
- eState = SsStop;
- sSymbol += cToken;
- break;
- default :
- {
- if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cToken) ||
- StringEqualsChar( pFormatter->GetNumThousandSep(), cToken) ||
- StringEqualsChar( pFormatter->GetDateSep(), cToken) ||
- StringEqualsChar( pLoc->getTimeSep(), cToken) ||
- StringEqualsChar( pLoc->getTime100SecSep(), cToken))
- {
- // Another separator than pre-known ASCII
- eType = NF_SYMBOLTYPE_DEL;
- sSymbol += cToken;
- eState = SsStop;
- }
- else if ( pChrCls->isLetter( rStr, nPos-1 ) )
- {
- short nTmpType = GetKeyWord( rStr, nPos-1 );
- if ( nTmpType )
- {
- bool bCurrency = false;
- // "Automatic" currency may start with keyword,
- // like "R" (Rand) and 'R' (era)
- if ( nCurrPos != STRING_NOTFOUND &&
- nPos-1 + sCurString.Len() <= rStr.Len() &&
- sCurString.Search( sKeyword[nTmpType] ) == 0 )
- {
- String aTest = pChrCls->uppercase( rStr.Copy( nPos-1, sCurString.Len() ) );
- if ( aTest == sCurString )
- bCurrency = true;
- }
- if ( bCurrency )
- {
- eState = SsGetWord;
- sSymbol += cToken;
- }
- else
- {
- eType = nTmpType;
- xub_StrLen nLen = sKeyword[eType].Len();
- sSymbol = rStr.Copy( nPos-1, nLen );
- if ( eType == NF_KEY_E || IsAmbiguousE( eType ) )
- {
- sal_Unicode cNext = rStr.GetChar(nPos);
- switch ( cNext )
- {
- case '+' :
- case '-' : // E+ E- combine to one symbol
- sSymbol += cNext;
- eType = NF_KEY_E;
- nPos++;
- break;
- case '0' :
- case '#' : // scientific E without sign
- eType = NF_KEY_E;
- break;
- }
- }
- nPos--;
- nPos = nPos + nLen;
- eState = SsStop;
- }
- }
- else
- {
- eState = SsGetWord;
- sSymbol += cToken;
- }
- }
- else
- {
- eType = NF_SYMBOLTYPE_STRING;
- eState = SsStop;
- sSymbol += cToken;
- }
- }
- break;
- }
- }
- break;
- case SsGetChar:
- {
- sSymbol += cToken;
- eState = SsStop;
- }
- break;
- case SsGetString:
- {
- if (cToken == '"')
- eState = SsStop;
- sSymbol += cToken;
- }
- break;
- case SsGetWord:
- {
- if ( pChrCls->isLetter( rStr, nPos-1 ) )
- {
- short nTmpType = GetKeyWord( rStr, nPos-1 );
- if ( nTmpType )
- { // beginning of keyword, stop scan and put back
- eType = NF_SYMBOLTYPE_STRING;
- eState = SsStop;
- nPos--;
- }
- else
- sSymbol += cToken;
- }
- else
- {
- bool bDontStop = false;
- switch (cToken)
- {
- case '/': // AM/PM, A/P
- {
- sal_Unicode cNext = rStr.GetChar(nPos);
- if ( cNext == 'P' || cNext == 'p' )
- {
- xub_StrLen nLen = sSymbol.Len();
- if ( 1 <= nLen
- && (sSymbol.GetChar(0) == 'A' || sSymbol.GetChar(0) == 'a')
- && (nLen == 1 || (nLen == 2
- && (sSymbol.GetChar(1) == 'M' || sSymbol.GetChar(1) == 'm')
- && (rStr.GetChar(nPos+1) == 'M' || rStr.GetChar(nPos+1) == 'm'))) )
- {
- sSymbol += cToken;
- bDontStop = true;
- }
- }
- }
- break;
- }
- // anything not recognized will stop the scan
- if ( eState != SsStop && !bDontStop )
- {
- eState = SsStop;
- nPos--;
- eType = NF_SYMBOLTYPE_STRING;
- }
- }
- }
- break;
- case SsGetStar:
- {
- eState = SsStop;
- sSymbol += cToken;
- nRepPos = (nPos - nStart) - 1; // everytime > 0!!
- }
- break;
- case SsGetBlank:
- {
- eState = SsStop;
- sSymbol += cToken;
- }
- break;
- default:
- break;
- } // of switch
- } // of while
- if (eState == SsGetWord)
- eType = NF_SYMBOLTYPE_STRING;
- return eType;
- }
- xub_StrLen ImpSvNumberformatScan::Symbol_Division(const String& rString)
- {
- nCurrPos = STRING_NOTFOUND;
- // Ist Waehrung im Spiel?
- String sString = pFormatter->GetCharClass()->uppercase(rString);
- xub_StrLen nCPos = 0;
- while (nCPos != STRING_NOTFOUND)
- {
- nCPos = sString.Search(GetCurString(),nCPos);
- if (nCPos != STRING_NOTFOUND)
- {
- // in Quotes?
- xub_StrLen nQ = SvNumberformat::GetQuoteEnd( sString, nCPos );
- if ( nQ == STRING_NOTFOUND )
- {
- sal_Unicode c;
- if ( nCPos == 0 ||
- ((c = sString.GetChar(xub_StrLen(nCPos-1))) != '"'
- && c != '\\') ) // dm kann durch "dm
- { // \d geschuetzt werden
- nCurrPos = nCPos;
- nCPos = STRING_NOTFOUND; // Abbruch
- }
- else
- nCPos++; // weitersuchen
- }
- else
- nCPos = nQ + 1; // weitersuchen
- }
- }
- nAnzStrings = 0;
- bool bStar = false; // wird bei '*'Detektion gesetzt
- Reset();
- xub_StrLen nPos = 0;
- const xub_StrLen nLen = rString.Len();
- while (nPos < nLen && nAnzStrings < NF_MAX_FORMAT_SYMBOLS)
- {
- nTypeArray[nAnzStrings] = Next_Symbol(rString, nPos, sStrArray[nAnzStrings]);
- if (nTypeArray[nAnzStrings] == NF_SYMBOLTYPE_STAR)
- { // Ueberwachung des '*'
- if (bStar)
- return nPos; // Fehler: doppelter '*'
- else
- bStar = true;
- }
- nAnzStrings++;
- }
- return 0; // 0 => ok
- }
- void ImpSvNumberformatScan::SkipStrings(sal_uInt16& i, xub_StrLen& nPos)
- {
- while (i < nAnzStrings && ( nTypeArray[i] == NF_SYMBOLTYPE_STRING
- || nTypeArray[i] == NF_SYMBOLTYPE_BLANK
- || nTypeArray[i] == NF_SYMBOLTYPE_STAR) )
- {
- nPos = nPos + sStrArray[i].Len();
- i++;
- }
- }
- sal_uInt16 ImpSvNumberformatScan::PreviousKeyword(sal_uInt16 i)
- {
- short res = 0;
- if (i > 0 && i < nAnzStrings)
- {
- i--;
- while (i > 0 && nTypeArray[i] <= 0)
- i--;
- if (nTypeArray[i] > 0)
- res = nTypeArray[i];
- }
- return res;
- }
- sal_uInt16 ImpSvNumberformatScan::NextKeyword(sal_uInt16 i)
- {
- short res = 0;
- if (i < nAnzStrings-1)
- {
- i++;
- while (i < nAnzStrings-1 && nTypeArray[i] <= 0)
- i++;
- if (nTypeArray[i] > 0)
- res = nTypeArray[i];
- }
- return res;
- }
- short ImpSvNumberformatScan::PreviousType( sal_uInt16 i )
- {
- if ( i > 0 && i < nAnzStrings )
- {
- do
- {
- i--;
- } while ( i > 0 && nTypeArray[i] == NF_SYMBOLTYPE_EMPTY );
- return nTypeArray[i];
- }
- return 0;
- }
- sal_Unicode ImpSvNumberformatScan::PreviousChar(sal_uInt16 i)
- {
- sal_Unicode res = ' ';
- if (i > 0 && i < nAnzStrings)
- {
- i--;
- while (i > 0 && ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY
- || nTypeArray[i] == NF_SYMBOLTYPE_STRING
- || nTypeArray[i] == NF_SYMBOLTYPE_STAR
- || nTypeArray[i] == NF_SYMBOLTYPE_BLANK ) )
- i--;
- if (sStrArray[i].Len() > 0)
- res = sStrArray[i].GetChar(xub_StrLen(sStrArray[i].Len()-1));
- }
- return res;
- }
- sal_Unicode ImpSvNumberformatScan::NextChar(sal_uInt16 i)
- {
- sal_Unicode res = ' ';
- if (i < nAnzStrings-1)
- {
- i++;
- while (i < nAnzStrings-1 &&
- ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY
- || nTypeArray[i] == NF_SYMBOLTYPE_STRING
- || nTypeArray[i] == NF_SYMBOLTYPE_STAR
- || nTypeArray[i] == NF_SYMBOLTYPE_BLANK))
- i++;
- if (sStrArray[i].Len() > 0)
- res = sStrArray[i].GetChar(0);
- }
- return res;
- }
- bool ImpSvNumberformatScan::IsLastBlankBeforeFrac(sal_uInt16 i)
- {
- bool res = true;
- if (i < nAnzStrings-1)
- {
- bool bStop = false;
- i++;
- while (i < nAnzStrings-1 && !bStop)
- {
- i++;
- if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
- sStrArray[i].GetChar(0) == '/')
- bStop = true;
- else if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL &&
- sStrArray[i].GetChar(0) == ' ')
- res = false;
- }
- if (!bStop) // kein '/'
- res = false;
- }
- else
- res = false; // kein '/' mehr
- return res;
- }
- void ImpSvNumberformatScan::Reset()
- {
- nAnzStrings = 0;
- nAnzResStrings = 0;
- #if 0
- // ER 20.06.97 14:05 nicht noetig, wenn nAnzStrings beachtet wird
- for (size_t i = 0; i < NF_MAX_FORMAT_SYMBOLS; i++)
- {
- sStrArray[i].Erase();
- nTypeArray[i] = 0;
- }
- #endif
- eScannedType = NUMBERFORMAT_UNDEFINED;
- nRepPos = 0;
- bExp = false;
- bThousand = false;
- nThousand = 0;
- bDecSep = false;
- nDecPos = -1;
- nExpPos = (sal_uInt16) -1;
- nBlankPos = (sal_uInt16) -1;
- nCntPre = 0;
- nCntPost = 0;
- nCntExp = 0;
- bFrac = false;
- bBlank = false;
- nNatNumModifier = 0;
- }
- bool ImpSvNumberformatScan::Is100SecZero( sal_uInt16 i, bool bHadDecSep )
- {
- sal_uInt16 nIndexPre = PreviousKeyword( i );
- return (nIndexPre == NF_KEY_S || nIndexPre == NF_KEY_SS)
- && (bHadDecSep // S, SS ','
- || (i>0 && nTypeArray[i-1] == NF_SYMBOLTYPE_STRING));
- // SS"any"00 take "any" as a valid decimal separator
- }
- xub_StrLen ImpSvNumberformatScan::ScanType()
- {
- const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
- xub_StrLen nPos = 0;
- sal_uInt16 i = 0;
- short eNewType;
- bool bMatchBracket = false;
- bool bHaveGeneral = false; // if General/Standard encountered
- SkipStrings(i, nPos);
- while (i < nAnzStrings)
- {
- if (nTypeArray[i] > 0)
- { // keyword
- switch (nTypeArray[i])
- {
- case NF_KEY_E: // E
- eNewType = NUMBERFORMAT_SCIENTIFIC;
- break;
- case NF_KEY_AMPM: // AM,A,PM,P
- case NF_KEY_AP:
- case NF_KEY_H: // H
- case NF_KEY_HH: // HH
- case NF_KEY_S: // S
- case NF_KEY_SS: // SS
- eNewType = NUMBERFORMAT_TIME;
- break;
- case NF_KEY_M: // M
- case NF_KEY_MM: // MM
- { // minute or month
- sal_uInt16 nIndexPre = PreviousKeyword(i);
- sal_uInt16 nIndexNex = NextKeyword(i);
- sal_Unicode cChar = PreviousChar(i);
- if (nIndexPre == NF_KEY_H || // H
- nIndexPre == NF_KEY_HH || // HH
- nIndexNex == NF_KEY_S || // S
- nIndexNex == NF_KEY_SS || // SS
- cChar == '[' ) // [M
- {
- eNewType = NUMBERFORMAT_TIME;
- nTypeArray[i] -= 2; // 6 -> 4, 7 -> 5
- }
- else
- eNewType = NUMBERFORMAT_DATE;
- }
- break;
- case NF_KEY_MMM: // MMM
- case NF_KEY_MMMM: // MMMM
- case NF_KEY_MMMMM: // MMMMM
- case NF_KEY_Q: // Q
- case NF_KEY_QQ: // QQ
- case NF_KEY_D: // D
- case NF_KEY_DD: // DD
- case NF_KEY_DDD: // DDD
- case NF_KEY_DDDD: // DDDD
- case NF_KEY_YY: // YY
- case NF_KEY_YYYY: // YYYY
- case NF_KEY_NN: // NN
- case NF_KEY_NNN: // NNN
- case NF_KEY_NNNN: // NNNN
- case NF_KEY_WW : // WW
- case NF_KEY_AAA : // AAA
- case NF_KEY_AAAA : // AAAA
- case NF_KEY_EC : // E
- case NF_KEY_EEC : // EE
- case NF_KEY_G : // G
- case NF_KEY_GG : // GG
- case NF_KEY_GGG : // GGG
- case NF_KEY_R : // R
- case NF_KEY_RR : // RR
- eNewType = NUMBERFORMAT_DATE;
- break;
- case NF_KEY_CCC: // CCC
- eNewType = NUMBERFORMAT_CURRENCY;
- break;
- case NF_KEY_GENERAL: // Standard
- eNewType = NUMBERFORMAT_NUMBER;
- bHaveGeneral = true;
- break;
- default:
- eNewType = NUMBERFORMAT_UNDEFINED;
- break;
- }
- }
- else
- { // control character
- switch ( sStrArray[i].GetChar(0) )
- {
- case '#':
- case '?':
- eNewType = NUMBERFORMAT_NUMBER;
- break;
- case '0':
- {
- if ( (eScannedType & NUMBERFORMAT_TIME) == NUMBERFORMAT_TIME )
- {
- if ( Is100SecZero( i, bDecSep ) )
- {
- bDecSep = true; // subsequent 0's
- eNewType = NUMBERFORMAT_TIME;
- }
- else
- return nPos; // Error
- }
- else
- eNewType = NUMBERFORMAT_NUMBER;
- }
- break;
- case '%':
- …
Large files files are truncated, but you can click here to view the full file