LCOV - code coverage report
Current view: top level - basic/source/comp - basiccharclass.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 78 82 95.1 %
Date: 2014-11-03 Functions: 8 9 88.9 %
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             : #include "basiccharclass.hxx"
      21             : 
      22             : #include <unotools/charclass.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/settings.hxx>
      25             : 
      26          74 : BasicCharClass::BasicCharClass()
      27             : {
      28       19018 :   for( sal_uInt16 i = 0; i < 256; ++i )
      29       18944 :     IsLetterTab[i] = false;
      30             : 
      31          74 :   IsLetterTab[0xC0] = true;   // À , CAPITAL LETTER A WITH GRAVE ACCENT
      32          74 :   IsLetterTab[0xC1] = true;   // Á , CAPITAL LETTER A WITH ACUTE ACCENT
      33          74 :   IsLetterTab[0xC2] = true;   // Â , CAPITAL LETTER A WITH CIRCUMFLEX ACCENT
      34          74 :   IsLetterTab[0xC3] = true;   // Ã , CAPITAL LETTER A WITH TILDE
      35          74 :   IsLetterTab[0xC4] = true;   // Ä , CAPITAL LETTER A WITH DIAERESIS
      36          74 :   IsLetterTab[0xC5] = true;   // Å , CAPITAL LETTER A WITH RING ABOVE
      37          74 :   IsLetterTab[0xC6] = true;   // Æ , CAPITAL LIGATURE AE
      38          74 :   IsLetterTab[0xC7] = true;   // Ç , CAPITAL LETTER C WITH CEDILLA
      39          74 :   IsLetterTab[0xC8] = true;   // È , CAPITAL LETTER E WITH GRAVE ACCENT
      40          74 :   IsLetterTab[0xC9] = true;   // É , CAPITAL LETTER E WITH ACUTE ACCENT
      41          74 :   IsLetterTab[0xCA] = true;   // Ê , CAPITAL LETTER E WITH CIRCUMFLEX ACCENT
      42          74 :   IsLetterTab[0xCB] = true;   // Ë , CAPITAL LETTER E WITH DIAERESIS
      43          74 :   IsLetterTab[0xCC] = true;   // Ì , CAPITAL LETTER I WITH GRAVE ACCENT
      44          74 :   IsLetterTab[0xCD] = true;   // Í , CAPITAL LETTER I WITH ACUTE ACCENT
      45          74 :   IsLetterTab[0xCE] = true;   // Î , CAPITAL LETTER I WITH CIRCUMFLEX ACCENT
      46          74 :   IsLetterTab[0xCF] = true;   // Ï , CAPITAL LETTER I WITH DIAERESIS
      47          74 :   IsLetterTab[0xD0] = true;   // Ð , CAPITAL LETTER ETH
      48          74 :   IsLetterTab[0xD1] = true;   // Ñ , CAPITAL LETTER N WITH TILDE
      49          74 :   IsLetterTab[0xD2] = true;   // Ò , CAPITAL LETTER O WITH GRAVE ACCENT
      50          74 :   IsLetterTab[0xD3] = true;   // Ó , CAPITAL LETTER O WITH ACUTE ACCENT
      51          74 :   IsLetterTab[0xD4] = true;   // Ô , CAPITAL LETTER O WITH CIRCUMFLEX ACCENT
      52          74 :   IsLetterTab[0xD5] = true;   // Õ , CAPITAL LETTER O WITH TILDE
      53          74 :   IsLetterTab[0xD6] = true;   // Ö , CAPITAL LETTER O WITH DIAERESIS
      54          74 :   IsLetterTab[0xD8] = true;   // Ø , CAPITAL LETTER O WITH STROKE
      55          74 :   IsLetterTab[0xD9] = true;   // Ù , CAPITAL LETTER U WITH GRAVE ACCENT
      56          74 :   IsLetterTab[0xDA] = true;   // Ú , CAPITAL LETTER U WITH ACUTE ACCENT
      57          74 :   IsLetterTab[0xDB] = true;   // Û , CAPITAL LETTER U WITH CIRCUMFLEX ACCENT
      58          74 :   IsLetterTab[0xDC] = true;   // Ü , CAPITAL LETTER U WITH DIAERESIS
      59          74 :   IsLetterTab[0xDD] = true;   // Ý , CAPITAL LETTER Y WITH ACUTE ACCENT
      60          74 :   IsLetterTab[0xDE] = true;   // Þ , CAPITAL LETTER THORN
      61          74 :   IsLetterTab[0xDF] = true;   // ß , SMALL LETTER SHARP S
      62          74 :   IsLetterTab[0xE0] = true;   // à , SMALL LETTER A WITH GRAVE ACCENT
      63          74 :   IsLetterTab[0xE1] = true;   // á , SMALL LETTER A WITH ACUTE ACCENT
      64          74 :   IsLetterTab[0xE2] = true;   // â , SMALL LETTER A WITH CIRCUMFLEX ACCENT
      65          74 :   IsLetterTab[0xE3] = true;   // ã , SMALL LETTER A WITH TILDE
      66          74 :   IsLetterTab[0xE4] = true;   // ä , SMALL LETTER A WITH DIAERESIS
      67          74 :   IsLetterTab[0xE5] = true;   // å , SMALL LETTER A WITH RING ABOVE
      68          74 :   IsLetterTab[0xE6] = true;   // æ , SMALL LIGATURE AE
      69          74 :   IsLetterTab[0xE7] = true;   // ç , SMALL LETTER C WITH CEDILLA
      70          74 :   IsLetterTab[0xE8] = true;   // è , SMALL LETTER E WITH GRAVE ACCENT
      71          74 :   IsLetterTab[0xE9] = true;   // é , SMALL LETTER E WITH ACUTE ACCENT
      72          74 :   IsLetterTab[0xEA] = true;   // ê , SMALL LETTER E WITH CIRCUMFLEX ACCENT
      73          74 :   IsLetterTab[0xEB] = true;   // ë , SMALL LETTER E WITH DIAERESIS
      74          74 :   IsLetterTab[0xEC] = true;   // ì , SMALL LETTER I WITH GRAVE ACCENT
      75          74 :   IsLetterTab[0xED] = true;   // í , SMALL LETTER I WITH ACUTE ACCENT
      76          74 :   IsLetterTab[0xEE] = true;   // î , SMALL LETTER I WITH CIRCUMFLEX ACCENT
      77          74 :   IsLetterTab[0xEF] = true;   // ï , SMALL LETTER I WITH DIAERESIS
      78          74 :   IsLetterTab[0xF0] = true;   // ð , SMALL LETTER ETH
      79          74 :   IsLetterTab[0xF1] = true;   // ñ , SMALL LETTER N WITH TILDE
      80          74 :   IsLetterTab[0xF2] = true;   // ò , SMALL LETTER O WITH GRAVE ACCENT
      81          74 :   IsLetterTab[0xF3] = true;   // ó , SMALL LETTER O WITH ACUTE ACCENT
      82          74 :   IsLetterTab[0xF4] = true;   // ô , SMALL LETTER O WITH CIRCUMFLEX ACCENT
      83          74 :   IsLetterTab[0xF5] = true;   // õ , SMALL LETTER O WITH TILDE
      84          74 :   IsLetterTab[0xF6] = true;   // ö , SMALL LETTER O WITH DIAERESIS
      85          74 :   IsLetterTab[0xF8] = true;   // ø , SMALL LETTER O WITH OBLIQUE BAR
      86          74 :   IsLetterTab[0xF9] = true;   // ù , SMALL LETTER U WITH GRAVE ACCENT
      87          74 :   IsLetterTab[0xFA] = true;   // ú , SMALL LETTER U WITH ACUTE ACCENT
      88          74 :   IsLetterTab[0xFB] = true;   // û , SMALL LETTER U WITH CIRCUMFLEX ACCENT
      89          74 :   IsLetterTab[0xFC] = true;   // ü , SMALL LETTER U WITH DIAERESIS
      90          74 :   IsLetterTab[0xFD] = true;   // ý , SMALL LETTER Y WITH ACUTE ACCENT
      91          74 :   IsLetterTab[0xFE] = true;   // þ , SMALL LETTER THORN
      92          74 :   IsLetterTab[0xFF] = true;   // ÿ , SMALL LETTER Y WITH DIAERESIS
      93          74 : }
      94             : 
      95      184310 : bool BasicCharClass::isLetter( sal_Unicode c )
      96             : {
      97      184310 :   return (c < 256 ? IsLetterTab[c] : isLetterUnicode( c ));
      98             : }
      99             : 
     100           0 : bool BasicCharClass::isLetterUnicode( sal_Unicode c )
     101             : {
     102             :   static CharClass* pCharClass = NULL;
     103           0 :   if( pCharClass == NULL )
     104           0 :     pCharClass = new CharClass( Application::GetSettings().GetLanguageTag() );
     105             :   // can we get pCharClass to accept a sal_Unicode instead of this waste?
     106           0 :   return pCharClass->isLetter( OUString(c), 0 );
     107             : }
     108             : 
     109      999696 : bool BasicCharClass::isAlpha( sal_Unicode c, bool bCompatible )
     110             : {
     111      568652 :   return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
     112     1226456 :     || (bCompatible && isLetter( c ));
     113             : }
     114             : 
     115      814670 : bool BasicCharClass::isDigit( sal_Unicode c )
     116             : {
     117      814670 :   return (c >= '0' && c <= '9');
     118             : }
     119             : 
     120      706308 : bool BasicCharClass::isAlphaNumeric( sal_Unicode c, bool bCompatible )
     121             : {
     122      706308 :   return isDigit( c ) || isAlpha( c, bCompatible );
     123             : }
     124             : 
     125      504958 : bool BasicCharClass::isWhitespace( sal_Unicode c )
     126             : {
     127      504958 :   return (c == ' ') || (c == '\t') || (c == '\f');
     128        1203 : }
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10