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