LCOV - code coverage report
Current view: top level - libreoffice/i18npool/source/transliteration - fullwidthToHalfwidth.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 51 0.0 %
Date: 2012-12-27 Functions: 0 9 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 <i18nutil/widthfolding.hxx>
      25             : #define TRANSLITERATION_fullwidthToHalfwidth
      26             : #define TRANSLITERATION_fullwidthKatakanaToHalfwidthKatakana
      27             : #define TRANSLITERATION_fullwidthToHalfwidthLikeASC
      28             : #include <transliteration_OneToOne.hxx>
      29             : 
      30             : using namespace com::sun::star::uno;
      31             : using namespace com::sun::star::lang;
      32             : 
      33             : using ::rtl::OUString;
      34             : 
      35             : namespace com { namespace sun { namespace star { namespace i18n {
      36             : 
      37           0 : fullwidthToHalfwidth::fullwidthToHalfwidth()
      38             : {
      39           0 :     func = (TransFunc) 0;
      40           0 :     table = &widthfolding::getfull2halfTable();
      41           0 :     transliterationName = "fullwidthToHalfwidth";
      42           0 :     implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH";
      43           0 : }
      44             : 
      45             : /**
      46             :  * Transliterate fullwidth to halfwidth.
      47             :  * The output is a reference of OUString. You MUST delete this object when you do not need to use it any more
      48             :  * The output string contains a transliterated string only, not whole string.
      49             :  */
      50             : OUString SAL_CALL
      51           0 : fullwidthToHalfwidth::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
      52             :   throw(RuntimeException)
      53             : {
      54             :     // Decomposition: GA --> KA + voice-mark
      55           0 :     const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
      56             : 
      57             :     // One to One mapping
      58           0 :     useOffset = sal_False;
      59           0 :     const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
      60           0 :     useOffset = sal_True;
      61           0 :     return tmp;
      62             : }
      63             : 
      64             : sal_Unicode SAL_CALL
      65           0 : fullwidthToHalfwidth::transliterateChar2Char( sal_Unicode inChar)
      66             :   throw(RuntimeException, MultipleCharsOutputException)
      67             : {
      68           0 :     sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
      69           0 :     if (newChar == 0xFFFF)
      70           0 :         throw MultipleCharsOutputException();
      71           0 :     return transliteration_OneToOne::transliterateChar2Char(inChar);
      72             : }
      73             : 
      74           0 : fullwidthKatakanaToHalfwidthKatakana::fullwidthKatakanaToHalfwidthKatakana()
      75             : {
      76           0 :     func = (TransFunc) 0;
      77           0 :     table = &widthfolding::getfullKana2halfKanaTable();
      78           0 :     transliterationName = "fullwidthKatakanaToHalfwidthKatakana";
      79           0 :     implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTHKATAKANA_HALFWIDTHKATAKANA";
      80           0 : }
      81             : 
      82             : /**
      83             :  * Transliterate fullwidth katakana to halfwidth katakana.
      84             :  */
      85             : OUString SAL_CALL
      86           0 : fullwidthKatakanaToHalfwidthKatakana::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
      87             :   throw(RuntimeException)
      88             : {
      89             :     // Decomposition: GA --> KA + voice-mark
      90           0 :     const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
      91             : 
      92             :     // One to One mapping
      93           0 :     useOffset = sal_False;
      94           0 :     const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
      95           0 :     useOffset = sal_True;
      96           0 :     return tmp;
      97             : }
      98             : 
      99             : sal_Unicode SAL_CALL
     100           0 : fullwidthKatakanaToHalfwidthKatakana::transliterateChar2Char( sal_Unicode inChar )
     101             :   throw(RuntimeException, MultipleCharsOutputException)
     102             : {
     103           0 :     sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
     104           0 :     if (newChar == 0xFFFF)
     105           0 :         throw MultipleCharsOutputException();
     106           0 :     return transliteration_OneToOne::transliterateChar2Char(inChar);
     107             : }
     108             : 
     109           0 : fullwidthToHalfwidthLikeASC::fullwidthToHalfwidthLikeASC()
     110             : {
     111           0 :     func = (TransFunc) 0;
     112           0 :     table = &widthfolding::getfull2halfTableForASC();
     113           0 :     transliterationName = "fullwidthToHalfwidthLikeASC";
     114           0 :     implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH_LIKE_ASC";
     115           0 : }
     116             : 
     117             : /**
     118             :  * Transliterate fullwidth to halfwidth like Excel's ASC function.
     119             :  */
     120             : OUString SAL_CALL
     121           0 : fullwidthToHalfwidthLikeASC::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
     122             :   throw(RuntimeException)
     123             : {
     124             :     // Decomposition: GA --> KA + voice-mark
     125           0 :     const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
     126             : 
     127             :     // One to One mapping
     128           0 :     useOffset = sal_False;
     129           0 :     const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
     130           0 :     useOffset = sal_True;
     131             : 
     132           0 :     return tmp;
     133             : }
     134             : 
     135             : sal_Unicode SAL_CALL
     136           0 : fullwidthToHalfwidthLikeASC::transliterateChar2Char( sal_Unicode inChar )
     137             :   throw(RuntimeException, MultipleCharsOutputException)
     138             : {
     139           0 :     sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
     140           0 :     if (newChar == 0xFFFF)
     141           0 :         throw MultipleCharsOutputException();
     142           0 :     return transliteration_OneToOne::transliterateChar2Char(inChar);
     143             : }
     144             : 
     145             : } } } }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10