xref: /trunk/main/sw/source/filter/html/htmlftn.cxx (revision efeef26f)
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 
29 
30 #include <svtools/htmlout.hxx>
31 #include <svtools/htmlkywd.hxx>
32 #include <errhdl.hxx>
33 #include <ndindex.hxx>
34 #include <fmtftn.hxx>
35 #include <txtftn.hxx>
36 #include <ftninfo.hxx>
37 #include <doc.hxx>
38 #include <ndtxt.hxx>
39 #include <charfmt.hxx>
40 
41 
42 #include "swhtml.hxx"
43 #include "wrthtml.hxx"
44 
45 typedef SwTxtFtn *SwTxtFtnPtr;
46 SV_DECL_PTRARR( SwHTMLTxtFtns, SwTxtFtnPtr, 1, 1 )
47 
48 struct SwHTMLFootEndNote_Impl
49 {
50 	SwHTMLTxtFtns aTxtFtns;
51 	SvStringsDtor aNames;
52 
53 	String sName;
54 	String sContent;			// Infos fuer die letzte Fussnote
55 	sal_Bool bEndNote;
56 	sal_Bool bFixed;
57 };
58 
59 
lcl_html_getNextPart(String & rPart,const String & rContent,xub_StrLen nPos)60 xub_StrLen lcl_html_getNextPart( String& rPart, const String& rContent,
61 							 xub_StrLen nPos )
62 {
63 	rPart = aEmptyStr;
64 	xub_StrLen nLen = rContent.Len();
65 	if( nPos >= nLen )
66 	{
67 		nPos = STRING_MAXLEN;
68 	}
69 	else
70 	{
71 		sal_Bool bQuoted = sal_False, bDone = sal_False;
72 		for( ; nPos < nLen && !bDone; nPos++ )
73 		{
74 			sal_Unicode c = rContent.GetChar( nPos );
75 			switch( c )
76 			{
77 			case '\\':
78 				if( bQuoted )
79 					rPart += c;
80 				bQuoted = !bQuoted;
81 				break;
82 
83 			case ';':
84 				if( bQuoted )
85 					rPart += c;
86 				else
87 					bDone = sal_True;
88 				bQuoted = sal_False;
89 				break;
90 
91 			default:
92 				rPart += c;
93 				bQuoted = sal_False;
94 				break;
95 			}
96 		}
97 	}
98 
99 	return nPos;
100 }
101 
lcl_html_getEndNoteInfo(SwEndNoteInfo & rInfo,const String & rContent,sal_Bool bEndNote)102 xub_StrLen lcl_html_getEndNoteInfo( SwEndNoteInfo& rInfo,
103 									const String& rContent,
104 									sal_Bool bEndNote )
105 {
106 	xub_StrLen nStrPos = 0;
107 	for( sal_uInt16 nPart = 0; nPart < 4; nPart++ )
108 	{
109 		String aPart;
110 		if( STRING_MAXLEN != nStrPos )
111 			nStrPos = lcl_html_getNextPart( aPart, rContent, nStrPos );
112 
113 		switch( nPart )
114 		{
115 		case 0:
116             rInfo.aFmt.SetNumberingType( static_cast< sal_Int16 >(bEndNote ? SVX_NUM_ROMAN_LOWER : SVX_NUM_ARABIC));
117 			if( aPart.Len() )
118 				rInfo.aFmt.SetNumberingType(SwHTMLParser::GetNumType( aPart,
119 															 rInfo.aFmt.GetNumberingType() ));
120 			break;
121 
122 		case 1:
123 			rInfo.nFtnOffset = aPart.Len() == 0 ? 0 : (sal_uInt16)aPart.ToInt32();
124 			break;
125 
126 		case 2:
127 			rInfo.SetPrefix( aPart );
128 			break;
129 
130 		case 3:
131 			rInfo.SetSuffix( aPart );
132 			break;
133 		}
134 	}
135 
136 	return nStrPos;
137 }
138 
FillEndNoteInfo(const String & rContent)139 void SwHTMLParser::FillEndNoteInfo( const String& rContent )
140 {
141 	SwEndNoteInfo aInfo( pDoc->GetEndNoteInfo() );
142 	lcl_html_getEndNoteInfo( aInfo, rContent, sal_True );
143 	pDoc->SetEndNoteInfo( aInfo );
144 }
145 
FillFootNoteInfo(const String & rContent)146 void SwHTMLParser::FillFootNoteInfo( const String& rContent )
147 {
148 	SwFtnInfo aInfo( pDoc->GetFtnInfo() );
149 
150 	xub_StrLen nStrPos = lcl_html_getEndNoteInfo( aInfo, rContent, sal_False );
151 
152 	for( sal_uInt16 nPart = 4; nPart < 8; nPart++ )
153 	{
154 		String aPart;
155 		if( STRING_MAXLEN != nStrPos )
156 			nStrPos = lcl_html_getNextPart( aPart, rContent, nStrPos );
157 
158 		switch( nPart )
159 		{
160 		case 4:
161 			aInfo.eNum = FTNNUM_DOC;
162 			if( aPart.Len() )
163 			{
164 				switch( aPart.GetChar(0) )
165 				{
166 				case 'D': aInfo.eNum = FTNNUM_DOC; break;
167 				case 'C': aInfo.eNum = FTNNUM_CHAPTER; break;
168 				case 'P': aInfo.eNum = FTNNUM_PAGE; break;
169 				}
170 			}
171 			break;
172 
173 		case 5:
174 			aInfo.ePos = FTNPOS_PAGE;
175 			if( aPart.Len() )
176 			{
177 				switch( aPart.GetChar(0) )
178 				{
179 				case 'C': aInfo.ePos = FTNPOS_CHAPTER; break;
180 				case 'P': aInfo.ePos = FTNPOS_PAGE; break;
181 				}
182 			}
183 			break;
184 
185 		case 6:
186 			aInfo.aQuoVadis = aPart;
187 			break;
188 
189 		case 7:
190 			aInfo.aErgoSum = aPart;
191 			break;
192 		}
193 	}
194 
195 	pDoc->SetFtnInfo( aInfo );
196 }
197 
InsertFootEndNote(const String & rName,sal_Bool bEndNote,sal_Bool bFixed)198 void SwHTMLParser::InsertFootEndNote( const String& rName, sal_Bool bEndNote,
199 									  sal_Bool bFixed )
200 {
201 	if( !pFootEndNoteImpl )
202 		pFootEndNoteImpl = new SwHTMLFootEndNote_Impl;
203 
204 	pFootEndNoteImpl->sName = rName;
205 	if( pFootEndNoteImpl->sName.Len() > 3 )
206 		pFootEndNoteImpl->sName.Erase( pFootEndNoteImpl->sName.Len() - 3 );
207 	// TODO: ToUpperAscii???
208 	pFootEndNoteImpl->sName.ToUpperAscii();
209 
210 	pFootEndNoteImpl->bEndNote = bEndNote;
211 	pFootEndNoteImpl->bFixed = bFixed;
212 	pFootEndNoteImpl->sContent = aEmptyStr;
213 }
214 
FinishFootEndNote()215 void SwHTMLParser::FinishFootEndNote()
216 {
217 	if( !pFootEndNoteImpl )
218 		return;
219 
220 	SwFmtFtn aFtn( pFootEndNoteImpl->bEndNote );
221 	if( pFootEndNoteImpl->bFixed )
222 		aFtn.SetNumStr( pFootEndNoteImpl->sContent );
223 
224     pDoc->InsertPoolItem( *pPam, aFtn, 0 );
225     SwTxtFtn * const pTxtFtn = static_cast<SwTxtFtn *>(
226         pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
227             pPam->GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_FTN ) );
228 	// In Kopf- und Fusszeilen duerfen keine Fussnoten eingefuegt werden.
229 	if( pTxtFtn )
230 	{
231 		pFootEndNoteImpl->aTxtFtns.Insert( pTxtFtn,
232 										   pFootEndNoteImpl->aTxtFtns.Count() );
233 
234 		pFootEndNoteImpl->aNames.Insert( new String(pFootEndNoteImpl->sName),
235 										 pFootEndNoteImpl->aNames.Count() );
236 	}
237 	pFootEndNoteImpl->sName = aEmptyStr;
238 	pFootEndNoteImpl->sContent = aEmptyStr;
239 	pFootEndNoteImpl->bFixed = sal_False;
240 }
241 
InsertFootEndNoteText()242 void SwHTMLParser::InsertFootEndNoteText()
243 {
244 	if( pFootEndNoteImpl && pFootEndNoteImpl->bFixed )
245 		pFootEndNoteImpl->sContent += aToken;
246 }
247 
DeleteFootEndNoteImpl()248 void SwHTMLParser::DeleteFootEndNoteImpl()
249 {
250 	delete pFootEndNoteImpl;
251 	pFootEndNoteImpl = 0;
252 }
253 
GetFootEndNoteSection(const String & rName)254 SwNodeIndex *SwHTMLParser::GetFootEndNoteSection( const String& rName )
255 {
256 	SwNodeIndex *pStartNodeIdx = 0;
257 
258 	if( pFootEndNoteImpl )
259 	{
260 		String aName( rName );
261 		// TODO: ToUpperAscii
262 		aName.ToUpperAscii();
263 
264 		sal_uInt16 nCount = pFootEndNoteImpl->aNames.Count();
265 		for( sal_uInt16 i=0; i<nCount; i++ )
266 		{
267 			if( *pFootEndNoteImpl->aNames[i] == aName )
268 			{
269 				pStartNodeIdx = pFootEndNoteImpl->aTxtFtns[i]->GetStartNode();
270 				pFootEndNoteImpl->aNames.DeleteAndDestroy( i, 1 );
271 				pFootEndNoteImpl->aTxtFtns.Remove( i, 1 );
272 				if( !pFootEndNoteImpl->aNames.Count() )
273 				{
274 					delete pFootEndNoteImpl;
275 					pFootEndNoteImpl = 0;
276 				}
277 
278 				break;
279 			}
280 		}
281 	}
282 
283 	return pStartNodeIdx;
284 }
285 
OutHTML_SwFmtFtn(Writer & rWrt,const SfxPoolItem & rHt)286 Writer& OutHTML_SwFmtFtn( Writer& rWrt, const SfxPoolItem& rHt )
287 {
288 	SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
289 
290 	SwFmtFtn& rFmtFtn = (SwFmtFtn&)rHt;
291 	SwTxtFtn *pTxtFtn = rFmtFtn.GetTxtFtn();
292 	if( !pTxtFtn )
293 		return rWrt;
294 
295 	String sFtnName, sClass;
296 	sal_uInt16 nPos;
297 	if( rFmtFtn.IsEndNote() )
298 	{
299 		nPos = rHTMLWrt.pFootEndNotes ? rHTMLWrt.pFootEndNotes->Count() : 0;
300 		ASSERT( nPos == rHTMLWrt.nFootNote + rHTMLWrt.nEndNote,
301 				"OutHTML_SwFmtFtn: Position falsch" );
302 		sClass.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdendnote_anc );
303 		sFtnName.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdendnote );
304 		sFtnName += String::CreateFromInt32( (sal_Int32)(++rHTMLWrt.nEndNote) );
305 	}
306 	else
307 	{
308 		nPos = rHTMLWrt.nFootNote;
309 		sClass.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote_anc );
310 		sFtnName.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote);
311 		sFtnName += String::CreateFromInt32( (sal_Int32)(++rHTMLWrt.nFootNote));
312 	}
313 
314 	if( !rHTMLWrt.pFootEndNotes )
315 		rHTMLWrt.pFootEndNotes = new SwHTMLTxtFtns;
316 	rHTMLWrt.pFootEndNotes->Insert( pTxtFtn, nPos );
317 
318 	ByteString sOut( '<' );
319 	(((sOut += OOO_STRING_SVTOOLS_HTML_anchor) += ' ') += OOO_STRING_SVTOOLS_HTML_O_class) += "=\"";
320 	rWrt.Strm() << sOut.GetBuffer();
321 	HTMLOutFuncs::Out_String( rWrt.Strm(), sClass, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
322 	((sOut = "\" ") += OOO_STRING_SVTOOLS_HTML_O_name) += "=\"";
323 	rWrt.Strm() << sOut.GetBuffer();
324 	HTMLOutFuncs::Out_String( rWrt.Strm(), sFtnName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
325 	(((sOut = OOO_STRING_SVTOOLS_HTML_FTN_anchor) += "\" ") += OOO_STRING_SVTOOLS_HTML_O_href) += "=\"#";
326 	rWrt.Strm() << sOut.GetBuffer();
327 	HTMLOutFuncs::Out_String( rWrt.Strm(), sFtnName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
328 	(sOut = OOO_STRING_SVTOOLS_HTML_FTN_symbol)+= '\"';
329 	if( rFmtFtn.GetNumStr().Len() )
330 		(sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_sdfixed;
331 	sOut += '>';
332 	rWrt.Strm() << sOut.GetBuffer();
333 	HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_superscript, sal_True );
334 
335 	HTMLOutFuncs::Out_String( rWrt.Strm(), rFmtFtn.GetViewNumStr(*rWrt.pDoc),
336 						   	  rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
337 	HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_superscript, sal_False );
338 	HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_anchor, sal_False );
339 
340 	return rWrt;
341 }
342 
OutFootEndNotes()343 void SwHTMLWriter::OutFootEndNotes()
344 {
345 	ASSERT( pFootEndNotes,
346 			"SwHTMLWriter::OutFootEndNotes(): unnoetiger Aufruf" );
347 	if( !pFootEndNotes )
348 		return;
349 
350 #ifdef DBG_UTIL
351 	sal_uInt16 nFtn = nFootNote, nEn = nEndNote;
352 #endif
353 	nFootNote = 0, nEndNote = 0;
354 
355 	for( sal_uInt16 i=0; i<pFootEndNotes->Count(); i++ )
356 	{
357 		SwTxtFtn *pTxtFtn = (*pFootEndNotes)[i];
358 		pFmtFtn = &pTxtFtn->GetFtn();
359 
360 		String sFtnName, sClass;
361 		if( pFmtFtn->IsEndNote() )
362 		{
363 			sClass.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdendnote );
364 			sFtnName.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdendnote );
365 			sFtnName.Append( String::CreateFromInt32((sal_Int32)(++nEndNote)) );
366 		}
367 		else
368 		{
369 			sClass.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote );
370 			sFtnName.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote );
371 			sFtnName.Append( String::CreateFromInt32((sal_Int32)(++nFootNote)));
372 		}
373 
374 		if( bLFPossible )
375 			OutNewLine();
376 		ByteString sOut( '<' );
377 		(((sOut += OOO_STRING_SVTOOLS_HTML_division) += ' ') += OOO_STRING_SVTOOLS_HTML_O_id) += "=\"";
378 		Strm() << sOut.GetBuffer();
379 		HTMLOutFuncs::Out_String( Strm(), sFtnName, eDestEnc, &aNonConvertableCharacters );
380 		Strm() << "\">";
381 
382 		bLFPossible = sal_True;
383 		IncIndentLevel();	// Inhalt von <DIV> einruecken
384 
385 		ASSERT( pTxtFtn, "SwHTMLWriter::OutFootEndNotes: SwTxtFtn fehlt" );
386 		SwNodeIndex *pSttNdIdx = pTxtFtn->GetStartNode();
387 		ASSERT( pSttNdIdx,
388 				"SwHTMLWriter::OutFootEndNotes: StartNode-Index fehlt" );
389 		if( pSttNdIdx )
390 		{
391 			HTMLSaveData aSaveData( *this, pSttNdIdx->GetIndex()+1,
392 				pSttNdIdx->GetNode().EndOfSectionIndex(), sal_False );
393 			Out_SwDoc( pCurPam );
394 		}
395 
396 		DecIndentLevel();	// Inhalt von <DIV> einruecken
397 		if( bLFPossible )
398 			OutNewLine();
399 		HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_division, sal_False );
400 		bLFPossible = sal_True;
401 
402 		ASSERT( !pFmtFtn,
403 				"SwHTMLWriter::OutFootEndNotes: Ftn wurde nicht ausgegeben" );
404 		if( pFmtFtn )
405 		{
406 			if( pFmtFtn->IsEndNote() )
407 				nEndNote++;
408 			else
409 				nFootNote++;
410 
411 			pFmtFtn = 0;
412 		}
413 	}
414 
415 #ifdef DBG_UTIL
416 	ASSERT( nFtn == nFootNote,
417 			"SwHTMLWriter::OutFootEndNotes: Anzahl Fussnoten stimmt nicht" );
418 	ASSERT( nEn == nEndNote,
419 			"SwHTMLWriter::OutFootEndNotes: Anzahl Endnoten stimmt nicht" );
420 #endif
421 
422 	delete pFootEndNotes;
423 	pFootEndNotes = 0;
424 	nFootNote = nEndNote = 0;
425 }
426 
GetFootEndNoteSym(const SwFmtFtn & rFmtFtn)427 String SwHTMLWriter::GetFootEndNoteSym( const SwFmtFtn& rFmtFtn )
428 {
429 	const SwEndNoteInfo * pInfo = 0;
430 	if( rFmtFtn.GetNumStr().Len() == 0 )
431 		pInfo = rFmtFtn.IsEndNote() ? &pDoc->GetEndNoteInfo()
432 									: &pDoc->GetFtnInfo();
433 
434 	String sRet;
435 	if( pInfo )
436 		sRet = pInfo->GetPrefix();
437 	sRet += rFmtFtn.GetViewNumStr( *pDoc );
438 	if( pInfo )
439 		sRet += pInfo->GetSuffix();
440 
441 	return sRet;
442 }
443 
OutFootEndNoteSym(const SwFmtFtn & rFmtFtn,const String & rNum,sal_uInt16 nScript)444 void SwHTMLWriter::OutFootEndNoteSym( const SwFmtFtn& rFmtFtn,
445 								   	  const String& rNum,
446 								   	  sal_uInt16 nScript )
447 {
448 	const SwEndNoteInfo *pInfo;
449 
450 	String sFtnName, sClass, sPrefix, sSuffix;
451 	if( rFmtFtn.IsEndNote() )
452 	{
453 		sClass.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdendnote_sym );
454 		sFtnName.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdendnote );
455 		sFtnName.Append( String::CreateFromInt32((sal_Int32)nEndNote) );
456 		pInfo = &pDoc->GetEndNoteInfo();
457 	}
458 	else
459 	{
460 		sClass.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote_sym );
461 		sFtnName.AssignAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote );
462 		sFtnName.Append( String::CreateFromInt32((sal_Int32)nFootNote));
463 		pInfo = &pDoc->GetFtnInfo();
464 	}
465 
466 	const SwCharFmt *pSymCharFmt = pInfo->GetCharFmt( *pDoc );
467 	if( pSymCharFmt && aScriptTextStyles.Seek_Entry( (String *)&pSymCharFmt->GetName() ) )
468 	{
469 		switch( nScript )
470 		{
471 		case CSS1_OUTMODE_WESTERN:
472 			sClass.AppendAscii( RTL_CONSTASCII_STRINGPARAM("-western") );
473 			break;
474 		case CSS1_OUTMODE_CJK:
475 			sClass.AppendAscii( RTL_CONSTASCII_STRINGPARAM("-cjk") );
476 			break;
477 		case CSS1_OUTMODE_CTL:
478 			sClass.AppendAscii( RTL_CONSTASCII_STRINGPARAM("-ctl") );
479 			break;
480 		}
481 	}
482 
483 	ByteString sOut( '<' );
484 	(((sOut += OOO_STRING_SVTOOLS_HTML_anchor) +=  ' ') += OOO_STRING_SVTOOLS_HTML_O_class) += "=\"";
485 	Strm() << sOut.GetBuffer();
486 	HTMLOutFuncs::Out_String( Strm(), sClass, eDestEnc, &aNonConvertableCharacters );
487 	((sOut = "\" ") += OOO_STRING_SVTOOLS_HTML_O_name) += "=\"";
488 	Strm() << sOut.GetBuffer();
489 	HTMLOutFuncs::Out_String( Strm(), sFtnName, eDestEnc, &aNonConvertableCharacters );
490 	(((sOut = OOO_STRING_SVTOOLS_HTML_FTN_symbol) +="\" ") += OOO_STRING_SVTOOLS_HTML_O_href) += "=\"#";
491 	Strm() << sOut.GetBuffer();
492 	HTMLOutFuncs::Out_String( Strm(), sFtnName, eDestEnc, &aNonConvertableCharacters );
493 	(sOut = OOO_STRING_SVTOOLS_HTML_FTN_anchor) += "\">";
494 	Strm() << sOut.GetBuffer();
495 
496 	HTMLOutFuncs::Out_String( Strm(), rNum, eDestEnc, &aNonConvertableCharacters );
497 	HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_anchor, sal_False );
498 }
499 
lcl_html_fillEndNoteInfo(const SwEndNoteInfo & rInfo,String * pParts,sal_Bool bEndNote)500 sal_uInt16 lcl_html_fillEndNoteInfo( const SwEndNoteInfo& rInfo,
501 								 String *pParts,
502 								 sal_Bool bEndNote	)
503 {
504 	sal_uInt16 nParts = 0;
505 	sal_Int16 eFmt = rInfo.aFmt.GetNumberingType();
506 	if( (bEndNote ? SVX_NUM_ROMAN_LOWER : SVX_NUM_ARABIC) != eFmt )
507 	{
508 		const sal_Char *pStr = SwHTMLWriter::GetNumFormat( eFmt );
509 		if( pStr )
510 		{
511 			pParts[0] = String::CreateFromAscii( pStr );
512 			nParts = 1;
513 		}
514 	}
515 	if( rInfo.nFtnOffset > 0 )
516 	{
517 		pParts[1] =	String::CreateFromInt32( (sal_Int32)rInfo.nFtnOffset );
518 		nParts = 2;
519 	}
520 	if( rInfo.GetPrefix().Len() > 0 )
521 	{
522 		pParts[2] =	rInfo.GetPrefix();
523 		nParts = 3;
524 	}
525 	if( rInfo.GetSuffix().Len() > 0 )
526 	{
527 		pParts[3] =	rInfo.GetSuffix();
528 		nParts = 4;
529 	}
530 
531 	return nParts;
532 }
533 
lcl_html_outFootEndNoteInfo(Writer & rWrt,String * pParts,sal_uInt16 nParts,const sal_Char * pName)534 void lcl_html_outFootEndNoteInfo( Writer& rWrt, String *pParts,
535 								  sal_uInt16 nParts, const sal_Char *pName )
536 {
537 	SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
538 
539 	String aContent;
540 	for( sal_uInt16 i=0; i<nParts; i++ )
541 	{
542 		xub_StrLen nPos = 0;
543 		String aTmp( pParts[i] );
544 		String aRep( String::CreateFromAscii("\\\\") );
545 		while( STRING_NOTFOUND != (nPos = aTmp.SearchAndReplaceAscii( "\\",
546 													 aRep, nPos ) ) )
547 			nPos += 2;
548 		nPos = 0;
549 		aRep.AssignAscii( "\\;" );
550 		while( STRING_NOTFOUND != (nPos = aTmp.SearchAndReplaceAscii( ";",
551 													 aRep, nPos ) ) )
552 			nPos += 2;
553 		if( i > 0 )
554 			aContent += ';';
555 		aContent += aTmp;
556 	}
557 
558 	rHTMLWrt.OutNewLine();
559 	ByteString sOut( '<' );
560 	(((((((sOut += OOO_STRING_SVTOOLS_HTML_meta) +=  ' ')
561 		+= OOO_STRING_SVTOOLS_HTML_O_name) += "=\"") += pName) += "\" ")
562 		+= OOO_STRING_SVTOOLS_HTML_O_content) += "=\"";
563 	rWrt.Strm() << sOut.GetBuffer();
564 	HTMLOutFuncs::Out_String( rWrt.Strm(), aContent, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
565 	rWrt.Strm() << "\">";
566 }
567 
OutFootEndNoteInfo()568 void SwHTMLWriter::OutFootEndNoteInfo()
569 {
570 	// Nummerntyp (1 bzw. i)
571 	// Offset (0)
572 	// Davor
573 	// Dahinter
574 	// Dok/Seite/Kap (D)
575 	// Position (S)
576 	// Folgeseite
577 	// Beginn
578 
579 	{
580 		const SwFtnInfo& rInfo = pDoc->GetFtnInfo();
581 		String aParts[8];
582 		sal_uInt16 nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, sal_False );
583 		if( rInfo.eNum != FTNNUM_DOC )
584 		{
585 			aParts[4] = rInfo.eNum == FTNNUM_CHAPTER ? 'C' : 'P';
586 			nParts = 5;
587 		}
588 		if( rInfo.ePos != FTNPOS_PAGE)
589 		{
590 			aParts[5] = 'C';
591 			nParts = 6;
592 		}
593 		if( rInfo.aQuoVadis.Len() > 0 )
594 		{
595 			aParts[6] =	rInfo.aQuoVadis;
596 			nParts = 7;
597 		}
598 		if( rInfo.aErgoSum.Len() > 0 )
599 		{
600 			aParts[7] =	rInfo.aErgoSum;
601 			nParts = 8;
602 		}
603 		if( nParts > 0 )
604 			lcl_html_outFootEndNoteInfo( *this, aParts, nParts,
605 										 OOO_STRING_SVTOOLS_HTML_META_sdfootnote );
606 	}
607 
608 	{
609 		const SwEndNoteInfo& rInfo = pDoc->GetEndNoteInfo();
610 		String aParts[4];
611 		sal_uInt16 nParts = lcl_html_fillEndNoteInfo( rInfo, aParts, sal_True );
612 		if( nParts > 0 )
613 			lcl_html_outFootEndNoteInfo( *this, aParts, nParts,
614 										 OOO_STRING_SVTOOLS_HTML_META_sdendnote );
615 	}
616 }
617 
618