summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Hong <khong@openoffice.org>2002-06-20 01:39:53 +0000
committerKarl Hong <khong@openoffice.org>2002-06-20 01:39:53 +0000
commite97e15baab831b683789f24f7196f8b763716bdb (patch)
treecdc79bbfc98b1b77e500c31c7b053dc997c23789
parentc74f343f4494aed40aefc4d347a079bc90499a30 (diff)
#99859#first implementation for NativeNumberSupplier
-rw-r--r--i18npool/inc/nativenumbersupplier.hxx110
-rw-r--r--i18npool/prj/build.lst3
-rw-r--r--i18npool/source/nativenumber/data/numberchar.h170
-rw-r--r--i18npool/source/nativenumber/makefile.mk85
-rw-r--r--i18npool/source/nativenumber/nativenumbersupplier.cxx652
-rw-r--r--i18npool/source/registerservices/registerservices.cxx9
-rw-r--r--i18npool/util/makefile.mk5
7 files changed, 1029 insertions, 5 deletions
diff --git a/i18npool/inc/nativenumbersupplier.hxx b/i18npool/inc/nativenumbersupplier.hxx
new file mode 100644
index 000000000000..862f696ef384
--- /dev/null
+++ b/i18npool/inc/nativenumbersupplier.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * $RCSfile: nativenumbersupplier.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: khong $ $Date: 2002-06-20 02:36:39 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _I18N_NATIVENUMBERSUPPLIER_HXX_
+#define _I18N_NATIVENUMBERSUPPLIER_HXX_
+
+#include <drafts/com/sun/star/i18n/XNativeNumberSupplier.hpp>
+#include <drafts/com/sun/star/i18n/NativeNumberMode.hpp>
+#include <drafts/com/sun/star/i18n/NativeNumberXmlAttributes.hpp>
+#include <cppuhelper/implbase2.hxx> // helper for implementations
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace com { namespace sun { namespace star { namespace i18n {
+
+// ----------------------------------------------------
+// class NativeNumberSupplier
+// ----------------------------------------------------
+class NativeNumberSupplier : public cppu::WeakImplHelper2
+<
+ drafts::com::sun::star::i18n::XNativeNumberSupplier,
+ com::sun::star::lang::XServiceInfo
+>
+{
+public:
+ // Methods
+ virtual ::rtl::OUString SAL_CALL getNativeNumberString( const ::rtl::OUString& aNumberString,
+ const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nNativeNumberMode )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isValidNatNum( const ::com::sun::star::lang::Locale& aLocale,
+ sal_Int16 nNativeNumberMode )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::drafts::com::sun::star::i18n::NativeNumberXmlAttributes SAL_CALL convertToXmlAttributes(
+ const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nNativeNumberMode )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int16 SAL_CALL convertFromXmlAttributes(
+ const ::drafts::com::sun::star::i18n::NativeNumberXmlAttributes& aAttr )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ //XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
+ throw( com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+} } } }
+
+#endif
diff --git a/i18npool/prj/build.lst b/i18npool/prj/build.lst
index 2734748fdcde..2a96725e508d 100644
--- a/i18npool/prj/build.lst
+++ b/i18npool/prj/build.lst
@@ -11,8 +11,9 @@ inp i18npool\source\localedata\data nmake - all inp_locdata_dat
inp i18npool\source\calendar nmake - all inp_cal inp_utypes NULL
inp i18npool\source\numberformatcode nmake - all inp_numformat inp_utypes NULL
inp i18npool\source\defaultnumberingprovider nmake - all inp_dnum inp_utypes NULL
+inp i18npool\source\nativenumber nmake - all inp_natnum inp_utypes NULL
inp i18npool\source\indexentry nmake - all inp_index inp_utypes NULL
inp i18npool\source\collator nmake - all inp_collator inp_utypes NULL
inp i18npool\source\inputchecker nmake - all inp_inputchecker inp_utypes NULL
-inp i18npool\util nmake - all inp_util inp_brkit inp_dict inp_chclass inp_translit inp_cal inp_dnum inp_localedata inp_locdata_data inp_numformat inp_rserv inp_index inp_collator inp_inputchecker NULL
+inp i18npool\util nmake - all inp_util inp_brkit inp_dict inp_chclass inp_translit inp_cal inp_dnum inp_natnum inp_localedata inp_locdata_data inp_numformat inp_rserv inp_index inp_collator inp_inputchecker NULL
diff --git a/i18npool/source/nativenumber/data/numberchar.h b/i18npool/source/nativenumber/data/numberchar.h
new file mode 100644
index 000000000000..7b526b1acf39
--- /dev/null
+++ b/i18npool/source/nativenumber/data/numberchar.h
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * $RCSfile: numberchar.h,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: khong $ $Date: 2002-06-20 02:31:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _L10N_TRANSLITERATION_NUMTOCHAR_H_
+#define _L10N_TRANSLITERATION_NUMTOCHAR_H_
+
+namespace com { namespace sun { namespace star { namespace i18n {
+
+static const sal_Int16 NumberChar_HalfWidth = 0;
+static const sal_Int16 NumberChar_FullWidth = 1;
+static const sal_Int16 NumberChar_Lower_zh = 2;
+static const sal_Int16 NumberChar_Upper_zh = 3;
+static const sal_Int16 NumberChar_Upper_zh_TW = 4;
+static const sal_Int16 NumberChar_Modern_ja = 5;
+static const sal_Int16 NumberChar_Traditional_ja= 6;
+static const sal_Int16 NumberChar_Lower_ko = 7;
+static const sal_Int16 NumberChar_Upper_ko = 8;
+static const sal_Int16 NumberChar_Hangul_ko = 9;
+static const sal_Int16 NumberChar_Indic_ar = 10;
+static const sal_Int16 NumberChar_EastIndic_ar = 11;
+static const sal_Int16 NumberChar_Indic_hi = 12;
+static const sal_Int16 NumberChar_th = 13;
+static const sal_Int16 NumberChar_Count = 14;
+
+static sal_Unicode NumberChar[][10] = {
+// 0 1 2 3 4 5 6 7 8 9
+ { 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039 }, // Half Width (Ascii)
+ { 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17, 0xFF18, 0xFF19 }, // Full Width
+ { 0x3007, 0x4E00, 0x4E8c, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D }, // Chinese Lower
+ { 0x96F6, 0x58F9, 0x8D30, 0x53C1, 0x8086, 0x4F0D, 0x9646, 0x67D2, 0x634C, 0x7396 }, // S. Chinese Upper
+ { 0x96F6, 0x58F9, 0x8CB3, 0x53C3, 0x8086, 0x4F0D, 0x9678, 0x67D2, 0x634C, 0x7396 }, // T. Chinese Upper
+ { 0x3007, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D }, // Japanese Modern
+ { 0x96F6, 0x58F1, 0x5F10, 0x53C2, 0x56DB, 0x4F0D, 0x516D, 0x4E03, 0x516B, 0x4E5D }, // Japanese Trad.
+ { 0x3007, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D }, // Korean Lower
+ { 0xF9B2, 0x58F9, 0x8CB3, 0x53C3, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D }, // Korean Upper
+ { 0xC601, 0xC77C, 0xC774, 0xC0BC, 0xC0AC, 0xC624, 0xC721, 0xCE60, 0xD314, 0xAD6C }, // Korean Hangul
+ { 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669 }, // Arabic Indic
+ { 0x06F0, 0x06F1, 0x06F2, 0x06F3, 0x06F4, 0x06F5, 0x06F6, 0x06F7, 0x06F8, 0x06F9 }, // Est. Arabic Indic
+ { 0x0966, 0x0967, 0x0968, 0x0969, 0x096A, 0x096B, 0x096C, 0x096D, 0x096E, 0x096F }, // Indic
+ { 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59 } // Thai
+};
+
+static sal_Unicode DecimalChar[] = {
+ 0x002E, // Half Width (Ascii)
+ 0xFF0E, // Full Width
+ 0xFF0E, // Chinese Lower
+ 0x70B9, // S. Chinese Upper
+ 0x9EDE, // T. Chinese Upper
+ 0x30FB, // Japanese Modern
+ 0x30FB, // Japanese Trad.
+ 0xFF0E, // Korean Lower
+ 0x9EDE, // Korean Upper
+ 0xC810, // Korean Hangul
+ 0x066B, // Arabic Indic
+ 0x002E, // Est. Arabic Indic
+ 0x002E, // Indic
+ 0x002E // Thai
+};
+
+static sal_Unicode MinusChar[] = {
+ 0x002D, // Half Width (Ascii)
+ 0xFF0D, // Full Width
+ 0xFF0D, // Chinese Lower
+ 0x8D1F, // S. Chinese Upper
+ 0x5069, // T. Chinese Upper
+ 0x2212, // Japanese Modern
+ 0x2212, // Japanese Trad.
+ 0xFF0D, // Korean Lower
+ 0x5069, // Korean Upper
+ 0xFF0D, // Korean Hangul ???
+ 0x002D, // Arabic Indic
+ 0x002D, // Est. Arabic Indic
+ 0x002D, // Indic
+ 0x002D, // Thai
+};
+
+#define NUMBER_ZERO NumberChar[NumberChar_HalfWidth][0] // 0x0030
+#define NUMBER_ONE NumberChar[NumberChar_HalfWidth][1] // 0x0031
+#define NUMBER_NINE NumberChar[NumberChar_HalfWidth][9] // 0x0039
+#define NUMBER_DECIMAL DecimalChar[0]
+#define NUMBER_MINUS MinusChar[0]
+#define isNumber(n) ( NUMBER_ZERO <= n && n <= NUMBER_NINE )
+#define isDecimal(n) ( n == NUMBER_DECIMAL )
+#define isMinus(n) ( n == NUMBER_MINUS )
+
+const sal_Int16 Multiplier_Lower_zh = 0;
+const sal_Int16 Multiplier_Upper_zh = 1;
+const sal_Int16 Multiplier_Lower_zh_TW = 2;
+const sal_Int16 Multiplier_Upper_zh_TW = 3;
+const sal_Int16 Multiplier_Hangul_ko = 4;
+const sal_Int16 Multiplier_Modern_ja = 5;
+const sal_Int16 Multiplier_Traditional_ja = 6;
+const sal_Int16 Multiplier_Count = 7;
+
+const sal_Int16 ExponentCount_CJK = 6;
+
+static sal_Int16 MultiplierExponent_CJK[ExponentCount_CJK] = {
+ 12, 8, 4, 3, 2, 1
+};
+static sal_Unicode MultiplierChar_CJK[][ExponentCount_CJK] = {
+ 0x5146, 0x4EBF, 0x4E07, 0x5343, 0x767E, 0x5341, // S. Chinese Lower
+ 0x5146, 0x4EBF, 0x4E07, 0x4EDF, 0x4F70, 0x62FE, // S. Chinese Upper
+ 0x5146, 0x5104, 0x842C, 0x5343, 0x767E, 0x5341, // T. Chinese & Korean Lower
+ 0x5146, 0x5104, 0x842C, 0x4EDF, 0x4F70, 0x62FE, // T. Chinese & Korean Upper
+ 0xC870, 0xC5B5, 0xB9CC, 0xCC9C, 0xBC31, 0xC2ED, // Korean Hangul
+ 0x5146, 0x5104, 0x4E07, 0x5343, 0x767E, 0x5341, // Japanese Modern
+ 0x5146, 0x5104, 0x842C, 0x9621, 0x767E, 0x62FE, // Japanese Traditional
+};
+
+const sal_Int16 ExponentCount_short_CJK = 2;
+
+static sal_Int16 MultiplierExponent_short_CJK[ExponentCount_short_CJK] = {
+ 8, 4,
+};
+
+static sal_Unicode MultiplierChar_short_CJK[][ExponentCount_short_CJK] = {
+ 0x4EBF, 0x4E07, // S. Chinese Lower
+ 0x4EBF, 0x4E07, // S. Chinese Upper
+ 0x5104, 0x842C, // T. Chinese & Korean Lower
+ 0x5104, 0x842C, // T. Chinese & Korean Upper
+ 0xC5B5, 0xB9CC, // Korean Hangul
+ 0x5104, 0x4E07, // Japanese Modern
+ 0x5104, 0x842C, // Japanese Traditional
+};
+
+typedef struct {
+ sal_Int16 ExponentCount;
+ sal_Int16* MultiplierExponent;
+ sal_Unicode *MultiplierChar;
+} Multiplier;
+
+} } } }
+
+#endif // _L10N_TRANSLITERATION_NUMTOCHAR_H_
diff --git a/i18npool/source/nativenumber/makefile.mk b/i18npool/source/nativenumber/makefile.mk
new file mode 100644
index 000000000000..fc8da3f7c15a
--- /dev/null
+++ b/i18npool/source/nativenumber/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#*
+#* $RCSfile: makefile.mk,v $
+#*
+#* $Revision: 1.1 $
+#*
+#* last change: $Author: khong $ $Date: 2002-06-20 02:28:47 $
+#*
+#* The Contents of this file are made available subject to the terms of
+#* either of the following licenses
+#*
+#* - GNU Lesser General Public License Version 2.1
+#* - Sun Industry Standards Source License Version 1.1
+#*
+#* Sun Microsystems Inc., October, 2000
+#*
+#* GNU Lesser General Public License Version 2.1
+#* =============================================
+#* Copyright 2000 by Sun Microsystems, Inc.
+#* 901 San Antonio Road, Palo Alto, CA 94303, USA
+#*
+#* This library is free software; you can redistribute it and/or
+#* modify it under the terms of the GNU Lesser General Public
+#* License version 2.1, as published by the Free Software Foundation.
+#*
+#* This library 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 for more details.
+#*
+#* You should have received a copy of the GNU Lesser General Public
+#* License along with this library; if not, write to the Free Software
+#* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+#* MA 02111-1307 USA
+#*
+#*
+#* Sun Industry Standards Source License Version 1.1
+#* =================================================
+#* The contents of this file are subject to the Sun Industry Standards
+#* Source License Version 1.1 (the "License"); You may not use this file
+#* except in compliance with the License. You may obtain a copy of the
+#* License at http://www.openoffice.org/license.html.
+#*
+#* Software provided under this License is provided on an "AS IS" basis,
+#* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+#* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+#* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+#* See the License for the specific provisions governing your rights and
+#* obligations concerning the Software.
+#*
+#* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#*
+#* Copyright: 2000 by Sun Microsystems, Inc.
+#*
+#* All Rights Reserved.
+#*
+#* Contributor(s): _______________________________________
+#*
+#*
+#************************************************************************/
+
+PRJ=..$/..
+
+PRJNAME=i18npool
+TARGET=nativenumber
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/nativenumbersupplier.obj \
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
new file mode 100644
index 000000000000..691138036a0a
--- /dev/null
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -0,0 +1,652 @@
+/*************************************************************************
+ *
+ * $RCSfile: nativenumbersupplier.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: khong $ $Date: 2002-06-20 02:28:47 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <rtl/ustrbuf.hxx>
+#include <tools/string.hxx>
+#include <nativenumbersupplier.hxx>
+#include <data/numberchar.h>
+#include <x_rtl_ustring.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::lang;
+using namespace ::drafts::com::sun::star::i18n;
+using namespace ::rtl;
+
+
+typedef struct {
+ sal_Int16 number;
+ sal_Unicode *multiplierChar;
+ sal_Int16 numberFlag;
+ sal_Int16 exponentCount;
+ sal_Int16 *multiplierExponent;
+} Number;
+
+
+#define NUMBER_OMIT_ZERO (1 << 0)
+#define NUMBER_OMIT_ONE (1 << 1)
+#define NUMBER_OMIT_ONLY_ZERO (1 << 2)
+#define NUMBER_OMIT_ALL ( NUMBER_OMIT_ZERO|NUMBER_OMIT_ONE|NUMBER_OMIT_ONLY_ZERO )
+
+
+#define NUMBER_COMMA 0x002C
+#define isComma(ch) (ch == NUMBER_COMMA)
+#define MAX_SAL_UINT32 0xFFFFFFFF
+#define MAX_VALUE (MAX_SAL_UINT32 - 9) / 10
+
+namespace com { namespace sun { namespace star { namespace i18n {
+
+
+OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
+ Sequence< sal_Int32 >& offset, sal_Int16 number ) throw(RuntimeException)
+{
+ const sal_Unicode *src = inStr.getStr() + startPos;
+ rtl_uString *newStr = x_rtl_uString_new_WithLength(nCount);
+ offset.realloc(nCount);
+
+ for (sal_Int32 i = 0; i < nCount; i++) {
+ sal_Unicode ch = src[i];
+ newStr->buffer[i] = (isNumber(ch) ? NumberChar[number][ ch - NUMBER_ZERO ] :
+ (isDecimal(ch) ? DecimalChar[number] : (isMinus(ch) ? MinusChar[number] : ch)));
+ offset[i] = startPos + i;
+ }
+ return OUString(newStr->buffer, nCount);
+}
+
+sal_Bool SAL_CALL AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, sal_Int32 len,
+ sal_Unicode *dst, sal_Int32& count, sal_Unicode multiChar, Sequence< sal_Int32 >& offset, sal_Int32 startPos,
+ Number *number, sal_Unicode* numberChar)
+{
+ if ( len <= number->multiplierExponent[number->exponentCount-1] ) {
+ if (number->multiplierExponent[number->exponentCount-1] > 1) {
+ sal_Int16 i;
+ sal_Bool notZero = false;
+ for (i = 0; i < len; i++, begin++) {
+ if (notZero || str[begin] != NUMBER_ZERO) {
+ dst[count] = numberChar[str[begin] - NUMBER_ZERO];
+ offset[count++] = begin + startPos;
+ notZero = sal_True;
+ }
+ }
+ if (notZero && multiChar > 0) {
+ dst[count] = multiChar;
+ offset[count++] = begin + startPos;
+ }
+ return notZero;
+ } else if (str[begin] != NUMBER_ZERO) {
+ if (!(number->numberFlag & NUMBER_OMIT_ONE) || multiChar == 0 || str[begin] != NUMBER_ONE) {
+ dst[count] = numberChar[str[begin] - NUMBER_ZERO];
+ offset[count++] = begin + startPos;
+ }
+ if (multiChar > 0) {
+ dst[count] = multiChar;
+ offset[count++] = begin + startPos;
+ }
+ } else if (!(number->numberFlag & NUMBER_OMIT_ZERO) && count > 0 && dst[count-1] != numberChar[0]) {
+ dst[count] = numberChar[0];
+ offset[count++] = begin + startPos;
+ }
+ return str[begin] != NUMBER_ZERO;
+ } else {
+ sal_Bool printPower = sal_False;
+ sal_Int16 last = 0;
+ for (sal_Int16 i = 1; i <= number->exponentCount; i++) {
+ sal_Int32 tmp = len - (i == number->exponentCount ? 0 : number->multiplierExponent[i]);
+ if (tmp > 0) {
+ printPower |= AsciiToNative_numberMaker(str, begin, tmp, dst, count,
+ (i == number->exponentCount ? 0 : number->multiplierChar[i]), offset, startPos, number, numberChar);
+ begin += tmp;
+ len -= tmp;
+ }
+ }
+ if (printPower) {
+ if (count > 0 && dst[count-1] == numberChar[0])
+ count--;
+ if (multiChar > 0) {
+ dst[count] = multiChar;
+ offset[count++] = begin + startPos;
+ }
+ }
+ return printPower;
+ }
+}
+
+OUString SAL_CALL AsciiToNative( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
+ Sequence< sal_Int32 >& offset, Number* number ) throw(RuntimeException)
+{
+ sal_Int32 strLen = inStr.getLength() - startPos;
+ sal_Unicode *numberChar = NumberChar[number->number];
+
+ if (nCount > strLen)
+ nCount = strLen;
+
+ if (nCount > 0) {
+ const sal_Unicode *str = inStr.getStr() + startPos;
+ rtl_uString *newStr = x_rtl_uString_new_WithLength(nCount * 2);
+ rtl_uString *srcStr = x_rtl_uString_new_WithLength(nCount); // for keeping number without comma
+ sal_Int32 i, len = 0, count = 0;
+
+ offset.realloc( nCount * 2 );
+ sal_Bool doDecimal = sal_False;
+
+ for (i = 0; i <= nCount; i++) {
+ if (i < nCount && isNumber(str[i])) {
+ if (doDecimal) {
+ newStr->buffer[count] = numberChar[str[i] - NUMBER_ZERO];
+ offset[count++] = i + startPos;
+ }
+ else
+ srcStr->buffer[len++] = str[i];
+ } else {
+ if (len > 0) {
+ if (isComma(str[i]) && i < nCount-1 && isNumber(str[i+1]))
+ continue; // skip comma inside number string
+ sal_Bool notZero = sal_False;
+ for (sal_Int32 begin = 0, end = len % number->multiplierExponent[0];
+ end <= len; begin = end, end += number->multiplierExponent[0]) {
+ sal_Int32 _count = count;
+ notZero |= AsciiToNative_numberMaker(srcStr->buffer, begin, end - begin, newStr->buffer, count,
+ end == len ? 0 : number->multiplierChar[0], offset, i - len + startPos, number, numberChar);
+ if (count > 0 && newStr->buffer[count-1] == numberChar[0])
+ count--;
+ if (notZero && _count == count) {
+ if (end != len) {
+ newStr->buffer[count] = number->multiplierChar[0];
+ offset[count++] = i - len + startPos;
+ }
+ }
+ }
+ if (! notZero && ! (number->numberFlag & NUMBER_OMIT_ONLY_ZERO)) {
+ newStr->buffer[count] = numberChar[0];
+ offset[count++] = i - len + startPos;
+ }
+ len = 0;
+ }
+ if (i < nCount) {
+ if (doDecimal = (!doDecimal && isDecimal(str[i]) && i < nCount-1 && isNumber(str[i+1])))
+ newStr->buffer[count] = DecimalChar[number->number];
+ else if (isMinus(str[i]) && i < nCount-1 && isNumber(str[i+1]))
+ newStr->buffer[count] = MinusChar[number->number];
+ else
+ newStr->buffer[count] = str[i];
+ offset[count++] = i + startPos;
+ }
+ }
+ }
+
+ offset.realloc(count);
+ return OUString(newStr->buffer, count);
+ }
+ return OUString();
+}
+static void SAL_CALL NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_Unicode *str,
+ sal_Int32& i, sal_Int32 nCount, sal_Unicode *dst, sal_Int32& count, Sequence< sal_Int32 >& offset,
+ OUString& numberChar, OUString& multiplierChar)
+{
+ sal_Int16 curr = 0, num = 0, end = 0, shift = 0;
+ while (++i < nCount) {
+ if ((curr = numberChar.indexOf(str[i])) >= 0) {
+ if (num > 0)
+ break;
+ num = curr % 10;
+ } else if ((curr = multiplierChar.indexOf(str[i])) >= 0) {
+ curr = MultiplierExponent_CJK[curr % ExponentCount_CJK];
+ if (prev > curr && num == 0) num = 1; // One may be omitted in informal format
+ shift = end = 0;
+ if (curr >= max)
+ max = curr;
+ else if (curr > prev)
+ shift = max - curr;
+ else
+ end = curr;
+ while (end++ < prev) {
+ dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
+ offset[count++] = i;
+ }
+ if (shift) {
+ count -= max;
+ for (sal_Int16 j = 0; j < shift; j++, count++) {
+ dst[count] = dst[count + curr];
+ offset[count] = offset[count + curr];
+ }
+ max = curr;
+ }
+ NativeToAscii_numberMaker(max, curr, str, i, nCount, dst,
+ count, offset, numberChar, multiplierChar);
+ return;
+ } else
+ break;
+ }
+ while (end++ < prev) {
+ dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
+ offset[count++] = i - 1;
+ }
+}
+
+static OUString SAL_CALL NativeToAscii(const OUString& inStr,
+ sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) throw(RuntimeException)
+{
+ sal_Int32 strLen = inStr.getLength() - startPos;
+
+ if (nCount > strLen)
+ nCount = strLen;
+
+ if (nCount > 0) {
+ const sal_Unicode *str = inStr.getStr() + startPos;
+ rtl_uString *newStr = x_rtl_uString_new_WithLength(nCount * MultiplierExponent_CJK[0] + 1);
+ offset.realloc( nCount * MultiplierExponent_CJK[0] + 1 );
+ sal_Int32 i = 0, count = 0, index;
+
+ OUString numberChar, multiplierChar, decimalChar, minusChar;
+ numberChar = OUString((sal_Unicode*)NumberChar, 10*NumberChar_Count);
+ multiplierChar = OUString((sal_Unicode*) MultiplierChar_CJK, ExponentCount_CJK*Multiplier_Count);
+ decimalChar = OUString(DecimalChar);
+ minusChar = OUString(MinusChar);
+
+ while (i < nCount) {
+ if ((index = multiplierChar.indexOf(str[i])) >= 0) {
+ if (count == 0 || !isNumber(newStr->buffer[count-1])) { // add 1 in front of multiplier
+ newStr->buffer[count] = NUMBER_ONE;
+ offset[count++] = i;
+ }
+ index = MultiplierExponent_CJK[index % ExponentCount_CJK];
+ NativeToAscii_numberMaker(index, index, str, i, nCount, newStr->buffer, count, offset,
+ numberChar, multiplierChar);
+ } else {
+ if ((index = numberChar.indexOf(str[i])) >= 0)
+ newStr->buffer[count] = (index % 10) + NUMBER_ZERO;
+ else if ((index = decimalChar.indexOf(str[i])) >= 0 &&
+ (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
+ multiplierChar.indexOf(str[i+1]) >= 0)))
+ // Only when decimal point is followed by numbers,
+ // it will be convert to ASCII decimal point
+ newStr->buffer[count] = NUMBER_DECIMAL;
+ else if ((index = minusChar.indexOf(str[i])) >= 0 &&
+ (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
+ multiplierChar.indexOf(str[i+1]) >= 0)))
+ // Only when minus is followed by numbers,
+ // it will be convert to ASCII minus sign
+ newStr->buffer[count] = NUMBER_MINUS;
+ else
+ newStr->buffer[count] = str[i];
+ offset[count++] = i++;
+ }
+ }
+
+ offset.realloc(count);
+ for (i = 0; i < count; i++)
+ offset[i] += startPos;
+ return OUString(newStr->buffer, count);
+ }
+ return OUString();
+}
+
+#define isLang(lang) rLocale.Language.equalsAsciiL(lang, 2)
+#define isCtry(ctry) rLocale.Country.equalsAsciiL(ctry, 2)
+
+static sal_Int16 SAL_CALL getLanguageNumber( const Locale& rLocale)
+{
+ sal_Char *aLocaleList[] = { "zh_CN", "zh_TW", "ja", "ko", "ar", "th", "hi" };
+ sal_Int16 nbOfLocale = sizeof(aLocaleList)/sizeof(aLocaleList[0]);
+
+ // return zh_TW for TW, HK and MO, return zh_CN for other zh locales.
+ if (isLang("zh")) return (isCtry("TW") || isCtry("HK") || isCtry("MO")) ? 1 : 0;
+
+ for (sal_Int16 i = 2; i < nbOfLocale; i++)
+ if (isLang(aLocaleList[i]))
+ return i;
+
+ return -1;
+}
+
+static Number natnum4[4] = {
+ { NumberChar_Lower_zh, MultiplierChar_CJK[Multiplier_Lower_zh], 0,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Lower_zh, MultiplierChar_CJK[Multiplier_Lower_zh], 0,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Modern_ja, MultiplierChar_CJK[Multiplier_Modern_ja], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Lower_ko, MultiplierChar_CJK[Multiplier_Upper_zh_TW], NUMBER_OMIT_ZERO,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+};
+
+static Number natnum5[4] = {
+ { NumberChar_Upper_zh, MultiplierChar_CJK[Multiplier_Upper_zh], 0,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Upper_zh_TW, MultiplierChar_CJK[Multiplier_Upper_zh_TW], 0,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Traditional_ja, MultiplierChar_CJK[Multiplier_Traditional_ja], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Upper_ko, MultiplierChar_CJK[Multiplier_Upper_zh_TW], NUMBER_OMIT_ZERO,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+};
+
+static Number natnum6[4] = {
+ { NumberChar_FullWidth, MultiplierChar_CJK[Multiplier_Lower_zh], 0,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_FullWidth, MultiplierChar_CJK[Multiplier_Lower_zh], 0,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_FullWidth, MultiplierChar_CJK[Multiplier_Modern_ja], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_FullWidth, MultiplierChar_CJK[Multiplier_Hangul_ko], NUMBER_OMIT_ZERO,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+};
+
+static Number natnum7[4] = {
+ { NumberChar_Lower_zh, MultiplierChar_CJK[Multiplier_Lower_zh], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Lower_zh, MultiplierChar_CJK[Multiplier_Lower_zh], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Modern_ja, MultiplierChar_short_CJK[Multiplier_Modern_ja], NUMBER_OMIT_ALL,
+ ExponentCount_short_CJK, MultiplierExponent_short_CJK },
+ { NumberChar_Lower_ko, MultiplierChar_CJK[Multiplier_Upper_zh_TW], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+};
+
+static Number natnum8[4] = {
+ { NumberChar_Upper_zh, MultiplierChar_CJK[Multiplier_Upper_zh], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Upper_zh_TW, MultiplierChar_CJK[Multiplier_Upper_zh_TW], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+ { NumberChar_Traditional_ja, MultiplierChar_short_CJK[Multiplier_Traditional_ja], NUMBER_OMIT_ALL,
+ ExponentCount_short_CJK, MultiplierExponent_short_CJK },
+ { NumberChar_Upper_ko, MultiplierChar_CJK[Multiplier_Upper_zh_TW], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK },
+};
+
+static Number natnum10 = { NumberChar_Hangul_ko, MultiplierChar_CJK[Multiplier_Hangul_ko], NUMBER_OMIT_ZERO,
+ ExponentCount_CJK, MultiplierExponent_CJK };
+static Number natnum11 = { NumberChar_Hangul_ko, MultiplierChar_CJK[Multiplier_Hangul_ko], NUMBER_OMIT_ALL,
+ ExponentCount_CJK, MultiplierExponent_CJK };
+
+static sal_Int16 natnum1[] = { NumberChar_Lower_zh, NumberChar_Lower_zh, NumberChar_Modern_ja, NumberChar_Lower_ko,
+ NumberChar_Indic_ar, NumberChar_th, NumberChar_Indic_hi };
+static sal_Int16 sizeof_natnum1 = sizeof(natnum1)/sizeof(natnum1[0]);
+static sal_Int16 natnum2[] = { NumberChar_Upper_zh, NumberChar_Upper_zh_TW, NumberChar_Traditional_ja,
+ NumberChar_Upper_ko };
+static sal_Int16 sizeof_natnum2 = sizeof(natnum2)/sizeof(natnum2[0]);
+
+OUString SAL_CALL NativeNumberSupplier::getNativeNumberString(const OUString& aNumberString, const Locale& aLocale,
+ sal_Int16 nNativeNumberMode) throw (RuntimeException)
+{
+ Sequence< sal_Int32 > offset;
+ Number *number = 0;
+ sal_Int16 num = -1;
+
+ if (isValidNatNum(aLocale, nNativeNumberMode)) {
+ sal_Int16 langnum = getLanguageNumber(aLocale);
+ switch (nNativeNumberMode) {
+ case NativeNumberMode::NATNUM0: // Ascii
+ return NativeToAscii(aNumberString, 0, aNumberString.getLength(), offset);
+ break;
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ num = natnum1[langnum];
+ break;
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ num = natnum2[langnum];
+ break;
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ num = NumberChar_FullWidth;
+ break;
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ number = &natnum4[langnum];
+ break;
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ number = &natnum5[langnum];
+ break;
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ number = &natnum6[langnum];
+ break;
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ number = &natnum7[langnum];
+ break;
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ number = &natnum8[langnum];
+ break;
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ num = NumberChar_Hangul_ko;
+ break;
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ number = &natnum10;
+ break;
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ number = &natnum11;
+ break;
+ default:
+ break;
+ }
+ }
+ if (number)
+ return AsciiToNative( aNumberString, 0, aNumberString.getLength(), offset, number );
+ else if (num >= 0)
+ return AsciiToNativeChar(aNumberString, 0, aNumberString.getLength(), offset, num);
+ else
+ return aNumberString;
+}
+
+sal_Bool SAL_CALL NativeNumberSupplier::isValidNatNum( const Locale& aLocale, sal_Int16 nNativeNumberMode ) throw (RuntimeException)
+{
+ sal_Int16 langnum = getLanguageNumber(aLocale);
+
+ switch (nNativeNumberMode) {
+ case NativeNumberMode::NATNUM0: // Ascii
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ return sal_True;
+ break;
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ return (langnum >= 0);
+ break;
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ return (langnum >= 0 && langnum < 4);
+ break;
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ return (langnum == 3);
+ break;
+ }
+ return sal_False;
+}
+
+NativeNumberXmlAttributes SAL_CALL NativeNumberSupplier::convertToXmlAttributes( const Locale& aLocale, sal_Int16 nNativeNumberMode ) throw (RuntimeException)
+{
+ static const sal_Int16 attShort = 0;
+ static const sal_Int16 attMedium = 1;
+ static const sal_Int16 attLong = 2;
+ static sal_Char *attType[] = { "short", "medium", "long" };
+
+ sal_Int16 number = NumberChar_HalfWidth, type = attShort;
+
+ if (isValidNatNum(aLocale, nNativeNumberMode)) {
+ sal_Int16 langnum = getLanguageNumber(aLocale);
+ switch (nNativeNumberMode) {
+ case NativeNumberMode::NATNUM0: // Ascii
+ number = NumberChar_HalfWidth;
+ type = attShort;
+ break;
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ number = natnum1[langnum];
+ type = attShort;
+ break;
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ number = natnum2[langnum];
+ type = attShort;
+ break;
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ number = NumberChar_FullWidth;
+ type = attShort;
+ break;
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ number = natnum1[langnum];
+ type = attLong;
+ break;
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ number = natnum2[langnum];
+ type = attLong;
+ break;
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ number = NumberChar_FullWidth;
+ type = attLong;
+ break;
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ number = natnum1[langnum];
+ type = attMedium;
+ break;
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ number = natnum2[langnum];
+ type = attMedium;
+ break;
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ number = NumberChar_Hangul_ko;
+ type = attShort;
+ break;
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ number = NumberChar_Hangul_ko;
+ type = attLong;
+ break;
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ number = NumberChar_Hangul_ko;
+ type = attMedium;
+ break;
+ default:
+ break;
+ }
+ }
+ NativeNumberXmlAttributes att(aLocale, OUString(NumberChar[number] + 1, 1),
+ OUString::createFromAscii(attType[type]));
+ return att;
+}
+
+static sal_Bool natNumIn(sal_Int16 num, sal_Int16 natnum[], sal_Int16 len)
+{
+ for (sal_Int16 i = 0; i < len; i++)
+ if (natnum[i] == num)
+ return sal_True;
+ return sal_False;
+}
+
+sal_Int16 SAL_CALL NativeNumberSupplier::convertFromXmlAttributes( const NativeNumberXmlAttributes& aAttr ) throw (RuntimeException)
+{
+ sal_Unicode numberChar[NumberChar_Count];
+ for (sal_Int16 i = 0; i < NumberChar_Count; i++)
+ numberChar[i] = NumberChar[i][1];
+ OUString number(numberChar, NumberChar_Count);
+
+ sal_Int16 num = number.indexOf(aAttr.Number);
+
+ if (aAttr.Type.equalsAscii("short")) {
+ if (num == NumberChar_FullWidth)
+ return NativeNumberMode::NATNUM3;
+ else if (num == NumberChar_Hangul_ko)
+ return NativeNumberMode::NATNUM9;
+ else if (natNumIn(num, natnum1, sizeof_natnum1))
+ return NativeNumberMode::NATNUM1;
+ else if (natNumIn(num, natnum2, sizeof_natnum2))
+ return NativeNumberMode::NATNUM2;
+ } else if (aAttr.Type.equalsAscii("medium")) {
+ if (num == NumberChar_Hangul_ko)
+ return NativeNumberMode::NATNUM11;
+ else if (natNumIn(num, natnum1, sizeof_natnum1))
+ return NativeNumberMode::NATNUM7;
+ else if (natNumIn(num, natnum2, sizeof_natnum2))
+ return NativeNumberMode::NATNUM8;
+ } else if (aAttr.Type.equalsAscii("long")) {
+ if (num == NumberChar_FullWidth)
+ return NativeNumberMode::NATNUM6;
+ else if (num == NumberChar_Hangul_ko)
+ return NativeNumberMode::NATNUM10;
+ else if (natNumIn(num, natnum1, sizeof_natnum1))
+ return NativeNumberMode::NATNUM4;
+ else if (natNumIn(num, natnum2, sizeof_natnum2))
+ return NativeNumberMode::NATNUM5;
+ } else {
+ throw RuntimeException();
+ }
+ return NativeNumberMode::NATNUM0;
+}
+
+static sal_Char* implementationName = "com.sun.star.i18n.NativeNumberSupplier";
+
+OUString SAL_CALL NativeNumberSupplier::getImplementationName() throw( RuntimeException )
+{
+ return OUString::createFromAscii( implementationName );
+}
+
+sal_Bool SAL_CALL
+NativeNumberSupplier::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ return rServiceName.compareToAscii(implementationName) == 0;
+}
+
+Sequence< OUString > SAL_CALL
+NativeNumberSupplier::getSupportedServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii( implementationName );
+ return aRet;
+}
+
+} } } }
diff --git a/i18npool/source/registerservices/registerservices.cxx b/i18npool/source/registerservices/registerservices.cxx
index c034bfa17f7c..62bea15bd824 100644
--- a/i18npool/source/registerservices/registerservices.cxx
+++ b/i18npool/source/registerservices/registerservices.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: registerservices.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: khong $ $Date: 2002-06-18 22:36:32 $
+ * last change: $Author: khong $ $Date: 2002-06-20 02:33:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,6 +80,7 @@ eak * See the License for the specific provisions governing your rights and
#include <localedata.hxx>
#include <numberformatcode.hxx>
+#include <nativenumbersupplier.hxx>
#include <defaultnumberingprovider.hxx>
#include <servicename.hxx>
@@ -169,6 +170,7 @@ typedef ::com::sun::star::uno::Reference<
using namespace ::com::sun::star::i18n;
IMPL_CREATEINSTANCE_MSF( NumberFormatCodeMapper )
+IMPL_CREATEINSTANCE( NativeNumberSupplier )
IMPL_CREATEINSTANCE( LocaleData )
IMPL_CREATEINSTANCE_MSF( DefaultNumberingProvider )
IMPL_CREATEINSTANCE_MSF( IndexEntrySupplier )
@@ -344,6 +346,9 @@ static const struct InstancesArray {
{ "com.sun.star.i18n.NumberFormatMapper",
"com.sun.star.i18n.NumberFormatCodeMapper",
& NumberFormatCodeMapper_CreateInstance },
+ { "com.sun.star.i18n.NativeNumberSupplier",
+ "com.sun.star.i18n.NativeNumberSupplier",
+ & NativeNumberSupplier_CreateInstance },
{ "com.sun.star.text.DefaultNumberingProvider",
"com.sun.star.text.DefaultNumberingProvider",
&DefaultNumberingProvider_CreateInstance },
diff --git a/i18npool/util/makefile.mk b/i18npool/util/makefile.mk
index 24de7e853f4e..498afbe5c38f 100644
--- a/i18npool/util/makefile.mk
+++ b/i18npool/util/makefile.mk
@@ -2,9 +2,9 @@
#*
#* $RCSfile: makefile.mk,v $
#*
-#* $Revision: 1.9 $
+#* $Revision: 1.10 $
#*
-#* last change: $Author: er $ $Date: 2002-03-28 03:05:06 $
+#* last change: $Author: khong $ $Date: 2002-06-20 02:38:54 $
#*
#* The Contents of this file are made available subject to the terms of
#* either of the following licenses
@@ -79,6 +79,7 @@ SYMBOLPREFIX=i18n$(UPD)$(DLLPOSTFIX)
LIB1TARGET= $(SLB)$/$(TARGET).lib
LIB1FILES= $(SLB)$/defaultnumberingprovider.lib \
+ $(SLB)$/nativenumber.lib \
$(SLB)$/registerservices.lib \
$(SLB)$/numberformatcode.lib \
$(SLB)$/locale.lib \