LCOV - code coverage report
Current view: top level - sal/textenc - textenc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 19 84.2 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 16 68.8 %

           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                 :            : /* TODO! This file should not be called textenc.c, because it is not the
      30                 :            :    implementation of rtl/textenc.h.  Rather, it should be called
      31                 :            :    gettextencodingdata.c. */
      32                 :            : 
      33                 :            : #include "sal/config.h"
      34                 :            : 
      35                 :            : #include <cstddef>
      36                 :            : #include <cstdlib>
      37                 :            : 
      38                 :            : #include "boost/noncopyable.hpp"
      39                 :            : #include "osl/diagnose.h"
      40                 :            : #include "osl/module.hxx"
      41                 :            : #include "rtl/instance.hxx"
      42                 :            : #include "rtl/textenc.h"
      43                 :            : #include "rtl/ustring.h"
      44                 :            : #include "rtl/ustring.hxx"
      45                 :            : #include "sal/macros.h"
      46                 :            : #include "sal/types.h"
      47                 :            : 
      48                 :            : #include "convertsimple.hxx"
      49                 :            : #include "gettextencodingdata.hxx"
      50                 :            : #include "tcvtbyte.hxx"
      51                 :            : #include "tcvtutf8.hxx"
      52                 :            : #include "tenchelp.hxx"
      53                 :            : 
      54                 :            : #define NOTABUNI_START 0xFF
      55                 :            : #define NOTABUNI_END 0x00
      56                 :            : 
      57                 :            : #define NOTABCHAR_START 0xFFFF
      58                 :            : #define NOTABCHAR_END 0x0000
      59                 :            : 
      60                 :            : #define SAME8090UNI_START 0x80
      61                 :            : #define SAME8090UNI_END 0x9F
      62                 :            : static sal_uInt16 const aImpl8090SameToUniTab[SAME8090UNI_END
      63                 :            :                                                   - SAME8090UNI_START
      64                 :            :                                                   + 1]
      65                 :            : = { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, /* 0x80 */
      66                 :            :     0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
      67                 :            :     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, /* 0x90 */
      68                 :            :     0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F };
      69                 :            : 
      70                 :            : #define SAME8090CHAR_START 0x0080
      71                 :            : #define SAME8090CHAR_END 0x009F
      72                 :            : static sal_uChar const aImpl8090SameToCharTab[SAME8090CHAR_END
      73                 :            :                                                   - SAME8090CHAR_START
      74                 :            :                                                   + 1]
      75                 :            :     = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x0080 */
      76                 :            :         0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
      77                 :            :         0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x0090 */
      78                 :            :         0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F };
      79                 :            : 
      80                 :            : #define SAMEA0FFCHAR_START 0x00A0
      81                 :            : #define SAMEA0FFCHAR_END 0x00FF
      82                 :            : static sal_uChar const aImplA0FFSameToCharTab[SAMEA0FFCHAR_END
      83                 :            :                                                   - SAMEA0FFCHAR_START
      84                 :            :                                                   + 1]
      85                 :            :     = { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, /* 0x00A0 */
      86                 :            :         0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
      87                 :            :         0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, /* 0x00B0 */
      88                 :            :         0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
      89                 :            :         0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 0x00C0 */
      90                 :            :         0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
      91                 :            :         0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, /* 0x00D0 */
      92                 :            :         0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
      93                 :            :         0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, /* 0x00E0 */
      94                 :            :         0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
      95                 :            :         0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 0x00F0 */
      96                 :            :         0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF };
      97                 :            : 
      98                 :            : static sal_uInt16 const aImplDoubleByteIdentifierTab[1] = { 0 };
      99                 :            : 
     100                 :            : /* ======================================================================= */
     101                 :            : 
     102                 :            : /* MS-1252 */
     103                 :            : /* Windows Standard CharSet (ANSI) for Western Script */
     104                 :            : /* 1-Byte, 0x00-0x7F ASCII ohne Ausnahme */
     105                 :            : /* Convert-Tables: mappings/vendors/micsft/windows/cp1252.txt from 04/15/98 Version 2.01 */
     106                 :            : /* Last-Changes from us: */
     107                 :            : 
     108                 :            : /* ----------------------------------------------------------------------- */
     109                 :            : 
     110                 :            : #define MS1252UNI_START                 0x80
     111                 :            : #define MS1252UNI_END                   0xFF
     112                 :            : static sal_uInt16 const aImplMS1252ToUniTab[MS1252UNI_END - MS1252UNI_START + 1] =
     113                 :            : {
     114                 :            : /*       0       1       2       3       4       5       6       7 */
     115                 :            : /*       8       9       A       B       C       D       E       F */
     116                 :            :     0x20AC,      0, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, /* 0x80 */
     117                 :            :     0x02C6, 0x2030, 0x0160, 0x2039, 0x0152,      0, 0x017D,      0, /* 0x80 */
     118                 :            :          0, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, /* 0x90 */
     119                 :            :     0x02DC, 0x2122, 0x0161, 0x203A, 0x0153,      0, 0x017E, 0x0178, /* 0x90 */
     120                 :            :     0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, /* 0xA0 */
     121                 :            :     0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, /* 0xA0 */
     122                 :            :     0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, /* 0xB0 */
     123                 :            :     0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, /* 0xB0 */
     124                 :            :     0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, /* 0xC0 */
     125                 :            :     0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, /* 0xC0 */
     126                 :            :     0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, /* 0xD0 */
     127                 :            :     0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, /* 0xD0 */
     128                 :            :     0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, /* 0xE0 */
     129                 :            :     0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, /* 0xE0 */
     130                 :            :     0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, /* 0xF0 */
     131                 :            :     0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF  /* 0xF0 */
     132                 :            : };
     133                 :            : 
     134                 :            : /* ----------------------------------------------------------------------- */
     135                 :            : 
     136                 :            : #define MS1252TOCHARTABEX_COUNT         27
     137                 :            : static ImplUniCharTabData const aImplMS1252ToCharTabEx[MS1252TOCHARTABEX_COUNT] =
     138                 :            : {
     139                 :            :   { 0x0152, 0x8C, 0 },
     140                 :            :   { 0x0153, 0x9C, 0 },
     141                 :            :   { 0x0160, 0x8A, 0 },
     142                 :            :   { 0x0161, 0x9A, 0 },
     143                 :            :   { 0x0178, 0x9F, 0 },
     144                 :            :   { 0x017D, 0x8E, 0 },
     145                 :            :   { 0x017E, 0x9E, 0 },
     146                 :            :   { 0x0192, 0x83, 0 },
     147                 :            :   { 0x02C6, 0x88, 0 },
     148                 :            :   { 0x02DC, 0x98, 0 },
     149                 :            :   { 0x2013, 0x96, 0 },
     150                 :            :   { 0x2014, 0x97, 0 },
     151                 :            :   { 0x2018, 0x91, 0 },
     152                 :            :   { 0x2019, 0x92, 0 },
     153                 :            :   { 0x201A, 0x82, 0 },
     154                 :            :   { 0x201C, 0x93, 0 },
     155                 :            :   { 0x201D, 0x94, 0 },
     156                 :            :   { 0x201E, 0x84, 0 },
     157                 :            :   { 0x2020, 0x86, 0 },
     158                 :            :   { 0x2021, 0x87, 0 },
     159                 :            :   { 0x2022, 0x95, 0 },
     160                 :            :   { 0x2026, 0x85, 0 },
     161                 :            :   { 0x2030, 0x89, 0 },
     162                 :            :   { 0x2039, 0x8B, 0 },
     163                 :            :   { 0x203A, 0x9B, 0 },
     164                 :            :   { 0x20AC, 0x80, 0 },
     165                 :            :   { 0x2122, 0x99, 0 },
     166                 :            : };
     167                 :            : 
     168                 :            : /* ----------------------------------------------------------------------- */
     169                 :            : 
     170                 :            : static ImplByteConvertData const aImplMS1252ByteCvtData =
     171                 :            : {
     172                 :            :     aImplMS1252ToUniTab,
     173                 :            :     NULL,
     174                 :            :     MS1252UNI_START, MS1252UNI_END,
     175                 :            :     NOTABUNI_START, NOTABUNI_END,
     176                 :            :     aImplA0FFSameToCharTab,
     177                 :            :     NULL,
     178                 :            :     aImplMS1252ToCharTabEx,
     179                 :            :     SAMEA0FFCHAR_START, SAMEA0FFCHAR_END,
     180                 :            :     NOTABCHAR_START, NOTABCHAR_END,
     181                 :            :     MS1252TOCHARTABEX_COUNT
     182                 :            : };
     183                 :            : 
     184                 :            : /* ----------------------------------------------------------------------- */
     185                 :            : 
     186                 :            : static ImplTextEncodingData const aImplMS1252TextEncodingData
     187                 :            :     = { { &aImplMS1252ByteCvtData,
     188                 :            :           sal::detail::textenc::convertCharToUnicode,
     189                 :            :           sal::detail::textenc::convertUnicodeToChar,
     190                 :            :           NULL,
     191                 :            :           NULL,
     192                 :            :           NULL,
     193                 :            :           NULL,
     194                 :            :           NULL,
     195                 :            :           NULL },
     196                 :            :         1,
     197                 :            :         1,
     198                 :            :         1,
     199                 :            :         0,
     200                 :            :         "iso8859-1",
     201                 :            :         "windows-1252",
     202                 :            :         RTL_TEXTENCODING_INFO_ASCII | RTL_TEXTENCODING_INFO_MIME };
     203                 :            :     /* WIN, SCRIPT_LATIN, pc code page 850 */
     204                 :            : 
     205                 :            : /* ======================================================================= */
     206                 :            : 
     207                 :            : /* ISO-8859-1 */
     208                 :            : /* Unix Standard CharSet (Latin1) for Western Script */
     209                 :            : /* 1-Byte, 0x00-0x7F ASCII ohne Ausnahme, 0x80-0x9F Control-Caracter wie in Unicode */
     210                 :            : /* Convert-Tables: mappings/iso8859/8859-1.txt from 07/27/99 Version 1.0 (based on Unicode 3.0) */
     211                 :            : /* Last-Changes from us: */
     212                 :            : 
     213                 :            : #define ISO88591UNI_START               0xA0
     214                 :            : #define ISO88591UNI_END                 0xFF
     215                 :            : static sal_uInt16 const aImplISO88591ToUniTab[ISO88591UNI_END - ISO88591UNI_START + 1] =
     216                 :            : {
     217                 :            : /*       0       1       2       3       4       5       6       7 */
     218                 :            : /*       8       9       A       B       C       D       E       F */
     219                 :            :     0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, /* 0xA0 */
     220                 :            :     0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, /* 0xA0 */
     221                 :            :     0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, /* 0xB0 */
     222                 :            :     0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, /* 0xB0 */
     223                 :            :     0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, /* 0xC0 */
     224                 :            :     0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, /* 0xC0 */
     225                 :            :     0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, /* 0xD0 */
     226                 :            :     0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, /* 0xD0 */
     227                 :            :     0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, /* 0xE0 */
     228                 :            :     0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, /* 0xE0 */
     229                 :            :     0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, /* 0xF0 */
     230                 :            :     0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF  /* 0xF0 */
     231                 :            : };
     232                 :            : 
     233                 :            : /* ----------------------------------------------------------------------- */
     234                 :            : 
     235                 :            : static ImplByteConvertData const aImplISO88591ByteCvtData =
     236                 :            : {
     237                 :            :     aImplISO88591ToUniTab,
     238                 :            :     aImpl8090SameToUniTab,
     239                 :            :     ISO88591UNI_START, ISO88591UNI_END,
     240                 :            :     SAME8090UNI_START, SAME8090UNI_END,
     241                 :            :     aImplA0FFSameToCharTab,
     242                 :            :     aImpl8090SameToCharTab,
     243                 :            :     NULL,
     244                 :            :     SAMEA0FFCHAR_START, SAMEA0FFCHAR_END,
     245                 :            :     SAME8090CHAR_START, SAME8090CHAR_END,
     246                 :            :     0
     247                 :            : };
     248                 :            : 
     249                 :            : /* ----------------------------------------------------------------------- */
     250                 :            : 
     251                 :            : static ImplTextEncodingData const aImplISO88591TextEncodingData
     252                 :            :     = { { &aImplISO88591ByteCvtData,
     253                 :            :           sal::detail::textenc::convertCharToUnicode,
     254                 :            :           sal::detail::textenc::convertUnicodeToChar,
     255                 :            :           NULL,
     256                 :            :           NULL,
     257                 :            :           NULL,
     258                 :            :           NULL,
     259                 :            :           NULL,
     260                 :            :           NULL },
     261                 :            :         1,
     262                 :            :         1,
     263                 :            :         1,
     264                 :            :         0,
     265                 :            :         "iso8859-1",
     266                 :            :         "iso-8859-1",
     267                 :            :         RTL_TEXTENCODING_INFO_ASCII | RTL_TEXTENCODING_INFO_MIME };
     268                 :            :     /* SCRIPT_LATIN, pc code page 850 */
     269                 :            : 
     270                 :            : /* ======================================================================= */
     271                 :            : 
     272                 :            : /* US-ASCII */
     273                 :            : /* 7-Bit ASCII */
     274                 :            : /* 1-Byte, 0x00-0x7F ASCII ohne Ausnahme */
     275                 :            : /* For the import we use ISO-8859-1 with MS extension (MS-1252), because */
     276                 :            : /* when the 8-Bit is set, the chance, that this is a ISO-8859-1 character */
     277                 :            : /* is the greatest. For the export all chars greater than 127 are not */
     278                 :            : /* converted and are replaced by the replacement character. */
     279                 :            : /* Last-Changes from us: */
     280                 :            : 
     281                 :            : /* ----------------------------------------------------------------------- */
     282                 :            : 
     283                 :            : static ImplByteConvertData const aImplUSASCIIByteCvtData =
     284                 :            : {
     285                 :            :     aImplMS1252ToUniTab,
     286                 :            :     NULL,
     287                 :            :     MS1252UNI_START, MS1252UNI_END,
     288                 :            :     NOTABUNI_START, NOTABUNI_END,
     289                 :            :     NULL,
     290                 :            :     NULL,
     291                 :            :     NULL,
     292                 :            :     NOTABCHAR_START, NOTABCHAR_END,
     293                 :            :     NOTABCHAR_START, NOTABCHAR_END,
     294                 :            :     0
     295                 :            : };
     296                 :            : 
     297                 :            : /* ----------------------------------------------------------------------- */
     298                 :            : 
     299                 :            : static ImplTextEncodingData const aImplUSASCIITextEncodingData
     300                 :            :     = { { &aImplUSASCIIByteCvtData,
     301                 :            :           sal::detail::textenc::convertCharToUnicode,
     302                 :            :           sal::detail::textenc::convertUnicodeToChar,
     303                 :            :           NULL,
     304                 :            :           NULL,
     305                 :            :           NULL,
     306                 :            :           NULL,
     307                 :            :           NULL,
     308                 :            :           NULL },
     309                 :            :         1,
     310                 :            :         1,
     311                 :            :         1,
     312                 :            :         0,
     313                 :            :         "iso8859-1",
     314                 :            :         "us-ascii",
     315                 :            :         RTL_TEXTENCODING_INFO_ASCII
     316                 :            :             | RTL_TEXTENCODING_INFO_7BIT
     317                 :            :             | RTL_TEXTENCODING_INFO_MIME };
     318                 :            :     /* SCRIPT_LATIN, pc code page 437 */
     319                 :            : 
     320                 :            : static ImplTextEncodingData const aImplUTF8TextEncodingData
     321                 :            :     = { { NULL,
     322                 :            :           &ImplConvertUtf8ToUnicode,
     323                 :            :           &ImplConvertUnicodeToUtf8,
     324                 :            :           &ImplCreateUtf8ToUnicodeContext,
     325                 :            :           &ImplDestroyUtf8ToUnicodeContext,
     326                 :            :           &ImplResetUtf8ToUnicodeContext,
     327                 :            :           &ImplCreateUnicodeToUtf8Context,
     328                 :            :           &ImplDestroyUnicodeToUtf8Context,
     329                 :            :           &ImplResetUnicodeToUtf8Context },
     330                 :            :         1,
     331                 :            :         6,
     332                 :            :         1,
     333                 :            :         0,
     334                 :            :         "iso8859-1",
     335                 :            :         "utf-8",
     336                 :            :         RTL_TEXTENCODING_INFO_ASCII
     337                 :            :             | RTL_TEXTENCODING_INFO_UNICODE
     338                 :            :             | RTL_TEXTENCODING_INFO_MULTIBYTE
     339                 :            :             | RTL_TEXTENCODING_INFO_MIME };
     340                 :            :     /* SCRIPT_UNICODE, pc code page 850 */
     341                 :            : 
     342                 :            : static char aImplJavaUtf8TextConverterTag;
     343                 :            :     /* The value of this tag is irrelevant.  Only its address != NULL is used to
     344                 :            :        distinguish between RTL_TEXTENCODING_UTF8 and
     345                 :            :        RTL_TEXTENCODING_JAVA_UTF8. */
     346                 :            : 
     347                 :            : static ImplTextEncodingData const aImplJavaUtf8TextEncodingData
     348                 :            :     = { { &aImplJavaUtf8TextConverterTag,
     349                 :            :           &ImplConvertUtf8ToUnicode,
     350                 :            :           &ImplConvertUnicodeToUtf8,
     351                 :            :           &ImplCreateUtf8ToUnicodeContext,
     352                 :            :           &ImplDestroyUtf8ToUnicodeContext,
     353                 :            :           &ImplResetUtf8ToUnicodeContext,
     354                 :            :           &ImplCreateUnicodeToUtf8Context,
     355                 :            :           &ImplDestroyUnicodeToUtf8Context,
     356                 :            :           &ImplResetUnicodeToUtf8Context },
     357                 :            :         1,
     358                 :            :         3,
     359                 :            :         1,
     360                 :            :         0,
     361                 :            :         NULL,
     362                 :            :         NULL,
     363                 :            :         RTL_TEXTENCODING_INFO_UNICODE | RTL_TEXTENCODING_INFO_MULTIBYTE };
     364                 :            : 
     365                 :            : namespace {
     366                 :            : 
     367                 :            : #if defined DISABLE_DYNLOADING || defined ANDROID
     368                 :            : 
     369                 :            : extern "C" ImplTextEncodingData const * sal_getFullTextEncodingData(
     370                 :            :     rtl_TextEncoding); // from tables.cxx in sal_textenc library
     371                 :            : 
     372                 :            : class FullTextEncodingData: private boost::noncopyable {
     373                 :            : public:
     374                 :            :     ImplTextEncodingData const * get(rtl_TextEncoding encoding) {
     375                 :            :         return sal_getFullTextEncodingData(encoding);
     376                 :            :     }
     377                 :            : };
     378                 :            : 
     379                 :            : #else
     380                 :            : 
     381                 :            : extern "C" {
     382                 :            : 
     383                 :            : typedef ImplTextEncodingData const * TextEncodingFunction(rtl_TextEncoding);
     384                 :            : 
     385                 :          0 : void SAL_CALL thisModule() {}
     386                 :            : 
     387                 :            : };
     388                 :            : 
     389         [ +  - ]:         82 : class FullTextEncodingData: private boost::noncopyable {
     390                 :            : public:
     391                 :         82 :     FullTextEncodingData() {
     392 [ -  + ][ +  - ]:         82 :         if (!module_.loadRelative(&thisModule, SAL_MODULENAME("sal_textenc"))) {
     393                 :            :             OSL_TRACE("Loading sal_textenc library failed");
     394                 :          0 :             std::abort();
     395                 :            :         }
     396                 :            :         function_ = reinterpret_cast< TextEncodingFunction * >(
     397         [ +  - ]:         82 :             module_.getFunctionSymbol("sal_getFullTextEncodingData"));
     398         [ -  + ]:         82 :         if (function_ == 0) {
     399                 :            :             OSL_TRACE(
     400                 :            :                 "Obtaining sal_getFullTextEncodingData fuction from sal_textenc"
     401                 :            :                 " library failed");
     402                 :          0 :             std::abort();
     403                 :            :         }
     404                 :         82 :     }
     405                 :            : 
     406                 :      22226 :     ImplTextEncodingData const * get(rtl_TextEncoding encoding) {
     407                 :      22226 :         return (*function_)(encoding);
     408                 :            :     }
     409                 :            : 
     410                 :            : private:
     411                 :            :     osl::Module module_;
     412                 :            :     TextEncodingFunction * function_;
     413                 :            : };
     414                 :            : 
     415                 :            : #endif
     416                 :            : 
     417                 :            : struct FullTextEncodingDataSingleton:
     418                 :            :     public rtl::Static< FullTextEncodingData, FullTextEncodingDataSingleton >
     419                 :            : {};
     420                 :            : 
     421                 :            : }
     422                 :            : 
     423                 :            : ImplTextEncodingData const *
     424                 :    2561445 : Impl_getTextEncodingData(rtl_TextEncoding nEncoding)
     425                 :            : {
     426   [ +  +  +  +  :    2561445 :     switch(nEncoding)
                   +  + ]
     427                 :            :     {
     428                 :            :         case RTL_TEXTENCODING_ASCII_US:
     429                 :     963430 :             return &aImplUSASCIITextEncodingData; break;
     430                 :            :         case RTL_TEXTENCODING_MS_1252:
     431                 :     198609 :             return &aImplMS1252TextEncodingData; break;
     432                 :            :         case RTL_TEXTENCODING_UTF8:
     433                 :    1180111 :             return &aImplUTF8TextEncodingData; break;
     434                 :            :         case RTL_TEXTENCODING_JAVA_UTF8:
     435                 :        752 :             return &aImplJavaUtf8TextEncodingData; break;
     436                 :            :         case RTL_TEXTENCODING_ISO_8859_1:
     437                 :     196317 :             return &aImplISO88591TextEncodingData; break;
     438                 :            :         default:
     439                 :    2561445 :             return FullTextEncodingDataSingleton::get().get(nEncoding);
     440                 :            :     }
     441                 :            : }
     442                 :            : 
     443                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10