LCOV - code coverage report
Current view: top level - i18npool/source/inputchecker - inputsequencechecker_hi.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 15 0.0 %
Date: 2015-06-13 12:38:46 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             : 
      24             : namespace com {
      25             : namespace sun {
      26             : namespace star {
      27             : namespace i18n {
      28             : 
      29           0 : InputSequenceChecker_hi::InputSequenceChecker_hi()
      30           0 :     : InputSequenceCheckerImpl("com.sun.star.i18n.InputSequenceChecker_hi")
      31             : {
      32           0 : }
      33             : 
      34           0 : InputSequenceChecker_hi::~InputSequenceChecker_hi()
      35             : {
      36           0 : }
      37             : /* Non-Defined Class type */
      38             : #define __ND        0
      39             : 
      40             : /*
      41             :  * Devanagari character type definitions
      42             :  */
      43             : #define __UP  1  // ChandraBindu & Anuswar
      44             : #define __NP  2  // Visarg
      45             : #define __IV    3  // Independent Vowels
      46             : #define __CN    4  // Consonants except _CK & _RC
      47             : #define __CK    5  // Consonants that can be followed by Nukta
      48             : #define __RC    6  // Ra
      49             : #define __NM    7  // Matra
      50             : #define __RM    8  // Ra + HAL
      51             : #define __IM    9  // Choti I Matra
      52             : #define __HL    10 // HAL
      53             : #define __NK    11 // Nukta
      54             : #define __VD    12 // Vedic
      55             : #define __HD    13 // Hindu Numerals
      56             : 
      57             : /*
      58             :  * Devanagari character type table
      59             :  */
      60             : static const sal_uInt16 devaCT[128] = {
      61             : /*         0,    1,    2,    3,    4,    5,    6,    7,
      62             :            8,    9,    A,    B,    C,    D,    E,    F, */
      63             : /* 0900 */ __ND, __UP, __UP, __NP, __ND, __IV, __IV, __IV,
      64             :            __IV, __IV, __IV, __IV, __IV, __IV, __IV, __IV,
      65             : /* 0910 */ __IV, __IV, __IV, __IV, __IV, __CK, __CK, __CK,
      66             :            __CN, __CN, __CN, __CN, __CK, __CN, __CN, __CN,
      67             : /* 0920 */ __CN, __CK, __CK, __CN, __CN, __CN, __CN, __CN,
      68             :            __CN, __CN, __CN, __CK, __CN, __CN, __CN, __CN,
      69             : /* 0930 */ __RC, __CN, __CN, __CN, __CN, __CN, __CN, __CN,
      70             :            __CN, __CN, __ND, __ND, __NK, __VD, __NM, __IM,
      71             : /* 0940 */ __RM, __NM, __NM, __NM, __NM, __RM, __RM, __RM,
      72             :            __RM, __RM, __RM, __RM, __RM, __HL, __ND, __ND,
      73             : /* 0950 */ __ND, __VD, __VD, __VD, __VD, __ND, __ND, __ND,
      74             :            __CN, __CN, __CN, __CN, __CN, __CN, __CN, __CN,
      75             : /* 0960 */ __IV, __IV, __NM, __NM, __ND, __ND, __HD, __HD,
      76             :            __HD, __HD, __HD, __HD, __HD, __HD, __HD, __HD,
      77             : /* 0970 */ __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
      78             :            __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND,
      79             : };
      80             : 
      81             : /*
      82             :  * Devanagari character composition table
      83             :  */
      84             : static const sal_uInt16 dev_cell_check[14][14] = {
      85             :   /*        ND, UP, NP, IV, CN, CK, RC, NM, RM, IM, HL, NK, VD, HD, */
      86             :   /* 0  */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* ND */
      87             :   /* 1  */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* UP */
      88             :   /* 2  */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* NP */
      89             :   /* 3  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* IV */
      90             :   /* 4  */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0 }, /* CN */
      91             :   /* 5  */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  1,  0,  0 }, /* CK */
      92             :   /* 6  */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0 }, /* RC */
      93             :   /* 7  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* NM */
      94             :   /* 8  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* RM */
      95             :   /* 9  */ { 0,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* IM */
      96             :   /* 10 */ { 0,  0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0 }, /* HL */
      97             :   /* 11 */ { 0,  1,  1,  0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  0 }, /* NK */
      98             :   /* 12 */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }, /* VD */
      99             :   /* 13 */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }  /* HD */
     100             : };
     101             : 
     102             : sal_Bool _DEV_Composible[2][2] = {
     103             : /* Mode 0 */    {sal_True, sal_True }, // PASSTHROUGH = 0
     104             : /* Mode 1 */    {sal_False, sal_True}  // STRICT = 1
     105             : };
     106             : 
     107             : #define getCharType(x) \
     108             :     ((x >= 0x0900 && x < 0x097f) ? devaCT[x - 0x0900] : __ND)
     109             : 
     110             : sal_Bool SAL_CALL
     111           0 : InputSequenceChecker_hi::checkInputSequence(const OUString& Text,
     112             :                                             sal_Int32       nStartPos,
     113             :                                             sal_Unicode     inputChar,
     114             :                                             sal_Int16       inputCheckMode)
     115             :   throw(com::sun::star::uno::RuntimeException, std::exception)
     116             : {
     117           0 :     sal_Unicode currentChar = Text[nStartPos];
     118           0 :   sal_uInt16  ch1 = getCharType(inputChar);
     119           0 :     sal_uInt16  ch2 = getCharType(currentChar);
     120             : 
     121           0 :     return (_DEV_Composible[inputCheckMode][dev_cell_check[ch2][ch1]]);
     122             : }
     123             : 
     124             : sal_Int32 SAL_CALL
     125           0 : InputSequenceChecker_hi::correctInputSequence(OUString& Text,
     126             :                                             sal_Int32       nStartPos,
     127             :                                             sal_Unicode     inputChar,
     128             :                                             sal_Int16       inputCheckMode)
     129             :   throw(com::sun::star::uno::RuntimeException, std::exception)
     130             : {
     131           0 :     if (checkInputSequence(Text, nStartPos, inputChar, inputCheckMode))
     132           0 :         Text = Text.replaceAt(++nStartPos, 0, OUString(inputChar));
     133             :     else
     134           0 :         nStartPos=Text.getLength();
     135           0 :     return nStartPos;
     136             : }
     137             : } } } }
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11