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