diff options
author | Bustamam Harun <bustamam@openoffice.org> | 2002-04-24 16:10:09 +0000 |
---|---|---|
committer | Bustamam Harun <bustamam@openoffice.org> | 2002-04-24 16:10:09 +0000 |
commit | 30d8ec7a07ee4c6d17676260999cee0d48bb6965 (patch) | |
tree | 28819418c23759f00cba02589cb7425ecb74f9f4 /i18npool/source/inputchecker | |
parent | e776f4a2a3e1ba58a802720de5dcbc91a27ed416 (diff) |
#98754# Hindi BreakIterator and Input Sequence checking
Diffstat (limited to 'i18npool/source/inputchecker')
-rw-r--r-- | i18npool/source/inputchecker/inputsequencechecker_hi.cxx | 160 | ||||
-rw-r--r-- | i18npool/source/inputchecker/makefile.mk | 7 |
2 files changed, 164 insertions, 3 deletions
diff --git a/i18npool/source/inputchecker/inputsequencechecker_hi.cxx b/i18npool/source/inputchecker/inputsequencechecker_hi.cxx new file mode 100644 index 000000000000..2f5533b6e6c0 --- /dev/null +++ b/i18npool/source/inputchecker/inputsequencechecker_hi.cxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * 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 <inputsequencechecker_hi.hxx> + +using namespace rtl; + +namespace com { +namespace sun { +namespace star { +namespace i18n { + +InputSequenceChecker_hi::InputSequenceChecker_hi() +{ + serviceName = "com.sun.star.i18n.InputSequenceChecker_hi"; +} + +InputSequenceChecker_hi::~InputSequenceChecker_hi() +{ +} +/* Non-Defined Class type */ +#define __ND 0 + +/* + * Devanagari character type definitions + */ +#define __UP 1 // ChandraBindu & Anuswar +#define __NP 2 // Visarg +#define __IV 3 // Independant Vowels +#define __CN 4 // Consonants except _CK & _RC +#define __CK 5 // Consonants that can be followed by Nukta +#define __RC 6 // Ra +#define __NM 7 // Matra +#define __RM 8 // Ra + HAL +#define __IM 9 // Choti I Matra +#define __HL 10 // HAL +#define __NK 11 // Nukta +#define __VD 12 // Vedic +#define __HD 13 // Hindu Numerals + +/* + * Devanagari character type table + */ +static const sal_uInt16 devaCT[128] = { +/* 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, A, B, C, D, E, F, */ +/* 0900 */ __ND, __UP, __UP, __NP, __ND, __IV, __IV, __IV, + __IV, __IV, __IV, __IV, __IV, __IV, __IV, __IV, +/* 0910 */ __IV, __IV, __IV, __IV, __IV, __CK, __CK, __CK, + __CN, __CN, __CN, __CN, __CK, __CN, __CN, __CN, +/* 0920 */ __CN, __CK, __CK, __CN, __CN, __CN, __CN, __CN, + __CN, __CN, __CN, __CK, __CN, __CN, __CN, __CN, +/* 0930 */ __RC, __CN, __CN, __CN, __CN, __CN, __CN, __CN, + __CN, __CN, __ND, __ND, __NK, __VD, __NM, __IM, +/* 0940 */ __RM, __NM, __NM, __NM, __NM, __RM, __RM, __RM, + __RM, __RM, __RM, __RM, __RM, __HL, __ND, __ND, +/* 0950 */ __ND, __VD, __VD, __VD, __VD, __ND, __ND, __ND, + __CN, __CN, __CN, __CN, __CN, __CN, __CN, __CN, +/* 0960 */ __IV, __IV, __NM, __NM, __ND, __ND, __HD, __HD, + __HD, __HD, __HD, __HD, __HD, __HD, __HD, __HD, +/* 0970 */ __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND, + __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND, +}; + +/* + * Devanagari character composition table + */ +static const sal_uInt16 dev_cell_check[14][14] = { + /* ND, UP, NP, IV, CN, CK, RC, NM, RM, IM, HL, NK, VD, HD, */ + /* 0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ND */ + /* 1 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* UP */ + /* 2 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* NP */ + /* 3 */ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* IV */ + /* 4 */ 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, /* CN */ + /* 5 */ 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, /* CK */ + /* 6 */ 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, /* RC */ + /* 7 */ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* NM */ + /* 8 */ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* RM */ + /* 9 */ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* IM */ + /* 10 */ 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* HL */ + /* 11 */ 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, /* NK */ + /* 12 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* VD */ + /* 13 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* HD */ +}; + +sal_Bool _DEV_Composible[2][2] = { +/* Mode 0 */ {sal_True, sal_True }, // PASSTHROUGH = 0 +/* Mode 1 */ {sal_False, sal_True} // STRICT = 1 +}; + +#define getCharType(x) \ + ((x >= 0x0900 && x < 0x097f) ? devaCT[x - 0x0900] : __ND) + +sal_Bool SAL_CALL +InputSequenceChecker_hi::checkInputSequence(const OUString& Text, + sal_Int32 nStartPos, + sal_Unicode inputChar, + sal_Int16 inputCheckMode) + throw(com::sun::star::uno::RuntimeException) +{ + sal_Unicode currentChar = Text[nStartPos]; + sal_uInt16 ch1 = getCharType(inputChar); + sal_uInt16 ch2 = getCharType(currentChar); + + return (_DEV_Composible[inputCheckMode][dev_cell_check[ch2][ch1]]); +} + +} } } } diff --git a/i18npool/source/inputchecker/makefile.mk b/i18npool/source/inputchecker/makefile.mk index 557874bbd3d8..bd762a768116 100644 --- a/i18npool/source/inputchecker/makefile.mk +++ b/i18npool/source/inputchecker/makefile.mk @@ -2,9 +2,9 @@ #* #* $RCSfile: makefile.mk,v $ #* -#* $Revision: 1.2 $ +#* $Revision: 1.3 $ #* -#* last change: $Author: er $ $Date: 2002-03-26 17:07:06 $ +#* last change: $Author: bustamam $ $Date: 2002-04-24 17:09:27 $ #* #* The Contents of this file are made available subject to the terms of #* either of the following licenses @@ -76,7 +76,8 @@ ENABLE_EXCEPTIONS=TRUE SLOFILES= \ $(SLO)$/inputsequencechecker.obj \ - $(SLO)$/inputsequencechecker_th.obj + $(SLO)$/inputsequencechecker_th.obj \ + $(SLO)$/inputsequencechecker_hi.obj # --- Targets ------------------------------------------------------ |