LCOV - code coverage report
Current view: top level - svtools/source/svhtml - htmlout.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 200 611 32.7 %
Date: 2015-06-13 12:38:46 Functions: 14 18 77.8 %
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        2324 : HTMLOutContext::HTMLOutContext( rtl_TextEncoding eDestEnc )
      40             : {
      41             :     m_eDestEnc = RTL_TEXTENCODING_DONTKNOW == eDestEnc
      42             :                     ? osl_getThreadTextEncoding()
      43        2324 :                     : eDestEnc;
      44             : 
      45        2324 :     m_hConv = rtl_createUnicodeToTextConverter( eDestEnc );
      46             :     DBG_ASSERT( m_hConv,
      47             :         "HTMLOutContext::HTMLOutContext: no converter for source encoding" );
      48        2324 :     m_hContext = m_hConv ? rtl_createUnicodeToTextContext( m_hConv )
      49        4648 :                      : reinterpret_cast<rtl_TextToUnicodeContext>(1);
      50        2324 : }
      51             : 
      52        2324 : HTMLOutContext::~HTMLOutContext()
      53             : {
      54        2324 :     rtl_destroyUnicodeToTextContext( m_hConv, m_hContext );
      55        2324 :     rtl_destroyUnicodeToTextConverter( m_hConv );
      56        2324 : }
      57             : 
      58       17492 : static const sal_Char *lcl_svhtml_GetEntityForChar( sal_Unicode c,
      59             :                                              rtl_TextEncoding eDestEnc )
      60             : {
      61       17492 :     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       17492 :     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       17492 :     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           2 :     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       17492 :     if( !pStr &&
     328       17490 :         ( eDestEnc != RTL_TEXTENCODING_ISO_8859_7 ) &&
     329             :         ( eDestEnc != RTL_TEXTENCODING_MS_1253 ) )
     330             :     {
     331       17490 :         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       17492 :     return pStr;
     389             : }
     390             : 
     391       17497 : static OString lcl_ConvertCharToHTML( sal_Unicode c,
     392             :                             HTMLOutContext& rContext,
     393             :                             OUString *pNonConvertableChars )
     394             : {
     395       17497 :     OStringBuffer aDest;
     396             :     DBG_ASSERT( RTL_TEXTENCODING_DONTKNOW != rContext.m_eDestEnc,
     397             :                     "wrong destination encoding" );
     398       17497 :     const sal_Char *pStr = 0;
     399       17497 :     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       17497 :         if( c < 128 || RTL_TEXTENCODING_UTF8 != rContext.m_eDestEnc )
     416       17492 :             pStr = lcl_svhtml_GetEntityForChar( c, rContext.m_eDestEnc );
     417       17497 :         break;
     418             :     }
     419             : 
     420             :     sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
     421       17497 :     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       17497 :                         RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
     427       17497 :     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           2 :                             &nInfo, &nSrcChars );
     434             :         DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
     435           2 :         sal_Char *pBuffer = cBuffer;
     436           4 :         while( nLen-- )
     437           0 :             aDest.append(*pBuffer++);
     438           2 :         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       17495 :                                                   &nInfo, &nSrcChars );
     447       17495 :         if( nLen > 0 && (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0 )
     448             :         {
     449       17495 :             sal_Char *pBuffer = cBuffer;
     450       52492 :             while( nLen-- )
     451       34997 :                 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[callee_ptr_arith]
     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       17497 :     return aDest.makeStringAndClear();
     477             : }
     478             : 
     479        2350 : static OString lcl_FlushToAscii( HTMLOutContext& rContext )
     480             : {
     481        2350 :     OStringBuffer aDest;
     482             : 
     483        2350 :     sal_Unicode c = 0;
     484             :     sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
     485        2350 :     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        2350 :                         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        2350 :                         &nInfo, &nSrcChars );
     496             :     DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
     497        2350 :     sal_Char *pBuffer = cBuffer;
     498        4700 :     while( nLen-- )
     499           0 :         aDest.append(*pBuffer++);
     500        2350 :     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        1040 : SvStream& HTMLOutFuncs::Out_AsciiTag( SvStream& rStream, const sal_Char *pStr,
     516             :                                       bool bOn, rtl_TextEncoding )
     517             : {
     518        1040 :     if(bOn)
     519         209 :         rStream.WriteCharPtr("<");
     520             :     else
     521         831 :         rStream.WriteCharPtr("</");
     522             : 
     523        1040 :     rStream.WriteCharPtr(pStr).WriteChar('>');
     524             : 
     525        1040 :     return rStream;
     526             : }
     527             : 
     528       17497 : SvStream& HTMLOutFuncs::Out_Char( SvStream& rStream, sal_Unicode c,
     529             :                                   HTMLOutContext& rContext,
     530             :                                   OUString *pNonConvertableChars )
     531             : {
     532       17497 :     OString sOut = lcl_ConvertCharToHTML( c, rContext, pNonConvertableChars );
     533       17497 :     rStream.WriteCharPtr( sOut.getStr() );
     534       17497 :     return rStream;
     535             : }
     536             : 
     537        2033 : SvStream& HTMLOutFuncs::Out_String( SvStream& rStream, const OUString& rOUStr,
     538             :                                     rtl_TextEncoding eDestEnc,
     539             :                                     OUString *pNonConvertableChars )
     540             : {
     541        2033 :     HTMLOutContext aContext( eDestEnc );
     542        2033 :     sal_Int32 nLen = rOUStr.getLength();
     543       19199 :     for( sal_Int32 n = 0; n < nLen; n++ )
     544       17166 :         HTMLOutFuncs::Out_Char( rStream, rOUStr[n],
     545       17166 :                                 aContext, pNonConvertableChars );
     546        2033 :     HTMLOutFuncs::FlushToAscii( rStream, aContext );
     547        2033 :     return rStream;
     548             : }
     549             : 
     550        2350 : SvStream& HTMLOutFuncs::FlushToAscii( SvStream& rStream,
     551             :                                        HTMLOutContext& rContext )
     552             : {
     553        2350 :     OString sOut = lcl_FlushToAscii( rContext );
     554             : 
     555        2350 :     if (!sOut.isEmpty())
     556           0 :         rStream.WriteCharPtr( sOut.getStr() );
     557             : 
     558        2350 :     return rStream;
     559             : }
     560             : 
     561         825 : SvStream& HTMLOutFuncs::Out_Hex( SvStream& rStream, sal_uLong nHex, sal_uInt8 nLen,
     562             :                                    rtl_TextEncoding )
     563             : {                                                  // in einen Stream aus
     564         825 :     sal_Char aNToABuf[] = "0000000000000000";
     565             : 
     566             :     DBG_ASSERT( nLen < sizeof(aNToABuf), "zu viele Stellen" );
     567         825 :     if( nLen>=sizeof(aNToABuf) )
     568           0 :         nLen = (sizeof(aNToABuf)-1);
     569             : 
     570             :     // set pointer to end of buffer
     571         825 :     sal_Char *pStr = aNToABuf + (sizeof(aNToABuf)-1);
     572        2475 :     for( sal_uInt8 n = 0; n < nLen; ++n )
     573             :     {
     574        1650 :         *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
     575        1650 :         if( *pStr > '9' )
     576        1531 :             *pStr += 39;
     577        1650 :         nHex >>= 4;
     578             :     }
     579         825 :     return rStream.WriteCharPtr( pStr );
     580             : }
     581             : 
     582             : 
     583         275 : SvStream& HTMLOutFuncs::Out_Color( SvStream& rStream, const Color& rColor,
     584             :                                    rtl_TextEncoding )
     585             : {
     586         275 :     rStream.WriteCharPtr( "\"#" );
     587         275 :     if( rColor.GetColor() == COL_AUTO )
     588             :     {
     589           0 :         rStream.WriteCharPtr( "000000" );
     590             :     }
     591             :     else
     592             :     {
     593         275 :         Out_Hex( rStream, rColor.GetRed(), 2 );
     594         275 :         Out_Hex( rStream, rColor.GetGreen(), 2 );
     595         275 :         Out_Hex( rStream, rColor.GetBlue(), 2 );
     596             :     }
     597         275 :     rStream.WriteChar( '\"' );
     598             : 
     599         275 :     return rStream;
     600             : }
     601             : 
     602           1 : 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           1 :     if( RTL_TEXTENCODING_DONTKNOW == eDestEnc )
     615           0 :         eDestEnc = osl_getThreadTextEncoding();
     616             : 
     617           1 :     const OUString& rOutName = !rName.isEmpty() ? rName : rIMap.GetName();
     618             :     DBG_ASSERT( !rOutName.isEmpty(), "Kein ImageMap-Name" );
     619           1 :     if( rOutName.isEmpty() )
     620           0 :         return rStream;
     621             : 
     622           1 :     OStringBuffer sOut;
     623           1 :     sOut.append('<')
     624           1 :         .append(OOO_STRING_SVTOOLS_HTML_map)
     625           1 :         .append(' ')
     626           1 :         .append(OOO_STRING_SVTOOLS_HTML_O_name)
     627           1 :         .append("=\"");
     628           1 :     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     629           1 :     Out_String( rStream, rOutName, eDestEnc, pNonConvertableChars );
     630           1 :     rStream.WriteCharPtr( "\">" );
     631             : 
     632           2 :     for( size_t i=0; i<rIMap.GetIMapObjectCount(); i++ )
     633             :     {
     634           1 :         const IMapObject* pObj = rIMap.GetIMapObject( i );
     635             :         DBG_ASSERT( pObj, "Wo ist das ImageMap-Object?" );
     636             : 
     637           1 :         if( pObj )
     638             :         {
     639           1 :             const sal_Char *pShape = 0;
     640           1 :             OString aCoords;
     641           1 :             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           1 :                         static_cast<const IMapPolygonObject *>(pObj);
     682           1 :                     pShape= OOO_STRING_SVTOOLS_HTML_SH_poly;
     683           1 :                     Polygon aPoly( pPolyObj->GetPolygon() );
     684           1 :                     sal_uInt16 nCount = aPoly.GetSize();
     685           2 :                     OStringBuffer aTmpBuf;
     686           1 :                     if( nCount>0 )
     687             :                     {
     688           1 :                         const Point& rPoint = aPoly[0];
     689           1 :                         aTmpBuf.append(static_cast<sal_Int32>(rPoint.X()))
     690           1 :                             .append(',')
     691           2 :                             .append(static_cast<sal_Int32>(rPoint.Y()));
     692             :                     }
     693          97 :                     for( sal_uInt16 j=1; j<nCount; j++ )
     694             :                     {
     695          96 :                         const Point& rPoint = aPoly[j];
     696          96 :                         aTmpBuf.append(',')
     697         192 :                             .append(static_cast<sal_Int32>(rPoint.X()))
     698          96 :                             .append(',')
     699         192 :                             .append(static_cast<sal_Int32>(rPoint.Y()));
     700             :                     }
     701           2 :                     aCoords = aTmpBuf.makeStringAndClear();
     702             :                 }
     703           1 :                 break;
     704             :             default:
     705             :                 DBG_ASSERT( pShape, "unbekanntes IMapObject" );
     706           0 :                 break;
     707             :             }
     708             : 
     709           1 :             if( pShape )
     710             :             {
     711           1 :                 if( pDelim )
     712           1 :                     rStream.WriteCharPtr( pDelim );
     713           1 :                 if( pIndentArea )
     714           1 :                     rStream.WriteCharPtr( pIndentArea );
     715             : 
     716           1 :                 sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_area)
     717           1 :                     .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_shape)
     718           1 :                     .append('=').append(pShape).append(' ')
     719           1 :                     .append(OOO_STRING_SVTOOLS_HTML_O_coords).append("=\"")
     720           1 :                     .append(aCoords).append("\" ");
     721           1 :                 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     722             : 
     723           1 :                 OUString aURL( pObj->GetURL() );
     724           1 :                 if( !aURL.isEmpty() && pObj->IsActive() )
     725             :                 {
     726           2 :                     aURL = URIHelper::simpleNormalizedMakeRelative(
     727           1 :                         rBaseURL, aURL );
     728           1 :                     sOut.append(OOO_STRING_SVTOOLS_HTML_O_href).append("=\"");
     729           1 :                     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     730           1 :                     Out_String( rStream, aURL, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     731             :                 }
     732             :                 else
     733           0 :                     rStream.WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_nohref );
     734             : 
     735           1 :                 const OUString& rObjName = pObj->GetName();
     736           1 :                 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           1 :                 const OUString& rTarget = pObj->GetTarget();
     745           1 :                 if( !rTarget.isEmpty() && pObj->IsActive() )
     746             :                 {
     747           1 :                     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_target)
     748           1 :                         .append("=\"");
     749           1 :                     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     750           1 :                     Out_String( rStream, rTarget, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     751             :                 }
     752             : 
     753           2 :                 OUString rDesc( pObj->GetAltText() );
     754           1 :                 if( rDesc.isEmpty() )
     755           0 :                     rDesc = pObj->GetDesc();
     756             : 
     757           1 :                 if( !rDesc.isEmpty() )
     758             :                 {
     759           1 :                     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_alt)
     760           1 :                         .append("=\"");
     761           1 :                     rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
     762           1 :                     Out_String( rStream, rDesc, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
     763             :                 }
     764             : 
     765           1 :                 const SvxMacroTableDtor& rMacroTab = pObj->GetMacroTable();
     766           1 :                 if( pEventTable && !rMacroTab.empty() )
     767             :                     Out_Events( rStream, rMacroTab, pEventTable,
     768           0 :                                 bOutStarBasic, eDestEnc, pNonConvertableChars );
     769             : 
     770           2 :                 rStream.WriteChar( '>' );
     771           1 :             }
     772             :         }
     773             : 
     774             :     }
     775             : 
     776           1 :     if( pDelim )
     777           1 :         rStream.WriteCharPtr( pDelim );
     778           1 :     if( pIndentMap )
     779           1 :         rStream.WriteCharPtr( pIndentMap );
     780           1 :     Out_AsciiTag( rStream, OOO_STRING_SVTOOLS_HTML_map, false );
     781             : 
     782           1 :     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          75 : OString HTMLOutFuncs::CreateTableDataOptionsValNum(
     935             :             bool bValue,
     936             :             double fVal, sal_uLong nFormat, SvNumberFormatter& rFormatter,
     937             :             rtl_TextEncoding eDestEnc, OUString* pNonConvertableChars)
     938             : {
     939          75 :     OStringBuffer aStrTD;
     940             : 
     941          75 :     if ( bValue )
     942             :     {
     943             :         // printf / scanf is not precise enough
     944          10 :         OUString aValStr;
     945          10 :         rFormatter.GetInputLineString( fVal, 0, aValStr );
     946          20 :         OString sTmp(OUStringToOString(aValStr, eDestEnc));
     947          10 :         aStrTD.append(' ').
     948          10 :             append(OOO_STRING_SVTOOLS_HTML_O_SDval).
     949          10 :             append("=\"").
     950          20 :             append(sTmp).append('\"');
     951             :     }
     952          75 :     if ( bValue || nFormat )
     953             :     {
     954          10 :         aStrTD.append(' ').
     955          10 :             append(OOO_STRING_SVTOOLS_HTML_O_SDnum).
     956          10 :             append("=\"").
     957             :             append(static_cast<sal_Int32>(
     958          20 :                 Application::GetSettings().GetLanguageTag().getLanguageType())).
     959          10 :             append(';'); // Language for Format 0
     960          10 :         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          10 :         aStrTD.append('\"');
     977             :     }
     978          75 :     return aStrTD.makeStringAndClear();
     979             : }
     980             : 
     981           1 : void HtmlWriterHelper::applyColor(HtmlWriter& rHtmlWriter, const OString &aAttributeName, const Color& rColor)
     982             : {
     983           1 :     OStringBuffer sBuffer;
     984             : 
     985           1 :     if( rColor.GetColor() == COL_AUTO )
     986             :     {
     987           0 :         sBuffer.append("#000000");
     988             :     }
     989             :     else
     990             :     {
     991           1 :         sBuffer.append('#');
     992           1 :         std::ostringstream sStringStream;
     993             :         sStringStream
     994           1 :             << std::right
     995           2 :             << std::setfill('0')
     996           2 :             << std::setw(6)
     997           1 :             << std::hex
     998           2 :             << rColor.GetRGBColor();
     999           1 :         sBuffer.append(sStringStream.str().c_str());
    1000             :     }
    1001             : 
    1002           1 :     rHtmlWriter.attribute(aAttributeName, sBuffer.makeStringAndClear());
    1003           1 : }
    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           0 : }
    1029             : 
    1030             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11