LCOV - code coverage report
Current view: top level - sw/source/filter/html - htmlftn.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 28 319 8.8 %
Date: 2014-04-11 Functions: 3 18 16.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10