LCOV - code coverage report
Current view: top level - svtools/source/svhtml - htmlout.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 196 611 32.1 %
Date: 2014-11-03 Functions: 16 20 80.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 <svl/zformat.hxx>
      22             : #include <svl/macitem.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/settings.hxx>
      25             : #include <svl/zforlist.hxx>
      26             : 
      27             : #include <svtools/htmlout.hxx>
      28             : #include <svtools/htmlkywd.hxx>
      29             : #include <svtools/imap.hxx>
      30             : #include <svtools/imaprect.hxx>
      31             : #include <svtools/imapcirc.hxx>
      32             : #include <svtools/imappoly.hxx>
      33             : #include <svl/urihelper.hxx>
      34             : 
      35             : #include <sstream>
      36             : 
      37             : #define TXTCONV_BUFFER_SIZE 20
      38             : 
      39        4552 : HTMLOutContext::HTMLOutContext( rtl_TextEncoding eDestEnc )
      40             : {
      41             :     m_eDestEnc = RTL_TEXTENCODING_DONTKNOW == eDestEnc
      42             :                     ? osl_getThreadTextEncoding()
      43        4552 :                     : eDestEnc;
      44             : 
      45        4552 :     m_hConv = rtl_createUnicodeToTextConverter( eDestEnc );
      46             :     DBG_ASSERT( m_hConv,
      47             :         "HTMLOutContext::HTMLOutContext: no converter for source encoding" );
      48        4552 :     m_hContext = m_hConv ? rtl_createUnicodeToTextContext( m_hConv )
      49        9104 :                      : reinterpret_cast<rtl_TextToUnicodeContext>(1);
      50        4552 : }
      51             : 
      52        4552 : HTMLOutContext::~HTMLOutContext()
      53             : {
      54        4552 :     rtl_destroyUnicodeToTextContext( m_hConv, m_hContext );
      55        4552 :     rtl_destroyUnicodeToTextConverter( m_hConv );
      56        4552 : }
      57             : 
      58       33504 : static const sal_Char *lcl_svhtml_GetEntityForChar( sal_Unicode c,
      59             :                                              rtl_TextEncoding eDestEnc )
      60             : {
      61       33504 :     const sal_Char* pStr = 0;
      62             : 
      63             :     // Note: We currently handle special cases for ISO-8859-2 here simply because
      64             :     // the code was already submitted.  But we should also handle other code pages
      65             :     // as well as the code becomes available.
      66             : 
      67       33504 :     if( eDestEnc == RTL_TEXTENCODING_ISO_8859_2 || eDestEnc == RTL_TEXTENCODING_MS_1250 )
      68             :     {
      69             :         // Don't handle the following characters for Easter European (ISO-8859-2).
      70           0 :         switch ( c )
      71             :         {
      72             :         case 164: // curren
      73             :         case 184: // ccedil
      74             :         case 193: // Aacute
      75             :         case 194: // Acirc
      76             :         case 196: // Auml
      77             :         case 199: // Ccedil
      78             :         case 201: // Eacute
      79             :         case 203: // Euml
      80             :         case 205: // Iacute
      81             :         case 206: // Icirc
      82             :         case 211: // Oacute
      83             :         case 212: // Ocirc
      84             :         case 214: // Ouml
      85             :         case 215: // times
      86             :         case 218: // Uacute
      87             :         case 220: // Uuml
      88             :         case 221: // Yacute
      89             :         case 225: // aacute
      90             :         case 226: // acirc
      91             :         case 228: // auml
      92             :         case 233: // eacute
      93             :         case 235: // euml
      94             :         case 237: // iacute
      95             :         case 238: // icirc
      96             :         case 243: // oacute
      97             :         case 244: // ocirc
      98             :         case 246: // ouml
      99             :         case 247: // divide
     100             :         case 250: // uacute
     101             :         case 252: // uuml
     102             :         case 253: // yacute
     103             :         case 352: // Scaron
     104             :         case 353: // scaron
     105           0 :             return pStr;
     106             :         }
     107             :     }
     108             : 
     109             :     // TODO: handle more special cases for other code pages.
     110             : 
     111       33504 :     switch( c )
     112             :     {
     113             : //      case '\x0a':   return HTMLOutFuncs::Out_Tag( rStream, OOO_STRING_SVTOOLS_HTML_linebreak );
     114             : 
     115           0 :     case '<':       pStr = OOO_STRING_SVTOOLS_HTML_C_lt;        break;
     116           0 :     case '>':       pStr = OOO_STRING_SVTOOLS_HTML_C_gt;        break;
     117           0 :     case '&':       pStr = OOO_STRING_SVTOOLS_HTML_C_amp;       break;
     118           0 :     case '"':       pStr = OOO_STRING_SVTOOLS_HTML_C_quot;  break;
     119             : 
     120           0 :     case 161:       pStr = OOO_STRING_SVTOOLS_HTML_S_iexcl; break;
     121           0 :     case 162:       pStr = OOO_STRING_SVTOOLS_HTML_S_cent;  break;
     122           0 :     case 163:       pStr = OOO_STRING_SVTOOLS_HTML_S_pound; break;
     123           0 :     case 164:       pStr = OOO_STRING_SVTOOLS_HTML_S_curren;    break;
     124           0 :     case 165:       pStr = OOO_STRING_SVTOOLS_HTML_S_yen;       break;
     125           0 :     case 166:       pStr = OOO_STRING_SVTOOLS_HTML_S_brvbar;    break;
     126           0 :     case 167:       pStr = OOO_STRING_SVTOOLS_HTML_S_sect;  break;
     127           0 :     case 168:       pStr = OOO_STRING_SVTOOLS_HTML_S_uml;       break;
     128           0 :     case 169:       pStr = OOO_STRING_SVTOOLS_HTML_S_copy;  break;
     129           0 :     case 170:       pStr = OOO_STRING_SVTOOLS_HTML_S_ordf;  break;
     130           0 :     case 171:       pStr = OOO_STRING_SVTOOLS_HTML_S_laquo; break;
     131           0 :     case 172:       pStr = OOO_STRING_SVTOOLS_HTML_S_not;       break;
     132           0 :     case 174:       pStr = OOO_STRING_SVTOOLS_HTML_S_reg;       break;
     133           0 :     case 175:       pStr = OOO_STRING_SVTOOLS_HTML_S_macr;  break;
     134           0 :     case 176:       pStr = OOO_STRING_SVTOOLS_HTML_S_deg;       break;
     135           0 :     case 177:       pStr = OOO_STRING_SVTOOLS_HTML_S_plusmn;    break;
     136           0 :     case 178:       pStr = OOO_STRING_SVTOOLS_HTML_S_sup2;  break;
     137           0 :     case 179:       pStr = OOO_STRING_SVTOOLS_HTML_S_sup3;  break;
     138           0 :     case 180:       pStr = OOO_STRING_SVTOOLS_HTML_S_acute; break;
     139           0 :     case 181:       pStr = OOO_STRING_SVTOOLS_HTML_S_micro; break;
     140           0 :     case 182:       pStr = OOO_STRING_SVTOOLS_HTML_S_para;  break;
     141           0 :     case 183:       pStr = OOO_STRING_SVTOOLS_HTML_S_middot;    break;
     142           0 :     case 184:       pStr = OOO_STRING_SVTOOLS_HTML_S_cedil; break;
     143           0 :     case 185:       pStr = OOO_STRING_SVTOOLS_HTML_S_sup1;  break;
     144           0 :     case 186:       pStr = OOO_STRING_SVTOOLS_HTML_S_ordm;  break;
     145           0 :     case 187:       pStr = OOO_STRING_SVTOOLS_HTML_S_raquo; break;
     146           0 :     case 188:       pStr = OOO_STRING_SVTOOLS_HTML_S_frac14;    break;
     147           0 :     case 189:       pStr = OOO_STRING_SVTOOLS_HTML_S_frac12;    break;
     148           0 :     case 190:       pStr = OOO_STRING_SVTOOLS_HTML_S_frac34;    break;
     149           0 :     case 191:       pStr = OOO_STRING_SVTOOLS_HTML_S_iquest;    break;
     150             : 
     151           0 :     case 192:       pStr = OOO_STRING_SVTOOLS_HTML_C_Agrave;    break;
     152           0 :     case 193:       pStr = OOO_STRING_SVTOOLS_HTML_C_Aacute;    break;
     153           0 :     case 194:       pStr = OOO_STRING_SVTOOLS_HTML_C_Acirc; break;
     154           0 :     case 195:       pStr = OOO_STRING_SVTOOLS_HTML_C_Atilde;    break;
     155           0 :     case 196:       pStr = OOO_STRING_SVTOOLS_HTML_C_Auml;  break;
     156           0 :     case 197:       pStr = OOO_STRING_SVTOOLS_HTML_C_Aring; break;
     157           0 :     case 198:       pStr = OOO_STRING_SVTOOLS_HTML_C_AElig; break;
     158           0 :     case 199:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ccedil;    break;
     159           0 :     case 200:       pStr = OOO_STRING_SVTOOLS_HTML_C_Egrave;    break;
     160           0 :     case 201:       pStr = OOO_STRING_SVTOOLS_HTML_C_Eacute;    break;
     161           0 :     case 202:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ecirc; break;
     162           0 :     case 203:       pStr = OOO_STRING_SVTOOLS_HTML_C_Euml;  break;
     163           0 :     case 204:       pStr = OOO_STRING_SVTOOLS_HTML_C_Igrave;    break;
     164           0 :     case 205:       pStr = OOO_STRING_SVTOOLS_HTML_C_Iacute;    break;
     165           0 :     case 206:       pStr = OOO_STRING_SVTOOLS_HTML_C_Icirc; break;
     166           0 :     case 207:       pStr = OOO_STRING_SVTOOLS_HTML_C_Iuml;  break;
     167           0 :     case 208:       pStr = OOO_STRING_SVTOOLS_HTML_C_ETH;       break;
     168           0 :     case 209:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ntilde;    break;
     169           0 :     case 210:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ograve;    break;
     170           0 :     case 211:       pStr = OOO_STRING_SVTOOLS_HTML_C_Oacute;    break;
     171           0 :     case 212:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ocirc; break;
     172           0 :     case 213:       pStr = OOO_STRING_SVTOOLS_HTML_C_Otilde;    break;
     173           0 :     case 214:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ouml;  break;
     174           0 :     case 215:       pStr = OOO_STRING_SVTOOLS_HTML_S_times; break;
     175           0 :     case 216:       pStr = OOO_STRING_SVTOOLS_HTML_C_Oslash;    break;
     176           0 :     case 217:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ugrave;    break;
     177           0 :     case 218:       pStr = OOO_STRING_SVTOOLS_HTML_C_Uacute;    break;
     178           0 :     case 219:       pStr = OOO_STRING_SVTOOLS_HTML_C_Ucirc; break;
     179           0 :     case 220:       pStr = OOO_STRING_SVTOOLS_HTML_C_Uuml;  break;
     180           0 :     case 221:       pStr = OOO_STRING_SVTOOLS_HTML_C_Yacute;    break;
     181             : 
     182           0 :     case 222:       pStr = OOO_STRING_SVTOOLS_HTML_C_THORN; break;
     183           0 :     case 223:       pStr = OOO_STRING_SVTOOLS_HTML_C_szlig; break;
     184             : 
     185           0 :     case 224:       pStr = OOO_STRING_SVTOOLS_HTML_S_agrave;    break;
     186           0 :     case 225:       pStr = OOO_STRING_SVTOOLS_HTML_S_aacute;    break;
     187           0 :     case 226:       pStr = OOO_STRING_SVTOOLS_HTML_S_acirc; break;
     188           0 :     case 227:       pStr = OOO_STRING_SVTOOLS_HTML_S_atilde;    break;
     189           0 :     case 228:       pStr = OOO_STRING_SVTOOLS_HTML_S_auml;  break;
     190           0 :     case 229:       pStr = OOO_STRING_SVTOOLS_HTML_S_aring; break;
     191           0 :     case 230:       pStr = OOO_STRING_SVTOOLS_HTML_S_aelig; break;
     192           0 :     case 231:       pStr = OOO_STRING_SVTOOLS_HTML_S_ccedil;    break;
     193           0 :     case 232:       pStr = OOO_STRING_SVTOOLS_HTML_S_egrave;    break;
     194           0 :     case 233:       pStr = OOO_STRING_SVTOOLS_HTML_S_eacute;    break;
     195           0 :     case 234:       pStr = OOO_STRING_SVTOOLS_HTML_S_ecirc; break;
     196           0 :     case 235:       pStr = OOO_STRING_SVTOOLS_HTML_S_euml;  break;
     197           0 :     case 236:       pStr = OOO_STRING_SVTOOLS_HTML_S_igrave;    break;
     198           0 :     case 237:       pStr = OOO_STRING_SVTOOLS_HTML_S_iacute;    break;
     199           0 :     case 238:       pStr = OOO_STRING_SVTOOLS_HTML_S_icirc; break;
     200           0 :     case 239:       pStr = OOO_STRING_SVTOOLS_HTML_S_iuml;  break;
     201           0 :     case 240:       pStr = OOO_STRING_SVTOOLS_HTML_S_eth;       break;
     202           0 :     case 241:       pStr = OOO_STRING_SVTOOLS_HTML_S_ntilde;    break;
     203           0 :     case 242:       pStr = OOO_STRING_SVTOOLS_HTML_S_ograve;    break;
     204           0 :     case 243:       pStr = OOO_STRING_SVTOOLS_HTML_S_oacute;    break;
     205           0 :     case 244:       pStr = OOO_STRING_SVTOOLS_HTML_S_ocirc; break;
     206           0 :     case 245:       pStr = OOO_STRING_SVTOOLS_HTML_S_otilde;    break;
     207           0 :     case 246:       pStr = OOO_STRING_SVTOOLS_HTML_S_ouml;  break;
     208           0 :     case 247:       pStr = OOO_STRING_SVTOOLS_HTML_S_divide;    break;
     209           0 :     case 248:       pStr = OOO_STRING_SVTOOLS_HTML_S_oslash;    break;
     210           0 :     case 249:       pStr = OOO_STRING_SVTOOLS_HTML_S_ugrave;    break;
     211           0 :     case 250:       pStr = OOO_STRING_SVTOOLS_HTML_S_uacute;    break;
     212           0 :     case 251:       pStr = OOO_STRING_SVTOOLS_HTML_S_ucirc; break;
     213           0 :     case 252:       pStr = OOO_STRING_SVTOOLS_HTML_S_uuml;  break;
     214           0 :     case 253:       pStr = OOO_STRING_SVTOOLS_HTML_S_yacute;    break;
     215           0 :     case 254:       pStr = OOO_STRING_SVTOOLS_HTML_S_thorn; break;
     216           0 :     case 255:       pStr = OOO_STRING_SVTOOLS_HTML_S_yuml;  break;
     217             : 
     218           0 :     case 338:       pStr = OOO_STRING_SVTOOLS_HTML_S_OElig; break;
     219           0 :     case 339:       pStr = OOO_STRING_SVTOOLS_HTML_S_oelig; break;
     220           0 :     case 352:       pStr = OOO_STRING_SVTOOLS_HTML_S_Scaron;    break;
     221           0 :     case 353:       pStr = OOO_STRING_SVTOOLS_HTML_S_scaron;    break;
     222           0 :     case 376:       pStr = OOO_STRING_SVTOOLS_HTML_S_Yuml;  break;
     223           0 :     case 402:       pStr = OOO_STRING_SVTOOLS_HTML_S_fnof;  break;
     224           0 :     case 710:       pStr = OOO_STRING_SVTOOLS_HTML_S_circ;  break;
     225           0 :     case 732:       pStr = OOO_STRING_SVTOOLS_HTML_S_tilde; break;
     226             : 
     227             :     // Greek chars are handled later,
     228             :     // since they should *not* be transformed to entities
     229             :     // when generating Greek text (== using Greek encoding)
     230             : 
     231           0 :     case 8194:      pStr = OOO_STRING_SVTOOLS_HTML_S_ensp;  break;
     232           0 :     case 8195:      pStr = OOO_STRING_SVTOOLS_HTML_S_emsp;  break;
     233           0 :     case 8201:      pStr = OOO_STRING_SVTOOLS_HTML_S_thinsp;    break;
     234           0 :     case 8204:      pStr = OOO_STRING_SVTOOLS_HTML_S_zwnj;  break;
     235           0 :     case 8205:      pStr = OOO_STRING_SVTOOLS_HTML_S_zwj;       break;
     236           0 :     case 8206:      pStr = OOO_STRING_SVTOOLS_HTML_S_lrm;       break;
     237           0 :     case 8207:      pStr = OOO_STRING_SVTOOLS_HTML_S_rlm;       break;
     238           0 :     case 8211:      pStr = OOO_STRING_SVTOOLS_HTML_S_ndash; break;
     239           0 :     case 8212:      pStr = OOO_STRING_SVTOOLS_HTML_S_mdash; break;
     240           0 :     case 8216:      pStr = OOO_STRING_SVTOOLS_HTML_S_lsquo; break;
     241           0 :     case 8217:      pStr = OOO_STRING_SVTOOLS_HTML_S_rsquo; break;
     242           0 :     case 8218:      pStr = OOO_STRING_SVTOOLS_HTML_S_sbquo; break;
     243           0 :     case 8220:      pStr = OOO_STRING_SVTOOLS_HTML_S_ldquo; break;
     244           0 :     case 8221:      pStr = OOO_STRING_SVTOOLS_HTML_S_rdquo; break;
     245           0 :     case 8222:      pStr = OOO_STRING_SVTOOLS_HTML_S_bdquo; break;
     246           0 :     case 8224:      pStr = OOO_STRING_SVTOOLS_HTML_S_dagger;    break;
     247           0 :     case 8225:      pStr = OOO_STRING_SVTOOLS_HTML_S_Dagger;    break;
     248           0 :     case 8226:      pStr = OOO_STRING_SVTOOLS_HTML_S_bull;  break;
     249           0 :     case 8230:      pStr = OOO_STRING_SVTOOLS_HTML_S_hellip;    break;
     250           0 :     case 8240:      pStr = OOO_STRING_SVTOOLS_HTML_S_permil;    break;
     251           0 :     case 8242:      pStr = OOO_STRING_SVTOOLS_HTML_S_prime; break;
     252           0 :     case 8243:      pStr = OOO_STRING_SVTOOLS_HTML_S_Prime; break;
     253           0 :     case 8249:      pStr = OOO_STRING_SVTOOLS_HTML_S_lsaquo;    break;
     254           0 :     case 8250:      pStr = OOO_STRING_SVTOOLS_HTML_S_rsaquo;    break;
     255           0 :     case 8254:      pStr = OOO_STRING_SVTOOLS_HTML_S_oline; break;
     256           0 :     case 8260:      pStr = OOO_STRING_SVTOOLS_HTML_S_frasl; break;
     257           0 :     case 8364:      pStr = OOO_STRING_SVTOOLS_HTML_S_euro;  break;
     258           0 :     case 8465:      pStr = OOO_STRING_SVTOOLS_HTML_S_image; break;
     259           0 :     case 8472:      pStr = OOO_STRING_SVTOOLS_HTML_S_weierp;    break;
     260           0 :     case 8476:      pStr = OOO_STRING_SVTOOLS_HTML_S_real;  break;
     261           0 :     case 8482:      pStr = OOO_STRING_SVTOOLS_HTML_S_trade; break;
     262           0 :     case 8501:      pStr = OOO_STRING_SVTOOLS_HTML_S_alefsym;   break;
     263           0 :     case 8592:      pStr = OOO_STRING_SVTOOLS_HTML_S_larr;  break;
     264           0 :     case 8593:      pStr = OOO_STRING_SVTOOLS_HTML_S_uarr;  break;
     265           0 :     case 8594:      pStr = OOO_STRING_SVTOOLS_HTML_S_rarr;  break;
     266           0 :     case 8595:      pStr = OOO_STRING_SVTOOLS_HTML_S_darr;  break;
     267           0 :     case 8596:      pStr = OOO_STRING_SVTOOLS_HTML_S_harr;  break;
     268           0 :     case 8629:      pStr = OOO_STRING_SVTOOLS_HTML_S_crarr; break;
     269           0 :     case 8656:      pStr = OOO_STRING_SVTOOLS_HTML_S_lArr;  break;
     270           0 :     case 8657:      pStr = OOO_STRING_SVTOOLS_HTML_S_uArr;  break;
     271           0 :     case 8658:      pStr = OOO_STRING_SVTOOLS_HTML_S_rArr;  break;
     272           0 :     case 8659:      pStr = OOO_STRING_SVTOOLS_HTML_S_dArr;  break;
     273           0 :     case 8660:      pStr = OOO_STRING_SVTOOLS_HTML_S_hArr;  break;
     274           0 :     case 8704:      pStr = OOO_STRING_SVTOOLS_HTML_S_forall;    break;
     275           0 :     case 8706:      pStr = OOO_STRING_SVTOOLS_HTML_S_part;  break;
     276           0 :     case 8707:      pStr = OOO_STRING_SVTOOLS_HTML_S_exist; break;
     277           0 :     case 8709:      pStr = OOO_STRING_SVTOOLS_HTML_S_empty; break;
     278           0 :     case 8711:      pStr = OOO_STRING_SVTOOLS_HTML_S_nabla; break;
     279           0 :     case 8712:      pStr = OOO_STRING_SVTOOLS_HTML_S_isin;  break;
     280           0 :     case 8713:      pStr = OOO_STRING_SVTOOLS_HTML_S_notin; break;
     281           0 :     case 8715:      pStr = OOO_STRING_SVTOOLS_HTML_S_ni;        break;
     282           0 :     case 8719:      pStr = OOO_STRING_SVTOOLS_HTML_S_prod;  break;
     283           0 :     case 8721:      pStr = OOO_STRING_SVTOOLS_HTML_S_sum;       break;
     284           0 :     case 8722:      pStr = OOO_STRING_SVTOOLS_HTML_S_minus; break;
     285           0 :     case 8727:      pStr = OOO_STRING_SVTOOLS_HTML_S_lowast;    break;
     286           0 :     case 8730:      pStr = OOO_STRING_SVTOOLS_HTML_S_radic; break;
     287           0 :     case 8733:      pStr = OOO_STRING_SVTOOLS_HTML_S_prop;  break;
     288           0 :     case 8734:      pStr = OOO_STRING_SVTOOLS_HTML_S_infin; break;
     289           0 :     case 8736:      pStr = OOO_STRING_SVTOOLS_HTML_S_ang;       break;
     290           0 :     case 8743:      pStr = OOO_STRING_SVTOOLS_HTML_S_and;       break;
     291           0 :     case 8744:      pStr = OOO_STRING_SVTOOLS_HTML_S_or;        break;
     292           0 :     case 8745:      pStr = OOO_STRING_SVTOOLS_HTML_S_cap;       break;
     293           0 :     case 8746:      pStr = OOO_STRING_SVTOOLS_HTML_S_cup;       break;
     294           0 :     case 8747:      pStr = OOO_STRING_SVTOOLS_HTML_S_int;       break;
     295           0 :     case 8756:      pStr = OOO_STRING_SVTOOLS_HTML_S_there4;    break;
     296           0 :     case 8764:      pStr = OOO_STRING_SVTOOLS_HTML_S_sim;       break;
     297           0 :     case 8773:      pStr = OOO_STRING_SVTOOLS_HTML_S_cong;  break;
     298           0 :     case 8776:      pStr = OOO_STRING_SVTOOLS_HTML_S_asymp; break;
     299           0 :     case 8800:      pStr = OOO_STRING_SVTOOLS_HTML_S_ne;        break;
     300           0 :     case 8801:      pStr = OOO_STRING_SVTOOLS_HTML_S_equiv; break;
     301           0 :     case 8804:      pStr = OOO_STRING_SVTOOLS_HTML_S_le;        break;
     302           0 :     case 8805:      pStr = OOO_STRING_SVTOOLS_HTML_S_ge;        break;
     303           0 :     case 8834:      pStr = OOO_STRING_SVTOOLS_HTML_S_sub;       break;
     304           0 :     case 8835:      pStr = OOO_STRING_SVTOOLS_HTML_S_sup;       break;
     305           0 :     case 8836:      pStr = OOO_STRING_SVTOOLS_HTML_S_nsub;  break;
     306           0 :     case 8838:      pStr = OOO_STRING_SVTOOLS_HTML_S_sube;  break;
     307           0 :     case 8839:      pStr = OOO_STRING_SVTOOLS_HTML_S_supe;  break;
     308           0 :     case 8853:      pStr = OOO_STRING_SVTOOLS_HTML_S_oplus; break;
     309           0 :     case 8855:      pStr = OOO_STRING_SVTOOLS_HTML_S_otimes;    break;
     310           0 :     case 8869:      pStr = OOO_STRING_SVTOOLS_HTML_S_perp;  break;
     311           0 :     case 8901:      pStr = OOO_STRING_SVTOOLS_HTML_S_sdot;  break;
     312           0 :     case 8968:      pStr = OOO_STRING_SVTOOLS_HTML_S_lceil; break;
     313           0 :     case 8969:      pStr = OOO_STRING_SVTOOLS_HTML_S_rceil; break;
     314           0 :     case 8970:      pStr = OOO_STRING_SVTOOLS_HTML_S_lfloor;    break;
     315           0 :     case 8971:      pStr = OOO_STRING_SVTOOLS_HTML_S_rfloor;    break;
     316           0 :     case 9001:      pStr = OOO_STRING_SVTOOLS_HTML_S_lang;  break;
     317           0 :     case 9002:      pStr = OOO_STRING_SVTOOLS_HTML_S_rang;  break;
     318           0 :     case 9674:      pStr = OOO_STRING_SVTOOLS_HTML_S_loz;       break;
     319           0 :     case 9824:      pStr = OOO_STRING_SVTOOLS_HTML_S_spades;    break;
     320           0 :     case 9827:      pStr = OOO_STRING_SVTOOLS_HTML_S_clubs; break;
     321           0 :     case 9829:      pStr = OOO_STRING_SVTOOLS_HTML_S_hearts;    break;
     322           0 :     case 9830:      pStr = OOO_STRING_SVTOOLS_HTML_S_diams; break;
     323             :     }
     324             : 
     325             :     // Greek chars: if we do not produce a Greek encoding,
     326             :     // transform them into entities
     327       33504 :     if( !pStr &&
     328       33504 :         ( eDestEnc != RTL_TEXTENCODING_ISO_8859_7 ) &&
     329             :         ( eDestEnc != RTL_TEXTENCODING_MS_1253 ) )
     330             :     {
     331       33504 :         switch( c )
     332             :         {
     333           0 :         case 913:       pStr = OOO_STRING_SVTOOLS_HTML_S_Alpha; break;
     334           0 :         case 914:       pStr = OOO_STRING_SVTOOLS_HTML_S_Beta;  break;
     335           0 :         case 915:       pStr = OOO_STRING_SVTOOLS_HTML_S_Gamma; break;
     336           0 :         case 916:       pStr = OOO_STRING_SVTOOLS_HTML_S_Delta; break;
     337           0 :         case 917:       pStr = OOO_STRING_SVTOOLS_HTML_S_Epsilon;   break;
     338           0 :         case 918:       pStr = OOO_STRING_SVTOOLS_HTML_S_Zeta;  break;
     339           0 :         case 919:       pStr = OOO_STRING_SVTOOLS_HTML_S_Eta;       break;
     340           0 :         case 920:       pStr = OOO_STRING_SVTOOLS_HTML_S_Theta; break;
     341           0 :         case 921:       pStr = OOO_STRING_SVTOOLS_HTML_S_Iota;  break;
     342           0 :         case 922:       pStr = OOO_STRING_SVTOOLS_HTML_S_Kappa; break;
     343           0 :         case 923:       pStr = OOO_STRING_SVTOOLS_HTML_S_Lambda;    break;
     344           0 :         case 924:       pStr = OOO_STRING_SVTOOLS_HTML_S_Mu;        break;
     345           0 :         case 925:       pStr = OOO_STRING_SVTOOLS_HTML_S_Nu;        break;
     346           0 :         case 926:       pStr = OOO_STRING_SVTOOLS_HTML_S_Xi;        break;
     347           0 :         case 927:       pStr = OOO_STRING_SVTOOLS_HTML_S_Omicron;   break;
     348           0 :         case 928:       pStr = OOO_STRING_SVTOOLS_HTML_S_Pi;        break;
     349           0 :         case 929:       pStr = OOO_STRING_SVTOOLS_HTML_S_Rho;       break;
     350           0 :         case 931:       pStr = OOO_STRING_SVTOOLS_HTML_S_Sigma; break;
     351           0 :         case 932:       pStr = OOO_STRING_SVTOOLS_HTML_S_Tau;       break;
     352           0 :         case 933:       pStr = OOO_STRING_SVTOOLS_HTML_S_Upsilon;   break;
     353           0 :         case 934:       pStr = OOO_STRING_SVTOOLS_HTML_S_Phi;       break;
     354           0 :         case 935:       pStr = OOO_STRING_SVTOOLS_HTML_S_Chi;       break;
     355           0 :         case 936:       pStr = OOO_STRING_SVTOOLS_HTML_S_Psi;       break;
     356           0 :         case 937:       pStr = OOO_STRING_SVTOOLS_HTML_S_Omega; break;
     357           0 :         case 945:       pStr = OOO_STRING_SVTOOLS_HTML_S_alpha; break;
     358           0 :         case 946:       pStr = OOO_STRING_SVTOOLS_HTML_S_beta;  break;
     359           0 :         case 947:       pStr = OOO_STRING_SVTOOLS_HTML_S_gamma; break;
     360           0 :         case 948:       pStr = OOO_STRING_SVTOOLS_HTML_S_delta; break;
     361           0 :         case 949:       pStr = OOO_STRING_SVTOOLS_HTML_S_epsilon;   break;
     362           0 :         case 950:       pStr = OOO_STRING_SVTOOLS_HTML_S_zeta;  break;
     363           0 :         case 951:       pStr = OOO_STRING_SVTOOLS_HTML_S_eta;       break;
     364           0 :         case 952:       pStr = OOO_STRING_SVTOOLS_HTML_S_theta; break;
     365           0 :         case 953:       pStr = OOO_STRING_SVTOOLS_HTML_S_iota;  break;
     366           0 :         case 954:       pStr = OOO_STRING_SVTOOLS_HTML_S_kappa; break;
     367           0 :         case 955:       pStr = OOO_STRING_SVTOOLS_HTML_S_lambda;    break;
     368           0 :         case 956:       pStr = OOO_STRING_SVTOOLS_HTML_S_mu;        break;
     369           0 :         case 957:       pStr = OOO_STRING_SVTOOLS_HTML_S_nu;        break;
     370           0 :         case 958:       pStr = OOO_STRING_SVTOOLS_HTML_S_xi;        break;
     371           0 :         case 959:       pStr = OOO_STRING_SVTOOLS_HTML_S_omicron;   break;
     372           0 :         case 960:       pStr = OOO_STRING_SVTOOLS_HTML_S_pi;        break;
     373           0 :         case 961:       pStr = OOO_STRING_SVTOOLS_HTML_S_rho;       break;
     374           0 :         case 962:       pStr = OOO_STRING_SVTOOLS_HTML_S_sigmaf;    break;
     375           0 :         case 963:       pStr = OOO_STRING_SVTOOLS_HTML_S_sigma; break;
     376           0 :         case 964:       pStr = OOO_STRING_SVTOOLS_HTML_S_tau;       break;
     377           0 :         case 965:       pStr = OOO_STRING_SVTOOLS_HTML_S_upsilon;   break;
     378           0 :         case 966:       pStr = OOO_STRING_SVTOOLS_HTML_S_phi;       break;
     379           0 :         case 967:       pStr = OOO_STRING_SVTOOLS_HTML_S_chi;       break;
     380           0 :         case 968:       pStr = OOO_STRING_SVTOOLS_HTML_S_psi;       break;
     381           0 :         case 969:       pStr = OOO_STRING_SVTOOLS_HTML_S_omega; break;
     382           0 :         case 977:       pStr = OOO_STRING_SVTOOLS_HTML_S_thetasym;break;
     383           0 :         case 978:       pStr = OOO_STRING_SVTOOLS_HTML_S_upsih; break;
     384           0 :         case 982:       pStr = OOO_STRING_SVTOOLS_HTML_S_piv;       break;
     385             :         }
     386             :     }
     387             : 
     388       33504 :     return pStr;
     389             : }
     390             : 
     391       33510 : static OString lcl_ConvertCharToHTML( sal_Unicode c,
     392             :                             HTMLOutContext& rContext,
     393             :                             OUString *pNonConvertableChars )
     394             : {
     395       33510 :     OStringBuffer aDest;
     396             :     DBG_ASSERT( RTL_TEXTENCODING_DONTKNOW != rContext.m_eDestEnc,
     397             :                     "wrong destination encoding" );
     398       33510 :     const sal_Char *pStr = 0;
     399       33510 :     switch( c )
     400             :     {
     401             :     case 0xA0:      // is a hard blank
     402           0 :         pStr = OOO_STRING_SVTOOLS_HTML_S_nbsp;
     403           0 :         break;
     404             :     case 0x2011:    // is a hard hyphen
     405           0 :         pStr = "#8209";
     406           0 :         break;
     407             :     case 0xAD:      // is a soft hyphen
     408           0 :         pStr = OOO_STRING_SVTOOLS_HTML_S_shy;
     409           0 :         break;
     410             :     default:
     411             :         // There may be an entity for the character.
     412             :         // The new HTML4 entities above 255 are not used for UTF-8,
     413             :         // because Netscape 4 does support UTF-8 but does not support
     414             :         // these entities.
     415       33510 :         if( c < 128 || RTL_TEXTENCODING_UTF8 != rContext.m_eDestEnc )
     416       33504 :             pStr = lcl_svhtml_GetEntityForChar( c, rContext.m_eDestEnc );
     417       33510 :         break;
     418             :     }
     419             : 
     420             :     sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
     421       33510 :     sal_uInt32 nInfo = 0;
     422             :     sal_Size nSrcChars;
     423             :     const sal_uInt32 nFlags = RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE|
     424             :                         RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE|
     425             :                         RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|
     426       33510 :                         RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
     427       33510 :     if( pStr )
     428             :     {
     429             :         sal_Size nLen = rtl_convertUnicodeToText(
     430             :                             rContext.m_hConv, rContext.m_hContext, &c, 0,
     431             :                             cBuffer, TXTCONV_BUFFER_SIZE,
     432             :                             nFlags|RTL_UNICODETOTEXT_FLAGS_FLUSH,
     433           0 :                             &nInfo, &nSrcChars );
     434             :         DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
     435           0 :         sal_Char *pBuffer = cBuffer;
     436           0 :         while( nLen-- )
     437           0 :             aDest.append(*pBuffer++);
     438           0 :         aDest.append('&').append(pStr).append(';');
     439             :     }
     440             :     else
     441             :     {
     442             :         sal_Size nLen = rtl_convertUnicodeToText( rContext.m_hConv,
     443             :                                                   rContext.m_hContext, &c, 1,
     444             :                                                      cBuffer, TXTCONV_BUFFER_SIZE,
     445             :                                                   nFlags,
     446       33510 :                                                   &nInfo, &nSrcChars );
     447       33510 :         if( nLen > 0 && (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0 )
     448             :         {
     449       33510 :             sal_Char *pBuffer = cBuffer;
     450      100536 :             while( nLen-- )
     451       67026 :                 aDest.append(*pBuffer++);
     452             :         }
     453             :         else
     454             :         {
     455             :             // If the character could not be converted to the destination
     456             :             // character set, the UNICODE character is exported as character
     457             :             // entity.
     458             :             // coverity[array_vs_singleton]
     459             :             nLen = rtl_convertUnicodeToText(
     460             :                                 rContext.m_hConv, rContext.m_hContext, &c, 0,
     461             :                                 cBuffer, TXTCONV_BUFFER_SIZE,
     462             :                                 nFlags|RTL_UNICODETOTEXT_FLAGS_FLUSH,
     463           0 :                                 &nInfo, &nSrcChars );
     464             :             DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
     465           0 :             sal_Char *pBuffer = cBuffer;
     466           0 :             while( nLen-- )
     467           0 :                 aDest.append(*pBuffer++);
     468             : 
     469           0 :             aDest.append('&').append('#').append(static_cast<sal_Int64>(c))
     470           0 :                  .append(';');
     471           0 :             if( pNonConvertableChars &&
     472           0 :                 -1 == pNonConvertableChars->indexOf( c ) )
     473           0 :                 (*pNonConvertableChars) += OUString(c);
     474             :         }
     475             :     }
     476       33510 :     return aDest.makeStringAndClear();
     477             : }
     478             : 
     479        4596 : static OString lcl_FlushToAscii( HTMLOutContext& rContext )
     480             : {
     481        4596 :     OStringBuffer aDest;
     482             : 
     483        4596 :     sal_Unicode c = 0;
     484             :     sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
     485        4596 :     sal_uInt32 nInfo = 0;
     486             :     sal_Size nSrcChars;
     487             :     const sal_uInt32 nFlags = RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE|
     488             :                         RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE|
     489             :                         RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|
     490             :                         RTL_UNICODETOTEXT_FLAGS_FLUSH|
     491        4596 :                         RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
     492             :     sal_Size nLen = rtl_convertUnicodeToText(
     493             :                         rContext.m_hConv, rContext.m_hContext, &c, 0,
     494             :                         cBuffer, TXTCONV_BUFFER_SIZE, nFlags,
     495        4596 :                         &nInfo, &nSrcChars );
     496             :     DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
     497        4596 :     sal_Char *pBuffer = cBuffer;
     498        9192 :     while( nLen-- )
     499           0 :         aDest.append(*pBuffer++);
     500        4596 :     return aDest.makeStringAndClear();
     501             : }
     502             : 
     503           0 : OString HTMLOutFuncs::ConvertStringToHTML( const OUString& rSrc,
     504             :     rtl_TextEncoding eDestEnc, OUString *pNonConvertableChars )
     505             : {
     506           0 :     HTMLOutContext aContext( eDestEnc );
     507           0 :     OStringBuffer aDest;
     508           0 :     for( sal_Int32 i=0, nLen = rSrc.getLength(); i < nLen; i++ )
     509             :         aDest.append(lcl_ConvertCharToHTML(
     510           0 :             rSrc[i], aContext, pNonConvertableChars));
     511           0 :     aDest.append(lcl_FlushToAscii(aContext));
     512           0 :     return aDest.makeStringAndClear();
     513             : }
     514             : 
     515        1994 : SvStream& HTMLOutFuncs::Out_AsciiTag( SvStream& rStream, const sal_Char *pStr,
     516             :                                       bool bOn, rtl_TextEncoding )
     517             : {
     518        1994 :     if(bOn)
     519         394 :         rStream.WriteCharPtr("<");
     520             :     else
     521        1600 :         rStream.WriteCharPtr("</");
     522             : 
     523        1994 :     rStream.WriteCharPtr(pStr).WriteChar('>');
     524             : 
     525        1994 :     return rStream;
     526             : }
     527             : 
     528       33510 : SvStream& HTMLOutFuncs::Out_Char( SvStream& rStream, sal_Unicode c,
     529             :                                   HTMLOutContext& rContext,
     530             :                                   OUString *pNonConvertableChars )
     531             : {
     532       33510 :     OString sOut = lcl_ConvertCharToHTML( c, rContext, pNonConvertableChars );
     533       33510 :     rStream.WriteCharPtr( sOut.getStr() );
     534       33510 :     return rStream;
     535             : }
     536             : 
     537        3982 : SvStream& HTMLOutFuncs::Out_String( SvStream& rStream, const OUString& rOUStr,
     538             :                                     rtl_TextEncoding eDestEnc,
     539             :                                     OUString *pNonConvertableChars )
     540             : {
     541        3982 :     HTMLOutContext aContext( eDestEnc );
     542        3982 :     sal_Int32 nLen = rOUStr.getLength();
     543       36984 :     for( sal_Int32 n = 0; n < nLen; n++ )
     544       33002 :         HTMLOutFuncs::Out_Char( rStream, rOUStr[n],
     545       33002 :                                 aContext, pNonConvertableChars );
     546        3982 :     HTMLOutFuncs::FlushToAscii( rStream, aContext );
     547        3982 :     return rStream;
     548             : }
     549             : 
     550        4596 : SvStream& HTMLOutFuncs::FlushToAscii( SvStream& rStream,
     551             :                                        HTMLOutContext& rContext )
     552             : {
     553        4596 :     OString sOut = lcl_FlushToAscii( rContext );
     554             : 
     555        4596 :     if (!sOut.isEmpty())
     556           0 :         rStream.WriteCharPtr( sOut.getStr() );
     557             : 
     558        4596 :     return rStream;
     559             : }
     560             : 
     561        1632 : SvStream& HTMLOutFuncs::Out_Hex( SvStream& rStream, sal_uLong nHex, sal_uInt8 nLen,
     562             :                                    rtl_TextEncoding )
     563             : {                                                  // in einen Stream aus
     564        1632 :     sal_Char aNToABuf[] = "0000000000000000";
     565             : 
     566             :     DBG_ASSERT( nLen < sizeof(aNToABuf), "zu viele Stellen" );
     567        1632 :     if( nLen>=sizeof(aNToABuf) )
     568           0 :         nLen = (sizeof(aNToABuf)-1);
     569             : 
     570             :     // set pointer to end of buffer
     571        1632 :     sal_Char *pStr = aNToABuf + (sizeof(aNToABuf)-1);
     572        4896 :     for( sal_uInt8 n = 0; n < nLen; ++n )
     573             :     {
     574        3264 :         *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
     575        3264 :         if( *pStr > '9' )
     576        3050 :             *pStr += 39;
     577        3264 :         nHex >>= 4;
     578             :     }
     579        1632 :     return rStream.WriteCharPtr( pStr );
     580             : }
     581             : 
     582             : 
     583         544 : SvStream& HTMLOutFuncs::Out_Color( SvStream& rStream, const Color& rColor,
     584             :                                    rtl_TextEncoding )
     585             : {
     586         544 :     rStream.WriteCharPtr( "\"#" );
     587         544 :     if( rColor.GetColor() == COL_AUTO )
     588             :     {
     589           0 :         rStream.WriteCharPtr( "000000" );
     590             :     }
     591             :     else
     592             :     {
     593         544 :         Out_Hex( rStream, rColor.GetRed(), 2 );
     594         544 :         Out_Hex( rStream, rColor.GetGreen(), 2 );
     595         544 :         Out_Hex( rStream, rColor.GetBlue(), 2 );
     596             :     }
     597         544 :     rStream.WriteChar( '\"' );
     598             : 
     599         544 :     return rStream;
     600             : }
     601             : 
     602           2 : SvStream& HTMLOutFuncs::Out_ImageMap( SvStream& rStream,
     603             :                                       const OUString& rBaseURL,
     604             :                                       const ImageMap& rIMap,
     605             :                                       const OUString& rName,
     606             :                                       const HTMLOutEvent *pEventTable,
     607             :                                       bool bOutStarBasic,
     608             :                                       const sal_Char *pDelim,
     609             :                                       const sal_Char *pIndentArea,
     610             :                                       const sal_Char *pIndentMap,
     611             :                                       rtl_TextEncoding eDestEnc,
     612             :                                       OUString *pNonConvertableChars    )
     613             : {
     614           2 :     if( RTL_TEXTENCODING_DONTKNOW == eDestEnc )
     615           0 :         eDestEnc = osl_getThreadTextEncoding();
     616             : 
     617           2 :     const OUString& rOutName = !rName.isEmpty() ? rName : rIMap.GetName();
     618             :     DBG_ASSERT( !rOutName.isEmpty(), "Kein ImageMap-Name" );
     619           2 :     if( rOutName.isEmpty() )
     620           0 :         return rStream;
     621             : 
     622           2 :     OStringBuffer sOut;
     623           2 :     sOut.append('<')
     624           2 :         .append(OOO_STRING_SVTOOLS_HTML_map)
     625           2 :         .append(' ')
     626           2 :         .append(OOO_STRING_SVTOOLS_HTML_O_name)
     627           2 :         .append("=\"");
     628           2 :     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     629           2 :     Out_String( rStream, rOutName, eDestEnc, pNonConvertableChars );
     630           2 :     rStream.WriteCharPtr( "\">" );
     631             : 
     632           4 :     for( sal_uInt16 i=0U; i<rIMap.GetIMapObjectCount(); i++ )
     633             :     {
     634           2 :         const IMapObject* pObj = rIMap.GetIMapObject( i );
     635             :         DBG_ASSERT( pObj, "Wo ist das ImageMap-Object?" );
     636             : 
     637           2 :         if( pObj )
     638             :         {
     639           2 :             const sal_Char *pShape = 0;
     640           2 :             OString aCoords;
     641           2 :             switch( pObj->GetType() )
     642             :             {
     643             :             case( IMAP_OBJ_RECTANGLE ):
     644             :                 {
     645             :                     const IMapRectangleObject* pRectObj =
     646           0 :                         static_cast<const IMapRectangleObject *>(pObj);
     647           0 :                     pShape = OOO_STRING_SVTOOLS_HTML_SH_rect;
     648           0 :                     Rectangle aRect( pRectObj->GetRectangle() );
     649             : 
     650           0 :                     aCoords = OStringBuffer()
     651           0 :                         .append(static_cast<sal_Int32>(aRect.Left()))
     652           0 :                         .append(',')
     653           0 :                         .append(static_cast<sal_Int32>(aRect.Top()))
     654           0 :                         .append(',')
     655           0 :                         .append(static_cast<sal_Int32>(aRect.Right()))
     656           0 :                         .append(',')
     657           0 :                         .append(static_cast<sal_Int32>(aRect.Bottom()))
     658           0 :                         .makeStringAndClear();
     659             :                 }
     660           0 :                 break;
     661             :             case( IMAP_OBJ_CIRCLE ):
     662             :                 {
     663             :                     const IMapCircleObject* pCirc =
     664           0 :                         static_cast<const IMapCircleObject *>(pObj);
     665           0 :                     pShape= OOO_STRING_SVTOOLS_HTML_SH_circ;
     666           0 :                     Point aCenter( pCirc->GetCenter() );
     667           0 :                     long nOff = pCirc->GetRadius();
     668             : 
     669           0 :                     aCoords = OStringBuffer()
     670           0 :                         .append(static_cast<sal_Int32>(aCenter.X()))
     671           0 :                         .append(',')
     672           0 :                         .append(static_cast<sal_Int32>(aCenter.Y()))
     673           0 :                         .append(',')
     674           0 :                         .append(static_cast<sal_Int32>(nOff))
     675           0 :                         .makeStringAndClear();
     676             :                 }
     677           0 :                 break;
     678             :             case( IMAP_OBJ_POLYGON ):
     679             :                 {
     680             :                     const IMapPolygonObject* pPolyObj =
     681           2 :                         static_cast<const IMapPolygonObject *>(pObj);
     682           2 :                     pShape= OOO_STRING_SVTOOLS_HTML_SH_poly;
     683           2 :                     Polygon aPoly( pPolyObj->GetPolygon() );
     684           2 :                     sal_uInt16 nCount = aPoly.GetSize();
     685           4 :                     OStringBuffer aTmpBuf;
     686           2 :                     if( nCount>0 )
     687             :                     {
     688           2 :                         const Point& rPoint = aPoly[0];
     689           2 :                         aTmpBuf.append(static_cast<sal_Int32>(rPoint.X()))
     690           2 :                             .append(',')
     691           4 :                             .append(static_cast<sal_Int32>(rPoint.Y()));
     692             :                     }
     693         194 :                     for( sal_uInt16 j=1; j<nCount; j++ )
     694             :                     {
     695         192 :                         const Point& rPoint = aPoly[j];
     696         192 :                         aTmpBuf.append(',')
     697         384 :                             .append(static_cast<sal_Int32>(rPoint.X()))
     698         192 :                             .append(',')
     699         384 :                             .append(static_cast<sal_Int32>(rPoint.Y()));
     700             :                     }
     701           4 :                     aCoords = aTmpBuf.makeStringAndClear();
     702             :                 }
     703           2 :                 break;
     704             :             default:
     705             :                 DBG_ASSERT( pShape, "unbekanntes IMapObject" );
     706           0 :                 break;
     707             :             }
     708             : 
     709           2 :             if( pShape )
     710             :             {
     711           2 :                 if( pDelim )
     712           2 :                     rStream.WriteCharPtr( pDelim );
     713           2 :                 if( pIndentArea )
     714           2 :                     rStream.WriteCharPtr( pIndentArea );
     715             : 
     716           2 :                 sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_area)
     717           2 :                     .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_shape)
     718           2 :                     .append('=').append(pShape).append(' ')
     719           2 :                     .append(OOO_STRING_SVTOOLS_HTML_O_coords).append("=\"")
     720           2 :                     .append(aCoords).append("\" ");
     721           2 :                 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     722             : 
     723           2 :                 OUString aURL( pObj->GetURL() );
     724           2 :                 if( !aURL.isEmpty() && pObj->IsActive() )
     725             :                 {
     726           4 :                     aURL = URIHelper::simpleNormalizedMakeRelative(
     727           2 :                         rBaseURL, aURL );
     728           2 :                     sOut.append(OOO_STRING_SVTOOLS_HTML_O_href).append("=\"");
     729           2 :                     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     730           2 :                     Out_String( rStream, aURL, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     731             :                 }
     732             :                 else
     733           0 :                     rStream.WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_nohref );
     734             : 
     735           2 :                 const OUString& rObjName = pObj->GetName();
     736           2 :                 if( !rObjName.isEmpty() )
     737             :                 {
     738           0 :                     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
     739           0 :                         .append("=\"");
     740           0 :                     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     741           0 :                     Out_String( rStream, rObjName, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     742             :                 }
     743             : 
     744           2 :                 const OUString& rTarget = pObj->GetTarget();
     745           2 :                 if( !rTarget.isEmpty() && pObj->IsActive() )
     746             :                 {
     747           2 :                     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_target)
     748           2 :                         .append("=\"");
     749           2 :                     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     750           2 :                     Out_String( rStream, rTarget, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     751             :                 }
     752             : 
     753           4 :                 OUString rDesc( pObj->GetAltText() );
     754           2 :                 if( rDesc.isEmpty() )
     755           0 :                     rDesc = pObj->GetDesc();
     756             : 
     757           2 :                 if( !rDesc.isEmpty() )
     758             :                 {
     759           2 :                     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_alt)
     760           2 :                         .append("=\"");
     761           2 :                     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     762           2 :                     Out_String( rStream, rDesc, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     763             :                 }
     764             : 
     765           2 :                 const SvxMacroTableDtor& rMacroTab = pObj->GetMacroTable();
     766           2 :                 if( pEventTable && !rMacroTab.empty() )
     767             :                     Out_Events( rStream, rMacroTab, pEventTable,
     768           0 :                                 bOutStarBasic, eDestEnc, pNonConvertableChars );
     769             : 
     770           4 :                 rStream.WriteChar( '>' );
     771           2 :             }
     772             :         }
     773             : 
     774             :     }
     775             : 
     776           2 :     if( pDelim )
     777           2 :         rStream.WriteCharPtr( pDelim );
     778           2 :     if( pIndentMap )
     779           2 :         rStream.WriteCharPtr( pIndentMap );
     780           2 :     Out_AsciiTag( rStream, OOO_STRING_SVTOOLS_HTML_map, false );
     781             : 
     782           2 :     return rStream;
     783             : }
     784             : 
     785           0 : SvStream& HTMLOutFuncs::OutScript( SvStream& rStrm,
     786             :                                    const OUString& rBaseURL,
     787             :                                    const OUString& rSource,
     788             :                                    const OUString& rLanguage,
     789             :                                    ScriptType eScriptType,
     790             :                                    const OUString& rSrc,
     791             :                                    const OUString *pSBLibrary,
     792             :                                    const OUString *pSBModule,
     793             :                                    rtl_TextEncoding eDestEnc,
     794             :                                    OUString *pNonConvertableChars )
     795             : {
     796           0 :     if( RTL_TEXTENCODING_DONTKNOW == eDestEnc )
     797           0 :         eDestEnc = osl_getThreadTextEncoding();
     798             : 
     799             :     // script is not indented!
     800           0 :     OStringBuffer sOut;
     801           0 :     sOut.append('<')
     802           0 :         .append(OOO_STRING_SVTOOLS_HTML_script);
     803             : 
     804           0 :     if( !rLanguage.isEmpty() )
     805             :     {
     806           0 :         sOut.append(' ')
     807           0 :             .append(OOO_STRING_SVTOOLS_HTML_O_language)
     808           0 :             .append("=\"");
     809           0 :         rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     810           0 :         Out_String( rStrm, rLanguage, eDestEnc, pNonConvertableChars );
     811           0 :         sOut.append('\"');
     812             :     }
     813             : 
     814           0 :     if( !rSrc.isEmpty() )
     815             :     {
     816           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_src).append("=\"");
     817           0 :         rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     818           0 :         Out_String( rStrm, URIHelper::simpleNormalizedMakeRelative(rBaseURL, rSrc), eDestEnc, pNonConvertableChars );
     819           0 :         sOut.append('\"');
     820             :     }
     821             : 
     822           0 :     if( STARBASIC != eScriptType && pSBLibrary )
     823             :     {
     824           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_sdlibrary)
     825           0 :             .append("=\"");
     826           0 :         rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     827           0 :         Out_String( rStrm, *pSBLibrary, eDestEnc, pNonConvertableChars );
     828           0 :         sOut.append('\"');
     829             :     }
     830             : 
     831           0 :     if( STARBASIC != eScriptType && pSBModule )
     832             :     {
     833           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_sdmodule)
     834           0 :             .append("=\"");
     835           0 :         rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     836           0 :         Out_String( rStrm, *pSBModule, eDestEnc, pNonConvertableChars );
     837           0 :         sOut.append('\"');
     838             :     }
     839             : 
     840           0 :     sOut.append('>');
     841             : 
     842           0 :     rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     843             : 
     844           0 :     if( !rSource.isEmpty() || pSBLibrary || pSBModule )
     845             :     {
     846           0 :         rStrm.WriteCharPtr( SAL_NEWLINE_STRING );
     847             : 
     848           0 :         if( JAVASCRIPT != eScriptType )
     849             :         {
     850           0 :             rStrm.WriteCharPtr( "<!--" )
     851           0 :                  .WriteCharPtr( SAL_NEWLINE_STRING );
     852             :         }
     853             : 
     854           0 :         if( STARBASIC == eScriptType )
     855             :         {
     856           0 :             if( pSBLibrary )
     857             :             {
     858           0 :                 sOut.append("' ")
     859           0 :                     .append(OOO_STRING_SVTOOLS_HTML_SB_library)
     860           0 :                     .append(' ')
     861           0 :                     .append(OUStringToOString(*pSBLibrary, eDestEnc));
     862           0 :                 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() ).WriteCharPtr( SAL_NEWLINE_STRING );
     863             :             }
     864             : 
     865           0 :             if( pSBModule )
     866             :             {
     867           0 :                 sOut.append("' ")
     868           0 :                     .append(OOO_STRING_SVTOOLS_HTML_SB_module)
     869           0 :                     .append(' ')
     870           0 :                     .append(OUStringToOString(*pSBModule, eDestEnc));
     871           0 :                 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() ).WriteCharPtr( SAL_NEWLINE_STRING );
     872             :             }
     873             :         }
     874             : 
     875           0 :         if( !rSource.isEmpty() )
     876             :         {
     877             :             // we write the module in ANSI-charset, but with
     878             :             // the system new line.
     879           0 :             const OString sSource(OUStringToOString(rSource, eDestEnc));
     880           0 :             rStrm.WriteCharPtr( sSource.getStr() ).WriteCharPtr( SAL_NEWLINE_STRING );
     881             :         }
     882           0 :         rStrm.WriteCharPtr( SAL_NEWLINE_STRING );
     883             : 
     884           0 :         if( JAVASCRIPT != eScriptType )
     885             :         {
     886             :             // MIB/MM: if it is not StarBasic, a // could be wrong.
     887             :             // As the comment is removed during reading, it is not helping us....
     888           0 :             rStrm.WriteCharPtr( STARBASIC == eScriptType ? "' -->" : "// -->" )
     889           0 :                  .WriteCharPtr( SAL_NEWLINE_STRING );
     890             :         }
     891             :     }
     892             : 
     893           0 :     HTMLOutFuncs::Out_AsciiTag( rStrm, OOO_STRING_SVTOOLS_HTML_script, false );
     894             : 
     895           0 :     return rStrm;
     896             : }
     897             : 
     898             : 
     899           0 : SvStream& HTMLOutFuncs::Out_Events( SvStream& rStrm,
     900             :                                     const SvxMacroTableDtor& rMacroTable,
     901             :                                     const HTMLOutEvent *pEventTable,
     902             :                                     bool bOutStarBasic,
     903             :                                     rtl_TextEncoding eDestEnc,
     904             :                                     OUString *pNonConvertableChars )
     905             : {
     906           0 :     sal_uInt16 i=0;
     907           0 :     while( pEventTable[i].pBasicName || pEventTable[i].pJavaName )
     908             :     {
     909             :         const SvxMacro *pMacro =
     910           0 :             rMacroTable.Get( pEventTable[i].nEvent );
     911             : 
     912           0 :         if( pMacro && pMacro->HasMacro() &&
     913           0 :             ( JAVASCRIPT == pMacro->GetScriptType() || bOutStarBasic ))
     914             :         {
     915           0 :             const sal_Char *pStr = STARBASIC == pMacro->GetScriptType()
     916           0 :                 ? pEventTable[i].pBasicName
     917           0 :                 : pEventTable[i].pJavaName;
     918             : 
     919           0 :             if( pStr )
     920             :             {
     921           0 :                 OStringBuffer sOut;
     922           0 :                 sOut.append(' ').append(pStr).append("=\"");
     923           0 :                 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     924             : 
     925           0 :                 Out_String( rStrm, pMacro->GetMacName(), eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     926             :             }
     927             :         }
     928           0 :         i++;
     929             :     }
     930             : 
     931           0 :     return rStrm;
     932             : }
     933             : 
     934         150 : OString HTMLOutFuncs::CreateTableDataOptionsValNum(
     935             :             bool bValue,
     936             :             double fVal, sal_uLong nFormat, SvNumberFormatter& rFormatter,
     937             :             rtl_TextEncoding eDestEnc, OUString* pNonConvertableChars)
     938             : {
     939         150 :     OStringBuffer aStrTD;
     940             : 
     941         150 :     if ( bValue )
     942             :     {
     943             :         // printf / scanf is not precise enough
     944          20 :         OUString aValStr;
     945          20 :         rFormatter.GetInputLineString( fVal, 0, aValStr );
     946          40 :         OString sTmp(OUStringToOString(aValStr, eDestEnc));
     947          20 :         aStrTD.append(' ').
     948          20 :             append(OOO_STRING_SVTOOLS_HTML_O_SDval).
     949          20 :             append("=\"").
     950          40 :             append(sTmp).append('\"');
     951             :     }
     952         150 :     if ( bValue || nFormat )
     953             :     {
     954          20 :         aStrTD.append(' ').
     955          20 :             append(OOO_STRING_SVTOOLS_HTML_O_SDnum).
     956          20 :             append("=\"").
     957             :             append(static_cast<sal_Int32>(
     958          40 :                 Application::GetSettings().GetLanguageTag().getLanguageType())).
     959          20 :             append(';'); // Language for Format 0
     960          20 :         if ( nFormat )
     961             :         {
     962           0 :             OString aNumStr;
     963             :             LanguageType nLang;
     964           0 :             const SvNumberformat* pFormatEntry = rFormatter.GetEntry( nFormat );
     965           0 :             if ( pFormatEntry )
     966             :             {
     967           0 :                 aNumStr = ConvertStringToHTML( pFormatEntry->GetFormatstring(),
     968           0 :                     eDestEnc, pNonConvertableChars );
     969           0 :                 nLang = pFormatEntry->GetLanguage();
     970             :             }
     971             :             else
     972           0 :                 nLang = LANGUAGE_SYSTEM;
     973           0 :             aStrTD.append(static_cast<sal_Int32>(nLang)).append(';').
     974           0 :                 append(aNumStr);
     975             :         }
     976          20 :         aStrTD.append('\"');
     977             :     }
     978         150 :     return aStrTD.makeStringAndClear();
     979             : }
     980             : 
     981           4 : void HtmlWriterHelper::applyColor(HtmlWriter& rHtmlWriter, const OString &aAttributeName, const Color& rColor)
     982             : {
     983           4 :     OStringBuffer sBuffer;
     984             : 
     985           4 :     if( rColor.GetColor() == COL_AUTO )
     986             :     {
     987           0 :         sBuffer.append("#000000");
     988             :     }
     989             :     else
     990             :     {
     991           4 :         sBuffer.append('#');
     992           4 :         std::ostringstream sStringStream;
     993             :         sStringStream
     994           4 :             << std::right
     995           8 :             << std::setfill('0')
     996           8 :             << std::setw(6)
     997           4 :             << std::hex
     998           8 :             << rColor.GetRGBColor();
     999           4 :         sBuffer.append(sStringStream.str().c_str());
    1000             :     }
    1001             : 
    1002           4 :     rHtmlWriter.attribute(aAttributeName, sBuffer.makeStringAndClear());
    1003           4 : }
    1004             : 
    1005             : 
    1006           0 : void HtmlWriterHelper::applyEvents(HtmlWriter& rHtmlWriter, const SvxMacroTableDtor& rMacroTable, const HTMLOutEvent* pEventTable, bool bOutStarBasic)
    1007             : {
    1008           0 :     sal_uInt16 i = 0;
    1009           0 :     while (pEventTable[i].pBasicName || pEventTable[i].pJavaName)
    1010             :     {
    1011           0 :         const SvxMacro* pMacro = rMacroTable.Get(pEventTable[i].nEvent);
    1012             : 
    1013           0 :         if (pMacro && pMacro->HasMacro() && (JAVASCRIPT == pMacro->GetScriptType() || bOutStarBasic))
    1014             :         {
    1015           0 :             const sal_Char* pAttributeName = NULL;
    1016           0 :             if (STARBASIC == pMacro->GetScriptType())
    1017           0 :                 pAttributeName = pEventTable[i].pBasicName;
    1018             :             else
    1019           0 :                 pAttributeName = pEventTable[i].pJavaName;
    1020             : 
    1021           0 :             if (pAttributeName)
    1022             :             {
    1023           0 :                 rHtmlWriter.attribute(pAttributeName, OUStringToOString(pMacro->GetMacName(), RTL_TEXTENCODING_UTF8));
    1024             :             }
    1025             :         }
    1026           0 :         i++;
    1027             :     }
    1028        1227 : }
    1029             : 
    1030             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10