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