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