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