LCOV - code coverage report
Current view: top level - i18npool/source/transliteration - ignoreIandEfollowedByYa_ja_JP.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 Functions: 0 1 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 <utility>
      22             : #include <comphelper/string.hxx>
      23             : #include <i18nutil/oneToOneMapping.hxx>
      24             : #define TRANSLITERATION_IandEfollowedByYa_ja_JP
      25             : #include <transliteration_Ignore.hxx>
      26             : 
      27             : using namespace com::sun::star::uno;
      28             : using namespace com::sun::star::lang;
      29             : 
      30             : 
      31             : namespace com { namespace sun { namespace star { namespace i18n {
      32             : 
      33             : OneToOneMappingTable_t IandE[] = {
      34             :     { 0x30A3, 0x0000 },  // KATAKANA LETTER SMALL I
      35             :     { 0x30A4, 0x0000 },  // KATAKANA LETTER I
      36             :     { 0x30A7, 0x0000 },  // KATAKANA LETTER SMALL E
      37             :     { 0x30A8, 0x0000 },  // KATAKANA LETTER E
      38             :     { 0x30AD, 0x0000 },  // KATAKANA LETTER KI
      39             :     { 0x30AE, 0x0000 },  // KATAKANA LETTER GI
      40             :     { 0x30B1, 0x0000 },  // KATAKANA LETTER KE
      41             :     { 0x30B2, 0x0000 },  // KATAKANA LETTER GE
      42             :     { 0x30B7, 0x0000 },  // KATAKANA LETTER SI
      43             :     { 0x30B8, 0x0000 },  // KATAKANA LETTER ZI
      44             :     { 0x30BB, 0x0000 },  // KATAKANA LETTER SE
      45             :     { 0x30BC, 0x0000 },  // KATAKANA LETTER ZE
      46             :     { 0x30C1, 0x0000 },  // KATAKANA LETTER TI
      47             :     { 0x30C2, 0x0000 },  // KATAKANA LETTER DI
      48             :     { 0x30C6, 0x0000 },  // KATAKANA LETTER TE
      49             :     { 0x30C7, 0x0000 },  // KATAKANA LETTER DE
      50             :     { 0x30CB, 0x0000 },  // KATAKANA LETTER NI
      51             :     { 0x30CD, 0x0000 },  // KATAKANA LETTER NE
      52             :     { 0x30D2, 0x0000 },  // KATAKANA LETTER HI
      53             :     { 0x30D3, 0x0000 },  // KATAKANA LETTER BI
      54             :     { 0x30D4, 0x0000 },  // KATAKANA LETTER PI
      55             :     { 0x30D8, 0x0000 },  // KATAKANA LETTER HE
      56             :     { 0x30D9, 0x0000 },  // KATAKANA LETTER BE
      57             :     { 0x30DA, 0x0000 },  // KATAKANA LETTER PE
      58             :     { 0x30DF, 0x0000 },  // KATAKANA LETTER MI
      59             :     { 0x30E1, 0x0000 },  // KATAKANA LETTER ME
      60             :     { 0x30EA, 0x0000 },  // KATAKANA LETTER RI
      61             :     { 0x30EC, 0x0000 },  // KATAKANA LETTER RE
      62             :     { 0x30F0, 0x0000 },  // KATAKANA LETTER WI
      63             :     { 0x30F1, 0x0000 },  // KATAKANA LETTER WE
      64             :     { 0x30F6, 0x0000 },  // KATAKANA LETTER SMALL KE
      65             :     { 0x30F8, 0x0000 },  // KATAKANA LETTER VI
      66             :     { 0x30F9, 0x0000 }   // KATAKANA LETTER VE
      67             : };
      68             : 
      69             : 
      70             : 
      71             : 
      72             : OUString SAL_CALL
      73           0 : ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
      74             :   throw(RuntimeException, std::exception)
      75             : {
      76             :     // Create a string buffer which can hold nCount + 1 characters.
      77             :     // The reference count is 1 now.
      78           0 :     rtl_uString * newStr = rtl_uString_alloc(nCount);
      79           0 :     sal_Unicode * dst = newStr->buffer;
      80           0 :     const sal_Unicode * src = inStr.getStr() + startPos;
      81             : 
      82           0 :     sal_Int32 *p = 0;
      83           0 :     sal_Int32 position = 0;
      84           0 :     if (useOffset) {
      85             :         // Allocate nCount length to offset argument.
      86           0 :         offset.realloc( nCount );
      87           0 :         p = offset.getArray();
      88           0 :         position = startPos;
      89             :     }
      90             : 
      91             : 
      92           0 :     sal_Unicode previousChar = *src ++;
      93             :     sal_Unicode currentChar;
      94             : 
      95             :     // One to one mapping
      96           0 :     oneToOneMapping aTable(IandE, sizeof(IandE));
      97             : 
      98             :     // Translation
      99           0 :     while (-- nCount > 0) {
     100           0 :         currentChar = *src ++;
     101             : 
     102             :         // the character listed in above table + YA --> the character + A
     103           0 :         if (currentChar == 0x30E3 ||   // KATAKANA LETTER SMALL YA
     104             :                 currentChar == 0x30E4) {   // KATAKANA LETTER YA
     105           0 :             if (aTable[ previousChar ] != previousChar) {
     106           0 :                 if (useOffset) {
     107           0 :                     *p ++ = position++;
     108           0 :                     *p ++ = position++;
     109             :                 }
     110           0 :                 *dst ++ = previousChar;
     111           0 :                 *dst ++ = 0x30A2;          // KATAKANA LETTER A
     112           0 :                 previousChar = *src ++;
     113           0 :                 nCount --;
     114           0 :                 continue;
     115             :             }
     116             :         }
     117             : 
     118           0 :         if (useOffset)
     119           0 :             *p ++ = position++;
     120           0 :         *dst ++ = previousChar;
     121           0 :         previousChar = currentChar;
     122             :     }
     123             : 
     124           0 :     if (nCount == 0) {
     125           0 :         if (useOffset)
     126           0 :             *p = position;
     127           0 :         *dst ++ = previousChar;
     128             :     }
     129             : 
     130           0 :     *dst = (sal_Unicode) 0;
     131             : 
     132           0 :     newStr->length = sal_Int32(dst - newStr->buffer);
     133           0 :     if (useOffset)
     134           0 :         offset.realloc(newStr->length);
     135           0 :     return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
     136             : }
     137             : 
     138             : } } } }
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10