LCOV - code coverage report
Current view: top level - i18npool/source/transliteration - transliteration_Numeric.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 57 0.0 %
Date: 2014-04-14 Functions: 0 7 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 <transliteration_Numeric.hxx>
      22             : #include <nativenumbersupplier.hxx>
      23             : #include <defaultnumberingprovider.hxx>
      24             : #include <comphelper/string.hxx>
      25             : 
      26             : using namespace com::sun::star::uno;
      27             : 
      28             : 
      29             : namespace com { namespace sun { namespace star { namespace i18n {
      30             : 
      31           0 : sal_Int16 SAL_CALL transliteration_Numeric::getType() throw(RuntimeException, std::exception)
      32             : {
      33           0 :     return TransliterationType::NUMERIC;
      34             : }
      35             : 
      36             : OUString SAL_CALL
      37           0 :     transliteration_Numeric::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/, sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/ )
      38             : throw(RuntimeException, std::exception)
      39             : {
      40           0 :     throw RuntimeException();
      41             : }
      42             : 
      43             : sal_Bool SAL_CALL
      44           0 :     transliteration_Numeric::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 /*nCount1*/, sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 /*nCount2*/, sal_Int32& /*nMatch2*/ )
      45             : throw(RuntimeException, std::exception)
      46             : {
      47           0 :     throw RuntimeException();
      48             : }
      49             : 
      50             : Sequence< OUString > SAL_CALL
      51           0 :     transliteration_Numeric::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
      52             : throw(RuntimeException, std::exception)
      53             : {
      54           0 :     throw RuntimeException();
      55             : }
      56             : 
      57             : 
      58             : #define isNumber(c) ((c) >= 0x30 && (c) <= 0x39)
      59             : #define NUMBER_ZERO 0x30
      60             : 
      61             : OUString SAL_CALL
      62           0 : transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
      63             :         Sequence< sal_Int32 >& offset ) throw(RuntimeException)
      64             : {
      65           0 :     sal_Int32 number = -1, j = 0, endPos = startPos + nCount;
      66             : 
      67           0 :     if (endPos >  inStr.getLength())
      68           0 :         endPos = inStr.getLength();
      69             : 
      70           0 :     rtl_uString* pStr = rtl_uString_alloc(nCount);
      71           0 :     sal_Unicode* out = pStr->buffer;
      72             : 
      73           0 :     if (useOffset)
      74           0 :         offset.realloc(nCount);
      75             : 
      76           0 :     for (sal_Int32 i = startPos; i < endPos; i++) {
      77           0 :         if (i < endPos && isNumber(inStr[i])) {
      78           0 :             if (number == -1) {
      79           0 :                 startPos = i;
      80           0 :                 number = (inStr[i] - NUMBER_ZERO);
      81             :             } else  {
      82           0 :                 number = number * 10 + (inStr[i] - NUMBER_ZERO);
      83             :             }
      84             :         } else {
      85           0 :             if (number == 0) {
      86           0 :                 if (useOffset)
      87           0 :                     offset[j] = startPos;
      88           0 :                 out[j++] = NUMBER_ZERO;
      89           0 :             } if (number > tableSize && !recycleSymbol) {
      90           0 :                 for (sal_Int32 k = startPos; k < i; k++) {
      91           0 :                     if (useOffset)
      92           0 :                         offset[j] = k;
      93           0 :                     out[j++] = inStr[k];
      94           0 :                 }
      95           0 :             } else if (number > 0) {
      96           0 :                 if (useOffset)
      97           0 :                     offset[j] = startPos;
      98           0 :                 out[j++] = table[--number % tableSize];
      99           0 :             } else if (i < endPos) {
     100           0 :                 if (useOffset)
     101           0 :                     offset[j] = i;
     102           0 :                 out[j++] = inStr[i];
     103             :             }
     104           0 :             number = -1;
     105             :         }
     106             :     }
     107           0 :     out[j] = 0;
     108             : 
     109           0 :     if (useOffset)
     110           0 :         offset.realloc(j);
     111             : 
     112           0 :     return OUString( pStr, SAL_NO_ACQUIRE );
     113             : }
     114             : 
     115             : OUString SAL_CALL
     116           0 : transliteration_Numeric::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
     117             :         Sequence< sal_Int32 >& offset ) throw(RuntimeException, std::exception)
     118             : {
     119           0 :     if (tableSize)
     120           0 :         return transliterateBullet( inStr, startPos, nCount, offset);
     121             :     else
     122           0 :         return NativeNumberSupplier(useOffset).getNativeNumberString( inStr.copy(startPos, nCount), aLocale, nNativeNumberMode, offset );
     123             : }
     124             : 
     125             : sal_Unicode SAL_CALL
     126           0 : transliteration_Numeric::transliterateChar2Char( sal_Unicode inChar ) throw(RuntimeException, MultipleCharsOutputException, std::exception)
     127             : {
     128           0 :     if (tableSize) {
     129           0 :         if (isNumber(inChar)) {
     130           0 :             sal_Int16 number = inChar - NUMBER_ZERO;
     131           0 :             if (number <= tableSize || recycleSymbol)
     132           0 :                 return table[--number % tableSize];
     133             :         }
     134           0 :         return inChar;
     135             :     }
     136             :     else
     137           0 :         return NativeNumberSupplier().getNativeNumberChar( inChar, aLocale, nNativeNumberMode );
     138             : }
     139             : 
     140             : } } } }
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10