LCOV - code coverage report
Current view: top level - sw/source/filter/html - wrthtml.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 528 746 70.8 %
Date: 2015-06-13 12:38:46 Functions: 32 38 84.2 %
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 <stdlib.h>
      21             : #include <hintids.hxx>
      22             : #include <comphelper/string.hxx>
      23             : #include <svl/urihelper.hxx>
      24             : #include <rtl/tencinfo.h>
      25             : #include <vcl/wrkwin.hxx>
      26             : #include <sfx2/linkmgr.hxx>
      27             : 
      28             : #include <svtools/htmlcfg.hxx>
      29             : #include <vcl/svapp.hxx>
      30             : #include <i18nlangtag/languagetag.hxx>
      31             : #include <sfx2/frmhtmlw.hxx>
      32             : #include <svx/xoutbmp.hxx>
      33             : #include <svx/unobrushitemhelper.hxx>
      34             : #include <sfx2/htmlmode.hxx>
      35             : #include <editeng/lrspitem.hxx>
      36             : #include <editeng/colritem.hxx>
      37             : #include <editeng/brushitem.hxx>
      38             : #include <editeng/fontitem.hxx>
      39             : #include <editeng/scripttypeitem.hxx>
      40             : #include <editeng/langitem.hxx>
      41             : #include <svl/stritem.hxx>
      42             : #include <editeng/frmdiritem.hxx>
      43             : 
      44             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      45             : #include <com/sun/star/document/XDocumentProperties.hpp>
      46             : #include <com/sun/star/form/XFormsSupplier.hpp>
      47             : #include <com/sun/star/form/XForm.hpp>
      48             : #include <com/sun/star/form/XImageProducerSupplier.hpp>
      49             : #include <com/sun/star/form/XFormController.hpp>
      50             : #include <com/sun/star/container/XContainer.hpp>
      51             : #include <com/sun/star/container/XIndexContainer.hpp>
      52             : #include <com/sun/star/container/XSet.hpp>
      53             : #include <fmthdft.hxx>
      54             : #include <fmtfld.hxx>
      55             : #include <fmtpdsc.hxx>
      56             : #include <txatbase.hxx>
      57             : #include <frmatr.hxx>
      58             : #include <charfmt.hxx>
      59             : #include <docary.hxx>
      60             : #include <pam.hxx>
      61             : #include <doc.hxx>
      62             : #include <ndtxt.hxx>
      63             : #include <mdiexp.hxx>
      64             : #include <fltini.hxx>
      65             : #include <viewopt.hxx>
      66             : #include <IMark.hxx>
      67             : #include <poolfmt.hxx>
      68             : #include <pagedesc.hxx>
      69             : #include <section.hxx>
      70             : #include <swtable.hxx>
      71             : #include <fldbas.hxx>
      72             : #include <fmtclds.hxx>
      73             : #include <docsh.hxx>
      74             : #include <wrthtml.hxx>
      75             : #include <htmlnum.hxx>
      76             : #include <htmlfly.hxx>
      77             : #include <swmodule.hxx>
      78             : #include <statstr.hrc>
      79             : #include <swerror.h>
      80             : #include <rtl/strbuf.hxx>
      81             : #include <IDocumentSettingAccess.hxx>
      82             : #include <IDocumentStylePoolAccess.hxx>
      83             : #include <xmloff/odffields.hxx>
      84             : #include <tools/urlobj.hxx>
      85             : 
      86             : #define MAX_INDENT_LEVEL 20
      87             : 
      88             : using namespace css;
      89             : 
      90             : static sal_Char sIndentTabs[MAX_INDENT_LEVEL+2] =
      91             :     "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
      92             : 
      93          15 : SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL )
      94             :     : pHTMLPosFlyFrms(NULL)
      95          15 :     , pNumRuleInfo(new SwHTMLNumRuleInfo)
      96             :     , pNextNumRuleInfo(NULL)
      97             :     , nHTMLMode(0)
      98             :     , eCSS1Unit(FUNIT_NONE)
      99             :     , pFootEndNotes(NULL)
     100             :     , pxFormComps(NULL)
     101             :     , pTemplate(NULL)
     102             :     , pDfltColor(NULL)
     103             :     , pStartNdIdx(NULL)
     104             :     , pCurrPageDesc(NULL)
     105             :     , pFormatFootnote(NULL)
     106             :     , nWarn(0)
     107             :     , nLastLFPos(0)
     108             :     , nLastParaToken(0)
     109             :     , nBkmkTabPos(-1)
     110             :     , nImgMapCnt(1)
     111             :     , nFormCntrlCnt(0)
     112             :     , nEndNote(0)
     113             :     , nFootNote(0)
     114             :     , nLeftMargin(0)
     115             :     , nDfltLeftMargin(0)
     116             :     , nDfltRightMargin(0)
     117             :     , nFirstLineIndent(0)
     118             :     , nDfltFirstLineIndent(0)
     119             :     , nDfltTopMargin(0)
     120             :     , nDfltBottomMargin(0)
     121             :     , nIndentLvl(0)
     122             :     , nWhishLineLen(0)
     123             :     , nDefListLvl(0)
     124             :     , nDefListMargin(0)
     125             :     , nHeaderFooterSpace(0)
     126             :     , nTextAttrsToIgnore(0)
     127             :     , nExportMode(0)
     128             :     , nCSS1OutMode(0)
     129             :     , nCSS1Script(CSS1_OUTMODE_WESTERN)
     130             :     , nDirection(FRMDIR_HORI_LEFT_TOP)
     131             :     , eDestEnc(RTL_TEXTENCODING_MS_1252)
     132             :     , eLang(LANGUAGE_DONTKNOW)
     133             :     , bCfgOutStyles( false )
     134             :     , bCfgPreferStyles( false )
     135             :     , bCfgFormFeed( false )
     136             :     , bCfgStarBasic( false )
     137             :     , bCfgCpyLinkedGrfs( false )
     138             :     , bFirstLine(true)
     139             :     , bTagOn( false )
     140             :     , bTextAttr( false )
     141             :     , bOutOpts( false )
     142             :     , bOutTable( false )
     143             :     , bOutHeader( false )
     144             :     , bOutFooter( false )
     145             :     , bOutFlyFrame( false )
     146             :     , bFirstCSS1Rule( false )
     147             :     , bFirstCSS1Property( false )
     148             :     , bPoolCollTextModified( false )
     149             :     , bCSS1IgnoreFirstPageDesc( false )
     150             :     , bNoAlign( false )
     151             :     , bClearLeft( false )
     152             :     , bClearRight( false )
     153             :     , bLFPossible( false )
     154             :     , bPreserveForm( false )
     155             :     , bCfgNetscape4( false )
     156             :     , mbSkipImages(false)
     157             :     , mbSkipHeaderFooter(false)
     158             :     , bCfgPrintLayout( false )
     159          30 :     , bParaDotLeaders( false )
     160             : {
     161          15 :     SetBaseURL(rBaseURL);
     162          15 : }
     163             : 
     164          45 : SwHTMLWriter::~SwHTMLWriter()
     165             : {
     166          15 :     delete pNumRuleInfo;
     167          30 : }
     168             : 
     169          15 : void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
     170             : {
     171          15 :     const SfxItemSet* pSet = rMedium.GetItemSet();
     172          15 :     if (pSet == NULL)
     173          11 :         return;
     174             : 
     175             :     const SfxPoolItem* pItem;
     176          15 :     if (pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) != SfxItemState::SET)
     177          11 :         return;
     178             : 
     179             : 
     180           4 :     OUString sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
     181           4 :     if (sFilterOptions == "SkipImages")
     182             :     {
     183           3 :         mbSkipImages = true;
     184             :     }
     185           1 :     else if (sFilterOptions == "SkipHeaderFooter")
     186             :     {
     187           1 :         mbSkipHeaderFooter = true;
     188           4 :     }
     189             : }
     190             : 
     191          15 : sal_uLong SwHTMLWriter::WriteStream()
     192             : {
     193          15 :     SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
     194             : 
     195             :     // font heights 1-7
     196          15 :     aFontHeights[0] = rHtmlOptions.GetFontSize( 0 ) * 20;
     197          15 :     aFontHeights[1] = rHtmlOptions.GetFontSize( 1 ) * 20;
     198          15 :     aFontHeights[2] = rHtmlOptions.GetFontSize( 2 ) * 20;
     199          15 :     aFontHeights[3] = rHtmlOptions.GetFontSize( 3 ) * 20;
     200          15 :     aFontHeights[4] = rHtmlOptions.GetFontSize( 4 ) * 20;
     201          15 :     aFontHeights[5] = rHtmlOptions.GetFontSize( 5 ) * 20;
     202          15 :     aFontHeights[6] = rHtmlOptions.GetFontSize( 6 ) * 20;
     203             : 
     204             :     // ueberhaupt Styles ausgeben
     205             :     // (dann auch obere und untere Absatz-Abstaende)
     206          15 :     nExportMode = rHtmlOptions.GetExportMode();
     207          15 :     nHTMLMode = GetHtmlMode(0);
     208             : 
     209          15 :     if( HTML_CFG_WRITER == nExportMode || HTML_CFG_NS40 == nExportMode )
     210          15 :         nHTMLMode |= HTMLMODE_BLOCK_SPACER;
     211             : 
     212          15 :     if( HTML_CFG_WRITER == nExportMode || HTML_CFG_MSIE == nExportMode )
     213           0 :         nHTMLMode |= (HTMLMODE_FLOAT_FRAME | HTMLMODE_LSPACE_IN_NUMBUL);
     214             : 
     215          15 :     if( HTML_CFG_MSIE == nExportMode )
     216           0 :         nHTMLMode |= HTMLMODE_NBSP_IN_TABLES;
     217             : 
     218          15 :     if( HTML_CFG_WRITER == nExportMode || HTML_CFG_NS40 == nExportMode || HTML_CFG_MSIE == nExportMode )
     219          15 :         nHTMLMode |= HTMLMODE_ABS_POS_FLY | HTMLMODE_ABS_POS_DRAW;
     220             : 
     221          15 :     if( HTML_CFG_WRITER == nExportMode )
     222           0 :         nHTMLMode |= HTMLMODE_FLY_MARGINS;
     223             : 
     224          15 :     if( HTML_CFG_NS40 == nExportMode )
     225          15 :         nHTMLMode |= HTMLMODE_BORDER_NONE;
     226             : 
     227          15 :     nHTMLMode |= HTMLMODE_FONT_GENERIC;
     228             : 
     229          15 :     if( HTML_CFG_NS40==nExportMode )
     230          15 :         nHTMLMode |= HTMLMODE_NO_CONTROL_CENTERING;
     231             : 
     232          15 :     bCfgOutStyles = IsHTMLMode(HTMLMODE_SOME_STYLES | HTMLMODE_FULL_STYLES);
     233          15 :     bCfgNetscape4 = (HTML_CFG_NS40 == nExportMode);
     234             : 
     235          15 :     if( IsHTMLMode(HTMLMODE_SOME_STYLES | HTMLMODE_FULL_STYLES) )
     236          15 :         nHTMLMode |= HTMLMODE_PRINT_EXT;
     237             : 
     238          15 :     const sal_Char *pHelpHack = getenv( "HelpEx" );
     239          15 :     if( pHelpHack )
     240             :     {
     241           0 :         OString aTmp(pHelpHack);
     242           0 :         if (aTmp.equalsIgnoreAsciiCase("Hilfe"))
     243           0 :             nHTMLMode |= HTMLMODE_NO_BR_AT_PAREND;
     244             :     }
     245             : 
     246          15 :     eCSS1Unit = (FieldUnit)SW_MOD()->GetMetric( pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) );
     247             : 
     248          15 :     bool bWriteUTF8 = bWriteClipboardDoc;
     249          15 :     eDestEnc = bWriteUTF8 ? RTL_TEXTENCODING_UTF8 : rHtmlOptions.GetTextEncoding();
     250          15 :     const sal_Char *pCharSet = rtl_getBestMimeCharsetFromTextEncoding( eDestEnc );
     251          15 :     eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet );
     252             : 
     253             :     // Nur noch fuer den MS-IE ziehen wir den Export von Styles vor.
     254          15 :     bCfgPreferStyles = HTML_CFG_MSIE == nExportMode;
     255             : 
     256          15 :     bCfgStarBasic = rHtmlOptions.IsStarBasic();
     257             : 
     258          15 :     bCfgFormFeed = !IsHTMLMode(HTMLMODE_PRINT_EXT);
     259          15 :     bCfgCpyLinkedGrfs = rHtmlOptions.IsSaveGraphicsLocal();
     260             : 
     261          15 :     bCfgPrintLayout = rHtmlOptions.IsPrintLayoutExtension();
     262             : 
     263             :     // die HTML-Vorlage holen
     264          15 :     bool bOldHTMLMode = false;
     265          15 :     sal_uInt16 nOldTextFormatCollCnt = 0, nOldCharFormatCnt = 0;
     266             : 
     267             :     OSL_ENSURE( !pTemplate, "Wo kommt denn die HTML-Vorlage hier her?" );
     268          15 :     pTemplate = static_cast<HTMLReader*>(ReadHTML)->GetTemplateDoc();
     269          15 :     if( pTemplate )
     270             :     {
     271          15 :         pTemplate->acquire();
     272          15 :         bOldHTMLMode = pTemplate->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE);
     273          15 :         pTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, true);
     274             : 
     275          15 :         nOldTextFormatCollCnt = pTemplate->GetTextFormatColls()->size();
     276          15 :         nOldCharFormatCnt = pTemplate->GetCharFormats()->size();
     277             :     }
     278             : 
     279          15 :     if( bShowProgress )
     280          15 :         ::StartProgress( STR_STATSTR_W4WWRITE, 0, pDoc->GetNodes().Count(),
     281          30 :                          pDoc->GetDocShell());
     282             : 
     283          15 :     pDfltColor = 0;
     284          15 :     pFootEndNotes = 0;
     285          15 :     pFormatFootnote = 0;
     286          15 :     bOutTable = bOutHeader = bOutFooter = bOutFlyFrame = false;
     287          15 :     pxFormComps = 0;
     288          15 :     nFormCntrlCnt = 0;
     289          15 :     bPreserveForm = false;
     290          15 :     bClearLeft = bClearRight = false;
     291          15 :     bLFPossible = false;
     292             : 
     293          15 :     nLeftMargin = nDfltLeftMargin = nDfltRightMargin = 0;
     294          15 :     nDfltTopMargin = nDfltBottomMargin = 0;
     295          15 :     nFirstLineIndent = nDfltFirstLineIndent = 0;
     296          15 :     bPoolCollTextModified = false;
     297          15 :     bFirstCSS1Property = bFirstCSS1Rule = false;
     298          15 :     bCSS1IgnoreFirstPageDesc = false;
     299          15 :     nIndentLvl = 0;
     300          15 :     nWhishLineLen = 70;
     301          15 :     nLastLFPos = 0;
     302          15 :     nDefListLvl = 0;
     303          15 :     nDefListMargin = ((pTemplate && !bCfgOutStyles) ? pTemplate : pDoc)
     304          15 :         ->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_HTML_DD, false )
     305          15 :         ->GetLRSpace().GetTextLeft();
     306          15 :     nHeaderFooterSpace = 0;
     307          15 :     nTextAttrsToIgnore = 0;
     308          15 :     nCSS1OutMode = 0;
     309          15 :     SvtScriptType nScript = SvtLanguageOptions::GetScriptTypeOfLanguage( GetAppLanguage() );
     310          15 :     switch( nScript )
     311             :     {
     312             :     case SvtScriptType::ASIAN:
     313           0 :         nCSS1Script = CSS1_OUTMODE_CJK;
     314           0 :         break;
     315             :     case SvtScriptType::COMPLEX:
     316           0 :         nCSS1Script = CSS1_OUTMODE_CTL;
     317           0 :         break;
     318             :     default:
     319          15 :         nCSS1Script = CSS1_OUTMODE_WESTERN;
     320          15 :         break;
     321             :     }
     322             :     eLang = static_cast<const SvxLanguageItem&>(pDoc
     323          15 :             ->GetDefault(GetLangWhichIdFromScript(nCSS1Script))).GetLanguage();
     324             : 
     325          15 :     nFootNote = nEndNote = 0;
     326             : 
     327          15 :     nWarn = 0;
     328          15 :     GetNumInfo().Clear();
     329          15 :     pNextNumRuleInfo = 0;
     330             : 
     331          15 :     OString aStartTags;
     332             : 
     333             :     // Tabellen und Bereiche am Doc.-Anfang beachten
     334             :     {
     335          15 :         SwTableNode * pTNd = pCurPam->GetNode().FindTableNode();
     336          15 :         if( pTNd && bWriteAll )
     337             :         {
     338             :             // mit dem Tabellen-Node anfangen !!
     339           2 :             pCurPam->GetPoint()->nNode = *pTNd;
     340             : 
     341           2 :             if( bWriteOnlyFirstTable )
     342           0 :                 pCurPam->GetMark()->nNode = *pTNd->EndOfSectionNode();
     343             :         }
     344             : 
     345             :         // erster Node (der einen Seitenumbruch enthalten darf)
     346          15 :         pStartNdIdx = new SwNodeIndex( pCurPam->GetPoint()->nNode );
     347             : 
     348          15 :         SwSectionNode * pSNd = pCurPam->GetNode().FindSectionNode();
     349          30 :         while( pSNd )
     350             :         {
     351           0 :             if( bWriteAll )
     352             :             {
     353             :                 // mit dem Section-Node anfangen !!
     354           0 :                 pCurPam->GetPoint()->nNode = *pSNd;
     355             :             }
     356             :             else
     357             :             {
     358             :                 OSL_ENSURE( FILE_LINK_SECTION != pSNd->GetSection().GetType(),
     359             :                         "Export gelinkter Bereiche am Dok-Anfang ist nicht implemntiert" );
     360             : 
     361             :                 // nur das Tag fuer die Section merken
     362             :                 OString aName = HTMLOutFuncs::ConvertStringToHTML(
     363           0 :                     pSNd->GetSection().GetSectionName(), eDestEnc,
     364           0 :                     &aNonConvertableCharacters );
     365             : 
     366           0 :                 OStringBuffer sOut;
     367           0 :                 sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division)
     368           0 :                     .append(' ').append(OOO_STRING_SVTOOLS_HTML_O_id)
     369           0 :                     .append("=\"").append(aName).append('\"').append('>')
     370           0 :                     .append(aStartTags);
     371           0 :                 aStartTags = sOut.makeStringAndClear();
     372             :             }
     373             :             // FindSectionNode() an einem SectionNode liefert den selben!
     374           0 :             pSNd = pSNd->StartOfSectionNode()->FindSectionNode();
     375             :         }
     376             :     }
     377             : 
     378             :     // Tabelle fuer die freifliegenden Rahmen erzeugen, aber nur wenn
     379             :     // das gesamte Dokument geschrieben wird
     380          15 :     pHTMLPosFlyFrms = 0;
     381          15 :     CollectFlyFrms();
     382          15 :     nLastParaToken = 0;
     383          15 :     GetControls();
     384          15 :     CollectLinkTargets();
     385             : 
     386          15 :     sal_uInt16 nHeaderAttrs = 0;
     387          15 :     pCurrPageDesc = MakeHeader( nHeaderAttrs );
     388             : 
     389          15 :     bLFPossible = true;
     390             : 
     391             :     // Formulare, die nur HiddenControls enthalten ausgeben.
     392          15 :     OutHiddenForms();
     393             : 
     394          15 :     if( !aStartTags.isEmpty() )
     395           0 :         Strm().WriteCharPtr( aStartTags.getStr() );
     396             : 
     397             :     const SfxPoolItem *pItem;
     398          15 :     const SfxItemSet& rPageItemSet = pCurrPageDesc->GetMaster().GetAttrSet();
     399          60 :     if( !bWriteClipboardDoc && pDoc->GetDocShell() &&
     400          29 :          (!pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) &&
     401          42 :           !pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE)) &&
     402          13 :         SfxItemState::SET == rPageItemSet.GetItemState( RES_HEADER, true, &pItem) )
     403             :     {
     404             :         const SwFrameFormat *pHeaderFormat =
     405          13 :             static_cast<const SwFormatHeader *>(pItem)->GetHeaderFormat();
     406          13 :         if( pHeaderFormat )
     407           0 :             OutHTML_HeaderFooter( *this, *pHeaderFormat, true );
     408             :     }
     409             : 
     410          15 :     nTextAttrsToIgnore = nHeaderAttrs;
     411          15 :     Out_SwDoc( pOrigPam );
     412          15 :     nTextAttrsToIgnore = 0;
     413             : 
     414          15 :     if( pxFormComps && pxFormComps->is() )
     415           0 :         OutForm( false, *pxFormComps );
     416             : 
     417          15 :     if( pFootEndNotes )
     418           0 :         OutFootEndNotes();
     419             : 
     420          60 :     if( !bWriteClipboardDoc && pDoc->GetDocShell() &&
     421          57 :         (!pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE))  &&
     422          13 :         SfxItemState::SET == rPageItemSet.GetItemState( RES_FOOTER, true, &pItem) )
     423             :     {
     424             :         const SwFrameFormat *pFooterFormat =
     425          13 :             static_cast<const SwFormatFooter *>(pItem)->GetFooterFormat();
     426          13 :         if( pFooterFormat )
     427           1 :             OutHTML_HeaderFooter( *this, *pFooterFormat, false );
     428             :     }
     429             : 
     430          15 :     if( bLFPossible )
     431          15 :         OutNewLine();
     432          15 :     if (!mbSkipHeaderFooter)
     433             :     {
     434          14 :         HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_body, false );
     435          14 :         OutNewLine();
     436          14 :         HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_html, false );
     437             :     }
     438             : 
     439             :     // loesche die Tabelle mit den freifliegenden Rahmen
     440             :     sal_uInt16 i;
     441             :     OSL_ENSURE( !pHTMLPosFlyFrms, "Wurden nicht alle Rahmen ausgegeben" );
     442          15 :     if( pHTMLPosFlyFrms )
     443             :     {
     444           0 :         pHTMLPosFlyFrms->DeleteAndDestroyAll();
     445           0 :         delete pHTMLPosFlyFrms;
     446           0 :         pHTMLPosFlyFrms = 0;
     447             :     }
     448             : 
     449          15 :     aHTMLControls.DeleteAndDestroyAll();
     450             : 
     451          15 :     if( !aChrFormatInfos.empty() )
     452           2 :         aChrFormatInfos.clear();
     453             : 
     454          15 :     if( !aTextCollInfos.empty() )
     455          15 :         aTextCollInfos.clear();
     456             : 
     457          15 :     if(!aImgMapNames.empty())
     458           1 :         aImgMapNames.clear();
     459             : 
     460          15 :     aImplicitMarks.clear();
     461             : 
     462          15 :     aOutlineMarks.clear();
     463             : 
     464          15 :     aOutlineMarkPoss.clear();
     465             : 
     466          15 :     aNumRuleNames.clear();
     467             : 
     468          15 :     aScriptParaStyles.clear();
     469          15 :     aScriptTextStyles.clear();
     470             : 
     471          15 :     delete pDfltColor;
     472          15 :     pDfltColor = 0;
     473             : 
     474          15 :     delete pStartNdIdx;
     475          15 :     pStartNdIdx = 0;
     476             : 
     477          15 :     delete pxFormComps;
     478          15 :     pxFormComps = 0;
     479             : 
     480             :     OSL_ENSURE( !pFootEndNotes,
     481             :             "SwHTMLWriter::Write: Footnotes nicht durch OutFootEndNotes geloescht" );
     482             : 
     483          15 :     pCurrPageDesc = 0;
     484             : 
     485          15 :     ClearNextNumInfo();
     486             : 
     487         165 :     for( i=0; i<MAXLEVEL; i++ )
     488         150 :         aBulletGrfs[i].clear();
     489             : 
     490          15 :     aNonConvertableCharacters.clear();
     491             : 
     492          15 :     if( bShowProgress )
     493          15 :         ::EndProgress( pDoc->GetDocShell() );
     494             : 
     495          15 :     if( pTemplate )
     496             :     {
     497             :         // Waehrend des Exports angelegte Zeichen- und Abastzvorlagen
     498             :         // loeschen
     499          15 :         sal_uInt16 nTextFormatCollCnt = pTemplate->GetTextFormatColls()->size();
     500          32 :         while( nTextFormatCollCnt > nOldTextFormatCollCnt )
     501           2 :             pTemplate->DelTextFormatColl( --nTextFormatCollCnt );
     502             :         OSL_ENSURE( pTemplate->GetTextFormatColls()->size() == nOldTextFormatCollCnt,
     503             :                 "falsche Anzahl TextFormatColls geloescht" );
     504             : 
     505          15 :         sal_uInt16 nCharFormatCnt = pTemplate->GetCharFormats()->size();
     506          80 :         while( nCharFormatCnt > nOldCharFormatCnt )
     507          50 :             pTemplate->DelCharFormat( --nCharFormatCnt );
     508             :         OSL_ENSURE( pTemplate->GetCharFormats()->size() == nOldCharFormatCnt,
     509             :                 "falsche Anzahl CharFormats geloescht" );
     510             : 
     511             :         // HTML-Modus wieder restaurieren
     512          15 :         pTemplate->getIDocumentSettingAccess().set(DocumentSettingId::HTML_MODE, bOldHTMLMode);
     513             : 
     514          15 :         if( 0 == pTemplate->release() )
     515           0 :             delete pTemplate;
     516             : 
     517          15 :         pTemplate = 0;
     518             :     }
     519             : 
     520          15 :     return nWarn;
     521             : }
     522             : 
     523           0 : static const SwFormatCol *lcl_html_GetFormatCol( const SwSection& rSection,
     524             :                                        const SwSectionFormat& rFormat )
     525             : {
     526           0 :     const SwFormatCol *pCol = 0;
     527             : 
     528             :     const SfxPoolItem* pItem;
     529           0 :     if( FILE_LINK_SECTION != rSection.GetType() &&
     530           0 :         SfxItemState::SET == rFormat.GetAttrSet().GetItemState(RES_COL,false,&pItem) &&
     531           0 :         static_cast<const SwFormatCol *>(pItem)->GetNumCols() > 1 )
     532             :     {
     533           0 :         pCol = static_cast<const SwFormatCol *>(pItem);
     534             :     }
     535             : 
     536           0 :     return pCol;
     537             : }
     538             : 
     539           0 : static bool lcl_html_IsMultiColStart( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
     540             : {
     541           0 :     bool bRet = false;
     542             :     const SwSectionNode *pSectNd =
     543           0 :         rHTMLWrt.pDoc->GetNodes()[nIndex]->GetSectionNode();
     544           0 :     if( pSectNd )
     545             :     {
     546           0 :         const SwSection& rSection = pSectNd->GetSection();
     547           0 :         const SwSectionFormat *pFormat = rSection.GetFormat();
     548           0 :         if( pFormat && lcl_html_GetFormatCol( rSection, *pFormat ) )
     549           0 :             bRet = true;
     550             :     }
     551             : 
     552           0 :     return bRet;
     553             : }
     554             : 
     555           0 : static bool lcl_html_IsMultiColEnd( const SwHTMLWriter& rHTMLWrt, sal_uLong nIndex )
     556             : {
     557           0 :     bool bRet = false;
     558           0 :     const SwEndNode *pEndNd = rHTMLWrt.pDoc->GetNodes()[nIndex]->GetEndNode();
     559           0 :     if( pEndNd )
     560             :         bRet = lcl_html_IsMultiColStart( rHTMLWrt,
     561           0 :                                          pEndNd->StartOfSectionIndex() );
     562             : 
     563           0 :     return bRet;
     564             : }
     565             : 
     566           0 : static void lcl_html_OutSectionStartTag( SwHTMLWriter& rHTMLWrt,
     567             :                                      const SwSection& rSection,
     568             :                                      const SwSectionFormat& rFormat,
     569             :                                   const SwFormatCol *pCol,
     570             :                                   bool bContinued=false )
     571             : {
     572             :     OSL_ENSURE( pCol || !bContinued, "Continuation of DIV" );
     573             : 
     574           0 :     if( rHTMLWrt.bLFPossible )
     575           0 :         rHTMLWrt.OutNewLine();
     576             : 
     577           0 :     OStringBuffer sOut;
     578           0 :     sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_division);
     579             : 
     580           0 :     const OUString& rName = rSection.GetSectionName();
     581           0 :     if( !rName.isEmpty() && !bContinued )
     582             :     {
     583           0 :         sOut.append(" " + OString(OOO_STRING_SVTOOLS_HTML_O_id) + "=\"");
     584           0 :         rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     585           0 :         HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
     586           0 :         sOut.append('\"');
     587             :     }
     588             : 
     589           0 :     sal_uInt16 nDir = rHTMLWrt.GetHTMLDirection( rFormat.GetAttrSet() );
     590           0 :     rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     591           0 :     rHTMLWrt.OutDirection( nDir );
     592             : 
     593           0 :     if( FILE_LINK_SECTION == rSection.GetType() )
     594             :     {
     595           0 :         sOut.append(" " + OString(OOO_STRING_SVTOOLS_HTML_O_href) + "=\"");
     596           0 :         rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     597             : 
     598           0 :         const OUString& aFName = rSection.GetLinkFileName();
     599           0 :         OUString aURL( aFName.getToken(0,sfx2::cTokenSeparator) );
     600           0 :         OUString aFilter( aFName.getToken(1,sfx2::cTokenSeparator) );
     601           0 :         OUString aSection( aFName.getToken(2,sfx2::cTokenSeparator) );
     602             : 
     603           0 :         OUString aEncURL( URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aURL ) );
     604           0 :         sal_Unicode cDelim = 255U;
     605           0 :         bool bURLContainsDelim = (-1 != aEncURL.indexOf( cDelim ) );
     606             : 
     607           0 :         HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aEncURL,
     608             :                                   rHTMLWrt.eDestEnc,
     609           0 :                                   &rHTMLWrt.aNonConvertableCharacters );
     610           0 :         const sal_Char* pDelim = "&#255;";
     611           0 :         if( !aFilter.isEmpty() || !aSection.isEmpty() || bURLContainsDelim )
     612           0 :             rHTMLWrt.Strm().WriteCharPtr( pDelim );
     613           0 :         if( !aFilter.isEmpty() )
     614           0 :             HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aFilter, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
     615           0 :         if( !aSection.isEmpty() || bURLContainsDelim  )
     616           0 :                 rHTMLWrt.Strm().WriteCharPtr( pDelim );
     617           0 :         if( !aSection.isEmpty() )
     618             :         {
     619           0 :             sal_Int32 nPos = aSection.indexOf( '%' );
     620           0 :             while( nPos != -1 )
     621             :             {
     622           0 :                 aSection = aSection.replaceAt(nPos, 1, "%25");
     623           0 :                 nPos = aSection.indexOf( '%', nPos+3 );
     624             :             }
     625           0 :             nPos = aSection.indexOf( cDelim );
     626           0 :             while( nPos != -1 )
     627             :             {
     628           0 :                 aSection = aSection.replaceAt(nPos, 1, "%FF" );
     629           0 :                 nPos = aSection.indexOf( cDelim, nPos+3 );
     630             :             }
     631           0 :             HTMLOutFuncs::Out_String( rHTMLWrt.Strm(), aSection,
     632           0 :                                       rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
     633             :         }
     634           0 :         sOut.append('\"');
     635             :     }
     636           0 :     else if( pCol )
     637             :     {
     638             :         // minimum gutter width
     639           0 :         sal_uInt16 nGutter = pCol->GetGutterWidth( true );
     640           0 :         if( nGutter!=USHRT_MAX )
     641             :         {
     642           0 :             if( nGutter && Application::GetDefaultDevice() )
     643             :             {
     644             :                 nGutter = (sal_uInt16)Application::GetDefaultDevice()
     645           0 :                                 ->LogicToPixel( Size(nGutter, 0), MapMode(MAP_TWIP) ).Width();
     646             :             }
     647           0 :             sOut.append(" " + OString(OOO_STRING_SVTOOLS_HTML_O_gutter) + "=\"" + OString::number(nGutter) + "\"");
     648             :         }
     649             :     }
     650             : 
     651           0 :     rHTMLWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     652           0 :     if( rHTMLWrt.IsHTMLMode( rHTMLWrt.bCfgOutStyles ? HTMLMODE_ON : 0 ) )
     653           0 :         rHTMLWrt.OutCSS1_SectionFormatOptions( rFormat, pCol );
     654             : 
     655           0 :     rHTMLWrt.Strm().WriteChar( '>' );
     656             : 
     657           0 :     rHTMLWrt.bLFPossible = true;
     658           0 :     if( !rName.isEmpty() && !bContinued )
     659           0 :         rHTMLWrt.OutImplicitMark( rName, "region" );
     660             : 
     661           0 :     rHTMLWrt.IncIndentLevel();
     662           0 : }
     663             : 
     664           0 : static void lcl_html_OutSectionEndTag( SwHTMLWriter& rHTMLWrt )
     665             : {
     666           0 :     rHTMLWrt.DecIndentLevel();
     667           0 :     if( rHTMLWrt.bLFPossible )
     668           0 :         rHTMLWrt.OutNewLine();
     669           0 :     HTMLOutFuncs::Out_AsciiTag( rHTMLWrt.Strm(), OOO_STRING_SVTOOLS_HTML_division, false );
     670           0 :     rHTMLWrt.bLFPossible = true;
     671           0 : }
     672             : 
     673           0 : static Writer& OutHTML_Section( Writer& rWrt, const SwSectionNode& rSectNd )
     674             : {
     675           0 :     SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
     676             : 
     677             :     // End <PRE> and any <DL>, because a definition list's level may
     678             :     // change inside the section.
     679           0 :     rHTMLWrt.ChangeParaToken( 0 );
     680           0 :     rHTMLWrt.OutAndSetDefList( 0 );
     681             : 
     682           0 :     const SwSection& rSection = rSectNd.GetSection();
     683           0 :     const SwSectionFormat *pFormat = rSection.GetFormat();
     684             :     OSL_ENSURE( pFormat, "Section without a format?" );
     685             : 
     686           0 :     bool bStartTag = true;
     687           0 :     bool bEndTag = true;
     688           0 :     const SwSectionFormat *pSurrFormat = 0;
     689           0 :     const SwSectionNode *pSurrSectNd = 0;
     690           0 :     const SwSection *pSurrSection = 0;
     691           0 :     const SwFormatCol *pSurrCol = 0;
     692             : 
     693           0 :     sal_uInt32 nSectSttIdx = rSectNd.GetIndex();
     694           0 :     sal_uInt32 nSectEndIdx = rSectNd.EndOfSectionIndex();
     695           0 :     const SwFormatCol *pCol = lcl_html_GetFormatCol( rSection, *pFormat );
     696           0 :     if( pCol )
     697             :     {
     698             :         // If the next node is a columned section node, too, don't export
     699             :         // an empty section.
     700           0 :         if( lcl_html_IsMultiColStart( rHTMLWrt, nSectSttIdx+1 ) )
     701           0 :             bStartTag = false;
     702             : 
     703             :         // The same applies if the section end with another columned section.
     704           0 :         if( lcl_html_IsMultiColEnd( rHTMLWrt, nSectEndIdx-1 ) )
     705           0 :             bEndTag = false;
     706             : 
     707             :         //.is there a columned section around this one?
     708           0 :         const SwStartNode *pSttNd = rSectNd.StartOfSectionNode();
     709           0 :         if( pSttNd )
     710             :         {
     711           0 :             pSurrSectNd = pSttNd->FindSectionNode();
     712           0 :             if( pSurrSectNd )
     713             :             {
     714           0 :                 const SwStartNode *pBoxSttNd = pSttNd->FindTableBoxStartNode();
     715           0 :                 if( !pBoxSttNd ||
     716           0 :                     pBoxSttNd->GetIndex() < pSurrSectNd->GetIndex() )
     717             :                 {
     718           0 :                     pSurrSection = &pSurrSectNd->GetSection();
     719           0 :                     pSurrFormat = pSurrSection->GetFormat();
     720           0 :                     if( pSurrFormat )
     721             :                         pSurrCol = lcl_html_GetFormatCol( *pSurrSection,
     722           0 :                                                        *pSurrFormat );
     723             :                 }
     724             :             }
     725             :         }
     726             :     }
     727             : 
     728             :     // The surrounding section must be closed before the current one is
     729             :     // opended, except that it start immediately before the current one or
     730             :     // another end immediately before the current one
     731           0 :     if( pSurrCol && nSectSttIdx - pSurrSectNd->GetIndex() > 1 &&
     732           0 :         !lcl_html_IsMultiColEnd( rHTMLWrt, nSectSttIdx-1 ) )
     733           0 :         lcl_html_OutSectionEndTag( rHTMLWrt );
     734             : 
     735           0 :     if( bStartTag )
     736           0 :         lcl_html_OutSectionStartTag( rHTMLWrt, rSection, *pFormat, pCol );
     737             : 
     738             :     {
     739             :         HTMLSaveData aSaveData( rHTMLWrt,
     740           0 :             rHTMLWrt.pCurPam->GetPoint()->nNode.GetIndex()+1,
     741             :             rSectNd.EndOfSectionIndex(),
     742           0 :             false, pFormat );
     743           0 :         rHTMLWrt.Out_SwDoc( rHTMLWrt.pCurPam );
     744             :     }
     745             : 
     746           0 :     rHTMLWrt.pCurPam->GetPoint()->nNode = *rSectNd.EndOfSectionNode();
     747             : 
     748           0 :     if( bEndTag )
     749           0 :         lcl_html_OutSectionEndTag( rHTMLWrt );
     750             : 
     751             :     // The surrounding section must be started again, except that it ends
     752             :     // immeditaly behind the current one.
     753           0 :     if( pSurrCol &&
     754           0 :         pSurrSectNd->EndOfSectionIndex() - nSectEndIdx > 1 &&
     755           0 :         !lcl_html_IsMultiColStart( rHTMLWrt, nSectEndIdx+1 ) )
     756             :         lcl_html_OutSectionStartTag( rHTMLWrt, *pSurrSection, *pSurrFormat,
     757           0 :                                      pSurrCol, true );
     758             : 
     759           0 :     return rWrt;
     760             : }
     761             : 
     762         277 : void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
     763             : {
     764         277 :     bool bSaveWriteAll = bWriteAll;     // sichern
     765             : 
     766             :     // suche die naechste text::Bookmark-Position aus der text::Bookmark-Tabelle
     767         277 :     nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : -1;
     768             : 
     769             :     // gebe alle Bereiche des Pams in das HTML-File aus.
     770         277 :     do {
     771         277 :         bWriteAll = bSaveWriteAll;
     772         277 :         bFirstLine = true;
     773             : 
     774             :         // suche den ersten am Pam-auszugebenen FlyFrame
     775             :         // fehlt noch:
     776             : 
     777        1694 :         while( pCurPam->GetPoint()->nNode.GetIndex() < pCurPam->GetMark()->nNode.GetIndex() ||
     778         816 :               (pCurPam->GetPoint()->nNode.GetIndex() == pCurPam->GetMark()->nNode.GetIndex() &&
     779         277 :                pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) )
     780             :         {
     781         308 :             SwNode&  rNd = pCurPam->GetNode();
     782             : 
     783             :             OSL_ENSURE( !(rNd.IsGrfNode() || rNd.IsOLENode()),
     784             :                     "Grf- oder OLE-Node hier unerwartet" );
     785         308 :             if( rNd.IsTextNode() )
     786             :             {
     787         291 :                 SwTextNode* pTextNd = rNd.GetTextNode();
     788             : 
     789         291 :                 if( !bFirstLine )
     790          16 :                     pCurPam->GetPoint()->nContent.Assign( pTextNd, 0 );
     791             : 
     792         291 :                 OutHTML_SwTextNode( *this, *pTextNd );
     793             :             }
     794          17 :             else if( rNd.IsTableNode() )
     795             :             {
     796           2 :                 OutHTML_SwTableNode( *this, *rNd.GetTableNode(), 0 );
     797           2 :                 nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : -1;
     798             :             }
     799          15 :             else if( rNd.IsSectionNode() )
     800             :             {
     801           0 :                 OutHTML_Section( *this, *rNd.GetSectionNode() );
     802           0 :                 nBkmkTabPos = bWriteAll ? FindPos_Bkmk( *pCurPam->GetPoint() ) : -1;
     803             :             }
     804          15 :             else if( &rNd == &pDoc->GetNodes().GetEndOfContent() )
     805          15 :                 break;
     806             : 
     807         293 :             ++pCurPam->GetPoint()->nNode;   // Bewegen
     808         293 :             sal_uInt32 nPos = pCurPam->GetPoint()->nNode.GetIndex();
     809             : 
     810         293 :             if( bShowProgress )
     811         293 :                 ::SetProgressState( nPos, pDoc->GetDocShell() );   // Wie weit ?
     812             : 
     813             :             /* sollen nur die Selectierten Bereiche gesichert werden, so
     814             :              * duerfen nur die vollstaendigen Nodes gespeichert werde,
     815             :              * d.H. der 1. und n. Node teilweise, der 2. bis n-1. Node
     816             :              * vollstaendig. (vollstaendig heisst mit allen Formaten! )
     817             :              */
     818         293 :             bWriteAll = bSaveWriteAll ||
     819         293 :                         nPos != pCurPam->GetMark()->nNode.GetIndex();
     820         293 :             bFirstLine = false;
     821         293 :             bOutFooter = false; // Nach einem Node keine Fusszeile mehr
     822             :         }
     823             : 
     824         277 :         ChangeParaToken( 0 ); // MIB 8.7.97: Machen wir jetzt hier und nicht
     825             :                               // beim Aufrufer
     826         277 :         OutAndSetDefList( 0 );
     827             : 
     828         277 :     } while( CopyNextPam( &pPam ) );        // bis alle PaM's bearbeitet
     829             : 
     830         277 :     bWriteAll = bSaveWriteAll;          // wieder auf alten Wert zurueck
     831         277 : }
     832             : 
     833             : // schreibe die StyleTabelle, algemeine Angaben,Header/Footer/Footnotes
     834          42 : static void OutBodyColor( const sal_Char* pTag, const SwFormat *pFormat,
     835             :                           SwHTMLWriter& rHWrt )
     836             : {
     837          42 :     const SwFormat *pRefFormat = 0;
     838             : 
     839          42 :     if( rHWrt.pTemplate )
     840          42 :         pRefFormat = SwHTMLWriter::GetTemplateFormat( pFormat->GetPoolFormatId(),
     841          84 :                                                 &rHWrt.pTemplate->getIDocumentStylePoolAccess() );
     842             : 
     843          42 :     const SvxColorItem *pColorItem = 0;
     844             : 
     845          42 :     const SfxItemSet& rItemSet = pFormat->GetAttrSet();
     846          42 :     const SfxPoolItem *pRefItem = 0, *pItem = 0;
     847             :     bool bItemSet = SfxItemState::SET == rItemSet.GetItemState( RES_CHRATR_COLOR,
     848          42 :                                                            true, &pItem);
     849          84 :     bool bRefItemSet = pRefFormat &&
     850          42 :         SfxItemState::SET == pRefFormat->GetAttrSet().GetItemState( RES_CHRATR_COLOR,
     851          84 :                                                             true, &pRefItem);
     852          42 :     if( bItemSet )
     853             :     {
     854             :         // wenn das Item nur in der Vorlage des aktuellen Doks gesetzt
     855             :         // ist oder einen anderen Wert hat, als in der HTML-Vorlage,
     856             :         // wird es gesetzt
     857          33 :         const SvxColorItem *pCItem = static_cast<const SvxColorItem*>(pItem);
     858             : 
     859          33 :         if( !bRefItemSet )
     860             :         {
     861           5 :             pColorItem = pCItem;
     862             :         }
     863             :         else
     864             :         {
     865          28 :             Color aColor( pCItem->GetValue() );
     866          28 :             if( COL_AUTO == aColor.GetColor() )
     867           0 :                 aColor.SetColor( COL_BLACK );
     868             : 
     869          28 :             Color aRefColor( static_cast<const SvxColorItem*>(pRefItem)->GetValue() );
     870          28 :             if( COL_AUTO == aRefColor.GetColor() )
     871           0 :                 aRefColor.SetColor( COL_BLACK );
     872             : 
     873          28 :             if( !aColor.IsRGBEqual( aRefColor ) )
     874           2 :                 pColorItem = pCItem;
     875             :         }
     876             :     }
     877           9 :     else if( bRefItemSet )
     878             :     {
     879             :         // Das Item war in der HTML-Vorlage noch gesetzt, also geben wir
     880             :         // das Default aus
     881             :         pColorItem = static_cast<const SvxColorItem*>(&rItemSet.GetPool()
     882           0 :                                         ->GetDefaultItem( RES_CHRATR_COLOR ));
     883             :     }
     884             : 
     885          42 :     if( pColorItem )
     886             :     {
     887           7 :         OStringBuffer sOut;
     888           7 :         sOut.append(" " + OString(pTag) + "=");
     889           7 :         rHWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     890           7 :         Color aColor( pColorItem->GetValue() );
     891           7 :         if( COL_AUTO == aColor.GetColor() )
     892           2 :             aColor.SetColor( COL_BLACK );
     893           7 :         HTMLOutFuncs::Out_Color( rHWrt.Strm(), aColor, rHWrt.eDestEnc );
     894           7 :         if( RES_POOLCOLL_STANDARD==pFormat->GetPoolFormatId() )
     895           5 :             rHWrt.pDfltColor = new Color( aColor );
     896             :     }
     897          42 : }
     898             : 
     899          14 : sal_uInt16 SwHTMLWriter::OutHeaderAttrs()
     900             : {
     901          14 :     sal_uLong nIdx = pCurPam->GetPoint()->nNode.GetIndex();
     902          14 :     sal_uLong nEndIdx = pCurPam->GetMark()->nNode.GetIndex();
     903             : 
     904          14 :     SwTextNode *pTextNd = 0;
     905          50 :     while( nIdx<=nEndIdx &&
     906          18 :         0==(pTextNd=pDoc->GetNodes()[nIdx]->GetTextNode()) )
     907           4 :         nIdx++;
     908             : 
     909             :     OSL_ENSURE( pTextNd, "Kein Text-Node gefunden" );
     910          14 :     if( !pTextNd || !pTextNd->HasHints() )
     911           9 :         return 0;
     912             : 
     913           5 :     sal_uInt16 nAttrs = 0;
     914           5 :     const size_t nCntAttr = pTextNd->GetSwpHints().Count();
     915           5 :     sal_Int32 nOldPos = 0;
     916          13 :     for( size_t i=0; i<nCntAttr; ++i )
     917             :     {
     918           9 :         const SwTextAttr *pHt = pTextNd->GetSwpHints()[i];
     919           9 :         if( !pHt->End() )
     920             :         {
     921           1 :             sal_Int32 nPos = pHt->GetStart();
     922           2 :             if( nPos-nOldPos > 1
     923           2 :                 || ( pHt->Which() != RES_TXTATR_FIELD
     924           0 :                      && pHt->Which() != RES_TXTATR_ANNOTATION ) )
     925           1 :                 break;
     926             : 
     927             :             const sal_uInt16 nFieldWhich =
     928           0 :                 static_cast<const SwFormatField&>(pHt->GetAttr()).GetField()->GetTyp()->Which();
     929           0 :             if( RES_POSTITFLD!=nFieldWhich &&
     930             :                 RES_SCRIPTFLD!=nFieldWhich )
     931           0 :                 break;
     932             : 
     933           0 :             OutNewLine();
     934           0 :             OutHTML_SwFormatField( *this, pHt->GetAttr() );
     935           0 :             nOldPos = nPos;
     936             :             OSL_ENSURE( nAttrs<SAL_MAX_UINT16, "Too many attributes" );
     937           0 :             nAttrs++;
     938             :         }
     939             :     }
     940             : 
     941           5 :     return nAttrs;
     942             : }
     943             : 
     944          15 : const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
     945             : {
     946          15 :     OStringBuffer sOut;
     947          15 :     if (!mbSkipHeaderFooter)
     948             :     {
     949          14 :         sOut.append(OString(OOO_STRING_SVTOOLS_HTML_doctype) + " " + OString(OOO_STRING_SVTOOLS_HTML_doctype40));
     950          14 :         HTMLOutFuncs::Out_AsciiTag( Strm(), sOut.makeStringAndClear().getStr() );
     951             : 
     952             :         // baue den Vorspann
     953          14 :         OutNewLine();
     954          14 :         HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_html );
     955             : 
     956          14 :         OutNewLine();
     957          14 :         HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_head );
     958             : 
     959          14 :         IncIndentLevel();   // Inhalt von <HEAD> einruecken
     960             : 
     961             :         // DokumentInfo
     962          14 :         OString sIndent = GetIndentString();
     963             : 
     964          28 :         uno::Reference<document::XDocumentProperties> xDocProps;
     965          14 :         SwDocShell *pDocShell(pDoc->GetDocShell());
     966          14 :         if (pDocShell)
     967             :         {
     968             :             uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     969          14 :                                                                        pDocShell->GetModel(), uno::UNO_QUERY_THROW);
     970          14 :             xDocProps.set(xDPS->getDocumentProperties());
     971             :         }
     972             : 
     973             :         // xDocProps may be null here (when copying)
     974          14 :         SfxFrameHTMLWriter::Out_DocInfo( Strm(), GetBaseURL(), xDocProps,
     975             :                                          sIndent.getStr(), eDestEnc,
     976          28 :                                          &aNonConvertableCharacters );
     977             : 
     978             :         // Kommentare und Meta-Tags des ersten Absatzes
     979          14 :         rHeaderAttrs = OutHeaderAttrs();
     980             : 
     981          28 :         OutFootEndNoteInfo();
     982             :     }
     983             : 
     984          15 :     const SwPageDesc *pPageDesc = 0;
     985             : 
     986             :     // In Nicht-HTML-Dokumenten wird die erste gesetzte Seitenvorlage
     987             :     // exportiert und wenn keine gesetzt ist die Standard-Vorlage
     988          15 :     sal_uLong nNodeIdx = pCurPam->GetPoint()->nNode.GetIndex();
     989             : 
     990          30 :     while( nNodeIdx < pDoc->GetNodes().Count() )
     991             :     {
     992          15 :         SwNode *pNd = pDoc->GetNodes()[ nNodeIdx ];
     993          15 :         if( pNd->IsContentNode() )
     994             :         {
     995             :             pPageDesc = static_cast<const SwFormatPageDesc &>(pNd->GetContentNode()
     996          13 :                 ->GetAttr(RES_PAGEDESC)).GetPageDesc();
     997          13 :             break;
     998             :         }
     999           2 :         else if( pNd->IsTableNode() )
    1000             :         {
    1001           2 :             pPageDesc = pNd->GetTableNode()->GetTable().GetFrameFormat()
    1002           2 :                            ->GetPageDesc().GetPageDesc();
    1003           2 :             break;
    1004             :         }
    1005             : 
    1006           0 :         nNodeIdx++;
    1007             :     }
    1008             : 
    1009          15 :     if( !pPageDesc )
    1010           5 :         pPageDesc = &pDoc->GetPageDesc( 0 );
    1011             : 
    1012          15 :     if (!mbSkipHeaderFooter)
    1013             :     {
    1014             :         // und nun ... das Style-Sheet!!!
    1015          14 :         if( bCfgOutStyles )
    1016             :         {
    1017          14 :             OutStyleSheet( *pPageDesc );
    1018             :         }
    1019             : 
    1020             :         // und nun ... das BASIC und JavaScript!
    1021          14 :         if( pDoc->GetDocShell() )   // nur mit DocShell ist Basic moeglich
    1022          14 :             OutBasic();
    1023             : 
    1024          14 :         DecIndentLevel();   // Inhalt von <HEAD> einruecken
    1025          14 :         OutNewLine();
    1026          14 :         HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_head, false );
    1027             : 
    1028             :         // der Body wird nicht eingerueckt, weil sonst alles eingerueckt waere!
    1029          14 :         OutNewLine();
    1030          14 :         sOut.append("<" + OString(OOO_STRING_SVTOOLS_HTML_body));
    1031          14 :         Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1032             : 
    1033             :         // language
    1034          14 :         OutLanguage( eLang );
    1035             : 
    1036             :         // Textfarbe ausgeben, wenn sie an der Standard-Vorlage gesetzt ist
    1037             :         // und sich geaendert hat.
    1038             :         OutBodyColor( OOO_STRING_SVTOOLS_HTML_O_text,
    1039          14 :                       pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD, false ),
    1040          14 :                       *this );
    1041             : 
    1042             :         // Farben fuer (un)besuchte Links
    1043             :         OutBodyColor( OOO_STRING_SVTOOLS_HTML_O_link,
    1044          14 :                       pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( RES_POOLCHR_INET_NORMAL ),
    1045          14 :                       *this );
    1046             :         OutBodyColor( OOO_STRING_SVTOOLS_HTML_O_vlink,
    1047          14 :                       pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( RES_POOLCHR_INET_VISIT ),
    1048          14 :                       *this );
    1049             : 
    1050          14 :         const SfxItemSet& rItemSet = pPageDesc->GetMaster().GetAttrSet();
    1051             : 
    1052             :         // fdo#86857 page styles now contain the XATTR_*, not RES_BACKGROUND
    1053             :         SvxBrushItem const aBrushItem(
    1054          14 :                 getSvxBrushItemFromSourceSet(rItemSet, RES_BACKGROUND));
    1055          14 :         OutBackground(&aBrushItem, true);
    1056             : 
    1057          14 :         nDirection = GetHTMLDirection( rItemSet );
    1058          14 :         OutDirection( nDirection );
    1059             : 
    1060          14 :         if( bCfgOutStyles )
    1061          14 :             OutCSS1_BodyTagStyleOpt( *this, rItemSet );
    1062             : 
    1063             :         // Events anhaengen
    1064          14 :         if( pDoc->GetDocShell() )   // nur mit DocShell ist Basic moeglich
    1065          14 :             OutBasicBodyEvents();
    1066             : 
    1067          14 :         Strm().WriteChar( '>' );
    1068             :     }
    1069             : 
    1070          15 :     return pPageDesc;
    1071             : }
    1072             : 
    1073           5 : void SwHTMLWriter::OutAnchor( const OUString& rName )
    1074             : {
    1075           5 :     OStringBuffer sOut;
    1076           5 :     sOut.append("<" + OString(OOO_STRING_SVTOOLS_HTML_anchor) + " " + OString(OOO_STRING_SVTOOLS_HTML_O_name) + "=\"");
    1077           5 :     Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1078           5 :     HTMLOutFuncs::Out_String( Strm(), rName, eDestEnc, &aNonConvertableCharacters ).WriteCharPtr( "\">" );
    1079           5 :     HTMLOutFuncs::Out_AsciiTag( Strm(), OOO_STRING_SVTOOLS_HTML_anchor, false );
    1080           5 : }
    1081             : 
    1082         291 : void SwHTMLWriter::OutBookmarks()
    1083             : {
    1084             :     // hole das aktuelle Bookmark
    1085         291 :     const ::sw::mark::IMark* pBookmark = NULL;
    1086         291 :     IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
    1087         291 :     if(nBkmkTabPos != -1)
    1088           6 :         pBookmark = (pMarkAccess->getAllMarksBegin() + nBkmkTabPos)->get();
    1089             :     // Ausgabe aller Bookmarks in diesem Absatz. Die Content-Position
    1090             :     // wird vorerst nicht beruecksichtigt!
    1091         291 :     sal_uInt32 nNode = pCurPam->GetPoint()->nNode.GetIndex();
    1092         885 :     while( nBkmkTabPos != -1
    1093         297 :            && pBookmark->GetMarkPos().nNode.GetIndex() == nNode )
    1094             :     {
    1095             :         // Der Bereich derBookmark wird erstam ignoriert, da er von uns
    1096             :         // auch nicht eingelesen wird.
    1097             : 
    1098             :         // erst die SWG spezifischen Daten:
    1099           6 :         if ( dynamic_cast< const ::sw::mark::IBookmark* >(pBookmark) && !pBookmark->GetName().isEmpty() )
    1100             :         {
    1101           4 :             OutAnchor( pBookmark->GetName() );
    1102             :         }
    1103             : 
    1104           6 :         if( ++nBkmkTabPos >= pMarkAccess->getAllMarksCount() )
    1105           1 :             nBkmkTabPos = -1;
    1106             :         else
    1107           5 :             pBookmark = (pMarkAccess->getAllMarksBegin() + nBkmkTabPos)->get();
    1108             :     }
    1109             : 
    1110             :     sal_uInt32 nPos;
    1111         292 :     for( nPos = 0; nPos < aOutlineMarkPoss.size() &&
    1112           1 :                    aOutlineMarkPoss[nPos] < nNode; nPos++ )
    1113             :         ;
    1114             : 
    1115         583 :     while( nPos < aOutlineMarkPoss.size() && aOutlineMarkPoss[nPos] == nNode )
    1116             :     {
    1117           1 :         OUString sMark( aOutlineMarks[nPos] );
    1118           1 :         OutAnchor( sMark.replace('?', '_') ); // '?' causes problems in IE/Netscape 5
    1119           1 :         aOutlineMarkPoss.erase( aOutlineMarkPoss.begin()+nPos );
    1120           1 :         aOutlineMarks.erase( aOutlineMarks.begin() + nPos );
    1121           1 :     }
    1122         291 : }
    1123             : 
    1124           2 : void SwHTMLWriter::OutPointFieldmarks( const SwPosition& rPos )
    1125             : {
    1126             :     // "point" fieldmarks that occupy single character space, as opposed to
    1127             :     // range fieldmarks that are associated with start and end points.
    1128             : 
    1129           2 :     const IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
    1130           2 :     if (!pMarkAccess)
    1131           0 :         return;
    1132             : 
    1133           2 :     const sw::mark::IFieldmark* pMark = pMarkAccess->getFieldmarkFor(rPos);
    1134           2 :     if (!pMark)
    1135           0 :         return;
    1136             : 
    1137           2 :     if (pMark->GetFieldname() == ODF_FORMCHECKBOX)
    1138             :     {
    1139             :         const sw::mark::ICheckboxFieldmark* pCheckBox =
    1140           2 :             dynamic_cast<const sw::mark::ICheckboxFieldmark*>(pMark);
    1141             : 
    1142           2 :         if (pCheckBox)
    1143             :         {
    1144           2 :             OString aOut("<");
    1145           2 :             aOut += OOO_STRING_SVTOOLS_HTML_input;
    1146           2 :             aOut += " ";
    1147           2 :             aOut += OOO_STRING_SVTOOLS_HTML_O_type;
    1148           2 :             aOut += "=\"";
    1149           2 :             aOut += OOO_STRING_SVTOOLS_HTML_IT_checkbox;
    1150           2 :             aOut += "\"";
    1151             : 
    1152           2 :             if (pCheckBox->IsChecked())
    1153             :             {
    1154           1 :                 aOut += " ";
    1155           1 :                 aOut += OOO_STRING_SVTOOLS_HTML_O_checked;
    1156           1 :                 aOut += "=\"";
    1157           1 :                 aOut += OOO_STRING_SVTOOLS_HTML_O_checked;
    1158           1 :                 aOut += "\"";
    1159             :             }
    1160             : 
    1161           2 :             aOut += "/>";
    1162           2 :             Strm().WriteCharPtr(aOut.getStr());
    1163             :         }
    1164             :     }
    1165             : 
    1166             :     // TODO : Handle other single-point fieldmark types here (if any).
    1167             : }
    1168             : 
    1169           5 : void SwHTMLWriter::OutImplicitMark( const OUString& rMark,
    1170             :                                     const sal_Char *pMarkType )
    1171             : {
    1172           5 :     if( !rMark.isEmpty() && !aImplicitMarks.empty() )
    1173             :     {
    1174           0 :         OUString sMark(rMark + OUStringLiteral1<cMarkSeparator>() + OUString::createFromAscii(pMarkType));
    1175           0 :         if( 0 != aImplicitMarks.erase( sMark ) )
    1176             :         {
    1177           0 :             OutAnchor(sMark.replace('?', '_')); // '?' causes problems in IE/Netscape 5
    1178           0 :         }
    1179             :     }
    1180           5 : }
    1181             : 
    1182           4 : OUString SwHTMLWriter::convertHyperlinkHRefValue(const OUString& rURL)
    1183             : {
    1184           4 :     OUString sURL(rURL);
    1185           4 :     sal_Int32 nPos = sURL.lastIndexOf(cMarkSeparator);
    1186           4 :     if (nPos != -1)
    1187             :     {
    1188           1 :         OUString sCompare(comphelper::string::remove(sURL.copy(nPos + 1), ' '));
    1189           1 :         if (!sCompare.isEmpty())
    1190             :         {
    1191           1 :             sCompare = sCompare.toAsciiLowerCase();
    1192           4 :             if( sCompare == "region"  || sCompare == "frame"   ||
    1193           3 :                 sCompare == "graphic" || sCompare == "ole"     ||
    1194           3 :                 sCompare == "table"   || sCompare == "outline" ||
    1195           0 :                 sCompare == "text" )
    1196             :             {
    1197           1 :                 sURL = sURL.replace( '?', '_' );   // '?' causes problems in IE/Netscape 5
    1198             :             }
    1199           1 :         }
    1200             :     }
    1201             :     else
    1202             :     {
    1203           3 :         INetURLObject aURL(sURL);
    1204           3 :         sURL = aURL.GetMainURL(INetURLObject::NO_DECODE);
    1205             :     }
    1206           4 :     return URIHelper::simpleNormalizedMakeRelative( GetBaseURL(), sURL );
    1207             : }
    1208             : 
    1209           2 : void SwHTMLWriter::OutHyperlinkHRefValue( const OUString& rURL )
    1210             : {
    1211           2 :     OUString sURL = convertHyperlinkHRefValue(rURL);
    1212           2 :     HTMLOutFuncs::Out_String( Strm(), sURL, eDestEnc, &aNonConvertableCharacters );
    1213           2 : }
    1214             : 
    1215         276 : void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic )
    1216             : {
    1217         276 :     const Color &rBackColor = pBrushItem->GetColor();
    1218             :     /// check, if background color is not "no fill"/"auto fill", instead of
    1219             :     /// only checking, if transparency is not set.
    1220         276 :     if( rBackColor.GetColor() != COL_TRANSPARENT )
    1221             :     {
    1222         263 :         OStringBuffer sOut;
    1223         263 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_bgcolor).append('=');
    1224         263 :         Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1225         263 :         HTMLOutFuncs::Out_Color( Strm(), rBackColor, eDestEnc);
    1226             :     }
    1227             : 
    1228         276 :     if( !bGraphic )
    1229         538 :         return;
    1230             : 
    1231          14 :     OUString aGraphicInBase64;
    1232          14 :     const Graphic* pGrf = pBrushItem->GetGraphic();
    1233          14 :     if( pGrf )
    1234             :     {
    1235           0 :         sal_uLong nErr = XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64);
    1236           0 :         if( nErr )
    1237             :         {
    1238           0 :             nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
    1239             :         }
    1240           0 :         Strm().WriteCharPtr( " " OOO_STRING_SVTOOLS_HTML_O_background "=\"" );
    1241           0 :         Strm().WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_data ":" );
    1242           0 :         HTMLOutFuncs::Out_String( Strm(), aGraphicInBase64, eDestEnc, &aNonConvertableCharacters ).WriteChar( '\"' );
    1243          14 :     }
    1244             : }
    1245             : 
    1246           2 : void SwHTMLWriter::OutBackground( const SfxItemSet& rItemSet, bool bGraphic )
    1247             : {
    1248             :     const SfxPoolItem* pItem;
    1249           2 :     if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false,
    1250           2 :                                                &pItem ))
    1251             :     {
    1252           1 :         OutBackground( static_cast<const SvxBrushItem*>(pItem), bGraphic );
    1253             :     }
    1254           2 : }
    1255             : 
    1256         325 : sal_uInt16 SwHTMLWriter::GetLangWhichIdFromScript( sal_uInt16 nScript )
    1257             : {
    1258             :     sal_uInt16 nWhichId;
    1259         325 :     switch( nScript )
    1260             :     {
    1261             :     case CSS1_OUTMODE_CJK:
    1262           0 :         nWhichId = RES_CHRATR_CJK_LANGUAGE;
    1263           0 :         break;
    1264             :     case CSS1_OUTMODE_CTL:
    1265           0 :         nWhichId = RES_CHRATR_CJK_LANGUAGE;
    1266           0 :         break;
    1267             :     default:
    1268         325 :         nWhichId = RES_CHRATR_LANGUAGE;
    1269         325 :         break;
    1270             :     }
    1271         325 :     return nWhichId;
    1272             : }
    1273             : 
    1274         280 : void SwHTMLWriter::OutLanguage( LanguageType nLang )
    1275             : {
    1276         280 :     if( LANGUAGE_DONTKNOW != nLang )
    1277             :     {
    1278         280 :         OStringBuffer sOut;
    1279         280 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_lang)
    1280         280 :             .append("=\"");
    1281         280 :         Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1282         280 :         HTMLOutFuncs::Out_String( Strm(), LanguageTag::convertToBcp47(nLang),
    1283         560 :                                   eDestEnc, &aNonConvertableCharacters ).WriteChar( '"' );
    1284             :     }
    1285         280 : }
    1286             : 
    1287          16 : sal_uInt16 SwHTMLWriter::GetHTMLDirection( const SfxItemSet& rItemSet ) const
    1288             : {
    1289             :     return GetHTMLDirection(
    1290          16 :         static_cast < const SvxFrameDirectionItem& >( rItemSet.Get( RES_FRAMEDIR ) )
    1291          16 :             .GetValue() );
    1292             : }
    1293             : 
    1294         307 : sal_uInt16 SwHTMLWriter::GetHTMLDirection( sal_uInt16 nDir ) const
    1295             : {
    1296         307 :     switch( nDir )
    1297             :     {
    1298             :     case FRMDIR_VERT_TOP_LEFT:
    1299           0 :         nDir = FRMDIR_HORI_LEFT_TOP;
    1300           0 :         break;
    1301             :     case FRMDIR_VERT_TOP_RIGHT:
    1302           0 :         nDir = FRMDIR_HORI_RIGHT_TOP;
    1303           0 :         break;
    1304             :     case FRMDIR_ENVIRONMENT:
    1305          13 :         nDir = nDirection;
    1306             :     }
    1307             : 
    1308         307 :     return nDir;
    1309             : }
    1310             : 
    1311          14 : void SwHTMLWriter::OutDirection( sal_uInt16 nDir )
    1312             : {
    1313          14 :     OString sConverted = convertDirection(nDir);
    1314          14 :     if (!sConverted.isEmpty())
    1315             :     {
    1316          14 :         OStringBuffer sOut;
    1317          14 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_dir)
    1318          14 :             .append("=\"").append(sConverted).append('\"');
    1319          14 :         Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
    1320          14 :     }
    1321          14 : }
    1322             : 
    1323          14 : OString SwHTMLWriter::convertDirection(sal_uInt16 nDir)
    1324             : {
    1325          14 :     OString sConverted;
    1326          14 :     switch (nDir)
    1327             :     {
    1328             :     case FRMDIR_HORI_LEFT_TOP:
    1329             :     case FRMDIR_VERT_TOP_LEFT:
    1330          14 :         sConverted = "ltr";
    1331          14 :         break;
    1332             :     case FRMDIR_HORI_RIGHT_TOP:
    1333             :     case FRMDIR_VERT_TOP_RIGHT:
    1334           0 :         sConverted = "rtl";
    1335           0 :         break;
    1336             :     }
    1337          14 :     return sConverted;
    1338             : }
    1339             : 
    1340          16 : OString SwHTMLWriter::GetIndentString(sal_uInt16 nIncLvl)
    1341             : {
    1342          16 :     OString sRet;
    1343             : 
    1344             :     // etwas umstaendlich, aber wir haben nur einen Indent-String!
    1345          16 :     sal_uInt16 nLevel = nIndentLvl + nIncLvl;
    1346             : 
    1347          16 :     if( nLevel && nLevel <= MAX_INDENT_LEVEL)
    1348             :     {
    1349          15 :         sIndentTabs[nLevel] = 0;
    1350          15 :         sRet = sIndentTabs;
    1351          15 :         sIndentTabs[nLevel] = '\t';
    1352             :     }
    1353             : 
    1354          16 :     return sRet;
    1355             : }
    1356             : 
    1357        1380 : void SwHTMLWriter::OutNewLine( bool bCheck )
    1358             : {
    1359        1380 :     if( !bCheck || (Strm().Tell()-nLastLFPos) > nIndentLvl )
    1360             :     {
    1361        1380 :         Strm().WriteCharPtr( SAL_NEWLINE_STRING );
    1362        1380 :         nLastLFPos = Strm().Tell();
    1363             :     }
    1364             : 
    1365        1380 :     if( nIndentLvl && nIndentLvl <= MAX_INDENT_LEVEL)
    1366             :     {
    1367        1244 :         sIndentTabs[nIndentLvl] = 0;
    1368        1244 :         Strm().WriteCharPtr( sIndentTabs );
    1369        1244 :         sIndentTabs[nIndentLvl] = '\t';
    1370             :     }
    1371        1380 : }
    1372             : 
    1373           6 : sal_uInt16 SwHTMLWriter::GetHTMLFontSize( sal_uInt32 nHeight ) const
    1374             : {
    1375           6 :     sal_uInt16 nSize = 1;
    1376          26 :     for( sal_uInt16 i=6; i>0; i-- )
    1377             :     {
    1378          26 :         if( nHeight > (aFontHeights[i] + aFontHeights[i-1])/2 )
    1379             :         {
    1380           6 :             nSize = i+1;
    1381           6 :             break;
    1382             :         }
    1383             :     }
    1384             : 
    1385           6 :     return nSize;
    1386             : }
    1387             : 
    1388             : // Paragraphs with Table of Contents and other index styles will be typeset with
    1389             : // dot leaders at the position of the last tabulator in PrintLayout (CSS2) mode
    1390         291 : sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rStr )
    1391             : {
    1392         291 :     if (bCfgPrintLayout && ((nPoolId >= RES_POOLCOLL_TOX_CNTNT1 && nPoolId <= RES_POOLCOLL_TOX_CNTNT5) ||
    1393           0 :         (nPoolId >= RES_POOLCOLL_TOX_IDX1 && nPoolId <= RES_POOLCOLL_TOX_IDX3) ||
    1394           0 :         (nPoolId >= RES_POOLCOLL_TOX_USER1 && nPoolId <= RES_POOLCOLL_TOX_CNTNT10) ||
    1395           0 :         nPoolId == RES_POOLCOLL_TOX_ILLUS1 || nPoolId == RES_POOLCOLL_TOX_TABLES1 ||
    1396           0 :         nPoolId == RES_POOLCOLL_TOX_OBJECT1 ||
    1397           0 :         (nPoolId >= RES_POOLCOLL_TOX_AUTHORITIES1 && nPoolId <= RES_POOLCOLL_TOX_USER10))) {
    1398           0 :              sal_Int32 i = rStr.lastIndexOf('\t');
    1399             :              // there are only ASCII (Latin-1) characters after the tabulator
    1400           0 :              if (i > -1 && OUStringToOString(rStr.copy(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
    1401           0 :                  return i;
    1402             :     }
    1403         291 :     return -1;
    1404             : }
    1405             : 
    1406             : // Struktur speichert die aktuellen Daten des Writers zwischen, um
    1407             : // einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer
    1408         262 : HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, sal_uLong nStt,
    1409             :                            sal_uLong nEnd, bool bSaveNum,
    1410             :                            const SwFrameFormat *pFrameFormat)
    1411             :     : rWrt(rWriter)
    1412             :     , pOldPam(rWrt.pCurPam)
    1413         262 :     , pOldEnd(rWrt.GetEndPaM())
    1414             :     , pOldNumRuleInfo(0)
    1415             :     , pOldNextNumRuleInfo(0)
    1416             :     , nOldDefListLvl(rWrt.nDefListLvl)
    1417             :     , nOldDirection(rWrt.nDirection)
    1418             :     , bOldOutHeader(rWrt.bOutHeader)
    1419             :     , bOldOutFooter(rWrt.bOutFooter)
    1420             :     , bOldOutFlyFrame(rWrt.bOutFlyFrame)
    1421         524 :     , pOldFlyFormat(NULL)
    1422             : {
    1423         262 :     bOldWriteAll = rWrt.bWriteAll;
    1424             : 
    1425         262 :     rWrt.pCurPam = Writer::NewSwPaM( *rWrt.pDoc, nStt, nEnd );
    1426             : 
    1427             :     // Tabelle in Sonderbereichen erkennen
    1428         262 :     if( nStt != rWrt.pCurPam->GetMark()->nNode.GetIndex() )
    1429             :     {
    1430           0 :         const SwNode *pNd = rWrt.pDoc->GetNodes()[ nStt ];
    1431           0 :         if( pNd->IsTableNode() || pNd->IsSectionNode() )
    1432           0 :             rWrt.pCurPam->GetMark()->nNode = nStt;
    1433             :     }
    1434             : 
    1435         262 :     rWrt.SetEndPaM( rWrt.pCurPam );
    1436         262 :     rWrt.pCurPam->Exchange( );
    1437         262 :     rWrt.bWriteAll = true;
    1438         262 :     rWrt.nDefListLvl = 0;
    1439         262 :     rWrt.bOutHeader = rWrt.bOutFooter = false;
    1440             : 
    1441             :     // Ggf. die aktuelle Numerierungs-Info merken, damit sie wieder
    1442             :     // neu aufgenommen werden kann. Nur dann belibt auch die Numerierungs-
    1443             :     // Info des nachsten Absatz gueltig.
    1444         262 :     if( bSaveNum )
    1445             :     {
    1446         262 :         pOldNumRuleInfo = new SwHTMLNumRuleInfo( rWrt.GetNumInfo() );
    1447         262 :         pOldNextNumRuleInfo = rWrt.GetNextNumInfo();
    1448         262 :         rWrt.SetNextNumInfo( 0 );
    1449             :     }
    1450             :     else
    1451             :     {
    1452           0 :         rWrt.ClearNextNumInfo();
    1453             :     }
    1454             : 
    1455             :     // Die Numerierung wird in jedem Fall unterbrochen.
    1456         262 :     rWrt.GetNumInfo().Clear();
    1457             : 
    1458         262 :     if( pFrameFormat )
    1459           0 :         rWrt.nDirection = rWrt.GetHTMLDirection( pFrameFormat->GetAttrSet() );
    1460         262 : }
    1461             : 
    1462         262 : HTMLSaveData::~HTMLSaveData()
    1463             : {
    1464         262 :     delete rWrt.pCurPam;                    // Pam wieder loeschen
    1465             : 
    1466         262 :     rWrt.pCurPam = pOldPam;
    1467         262 :     rWrt.SetEndPaM( pOldEnd );
    1468         262 :     rWrt.bWriteAll = bOldWriteAll;
    1469         262 :     rWrt.nBkmkTabPos = bOldWriteAll ? rWrt.FindPos_Bkmk( *pOldPam->GetPoint() ) : -1;
    1470         262 :     rWrt.nLastParaToken = 0;
    1471         262 :     rWrt.nDefListLvl = nOldDefListLvl;
    1472         262 :     rWrt.nDirection = nOldDirection;
    1473         262 :     rWrt.bOutHeader = bOldOutHeader;
    1474         262 :     rWrt.bOutFooter = bOldOutFooter;
    1475         262 :     rWrt.bOutFlyFrame = bOldOutFlyFrame;
    1476             : 
    1477             :     // Ggf. die Numerierung von vor der Section fortsetzen. Die Numerierung
    1478             :     // des naecshten Absatz wird in jedem Fall ungueltig.
    1479         262 :     if( pOldNumRuleInfo )
    1480             :     {
    1481         262 :         rWrt.GetNumInfo().Set( *pOldNumRuleInfo );
    1482         262 :         delete pOldNumRuleInfo;
    1483         262 :         rWrt.SetNextNumInfo( pOldNextNumRuleInfo );
    1484             :     }
    1485             :     else
    1486             :     {
    1487           0 :         rWrt.GetNumInfo().Clear();
    1488           0 :         rWrt.ClearNextNumInfo();
    1489             :     }
    1490         262 : }
    1491             : 
    1492          15 : void GetHTMLWriter( const OUString&, const OUString& rBaseURL, WriterRef& xRet )
    1493             : {
    1494          15 :     xRet = new SwHTMLWriter( rBaseURL );
    1495         192 : }
    1496             : 
    1497             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11