LCOV - code coverage report
Current view: top level - sal/textenc - tenchelp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-08-25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 2 100.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                 :            : #ifndef INCLUDED_SAL_TEXTENC_TENCHELP_HXX
      30                 :            : #define INCLUDED_SAL_TEXTENC_TENCHELP_HXX
      31                 :            : 
      32                 :            : #include "sal/config.h"
      33                 :            : 
      34                 :            : #include "rtl/tencinfo.h"
      35                 :            : #include "rtl/textcvt.h"
      36                 :            : #include "rtl/textenc.h"
      37                 :            : #include "sal/types.h"
      38                 :            : 
      39                 :            : #include "unichars.hxx"
      40                 :            : 
      41                 :            : #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100
      42                 :            : #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF
      43                 :            : 
      44                 :            : /* ----------------- */
      45                 :            : /* - TextConverter - */
      46                 :            : /* ----------------- */
      47                 :            : 
      48                 :            : typedef
      49                 :            : sal_Size (* ImplConvertToUnicodeProc)(void const * pData,
      50                 :            :                                       void * pContext,
      51                 :            :                                       char const * pSrcBuf,
      52                 :            :                                       sal_Size nSrcBytes,
      53                 :            :                                       sal_Unicode * pDestBuf,
      54                 :            :                                       sal_Size nDestChars,
      55                 :            :                                       sal_uInt32 nFlags,
      56                 :            :                                       sal_uInt32 * pInfo,
      57                 :            :                                       sal_Size * pSrcCvtBytes);
      58                 :            : 
      59                 :            : typedef
      60                 :            : sal_Size (* ImplConvertToTextProc)(void const * pData,
      61                 :            :                                    void * pContext,
      62                 :            :                                    sal_Unicode const * pSrcBuf,
      63                 :            :                                    sal_Size nSrcChars,
      64                 :            :                                    char * pDestBuf,
      65                 :            :                                    sal_Size nDestBytes,
      66                 :            :                                    sal_uInt32 nFlags,
      67                 :            :                                    sal_uInt32 * pInfo,
      68                 :            :                                    sal_Size * pSrcCvtChars);
      69                 :            : 
      70                 :            : typedef void * (* ImplCreateTextContextProc)();
      71                 :            : 
      72                 :            : typedef void (* ImplDestroyTextContextProc)(void * pContext);
      73                 :            : 
      74                 :            : typedef void (* ImplResetTextContextProc)(void * pContext);
      75                 :            : 
      76                 :            : typedef void * (* ImplCreateUnicodeContextProc)();
      77                 :            : 
      78                 :            : typedef void (* ImplDestroyUnicodeContextProc)(void * pContext);
      79                 :            : 
      80                 :            : typedef void (* ImplResetUnicodeContextProc)(void * pContext);
      81                 :            : 
      82                 :            : struct ImplTextConverter
      83                 :            : {
      84                 :            :     void const * mpConvertData;
      85                 :            :     ImplConvertToUnicodeProc mpConvertTextToUnicodeProc;
      86                 :            :     ImplConvertToTextProc mpConvertUnicodeToTextProc;
      87                 :            :     ImplCreateTextContextProc mpCreateTextToUnicodeContext;
      88                 :            :     ImplDestroyTextContextProc mpDestroyTextToUnicodeContext;
      89                 :            :     ImplResetTextContextProc mpResetTextToUnicodeContext;
      90                 :            :     ImplCreateUnicodeContextProc mpCreateUnicodeToTextContext;
      91                 :            :     ImplDestroyUnicodeContextProc mpDestroyUnicodeToTextContext;
      92                 :            :     ImplResetUnicodeContextProc mpResetUnicodeToTextContext;
      93                 :            : };
      94                 :            : 
      95                 :            : /* ----------------------------- */
      96                 :            : /* - TextEncoding - Structures - */
      97                 :            : /* ----------------------------- */
      98                 :            : 
      99                 :            : struct ImplTextEncodingData
     100                 :            : {
     101                 :            :     ImplTextConverter maConverter;
     102                 :            :     sal_uInt8 mnMinCharSize;
     103                 :            :     sal_uInt8 mnMaxCharSize;
     104                 :            :     sal_uInt8 mnAveCharSize;
     105                 :            :     sal_uInt8 mnBestWindowsCharset;
     106                 :            :     char const * mpBestUnixCharset;
     107                 :            :     char const * mpBestMimeCharset;
     108                 :            :     sal_uInt32 mnInfoFlags;
     109                 :            : };
     110                 :            : 
     111                 :            : /* ----------------------------------- */
     112                 :            : /* - TextConverter - Byte-Structures - */
     113                 :            : /* ----------------------------------- */
     114                 :            : 
     115                 :            : struct ImplUniCharTabData
     116                 :            : {
     117                 :            :     sal_uInt16                      mnUniChar;
     118                 :            :     sal_uChar                       mnChar;
     119                 :            :     sal_uChar                       mnChar2;
     120                 :            :         // to cater for mappings like MS1258 with 1--2 bytes per Unicode char,
     121                 :            :         // 0 if unused
     122                 :            : };
     123                 :            : 
     124                 :            : struct ImplByteConvertData
     125                 :            : {
     126                 :            :     const sal_uInt16*               mpToUniTab1;
     127                 :            :     const sal_uInt16*               mpToUniTab2;
     128                 :            :     sal_uChar                       mnToUniStart1;
     129                 :            :     sal_uChar                       mnToUniEnd1;
     130                 :            :     sal_uChar                       mnToUniStart2;
     131                 :            :     sal_uChar                       mnToUniEnd2;
     132                 :            :     const sal_uChar*                mpToCharTab1;
     133                 :            :     const sal_uChar*                mpToCharTab2;
     134                 :            :     const ImplUniCharTabData*       mpToCharExTab;
     135                 :            :     sal_uInt16                      mnToCharStart1;
     136                 :            :     sal_uInt16                      mnToCharEnd1;
     137                 :            :     sal_uInt16                      mnToCharStart2;
     138                 :            :     sal_uInt16                      mnToCharEnd2;
     139                 :            :     sal_uInt16                      mnToCharExCount;
     140                 :            : };
     141                 :            : 
     142                 :            : /* ----------------------------------- */
     143                 :            : /* - TextConverter - DBCS-Structures - */
     144                 :            : /* ----------------------------------- */
     145                 :            : 
     146                 :            : struct ImplDBCSEUDCData
     147                 :            : {
     148                 :            :     sal_uChar                       mnLeadStart;
     149                 :            :     sal_uChar                       mnLeadEnd;
     150                 :            :     sal_uChar                       mnTrail1Start;
     151                 :            :     sal_uChar                       mnTrail1End;
     152                 :            :     sal_uChar                       mnTrail2Start;
     153                 :            :     sal_uChar                       mnTrail2End;
     154                 :            :     sal_uChar                       mnTrail3Start;
     155                 :            :     sal_uChar                       mnTrail3End;
     156                 :            :     sal_uChar                       mnTrailCount;
     157                 :            :     sal_uInt16                      mnTrailRangeCount;
     158                 :            :     sal_uInt16                      mnUniStart;
     159                 :            :     sal_uInt16                      mnUniEnd;
     160                 :            : };
     161                 :            : 
     162                 :            : struct ImplDBCSToUniLeadTab
     163                 :            : {
     164                 :            :     sal_uInt16                      mnUniChar;
     165                 :            :     sal_uInt8                       mnTrailStart;
     166                 :            :     sal_uInt8                       mnTrailEnd;
     167                 :            :     const sal_uInt16*               mpToUniTrailTab;
     168                 :            : };
     169                 :            : 
     170                 :            : struct ImplUniToDBCSHighTab
     171                 :            : {
     172                 :            :     sal_uInt8                       mnLowStart;
     173                 :            :     sal_uInt8                       mnLowEnd;
     174                 :            :     const sal_uInt16*               mpToUniTrailTab;
     175                 :            : };
     176                 :            : 
     177                 :            : struct ImplDBCSConvertData
     178                 :            : {
     179                 :            :     const ImplDBCSToUniLeadTab*     mpToUniLeadTab;
     180                 :            :     const ImplUniToDBCSHighTab*     mpToDBCSHighTab;
     181                 :            :     sal_uChar                       mnLeadStart;
     182                 :            :     sal_uChar                       mnLeadEnd;
     183                 :            :     sal_uChar                       mnTrailStart;
     184                 :            :     sal_uChar                       mnTrailEnd;
     185                 :            :     const ImplDBCSEUDCData*         mpEUDCTab;
     186                 :            :     sal_uInt16                      mnEUDCCount;
     187                 :            : };
     188                 :            : 
     189                 :            : /* ---------------------------------- */
     190                 :            : /* - TextConverter - EUC-Structures - */
     191                 :            : /* ---------------------------------- */
     192                 :            : 
     193                 :            : struct ImplEUCJPConvertData
     194                 :            : {
     195                 :            :     const ImplDBCSToUniLeadTab*     mpJIS0208ToUniLeadTab;
     196                 :            :     const ImplDBCSToUniLeadTab*     mpJIS0212ToUniLeadTab;
     197                 :            :     const ImplUniToDBCSHighTab*     mpUniToJIS0208HighTab;
     198                 :            :     const ImplUniToDBCSHighTab*     mpUniToJIS0212HighTab;
     199                 :            : };
     200                 :            : 
     201                 :            : /* --------------------------------- */
     202                 :            : /* - TextConverter - HelpFunctions - */
     203                 :            : /* --------------------------------- */
     204                 :            : 
     205                 :        970 : inline sal_Unicode ImplGetUndefinedUnicodeChar(
     206                 :            :     sal_uChar cChar, sal_uInt32 nFlags)
     207                 :            : {
     208                 :            :     return ((nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK)
     209                 :            :                    == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE) ?
     210                 :            :                RTL_TEXTCVT_BYTE_PRIVATE_START + cChar :
     211         [ +  + ]:        970 :                RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
     212                 :            : }
     213                 :            : 
     214                 :            : /* ----------------------------- */
     215                 :            : /* - TextConverter - Functions - */
     216                 :            : /* ----------------------------- */
     217                 :            : 
     218                 :            : sal_Size ImplDBCSToUnicode( const void* pData, void* pContext,
     219                 :            :                             const char* pSrcBuf, sal_Size nSrcBytes,
     220                 :            :                             sal_Unicode* pDestBuf, sal_Size nDestChars,
     221                 :            :                             sal_uInt32 nFlags, sal_uInt32* pInfo,
     222                 :            :                             sal_Size* pSrcCvtBytes );
     223                 :            : sal_Size ImplUnicodeToDBCS( const void* pData, void* pContext,
     224                 :            :                             const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
     225                 :            :                             char* pDestBuf, sal_Size nDestBytes,
     226                 :            :                             sal_uInt32 nFlags, sal_uInt32* pInfo,
     227                 :            :                             sal_Size* pSrcCvtChars );
     228                 :            : sal_Size ImplEUCJPToUnicode( const void* pData,
     229                 :            :                              void* pContext,
     230                 :            :                              const char* pSrcBuf, sal_Size nSrcBytes,
     231                 :            :                              sal_Unicode* pDestBuf, sal_Size nDestChars,
     232                 :            :                              sal_uInt32 nFlags, sal_uInt32* pInfo,
     233                 :            :                              sal_Size* pSrcCvtBytes );
     234                 :            : sal_Size ImplUnicodeToEUCJP( const void* pData,
     235                 :            :                              void* pContext,
     236                 :            :                              const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
     237                 :            :                              char* pDestBuf, sal_Size nDestBytes,
     238                 :            :                              sal_uInt32 nFlags, sal_uInt32* pInfo,
     239                 :            :                              sal_Size* pSrcCvtChars );
     240                 :            : void* ImplUTF7CreateUTF7TextToUnicodeContext();
     241                 :            : void ImplUTF7DestroyTextToUnicodeContext( void* pContext );
     242                 :            : void ImplUTF7ResetTextToUnicodeContext( void* pContext );
     243                 :            : sal_Size ImplUTF7ToUnicode( const void* pData, void* pContext,
     244                 :            :                             const char* pSrcBuf, sal_Size nSrcBytes,
     245                 :            :                             sal_Unicode* pDestBuf, sal_Size nDestChars,
     246                 :            :                             sal_uInt32 nFlags, sal_uInt32* pInfo,
     247                 :            :                             sal_Size* pSrcCvtBytes );
     248                 :            : void* ImplUTF7CreateUnicodeToTextContext();
     249                 :            : void ImplUTF7DestroyUnicodeToTextContext( void* pContext );
     250                 :            : void ImplUTF7ResetUnicodeToTextContext( void* pContext );
     251                 :            : sal_Size ImplUnicodeToUTF7( const void* pData, void* pContext,
     252                 :            :                             const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
     253                 :            :                             char* pDestBuf, sal_Size nDestBytes,
     254                 :            :                             sal_uInt32 nFlags, sal_uInt32* pInfo,
     255                 :            :                             sal_Size* pSrcCvtChars );
     256                 :            : 
     257                 :            : #endif
     258                 :            : 
     259                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10