LCOV - code coverage report
Current view: top level - i18npool/source/transliteration - ignoreKiKuFollowedBySa_ja_JP.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 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             : #define TRANSLITERATION_KiKuFollowedBySa_ja_JP
      24             : #include <transliteration_Ignore.hxx>
      25             : 
      26             : using namespace com::sun::star::uno;
      27             : using namespace com::sun::star::lang;
      28             : 
      29             : 
      30             : namespace com { namespace sun { namespace star { namespace i18n {
      31             : 
      32             : OUString SAL_CALL
      33           0 : ignoreKiKuFollowedBySa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
      34             :   throw(RuntimeException, std::exception)
      35             : {
      36             :     // Create a string buffer which can hold nCount + 1 characters.
      37             :     // The reference count is 1 now.
      38           0 :     rtl_uString * newStr = rtl_uString_alloc(nCount);
      39           0 :     sal_Unicode * dst = newStr->buffer;
      40           0 :     const sal_Unicode * src = inStr.getStr() + startPos;
      41             : 
      42           0 :     sal_Int32 *p = 0;
      43           0 :     sal_Int32 position = 0;
      44           0 :     if (useOffset) {
      45             :         // Allocate nCount length to offset argument.
      46           0 :         offset.realloc( nCount );
      47           0 :         p = offset.getArray();
      48           0 :         position = startPos;
      49             :     }
      50             : 
      51             : 
      52           0 :     sal_Unicode previousChar = *src ++;
      53             :     sal_Unicode currentChar;
      54             : 
      55             :     // Translation
      56           0 :     while (-- nCount > 0) {
      57           0 :         currentChar = *src ++;
      58             : 
      59             :         // KU + Sa-So --> KI + Sa-So
      60           0 :         if (previousChar == 0x30AF ) { // KATAKANA LETTER KU
      61           0 :             if (0x30B5 <= currentChar && // KATAKANA LETTER SA
      62             :                     currentChar <= 0x30BE) { // KATAKANA LETTER ZO
      63           0 :                 if (useOffset) {
      64           0 :                     *p ++ = position++;
      65           0 :                     *p ++ = position++;
      66             :                 }
      67           0 :                 *dst ++ = 0x30AD;          // KATAKANA LETTER KI
      68           0 :                 *dst ++ = currentChar;
      69           0 :                 previousChar = *src ++;
      70           0 :                 nCount --;
      71           0 :                 continue;
      72             :             }
      73             :         }
      74             : 
      75           0 :         if (useOffset)
      76           0 :             *p ++ = position++;
      77           0 :         *dst ++ = previousChar;
      78           0 :         previousChar = currentChar;
      79             :     }
      80             : 
      81           0 :     if (nCount == 0) {
      82           0 :         if (useOffset)
      83           0 :             *p = position;
      84           0 :         *dst ++ = previousChar;
      85             :     }
      86             : 
      87           0 :     *dst = (sal_Unicode) 0;
      88             : 
      89           0 :     newStr->length = sal_Int32(dst - newStr->buffer);
      90           0 :     if (useOffset)
      91           0 :         offset.realloc(newStr->length);
      92           0 :     return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
      93             : }
      94             : 
      95             : } } } }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10