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