1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svl/numformat.hxx>
22 #include <svl/zformat.hxx>
23 #include <svl/macitem.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/settings.hxx>
27 #include <svtools/HtmlWriter.hxx>
28 #include <svtools/htmlout.hxx>
29 #include <svtools/htmlkywd.hxx>
30 #include <vcl/imap.hxx>
31 #include <vcl/imaprect.hxx>
32 #include <vcl/imapcirc.hxx>
33 #include <vcl/imappoly.hxx>
34 #include <svl/urihelper.hxx>
35 #include <rtl/character.hxx>
36 #include <tools/debug.hxx>
40 #define TXTCONV_BUFFER_SIZE 20
42 static sal_Size
convertUnicodeToText(const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
, char* pDestBuf
,
43 sal_Size nDestBytes
, sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
44 sal_Size
* pSrcCvtChars
)
46 static rtl_UnicodeToTextConverter hConverter
47 = rtl_createUnicodeToTextConverter(RTL_TEXTENCODING_UTF8
);
48 static rtl_UnicodeToTextContext hContext
= hConverter
49 ? rtl_createUnicodeToTextContext(hConverter
)
50 : reinterpret_cast<rtl_TextToUnicodeContext
>(1);
52 return rtl_convertUnicodeToText(hConverter
, hContext
, pSrcBuf
, nSrcChars
, pDestBuf
, nDestBytes
,
53 nFlags
, pInfo
, pSrcCvtChars
);
56 static const char *lcl_svhtml_GetEntityForChar( sal_uInt32 c
,
57 rtl_TextEncoding eDestEnc
)
59 const char* pStr
= nullptr;
61 // Note: We currently handle special cases for ISO-8859-2 here simply because
62 // the code was already submitted. But we should also handle other code pages
63 // as well as the code becomes available.
65 if( eDestEnc
== RTL_TEXTENCODING_ISO_8859_2
|| eDestEnc
== RTL_TEXTENCODING_MS_1250
)
67 // Don't handle the following characters for Easter European (ISO-8859-2).
107 // TODO: handle more special cases for other code pages.
111 // case '\x0a': return HTMLOutFuncs::Out_Tag( rStream, OOO_STRING_SVTOOLS_HTML_linebreak );
113 case '<': pStr
= OOO_STRING_SVTOOLS_HTML_C_lt
; break;
114 case '>': pStr
= OOO_STRING_SVTOOLS_HTML_C_gt
; break;
115 case '&': pStr
= OOO_STRING_SVTOOLS_HTML_C_amp
; break;
116 case '"': pStr
= OOO_STRING_SVTOOLS_HTML_C_quot
; break;
118 case 161: pStr
= OOO_STRING_SVTOOLS_HTML_S_iexcl
; break;
119 case 162: pStr
= OOO_STRING_SVTOOLS_HTML_S_cent
; break;
120 case 163: pStr
= OOO_STRING_SVTOOLS_HTML_S_pound
; break;
121 case 164: pStr
= OOO_STRING_SVTOOLS_HTML_S_curren
; break;
122 case 165: pStr
= OOO_STRING_SVTOOLS_HTML_S_yen
; break;
123 case 166: pStr
= OOO_STRING_SVTOOLS_HTML_S_brvbar
; break;
124 case 167: pStr
= OOO_STRING_SVTOOLS_HTML_S_sect
; break;
125 case 168: pStr
= OOO_STRING_SVTOOLS_HTML_S_uml
; break;
126 case 169: pStr
= OOO_STRING_SVTOOLS_HTML_S_copy
; break;
127 case 170: pStr
= OOO_STRING_SVTOOLS_HTML_S_ordf
; break;
128 case 171: pStr
= OOO_STRING_SVTOOLS_HTML_S_laquo
; break;
129 case 172: pStr
= OOO_STRING_SVTOOLS_HTML_S_not
; break;
130 case 174: pStr
= OOO_STRING_SVTOOLS_HTML_S_reg
; break;
131 case 175: pStr
= OOO_STRING_SVTOOLS_HTML_S_macr
; break;
132 case 176: pStr
= OOO_STRING_SVTOOLS_HTML_S_deg
; break;
133 case 177: pStr
= OOO_STRING_SVTOOLS_HTML_S_plusmn
; break;
134 case 178: pStr
= OOO_STRING_SVTOOLS_HTML_S_sup2
; break;
135 case 179: pStr
= OOO_STRING_SVTOOLS_HTML_S_sup3
; break;
136 case 180: pStr
= OOO_STRING_SVTOOLS_HTML_S_acute
; break;
137 case 181: pStr
= OOO_STRING_SVTOOLS_HTML_S_micro
; break;
138 case 182: pStr
= OOO_STRING_SVTOOLS_HTML_S_para
; break;
139 case 183: pStr
= OOO_STRING_SVTOOLS_HTML_S_middot
; break;
140 case 184: pStr
= OOO_STRING_SVTOOLS_HTML_S_cedil
; break;
141 case 185: pStr
= OOO_STRING_SVTOOLS_HTML_S_sup1
; break;
142 case 186: pStr
= OOO_STRING_SVTOOLS_HTML_S_ordm
; break;
143 case 187: pStr
= OOO_STRING_SVTOOLS_HTML_S_raquo
; break;
144 case 188: pStr
= OOO_STRING_SVTOOLS_HTML_S_frac14
; break;
145 case 189: pStr
= OOO_STRING_SVTOOLS_HTML_S_frac12
; break;
146 case 190: pStr
= OOO_STRING_SVTOOLS_HTML_S_frac34
; break;
147 case 191: pStr
= OOO_STRING_SVTOOLS_HTML_S_iquest
; break;
149 case 192: pStr
= OOO_STRING_SVTOOLS_HTML_C_Agrave
; break;
150 case 193: pStr
= OOO_STRING_SVTOOLS_HTML_C_Aacute
; break;
151 case 194: pStr
= OOO_STRING_SVTOOLS_HTML_C_Acirc
; break;
152 case 195: pStr
= OOO_STRING_SVTOOLS_HTML_C_Atilde
; break;
153 case 196: pStr
= OOO_STRING_SVTOOLS_HTML_C_Auml
; break;
154 case 197: pStr
= OOO_STRING_SVTOOLS_HTML_C_Aring
; break;
155 case 198: pStr
= OOO_STRING_SVTOOLS_HTML_C_AElig
; break;
156 case 199: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ccedil
; break;
157 case 200: pStr
= OOO_STRING_SVTOOLS_HTML_C_Egrave
; break;
158 case 201: pStr
= OOO_STRING_SVTOOLS_HTML_C_Eacute
; break;
159 case 202: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ecirc
; break;
160 case 203: pStr
= OOO_STRING_SVTOOLS_HTML_C_Euml
; break;
161 case 204: pStr
= OOO_STRING_SVTOOLS_HTML_C_Igrave
; break;
162 case 205: pStr
= OOO_STRING_SVTOOLS_HTML_C_Iacute
; break;
163 case 206: pStr
= OOO_STRING_SVTOOLS_HTML_C_Icirc
; break;
164 case 207: pStr
= OOO_STRING_SVTOOLS_HTML_C_Iuml
; break;
165 case 208: pStr
= OOO_STRING_SVTOOLS_HTML_C_ETH
; break;
166 case 209: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ntilde
; break;
167 case 210: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ograve
; break;
168 case 211: pStr
= OOO_STRING_SVTOOLS_HTML_C_Oacute
; break;
169 case 212: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ocirc
; break;
170 case 213: pStr
= OOO_STRING_SVTOOLS_HTML_C_Otilde
; break;
171 case 214: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ouml
; break;
172 case 215: pStr
= OOO_STRING_SVTOOLS_HTML_S_times
; break;
173 case 216: pStr
= OOO_STRING_SVTOOLS_HTML_C_Oslash
; break;
174 case 217: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ugrave
; break;
175 case 218: pStr
= OOO_STRING_SVTOOLS_HTML_C_Uacute
; break;
176 case 219: pStr
= OOO_STRING_SVTOOLS_HTML_C_Ucirc
; break;
177 case 220: pStr
= OOO_STRING_SVTOOLS_HTML_C_Uuml
; break;
178 case 221: pStr
= OOO_STRING_SVTOOLS_HTML_C_Yacute
; break;
180 case 222: pStr
= OOO_STRING_SVTOOLS_HTML_C_THORN
; break;
181 case 223: pStr
= OOO_STRING_SVTOOLS_HTML_C_szlig
; break;
183 case 224: pStr
= OOO_STRING_SVTOOLS_HTML_S_agrave
; break;
184 case 225: pStr
= OOO_STRING_SVTOOLS_HTML_S_aacute
; break;
185 case 226: pStr
= OOO_STRING_SVTOOLS_HTML_S_acirc
; break;
186 case 227: pStr
= OOO_STRING_SVTOOLS_HTML_S_atilde
; break;
187 case 228: pStr
= OOO_STRING_SVTOOLS_HTML_S_auml
; break;
188 case 229: pStr
= OOO_STRING_SVTOOLS_HTML_S_aring
; break;
189 case 230: pStr
= OOO_STRING_SVTOOLS_HTML_S_aelig
; break;
190 case 231: pStr
= OOO_STRING_SVTOOLS_HTML_S_ccedil
; break;
191 case 232: pStr
= OOO_STRING_SVTOOLS_HTML_S_egrave
; break;
192 case 233: pStr
= OOO_STRING_SVTOOLS_HTML_S_eacute
; break;
193 case 234: pStr
= OOO_STRING_SVTOOLS_HTML_S_ecirc
; break;
194 case 235: pStr
= OOO_STRING_SVTOOLS_HTML_S_euml
; break;
195 case 236: pStr
= OOO_STRING_SVTOOLS_HTML_S_igrave
; break;
196 case 237: pStr
= OOO_STRING_SVTOOLS_HTML_S_iacute
; break;
197 case 238: pStr
= OOO_STRING_SVTOOLS_HTML_S_icirc
; break;
198 case 239: pStr
= OOO_STRING_SVTOOLS_HTML_S_iuml
; break;
199 case 240: pStr
= OOO_STRING_SVTOOLS_HTML_S_eth
; break;
200 case 241: pStr
= OOO_STRING_SVTOOLS_HTML_S_ntilde
; break;
201 case 242: pStr
= OOO_STRING_SVTOOLS_HTML_S_ograve
; break;
202 case 243: pStr
= OOO_STRING_SVTOOLS_HTML_S_oacute
; break;
203 case 244: pStr
= OOO_STRING_SVTOOLS_HTML_S_ocirc
; break;
204 case 245: pStr
= OOO_STRING_SVTOOLS_HTML_S_otilde
; break;
205 case 246: pStr
= OOO_STRING_SVTOOLS_HTML_S_ouml
; break;
206 case 247: pStr
= OOO_STRING_SVTOOLS_HTML_S_divide
; break;
207 case 248: pStr
= OOO_STRING_SVTOOLS_HTML_S_oslash
; break;
208 case 249: pStr
= OOO_STRING_SVTOOLS_HTML_S_ugrave
; break;
209 case 250: pStr
= OOO_STRING_SVTOOLS_HTML_S_uacute
; break;
210 case 251: pStr
= OOO_STRING_SVTOOLS_HTML_S_ucirc
; break;
211 case 252: pStr
= OOO_STRING_SVTOOLS_HTML_S_uuml
; break;
212 case 253: pStr
= OOO_STRING_SVTOOLS_HTML_S_yacute
; break;
213 case 254: pStr
= OOO_STRING_SVTOOLS_HTML_S_thorn
; break;
214 case 255: pStr
= OOO_STRING_SVTOOLS_HTML_S_yuml
; break;
216 case 338: pStr
= OOO_STRING_SVTOOLS_HTML_S_OElig
; break;
217 case 339: pStr
= OOO_STRING_SVTOOLS_HTML_S_oelig
; break;
218 case 352: pStr
= OOO_STRING_SVTOOLS_HTML_S_Scaron
; break;
219 case 353: pStr
= OOO_STRING_SVTOOLS_HTML_S_scaron
; break;
220 case 376: pStr
= OOO_STRING_SVTOOLS_HTML_S_Yuml
; break;
221 case 402: pStr
= OOO_STRING_SVTOOLS_HTML_S_fnof
; break;
222 case 710: pStr
= OOO_STRING_SVTOOLS_HTML_S_circ
; break;
223 case 732: pStr
= OOO_STRING_SVTOOLS_HTML_S_tilde
; break;
225 // Greek chars are handled later,
226 // since they should *not* be transformed to entities
227 // when generating Greek text (== using Greek encoding)
229 case 8194: pStr
= OOO_STRING_SVTOOLS_HTML_S_ensp
; break;
230 case 8195: pStr
= OOO_STRING_SVTOOLS_HTML_S_emsp
; break;
231 case 8201: pStr
= OOO_STRING_SVTOOLS_HTML_S_thinsp
; break;
232 case 8204: pStr
= OOO_STRING_SVTOOLS_HTML_S_zwnj
; break;
233 case 8205: pStr
= OOO_STRING_SVTOOLS_HTML_S_zwj
; break;
234 case 8206: pStr
= OOO_STRING_SVTOOLS_HTML_S_lrm
; break;
235 case 8207: pStr
= OOO_STRING_SVTOOLS_HTML_S_rlm
; break;
236 case 8211: pStr
= OOO_STRING_SVTOOLS_HTML_S_ndash
; break;
237 case 8212: pStr
= OOO_STRING_SVTOOLS_HTML_S_mdash
; break;
238 case 8216: pStr
= OOO_STRING_SVTOOLS_HTML_S_lsquo
; break;
239 case 8217: pStr
= OOO_STRING_SVTOOLS_HTML_S_rsquo
; break;
240 case 8218: pStr
= OOO_STRING_SVTOOLS_HTML_S_sbquo
; break;
241 case 8220: pStr
= OOO_STRING_SVTOOLS_HTML_S_ldquo
; break;
242 case 8221: pStr
= OOO_STRING_SVTOOLS_HTML_S_rdquo
; break;
243 case 8222: pStr
= OOO_STRING_SVTOOLS_HTML_S_bdquo
; break;
244 case 8224: pStr
= OOO_STRING_SVTOOLS_HTML_S_dagger
; break;
245 case 8225: pStr
= OOO_STRING_SVTOOLS_HTML_S_Dagger
; break;
246 case 8226: pStr
= OOO_STRING_SVTOOLS_HTML_S_bull
; break;
247 case 8230: pStr
= OOO_STRING_SVTOOLS_HTML_S_hellip
; break;
248 case 8240: pStr
= OOO_STRING_SVTOOLS_HTML_S_permil
; break;
249 case 8242: pStr
= OOO_STRING_SVTOOLS_HTML_S_prime
; break;
250 case 8243: pStr
= OOO_STRING_SVTOOLS_HTML_S_Prime
; break;
251 case 8249: pStr
= OOO_STRING_SVTOOLS_HTML_S_lsaquo
; break;
252 case 8250: pStr
= OOO_STRING_SVTOOLS_HTML_S_rsaquo
; break;
253 case 8254: pStr
= OOO_STRING_SVTOOLS_HTML_S_oline
; break;
254 case 8260: pStr
= OOO_STRING_SVTOOLS_HTML_S_frasl
; break;
255 case 8364: pStr
= OOO_STRING_SVTOOLS_HTML_S_euro
; break;
256 case 8465: pStr
= OOO_STRING_SVTOOLS_HTML_S_image
; break;
257 case 8472: pStr
= OOO_STRING_SVTOOLS_HTML_S_weierp
; break;
258 case 8476: pStr
= OOO_STRING_SVTOOLS_HTML_S_real
; break;
259 case 8482: pStr
= OOO_STRING_SVTOOLS_HTML_S_trade
; break;
260 case 8501: pStr
= OOO_STRING_SVTOOLS_HTML_S_alefsym
; break;
261 case 8592: pStr
= OOO_STRING_SVTOOLS_HTML_S_larr
; break;
262 case 8593: pStr
= OOO_STRING_SVTOOLS_HTML_S_uarr
; break;
263 case 8594: pStr
= OOO_STRING_SVTOOLS_HTML_S_rarr
; break;
264 case 8595: pStr
= OOO_STRING_SVTOOLS_HTML_S_darr
; break;
265 case 8596: pStr
= OOO_STRING_SVTOOLS_HTML_S_harr
; break;
266 case 8629: pStr
= OOO_STRING_SVTOOLS_HTML_S_crarr
; break;
267 case 8656: pStr
= OOO_STRING_SVTOOLS_HTML_S_lArr
; break;
268 case 8657: pStr
= OOO_STRING_SVTOOLS_HTML_S_uArr
; break;
269 case 8658: pStr
= OOO_STRING_SVTOOLS_HTML_S_rArr
; break;
270 case 8659: pStr
= OOO_STRING_SVTOOLS_HTML_S_dArr
; break;
271 case 8660: pStr
= OOO_STRING_SVTOOLS_HTML_S_hArr
; break;
272 case 8704: pStr
= OOO_STRING_SVTOOLS_HTML_S_forall
; break;
273 case 8706: pStr
= OOO_STRING_SVTOOLS_HTML_S_part
; break;
274 case 8707: pStr
= OOO_STRING_SVTOOLS_HTML_S_exist
; break;
275 case 8709: pStr
= OOO_STRING_SVTOOLS_HTML_S_empty
; break;
276 case 8711: pStr
= OOO_STRING_SVTOOLS_HTML_S_nabla
; break;
277 case 8712: pStr
= OOO_STRING_SVTOOLS_HTML_S_isin
; break;
278 case 8713: pStr
= OOO_STRING_SVTOOLS_HTML_S_notin
; break;
279 case 8715: pStr
= OOO_STRING_SVTOOLS_HTML_S_ni
; break;
280 case 8719: pStr
= OOO_STRING_SVTOOLS_HTML_S_prod
; break;
281 case 8721: pStr
= OOO_STRING_SVTOOLS_HTML_S_sum
; break;
282 case 8722: pStr
= OOO_STRING_SVTOOLS_HTML_S_minus
; break;
283 case 8727: pStr
= OOO_STRING_SVTOOLS_HTML_S_lowast
; break;
284 case 8730: pStr
= OOO_STRING_SVTOOLS_HTML_S_radic
; break;
285 case 8733: pStr
= OOO_STRING_SVTOOLS_HTML_S_prop
; break;
286 case 8734: pStr
= OOO_STRING_SVTOOLS_HTML_S_infin
; break;
287 case 8736: pStr
= OOO_STRING_SVTOOLS_HTML_S_ang
; break;
288 case 8743: pStr
= OOO_STRING_SVTOOLS_HTML_S_and
; break;
289 case 8744: pStr
= OOO_STRING_SVTOOLS_HTML_S_or
; break;
290 case 8745: pStr
= OOO_STRING_SVTOOLS_HTML_S_cap
; break;
291 case 8746: pStr
= OOO_STRING_SVTOOLS_HTML_S_cup
; break;
292 case 8747: pStr
= OOO_STRING_SVTOOLS_HTML_S_int
; break;
293 case 8756: pStr
= OOO_STRING_SVTOOLS_HTML_S_there4
; break;
294 case 8764: pStr
= OOO_STRING_SVTOOLS_HTML_S_sim
; break;
295 case 8773: pStr
= OOO_STRING_SVTOOLS_HTML_S_cong
; break;
296 case 8776: pStr
= OOO_STRING_SVTOOLS_HTML_S_asymp
; break;
297 case 8800: pStr
= OOO_STRING_SVTOOLS_HTML_S_ne
; break;
298 case 8801: pStr
= OOO_STRING_SVTOOLS_HTML_S_equiv
; break;
299 case 8804: pStr
= OOO_STRING_SVTOOLS_HTML_S_le
; break;
300 case 8805: pStr
= OOO_STRING_SVTOOLS_HTML_S_ge
; break;
301 case 8834: pStr
= OOO_STRING_SVTOOLS_HTML_S_sub
; break;
302 case 8835: pStr
= OOO_STRING_SVTOOLS_HTML_S_sup
; break;
303 case 8836: pStr
= OOO_STRING_SVTOOLS_HTML_S_nsub
; break;
304 case 8838: pStr
= OOO_STRING_SVTOOLS_HTML_S_sube
; break;
305 case 8839: pStr
= OOO_STRING_SVTOOLS_HTML_S_supe
; break;
306 case 8853: pStr
= OOO_STRING_SVTOOLS_HTML_S_oplus
; break;
307 case 8855: pStr
= OOO_STRING_SVTOOLS_HTML_S_otimes
; break;
308 case 8869: pStr
= OOO_STRING_SVTOOLS_HTML_S_perp
; break;
309 case 8901: pStr
= OOO_STRING_SVTOOLS_HTML_S_sdot
; break;
310 case 8968: pStr
= OOO_STRING_SVTOOLS_HTML_S_lceil
; break;
311 case 8969: pStr
= OOO_STRING_SVTOOLS_HTML_S_rceil
; break;
312 case 8970: pStr
= OOO_STRING_SVTOOLS_HTML_S_lfloor
; break;
313 case 8971: pStr
= OOO_STRING_SVTOOLS_HTML_S_rfloor
; break;
314 case 9001: pStr
= OOO_STRING_SVTOOLS_HTML_S_lang
; break;
315 case 9002: pStr
= OOO_STRING_SVTOOLS_HTML_S_rang
; break;
316 case 9674: pStr
= OOO_STRING_SVTOOLS_HTML_S_loz
; break;
317 case 9824: pStr
= OOO_STRING_SVTOOLS_HTML_S_spades
; break;
318 case 9827: pStr
= OOO_STRING_SVTOOLS_HTML_S_clubs
; break;
319 case 9829: pStr
= OOO_STRING_SVTOOLS_HTML_S_hearts
; break;
320 case 9830: pStr
= OOO_STRING_SVTOOLS_HTML_S_diams
; break;
323 // Greek chars: if we do not produce a Greek encoding,
324 // transform them into entities
326 ( eDestEnc
!= RTL_TEXTENCODING_ISO_8859_7
) &&
327 ( eDestEnc
!= RTL_TEXTENCODING_MS_1253
) )
331 case 913: pStr
= OOO_STRING_SVTOOLS_HTML_S_Alpha
; break;
332 case 914: pStr
= OOO_STRING_SVTOOLS_HTML_S_Beta
; break;
333 case 915: pStr
= OOO_STRING_SVTOOLS_HTML_S_Gamma
; break;
334 case 916: pStr
= OOO_STRING_SVTOOLS_HTML_S_Delta
; break;
335 case 917: pStr
= OOO_STRING_SVTOOLS_HTML_S_Epsilon
; break;
336 case 918: pStr
= OOO_STRING_SVTOOLS_HTML_S_Zeta
; break;
337 case 919: pStr
= OOO_STRING_SVTOOLS_HTML_S_Eta
; break;
338 case 920: pStr
= OOO_STRING_SVTOOLS_HTML_S_Theta
; break;
339 case 921: pStr
= OOO_STRING_SVTOOLS_HTML_S_Iota
; break;
340 case 922: pStr
= OOO_STRING_SVTOOLS_HTML_S_Kappa
; break;
341 case 923: pStr
= OOO_STRING_SVTOOLS_HTML_S_Lambda
; break;
342 case 924: pStr
= OOO_STRING_SVTOOLS_HTML_S_Mu
; break;
343 case 925: pStr
= OOO_STRING_SVTOOLS_HTML_S_Nu
; break;
344 case 926: pStr
= OOO_STRING_SVTOOLS_HTML_S_Xi
; break;
345 case 927: pStr
= OOO_STRING_SVTOOLS_HTML_S_Omicron
; break;
346 case 928: pStr
= OOO_STRING_SVTOOLS_HTML_S_Pi
; break;
347 case 929: pStr
= OOO_STRING_SVTOOLS_HTML_S_Rho
; break;
348 case 931: pStr
= OOO_STRING_SVTOOLS_HTML_S_Sigma
; break;
349 case 932: pStr
= OOO_STRING_SVTOOLS_HTML_S_Tau
; break;
350 case 933: pStr
= OOO_STRING_SVTOOLS_HTML_S_Upsilon
; break;
351 case 934: pStr
= OOO_STRING_SVTOOLS_HTML_S_Phi
; break;
352 case 935: pStr
= OOO_STRING_SVTOOLS_HTML_S_Chi
; break;
353 case 936: pStr
= OOO_STRING_SVTOOLS_HTML_S_Psi
; break;
354 case 937: pStr
= OOO_STRING_SVTOOLS_HTML_S_Omega
; break;
355 case 945: pStr
= OOO_STRING_SVTOOLS_HTML_S_alpha
; break;
356 case 946: pStr
= OOO_STRING_SVTOOLS_HTML_S_beta
; break;
357 case 947: pStr
= OOO_STRING_SVTOOLS_HTML_S_gamma
; break;
358 case 948: pStr
= OOO_STRING_SVTOOLS_HTML_S_delta
; break;
359 case 949: pStr
= OOO_STRING_SVTOOLS_HTML_S_epsilon
; break;
360 case 950: pStr
= OOO_STRING_SVTOOLS_HTML_S_zeta
; break;
361 case 951: pStr
= OOO_STRING_SVTOOLS_HTML_S_eta
; break;
362 case 952: pStr
= OOO_STRING_SVTOOLS_HTML_S_theta
; break;
363 case 953: pStr
= OOO_STRING_SVTOOLS_HTML_S_iota
; break;
364 case 954: pStr
= OOO_STRING_SVTOOLS_HTML_S_kappa
; break;
365 case 955: pStr
= OOO_STRING_SVTOOLS_HTML_S_lambda
; break;
366 case 956: pStr
= OOO_STRING_SVTOOLS_HTML_S_mu
; break;
367 case 957: pStr
= OOO_STRING_SVTOOLS_HTML_S_nu
; break;
368 case 958: pStr
= OOO_STRING_SVTOOLS_HTML_S_xi
; break;
369 case 959: pStr
= OOO_STRING_SVTOOLS_HTML_S_omicron
; break;
370 case 960: pStr
= OOO_STRING_SVTOOLS_HTML_S_pi
; break;
371 case 961: pStr
= OOO_STRING_SVTOOLS_HTML_S_rho
; break;
372 case 962: pStr
= OOO_STRING_SVTOOLS_HTML_S_sigmaf
; break;
373 case 963: pStr
= OOO_STRING_SVTOOLS_HTML_S_sigma
; break;
374 case 964: pStr
= OOO_STRING_SVTOOLS_HTML_S_tau
; break;
375 case 965: pStr
= OOO_STRING_SVTOOLS_HTML_S_upsilon
; break;
376 case 966: pStr
= OOO_STRING_SVTOOLS_HTML_S_phi
; break;
377 case 967: pStr
= OOO_STRING_SVTOOLS_HTML_S_chi
; break;
378 case 968: pStr
= OOO_STRING_SVTOOLS_HTML_S_psi
; break;
379 case 969: pStr
= OOO_STRING_SVTOOLS_HTML_S_omega
; break;
380 case 977: pStr
= OOO_STRING_SVTOOLS_HTML_S_thetasym
;break;
381 case 978: pStr
= OOO_STRING_SVTOOLS_HTML_S_upsih
; break;
382 case 982: pStr
= OOO_STRING_SVTOOLS_HTML_S_piv
; break;
389 static sal_Size
lcl_FlushContext(char* pBuffer
, sal_uInt32 nFlags
)
391 sal_uInt32 nInfo
= 0;
393 sal_Size nLen
= convertUnicodeToText(nullptr, 0,
394 pBuffer
, TXTCONV_BUFFER_SIZE
, nFlags
|RTL_UNICODETOTEXT_FLAGS_FLUSH
,
396 DBG_ASSERT((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
)) == 0, "HTMLOut: error while flushing");
400 static OString
lcl_ConvertCharToHTML( sal_uInt32 c
,
401 OUString
*pNonConvertableChars
)
403 assert(rtl::isUnicodeCodePoint(c
));
406 const char *pStr
= nullptr;
409 case 0xA0: // is a hard blank
410 pStr
= OOO_STRING_SVTOOLS_HTML_S_nbsp
;
412 case 0x2011: // is a hard hyphen
415 case 0xAD: // is a soft hyphen
416 pStr
= OOO_STRING_SVTOOLS_HTML_S_shy
;
419 // There may be an entity for the character.
420 // The new HTML4 entities above 255 are not used for UTF-8,
421 // because Netscape 4 does support UTF-8 but does not support
424 pStr
= lcl_svhtml_GetEntityForChar( c
, RTL_TEXTENCODING_UTF8
);
428 char cBuffer
[TXTCONV_BUFFER_SIZE
];
429 const sal_uInt32 nFlags
= RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE
|
430 RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE
|
431 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
|
432 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
;
435 sal_Size nLen
= lcl_FlushContext(cBuffer
, nFlags
);
436 char *pBuffer
= cBuffer
;
438 aDest
.append(*pBuffer
++);
439 aDest
.append(OString::Concat("&") + pStr
+ ";");
443 sal_uInt32 nInfo
= 0;
446 sal_Unicode utf16
[2];
447 auto n
= rtl::splitSurrogates(c
, utf16
);
448 sal_Size nLen
= convertUnicodeToText(utf16
, n
,
449 cBuffer
, TXTCONV_BUFFER_SIZE
,
450 nFlags
, &nInfo
, &nSrcChars
);
451 if( nLen
> 0 && (nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
|RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
)) == 0 )
453 char *pBuffer
= cBuffer
;
455 aDest
.append(*pBuffer
++);
459 // If the character could not be converted to the destination
460 // character set, the UNICODE character is exported as character
462 // coverity[callee_ptr_arith] - its ok
463 nLen
= lcl_FlushContext(cBuffer
, nFlags
);
464 char *pBuffer
= cBuffer
;
466 aDest
.append(*pBuffer
++);
468 aDest
.append("&#" + OString::number(static_cast<sal_Int32
>(c
))
469 // Unicode code points guaranteed to fit into sal_Int32
471 if( pNonConvertableChars
)
474 if( -1 == pNonConvertableChars
->indexOf( cs
) )
475 (*pNonConvertableChars
) += cs
;
479 return aDest
.makeStringAndClear();
482 static OString
lcl_FlushToAscii()
486 char cBuffer
[TXTCONV_BUFFER_SIZE
];
487 const sal_uInt32 nFlags
= RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE
|
488 RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE
|
489 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
|
490 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
;
491 sal_Size nLen
= lcl_FlushContext(cBuffer
, nFlags
);
492 char *pBuffer
= cBuffer
;
494 aDest
.append(*pBuffer
++);
495 return aDest
.makeStringAndClear();
498 OString
HTMLOutFuncs::ConvertStringToHTML( const OUString
& rSrc
,
499 OUString
*pNonConvertableChars
)
502 for( sal_Int32 i
=0, nLen
= rSrc
.getLength(); i
< nLen
; )
503 aDest
.append(lcl_ConvertCharToHTML(
504 rSrc
.iterateCodePoints(&i
), pNonConvertableChars
));
505 aDest
.append(lcl_FlushToAscii());
506 return aDest
.makeStringAndClear();
509 SvStream
& HTMLOutFuncs::Out_AsciiTag( SvStream
& rStream
, std::string_view rStr
,
513 rStream
.WriteOString("<");
515 rStream
.WriteOString("</");
517 rStream
.WriteOString(rStr
).WriteChar('>');
522 SvStream
& HTMLOutFuncs::Out_Char( SvStream
& rStream
, sal_uInt32 c
,
523 OUString
*pNonConvertableChars
)
525 OString sOut
= lcl_ConvertCharToHTML( c
, pNonConvertableChars
);
526 rStream
.WriteOString( sOut
);
530 SvStream
& HTMLOutFuncs::Out_String( SvStream
& rStream
, const OUString
& rOUStr
,
531 OUString
*pNonConvertableChars
)
533 sal_Int32 nLen
= rOUStr
.getLength();
534 for( sal_Int32 n
= 0; n
< nLen
; )
535 HTMLOutFuncs::Out_Char( rStream
, rOUStr
.iterateCodePoints(&n
),
536 pNonConvertableChars
);
537 HTMLOutFuncs::FlushToAscii( rStream
);
541 SvStream
& HTMLOutFuncs::FlushToAscii( SvStream
& rStream
)
543 OString sOut
= lcl_FlushToAscii();
546 rStream
.WriteOString( sOut
);
551 SvStream
& HTMLOutFuncs::Out_Hex( SvStream
& rStream
, sal_uInt32 nHex
, sal_uInt8 nLen
)
552 { // out into a stream
553 char aNToABuf
[] = "0000000000000000";
555 DBG_ASSERT( nLen
< sizeof(aNToABuf
), "too many places" );
556 if( nLen
>=sizeof(aNToABuf
) )
557 nLen
= (sizeof(aNToABuf
)-1);
559 // set pointer to end of buffer
560 char *pStr
= aNToABuf
+ (sizeof(aNToABuf
)-1);
561 for( sal_uInt8 n
= 0; n
< nLen
; ++n
)
563 *(--pStr
) = static_cast<char>(nHex
& 0xf ) + 48;
568 return rStream
.WriteOString( pStr
);
572 SvStream
& HTMLOutFuncs::Out_Color( SvStream
& rStream
, const Color
& rColor
, bool bXHTML
)
574 rStream
.WriteOString( "\"" );
576 rStream
.WriteOString( "color: " );
577 rStream
.WriteOString( "#" );
578 if( rColor
== COL_AUTO
)
580 rStream
.WriteOString( "000000" );
584 Out_Hex( rStream
, rColor
.GetRed(), 2 );
585 Out_Hex( rStream
, rColor
.GetGreen(), 2 );
586 Out_Hex( rStream
, rColor
.GetBlue(), 2 );
588 rStream
.WriteChar( '\"' );
593 SvStream
& HTMLOutFuncs::Out_ImageMap( SvStream
& rStream
,
594 const OUString
& rBaseURL
,
595 const ImageMap
& rIMap
,
596 const OUString
& rName
,
597 const HTMLOutEvent
*pEventTable
,
600 const char *pIndentArea
,
601 const char *pIndentMap
)
603 const OUString
& rOutName
= !rName
.isEmpty() ? rName
: rIMap
.GetName();
604 DBG_ASSERT( !rOutName
.isEmpty(), "No ImageMap-Name" );
605 if( rOutName
.isEmpty() )
609 OString::Concat("<") +
610 OOO_STRING_SVTOOLS_HTML_map
612 OOO_STRING_SVTOOLS_HTML_O_name
614 rStream
.WriteOString( sOut
);
616 Out_String( rStream
, rOutName
);
617 rStream
.WriteOString( "\">" );
619 for( size_t i
=0; i
<rIMap
.GetIMapObjectCount(); i
++ )
621 const IMapObject
* pObj
= rIMap
.GetIMapObject( i
);
622 DBG_ASSERT( pObj
, "Where is the ImageMap-Object?" );
626 const char *pShape
= nullptr;
628 switch( pObj
->GetType() )
630 case IMapObjectType::Rectangle
:
632 const IMapRectangleObject
* pRectObj
=
633 static_cast<const IMapRectangleObject
*>(pObj
);
634 pShape
= OOO_STRING_SVTOOLS_HTML_SH_rect
;
635 tools::Rectangle
aRect( pRectObj
->GetRectangle() );
638 OString::number(static_cast<sal_Int32
>(aRect
.Left()))
640 + OString::number(static_cast<sal_Int32
>(aRect
.Top()))
642 + OString::number(static_cast<sal_Int32
>(aRect
.Right()))
644 + OString::number(static_cast<sal_Int32
>(aRect
.Bottom()));;
647 case IMapObjectType::Circle
:
649 const IMapCircleObject
* pCirc
=
650 static_cast<const IMapCircleObject
*>(pObj
);
651 pShape
= OOO_STRING_SVTOOLS_HTML_SH_circ
;
652 Point
aCenter( pCirc
->GetCenter() );
653 tools::Long nOff
= pCirc
->GetRadius();
656 OString::number(static_cast<sal_Int32
>(aCenter
.X()))
658 + OString::number(static_cast<sal_Int32
>(aCenter
.Y()))
660 + OString::number(static_cast<sal_Int32
>(nOff
));
663 case IMapObjectType::Polygon
:
665 const IMapPolygonObject
* pPolyObj
=
666 static_cast<const IMapPolygonObject
*>(pObj
);
667 pShape
= OOO_STRING_SVTOOLS_HTML_SH_poly
;
668 tools::Polygon
aPoly( pPolyObj
->GetPolygon() );
669 sal_uInt16 nCount
= aPoly
.GetSize();
673 const Point
& rPoint
= aPoly
[0];
674 aTmpBuf
= OString::number(static_cast<sal_Int32
>(rPoint
.X()))
676 + OString::number(static_cast<sal_Int32
>(rPoint
.Y()));
678 for( sal_uInt16 j
=1; j
<nCount
; j
++ )
680 const Point
& rPoint
= aPoly
[j
];
683 + OString::number(static_cast<sal_Int32
>(rPoint
.X()))
685 + OString::number(static_cast<sal_Int32
>(rPoint
.Y()));
691 DBG_ASSERT( pShape
, "unknown IMapObject" );
698 rStream
.WriteOString( pDelim
);
700 rStream
.WriteOString( pIndentArea
);
702 sOut
.append(OString::Concat("<") + OOO_STRING_SVTOOLS_HTML_area
703 " " OOO_STRING_SVTOOLS_HTML_O_shape
705 OOO_STRING_SVTOOLS_HTML_O_coords
"=\"" +
707 rStream
.WriteOString( sOut
);
710 OUString
aURL( pObj
->GetURL() );
711 if( !aURL
.isEmpty() && pObj
->IsActive() )
713 aURL
= URIHelper::simpleNormalizedMakeRelative(
715 sOut
.append(OOO_STRING_SVTOOLS_HTML_O_href
"=\"");
716 rStream
.WriteOString( sOut
);
718 Out_String( rStream
, aURL
).WriteChar( '\"' );
721 rStream
.WriteOString( OOO_STRING_SVTOOLS_HTML_O_nohref
);
723 const OUString
& rObjName
= pObj
->GetName();
724 if( !rObjName
.isEmpty() )
726 sOut
.append(" " OOO_STRING_SVTOOLS_HTML_O_name
"=\"");
727 rStream
.WriteOString( sOut
);
729 Out_String( rStream
, rObjName
).WriteChar( '\"' );
732 const OUString
& rTarget
= pObj
->GetTarget();
733 if( !rTarget
.isEmpty() && pObj
->IsActive() )
735 sOut
.append(" " OOO_STRING_SVTOOLS_HTML_O_target
"=\"");
736 rStream
.WriteOString( sOut
);
738 Out_String( rStream
, rTarget
).WriteChar( '\"' );
741 OUString
rDesc( pObj
->GetAltText() );
742 if( rDesc
.isEmpty() )
743 rDesc
= pObj
->GetDesc();
745 if( !rDesc
.isEmpty() )
747 sOut
.append(" " OOO_STRING_SVTOOLS_HTML_O_alt
"=\"");
748 rStream
.WriteOString( sOut
);
750 Out_String( rStream
, rDesc
).WriteChar( '\"' );
753 const SvxMacroTableDtor
& rMacroTab
= pObj
->GetMacroTable();
754 if( pEventTable
&& !rMacroTab
.empty() )
755 Out_Events( rStream
, rMacroTab
, pEventTable
,
758 rStream
.WriteChar( '>' );
765 rStream
.WriteOString( pDelim
);
767 rStream
.WriteOString( pIndentMap
);
768 Out_AsciiTag( rStream
, OOO_STRING_SVTOOLS_HTML_map
, false );
773 SvStream
& HTMLOutFuncs::OutScript( SvStream
& rStrm
,
774 const OUString
& rBaseURL
,
775 std::u16string_view rSource
,
776 const OUString
& rLanguage
,
777 ScriptType eScriptType
,
778 const OUString
& rSrc
,
779 const OUString
*pSBLibrary
,
780 const OUString
*pSBModule
)
782 // script is not indented!
783 OStringBuffer
sOut("<" OOO_STRING_SVTOOLS_HTML_script
);
785 if( !rLanguage
.isEmpty() )
787 sOut
.append(" " OOO_STRING_SVTOOLS_HTML_O_language
"=\"");
788 rStrm
.WriteOString( sOut
);
790 Out_String( rStrm
, rLanguage
);
794 if( !rSrc
.isEmpty() )
796 sOut
.append(" " OOO_STRING_SVTOOLS_HTML_O_src
"=\"");
797 rStrm
.WriteOString( sOut
);
799 Out_String( rStrm
, URIHelper::simpleNormalizedMakeRelative(rBaseURL
, rSrc
) );
803 if( STARBASIC
!= eScriptType
&& pSBLibrary
)
805 sOut
.append(" " OOO_STRING_SVTOOLS_HTML_O_sdlibrary
"=\"");
806 rStrm
.WriteOString( sOut
);
808 Out_String( rStrm
, *pSBLibrary
);
812 if( STARBASIC
!= eScriptType
&& pSBModule
)
814 sOut
.append(" " OOO_STRING_SVTOOLS_HTML_O_sdmodule
"=\"");
815 rStrm
.WriteOString( sOut
);
817 Out_String( rStrm
, *pSBModule
);
823 rStrm
.WriteOString( sOut
);
826 if( !rSource
.empty() || pSBLibrary
|| pSBModule
)
828 rStrm
.WriteOString( SAL_NEWLINE_STRING
);
830 if( JAVASCRIPT
!= eScriptType
)
832 rStrm
.WriteOString( "<!--" )
833 .WriteOString( SAL_NEWLINE_STRING
);
836 if( STARBASIC
== eScriptType
)
840 sOut
.append("' " OOO_STRING_SVTOOLS_HTML_SB_library
" " +
841 OUStringToOString(*pSBLibrary
, RTL_TEXTENCODING_UTF8
));
842 rStrm
.WriteOString( sOut
).WriteOString( SAL_NEWLINE_STRING
);
848 sOut
.append("' " OOO_STRING_SVTOOLS_HTML_SB_module
" " +
849 OUStringToOString(*pSBModule
, RTL_TEXTENCODING_UTF8
));
850 rStrm
.WriteOString( sOut
).WriteOString( SAL_NEWLINE_STRING
);
855 if( !rSource
.empty() )
857 // we write the module in ANSI-charset, but with
858 // the system new line.
859 const OString
sSource(OUStringToOString(rSource
, RTL_TEXTENCODING_UTF8
));
860 rStrm
.WriteOString( sSource
).WriteOString( SAL_NEWLINE_STRING
);
862 rStrm
.WriteOString( SAL_NEWLINE_STRING
);
864 if( JAVASCRIPT
!= eScriptType
)
866 // MIB/MM: if it is not StarBasic, a // could be wrong.
867 // As the comment is removed during reading, it is not helping us...
868 rStrm
.WriteOString( STARBASIC
== eScriptType
? "' -->" : "// -->" )
869 .WriteOString( SAL_NEWLINE_STRING
);
873 HTMLOutFuncs::Out_AsciiTag( rStrm
, OOO_STRING_SVTOOLS_HTML_script
, false );
879 SvStream
& HTMLOutFuncs::Out_Events( SvStream
& rStrm
,
880 const SvxMacroTableDtor
& rMacroTable
,
881 const HTMLOutEvent
*pEventTable
,
883 OUString
*pNonConvertableChars
)
886 while( pEventTable
[i
].pBasicName
|| pEventTable
[i
].pJavaName
)
888 const SvxMacro
*pMacro
=
889 rMacroTable
.Get( pEventTable
[i
].nEvent
);
891 if( pMacro
&& pMacro
->HasMacro() &&
892 ( JAVASCRIPT
== pMacro
->GetScriptType() || bOutStarBasic
))
894 const char *pStr
= STARBASIC
== pMacro
->GetScriptType()
895 ? pEventTable
[i
].pBasicName
896 : pEventTable
[i
].pJavaName
;
900 OString sOut
= OString::Concat(" ") + pStr
+ "=\"";
901 rStrm
.WriteOString( sOut
);
903 Out_String( rStrm
, pMacro
->GetMacName(), pNonConvertableChars
).WriteChar( '\"' );
912 OString
HTMLOutFuncs::CreateTableDataOptionsValNum(
914 double fVal
, sal_uInt32 nFormat
, SvNumberFormatter
& rFormatter
,
915 OUString
* pNonConvertableChars
)
917 OStringBuffer aStrTD
;
921 // printf / scanf is not precise enough
923 rFormatter
.GetInputLineString( fVal
, 0, aValStr
);
924 OString
sTmp(OUStringToOString(aValStr
, RTL_TEXTENCODING_UTF8
));
925 aStrTD
.append(" " OOO_STRING_SVTOOLS_HTML_O_SDval
"=\"" +
928 if ( bValue
|| nFormat
)
930 aStrTD
.append(" " OOO_STRING_SVTOOLS_HTML_O_SDnum
"=\"" +
931 OString::number(static_cast<sal_uInt16
>(
932 Application::GetSettings().GetLanguageTag().getLanguageType())) +
933 ";"); // Language for Format 0
938 const SvNumberformat
* pFormatEntry
= rFormatter
.GetEntry( nFormat
);
941 aNumStr
= ConvertStringToHTML( pFormatEntry
->GetFormatstring(),
942 pNonConvertableChars
);
943 nLang
= pFormatEntry
->GetLanguage();
946 nLang
= LANGUAGE_SYSTEM
;
948 OString::number(static_cast<sal_Int32
>(static_cast<sal_uInt16
>(nLang
)))
954 return aStrTD
.makeStringAndClear();
957 bool HTMLOutFuncs::PrivateURLToInternalImg( OUString
& rURL
)
959 if( rURL
.startsWith(OOO_STRING_SVTOOLS_HTML_private_image
) )
961 rURL
= rURL
.copy( strlen(OOO_STRING_SVTOOLS_HTML_private_image
) );
968 void HtmlWriterHelper::applyColor(HtmlWriter
& rHtmlWriter
, std::string_view aAttributeName
, const Color
& rColor
)
970 OStringBuffer sBuffer
;
972 if( rColor
== COL_AUTO
)
974 sBuffer
.append("#000000");
979 std::ostringstream sStringStream
;
985 << sal_uInt32(rColor
.GetRGBColor());
986 sBuffer
.append(sStringStream
.str().c_str());
989 rHtmlWriter
.attribute(aAttributeName
, sBuffer
);
993 void HtmlWriterHelper::applyEvents(HtmlWriter
& rHtmlWriter
, const SvxMacroTableDtor
& rMacroTable
, const HTMLOutEvent
* pEventTable
, bool bOutStarBasic
)
996 while (pEventTable
[i
].pBasicName
|| pEventTable
[i
].pJavaName
)
998 const SvxMacro
* pMacro
= rMacroTable
.Get(pEventTable
[i
].nEvent
);
1000 if (pMacro
&& pMacro
->HasMacro() && (JAVASCRIPT
== pMacro
->GetScriptType() || bOutStarBasic
))
1002 const char* pAttributeName
= nullptr;
1003 if (STARBASIC
== pMacro
->GetScriptType())
1004 pAttributeName
= pEventTable
[i
].pBasicName
;
1006 pAttributeName
= pEventTable
[i
].pJavaName
;
1010 rHtmlWriter
.attribute(pAttributeName
, OUStringToOString(pMacro
->GetMacName(), RTL_TEXTENCODING_UTF8
));
1017 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */