LCOV - code coverage report
Current view: top level - libreoffice/i18npool/source/transliteration - textToPronounce_zh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 72 0.0 %
Date: 2012-12-27 Functions: 0 12 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             : // prevent internal compiler error with MSVC6SP3
      22             : #include <utility>
      23             : 
      24             : #include <rtl/string.hxx>
      25             : #include <rtl/ustrbuf.hxx>
      26             : #define TRANSLITERATION_ALL
      27             : #include <textToPronounce_zh.hxx>
      28             : 
      29             : using namespace com::sun::star::uno;
      30             : 
      31             : using ::rtl::OUString;
      32             : using ::rtl::OUStringBuffer;
      33             : 
      34             : namespace com { namespace sun { namespace star { namespace i18n {
      35             : 
      36           0 : sal_Int16 SAL_CALL TextToPronounce_zh::getType() throw (RuntimeException)
      37             : {
      38           0 :     return TransliterationType::ONE_TO_ONE| TransliterationType::IGNORE;
      39             : }
      40             : 
      41             : const sal_Unicode* SAL_CALL
      42           0 : TextToPronounce_zh::getPronounce(const sal_Unicode ch)
      43             : {
      44             :     static const sal_Unicode emptyString[]={0};
      45           0 :     if (idx) {
      46           0 :         sal_uInt16 address = idx[0][ch>>8];
      47           0 :         if (address != 0xFFFF)
      48           0 :             return &idx[2][idx[1][address + (ch & 0xFF)]];
      49             :     }
      50           0 :     return emptyString;
      51             : }
      52             : 
      53             : OUString SAL_CALL
      54           0 : TextToPronounce_zh::folding(const OUString & inStr, sal_Int32 startPos,
      55             :         sal_Int32 nCount, Sequence< sal_Int32 > & offset) throw (RuntimeException)
      56             : {
      57           0 :     OUStringBuffer sb;
      58           0 :     const sal_Unicode * chArr = inStr.getStr() + startPos;
      59             : 
      60           0 :     if (startPos < 0)
      61           0 :         throw RuntimeException();
      62             : 
      63           0 :     if (startPos + nCount > inStr.getLength())
      64           0 :         nCount = inStr.getLength() - startPos;
      65             : 
      66           0 :     offset[0] = 0;
      67           0 :     for (sal_Int32 i = 0; i < nCount; i++) {
      68           0 :         OUString pron(getPronounce(chArr[i]));
      69           0 :         sb.append(pron);
      70             : 
      71           0 :         if (useOffset)
      72           0 :             offset[i + 1] = offset[i] + pron.getLength();
      73           0 :     }
      74           0 :     return sb.makeStringAndClear();
      75             : }
      76             : 
      77             : OUString SAL_CALL
      78           0 : TextToPronounce_zh::transliterateChar2String( sal_Unicode inChar) throw(RuntimeException)
      79             : {
      80           0 :     return OUString(getPronounce(inChar));
      81             : }
      82             : 
      83             : sal_Unicode SAL_CALL
      84           0 : TextToPronounce_zh::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException)
      85             : {
      86           0 :     const sal_Unicode* pron=getPronounce(inChar);
      87           0 :     if (!pron || !pron[0])
      88           0 :         return 0;
      89           0 :     if (pron[1])
      90           0 :         throw MultipleCharsOutputException();
      91           0 :     return *pron;
      92             : }
      93             : 
      94             : sal_Bool SAL_CALL
      95           0 : TextToPronounce_zh::equals( const OUString & str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32 & nMatch1,
      96             :         const OUString & str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32 & nMatch2)
      97             :         throw (RuntimeException)
      98             : {
      99             :     sal_Int32 realCount;
     100             :     int i;  // loop variable
     101             :     const sal_Unicode * s1, * s2;
     102             :     const sal_Unicode *pron1, *pron2;
     103             : 
     104           0 :     if (nCount1 + pos1 > str1.getLength())
     105           0 :         nCount1 = str1.getLength() - pos1;
     106             : 
     107           0 :     if (nCount2 + pos2 > str2.getLength())
     108           0 :         nCount2 = str2.getLength() - pos2;
     109             : 
     110           0 :     realCount = ((nCount1 > nCount2) ? nCount2 : nCount1);
     111             : 
     112           0 :     s1 = str1.getStr() + pos1;
     113           0 :     s2 = str2.getStr() + pos2;
     114           0 :     for (i = 0; i < realCount; i++) {
     115           0 :         pron1=getPronounce(*s1++);
     116           0 :         pron2=getPronounce(*s2++);
     117           0 :         if (pron1 != pron2) {
     118           0 :             nMatch1 = nMatch2 = i;
     119           0 :             return sal_False;
     120             :         }
     121             :     }
     122           0 :     nMatch1 = nMatch2 = realCount;
     123           0 :     return (nCount1 == nCount2);
     124             : }
     125             : 
     126             : #ifdef DISABLE_DYNLOADING
     127             : 
     128             : extern "C" {
     129             : 
     130             : sal_uInt16** get_zh_zhuyin();
     131             : sal_uInt16** get_zh_pinyin();
     132             : 
     133             : }
     134             : 
     135             : #endif
     136             : 
     137           0 : TextToPinyin_zh_CN::TextToPinyin_zh_CN() :
     138             : #ifndef DISABLE_DYNLOADING
     139           0 :     TextToPronounce_zh("get_zh_pinyin")
     140             : #else
     141             :     TextToPronounce_zh(get_zh_pinyin)
     142             : #endif
     143             : {
     144           0 :         transliterationName = "ChineseCharacterToPinyin";
     145           0 :         implementationName = "com.sun.star.i18n.Transliteration.TextToPinyin_zh_CN";
     146           0 : }
     147             : 
     148           0 : TextToChuyin_zh_TW::TextToChuyin_zh_TW() :
     149             : #ifndef DISABLE_DYNLOADING
     150           0 :     TextToPronounce_zh("get_zh_zhuyin")
     151             : #else
     152             :     TextToPronounce_zh(get_zh_zhuyin)
     153             : #endif
     154             : {
     155           0 :         transliterationName = "ChineseCharacterToChuyin";
     156           0 :         implementationName = "com.sun.star.i18n.Transliteration.TextToChuyin_zh_TW";
     157           0 : }
     158             : 
     159             : #ifndef DISABLE_DYNLOADING
     160             : 
     161           0 : extern "C" { static void SAL_CALL thisModule() {} }
     162             : 
     163           0 : TextToPronounce_zh::TextToPronounce_zh(const sal_Char* func_name)
     164             : {
     165             : #ifdef SAL_DLLPREFIX
     166           0 :     OUString lib(SAL_DLLPREFIX"index_data" SAL_DLLEXTENSION);
     167             : #else
     168             :     OUString lib("index_data" SAL_DLLEXTENSION);
     169             : #endif
     170             :     hModule = osl_loadModuleRelative(
     171           0 :         &thisModule, lib.pData, SAL_LOADMODULE_DEFAULT );
     172           0 :     idx=NULL;
     173           0 :     if (hModule) {
     174           0 :         sal_uInt16** (*function)() = (sal_uInt16** (*)()) osl_getFunctionSymbol(hModule, OUString::createFromAscii(func_name).pData);
     175           0 :         if (function)
     176           0 :             idx=function();
     177           0 :     }
     178           0 : }
     179             : 
     180             : #else
     181             : 
     182             : TextToPronounce_zh::TextToPronounce_zh(sal_uInt16 ** (*function)())
     183             : {
     184             :     idx = function();
     185             : }
     186             : 
     187             : #endif
     188             : 
     189           0 : TextToPronounce_zh::~TextToPronounce_zh()
     190             : {
     191             : #ifndef DISABLE_DYNLOADING
     192           0 :     if (hModule) osl_unloadModule(hModule);
     193             : #endif
     194           0 : }
     195             : } } } }
     196             : 
     197             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10