LCOV - code coverage report
Current view: top level - libreoffice/i18npool/source/inputchecker - inputsequencechecker_hi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2012-12-27 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <inputsequencechecker_hi.hxx>
      22             : 
      23             : using ::rtl::OUString;
      24             : 
      25             : namespace com {
      26             : namespace sun {
      27             : namespace star {
      28             : namespace i18n {
      29             : 
      30           0 : InputSequenceChecker_hi::InputSequenceChecker_hi()
      31             : {
      32           0 :     serviceName = "com.sun.star.i18n.InputSequenceChecker_hi";
      33           0 : }
      34             : 
      35           0 : InputSequenceChecker_hi::~InputSequenceChecker_hi()
      36             : {
      37           0 : }
      38             : /* Non-Defined Class type */
      39             : #define __ND        0
      40             : 
      41             : /*
      42             :  * Devanagari character type definitions
      43             :  */
      44             : #define __UP  1  // ChandraBindu & Anuswar
      45             : #define __NP  2  // Visarg
      46             : #define __IV    3  // Independant Vowels
      47             : #define __CN    4  // Consonants except _CK & _RC
      48             : #define __CK    5  // Consonants that can be followed by Nukta
      49             : #define __RC    6  // Ra
      50             : #define __NM    7  // Matra
      51             : #define __RM    8  // Ra + HAL
      52             : #define __IM    9  // Choti I Matra
      53             : #define __HL    10 // HAL
      54             : #define __NK    11 // Nukta
      55             : #define __VD    12 // Vedic
      56             : #define __HD    13 // Hindu Numerals
      57             : 
      58             : /*
      59             :  * Devanagari character type table
      60             :  */
      61             : static const sal_uInt16 devaCT[128] = {
      62             : /*         0,    1,    2,    3,    4,    5,    6,    7,
      63             :            8,    9,    A,    B,    C,    D,    E,    F, */
      64             : /* 0900 */ __ND, __UP, __UP, __NP, __ND, __IV, __IV, __IV,
      65             :            __IV, __IV, __IV, __IV, __IV, __IV, __IV, __IV,
      66             : /* 0910 */ __IV, __IV, __IV, __IV, __IV, __CK, __CK, __CK,
      67             :            __CN, __CN, __CN, __CN, __CK, __CN, __CN, __CN,
      68             : /* 0920 */ __CN, __CK, __CK, __CN, __CN, __CN, __CN, __CN,
      69             :            __CN, __CN, __CN, __CK, __CN, __CN, __CN, __CN,
      70             : /* 0930 */ __RC, __CN, __CN, __CN, __CN, __CN, __CN, __CN,
      71             :            __CN, __CN, __ND, __ND, __NK, __VD, __NM, __IM,
      72             : /* 0940 */ __RM, __NM, __NM, __NM, __NM, __RM, __RM, __RM,
      73             :            __RM, __RM, __RM, __RM, __RM, __HL, __ND, __ND,
      74             : /* 0950 */ __ND, __VD, __VD, __VD, __VD, __ND, __ND, __ND,
      75             :            __CN, __CN, __CN, __CN, __CN, __CN, __CN, __CN,
      76             : /* 0960 */ __IV, __IV, __NM, __NM, __ND, __ND, __HD, __HD,
      77             :            __HD, __HD, __HD, __HD, __HD, __HD, __HD, __HD,
      78             : /* 0970 */ __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
      79             :            __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
      80             : };
      81             : 
      82             : /*
      83             :  * Devanagari character composition table
      84             :  */
      85             : static const sal_uInt16 dev_cell_check[14][14] = {
      86             :   /*        ND, UP, NP, IV, CN, CK, RC, NM, RM, IM, HL, NK, VD, HD, */
      87             :   /* 0  */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* ND */
      88             :   /* 1  */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* UP */
      89             :   /* 2  */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* NP */
      90             :   /* 3  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* IV */
      91             :   /* 4  */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0 }, /* CN */
      92             :   /* 5  */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  1,  0,  0 }, /* CK */
      93             :   /* 6  */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0 }, /* RC */
      94             :   /* 7  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* NM */
      95             :   /* 8  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* RM */
      96             :   /* 9  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* IM */
      97             :   /* 10 */ { 0,  0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0 }, /* HL */
      98             :   /* 11 */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0 }, /* NK */
      99             :   /* 12 */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* VD */
     100             :   /* 13 */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }  /* HD */
     101             : };
     102             : 
     103             : sal_Bool _DEV_Composible[2][2] = {
     104             : /* Mode 0 */    {sal_True, sal_True }, // PASSTHROUGH = 0
     105             : /* Mode 1 */    {sal_False, sal_True}  // STRICT = 1
     106             : };
     107             : 
     108             : #define getCharType(x) \
     109             :     ((x >= 0x0900 && x < 0x097f) ? devaCT[x - 0x0900] : __ND)
     110             : 
     111             : sal_Bool SAL_CALL
     112           0 : InputSequenceChecker_hi::checkInputSequence(const OUString& Text,
     113             :                                             sal_Int32       nStartPos,
     114             :                                             sal_Unicode     inputChar,
     115             :                                             sal_Int16       inputCheckMode)
     116             :   throw(com::sun::star::uno::RuntimeException)
     117             : {
     118           0 :     sal_Unicode currentChar = Text[nStartPos];
     119           0 :   sal_uInt16  ch1 = getCharType(inputChar);
     120           0 :     sal_uInt16  ch2 = getCharType(currentChar);
     121             : 
     122           0 :     return (_DEV_Composible[inputCheckMode][dev_cell_check[ch2][ch1]]);
     123             : }
     124             : 
     125             : sal_Int32 SAL_CALL
     126           0 : InputSequenceChecker_hi::correctInputSequence(OUString& Text,
     127             :                                             sal_Int32       nStartPos,
     128             :                                             sal_Unicode     inputChar,
     129             :                                             sal_Int16       inputCheckMode)
     130             :   throw(com::sun::star::uno::RuntimeException)
     131             : {
     132           0 :     if (checkInputSequence(Text, nStartPos, inputChar, inputCheckMode))
     133           0 :         Text = Text.replaceAt(++nStartPos, 0, OUString(inputChar));
     134             :     else
     135           0 :         nStartPos=Text.getLength();
     136           0 :     return nStartPos;
     137             : }
     138             : } } } }
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10