Bump version to 5.0-14
[LibreOffice.git] / svtools / source / svhtml / htmlout.cxx
blobb88d3880b2365168e1b75f4bc6fb446a36a41d4f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
35 #include <sstream>
37 #define TXTCONV_BUFFER_SIZE 20
39 HTMLOutContext::HTMLOutContext( rtl_TextEncoding eDestEnc )
41 m_eDestEnc = RTL_TEXTENCODING_DONTKNOW == eDestEnc
42 ? osl_getThreadTextEncoding()
43 : eDestEnc;
45 m_hConv = rtl_createUnicodeToTextConverter( eDestEnc );
46 DBG_ASSERT( m_hConv,
47 "HTMLOutContext::HTMLOutContext: no converter for source encoding" );
48 m_hContext = m_hConv ? rtl_createUnicodeToTextContext( m_hConv )
49 : reinterpret_cast<rtl_TextToUnicodeContext>(1);
52 HTMLOutContext::~HTMLOutContext()
54 rtl_destroyUnicodeToTextContext( m_hConv, m_hContext );
55 rtl_destroyUnicodeToTextConverter( m_hConv );
58 static const sal_Char *lcl_svhtml_GetEntityForChar( sal_Unicode c,
59 rtl_TextEncoding eDestEnc )
61 const sal_Char* pStr = 0;
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.
67 if( eDestEnc == RTL_TEXTENCODING_ISO_8859_2 || eDestEnc == RTL_TEXTENCODING_MS_1250 )
69 // Don't handle the following characters for Easter European (ISO-8859-2).
70 switch ( c )
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 return pStr;
109 // TODO: handle more special cases for other code pages.
111 switch( c )
113 // case '\x0a': return HTMLOutFuncs::Out_Tag( rStream, OOO_STRING_SVTOOLS_HTML_linebreak );
115 case '<': pStr = OOO_STRING_SVTOOLS_HTML_C_lt; break;
116 case '>': pStr = OOO_STRING_SVTOOLS_HTML_C_gt; break;
117 case '&': pStr = OOO_STRING_SVTOOLS_HTML_C_amp; break;
118 case '"': pStr = OOO_STRING_SVTOOLS_HTML_C_quot; break;
120 case 161: pStr = OOO_STRING_SVTOOLS_HTML_S_iexcl; break;
121 case 162: pStr = OOO_STRING_SVTOOLS_HTML_S_cent; break;
122 case 163: pStr = OOO_STRING_SVTOOLS_HTML_S_pound; break;
123 case 164: pStr = OOO_STRING_SVTOOLS_HTML_S_curren; break;
124 case 165: pStr = OOO_STRING_SVTOOLS_HTML_S_yen; break;
125 case 166: pStr = OOO_STRING_SVTOOLS_HTML_S_brvbar; break;
126 case 167: pStr = OOO_STRING_SVTOOLS_HTML_S_sect; break;
127 case 168: pStr = OOO_STRING_SVTOOLS_HTML_S_uml; break;
128 case 169: pStr = OOO_STRING_SVTOOLS_HTML_S_copy; break;
129 case 170: pStr = OOO_STRING_SVTOOLS_HTML_S_ordf; break;
130 case 171: pStr = OOO_STRING_SVTOOLS_HTML_S_laquo; break;
131 case 172: pStr = OOO_STRING_SVTOOLS_HTML_S_not; break;
132 case 174: pStr = OOO_STRING_SVTOOLS_HTML_S_reg; break;
133 case 175: pStr = OOO_STRING_SVTOOLS_HTML_S_macr; break;
134 case 176: pStr = OOO_STRING_SVTOOLS_HTML_S_deg; break;
135 case 177: pStr = OOO_STRING_SVTOOLS_HTML_S_plusmn; break;
136 case 178: pStr = OOO_STRING_SVTOOLS_HTML_S_sup2; break;
137 case 179: pStr = OOO_STRING_SVTOOLS_HTML_S_sup3; break;
138 case 180: pStr = OOO_STRING_SVTOOLS_HTML_S_acute; break;
139 case 181: pStr = OOO_STRING_SVTOOLS_HTML_S_micro; break;
140 case 182: pStr = OOO_STRING_SVTOOLS_HTML_S_para; break;
141 case 183: pStr = OOO_STRING_SVTOOLS_HTML_S_middot; break;
142 case 184: pStr = OOO_STRING_SVTOOLS_HTML_S_cedil; break;
143 case 185: pStr = OOO_STRING_SVTOOLS_HTML_S_sup1; break;
144 case 186: pStr = OOO_STRING_SVTOOLS_HTML_S_ordm; break;
145 case 187: pStr = OOO_STRING_SVTOOLS_HTML_S_raquo; break;
146 case 188: pStr = OOO_STRING_SVTOOLS_HTML_S_frac14; break;
147 case 189: pStr = OOO_STRING_SVTOOLS_HTML_S_frac12; break;
148 case 190: pStr = OOO_STRING_SVTOOLS_HTML_S_frac34; break;
149 case 191: pStr = OOO_STRING_SVTOOLS_HTML_S_iquest; break;
151 case 192: pStr = OOO_STRING_SVTOOLS_HTML_C_Agrave; break;
152 case 193: pStr = OOO_STRING_SVTOOLS_HTML_C_Aacute; break;
153 case 194: pStr = OOO_STRING_SVTOOLS_HTML_C_Acirc; break;
154 case 195: pStr = OOO_STRING_SVTOOLS_HTML_C_Atilde; break;
155 case 196: pStr = OOO_STRING_SVTOOLS_HTML_C_Auml; break;
156 case 197: pStr = OOO_STRING_SVTOOLS_HTML_C_Aring; break;
157 case 198: pStr = OOO_STRING_SVTOOLS_HTML_C_AElig; break;
158 case 199: pStr = OOO_STRING_SVTOOLS_HTML_C_Ccedil; break;
159 case 200: pStr = OOO_STRING_SVTOOLS_HTML_C_Egrave; break;
160 case 201: pStr = OOO_STRING_SVTOOLS_HTML_C_Eacute; break;
161 case 202: pStr = OOO_STRING_SVTOOLS_HTML_C_Ecirc; break;
162 case 203: pStr = OOO_STRING_SVTOOLS_HTML_C_Euml; break;
163 case 204: pStr = OOO_STRING_SVTOOLS_HTML_C_Igrave; break;
164 case 205: pStr = OOO_STRING_SVTOOLS_HTML_C_Iacute; break;
165 case 206: pStr = OOO_STRING_SVTOOLS_HTML_C_Icirc; break;
166 case 207: pStr = OOO_STRING_SVTOOLS_HTML_C_Iuml; break;
167 case 208: pStr = OOO_STRING_SVTOOLS_HTML_C_ETH; break;
168 case 209: pStr = OOO_STRING_SVTOOLS_HTML_C_Ntilde; break;
169 case 210: pStr = OOO_STRING_SVTOOLS_HTML_C_Ograve; break;
170 case 211: pStr = OOO_STRING_SVTOOLS_HTML_C_Oacute; break;
171 case 212: pStr = OOO_STRING_SVTOOLS_HTML_C_Ocirc; break;
172 case 213: pStr = OOO_STRING_SVTOOLS_HTML_C_Otilde; break;
173 case 214: pStr = OOO_STRING_SVTOOLS_HTML_C_Ouml; break;
174 case 215: pStr = OOO_STRING_SVTOOLS_HTML_S_times; break;
175 case 216: pStr = OOO_STRING_SVTOOLS_HTML_C_Oslash; break;
176 case 217: pStr = OOO_STRING_SVTOOLS_HTML_C_Ugrave; break;
177 case 218: pStr = OOO_STRING_SVTOOLS_HTML_C_Uacute; break;
178 case 219: pStr = OOO_STRING_SVTOOLS_HTML_C_Ucirc; break;
179 case 220: pStr = OOO_STRING_SVTOOLS_HTML_C_Uuml; break;
180 case 221: pStr = OOO_STRING_SVTOOLS_HTML_C_Yacute; break;
182 case 222: pStr = OOO_STRING_SVTOOLS_HTML_C_THORN; break;
183 case 223: pStr = OOO_STRING_SVTOOLS_HTML_C_szlig; break;
185 case 224: pStr = OOO_STRING_SVTOOLS_HTML_S_agrave; break;
186 case 225: pStr = OOO_STRING_SVTOOLS_HTML_S_aacute; break;
187 case 226: pStr = OOO_STRING_SVTOOLS_HTML_S_acirc; break;
188 case 227: pStr = OOO_STRING_SVTOOLS_HTML_S_atilde; break;
189 case 228: pStr = OOO_STRING_SVTOOLS_HTML_S_auml; break;
190 case 229: pStr = OOO_STRING_SVTOOLS_HTML_S_aring; break;
191 case 230: pStr = OOO_STRING_SVTOOLS_HTML_S_aelig; break;
192 case 231: pStr = OOO_STRING_SVTOOLS_HTML_S_ccedil; break;
193 case 232: pStr = OOO_STRING_SVTOOLS_HTML_S_egrave; break;
194 case 233: pStr = OOO_STRING_SVTOOLS_HTML_S_eacute; break;
195 case 234: pStr = OOO_STRING_SVTOOLS_HTML_S_ecirc; break;
196 case 235: pStr = OOO_STRING_SVTOOLS_HTML_S_euml; break;
197 case 236: pStr = OOO_STRING_SVTOOLS_HTML_S_igrave; break;
198 case 237: pStr = OOO_STRING_SVTOOLS_HTML_S_iacute; break;
199 case 238: pStr = OOO_STRING_SVTOOLS_HTML_S_icirc; break;
200 case 239: pStr = OOO_STRING_SVTOOLS_HTML_S_iuml; break;
201 case 240: pStr = OOO_STRING_SVTOOLS_HTML_S_eth; break;
202 case 241: pStr = OOO_STRING_SVTOOLS_HTML_S_ntilde; break;
203 case 242: pStr = OOO_STRING_SVTOOLS_HTML_S_ograve; break;
204 case 243: pStr = OOO_STRING_SVTOOLS_HTML_S_oacute; break;
205 case 244: pStr = OOO_STRING_SVTOOLS_HTML_S_ocirc; break;
206 case 245: pStr = OOO_STRING_SVTOOLS_HTML_S_otilde; break;
207 case 246: pStr = OOO_STRING_SVTOOLS_HTML_S_ouml; break;
208 case 247: pStr = OOO_STRING_SVTOOLS_HTML_S_divide; break;
209 case 248: pStr = OOO_STRING_SVTOOLS_HTML_S_oslash; break;
210 case 249: pStr = OOO_STRING_SVTOOLS_HTML_S_ugrave; break;
211 case 250: pStr = OOO_STRING_SVTOOLS_HTML_S_uacute; break;
212 case 251: pStr = OOO_STRING_SVTOOLS_HTML_S_ucirc; break;
213 case 252: pStr = OOO_STRING_SVTOOLS_HTML_S_uuml; break;
214 case 253: pStr = OOO_STRING_SVTOOLS_HTML_S_yacute; break;
215 case 254: pStr = OOO_STRING_SVTOOLS_HTML_S_thorn; break;
216 case 255: pStr = OOO_STRING_SVTOOLS_HTML_S_yuml; break;
218 case 338: pStr = OOO_STRING_SVTOOLS_HTML_S_OElig; break;
219 case 339: pStr = OOO_STRING_SVTOOLS_HTML_S_oelig; break;
220 case 352: pStr = OOO_STRING_SVTOOLS_HTML_S_Scaron; break;
221 case 353: pStr = OOO_STRING_SVTOOLS_HTML_S_scaron; break;
222 case 376: pStr = OOO_STRING_SVTOOLS_HTML_S_Yuml; break;
223 case 402: pStr = OOO_STRING_SVTOOLS_HTML_S_fnof; break;
224 case 710: pStr = OOO_STRING_SVTOOLS_HTML_S_circ; break;
225 case 732: pStr = OOO_STRING_SVTOOLS_HTML_S_tilde; break;
227 // Greek chars are handled later,
228 // since they should *not* be transformed to entities
229 // when generating Greek text (== using Greek encoding)
231 case 8194: pStr = OOO_STRING_SVTOOLS_HTML_S_ensp; break;
232 case 8195: pStr = OOO_STRING_SVTOOLS_HTML_S_emsp; break;
233 case 8201: pStr = OOO_STRING_SVTOOLS_HTML_S_thinsp; break;
234 case 8204: pStr = OOO_STRING_SVTOOLS_HTML_S_zwnj; break;
235 case 8205: pStr = OOO_STRING_SVTOOLS_HTML_S_zwj; break;
236 case 8206: pStr = OOO_STRING_SVTOOLS_HTML_S_lrm; break;
237 case 8207: pStr = OOO_STRING_SVTOOLS_HTML_S_rlm; break;
238 case 8211: pStr = OOO_STRING_SVTOOLS_HTML_S_ndash; break;
239 case 8212: pStr = OOO_STRING_SVTOOLS_HTML_S_mdash; break;
240 case 8216: pStr = OOO_STRING_SVTOOLS_HTML_S_lsquo; break;
241 case 8217: pStr = OOO_STRING_SVTOOLS_HTML_S_rsquo; break;
242 case 8218: pStr = OOO_STRING_SVTOOLS_HTML_S_sbquo; break;
243 case 8220: pStr = OOO_STRING_SVTOOLS_HTML_S_ldquo; break;
244 case 8221: pStr = OOO_STRING_SVTOOLS_HTML_S_rdquo; break;
245 case 8222: pStr = OOO_STRING_SVTOOLS_HTML_S_bdquo; break;
246 case 8224: pStr = OOO_STRING_SVTOOLS_HTML_S_dagger; break;
247 case 8225: pStr = OOO_STRING_SVTOOLS_HTML_S_Dagger; break;
248 case 8226: pStr = OOO_STRING_SVTOOLS_HTML_S_bull; break;
249 case 8230: pStr = OOO_STRING_SVTOOLS_HTML_S_hellip; break;
250 case 8240: pStr = OOO_STRING_SVTOOLS_HTML_S_permil; break;
251 case 8242: pStr = OOO_STRING_SVTOOLS_HTML_S_prime; break;
252 case 8243: pStr = OOO_STRING_SVTOOLS_HTML_S_Prime; break;
253 case 8249: pStr = OOO_STRING_SVTOOLS_HTML_S_lsaquo; break;
254 case 8250: pStr = OOO_STRING_SVTOOLS_HTML_S_rsaquo; break;
255 case 8254: pStr = OOO_STRING_SVTOOLS_HTML_S_oline; break;
256 case 8260: pStr = OOO_STRING_SVTOOLS_HTML_S_frasl; break;
257 case 8364: pStr = OOO_STRING_SVTOOLS_HTML_S_euro; break;
258 case 8465: pStr = OOO_STRING_SVTOOLS_HTML_S_image; break;
259 case 8472: pStr = OOO_STRING_SVTOOLS_HTML_S_weierp; break;
260 case 8476: pStr = OOO_STRING_SVTOOLS_HTML_S_real; break;
261 case 8482: pStr = OOO_STRING_SVTOOLS_HTML_S_trade; break;
262 case 8501: pStr = OOO_STRING_SVTOOLS_HTML_S_alefsym; break;
263 case 8592: pStr = OOO_STRING_SVTOOLS_HTML_S_larr; break;
264 case 8593: pStr = OOO_STRING_SVTOOLS_HTML_S_uarr; break;
265 case 8594: pStr = OOO_STRING_SVTOOLS_HTML_S_rarr; break;
266 case 8595: pStr = OOO_STRING_SVTOOLS_HTML_S_darr; break;
267 case 8596: pStr = OOO_STRING_SVTOOLS_HTML_S_harr; break;
268 case 8629: pStr = OOO_STRING_SVTOOLS_HTML_S_crarr; break;
269 case 8656: pStr = OOO_STRING_SVTOOLS_HTML_S_lArr; break;
270 case 8657: pStr = OOO_STRING_SVTOOLS_HTML_S_uArr; break;
271 case 8658: pStr = OOO_STRING_SVTOOLS_HTML_S_rArr; break;
272 case 8659: pStr = OOO_STRING_SVTOOLS_HTML_S_dArr; break;
273 case 8660: pStr = OOO_STRING_SVTOOLS_HTML_S_hArr; break;
274 case 8704: pStr = OOO_STRING_SVTOOLS_HTML_S_forall; break;
275 case 8706: pStr = OOO_STRING_SVTOOLS_HTML_S_part; break;
276 case 8707: pStr = OOO_STRING_SVTOOLS_HTML_S_exist; break;
277 case 8709: pStr = OOO_STRING_SVTOOLS_HTML_S_empty; break;
278 case 8711: pStr = OOO_STRING_SVTOOLS_HTML_S_nabla; break;
279 case 8712: pStr = OOO_STRING_SVTOOLS_HTML_S_isin; break;
280 case 8713: pStr = OOO_STRING_SVTOOLS_HTML_S_notin; break;
281 case 8715: pStr = OOO_STRING_SVTOOLS_HTML_S_ni; break;
282 case 8719: pStr = OOO_STRING_SVTOOLS_HTML_S_prod; break;
283 case 8721: pStr = OOO_STRING_SVTOOLS_HTML_S_sum; break;
284 case 8722: pStr = OOO_STRING_SVTOOLS_HTML_S_minus; break;
285 case 8727: pStr = OOO_STRING_SVTOOLS_HTML_S_lowast; break;
286 case 8730: pStr = OOO_STRING_SVTOOLS_HTML_S_radic; break;
287 case 8733: pStr = OOO_STRING_SVTOOLS_HTML_S_prop; break;
288 case 8734: pStr = OOO_STRING_SVTOOLS_HTML_S_infin; break;
289 case 8736: pStr = OOO_STRING_SVTOOLS_HTML_S_ang; break;
290 case 8743: pStr = OOO_STRING_SVTOOLS_HTML_S_and; break;
291 case 8744: pStr = OOO_STRING_SVTOOLS_HTML_S_or; break;
292 case 8745: pStr = OOO_STRING_SVTOOLS_HTML_S_cap; break;
293 case 8746: pStr = OOO_STRING_SVTOOLS_HTML_S_cup; break;
294 case 8747: pStr = OOO_STRING_SVTOOLS_HTML_S_int; break;
295 case 8756: pStr = OOO_STRING_SVTOOLS_HTML_S_there4; break;
296 case 8764: pStr = OOO_STRING_SVTOOLS_HTML_S_sim; break;
297 case 8773: pStr = OOO_STRING_SVTOOLS_HTML_S_cong; break;
298 case 8776: pStr = OOO_STRING_SVTOOLS_HTML_S_asymp; break;
299 case 8800: pStr = OOO_STRING_SVTOOLS_HTML_S_ne; break;
300 case 8801: pStr = OOO_STRING_SVTOOLS_HTML_S_equiv; break;
301 case 8804: pStr = OOO_STRING_SVTOOLS_HTML_S_le; break;
302 case 8805: pStr = OOO_STRING_SVTOOLS_HTML_S_ge; break;
303 case 8834: pStr = OOO_STRING_SVTOOLS_HTML_S_sub; break;
304 case 8835: pStr = OOO_STRING_SVTOOLS_HTML_S_sup; break;
305 case 8836: pStr = OOO_STRING_SVTOOLS_HTML_S_nsub; break;
306 case 8838: pStr = OOO_STRING_SVTOOLS_HTML_S_sube; break;
307 case 8839: pStr = OOO_STRING_SVTOOLS_HTML_S_supe; break;
308 case 8853: pStr = OOO_STRING_SVTOOLS_HTML_S_oplus; break;
309 case 8855: pStr = OOO_STRING_SVTOOLS_HTML_S_otimes; break;
310 case 8869: pStr = OOO_STRING_SVTOOLS_HTML_S_perp; break;
311 case 8901: pStr = OOO_STRING_SVTOOLS_HTML_S_sdot; break;
312 case 8968: pStr = OOO_STRING_SVTOOLS_HTML_S_lceil; break;
313 case 8969: pStr = OOO_STRING_SVTOOLS_HTML_S_rceil; break;
314 case 8970: pStr = OOO_STRING_SVTOOLS_HTML_S_lfloor; break;
315 case 8971: pStr = OOO_STRING_SVTOOLS_HTML_S_rfloor; break;
316 case 9001: pStr = OOO_STRING_SVTOOLS_HTML_S_lang; break;
317 case 9002: pStr = OOO_STRING_SVTOOLS_HTML_S_rang; break;
318 case 9674: pStr = OOO_STRING_SVTOOLS_HTML_S_loz; break;
319 case 9824: pStr = OOO_STRING_SVTOOLS_HTML_S_spades; break;
320 case 9827: pStr = OOO_STRING_SVTOOLS_HTML_S_clubs; break;
321 case 9829: pStr = OOO_STRING_SVTOOLS_HTML_S_hearts; break;
322 case 9830: pStr = OOO_STRING_SVTOOLS_HTML_S_diams; break;
325 // Greek chars: if we do not produce a Greek encoding,
326 // transform them into entities
327 if( !pStr &&
328 ( eDestEnc != RTL_TEXTENCODING_ISO_8859_7 ) &&
329 ( eDestEnc != RTL_TEXTENCODING_MS_1253 ) )
331 switch( c )
333 case 913: pStr = OOO_STRING_SVTOOLS_HTML_S_Alpha; break;
334 case 914: pStr = OOO_STRING_SVTOOLS_HTML_S_Beta; break;
335 case 915: pStr = OOO_STRING_SVTOOLS_HTML_S_Gamma; break;
336 case 916: pStr = OOO_STRING_SVTOOLS_HTML_S_Delta; break;
337 case 917: pStr = OOO_STRING_SVTOOLS_HTML_S_Epsilon; break;
338 case 918: pStr = OOO_STRING_SVTOOLS_HTML_S_Zeta; break;
339 case 919: pStr = OOO_STRING_SVTOOLS_HTML_S_Eta; break;
340 case 920: pStr = OOO_STRING_SVTOOLS_HTML_S_Theta; break;
341 case 921: pStr = OOO_STRING_SVTOOLS_HTML_S_Iota; break;
342 case 922: pStr = OOO_STRING_SVTOOLS_HTML_S_Kappa; break;
343 case 923: pStr = OOO_STRING_SVTOOLS_HTML_S_Lambda; break;
344 case 924: pStr = OOO_STRING_SVTOOLS_HTML_S_Mu; break;
345 case 925: pStr = OOO_STRING_SVTOOLS_HTML_S_Nu; break;
346 case 926: pStr = OOO_STRING_SVTOOLS_HTML_S_Xi; break;
347 case 927: pStr = OOO_STRING_SVTOOLS_HTML_S_Omicron; break;
348 case 928: pStr = OOO_STRING_SVTOOLS_HTML_S_Pi; break;
349 case 929: pStr = OOO_STRING_SVTOOLS_HTML_S_Rho; break;
350 case 931: pStr = OOO_STRING_SVTOOLS_HTML_S_Sigma; break;
351 case 932: pStr = OOO_STRING_SVTOOLS_HTML_S_Tau; break;
352 case 933: pStr = OOO_STRING_SVTOOLS_HTML_S_Upsilon; break;
353 case 934: pStr = OOO_STRING_SVTOOLS_HTML_S_Phi; break;
354 case 935: pStr = OOO_STRING_SVTOOLS_HTML_S_Chi; break;
355 case 936: pStr = OOO_STRING_SVTOOLS_HTML_S_Psi; break;
356 case 937: pStr = OOO_STRING_SVTOOLS_HTML_S_Omega; break;
357 case 945: pStr = OOO_STRING_SVTOOLS_HTML_S_alpha; break;
358 case 946: pStr = OOO_STRING_SVTOOLS_HTML_S_beta; break;
359 case 947: pStr = OOO_STRING_SVTOOLS_HTML_S_gamma; break;
360 case 948: pStr = OOO_STRING_SVTOOLS_HTML_S_delta; break;
361 case 949: pStr = OOO_STRING_SVTOOLS_HTML_S_epsilon; break;
362 case 950: pStr = OOO_STRING_SVTOOLS_HTML_S_zeta; break;
363 case 951: pStr = OOO_STRING_SVTOOLS_HTML_S_eta; break;
364 case 952: pStr = OOO_STRING_SVTOOLS_HTML_S_theta; break;
365 case 953: pStr = OOO_STRING_SVTOOLS_HTML_S_iota; break;
366 case 954: pStr = OOO_STRING_SVTOOLS_HTML_S_kappa; break;
367 case 955: pStr = OOO_STRING_SVTOOLS_HTML_S_lambda; break;
368 case 956: pStr = OOO_STRING_SVTOOLS_HTML_S_mu; break;
369 case 957: pStr = OOO_STRING_SVTOOLS_HTML_S_nu; break;
370 case 958: pStr = OOO_STRING_SVTOOLS_HTML_S_xi; break;
371 case 959: pStr = OOO_STRING_SVTOOLS_HTML_S_omicron; break;
372 case 960: pStr = OOO_STRING_SVTOOLS_HTML_S_pi; break;
373 case 961: pStr = OOO_STRING_SVTOOLS_HTML_S_rho; break;
374 case 962: pStr = OOO_STRING_SVTOOLS_HTML_S_sigmaf; break;
375 case 963: pStr = OOO_STRING_SVTOOLS_HTML_S_sigma; break;
376 case 964: pStr = OOO_STRING_SVTOOLS_HTML_S_tau; break;
377 case 965: pStr = OOO_STRING_SVTOOLS_HTML_S_upsilon; break;
378 case 966: pStr = OOO_STRING_SVTOOLS_HTML_S_phi; break;
379 case 967: pStr = OOO_STRING_SVTOOLS_HTML_S_chi; break;
380 case 968: pStr = OOO_STRING_SVTOOLS_HTML_S_psi; break;
381 case 969: pStr = OOO_STRING_SVTOOLS_HTML_S_omega; break;
382 case 977: pStr = OOO_STRING_SVTOOLS_HTML_S_thetasym;break;
383 case 978: pStr = OOO_STRING_SVTOOLS_HTML_S_upsih; break;
384 case 982: pStr = OOO_STRING_SVTOOLS_HTML_S_piv; break;
388 return pStr;
391 static OString lcl_ConvertCharToHTML( sal_Unicode c,
392 HTMLOutContext& rContext,
393 OUString *pNonConvertableChars )
395 OStringBuffer aDest;
396 DBG_ASSERT( RTL_TEXTENCODING_DONTKNOW != rContext.m_eDestEnc,
397 "wrong destination encoding" );
398 const sal_Char *pStr = 0;
399 switch( c )
401 case 0xA0: // is a hard blank
402 pStr = OOO_STRING_SVTOOLS_HTML_S_nbsp;
403 break;
404 case 0x2011: // is a hard hyphen
405 pStr = "#8209";
406 break;
407 case 0xAD: // is a soft hyphen
408 pStr = OOO_STRING_SVTOOLS_HTML_S_shy;
409 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 if( c < 128 || RTL_TEXTENCODING_UTF8 != rContext.m_eDestEnc )
416 pStr = lcl_svhtml_GetEntityForChar( c, rContext.m_eDestEnc );
417 break;
420 sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
421 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 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
427 if( pStr )
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 &nInfo, &nSrcChars );
434 DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
435 sal_Char *pBuffer = cBuffer;
436 while( nLen-- )
437 aDest.append(*pBuffer++);
438 aDest.append('&').append(pStr).append(';');
440 else
442 sal_Size nLen = rtl_convertUnicodeToText( rContext.m_hConv,
443 rContext.m_hContext, &c, 1,
444 cBuffer, TXTCONV_BUFFER_SIZE,
445 nFlags,
446 &nInfo, &nSrcChars );
447 if( nLen > 0 && (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0 )
449 sal_Char *pBuffer = cBuffer;
450 while( nLen-- )
451 aDest.append(*pBuffer++);
453 else
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 &nInfo, &nSrcChars );
464 DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
465 sal_Char *pBuffer = cBuffer;
466 while( nLen-- )
467 aDest.append(*pBuffer++);
469 aDest.append('&').append('#').append(static_cast<sal_Int64>(c))
470 .append(';');
471 if( pNonConvertableChars &&
472 -1 == pNonConvertableChars->indexOf( c ) )
473 (*pNonConvertableChars) += OUString(c);
476 return aDest.makeStringAndClear();
479 static OString lcl_FlushToAscii( HTMLOutContext& rContext )
481 OStringBuffer aDest;
483 sal_Unicode c = 0;
484 sal_Char cBuffer[TXTCONV_BUFFER_SIZE];
485 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 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 &nInfo, &nSrcChars );
496 DBG_ASSERT( (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0, "HTMLOut: error while flushing" );
497 sal_Char *pBuffer = cBuffer;
498 while( nLen-- )
499 aDest.append(*pBuffer++);
500 return aDest.makeStringAndClear();
503 OString HTMLOutFuncs::ConvertStringToHTML( const OUString& rSrc,
504 rtl_TextEncoding eDestEnc, OUString *pNonConvertableChars )
506 HTMLOutContext aContext( eDestEnc );
507 OStringBuffer aDest;
508 for( sal_Int32 i=0, nLen = rSrc.getLength(); i < nLen; i++ )
509 aDest.append(lcl_ConvertCharToHTML(
510 rSrc[i], aContext, pNonConvertableChars));
511 aDest.append(lcl_FlushToAscii(aContext));
512 return aDest.makeStringAndClear();
515 SvStream& HTMLOutFuncs::Out_AsciiTag( SvStream& rStream, const sal_Char *pStr,
516 bool bOn, rtl_TextEncoding )
518 if(bOn)
519 rStream.WriteCharPtr("<");
520 else
521 rStream.WriteCharPtr("</");
523 rStream.WriteCharPtr(pStr).WriteChar('>');
525 return rStream;
528 SvStream& HTMLOutFuncs::Out_Char( SvStream& rStream, sal_Unicode c,
529 HTMLOutContext& rContext,
530 OUString *pNonConvertableChars )
532 OString sOut = lcl_ConvertCharToHTML( c, rContext, pNonConvertableChars );
533 rStream.WriteCharPtr( sOut.getStr() );
534 return rStream;
537 SvStream& HTMLOutFuncs::Out_String( SvStream& rStream, const OUString& rOUStr,
538 rtl_TextEncoding eDestEnc,
539 OUString *pNonConvertableChars )
541 HTMLOutContext aContext( eDestEnc );
542 sal_Int32 nLen = rOUStr.getLength();
543 for( sal_Int32 n = 0; n < nLen; n++ )
544 HTMLOutFuncs::Out_Char( rStream, rOUStr[n],
545 aContext, pNonConvertableChars );
546 HTMLOutFuncs::FlushToAscii( rStream, aContext );
547 return rStream;
550 SvStream& HTMLOutFuncs::FlushToAscii( SvStream& rStream,
551 HTMLOutContext& rContext )
553 OString sOut = lcl_FlushToAscii( rContext );
555 if (!sOut.isEmpty())
556 rStream.WriteCharPtr( sOut.getStr() );
558 return rStream;
561 SvStream& HTMLOutFuncs::Out_Hex( SvStream& rStream, sal_uLong nHex, sal_uInt8 nLen,
562 rtl_TextEncoding )
563 { // in einen Stream aus
564 sal_Char aNToABuf[] = "0000000000000000";
566 DBG_ASSERT( nLen < sizeof(aNToABuf), "zu viele Stellen" );
567 if( nLen>=sizeof(aNToABuf) )
568 nLen = (sizeof(aNToABuf)-1);
570 // set pointer to end of buffer
571 sal_Char *pStr = aNToABuf + (sizeof(aNToABuf)-1);
572 for( sal_uInt8 n = 0; n < nLen; ++n )
574 *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
575 if( *pStr > '9' )
576 *pStr += 39;
577 nHex >>= 4;
579 return rStream.WriteCharPtr( pStr );
583 SvStream& HTMLOutFuncs::Out_Color( SvStream& rStream, const Color& rColor,
584 rtl_TextEncoding )
586 rStream.WriteCharPtr( "\"#" );
587 if( rColor.GetColor() == COL_AUTO )
589 rStream.WriteCharPtr( "000000" );
591 else
593 Out_Hex( rStream, rColor.GetRed(), 2 );
594 Out_Hex( rStream, rColor.GetGreen(), 2 );
595 Out_Hex( rStream, rColor.GetBlue(), 2 );
597 rStream.WriteChar( '\"' );
599 return rStream;
602 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 )
614 if( RTL_TEXTENCODING_DONTKNOW == eDestEnc )
615 eDestEnc = osl_getThreadTextEncoding();
617 const OUString& rOutName = !rName.isEmpty() ? rName : rIMap.GetName();
618 DBG_ASSERT( !rOutName.isEmpty(), "Kein ImageMap-Name" );
619 if( rOutName.isEmpty() )
620 return rStream;
622 OStringBuffer sOut;
623 sOut.append('<')
624 .append(OOO_STRING_SVTOOLS_HTML_map)
625 .append(' ')
626 .append(OOO_STRING_SVTOOLS_HTML_O_name)
627 .append("=\"");
628 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
629 Out_String( rStream, rOutName, eDestEnc, pNonConvertableChars );
630 rStream.WriteCharPtr( "\">" );
632 for( sal_uInt16 i=0U; i<rIMap.GetIMapObjectCount(); i++ )
634 const IMapObject* pObj = rIMap.GetIMapObject( i );
635 DBG_ASSERT( pObj, "Wo ist das ImageMap-Object?" );
637 if( pObj )
639 const sal_Char *pShape = 0;
640 OString aCoords;
641 switch( pObj->GetType() )
643 case( IMAP_OBJ_RECTANGLE ):
645 const IMapRectangleObject* pRectObj =
646 static_cast<const IMapRectangleObject *>(pObj);
647 pShape = OOO_STRING_SVTOOLS_HTML_SH_rect;
648 Rectangle aRect( pRectObj->GetRectangle() );
650 aCoords = OStringBuffer()
651 .append(static_cast<sal_Int32>(aRect.Left()))
652 .append(',')
653 .append(static_cast<sal_Int32>(aRect.Top()))
654 .append(',')
655 .append(static_cast<sal_Int32>(aRect.Right()))
656 .append(',')
657 .append(static_cast<sal_Int32>(aRect.Bottom()))
658 .makeStringAndClear();
660 break;
661 case( IMAP_OBJ_CIRCLE ):
663 const IMapCircleObject* pCirc =
664 static_cast<const IMapCircleObject *>(pObj);
665 pShape= OOO_STRING_SVTOOLS_HTML_SH_circ;
666 Point aCenter( pCirc->GetCenter() );
667 long nOff = pCirc->GetRadius();
669 aCoords = OStringBuffer()
670 .append(static_cast<sal_Int32>(aCenter.X()))
671 .append(',')
672 .append(static_cast<sal_Int32>(aCenter.Y()))
673 .append(',')
674 .append(static_cast<sal_Int32>(nOff))
675 .makeStringAndClear();
677 break;
678 case( IMAP_OBJ_POLYGON ):
680 const IMapPolygonObject* pPolyObj =
681 static_cast<const IMapPolygonObject *>(pObj);
682 pShape= OOO_STRING_SVTOOLS_HTML_SH_poly;
683 Polygon aPoly( pPolyObj->GetPolygon() );
684 sal_uInt16 nCount = aPoly.GetSize();
685 OStringBuffer aTmpBuf;
686 if( nCount>0 )
688 const Point& rPoint = aPoly[0];
689 aTmpBuf.append(static_cast<sal_Int32>(rPoint.X()))
690 .append(',')
691 .append(static_cast<sal_Int32>(rPoint.Y()));
693 for( sal_uInt16 j=1; j<nCount; j++ )
695 const Point& rPoint = aPoly[j];
696 aTmpBuf.append(',')
697 .append(static_cast<sal_Int32>(rPoint.X()))
698 .append(',')
699 .append(static_cast<sal_Int32>(rPoint.Y()));
701 aCoords = aTmpBuf.makeStringAndClear();
703 break;
704 default:
705 DBG_ASSERT( pShape, "unbekanntes IMapObject" );
706 break;
709 if( pShape )
711 if( pDelim )
712 rStream.WriteCharPtr( pDelim );
713 if( pIndentArea )
714 rStream.WriteCharPtr( pIndentArea );
716 sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_area)
717 .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_shape)
718 .append('=').append(pShape).append(' ')
719 .append(OOO_STRING_SVTOOLS_HTML_O_coords).append("=\"")
720 .append(aCoords).append("\" ");
721 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
723 OUString aURL( pObj->GetURL() );
724 if( !aURL.isEmpty() && pObj->IsActive() )
726 aURL = URIHelper::simpleNormalizedMakeRelative(
727 rBaseURL, aURL );
728 sOut.append(OOO_STRING_SVTOOLS_HTML_O_href).append("=\"");
729 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
730 Out_String( rStream, aURL, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
732 else
733 rStream.WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_nohref );
735 const OUString& rObjName = pObj->GetName();
736 if( !rObjName.isEmpty() )
738 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_name)
739 .append("=\"");
740 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
741 Out_String( rStream, rObjName, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
744 const OUString& rTarget = pObj->GetTarget();
745 if( !rTarget.isEmpty() && pObj->IsActive() )
747 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_target)
748 .append("=\"");
749 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
750 Out_String( rStream, rTarget, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
753 OUString rDesc( pObj->GetAltText() );
754 if( rDesc.isEmpty() )
755 rDesc = pObj->GetDesc();
757 if( !rDesc.isEmpty() )
759 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_alt)
760 .append("=\"");
761 rStream.WriteCharPtr( sOut.makeStringAndClear().getStr() );
762 Out_String( rStream, rDesc, eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
765 const SvxMacroTableDtor& rMacroTab = pObj->GetMacroTable();
766 if( pEventTable && !rMacroTab.empty() )
767 Out_Events( rStream, rMacroTab, pEventTable,
768 bOutStarBasic, eDestEnc, pNonConvertableChars );
770 rStream.WriteChar( '>' );
776 if( pDelim )
777 rStream.WriteCharPtr( pDelim );
778 if( pIndentMap )
779 rStream.WriteCharPtr( pIndentMap );
780 Out_AsciiTag( rStream, OOO_STRING_SVTOOLS_HTML_map, false );
782 return rStream;
785 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 )
796 if( RTL_TEXTENCODING_DONTKNOW == eDestEnc )
797 eDestEnc = osl_getThreadTextEncoding();
799 // script is not indented!
800 OStringBuffer sOut;
801 sOut.append('<')
802 .append(OOO_STRING_SVTOOLS_HTML_script);
804 if( !rLanguage.isEmpty() )
806 sOut.append(' ')
807 .append(OOO_STRING_SVTOOLS_HTML_O_language)
808 .append("=\"");
809 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
810 Out_String( rStrm, rLanguage, eDestEnc, pNonConvertableChars );
811 sOut.append('\"');
814 if( !rSrc.isEmpty() )
816 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_src).append("=\"");
817 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
818 Out_String( rStrm, URIHelper::simpleNormalizedMakeRelative(rBaseURL, rSrc), eDestEnc, pNonConvertableChars );
819 sOut.append('\"');
822 if( STARBASIC != eScriptType && pSBLibrary )
824 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_sdlibrary)
825 .append("=\"");
826 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
827 Out_String( rStrm, *pSBLibrary, eDestEnc, pNonConvertableChars );
828 sOut.append('\"');
831 if( STARBASIC != eScriptType && pSBModule )
833 sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_sdmodule)
834 .append("=\"");
835 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
836 Out_String( rStrm, *pSBModule, eDestEnc, pNonConvertableChars );
837 sOut.append('\"');
840 sOut.append('>');
842 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
844 if( !rSource.isEmpty() || pSBLibrary || pSBModule )
846 rStrm.WriteCharPtr( SAL_NEWLINE_STRING );
848 if( JAVASCRIPT != eScriptType )
850 rStrm.WriteCharPtr( "<!--" )
851 .WriteCharPtr( SAL_NEWLINE_STRING );
854 if( STARBASIC == eScriptType )
856 if( pSBLibrary )
858 sOut.append("' ")
859 .append(OOO_STRING_SVTOOLS_HTML_SB_library)
860 .append(' ')
861 .append(OUStringToOString(*pSBLibrary, eDestEnc));
862 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() ).WriteCharPtr( SAL_NEWLINE_STRING );
865 if( pSBModule )
867 sOut.append("' ")
868 .append(OOO_STRING_SVTOOLS_HTML_SB_module)
869 .append(' ')
870 .append(OUStringToOString(*pSBModule, eDestEnc));
871 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() ).WriteCharPtr( SAL_NEWLINE_STRING );
875 if( !rSource.isEmpty() )
877 // we write the module in ANSI-charset, but with
878 // the system new line.
879 const OString sSource(OUStringToOString(rSource, eDestEnc));
880 rStrm.WriteCharPtr( sSource.getStr() ).WriteCharPtr( SAL_NEWLINE_STRING );
882 rStrm.WriteCharPtr( SAL_NEWLINE_STRING );
884 if( JAVASCRIPT != eScriptType )
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 rStrm.WriteCharPtr( STARBASIC == eScriptType ? "' -->" : "// -->" )
889 .WriteCharPtr( SAL_NEWLINE_STRING );
893 HTMLOutFuncs::Out_AsciiTag( rStrm, OOO_STRING_SVTOOLS_HTML_script, false );
895 return rStrm;
899 SvStream& HTMLOutFuncs::Out_Events( SvStream& rStrm,
900 const SvxMacroTableDtor& rMacroTable,
901 const HTMLOutEvent *pEventTable,
902 bool bOutStarBasic,
903 rtl_TextEncoding eDestEnc,
904 OUString *pNonConvertableChars )
906 sal_uInt16 i=0;
907 while( pEventTable[i].pBasicName || pEventTable[i].pJavaName )
909 const SvxMacro *pMacro =
910 rMacroTable.Get( pEventTable[i].nEvent );
912 if( pMacro && pMacro->HasMacro() &&
913 ( JAVASCRIPT == pMacro->GetScriptType() || bOutStarBasic ))
915 const sal_Char *pStr = STARBASIC == pMacro->GetScriptType()
916 ? pEventTable[i].pBasicName
917 : pEventTable[i].pJavaName;
919 if( pStr )
921 OStringBuffer sOut;
922 sOut.append(' ').append(pStr).append("=\"");
923 rStrm.WriteCharPtr( sOut.makeStringAndClear().getStr() );
925 Out_String( rStrm, pMacro->GetMacName(), eDestEnc, pNonConvertableChars ).WriteChar( '\"' );
928 i++;
931 return rStrm;
934 OString HTMLOutFuncs::CreateTableDataOptionsValNum(
935 bool bValue,
936 double fVal, sal_uLong nFormat, SvNumberFormatter& rFormatter,
937 rtl_TextEncoding eDestEnc, OUString* pNonConvertableChars)
939 OStringBuffer aStrTD;
941 if ( bValue )
943 // printf / scanf is not precise enough
944 OUString aValStr;
945 rFormatter.GetInputLineString( fVal, 0, aValStr );
946 OString sTmp(OUStringToOString(aValStr, eDestEnc));
947 aStrTD.append(' ').
948 append(OOO_STRING_SVTOOLS_HTML_O_SDval).
949 append("=\"").
950 append(sTmp).append('\"');
952 if ( bValue || nFormat )
954 aStrTD.append(' ').
955 append(OOO_STRING_SVTOOLS_HTML_O_SDnum).
956 append("=\"").
957 append(static_cast<sal_Int32>(
958 Application::GetSettings().GetLanguageTag().getLanguageType())).
959 append(';'); // Language for Format 0
960 if ( nFormat )
962 OString aNumStr;
963 LanguageType nLang;
964 const SvNumberformat* pFormatEntry = rFormatter.GetEntry( nFormat );
965 if ( pFormatEntry )
967 aNumStr = ConvertStringToHTML( pFormatEntry->GetFormatstring(),
968 eDestEnc, pNonConvertableChars );
969 nLang = pFormatEntry->GetLanguage();
971 else
972 nLang = LANGUAGE_SYSTEM;
973 aStrTD.append(static_cast<sal_Int32>(nLang)).append(';').
974 append(aNumStr);
976 aStrTD.append('\"');
978 return aStrTD.makeStringAndClear();
981 void HtmlWriterHelper::applyColor(HtmlWriter& rHtmlWriter, const OString &aAttributeName, const Color& rColor)
983 OStringBuffer sBuffer;
985 if( rColor.GetColor() == COL_AUTO )
987 sBuffer.append("#000000");
989 else
991 sBuffer.append('#');
992 std::ostringstream sStringStream;
993 sStringStream
994 << std::right
995 << std::setfill('0')
996 << std::setw(6)
997 << std::hex
998 << rColor.GetRGBColor();
999 sBuffer.append(sStringStream.str().c_str());
1002 rHtmlWriter.attribute(aAttributeName, sBuffer.makeStringAndClear());
1006 void HtmlWriterHelper::applyEvents(HtmlWriter& rHtmlWriter, const SvxMacroTableDtor& rMacroTable, const HTMLOutEvent* pEventTable, bool bOutStarBasic)
1008 sal_uInt16 i = 0;
1009 while (pEventTable[i].pBasicName || pEventTable[i].pJavaName)
1011 const SvxMacro* pMacro = rMacroTable.Get(pEventTable[i].nEvent);
1013 if (pMacro && pMacro->HasMacro() && (JAVASCRIPT == pMacro->GetScriptType() || bOutStarBasic))
1015 const sal_Char* pAttributeName = NULL;
1016 if (STARBASIC == pMacro->GetScriptType())
1017 pAttributeName = pEventTable[i].pBasicName;
1018 else
1019 pAttributeName = pEventTable[i].pJavaName;
1021 if (pAttributeName)
1023 rHtmlWriter.attribute(pAttributeName, OUStringToOString(pMacro->GetMacName(), RTL_TEXTENCODING_UTF8));
1026 i++;
1030 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */