xref: /aoo41x/main/sw/source/filter/html/htmlfldw.cxx (revision c0286415)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <com/sun/star/i18n/ScriptType.hpp>
29 #include <tools/string.hxx>
30 #include <svtools/htmlkywd.hxx>
31 #include <svtools/htmlout.hxx>
32 #include <svtools/htmltokn.h>
33 #include <fmtfld.hxx>
34 #include <doc.hxx>
35 #include <breakit.hxx>
36 #include <ndtxt.hxx>
37 #include <txtfld.hxx>
38 #include "fldbas.hxx"
39 #include "docufld.hxx"
40 #include "flddat.hxx"
41 #include "htmlfld.hxx"
42 #include "wrthtml.hxx"
43 
44 using namespace nsSwDocInfoSubType;
45 
GetNumFormat(sal_uInt16 nFmt)46 const sal_Char *SwHTMLWriter::GetNumFormat( sal_uInt16 nFmt )
47 {
48 	const sal_Char *pFmtStr = 0;
49 
50 	switch( (SvxExtNumType)nFmt )
51 	{
52 	case SVX_NUM_CHARS_UPPER_LETTER:	pFmtStr = OOO_STRING_SW_HTML_FF_uletter; 	break;
53 	case SVX_NUM_CHARS_LOWER_LETTER:	pFmtStr = OOO_STRING_SW_HTML_FF_lletter; 	break;
54 	case SVX_NUM_ROMAN_UPPER:			pFmtStr = OOO_STRING_SW_HTML_FF_uroman; 		break;
55 	case SVX_NUM_ROMAN_LOWER:			pFmtStr = OOO_STRING_SW_HTML_FF_lroman; 		break;
56 	case SVX_NUM_ARABIC:				pFmtStr = OOO_STRING_SW_HTML_FF_arabic;	 	break;
57 	case SVX_NUM_NUMBER_NONE:			pFmtStr = OOO_STRING_SW_HTML_FF_none; 		break;
58 	case SVX_NUM_CHAR_SPECIAL:			pFmtStr = OOO_STRING_SW_HTML_FF_char; 		break;
59 	case SVX_NUM_PAGEDESC:				pFmtStr = OOO_STRING_SW_HTML_FF_page; 		break;
60 	case SVX_NUM_CHARS_UPPER_LETTER_N:	pFmtStr = OOO_STRING_SW_HTML_FF_ulettern; 	break;
61 	case SVX_NUM_CHARS_LOWER_LETTER_N:	pFmtStr = OOO_STRING_SW_HTML_FF_llettern; 	break;
62 	default:
63 		;
64 	}
65 
66 	return pFmtStr;
67 }
68 
69 extern sal_Bool lcl_css1atr_equalFontItems( const SfxPoolItem& r1, const SfxPoolItem& r2 );
OutHTML_SwField(Writer & rWrt,const SwField * pFld,const SwTxtNode & rTxtNd,xub_StrLen nFldPos)70 static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pFld,
71 							 	const SwTxtNode& rTxtNd, xub_StrLen nFldPos )
72 {
73 	SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
74 
75 	const SwFieldType* pFldTyp = pFld->GetTyp();
76 	sal_uInt16 nField = pFldTyp->Which();
77 	sal_uLong nFmt = pFld->GetFormat();
78 
79 	const sal_Char *pTypeStr=0,	// TYPE
80 			   	   *pSubStr=0, 	// SUBTYPE
81 			       *pFmtStr=0;	// FORMAT (SW)
82 	String aValue;				// VALUE (SW)
83 	sal_Bool bNumFmt=sal_False;			// SDNUM (Number-Formatter-Format)
84 	sal_Bool bNumValue=sal_False;  		// SDVAL (Number-Formatter-Value)
85 	double dNumValue = 0.0;	 	// SDVAL (Number-Formatter-Value)
86 	sal_Bool bFixed=sal_False;			// SDFIXED
87     String aName;               // NAME (CUSTOM)
88 
89 	switch( nField )
90 	{
91 		case RES_EXTUSERFLD:
92 			pTypeStr = OOO_STRING_SW_HTML_FT_sender;
93 			switch( (SwExtUserSubType)pFld->GetSubType() )
94 			{
95 				case EU_COMPANY:  	pSubStr = OOO_STRING_SW_HTML_FS_company;		break;
96 				case EU_FIRSTNAME:	pSubStr = OOO_STRING_SW_HTML_FS_firstname;	break;
97 				case EU_NAME: 		pSubStr = OOO_STRING_SW_HTML_FS_name;		break;
98 				case EU_SHORTCUT:	pSubStr = OOO_STRING_SW_HTML_FS_shortcut;	break;
99 				case EU_STREET: 	pSubStr = OOO_STRING_SW_HTML_FS_street;		break;
100 				case EU_COUNTRY:	pSubStr = OOO_STRING_SW_HTML_FS_country;     break;
101 				case EU_ZIP: 		pSubStr = OOO_STRING_SW_HTML_FS_zip;         break;
102 				case EU_CITY: 		pSubStr = OOO_STRING_SW_HTML_FS_city;        break;
103 				case EU_TITLE: 		pSubStr = OOO_STRING_SW_HTML_FS_title;       break;
104 				case EU_POSITION:	pSubStr = OOO_STRING_SW_HTML_FS_position;    break;
105 				case EU_PHONE_PRIVATE:	pSubStr = OOO_STRING_SW_HTML_FS_pphone;      break;
106 				case EU_PHONE_COMPANY:	pSubStr = OOO_STRING_SW_HTML_FS_cphone;      break;
107 				case EU_FAX: 		pSubStr = OOO_STRING_SW_HTML_FS_fax;         break;
108 				case EU_EMAIL:  	pSubStr = OOO_STRING_SW_HTML_FS_email;       break;
109 				case EU_STATE:  	pSubStr = OOO_STRING_SW_HTML_FS_state;       break;
110 				default:
111 					;
112 			}
113 			ASSERT( pSubStr, "ubekannter Subtyp fuer SwExtUserField" );
114 			bFixed = ((const SwExtUserField*)pFld)->IsFixed();
115 			break;
116 
117 		case RES_AUTHORFLD:
118 			pTypeStr = OOO_STRING_SW_HTML_FT_author;
119 			switch( (SwAuthorFormat)nFmt & 0xff)
120 			{
121 				case AF_NAME: 	  pFmtStr = OOO_STRING_SW_HTML_FF_name;		break;
122 				case AF_SHORTCUT:  pFmtStr = OOO_STRING_SW_HTML_FF_shortcut;	break;
123 			}
124 			ASSERT( pFmtStr, "ubekanntes Format fuer SwAuthorField" );
125 			bFixed = ((const SwAuthorField*)pFld)->IsFixed();
126 			break;
127 
128 		case RES_DATETIMEFLD:
129 			pTypeStr = OOO_STRING_SW_HTML_FT_datetime;
130 			bNumFmt = sal_True;
131 			if( ((SwDateTimeField*)pFld)->IsFixed() )
132 			{
133 				bNumValue = sal_True;
134 				dNumValue = ((SwDateTimeField*)pFld)->GetValue();
135 			}
136 			break;
137 
138 		case RES_PAGENUMBERFLD:
139 			{
140 				pTypeStr = OOO_STRING_SW_HTML_FT_page;
141 				SwPageNumSubType eSubType = (SwPageNumSubType)pFld->GetSubType();
142 				switch( eSubType )
143 				{
144 					case PG_RANDOM:		pSubStr = OOO_STRING_SW_HTML_FS_random;		break;
145 					case PG_NEXT:       pSubStr = OOO_STRING_SW_HTML_FS_next;		break;
146 					case PG_PREV:       pSubStr = OOO_STRING_SW_HTML_FS_prev;		break;
147 				}
148 				ASSERT( pSubStr, "ubekannter Subtyp fuer SwPageNumberField" );
149                 pFmtStr = SwHTMLWriter::GetNumFormat( static_cast< sal_uInt16 >(nFmt) );
150 
151 				if( (SvxExtNumType)nFmt==SVX_NUM_CHAR_SPECIAL )
152 				{
153 					aValue = ((const SwPageNumberField *)pFld)->GetUserString();
154 				}
155 				else
156 				{
157 					const String& rValue = pFld->GetPar2();
158 					short nValue = (short)rValue.ToInt32();
159 					if( (eSubType == PG_NEXT && nValue!=1) ||
160 						(eSubType == PG_PREV && nValue!=-1) ||
161 						(eSubType == PG_RANDOM && nValue!=0) )
162 					{
163 						aValue = rValue;
164 					}
165 				}
166 			}
167 			break;
168 		case RES_DOCINFOFLD:
169 			{
170 				sal_uInt16 nSubType = pFld->GetSubType();
171 				pTypeStr = OOO_STRING_SW_HTML_FT_docinfo;
172 				sal_uInt16 nExtSubType = nSubType & 0x0f00;
173 				nSubType &= 0x00ff;
174 
175 				switch( nSubType )
176 				{
177 					case DI_TITEL:    	pSubStr = OOO_STRING_SW_HTML_FS_title; 	break;
178 					case DI_THEMA:    	pSubStr = OOO_STRING_SW_HTML_FS_theme; 	break;
179 					case DI_KEYS:    	pSubStr = OOO_STRING_SW_HTML_FS_keys; 	break;
180 					case DI_COMMENT:    pSubStr = OOO_STRING_SW_HTML_FS_comment; break;
181 					case DI_CREATE:    	pSubStr = OOO_STRING_SW_HTML_FS_create; 	break;
182 					case DI_CHANGE:   	pSubStr = OOO_STRING_SW_HTML_FS_change; 	break;
183 					case DI_CUSTOM:   	pSubStr = OOO_STRING_SW_HTML_FS_custom; 	break;
184 					default:			pTypeStr = 0; 				break;
185 				}
186 
187                 if( DI_CUSTOM == nSubType ) {
188                     aName = static_cast<const SwDocInfoField*>(pFld)->GetName();
189                 }
190 
191 				if( DI_CREATE == nSubType || DI_CHANGE == nSubType )
192 				{
193 					switch( nExtSubType )
194 					{
195 						case DI_SUB_AUTHOR:
196 							pFmtStr = OOO_STRING_SW_HTML_FF_author;
197 							break;
198 						case DI_SUB_TIME:
199 							pFmtStr = OOO_STRING_SW_HTML_FF_time;
200 							bNumFmt = sal_True;
201 							break;
202 						case DI_SUB_DATE:
203 							pFmtStr = OOO_STRING_SW_HTML_FF_date;
204 							bNumFmt = sal_True;
205 							break;
206 					}
207 				}
208 				bFixed = ((const SwDocInfoField*)pFld)->IsFixed();
209 				if( bNumFmt )
210 				{
211 					if( bFixed )
212 					{
213 						// Fuer ein fixes Feld och den Num-Value ausgeben.
214 						// Fixe Felder ohne Zahlenformate sollte es
215 						// eigentlich nicht geben. ASSERT ist unten.
216 						dNumValue = ((const SwDocInfoField*)pFld)->GetValue();
217 						bNumValue = sal_True;
218 					}
219 					else if( !nFmt  )
220 					{
221 						// Nicht fixe Felder muessen kein Zahlenformat haben,
222 						// wenn sie aus 4.0-Dokumenten stammen.
223 						bNumFmt = sal_False;
224 					}
225 				}
226 			}
227 			break;
228 
229 		case RES_DOCSTATFLD:
230 			{
231 				pTypeStr = OOO_STRING_SW_HTML_FT_docstat;
232 				sal_uInt16 nSubType = pFld->GetSubType();
233 				switch( nSubType )
234 				{
235 					case DS_PAGE:    	pSubStr = OOO_STRING_SW_HTML_FS_page; 	break;
236 					case DS_PARA:    	pSubStr = OOO_STRING_SW_HTML_FS_para; 	break;
237 					case DS_WORD:    	pSubStr = OOO_STRING_SW_HTML_FS_word; 	break;
238 					case DS_CHAR:    	pSubStr = OOO_STRING_SW_HTML_FS_char; 	break;
239 					case DS_TBL:    	pSubStr = OOO_STRING_SW_HTML_FS_tbl; 	break;
240 					case DS_GRF:    	pSubStr = OOO_STRING_SW_HTML_FS_grf; 	break;
241 					case DS_OLE:    	pSubStr = OOO_STRING_SW_HTML_FS_ole; 	break;
242 					default:			pTypeStr = 0; 				break;
243 				}
244                 pFmtStr = SwHTMLWriter::GetNumFormat( static_cast< sal_uInt16 >(nFmt) );
245 			}
246 			break;
247 
248 		case RES_FILENAMEFLD:
249 			pTypeStr = OOO_STRING_SW_HTML_FT_filename;
250 			switch( (SwFileNameFormat)(nFmt & ~FF_FIXED) )
251 			{
252 				case FF_NAME: 	  	pFmtStr = OOO_STRING_SW_HTML_FF_name;		break;
253 				case FF_PATHNAME: 	pFmtStr = OOO_STRING_SW_HTML_FF_pathname;	break;
254 				case FF_PATH:     	pFmtStr = OOO_STRING_SW_HTML_FF_path;		break;
255 				case FF_NAME_NOEXT:	pFmtStr = OOO_STRING_SW_HTML_FF_name_noext;	break;
256 				default:
257 					;
258 			}
259 			bFixed = ((const SwFileNameField*)pFld)->IsFixed();
260 			ASSERT( pFmtStr, "unbekanntes Format fuer SwFileNameField" );
261 			break;
262 	}
263 
264 	// <SDFIELD>-Tag ausgeben
265 	if( pTypeStr )
266 	{
267 		ByteString sOut( '<' );
268 		((((sOut += OOO_STRING_SVTOOLS_HTML_sdfield) += ' ') += OOO_STRING_SVTOOLS_HTML_O_type) += '=')
269 			+= pTypeStr;
270 		if( pSubStr )
271 			(((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_subtype) += '=') += pSubStr;
272 		if( pFmtStr )
273 			(((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_format) += '=') += pFmtStr;
274 		if( aName.Len() )
275 		{
276 			(((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_name) += "=\"");
277 			rWrt.Strm() << sOut.GetBuffer();
278 			HTMLOutFuncs::Out_String( rWrt.Strm(), aName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
279 			sOut = '\"';
280         }
281 		if( aValue.Len() )
282 		{
283 			((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_value) += "=\"";
284 			rWrt.Strm() << sOut.GetBuffer();
285 			HTMLOutFuncs::Out_String( rWrt.Strm(), aValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
286 			sOut = '\"';
287 		}
288 		if( bNumFmt )
289 		{
290 			ASSERT( nFmt, "Zahlenformat ist 0" );
291 			sOut = HTMLOutFuncs::CreateTableDataOptionsValNum( sOut,
292 						bNumValue, dNumValue, nFmt,
293 						*rHTMLWrt.pDoc->GetNumberFormatter(),
294                         rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
295 
296 		}
297 		if( bFixed )
298 			(sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_sdfixed;
299 		sOut += '>';
300 		rWrt.Strm() << sOut.GetBuffer();
301 	}
302 
303 	// Inhalt des Feldes ausgeben
304     String const sExpand( pFld->ExpandField(true) );
305 	sal_Bool bNeedsCJKProcessing = sal_False;
306 	if( sExpand.Len() )
307 	{
308 		sal_uInt16 nScriptType = pBreakIt->GetBreakIter()->getScriptType( sExpand, 0 );
309 		xub_StrLen nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( sExpand, 0,
310 														  nScriptType );
311 
312 		sal_uInt16 nScript =
313 			SwHTMLWriter::GetCSS1ScriptForScriptType( nScriptType );
314 		if( nPos < sExpand.Len() || nScript != rHTMLWrt.nCSS1Script )
315 		{
316 			bNeedsCJKProcessing = sal_True;
317 		}
318 	}
319 
320 	if( bNeedsCJKProcessing )
321 	{
322 		SfxItemSet aScriptItemSet( rWrt.pDoc->GetAttrPool(),
323 								   RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
324 								   RES_CHRATR_POSTURE, RES_CHRATR_POSTURE,
325 								   RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
326 								   RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT,
327 								   0 );
328 		rTxtNd.GetAttr( aScriptItemSet, nFldPos, nFldPos+1 );
329 
330 		sal_uInt16 aWesternWhichIds[4] =
331 			{ RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
332 			  RES_CHRATR_POSTURE, RES_CHRATR_WEIGHT };
333 		sal_uInt16 aCJKWhichIds[4] =
334 			{ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONTSIZE,
335 			  RES_CHRATR_CJK_POSTURE, RES_CHRATR_CJK_WEIGHT };
336 		sal_uInt16 aCTLWhichIds[4] =
337 			{ RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONTSIZE,
338 			  RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT };
339 
340 		sal_uInt16 *pRefWhichIds = 0;
341 		switch( rHTMLWrt.nCSS1Script )
342 		{
343 		case CSS1_OUTMODE_WESTERN:
344 			pRefWhichIds = aWesternWhichIds;
345 			break;
346 		case CSS1_OUTMODE_CJK:
347 			pRefWhichIds = aCJKWhichIds;
348 			break;
349 		case CSS1_OUTMODE_CTL:
350 			pRefWhichIds = aCTLWhichIds;
351 			break;
352 		}
353 
354 		xub_StrLen nPos = 0;
355 		do
356 		{
357 			sal_uInt16 nScriptType = pBreakIt->GetBreakIter()->getScriptType( sExpand, nPos );
358 			sal_uInt16 nScript =
359 				SwHTMLWriter::GetCSS1ScriptForScriptType( nScriptType );
360 			xub_StrLen nEndPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript(
361 									sExpand, nPos, nScriptType );
362 			if( nScript != CSS1_OUTMODE_ANY_SCRIPT &&
363                 /* #108791# */ nScript != rHTMLWrt.nCSS1Script )
364 			{
365 				sal_uInt16 *pWhichIds = 0;
366 				switch( nScript )
367 				{
368 				case CSS1_OUTMODE_WESTERN:	pWhichIds = aWesternWhichIds; break;
369 				case CSS1_OUTMODE_CJK:		pWhichIds = aCJKWhichIds; break;
370 				case CSS1_OUTMODE_CTL:		pWhichIds = aCTLWhichIds; break;
371 				}
372 
373 				rHTMLWrt.bTagOn = sal_True;
374 				const SfxPoolItem *aItems[5];
375 				sal_uInt16 nItems = 0;
376 				for( sal_uInt16 i=0; i<4; i++ )
377 				{
378 					const SfxPoolItem *pRefItem =
379 						aScriptItemSet.GetItem( pRefWhichIds[i] );
380 					const SfxPoolItem *pItem =
381 						aScriptItemSet.GetItem( pWhichIds[i] );
382 					if( pRefItem && pItem &&
383 						!(0==i ? lcl_css1atr_equalFontItems( *pRefItem, *pItem )
384 							   : *pRefItem == *pItem) )
385 					{
386 						Out( aHTMLAttrFnTab, *pItem, rHTMLWrt );
387 						aItems[nItems++] = pItem;
388 					}
389 				}
390 
391 				HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.Copy( nPos, nEndPos ),
392 					rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
393 
394 				rHTMLWrt.bTagOn = sal_False;
395 				while( nItems )
396 					Out( aHTMLAttrFnTab, *aItems[--nItems], rHTMLWrt );
397 
398 			}
399 			else
400 			{
401 				HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.Copy( nPos, nEndPos ),
402 					rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
403 			}
404 			nPos = nEndPos;
405 		}
406 		while( nPos < sExpand.Len() );
407 	}
408 	else
409 	{
410 		HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand,
411 			  rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
412 	}
413 
414 	// Off-Tag ausgeben
415 	if( pTypeStr )
416 		HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_sdfield, sal_False );
417 
418 	return rWrt;
419 }
420 
421 
OutHTML_SwFmtFld(Writer & rWrt,const SfxPoolItem & rHt)422 Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt )
423 {
424 	SwFmtFld & rFld = (SwFmtFld&)rHt;
425 	const SwField* pFld = rFld.GetField();
426 	const SwFieldType* pFldTyp = pFld->GetTyp();
427 
428 	if( RES_SETEXPFLD == pFldTyp->Which() &&
429 		(nsSwGetSetExpType::GSE_STRING & pFld->GetSubType()) )
430 	{
431 		int bOn = sal_False;
432 		if( pFldTyp->GetName().EqualsAscii("HTML_ON" ) )
433 			bOn = sal_True;
434 		else if( !pFldTyp->GetName().EqualsAscii( "HTML_OFF" ) )
435 			return rWrt;
436 
437 		String rTxt( pFld->GetPar2() );
438 		rTxt.EraseLeadingChars().EraseTrailingChars();
439 		rWrt.Strm() << '<';
440 		if( !bOn )
441 			rWrt.Strm() << '/';
442 		// TODO: HTML-Tags are written without entitities, that for, characters
443 		// not contained in the destination encoding are lost!
444 		ByteString sTmp( rTxt, ((SwHTMLWriter&)rWrt).eDestEnc );
445 		rWrt.Strm() << sTmp.GetBuffer() << '>';
446 	}
447 	else if( RES_POSTITFLD == pFldTyp->Which() )
448 	{
449 		// Kommentare werden im ANSI-Zeichensetz, aber mit System-Zeilen-
450 		// Umbruechen gesschrieben.
451 		const String& rComment = pFld->GetPar2();
452 		sal_Bool bWritten = sal_False;
453 
454 		if( (rComment.Len() >= 6 && '<' == rComment.GetChar(0) &&
455 			'>' == rComment.GetChar(rComment.Len()-1) &&
456 			rComment.Copy( 1, 4 ).EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_meta)) ||
457 		  	(rComment.Len() >= 7 &&
458 			 rComment.Copy( 0, 4 ).EqualsAscii( "<!--" ) &&
459 			 rComment.Copy( rComment.Len()-3, 3 ).EqualsAscii( "-->" )) )
460 		{
461 			// META-Tags direkt ausgeben
462 			String sComment( rComment );
463 			sComment.ConvertLineEnd( GetSystemLineEnd() );
464 			// TODO: HTML-Tags are written without entitities, that for,
465 			// characters not contained in the destination encoding are lost!
466 			ByteString sTmp( sComment, ((SwHTMLWriter&)rWrt).eDestEnc );
467 			rWrt.Strm() << sTmp.GetBuffer();
468 			bWritten = sal_True;
469 		}
470 		else if( rComment.Len() >= 7 &&
471 				 '>' == rComment.GetChar(rComment.Len()-1) &&
472 				 rComment.Copy(0,5).EqualsIgnoreCaseAscii("HTML:") )
473 		{
474 			String sComment( rComment.Copy(5) );
475 			sComment.EraseLeadingChars();
476 			if( '<' == sComment.GetChar(0) )
477 			{
478 				sComment.ConvertLineEnd( GetSystemLineEnd() );
479 				// TODO: HTML-Tags are written without entitities, that for,
480 				// characters not contained in the destination encoding are
481 				// lost!
482 				ByteString sTmp( sComment, ((SwHTMLWriter&)rWrt).eDestEnc );
483 				rWrt.Strm() << sTmp.GetBuffer();
484 				bWritten = sal_True;
485 			}
486 
487 		}
488 
489 		if( !bWritten )
490 		{
491 			ByteString sOut( '<' );
492 
493 			String sComment( rComment );
494 			sComment.ConvertLineEnd( GetSystemLineEnd() );
495 			// TODO: ???
496 			(((sOut += OOO_STRING_SVTOOLS_HTML_comment) += ' ')
497 				+= ByteString( sComment, ((SwHTMLWriter&)rWrt).eDestEnc ))
498 				+= " -->";
499 			rWrt.Strm() << sOut.GetBuffer();
500 		}
501 	}
502 	else if( RES_SCRIPTFLD == pFldTyp->Which() )
503 	{
504 		SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
505 		if( rHTMLWrt.bLFPossible )
506 			rHTMLWrt.OutNewLine( sal_True );
507 
508 		sal_Bool bURL = ((const SwScriptField *)pFld)->IsCodeURL();
509 		const String& rType = pFld->GetPar1();
510 		String aContents, aURL;
511 		if(bURL)
512 			aURL = pFld->GetPar2();
513 		else
514 			aContents = pFld->GetPar2();
515 
516 		// sonst ist es der Script-Inhalt selbst. Da nur noh JavaScript
517 		// in Feldern landet, muss es sich um JavaSrript handeln ...:)
518         HTMLOutFuncs::OutScript( rWrt.Strm(), rWrt.GetBaseURL(), aContents, rType, JAVASCRIPT,
519 								 aURL, 0, 0, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
520 
521 		if( rHTMLWrt.bLFPossible )
522 			rHTMLWrt.OutNewLine( sal_True );
523 	}
524 	else
525 	{
526 		const SwTxtFld *pTxtFld = rFld.GetTxtFld();
527 		ASSERT( pTxtFld, "Where is the txt fld?" );
528 		if( pTxtFld )
529 			OutHTML_SwField( rWrt, pFld, pTxtFld->GetTxtNode(),
530 							 *pTxtFld->GetStart()  );
531 	}
532 	return rWrt;
533 }
534 
535 
536