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

Generated by: LCOV version 1.10