LCOV - code coverage report
Current view: top level - sal/textenc - tcvtbyte.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 58 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 24 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "sal/config.h"
      30                 :            : 
      31                 :            : #include "rtl/textcvt.h"
      32                 :            : 
      33                 :            : #include "handleundefinedunicodetotextchar.hxx"
      34                 :            : #include "tcvtbyte.hxx"
      35                 :            : #include "tenchelp.hxx"
      36                 :            : 
      37                 :          0 : sal_Size ImplSymbolToUnicode( SAL_UNUSED_PARAMETER const void*,
      38                 :            :                               SAL_UNUSED_PARAMETER void*,
      39                 :            :                               const char* pSrcBuf, sal_Size nSrcBytes,
      40                 :            :                               sal_Unicode* pDestBuf, sal_Size nDestChars,
      41                 :            :                               SAL_UNUSED_PARAMETER sal_uInt32,
      42                 :            :                               sal_uInt32* pInfo, sal_Size* pSrcCvtBytes )
      43                 :            : {
      44                 :            :     sal_uChar               c;
      45                 :            :     sal_Unicode*            pEndDestBuf;
      46                 :            :     const char*         pEndSrcBuf;
      47                 :            : 
      48                 :          0 :     *pInfo = 0;
      49                 :          0 :     pEndDestBuf = pDestBuf+nDestChars;
      50                 :          0 :     pEndSrcBuf  = pSrcBuf+nSrcBytes;
      51         [ #  # ]:          0 :     while ( pSrcBuf < pEndSrcBuf )
      52                 :            :     {
      53         [ #  # ]:          0 :         if ( pDestBuf == pEndDestBuf )
      54                 :            :         {
      55                 :          0 :             *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL;
      56                 :          0 :             break;
      57                 :            :         }
      58                 :            : 
      59                 :            :         /* 0-31 (all Control-Character get the same Unicode value) */
      60                 :          0 :         c = (sal_uChar)*pSrcBuf;
      61         [ #  # ]:          0 :         if ( c <= 0x1F )
      62                 :          0 :             *pDestBuf = (sal_Unicode)c;
      63                 :            :         else
      64                 :          0 :             *pDestBuf = ((sal_Unicode)c)+0xF000;
      65                 :          0 :         pDestBuf++;
      66                 :          0 :         pSrcBuf++;
      67                 :            :     }
      68                 :            : 
      69                 :          0 :     *pSrcCvtBytes = nSrcBytes - (pEndSrcBuf-pSrcBuf);
      70                 :          0 :     return (nDestChars - (pEndDestBuf-pDestBuf));
      71                 :            : }
      72                 :            : 
      73                 :          0 : sal_Size ImplUnicodeToSymbol( SAL_UNUSED_PARAMETER const void*,
      74                 :            :                               SAL_UNUSED_PARAMETER void*,
      75                 :            :                               const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
      76                 :            :                               char* pDestBuf, sal_Size nDestBytes,
      77                 :            :                               sal_uInt32 nFlags, sal_uInt32* pInfo,
      78                 :            :                               sal_Size* pSrcCvtChars )
      79                 :            : {
      80                 :            :     sal_Unicode             c;
      81                 :            :     char*               pEndDestBuf;
      82                 :            :     const sal_Unicode*      pEndSrcBuf;
      83                 :            : 
      84                 :          0 :     *pInfo = 0;
      85                 :          0 :     pEndDestBuf = pDestBuf+nDestBytes;
      86                 :          0 :     pEndSrcBuf  = pSrcBuf+nSrcChars;
      87         [ #  # ]:          0 :     while ( pSrcBuf < pEndSrcBuf )
      88                 :            :     {
      89         [ #  # ]:          0 :         if ( pDestBuf == pEndDestBuf )
      90                 :            :         {
      91                 :          0 :             *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL;
      92                 :          0 :             break;
      93                 :            :         }
      94                 :            : 
      95                 :          0 :         c = *pSrcBuf;
      96 [ #  # ][ #  # ]:          0 :         if ( (c >= 0xF000) && (c <= 0xF0FF) )
      97                 :            :         {
      98                 :          0 :             *pDestBuf = static_cast< char >(static_cast< unsigned char >(c-0xF000));
      99                 :          0 :             pDestBuf++;
     100                 :          0 :             pSrcBuf++;
     101                 :            :         }
     102                 :            :         // Normally 0x001F, but in many cases also symbol characters
     103                 :            :         // are stored in the first 256 bytes, so that we don't change
     104                 :            :         // these values
     105         [ #  # ]:          0 :         else if ( c <= 0x00FF )
     106                 :            :         {
     107                 :          0 :             *pDestBuf = static_cast< char >(static_cast< unsigned char >(c));
     108                 :          0 :             pDestBuf++;
     109                 :          0 :             pSrcBuf++;
     110                 :            :         }
     111                 :            :         else
     112                 :            :         {
     113                 :          0 :             if ( nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE )
     114                 :            :             {
     115                 :            :                 /* !!! */
     116                 :            :                 /* Only ascii  characters < 0x1F */
     117                 :            :             }
     118                 :            : 
     119                 :            :             /* Handle undefined and surrogates characters */
     120                 :            :             /* (all surrogates characters are undefined) */
     121         [ #  # ]:          0 :             if (!sal::detail::textenc::handleUndefinedUnicodeToTextChar(
     122                 :            :                     &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf, nFlags,
     123                 :          0 :                     pInfo))
     124                 :          0 :                 break;
     125                 :            :         }
     126                 :            :     }
     127                 :            : 
     128                 :          0 :     *pSrcCvtChars = nSrcChars - (pEndSrcBuf-pSrcBuf);
     129                 :          0 :     return (nDestBytes - (pEndDestBuf-pDestBuf));
     130                 :            : }
     131                 :            : 
     132                 :          0 : sal_Size ImplUpperCharToUnicode( const void* pData,
     133                 :            :                             SAL_UNUSED_PARAMETER void*,
     134                 :            :                             const char* pSrcBuf, sal_Size nSrcBytes,
     135                 :            :                             sal_Unicode* pDestBuf, sal_Size nDestChars,
     136                 :            :                             SAL_UNUSED_PARAMETER sal_uInt32, sal_uInt32* pInfo,
     137                 :            :                             sal_Size* pSrcCvtBytes )
     138                 :            : {
     139                 :            :     sal_uChar                   c;
     140                 :            :     sal_Unicode                 cConv;
     141                 :          0 :     const ImplByteConvertData*  pConvertData = (const ImplByteConvertData*)pData;
     142                 :            :     sal_Unicode*                pEndDestBuf;
     143                 :            :     const char*             pEndSrcBuf;
     144                 :            : 
     145                 :          0 :     *pInfo = 0;
     146                 :          0 :     pEndDestBuf = pDestBuf+nDestChars;
     147                 :          0 :     pEndSrcBuf  = pSrcBuf+nSrcBytes;
     148         [ #  # ]:          0 :     if ( pDestBuf == pEndDestBuf )
     149                 :            :     {
     150                 :          0 :         *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL;
     151                 :          0 :         *pSrcCvtBytes = 0;
     152                 :          0 :         return 0;
     153                 :            :     }
     154         [ #  # ]:          0 :     while ( pSrcBuf < pEndSrcBuf )
     155                 :            :     {
     156                 :          0 :         c = (sal_uChar)*pSrcBuf;
     157         [ #  # ]:          0 :         if (c < 0x80)
     158                 :          0 :             cConv = c;
     159                 :            :         else
     160                 :            :             // c <= 0xFF is implied.
     161                 :          0 :             cConv = pConvertData->mpToUniTab1[c - 0x80];
     162                 :            : 
     163                 :          0 :         *pDestBuf = cConv;
     164                 :          0 :         pDestBuf++;
     165                 :          0 :         pSrcBuf++;
     166                 :            :     }
     167                 :            : 
     168                 :          0 :     *pSrcCvtBytes = nSrcBytes - (pEndSrcBuf-pSrcBuf);
     169                 :          0 :     return (nDestChars - (pEndDestBuf-pDestBuf));
     170                 :            : }
     171                 :            : 
     172                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10