LCOV - code coverage report
Current view: top level - sd/source/filter/html - htmlex.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 351 1664 21.1 %
Date: 2015-06-13 12:38:46 Functions: 36 77 46.8 %
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 "htmlex.hxx"
      21             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      22             : #include <com/sun/star/document/XExporter.hpp>
      23             : #include <com/sun/star/document/XFilter.hpp>
      24             : #include <com/sun/star/drawing/GraphicExportFilter.hpp>
      25             : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      26             : 
      27             : #include <rtl/uri.hxx>
      28             : #include <comphelper/processfactory.hxx>
      29             : #include <osl/file.hxx>
      30             : #include <unotools/pathoptions.hxx>
      31             : #include <vcl/FilterConfigItem.hxx>
      32             : #include <unotools/ucbstreamhelper.hxx>
      33             : #include <unotools/localfilehelper.hxx>
      34             : #include <com/sun/star/frame/XStorable.hpp>
      35             : #include <sfx2/app.hxx>
      36             : #include <sfx2/dispatch.hxx>
      37             : #include <sfx2/docfile.hxx>
      38             : #include <sfx2/fcontnr.hxx>
      39             : #include <sfx2/frmhtmlw.hxx>
      40             : #include <sfx2/progress.hxx>
      41             : #include <vcl/wrkwin.hxx>
      42             : #include <svl/aeitem.hxx>
      43             : #include <svx/svditer.hxx>
      44             : #include <svtools/imaprect.hxx>
      45             : #include <svtools/imapcirc.hxx>
      46             : #include <svtools/imappoly.hxx>
      47             : #include <vcl/msgbox.hxx>
      48             : #include <editeng/outlobj.hxx>
      49             : #include <editeng/editobj.hxx>
      50             : #include <svx/svdopath.hxx>
      51             : #include <svx/xoutbmp.hxx>
      52             : #include <svtools/htmlout.hxx>
      53             : #include <vcl/cvtgrf.hxx>
      54             : #include <svtools/colorcfg.hxx>
      55             : #include <vcl/graphicfilter.hxx>
      56             : #include <editeng/colritem.hxx>
      57             : #include <editeng/editeng.hxx>
      58             : #include <editeng/wghtitem.hxx>
      59             : #include <editeng/udlnitem.hxx>
      60             : #include <editeng/postitem.hxx>
      61             : #include <editeng/crossedoutitem.hxx>
      62             : #include <editeng/flditem.hxx>
      63             : #include <svl/style.hxx>
      64             : #include <editeng/frmdiritem.hxx>
      65             : #include <svx/svdoutl.hxx>
      66             : #include <svx/svdogrp.hxx>
      67             : #include <svx/svdotable.hxx>
      68             : #include <tools/urlobj.hxx>
      69             : #include <vcl/bmpacc.hxx>
      70             : #include <svtools/sfxecode.hxx>
      71             : #include <com/sun/star/beans/PropertyState.hpp>
      72             : #include <tools/resmgr.hxx>
      73             : #include <comphelper/anytostring.hxx>
      74             : #include <cppuhelper/exc_hlp.hxx>
      75             : #include <basegfx/polygon/b2dpolygon.hxx>
      76             : 
      77             : #include "drawdoc.hxx"
      78             : #include "htmlpublishmode.hxx"
      79             : #include "Outliner.hxx"
      80             : #include "sdpage.hxx"
      81             : #include "sdattr.hxx"
      82             : #include "glob.hrc"
      83             : #include "anminfo.hxx"
      84             : #include "imapinfo.hxx"
      85             : #include "sdresid.hxx"
      86             : #include "buttonset.hxx"
      87             : 
      88             : using namespace ::com::sun::star;
      89             : using namespace ::com::sun::star::uno;
      90             : using namespace ::com::sun::star::beans;
      91             : using namespace ::com::sun::star::frame;
      92             : using namespace ::com::sun::star::lang;
      93             : using namespace ::com::sun::star::document;
      94             : 
      95             : using namespace sdr::table;
      96             : 
      97             : // get parameter from Itemset
      98             : #define RESTOHTML( res ) StringToHTMLString(SD_RESSTR(res))
      99             : 
     100             : const char *pButtonNames[] =
     101             : {
     102             :     "first-inactive.png",
     103             :     "first.png",
     104             :     "left-inactive.png",
     105             :     "left.png",
     106             :     "right-inactive.png",
     107             :     "right.png",
     108             :     "last-inactive.png",
     109             :     "last.png",
     110             :     "home.png",
     111             :     "text.png",
     112             :     "expand.png",
     113             :     "collapse.png",
     114             : };
     115             : 
     116             : #define BTN_FIRST_0 0
     117             : #define BTN_FIRST_1 1
     118             : #define BTN_PREV_0  2
     119             : #define BTN_PREV_1  3
     120             : #define BTN_NEXT_0  4
     121             : #define BTN_NEXT_1  5
     122             : #define BTN_LAST_0  6
     123             : #define BTN_LAST_1  7
     124             : #define BTN_INDEX   8
     125             : #define BTN_TEXT    9
     126             : #define BTN_MORE    10
     127             : #define BTN_LESS    11
     128             : 
     129             : // Helper class for the simple creation of files local/remote
     130             : class EasyFile
     131             : {
     132             : private:
     133             :     SvStream*   pOStm;
     134             :     SfxMedium*  pMedium;
     135             :     bool        bOpen;
     136             : 
     137             : public:
     138             : 
     139             :     EasyFile();
     140             :     ~EasyFile();
     141             : 
     142             :     sal_uLong createStream( const OUString& rUrl, SvStream*& rpStr );
     143             :     sal_uLong createFileName(  const OUString& rUrl, OUString& rFileName );
     144             :     sal_uLong close();
     145             : };
     146             : 
     147             : // Helper class for the embedding of text attributes into the html output
     148          26 : class HtmlState
     149             : {
     150             : private:
     151             :     bool mbColor;
     152             :     bool mbWeight;
     153             :     bool mbItalic;
     154             :     bool mbUnderline;
     155             :     bool mbStrike;
     156             :     bool mbLink;
     157             :     Color maColor;
     158             :     Color maDefColor;
     159             :     OUString maLink;
     160             :     OUString maTarget;
     161             : 
     162             : public:
     163             :     HtmlState( Color aDefColor );
     164             : 
     165             :     OUString SetWeight( bool bWeight );
     166             :     OUString SetItalic( bool bItalic );
     167             :     OUString SetUnderline( bool bUnderline );
     168             :     OUString SetColor( Color aColor );
     169             :     OUString SetStrikeout( bool bStrike );
     170             :     OUString SetLink( const OUString& aLink, const OUString& aTarget );
     171             :     OUString Flush();
     172             : };
     173             : 
     174             : // close all still open tags
     175          26 : OUString HtmlState::Flush()
     176             : {
     177          26 :     OUString aStr;
     178             : 
     179          26 :     aStr += SetWeight(false);
     180          26 :     aStr += SetItalic(false);
     181          26 :     aStr += SetUnderline(false);
     182          26 :     aStr += SetStrikeout(false);
     183          26 :     aStr += SetColor(maDefColor);
     184          26 :     aStr += SetLink("","");
     185             : 
     186          26 :     return aStr;
     187             : }
     188             : 
     189             : // c'tor with default color for the page
     190          26 : HtmlState::HtmlState( Color aDefColor )
     191             : {
     192          26 :     mbColor = false;
     193          26 :     mbWeight = false;
     194          26 :     mbItalic = false;
     195          26 :     mbUnderline = false;
     196          26 :     mbLink = false;
     197          26 :     mbStrike = false;
     198          26 :     maDefColor = aDefColor;
     199          26 : }
     200             : 
     201             : // enables/disables bold print
     202          52 : OUString HtmlState::SetWeight( bool bWeight )
     203             : {
     204          52 :     OUString aStr;
     205             : 
     206          52 :     if(bWeight && !mbWeight)
     207           0 :         aStr = "<b>";
     208          52 :     else if(!bWeight && mbWeight)
     209           0 :         aStr = "</b>";
     210             : 
     211          52 :     mbWeight = bWeight;
     212          52 :     return aStr;
     213             : }
     214             : 
     215             : // enables/disables italic
     216             : 
     217          52 : OUString HtmlState::SetItalic( bool bItalic )
     218             : {
     219          52 :     OUString aStr;
     220             : 
     221          52 :     if(bItalic && !mbItalic)
     222           0 :         aStr = "<i>";
     223          52 :     else if(!bItalic && mbItalic)
     224           0 :         aStr = "</i>";
     225             : 
     226          52 :     mbItalic = bItalic;
     227          52 :     return aStr;
     228             : }
     229             : 
     230             : // enables/disables underlines
     231             : 
     232          52 : OUString HtmlState::SetUnderline( bool bUnderline )
     233             : {
     234          52 :     OUString aStr;
     235             : 
     236          52 :     if(bUnderline && !mbUnderline)
     237           0 :         aStr = "<u>";
     238          52 :     else if(!bUnderline && mbUnderline)
     239           0 :         aStr = "</u>";
     240             : 
     241          52 :     mbUnderline = bUnderline;
     242          52 :     return aStr;
     243             : }
     244             : 
     245             : // enables/disables strike through
     246          52 : OUString HtmlState::SetStrikeout( bool bStrike )
     247             : {
     248          52 :     OUString aStr;
     249             : 
     250          52 :     if(bStrike && !mbStrike)
     251           0 :         aStr = "<strike>";
     252          52 :     else if(!bStrike && mbStrike)
     253           0 :         aStr = "</strike>";
     254             : 
     255          52 :     mbStrike = bStrike;
     256          52 :     return aStr;
     257             : }
     258             : 
     259             : // Sets the specified text color
     260          26 : OUString HtmlState::SetColor( Color aColor )
     261             : {
     262          26 :     OUString aStr;
     263             : 
     264          26 :     if(mbColor && aColor == maColor)
     265           0 :         return aStr;
     266             : 
     267          26 :     if(mbColor)
     268             :     {
     269           0 :         aStr = "</font>";
     270           0 :         mbColor = false;
     271             :     }
     272             : 
     273          26 :     if(aColor != maDefColor)
     274             :     {
     275           0 :         maColor = aColor;
     276           0 :         aStr += "<font color=\"" + HtmlExport::ColorToHTMLString(aColor) + "\">";
     277           0 :         mbColor = true;
     278             :     }
     279             : 
     280          26 :     return aStr;
     281             : }
     282             : 
     283             : // enables/disables a hyperlink
     284          52 : OUString HtmlState::SetLink( const OUString& aLink, const OUString& aTarget )
     285             : {
     286          52 :     OUString aStr;
     287             : 
     288          52 :     if(mbLink&&maLink == aLink&&maTarget==aTarget)
     289           0 :         return aStr;
     290             : 
     291          52 :     if(mbLink)
     292             :     {
     293           0 :         aStr = "</a>";
     294           0 :         mbLink = false;
     295             :     }
     296             : 
     297          52 :     if (!aLink.isEmpty())
     298             :     {
     299           0 :         aStr += "<a href=\"" + aLink;
     300           0 :         if (!aTarget.isEmpty())
     301             :         {
     302           0 :             aStr += "\" target=\"" + aTarget;
     303             :         }
     304           0 :         aStr += "\">";
     305           0 :         mbLink = true;
     306           0 :         maLink = aLink;
     307           0 :         maTarget = aTarget;
     308             :     }
     309             : 
     310          52 :     return aStr;
     311             : }
     312             : namespace
     313             : {
     314             : 
     315          25 : OUString getParagraphStyle( SdrOutliner* pOutliner, sal_Int32 nPara )
     316             : {
     317          25 :     SfxItemSet aParaSet( pOutliner->GetParaAttribs( nPara ) );
     318             : 
     319          25 :     OUString sStyle;
     320             : 
     321          25 :     if( static_cast<const SvxFrameDirectionItem*>(aParaSet.GetItem( EE_PARA_WRITINGDIR ))->GetValue() == FRMDIR_HORI_RIGHT_TOP )
     322             :     {
     323             : 
     324           0 :         sStyle = "direction: rtl;";
     325             :     }
     326             :     else
     327             :     {
     328             :         // This is the default so don't write it out
     329             :         // sStyle += "direction: ltr;";
     330             :     }
     331          25 :     return sStyle;
     332             : }
     333             : 
     334          25 : void lclAppendStyle(OUStringBuffer& aBuffer, const OUString& aTag, const OUString& aStyle)
     335             : {
     336          25 :     if (aStyle.isEmpty())
     337          22 :         aBuffer.append("<" + aTag + ">");
     338             :     else
     339           3 :         aBuffer.append("<" + aTag + " style=\"" + aStyle + "\">");
     340          25 : }
     341             : 
     342             : } // anonymous namespace
     343             : 
     344             : // constructor for the html export helper classes
     345           1 : HtmlExport::HtmlExport(
     346             :     const OUString& aPath,
     347             :     const Sequence< PropertyValue >& rParams,
     348             :     SdDrawDocument* pExpDoc,
     349             :     sd::DrawDocShell* pDocShell )
     350             :     :   maPath( aPath ),
     351             :         mpDoc(pExpDoc),
     352             :         mpDocSh( pDocShell ),
     353             :         meEC(NULL),
     354             :         meMode( PUBLISH_SINGLE_DOCUMENT ),
     355             :         mbContentsPage(false),
     356             :         mnButtonThema(-1),
     357             :         mnWidthPixel( PUB_MEDRES_WIDTH ),
     358             :         meFormat( FORMAT_JPG ),
     359             :         mbNotes(false),
     360             :         mnCompression( -1 ),
     361             :         mbDownload( false ),
     362             :         mbSlideSound(true),
     363             :         mbHiddenSlides(true),
     364             :         mbUserAttr(false),
     365             :         maTextColor(COL_BLACK),
     366             :         maBackColor(COL_WHITE),
     367             :         mbDocColors(false),
     368             :         maHTMLExtension(SdResId(STR_HTMLEXP_DEFAULT_EXTENSION)),
     369             :         maIndexUrl("index"),
     370             :         meScript( SCRIPT_ASP ),
     371             :         maHTMLHeader(
     372             :             "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\r\n"
     373             :             "     \"http://www.w3.org/TR/html4/transitional.dtd\">\r\n"
     374             :             "<html>\r\n<head>\r\n" ),
     375           1 :         mpButtonSet( new ButtonSet() )
     376             : {
     377           1 :     bool bChange = mpDoc->IsChanged();
     378             : 
     379           1 :     maIndexUrl += maHTMLExtension;
     380             : 
     381           1 :     InitExportParameters( rParams );
     382             : 
     383           1 :     switch( meMode )
     384             :     {
     385             :     case PUBLISH_HTML:
     386             :     case PUBLISH_FRAMES:
     387           0 :         ExportHtml();
     388           0 :         break;
     389             :     case PUBLISH_WEBCAST:
     390           0 :         ExportWebCast();
     391           0 :         break;
     392             :     case PUBLISH_KIOSK:
     393           0 :         ExportKiosk();
     394           0 :         break;
     395             :     case PUBLISH_SINGLE_DOCUMENT:
     396           1 :         ExportSingleDocument();
     397           1 :         break;
     398             :     }
     399             : 
     400           1 :     mpDoc->SetChanged(bChange);
     401           1 : }
     402             : 
     403           1 : HtmlExport::~HtmlExport()
     404             : {
     405           1 : }
     406             : 
     407             : // get common export parameters from item set
     408           1 : void HtmlExport::InitExportParameters( const Sequence< PropertyValue >& rParams )
     409             : {
     410           1 :     mbImpress = mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS;
     411             : 
     412           1 :     sal_Int32 nArgs = rParams.getLength();
     413           1 :     const PropertyValue* pParams = rParams.getConstArray();
     414           1 :     OUString aStr;
     415           2 :     while( nArgs-- )
     416             :     {
     417           0 :         if ( pParams->Name == "PublishMode" )
     418             :         {
     419           0 :             sal_Int32 temp = 0;
     420           0 :             pParams->Value >>= temp;
     421           0 :             meMode = (HtmlPublishMode)temp;
     422             :         }
     423           0 :         else if ( pParams->Name == "IndexURL" )
     424             :         {
     425           0 :             pParams->Value >>= aStr;
     426           0 :             maIndexUrl = aStr;
     427             :         }
     428           0 :         else if ( pParams->Name == "Format" )
     429             :         {
     430           0 :             sal_Int32 temp = 0;
     431           0 :             pParams->Value >>= temp;
     432           0 :             meFormat = (PublishingFormat)temp;
     433             :         }
     434           0 :         else if ( pParams->Name == "Compression" )
     435             :         {
     436           0 :             pParams->Value >>= aStr;
     437           0 :             OUString aTmp( aStr );
     438           0 :             if(!aTmp.isEmpty())
     439             :             {
     440           0 :                 aTmp = aTmp.replaceFirst("%", "");
     441           0 :                 mnCompression = (sal_Int16)aTmp.toInt32();
     442           0 :             }
     443             :         }
     444           0 :         else if ( pParams->Name == "Width" )
     445             :         {
     446           0 :             sal_Int32 temp = 0;
     447           0 :             pParams->Value >>= temp;
     448           0 :             mnWidthPixel = (sal_uInt16)temp;
     449             :         }
     450           0 :         else if ( pParams->Name == "UseButtonSet" )
     451             :         {
     452           0 :             sal_Int32 temp = 0;
     453           0 :             pParams->Value >>= temp;
     454           0 :             mnButtonThema = (sal_Int16)temp;
     455             :         }
     456           0 :         else if ( pParams->Name == "IsExportNotes" )
     457             :         {
     458           0 :             if( mbImpress )
     459             :             {
     460           0 :                 bool temp = false;
     461           0 :                 pParams->Value >>= temp;
     462           0 :                 mbNotes = temp;
     463             :             }
     464             :         }
     465           0 :         else if ( pParams->Name == "IsExportContentsPage" )
     466             :         {
     467           0 :             bool temp = false;
     468           0 :             pParams->Value >>= temp;
     469           0 :             mbContentsPage = temp;
     470             :         }
     471           0 :         else if ( pParams->Name == "Author" )
     472             :         {
     473           0 :             pParams->Value >>= aStr;
     474           0 :             maAuthor = aStr;
     475             :         }
     476           0 :         else if ( pParams->Name == "EMail" )
     477             :         {
     478           0 :             pParams->Value >>= aStr;
     479           0 :             maEMail = aStr;
     480             :         }
     481           0 :         else if ( pParams->Name == "HomepageURL" )
     482             :         {
     483           0 :             pParams->Value >>= aStr;
     484           0 :             maHomePage = aStr;
     485             :         }
     486           0 :         else if ( pParams->Name == "UserText" )
     487             :         {
     488           0 :             pParams->Value >>= aStr;
     489           0 :             maInfo = aStr;
     490             :         }
     491           0 :         else if ( pParams->Name == "EnableDownload" )
     492             :         {
     493           0 :             bool temp = false;
     494           0 :             pParams->Value >>= temp;
     495           0 :             mbDownload = temp;
     496             :         }
     497           0 :         else if ( pParams->Name == "SlideSound" )
     498             :         {
     499           0 :             bool temp = true;
     500           0 :             pParams->Value >>= temp;
     501           0 :             mbSlideSound = temp;
     502             :         }
     503           0 :         else if ( pParams->Name == "HiddenSlides" )
     504             :         {
     505           0 :             bool temp = true;
     506           0 :             pParams->Value >>= temp;
     507           0 :             mbHiddenSlides = temp;
     508             :         }
     509           0 :         else if ( pParams->Name == "BackColor" )
     510             :         {
     511           0 :             sal_Int32 temp = 0;
     512           0 :             pParams->Value >>= temp;
     513           0 :             maBackColor = temp;
     514           0 :             mbUserAttr = true;
     515             :         }
     516           0 :         else if ( pParams->Name == "TextColor" )
     517             :         {
     518           0 :             sal_Int32 temp = 0;
     519           0 :             pParams->Value >>= temp;
     520           0 :             maTextColor = temp;
     521           0 :             mbUserAttr = true;
     522             :         }
     523           0 :         else if ( pParams->Name == "LinkColor" )
     524             :         {
     525           0 :             sal_Int32 temp = 0;
     526           0 :             pParams->Value >>= temp;
     527           0 :             maLinkColor = temp;
     528           0 :             mbUserAttr = true;
     529             :         }
     530           0 :         else if ( pParams->Name == "VLinkColor" )
     531             :         {
     532           0 :             sal_Int32 temp = 0;
     533           0 :             pParams->Value >>= temp;
     534           0 :             maVLinkColor = temp;
     535           0 :             mbUserAttr = true;
     536             :         }
     537           0 :         else if ( pParams->Name == "ALinkColor" )
     538             :         {
     539           0 :             sal_Int32 temp = 0;
     540           0 :             pParams->Value >>= temp;
     541           0 :             maALinkColor = temp;
     542           0 :             mbUserAttr = true;
     543             :         }
     544           0 :         else if ( pParams->Name == "IsUseDocumentColors" )
     545             :         {
     546           0 :             bool temp = false;
     547           0 :             pParams->Value >>= temp;
     548           0 :             mbDocColors = temp;
     549             :         }
     550           0 :         else if ( pParams->Name == "KioskSlideDuration" )
     551             :         {
     552           0 :             double temp = 0.0;
     553           0 :             pParams->Value >>= temp;
     554           0 :             mfSlideDuration = temp;
     555           0 :             mbAutoSlide = true;
     556             :         }
     557           0 :         else if ( pParams->Name == "KioskEndless" )
     558             :         {
     559           0 :             bool temp = false;
     560           0 :             pParams->Value >>= temp;
     561           0 :             mbEndless = temp;
     562             :         }
     563           0 :         else if ( pParams->Name == "WebCastCGIURL" )
     564             :         {
     565           0 :             pParams->Value >>= aStr;
     566           0 :             maCGIPath = aStr;
     567             :         }
     568           0 :         else if ( pParams->Name == "WebCastTargetURL" )
     569             :         {
     570           0 :             pParams->Value >>= aStr;
     571           0 :             maURLPath = aStr;
     572             :         }
     573           0 :         else if ( pParams->Name == "WebCastScriptLanguage" )
     574             :         {
     575           0 :             pParams->Value >>= aStr;
     576           0 :             if ( aStr == "asp" )
     577             :             {
     578           0 :                 meScript = SCRIPT_ASP;
     579             :             }
     580             :             else
     581             :             {
     582           0 :                 meScript = SCRIPT_PERL;
     583             :             }
     584             :         }
     585             :         else
     586             :         {
     587             :             OSL_FAIL("Unknown property for html export detected!");
     588             :         }
     589             : 
     590           0 :         pParams++;
     591             :     }
     592             : 
     593           1 :     if( meMode == PUBLISH_KIOSK )
     594             :     {
     595           0 :         mbContentsPage = false;
     596           0 :         mbNotes = false;
     597             : 
     598             :     }
     599             : 
     600             :     // calculate image sizes
     601           1 :     SdPage* pPage = mpDoc->GetSdPage(0, PK_STANDARD);
     602           1 :     Size aTmpSize( pPage->GetSize() );
     603           1 :     double dRatio=((double)aTmpSize.Width())/aTmpSize.Height();
     604             : 
     605           1 :     mnHeightPixel = (sal_uInt16)(mnWidthPixel/dRatio);
     606             : 
     607             :     // we come up with a destination...
     608             : 
     609           2 :     INetURLObject aINetURLObj( maPath );
     610             :     DBG_ASSERT( aINetURLObj.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
     611             : 
     612           1 :     maExportPath = aINetURLObj.GetPartBeforeLastName(); // with trailing '/'
     613           1 :     maIndex = aINetURLObj.GetLastName();
     614             : 
     615           1 :     mnSdPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
     616           5 :     for( sal_uInt16 nPage = 0; nPage < mnSdPageCount; nPage++ )
     617             :     {
     618           4 :         pPage = mpDoc->GetSdPage( nPage, PK_STANDARD );
     619             : 
     620           4 :         if( mbHiddenSlides || !pPage->IsExcluded() )
     621             :         {
     622           4 :             maPages.push_back( pPage );
     623           4 :             maNotesPages.push_back( mpDoc->GetSdPage( nPage, PK_NOTES ) );
     624             :         }
     625             :     }
     626           1 :     mnSdPageCount = maPages.size();
     627             : 
     628           1 :     mbFrames = meMode == PUBLISH_FRAMES;
     629             : 
     630           2 :     maDocFileName = maIndex;
     631           1 : }
     632             : 
     633           1 : void HtmlExport::ExportSingleDocument()
     634             : {
     635           1 :     SdrOutliner* pOutliner = mpDoc->GetInternalOutliner();
     636             : 
     637           1 :     maPageNames.resize(mnSdPageCount);
     638             : 
     639           1 :     mnPagesWritten = 0;
     640           1 :     InitProgress(mnSdPageCount);
     641             : 
     642           1 :     OUStringBuffer aStr(maHTMLHeader);
     643           1 :     aStr.append(DocumentMetadata());
     644           1 :     aStr.append("\r\n");
     645           1 :     aStr.append("</head>\r\n");
     646           1 :     aStr.append(CreateBodyTag());
     647             : 
     648           5 :     for(sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; ++nSdPage)
     649             :     {
     650           4 :         SdPage* pPage = maPages[nSdPage];
     651           4 :         maPageNames[nSdPage] = pPage->GetName();
     652             : 
     653           4 :         if( mbDocColors )
     654             :         {
     655           0 :             SetDocColors( pPage );
     656             :         }
     657             : 
     658             :         // page title
     659           4 :         OUString sTitleText(CreateTextForTitle(pOutliner, pPage, pPage->GetPageBackgroundColor()));
     660           8 :         OUString sStyle;
     661             : 
     662           4 :         if (nSdPage != 0) // First page - no need for a page brake here
     663           3 :             sStyle += "page-break-before:always; ";
     664           4 :         sStyle += getParagraphStyle(pOutliner, 0);
     665             : 
     666           4 :         lclAppendStyle(aStr, "h1", sStyle);
     667             : 
     668           4 :         aStr.append(sTitleText);
     669           4 :         aStr.append("</h1>\r\n");
     670             : 
     671             :         // write outline text
     672           4 :         aStr.append(CreateTextForPage( pOutliner, pPage, true, pPage->GetPageBackgroundColor() ));
     673             : 
     674             :         // notes
     675           4 :         if(mbNotes)
     676             :         {
     677           0 :             SdPage* pNotesPage = maNotesPages[ nSdPage ];
     678           0 :             OUString aNotesStr( CreateTextForNotesPage( pOutliner, pNotesPage, true, maBackColor) );
     679             : 
     680           0 :             if (!aNotesStr.isEmpty())
     681             :             {
     682           0 :                 aStr.append("<br>\r\n<h3>");
     683           0 :                 aStr.append(RESTOHTML(STR_HTMLEXP_NOTES));
     684           0 :                 aStr.append(":</h3>\r\n");
     685             : 
     686           0 :                 aStr.append(aNotesStr);
     687           0 :             }
     688             :         }
     689             : 
     690           4 :         if (mpProgress)
     691           4 :             mpProgress->SetState(++mnPagesWritten);
     692             : 
     693           4 :     }
     694             : 
     695             :     // close page
     696           1 :     aStr.append("</body>\r\n</html>");
     697             : 
     698           1 :     WriteHtml(maDocFileName, false, aStr.makeStringAndClear());
     699             : 
     700           1 :     pOutliner->Clear();
     701           1 :     ResetProgress();
     702           1 : }
     703             : 
     704             : // exports the (in the c'tor specified impress document) to html
     705           0 : void HtmlExport::ExportHtml()
     706             : {
     707           0 :     if(mbUserAttr)
     708             :     {
     709           0 :         if( maTextColor == COL_AUTO )
     710             :         {
     711           0 :             if( !maBackColor.IsDark() )
     712           0 :                 maTextColor = COL_BLACK;
     713             :         }
     714             :     }
     715           0 :     else if( mbDocColors )
     716             :     {
     717             :         // default colors for the color schema 'From Document'
     718           0 :         SetDocColors();
     719           0 :         maFirstPageColor = maBackColor;
     720             :     }
     721             : 
     722             :     // get name for downloadable presentation if needed
     723           0 :     if( mbDownload )
     724             :     {
     725             :         // fade out separator search and extension
     726           0 :         sal_Int32 nSepPos = maDocFileName.indexOf('.');
     727           0 :         if (nSepPos != -1)
     728           0 :             maDocFileName = maDocFileName.copy(0, nSepPos);
     729             : 
     730           0 :         maDocFileName += ".odp";
     731             :     }
     732             : 
     733           0 :     sal_uInt16 nProgrCount = mnSdPageCount;
     734           0 :     nProgrCount += mbImpress?mnSdPageCount:0;
     735           0 :     nProgrCount += mbContentsPage?1:0;
     736           0 :     nProgrCount += (mbFrames && mbNotes)?mnSdPageCount:0;
     737           0 :     nProgrCount += (mbFrames)?8:0;
     738           0 :     InitProgress( nProgrCount );
     739             : 
     740           0 :     mpDocSh->SetWaitCursor( true );
     741             : 
     742             :     // Exceptions are cool...
     743             : 
     744           0 :     CreateFileNames();
     745             : 
     746             :     // this is not a true while
     747             :     while( true )
     748             :     {
     749           0 :         if( checkForExistingFiles() )
     750           0 :             break;
     751             : 
     752           0 :         if( !CreateImagesForPresPages() )
     753           0 :             break;
     754             : 
     755           0 :         if( mbContentsPage &&
     756           0 :            !CreateImagesForPresPages( true ) )
     757           0 :             break;
     758             : 
     759           0 :         if( !CreateHtmlForPresPages() )
     760           0 :             break;
     761             : 
     762           0 :         if( mbImpress )
     763           0 :             if( !CreateHtmlTextForPresPages() )
     764           0 :                 break;
     765             : 
     766           0 :         if( mbFrames )
     767             :         {
     768           0 :             if( !CreateFrames() )
     769           0 :                 break;
     770             : 
     771           0 :             if( !CreateOutlinePages() )
     772           0 :                 break;
     773             : 
     774           0 :             if( !CreateNavBarFrames() )
     775           0 :                 break;
     776             : 
     777           0 :             if( mbNotes && mbImpress )
     778           0 :                 if( !CreateNotesPages() )
     779           0 :                     break;
     780             : 
     781             :         }
     782             : 
     783           0 :         if( mbContentsPage )
     784           0 :             if( !CreateContentPage() )
     785           0 :                 break;
     786             : 
     787           0 :         if( !CreateBitmaps() )
     788           0 :             break;
     789             : 
     790           0 :         mpDocSh->SetWaitCursor( false );
     791           0 :         ResetProgress();
     792             : 
     793           0 :         if( mbDownload )
     794           0 :             SavePresentation();
     795             : 
     796           0 :         return;
     797             :     }
     798             : 
     799             :     // if we get to this point the export was
     800             :     // canceled by the user after an error
     801           0 :     mpDocSh->SetWaitCursor( false );
     802           0 :     ResetProgress();
     803             : }
     804             : 
     805           0 : void HtmlExport::SetDocColors( SdPage* pPage )
     806             : {
     807           0 :     if( pPage == NULL )
     808           0 :         pPage = mpDoc->GetSdPage(0, PK_STANDARD);
     809             : 
     810           0 :     svtools::ColorConfig aConfig;
     811           0 :     maVLinkColor = Color(aConfig.GetColorValue(svtools::LINKSVISITED).nColor);
     812           0 :     maALinkColor = Color(aConfig.GetColorValue(svtools::LINKS).nColor);
     813           0 :     maLinkColor  = Color(aConfig.GetColorValue(svtools::LINKS).nColor);
     814           0 :     maTextColor  = Color(COL_BLACK);
     815             : 
     816           0 :     SfxStyleSheet* pSheet = NULL;
     817             : 
     818           0 :     if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
     819             :     {
     820             :         // default text color from the outline template of the first page
     821           0 :         pSheet = pPage->GetStyleSheetForPresObj(PRESOBJ_OUTLINE);
     822           0 :         if(pSheet == NULL)
     823           0 :             pSheet = pPage->GetStyleSheetForPresObj(PRESOBJ_TEXT);
     824           0 :         if(pSheet == NULL)
     825           0 :             pSheet = pPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
     826             :     }
     827             : 
     828           0 :     if(pSheet == NULL)
     829           0 :         pSheet = mpDoc->GetDefaultStyleSheet();
     830             : 
     831           0 :     if(pSheet)
     832             :     {
     833           0 :         SfxItemSet& rSet = pSheet->GetItemSet();
     834           0 :         if(rSet.GetItemState(EE_CHAR_COLOR,true) == SfxItemState::SET)
     835           0 :             maTextColor = static_cast<const SvxColorItem*>(rSet.GetItem(EE_CHAR_COLOR,true))->GetValue();
     836             :     }
     837             : 
     838             :     // default background from the background of the master page of the first page
     839           0 :     maBackColor = pPage->GetPageBackgroundColor();
     840             : 
     841           0 :     if( maTextColor == COL_AUTO )
     842             :     {
     843           0 :         if( !maBackColor.IsDark() )
     844           0 :             maTextColor = COL_BLACK;
     845           0 :     }
     846           0 : }
     847             : 
     848           1 : void HtmlExport::InitProgress( sal_uInt16 nProgrCount )
     849             : {
     850           1 :     mpProgress = new SfxProgress( mpDocSh, SD_RESSTR(STR_CREATE_PAGES), nProgrCount );
     851           1 : }
     852             : 
     853           1 : void HtmlExport::ResetProgress()
     854             : {
     855           1 :     delete mpProgress;
     856           1 :     mpProgress = NULL;
     857           1 : }
     858             : 
     859           0 : void HtmlExport::ExportKiosk()
     860             : {
     861           0 :     mnPagesWritten = 0;
     862           0 :     InitProgress( 2*mnSdPageCount );
     863             : 
     864           0 :     CreateFileNames();
     865           0 :     if( !checkForExistingFiles() )
     866             :     {
     867           0 :         if( CreateImagesForPresPages() )
     868           0 :             CreateHtmlForPresPages();
     869             :     }
     870             : 
     871           0 :     ResetProgress();
     872           0 : }
     873             : 
     874             : // Export Document with WebCast (TM) Technology
     875           0 : void HtmlExport::ExportWebCast()
     876             : {
     877           0 :     mnPagesWritten = 0;
     878           0 :     InitProgress( mnSdPageCount + 9 );
     879             : 
     880           0 :     mpDocSh->SetWaitCursor( true );
     881             : 
     882           0 :     CreateFileNames();
     883             : 
     884           0 :     if (maCGIPath.isEmpty())
     885           0 :         maCGIPath = ".";
     886             : 
     887           0 :     if (!maCGIPath.endsWith("/"))
     888           0 :         maCGIPath += "/";
     889             : 
     890           0 :     if( meScript == SCRIPT_ASP )
     891             :     {
     892           0 :         maURLPath = "./";
     893             :     }
     894             :     else
     895             :     {
     896           0 :         if (maURLPath.isEmpty())
     897           0 :             maURLPath = ".";
     898             : 
     899           0 :         if (!maURLPath.endsWith("/"))
     900           0 :             maURLPath += "/";
     901             :     }
     902             : 
     903             :     // this is not a true while
     904             :     while(true)
     905             :     {
     906           0 :         if( checkForExistingFiles() )
     907           0 :             break;
     908             : 
     909           0 :         if(!CreateImagesForPresPages())
     910           0 :             break;
     911             : 
     912           0 :         if( meScript == SCRIPT_ASP )
     913             :         {
     914           0 :             if(!CreateASPScripts())
     915           0 :                 break;
     916             :         }
     917             :         else
     918             :         {
     919           0 :             if(!CreatePERLScripts())
     920           0 :                 break;
     921             :         }
     922             : 
     923           0 :         if(!CreateImageFileList())
     924           0 :             break;
     925             : 
     926           0 :         if(!CreateImageNumberFile())
     927           0 :             break;
     928             : 
     929           0 :         break;
     930             :     }
     931             : 
     932           0 :     mpDocSh->SetWaitCursor( false );
     933           0 :     ResetProgress();
     934           0 : }
     935             : 
     936             : // Save the presentation as a downloadable file in the dest directory
     937           0 : bool HtmlExport::SavePresentation()
     938             : {
     939           0 :     meEC.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE, maDocFileName );
     940             : 
     941           0 :     OUString aURL(maExportPath + maDocFileName);
     942             : 
     943           0 :     mpDocSh->EnableSetModified( true );
     944             : 
     945             :     try
     946             :     {
     947           0 :         uno::Reference< frame::XStorable > xStorable( mpDoc->getUnoModel(), uno::UNO_QUERY );
     948           0 :         if( xStorable.is() )
     949             :         {
     950           0 :             uno::Sequence< beans::PropertyValue > aProperties( 2 );
     951           0 :             aProperties[ 0 ].Name = "Overwrite";
     952           0 :             aProperties[ 0 ].Value <<= true;
     953           0 :             aProperties[ 1 ].Name = "FilterName";
     954           0 :             aProperties[ 1 ].Value <<= OUString("impress8");
     955           0 :             xStorable->storeToURL( aURL, aProperties );
     956             : 
     957           0 :             mpDocSh->EnableSetModified( false );
     958             : 
     959           0 :             return true;
     960           0 :         }
     961             :     }
     962           0 :     catch( Exception& )
     963             :     {
     964             :     }
     965             : 
     966           0 :     mpDocSh->EnableSetModified( false );
     967             : 
     968           0 :     return false;
     969             : }
     970             : 
     971             : // create image files
     972           0 : bool HtmlExport::CreateImagesForPresPages( bool bThumbnail)
     973             : {
     974             :     try
     975             :     {
     976           0 :         Reference < XComponentContext > xContext = ::comphelper::getProcessComponentContext();
     977             : 
     978           0 :         Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create( xContext );
     979             : 
     980           0 :         Sequence< PropertyValue > aFilterData(((meFormat==FORMAT_JPG)&&(mnCompression != -1))? 3 : 2);
     981           0 :         aFilterData[0].Name = "PixelWidth";
     982           0 :         aFilterData[0].Value <<= (sal_Int32)(bThumbnail ? PUB_THUMBNAIL_WIDTH : mnWidthPixel );
     983           0 :         aFilterData[1].Name = "PixelHeight";
     984           0 :         aFilterData[1].Value <<= (sal_Int32)(bThumbnail ? PUB_THUMBNAIL_HEIGHT : mnHeightPixel);
     985           0 :         if((meFormat==FORMAT_JPG)&&(mnCompression != -1))
     986             :         {
     987           0 :             aFilterData[2].Name = "Quality";
     988           0 :             aFilterData[2].Value <<= (sal_Int32)mnCompression;
     989             :         }
     990             : 
     991           0 :         Sequence< PropertyValue > aDescriptor( 3 );
     992           0 :         aDescriptor[0].Name = "URL";
     993           0 :         aDescriptor[1].Name = "FilterName";
     994           0 :         OUString sFormat;
     995           0 :         if( meFormat == FORMAT_PNG )
     996           0 :             sFormat = "PNG";
     997           0 :         else if( meFormat == FORMAT_GIF )
     998           0 :             sFormat = "GIF";
     999             :         else
    1000           0 :             sFormat = "JPG";
    1001             : 
    1002           0 :         aDescriptor[1].Value <<= sFormat;
    1003           0 :         aDescriptor[2].Name = "FilterData";
    1004           0 :         aDescriptor[2].Value <<= aFilterData;
    1005             : 
    1006           0 :         for (sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; nSdPage++)
    1007             :         {
    1008           0 :             SdPage* pPage = maPages[ nSdPage ];
    1009             : 
    1010           0 :             OUString aFull(maExportPath);
    1011           0 :             if (bThumbnail)
    1012           0 :                 aFull += maThumbnailFiles[nSdPage];
    1013             :             else
    1014           0 :                 aFull += maImageFiles[nSdPage];
    1015             : 
    1016           0 :             aDescriptor[0].Value <<= aFull;
    1017             : 
    1018           0 :             Reference< XComponent > xPage( pPage->getUnoPage(), UNO_QUERY );
    1019           0 :             xGraphicExporter->setSourceDocument( xPage );
    1020           0 :             xGraphicExporter->filter( aDescriptor );
    1021             : 
    1022           0 :             if (mpProgress)
    1023           0 :                 mpProgress->SetState(++mnPagesWritten);
    1024           0 :         }
    1025             :     }
    1026           0 :     catch( Exception& )
    1027             :     {
    1028           0 :         return false;
    1029             :     }
    1030             : 
    1031           0 :     return true;
    1032             : }
    1033             : 
    1034             : // get SdrTextObject with layout text of this page
    1035           0 : SdrTextObj* HtmlExport::GetLayoutTextObject(SdrPage* pPage)
    1036             : {
    1037           0 :     const size_t nObjectCount = pPage->GetObjCount();
    1038           0 :     SdrTextObj*     pResult      = NULL;
    1039             : 
    1040           0 :     for (size_t nObject = 0; nObject < nObjectCount; ++nObject)
    1041             :     {
    1042           0 :         SdrObject* pObject = pPage->GetObj(nObject);
    1043           0 :         if (pObject->GetObjInventor() == SdrInventor &&
    1044           0 :             pObject->GetObjIdentifier() == OBJ_OUTLINETEXT)
    1045             :         {
    1046           0 :             pResult = static_cast<SdrTextObj*>(pObject);
    1047           0 :             break;
    1048             :         }
    1049             :     }
    1050           0 :     return pResult;
    1051             : }
    1052             : 
    1053             : // create HTML text version of impress pages
    1054           0 : OUString HtmlExport::CreateMetaCharset()
    1055             : {
    1056           0 :     OUString aStr;
    1057           0 :     const sal_Char *pCharSet = rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8 );
    1058           0 :     if ( pCharSet )
    1059             :     {
    1060           0 :         aStr = "  <meta HTTP-EQUIV=CONTENT-TYPE CONTENT=\"text/html; charset=" +
    1061           0 :                OUString::createFromAscii(pCharSet) + "\">\r\n";
    1062             :     }
    1063           0 :     return aStr;
    1064             : }
    1065             : 
    1066           1 : OUString HtmlExport::DocumentMetadata() const
    1067             : {
    1068           1 :     SvMemoryStream aStream;
    1069             : 
    1070           2 :     uno::Reference<document::XDocumentProperties> xDocProps;
    1071           1 :     if (mpDocSh)
    1072             :     {
    1073             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
    1074           1 :             mpDocSh->GetModel(), uno::UNO_QUERY_THROW);
    1075           1 :         xDocProps.set(xDPS->getDocumentProperties());
    1076             :     }
    1077             : 
    1078           2 :     OUString aNonConvertableCharacters;
    1079             : 
    1080             :     SfxFrameHTMLWriter::Out_DocInfo(aStream, maDocFileName, xDocProps,
    1081             :             "  ", RTL_TEXTENCODING_UTF8,
    1082           1 :             &aNonConvertableCharacters);
    1083             : 
    1084           2 :     OString aData(static_cast<const char*>(aStream.GetData()), aStream.GetSize());
    1085             : 
    1086           2 :     return OStringToOUString(aData, RTL_TEXTENCODING_UTF8);
    1087             : }
    1088             : 
    1089           0 : bool HtmlExport::CreateHtmlTextForPresPages()
    1090             : {
    1091           0 :     bool bOk = true;
    1092             : 
    1093           0 :     SdrOutliner* pOutliner = mpDoc->GetInternalOutliner();
    1094             : 
    1095           0 :     for(sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount && bOk; nSdPage++)
    1096             :     {
    1097           0 :         SdPage* pPage = maPages[ nSdPage ];
    1098             : 
    1099           0 :         if( mbDocColors )
    1100             :         {
    1101           0 :             SetDocColors( pPage );
    1102             :         }
    1103             : 
    1104             :         // HTML head
    1105           0 :         OUStringBuffer aStr(maHTMLHeader);
    1106           0 :         aStr.append(CreateMetaCharset());
    1107           0 :         aStr.append("  <title>");
    1108           0 :         aStr.append(StringToHTMLString(maPageNames[nSdPage]));
    1109           0 :         aStr.append("</title>\r\n");
    1110           0 :         aStr.append("</head>\r\n");
    1111           0 :         aStr.append(CreateBodyTag());
    1112             : 
    1113             :         // navigation bar
    1114           0 :         aStr.append(CreateNavBar(nSdPage, true));
    1115             : 
    1116             :         // page title
    1117           0 :         OUString sTitleText( CreateTextForTitle(pOutliner,pPage, pPage->GetPageBackgroundColor()) );
    1118           0 :         lclAppendStyle(aStr, "h1", getParagraphStyle(pOutliner, 0));
    1119           0 :         aStr.append(sTitleText);
    1120           0 :         aStr.append("</h1>\r\n");
    1121             : 
    1122             :         // write outline text
    1123           0 :         aStr.append(CreateTextForPage( pOutliner, pPage, true, pPage->GetPageBackgroundColor() ));
    1124             : 
    1125             :         // notes
    1126           0 :         if(mbNotes)
    1127             :         {
    1128           0 :             SdPage* pNotesPage = maNotesPages[ nSdPage ];
    1129           0 :             OUString aNotesStr( CreateTextForNotesPage( pOutliner, pNotesPage, true, maBackColor) );
    1130             : 
    1131           0 :             if (!aNotesStr.isEmpty())
    1132             :             {
    1133           0 :                 aStr.append("<br>\r\n<h3>");
    1134           0 :                 aStr.append(RESTOHTML(STR_HTMLEXP_NOTES));
    1135           0 :                 aStr.append(":</h3>\r\n");
    1136             : 
    1137           0 :                 aStr.append(aNotesStr);
    1138           0 :             }
    1139             :         }
    1140             : 
    1141             :         // close page
    1142           0 :         aStr.append("</body>\r\n</html>");
    1143             : 
    1144           0 :         bOk = WriteHtml(maTextFiles[nSdPage], false, aStr.makeStringAndClear());
    1145             : 
    1146           0 :         if (mpProgress)
    1147           0 :             mpProgress->SetState(++mnPagesWritten);
    1148             : 
    1149           0 :     }
    1150             : 
    1151           0 :     pOutliner->Clear();
    1152             : 
    1153           0 :     return bOk;
    1154             : }
    1155             : 
    1156             : /** exports the given html data into a non unicode file in the current export path with
    1157             :     the given filename */
    1158           1 : bool HtmlExport::WriteHtml( const OUString& rFileName, bool bAddExtension, const OUString& rHtmlData )
    1159             : {
    1160           1 :     sal_uLong nErr = 0;
    1161             : 
    1162           1 :     OUString aFileName( rFileName );
    1163           1 :     if( bAddExtension )
    1164           0 :         aFileName += maHTMLExtension;
    1165             : 
    1166           1 :     meEC.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE, rFileName );
    1167           2 :     EasyFile aFile;
    1168             :     SvStream* pStr;
    1169           2 :     OUString aFull(maExportPath + aFileName);
    1170           1 :     nErr = aFile.createStream(aFull , pStr);
    1171           1 :     if(nErr == 0)
    1172             :     {
    1173             :         OString aStr(OUStringToOString(rHtmlData,
    1174           1 :             RTL_TEXTENCODING_UTF8));
    1175           1 :         pStr->WriteCharPtr( aStr.getStr() );
    1176           1 :         nErr = aFile.close();
    1177             :     }
    1178             : 
    1179           1 :     if( nErr != 0 )
    1180           0 :         ErrorHandler::HandleError(nErr);
    1181             : 
    1182           2 :     return nErr == 0;
    1183             : }
    1184             : 
    1185             : /** creates a outliner text for the title objects of a page
    1186             :  */
    1187           4 : OUString HtmlExport::CreateTextForTitle( SdrOutliner* pOutliner, SdPage* pPage, const Color& rBackgroundColor )
    1188             : {
    1189           4 :     SdrTextObj* pTO = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TITLE));
    1190           4 :     if(!pTO)
    1191           0 :         pTO = GetLayoutTextObject(pPage);
    1192             : 
    1193           4 :     if (pTO && !pTO->IsEmptyPresObj())
    1194             :     {
    1195           4 :         OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
    1196           4 :         if(pOPO && pOutliner->GetParagraphCount() != 0)
    1197             :         {
    1198           4 :             pOutliner->Clear();
    1199           4 :             pOutliner->SetText(*pOPO);
    1200           4 :             return ParagraphToHTMLString(pOutliner,0, rBackgroundColor);
    1201             :         }
    1202             :     }
    1203             : 
    1204           0 :     return OUString();
    1205             : }
    1206             : 
    1207             : // creates a outliner text for a page
    1208           4 : OUString HtmlExport::CreateTextForPage(SdrOutliner* pOutliner, SdPage* pPage,
    1209             :                                        bool bHeadLine, const Color& rBackgroundColor)
    1210             : {
    1211           4 :     OUStringBuffer aStr;
    1212             : 
    1213          12 :     for (size_t i = 0; i <pPage->GetObjCount(); ++i )
    1214             :     {
    1215           8 :         SdrObject* pObject = pPage->GetObj(i);
    1216           8 :         PresObjKind eKind = pPage->GetPresObjKind(pObject);
    1217             : 
    1218           8 :         switch (eKind)
    1219             :         {
    1220             :             case PRESOBJ_NONE:
    1221             :             {
    1222           0 :                 if (pObject->GetObjIdentifier() == OBJ_GRUP)
    1223             :                 {
    1224           0 :                     SdrObjGroup* pObjectGroup = static_cast<SdrObjGroup*>(pObject);
    1225           0 :                     WriteObjectGroup(aStr, pObjectGroup, pOutliner, rBackgroundColor, false);
    1226             :                 }
    1227           0 :                 else if (pObject->GetObjIdentifier() == OBJ_TABLE)
    1228             :                 {
    1229           0 :                     SdrTableObj* pTableObject = static_cast<SdrTableObj*>(pObject);
    1230           0 :                     WriteTable(aStr, pTableObject, pOutliner, rBackgroundColor);
    1231             :                 }
    1232             :                 else
    1233             :                 {
    1234           0 :                     if (pObject->GetOutlinerParaObject())
    1235             :                     {
    1236           0 :                         WriteOutlinerParagraph(aStr, pOutliner, pObject->GetOutlinerParaObject(), rBackgroundColor, false);
    1237             :                     }
    1238             :                 }
    1239             :             }
    1240           0 :             break;
    1241             : 
    1242             :             case PRESOBJ_TABLE:
    1243             :             {
    1244           1 :                 SdrTableObj* pTableObject = static_cast<SdrTableObj*>(pObject);
    1245           1 :                 WriteTable(aStr, pTableObject, pOutliner, rBackgroundColor);
    1246             :             }
    1247           1 :             break;
    1248             : 
    1249             :             case PRESOBJ_TEXT:
    1250             :             case PRESOBJ_OUTLINE:
    1251             :             {
    1252           2 :                 SdrTextObj* pTextObject = static_cast<SdrTextObj*>(pObject);
    1253           2 :                 if (pTextObject->IsEmptyPresObj())
    1254           0 :                     continue;
    1255           2 :                 WriteOutlinerParagraph(aStr, pOutliner, pTextObject->GetOutlinerParaObject(), rBackgroundColor, bHeadLine);
    1256             :             }
    1257           2 :             break;
    1258             : 
    1259             :             default:
    1260           5 :                 break;
    1261             :         }
    1262             :     }
    1263           4 :     return aStr.makeStringAndClear();
    1264             : }
    1265             : 
    1266           1 : void HtmlExport::WriteTable(OUStringBuffer& aStr, SdrTableObj* pTableObject, SdrOutliner* pOutliner, const Color& rBackgroundColor)
    1267             : {
    1268           1 :     CellPos aStart, aEnd;
    1269             : 
    1270           1 :     aStart = SdrTableObj::getFirstCell();
    1271           1 :     aEnd = pTableObject->getLastCell();
    1272             : 
    1273           1 :     sal_Int32 nColCount = pTableObject->getColumnCount();
    1274           1 :     aStr.append("<table>\r\n");
    1275           6 :     for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
    1276             :     {
    1277           5 :         aStr.append("  <tr>\r\n");
    1278          15 :         for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
    1279             :         {
    1280          10 :             aStr.append("    <td>\r\n");
    1281          10 :             sal_Int32 nCellIndex = nRow * nColCount + nCol;
    1282          10 :             SdrText* pText = pTableObject->getText(nCellIndex);
    1283             : 
    1284          10 :             if (pText == NULL)
    1285           0 :                 continue;
    1286          10 :             WriteOutlinerParagraph(aStr, pOutliner, pText->GetOutlinerParaObject(), rBackgroundColor, false);
    1287          10 :             aStr.append("    </td>\r\n");
    1288             :         }
    1289           5 :         aStr.append("  </tr>\r\n");
    1290             :     }
    1291           1 :     aStr.append("</table>\r\n");
    1292           1 : }
    1293             : 
    1294           0 : void HtmlExport::WriteObjectGroup(OUStringBuffer& aStr, SdrObjGroup* pObjectGroup, SdrOutliner* pOutliner,
    1295             :                                   const Color& rBackgroundColor, bool bHeadLine)
    1296             : {
    1297           0 :     SdrObjListIter aGroupIterator(*pObjectGroup->GetSubList(), IM_DEEPNOGROUPS);
    1298           0 :     while (aGroupIterator.IsMore())
    1299             :     {
    1300           0 :         SdrObject* pCurrentObject = aGroupIterator.Next();
    1301           0 :         if (pCurrentObject->GetObjIdentifier() == OBJ_GRUP)
    1302             :         {
    1303           0 :             SdrObjGroup* pCurrentGroupObject = static_cast<SdrObjGroup*>(pCurrentObject);
    1304           0 :             WriteObjectGroup(aStr, pCurrentGroupObject, pOutliner, rBackgroundColor, bHeadLine);
    1305             :         }
    1306             :         else
    1307             :         {
    1308           0 :             OutlinerParaObject* pOutlinerParagraphObject = pCurrentObject->GetOutlinerParaObject();
    1309           0 :             if (pOutlinerParagraphObject != NULL)
    1310             :             {
    1311           0 :                 WriteOutlinerParagraph(aStr, pOutliner, pOutlinerParagraphObject, rBackgroundColor, bHeadLine);
    1312             :             }
    1313             :         }
    1314           0 :     }
    1315           0 : }
    1316             : 
    1317          12 : void HtmlExport::WriteOutlinerParagraph(OUStringBuffer& aStr, SdrOutliner* pOutliner,
    1318             :                                         OutlinerParaObject* pOutlinerParagraphObject,
    1319             :                                         const Color& rBackgroundColor, bool bHeadLine)
    1320             : {
    1321          12 :     if (pOutlinerParagraphObject == NULL)
    1322          12 :         return;
    1323             : 
    1324          12 :     pOutliner->SetText(*pOutlinerParagraphObject);
    1325             : 
    1326          12 :     sal_Int32 nCount = pOutliner->GetParagraphCount();
    1327             : 
    1328             : 
    1329          12 :     sal_Int16 nCurrentDepth = -1;
    1330             : 
    1331          34 :     for (sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
    1332             :     {
    1333          22 :         Paragraph* pParagraph = pOutliner->GetParagraph(nIndex);
    1334          22 :         if(pParagraph == NULL)
    1335           1 :             continue;
    1336             : 
    1337          22 :         const sal_Int16 nDepth = (sal_uInt16) pOutliner->GetDepth(nIndex);
    1338          22 :         OUString aParaText = ParagraphToHTMLString(pOutliner, nIndex, rBackgroundColor);
    1339             : 
    1340          22 :         if (aParaText.isEmpty())
    1341           1 :             continue;
    1342             : 
    1343          21 :         if (nDepth < 0)
    1344             :         {
    1345           7 :             OUString aTag = bHeadLine ? OUString("h2") : OUString("p");
    1346           7 :             lclAppendStyle(aStr, aTag, getParagraphStyle(pOutliner, nIndex));
    1347             : 
    1348           7 :             aStr.append(aParaText);
    1349           7 :             aStr.append("</" + aTag + ">\r\n");
    1350             :         }
    1351             :         else
    1352             :         {
    1353          35 :             while(nCurrentDepth < nDepth)
    1354             :             {
    1355           7 :                 aStr.append("<ul>\r\n");
    1356           7 :                 nCurrentDepth++;
    1357             :             }
    1358          30 :             while(nCurrentDepth > nDepth)
    1359             :             {
    1360           2 :                 aStr.append("</ul>\r\n");
    1361           2 :                 nCurrentDepth--;
    1362             :             }
    1363          14 :             lclAppendStyle(aStr, "li", getParagraphStyle(pOutliner, nIndex));
    1364          14 :             aStr.append(aParaText);
    1365          14 :             aStr.append("</li>\r\n");
    1366             :         }
    1367          21 :     }
    1368          29 :     while(nCurrentDepth >= 0)
    1369             :     {
    1370           5 :         aStr.append("</ul>\r\n");
    1371           5 :         nCurrentDepth--;
    1372             :     }
    1373          12 :     pOutliner->Clear();
    1374             : }
    1375             : 
    1376             : // creates a outliner text for a note page
    1377           0 : OUString HtmlExport::CreateTextForNotesPage( SdrOutliner* pOutliner,
    1378             :                                            SdPage* pPage,
    1379             :                                            bool,
    1380             :                                            const Color& rBackgroundColor )
    1381             : {
    1382           0 :     OUStringBuffer aStr;
    1383             : 
    1384           0 :     SdrTextObj* pTO = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_NOTES));
    1385             : 
    1386           0 :     if (pTO && !pTO->IsEmptyPresObj())
    1387             :     {
    1388           0 :         OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
    1389           0 :         if (pOPO)
    1390             :         {
    1391           0 :             pOutliner->Clear();
    1392           0 :             pOutliner->SetText( *pOPO );
    1393             : 
    1394           0 :             sal_Int32 nCount = pOutliner->GetParagraphCount();
    1395           0 :             for (sal_Int32 nPara = 0; nPara < nCount; nPara++)
    1396             :             {
    1397           0 :                 lclAppendStyle(aStr, "p", getParagraphStyle(pOutliner, nPara));
    1398           0 :                 aStr.append(ParagraphToHTMLString(pOutliner, nPara, rBackgroundColor));
    1399           0 :                 aStr.append("</p>\r\n");
    1400             :             }
    1401             :         }
    1402             :     }
    1403             : 
    1404           0 :     return aStr.makeStringAndClear();
    1405             : }
    1406             : 
    1407             : // converts a paragraph of the outliner to html
    1408          26 : OUString HtmlExport::ParagraphToHTMLString( SdrOutliner* pOutliner, sal_Int32 nPara, const Color& rBackgroundColor )
    1409             : {
    1410          26 :     OUStringBuffer aStr;
    1411             : 
    1412          26 :     if(NULL == pOutliner)
    1413           0 :         return OUString();
    1414             : 
    1415             :     // TODO: MALTE!!!
    1416          26 :     EditEngine& rEditEngine = *const_cast<EditEngine*>(&pOutliner->GetEditEngine());
    1417          26 :     bool bOldUpdateMode = rEditEngine.GetUpdateMode();
    1418          26 :     rEditEngine.SetUpdateMode(true);
    1419             : 
    1420          26 :     Paragraph* pPara = pOutliner->GetParagraph(nPara);
    1421          26 :     if(NULL == pPara)
    1422           0 :         return OUString();
    1423             : 
    1424          52 :     HtmlState aState( (mbUserAttr || mbDocColors)  ? maTextColor : Color(COL_BLACK) );
    1425          52 :     std::vector<sal_Int32> aPortionList;
    1426          26 :     rEditEngine.GetPortions( nPara, aPortionList );
    1427             : 
    1428          26 :     sal_Int32 nPos1 = 0;
    1429          52 :     for( std::vector<sal_Int32>::const_iterator it( aPortionList.begin() ); it != aPortionList.end(); ++it )
    1430             :     {
    1431          26 :         sal_Int32 nPos2 = *it;
    1432             : 
    1433          26 :         ESelection aSelection( nPara, nPos1, nPara, nPos2);
    1434             : 
    1435          26 :         SfxItemSet aSet( rEditEngine.GetAttribs( aSelection ) );
    1436             : 
    1437          52 :         OUString aPortion(StringToHTMLString(rEditEngine.GetText( aSelection )));
    1438             : 
    1439          26 :         aStr.append(TextAttribToHTMLString( &aSet, &aState, rBackgroundColor ));
    1440          26 :         aStr.append(aPortion);
    1441             : 
    1442          26 :         nPos1 = nPos2;
    1443          26 :     }
    1444          26 :     aStr.append(aState.Flush());
    1445          26 :     rEditEngine.SetUpdateMode(bOldUpdateMode);
    1446             : 
    1447          52 :     return aStr.makeStringAndClear();
    1448             : }
    1449             : 
    1450             : // Depending on the attributes of the specified set and the specified
    1451             : // HtmlState, it creates the needed html tags in order to get the
    1452             : // attributes
    1453          26 : OUString HtmlExport::TextAttribToHTMLString( SfxItemSet* pSet, HtmlState* pState, const Color& rBackgroundColor )
    1454             : {
    1455          26 :     OUStringBuffer aStr;
    1456             : 
    1457          26 :     if(NULL == pSet)
    1458           0 :         return OUString();
    1459             : 
    1460          52 :     OUString aLink, aTarget;
    1461          26 :     if ( pSet->GetItemState( EE_FEATURE_FIELD ) == SfxItemState::SET )
    1462             :     {
    1463           0 :         const SvxFieldItem* pItem = static_cast<const SvxFieldItem*>(pSet->GetItem( EE_FEATURE_FIELD ));
    1464           0 :         if(pItem)
    1465             :         {
    1466           0 :             const SvxURLField* pURL = PTR_CAST(SvxURLField, pItem->GetField());
    1467           0 :             if(pURL)
    1468             :             {
    1469           0 :                 aLink = pURL->GetURL();
    1470           0 :                 aTarget = pURL->GetTargetFrame();
    1471             :             }
    1472             :         }
    1473             :     }
    1474             : 
    1475             :     bool bTemp;
    1476          52 :     OUString aTemp;
    1477             : 
    1478          26 :     if ( pSet->GetItemState( EE_CHAR_WEIGHT ) == SfxItemState::SET )
    1479             :     {
    1480          26 :         bTemp = static_cast<const SvxWeightItem&>(pSet->Get( EE_CHAR_WEIGHT )).GetWeight() == WEIGHT_BOLD;
    1481          26 :         aTemp = pState->SetWeight( bTemp );
    1482          26 :         if( bTemp )
    1483           0 :             aStr.insert(0, aTemp);
    1484             :         else
    1485          26 :             aStr.append(aTemp);
    1486             :     }
    1487             : 
    1488          26 :     if ( pSet->GetItemState( EE_CHAR_UNDERLINE ) == SfxItemState::SET )
    1489             :     {
    1490          26 :         bTemp = static_cast<const SvxUnderlineItem&>(pSet->Get( EE_CHAR_UNDERLINE )).GetLineStyle() != UNDERLINE_NONE;
    1491          26 :         aTemp = pState->SetUnderline( bTemp );
    1492          26 :         if( bTemp )
    1493           0 :             aStr.insert(0, aTemp);
    1494             :         else
    1495          26 :             aStr.append(aTemp);
    1496             :     }
    1497             : 
    1498          26 :     if ( pSet->GetItemState( EE_CHAR_STRIKEOUT ) == SfxItemState::SET )
    1499             :     {
    1500          26 :         bTemp = static_cast<const SvxCrossedOutItem&>(pSet->Get( EE_CHAR_STRIKEOUT )).GetStrikeout() != STRIKEOUT_NONE;
    1501          26 :         aTemp = pState->SetStrikeout( bTemp );
    1502          26 :         if( bTemp )
    1503           0 :             aStr.insert(0, aTemp);
    1504             :         else
    1505          26 :             aStr.append(aTemp);
    1506             :     }
    1507             : 
    1508          26 :     if ( pSet->GetItemState( EE_CHAR_ITALIC ) == SfxItemState::SET )
    1509             :     {
    1510          26 :         bTemp = static_cast<const SvxPostureItem&>(pSet->Get( EE_CHAR_ITALIC )).GetPosture() != ITALIC_NONE;
    1511          26 :         aTemp = pState->SetItalic( bTemp );
    1512          26 :         if( bTemp )
    1513           0 :             aStr.insert(0, aTemp);
    1514             :         else
    1515          26 :             aStr.append(aTemp);
    1516             :     }
    1517             : 
    1518          26 :     if(mbDocColors)
    1519             :     {
    1520           0 :         if ( pSet->GetItemState( EE_CHAR_COLOR ) == SfxItemState::SET )
    1521             :         {
    1522           0 :             Color aTextColor = static_cast<const SvxColorItem&>(pSet->Get( EE_CHAR_COLOR )).GetValue();
    1523           0 :             if( aTextColor == COL_AUTO )
    1524             :             {
    1525           0 :                 if( !rBackgroundColor.IsDark() )
    1526           0 :                     aTextColor = COL_BLACK;
    1527             :             }
    1528           0 :             aStr.append(pState->SetColor( aTextColor ));
    1529             :         }
    1530             :     }
    1531             : 
    1532          26 :     if (!aLink.isEmpty())
    1533           0 :         aStr.insert(0, pState->SetLink(aLink, aTarget));
    1534             :     else
    1535          26 :         aStr.append(pState->SetLink(aLink, aTarget));
    1536             : 
    1537          52 :     return aStr.makeStringAndClear();
    1538             : }
    1539             : 
    1540             : // create HTML wrapper for picture files
    1541           0 : bool HtmlExport::CreateHtmlForPresPages()
    1542             : {
    1543           0 :     bool bOk = true;
    1544             : 
    1545           0 :     std::vector<SdrObject*> aClickableObjects;
    1546             : 
    1547           0 :     for(sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount && bOk; nSdPage++)
    1548             :     {
    1549             :         // find clickable objects (also on the master page) and put it in the
    1550             :         // list. This in reverse order character order since in html the first
    1551             :         // area is taken in the case they overlap.
    1552           0 :         SdPage* pPage = maPages[ nSdPage ];
    1553             : 
    1554           0 :         if( mbDocColors )
    1555             :         {
    1556           0 :             SetDocColors( pPage );
    1557             :         }
    1558             : 
    1559           0 :         bool    bMasterDone = false;
    1560             : 
    1561           0 :         while (!bMasterDone)
    1562             :         {
    1563             :             // sal_True = backwards
    1564           0 :             SdrObjListIter aIter(*pPage, IM_DEEPWITHGROUPS, true);
    1565             : 
    1566           0 :             SdrObject* pObject = aIter.Next();
    1567           0 :             while (pObject)
    1568             :             {
    1569           0 :                 SdAnimationInfo* pInfo     = mpDoc->GetAnimationInfo(pObject);
    1570           0 :                 SdIMapInfo*      pIMapInfo = mpDoc->GetIMapInfo(pObject);
    1571             : 
    1572           0 :                 if ((pInfo &&
    1573           0 :                      (pInfo->meClickAction == presentation::ClickAction_BOOKMARK  ||
    1574           0 :                       pInfo->meClickAction == presentation::ClickAction_DOCUMENT  ||
    1575           0 :                       pInfo->meClickAction == presentation::ClickAction_PREVPAGE  ||
    1576           0 :                       pInfo->meClickAction == presentation::ClickAction_NEXTPAGE  ||
    1577           0 :                       pInfo->meClickAction == presentation::ClickAction_FIRSTPAGE ||
    1578           0 :                       pInfo->meClickAction == presentation::ClickAction_LASTPAGE)) ||
    1579             :                      pIMapInfo)
    1580             :                 {
    1581           0 :                     aClickableObjects.push_back(pObject);
    1582             :                 }
    1583             : 
    1584           0 :                 pObject = aIter.Next();
    1585             :             }
    1586             :             // now to the master page or finishing
    1587           0 :             if (!pPage->IsMasterPage())
    1588           0 :                 pPage = static_cast<SdPage*>(&(pPage->TRG_GetMasterPage()));
    1589             :             else
    1590           0 :                 bMasterDone = true;
    1591           0 :         }
    1592             : 
    1593             :         // HTML Head
    1594           0 :         OUStringBuffer aStr(maHTMLHeader);
    1595           0 :         aStr.append(CreateMetaCharset());
    1596           0 :         aStr.append("  <title>" + StringToHTMLString(maPageNames[nSdPage]) + "</title>\r\n");
    1597             : 
    1598             :         // insert timing information
    1599           0 :         pPage = maPages[ nSdPage ];
    1600           0 :         if( meMode == PUBLISH_KIOSK )
    1601             :         {
    1602           0 :             double fSecs = 0;
    1603           0 :             bool bEndless = false;
    1604           0 :             if( !mbAutoSlide )
    1605             :             {
    1606           0 :                 if( pPage->GetPresChange() != PRESCHANGE_MANUAL )
    1607             :                 {
    1608           0 :                     fSecs = pPage->GetTime();
    1609           0 :                     bEndless = mpDoc->getPresentationSettings().mbEndless;
    1610             :                 }
    1611             :             }
    1612             :             else
    1613             :             {
    1614           0 :                 fSecs = mfSlideDuration;
    1615           0 :                 bEndless = mbEndless;
    1616             :             }
    1617             : 
    1618           0 :             if( fSecs != 0 )
    1619             :             {
    1620           0 :                 if( nSdPage < (mnSdPageCount-1) || bEndless )
    1621             :                 {
    1622           0 :                     aStr.append("<meta http-equiv=\"refresh\" content=\"");
    1623           0 :                     aStr.append(OUString::number(fSecs));
    1624           0 :                     aStr.append("; URL=");
    1625             : 
    1626           0 :                     int nPage = nSdPage + 1;
    1627           0 :                     if( nPage == mnSdPageCount )
    1628           0 :                         nPage = 0;
    1629             : 
    1630           0 :                     aStr.append(maHTMLFiles[nPage]);
    1631             : 
    1632           0 :                     aStr.append("\">\r\n");
    1633             :                 }
    1634             :             }
    1635             :         }
    1636             : 
    1637           0 :         aStr.append("</head>\r\n");
    1638             : 
    1639             :         // HTML Body
    1640           0 :         aStr.append(CreateBodyTag());
    1641             : 
    1642           0 :         if( mbSlideSound && pPage->IsSoundOn() )
    1643           0 :             aStr.append(InsertSound(pPage->GetSoundFile()));
    1644             : 
    1645             :         // navigation bar
    1646           0 :         if(!mbFrames )
    1647           0 :             aStr.append(CreateNavBar(nSdPage, false));
    1648             :         // Image
    1649           0 :         aStr.append("<center>");
    1650           0 :         aStr.append("<img src=\"");
    1651           0 :         aStr.append(maImageFiles[nSdPage]);
    1652           0 :         aStr.append("\" alt=\"\"");
    1653             : 
    1654           0 :         if (!aClickableObjects.empty())
    1655           0 :             aStr.append(" USEMAP=\"#map0\"");
    1656             : 
    1657           0 :         aStr.append("></center>\r\n");
    1658             : 
    1659             :         // notes
    1660           0 :         if(mbNotes && !mbFrames)
    1661             :         {
    1662           0 :             SdrOutliner* pOutliner = mpDoc->GetInternalOutliner();
    1663           0 :             SdPage* pNotesPage = maNotesPages[ nSdPage ];
    1664           0 :             OUString aNotesStr( CreateTextForNotesPage( pOutliner, pNotesPage, true, maBackColor) );
    1665           0 :             pOutliner->Clear();
    1666             : 
    1667           0 :             if (!aNotesStr.isEmpty())
    1668             :             {
    1669           0 :                 aStr.append("<h3>");
    1670           0 :                 aStr.append(RESTOHTML(STR_HTMLEXP_NOTES));
    1671           0 :                 aStr.append(":</h3><br>\r\n\r\n<p>");
    1672             : 
    1673           0 :                 aStr.append(aNotesStr);
    1674           0 :                 aStr.append("\r\n</p>\r\n");
    1675           0 :             }
    1676             :         }
    1677             : 
    1678             :         // create Imagemap if necessary
    1679           0 :         if (!aClickableObjects.empty())
    1680             :         {
    1681           0 :             aStr.append("<map name=\"map0\">\r\n");
    1682             : 
    1683           0 :             for (sal_uInt32 nObject = 0, n = aClickableObjects.size(); nObject < n; nObject++)
    1684             :             {
    1685           0 :                 SdrObject* pObject = aClickableObjects[nObject];
    1686           0 :                 SdAnimationInfo* pInfo     = mpDoc->GetAnimationInfo(pObject);
    1687           0 :                 SdIMapInfo*      pIMapInfo = mpDoc->GetIMapInfo(pObject);
    1688             : 
    1689           0 :                 Rectangle aRect(pObject->GetCurrentBoundRect());
    1690           0 :                 Point     aLogPos(aRect.TopLeft());
    1691           0 :                 bool      bIsSquare = aRect.GetWidth() == aRect.GetHeight();
    1692             : 
    1693           0 :                 sal_uLong nPageWidth = pPage->GetSize().Width() - pPage->GetLftBorder() -
    1694           0 :                                    pPage->GetRgtBorder();
    1695             : 
    1696             :                 // BoundRect is relative to the physical page origin, not the
    1697             :                 // origin of ordinates
    1698           0 :                 aRect.Move(-pPage->GetLftBorder(), -pPage->GetUppBorder());
    1699             : 
    1700           0 :                 double fLogicToPixel = ((double)mnWidthPixel) / nPageWidth;
    1701           0 :                 aRect.Left()   = (long)(aRect.Left() * fLogicToPixel);
    1702           0 :                 aRect.Top()    = (long)(aRect.Top() * fLogicToPixel);
    1703           0 :                 aRect.Right()  = (long)(aRect.Right() * fLogicToPixel);
    1704           0 :                 aRect.Bottom() = (long)(aRect.Bottom() * fLogicToPixel);
    1705           0 :                 long nRadius = aRect.GetWidth() / 2;
    1706             : 
    1707             :                 /**
    1708             :                     insert areas into Imagemap of the object, if the object has
    1709             :                     such a Imagemap
    1710             :                 */
    1711           0 :                 if (pIMapInfo)
    1712             :                 {
    1713           0 :                     const ImageMap& rIMap = pIMapInfo->GetImageMap();
    1714           0 :                     sal_uInt16 nAreaCount = rIMap.GetIMapObjectCount();
    1715           0 :                     for (sal_uInt16 nArea = 0; nArea < nAreaCount; nArea++)
    1716             :                     {
    1717           0 :                         IMapObject* pArea = rIMap.GetIMapObject(nArea);
    1718           0 :                         sal_uInt16 nType = pArea->GetType();
    1719           0 :                         OUString aURL( pArea->GetURL() );
    1720             : 
    1721             :                         // if necessary, convert page and object names into the
    1722             :                         // corresponding names of the html file
    1723             :                         bool        bIsMasterPage;
    1724           0 :                         sal_uInt16  nPgNum = mpDoc->GetPageByName( aURL, bIsMasterPage );
    1725           0 :                         SdrObject*  pObj = NULL;
    1726             : 
    1727           0 :                         if (nPgNum == SDRPAGE_NOTFOUND)
    1728             :                         {
    1729             :                             // is the bookmark a object?
    1730           0 :                             pObj = mpDoc->GetObj( aURL );
    1731           0 :                             if (pObj)
    1732           0 :                                 nPgNum = pObj->GetPage()->GetPageNum();
    1733             :                         }
    1734           0 :                         if (nPgNum != SDRPAGE_NOTFOUND)
    1735             :                         {
    1736           0 :                             nPgNum = (nPgNum - 1) / 2;  // SdrPageNum --> SdPageNum
    1737           0 :                             aURL = CreatePageURL(nPgNum);
    1738             :                         }
    1739             : 
    1740           0 :                         switch(nType)
    1741             :                         {
    1742             :                             case IMAP_OBJ_RECTANGLE:
    1743             :                             {
    1744             :                                 Rectangle aArea(static_cast<IMapRectangleObject*>(pArea)->
    1745           0 :                                                  GetRectangle(false));
    1746             : 
    1747             :                                 // conversion into pixel coordinates
    1748           0 :                                 aArea.Move(aLogPos.X() - pPage->GetLftBorder(),
    1749           0 :                                            aLogPos.Y() - pPage->GetUppBorder());
    1750           0 :                                 aArea.Left()   = (long)(aArea.Left() * fLogicToPixel);
    1751           0 :                                 aArea.Top()    = (long)(aArea.Top() * fLogicToPixel);
    1752           0 :                                 aArea.Right()  = (long)(aArea.Right() * fLogicToPixel);
    1753           0 :                                 aArea.Bottom() = (long)(aArea.Bottom() * fLogicToPixel);
    1754             : 
    1755           0 :                                 aStr.append(CreateHTMLRectArea(aArea, aURL));
    1756             :                             }
    1757           0 :                             break;
    1758             : 
    1759             :                             case IMAP_OBJ_CIRCLE:
    1760             :                             {
    1761             :                                 Point aCenter(static_cast<IMapCircleObject*>(pArea)->
    1762           0 :                                                  GetCenter(false));
    1763           0 :                                 aCenter += Point(aLogPos.X() - pPage->GetLftBorder(),
    1764           0 :                                                  aLogPos.Y() - pPage->GetUppBorder());
    1765           0 :                                 aCenter.X() = (long)(aCenter.X() * fLogicToPixel);
    1766           0 :                                 aCenter.Y() = (long)(aCenter.Y() * fLogicToPixel);
    1767             : 
    1768             :                                 sal_uLong nCircleRadius = static_cast<IMapCircleObject*>(pArea)->
    1769           0 :                                                  GetRadius(false);
    1770           0 :                                 nCircleRadius = (sal_uLong)(nCircleRadius * fLogicToPixel);
    1771             :                                 aStr.append(CreateHTMLCircleArea(nCircleRadius,
    1772           0 :                                                             aCenter.X(), aCenter.Y(),
    1773           0 :                                                             aURL));
    1774             :                             }
    1775           0 :                             break;
    1776             : 
    1777             :                             case IMAP_OBJ_POLYGON:
    1778             :                             {
    1779           0 :                                 Polygon aArea(static_cast<IMapPolygonObject*>(pArea)->GetPolygon(false));
    1780           0 :                                 aStr.append(CreateHTMLPolygonArea(::basegfx::B2DPolyPolygon(aArea.getB2DPolygon()), Size(aLogPos.X() - pPage->GetLftBorder(), aLogPos.Y() - pPage->GetUppBorder()), fLogicToPixel, aURL));
    1781             :                             }
    1782           0 :                             break;
    1783             : 
    1784             :                             default:
    1785             :                             {
    1786             :                                 DBG_WARNING("unknown IMAP_OBJ_type");
    1787             :                             }
    1788           0 :                             break;
    1789             :                         }
    1790           0 :                     }
    1791             :                 }
    1792             : 
    1793             :                 /**
    1794             :                     if there is a presentation::ClickAction, determine bookmark
    1795             :                     and create area for the whole object
    1796             :                 */
    1797           0 :                 if( pInfo )
    1798             :                 {
    1799           0 :                     OUString aHRef;
    1800           0 :                     presentation::ClickAction eClickAction = pInfo->meClickAction;
    1801             : 
    1802           0 :                     switch( eClickAction )
    1803             :                     {
    1804             :                         case presentation::ClickAction_BOOKMARK:
    1805             :                         {
    1806             :                             bool        bIsMasterPage;
    1807           0 :                             sal_uInt16  nPgNum = mpDoc->GetPageByName( pInfo->GetBookmark(), bIsMasterPage );
    1808           0 :                             SdrObject*  pObj = NULL;
    1809             : 
    1810           0 :                             if( nPgNum == SDRPAGE_NOTFOUND )
    1811             :                             {
    1812             :                                 // is the bookmark a object?
    1813           0 :                                 pObj = mpDoc->GetObj(pInfo->GetBookmark());
    1814           0 :                                 if (pObj)
    1815           0 :                                     nPgNum = pObj->GetPage()->GetPageNum();
    1816             :                             }
    1817             : 
    1818           0 :                             if( SDRPAGE_NOTFOUND != nPgNum )
    1819           0 :                                 aHRef = CreatePageURL(( nPgNum - 1 ) / 2 );
    1820             :                         }
    1821           0 :                         break;
    1822             : 
    1823             :                         case presentation::ClickAction_DOCUMENT:
    1824           0 :                             aHRef = pInfo->GetBookmark();
    1825           0 :                         break;
    1826             : 
    1827             :                         case presentation::ClickAction_PREVPAGE:
    1828             :                         {
    1829             :                             sal_uLong nPage;
    1830             : 
    1831           0 :                             if (nSdPage == 0)
    1832           0 :                                 nPage = 0;
    1833             :                             else
    1834           0 :                                 nPage = nSdPage - 1;
    1835             : 
    1836           0 :                             aHRef = CreatePageURL( (sal_uInt16) nPage);
    1837             :                         }
    1838           0 :                         break;
    1839             : 
    1840             :                         case presentation::ClickAction_NEXTPAGE:
    1841             :                         {
    1842           0 :                             sal_uLong nPage = nSdPage;
    1843           0 :                             if (nSdPage == mnSdPageCount - 1)
    1844           0 :                                 nPage = mnSdPageCount - 1;
    1845             :                             else
    1846           0 :                                 nPage = nSdPage + 1;
    1847             : 
    1848           0 :                             aHRef = CreatePageURL( (sal_uInt16) nPage);
    1849             :                         }
    1850           0 :                         break;
    1851             : 
    1852             :                         case presentation::ClickAction_FIRSTPAGE:
    1853           0 :                             aHRef = CreatePageURL(0);
    1854           0 :                         break;
    1855             : 
    1856             :                         case presentation::ClickAction_LASTPAGE:
    1857           0 :                             aHRef = CreatePageURL(mnSdPageCount - 1);
    1858           0 :                         break;
    1859             : 
    1860             :                         default:
    1861           0 :                             break;
    1862             :                     }
    1863             : 
    1864             :                     // and now the areas
    1865           0 :                     if (!aHRef.isEmpty())
    1866             :                     {
    1867             :                         // a circle?
    1868           0 :                         if (pObject->GetObjInventor() == SdrInventor &&
    1869           0 :                             pObject->GetObjIdentifier() == OBJ_CIRC  &&
    1870             :                             bIsSquare )
    1871             :                         {
    1872           0 :                             aStr.append(CreateHTMLCircleArea(aRect.GetWidth() / 2,
    1873           0 :                                                     aRect.Left() + nRadius,
    1874           0 :                                                     aRect.Top() + nRadius,
    1875           0 :                                                     aHRef));
    1876             :                         }
    1877             :                         // a polygon?
    1878           0 :                         else if (pObject->GetObjInventor() == SdrInventor &&
    1879           0 :                                  (pObject->GetObjIdentifier() == OBJ_PATHLINE ||
    1880           0 :                                   pObject->GetObjIdentifier() == OBJ_PLIN ||
    1881           0 :                                   pObject->GetObjIdentifier() == OBJ_POLY))
    1882             :                         {
    1883           0 :                             aStr.append(CreateHTMLPolygonArea(static_cast<SdrPathObj*>(pObject)->GetPathPoly(), Size(-pPage->GetLftBorder(), -pPage->GetUppBorder()), fLogicToPixel, aHRef));
    1884             :                         }
    1885             :                         // something completely different: use the BoundRect
    1886             :                         else
    1887             :                         {
    1888           0 :                             aStr.append(CreateHTMLRectArea(aRect, aHRef));
    1889             :                         }
    1890             : 
    1891           0 :                     }
    1892             :                 }
    1893             :             }
    1894             : 
    1895           0 :             aStr.append("</map>\r\n");
    1896             :         }
    1897           0 :         aClickableObjects.clear();
    1898             : 
    1899           0 :         aStr.append("</body>\r\n</html>");
    1900             : 
    1901           0 :         bOk = WriteHtml(maHTMLFiles[nSdPage], false, aStr.makeStringAndClear());
    1902             : 
    1903           0 :         if (mpProgress)
    1904           0 :             mpProgress->SetState(++mnPagesWritten);
    1905           0 :     }
    1906             : 
    1907           0 :     return bOk;
    1908             : }
    1909             : 
    1910             : // create overview pages
    1911           0 : bool HtmlExport::CreateContentPage()
    1912             : {
    1913           0 :     if( mbDocColors )
    1914           0 :         SetDocColors();
    1915             : 
    1916             :     // html head
    1917           0 :     OUStringBuffer aStr(maHTMLHeader);
    1918           0 :     aStr.append(CreateMetaCharset());
    1919           0 :     aStr.append("  <title>");
    1920           0 :     aStr.append(StringToHTMLString(maPageNames[0]));
    1921           0 :     aStr.append("</title>\r\n</head>\r\n");
    1922           0 :     aStr.append(CreateBodyTag());
    1923             : 
    1924             :     // page head
    1925           0 :     aStr.append("<center>\r\n");
    1926             : 
    1927           0 :     if(mbHeader)
    1928             :     {
    1929           0 :         aStr.append("<h1>");
    1930           0 :         aStr.append(getDocumentTitle());
    1931           0 :         aStr.append("</h1><br>\r\n");
    1932             :     }
    1933             : 
    1934           0 :     aStr.append("<h2>");
    1935             : 
    1936             :     // Solaris compiler bug workaround
    1937           0 :     if( mbFrames )
    1938             :         aStr.append(CreateLink(maFramePage,
    1939           0 :                                RESTOHTML(STR_HTMLEXP_CLICKSTART)));
    1940             :     else
    1941           0 :         aStr.append(CreateLink(StringToHTMLString(maHTMLFiles[0]),
    1942           0 :                                RESTOHTML(STR_HTMLEXP_CLICKSTART)));
    1943             : 
    1944           0 :     aStr.append("</h2>\r\n</center>\r\n");
    1945             : 
    1946           0 :     aStr.append("<center><table width=\"90%\"><tr>\r\n");
    1947             : 
    1948             :     // table of content
    1949           0 :     aStr.append("<td valign=\"top\" align=\"left\" width=\"25%\">\r\n");
    1950           0 :     aStr.append("<h3>");
    1951           0 :     aStr.append(RESTOHTML(STR_HTMLEXP_CONTENTS));
    1952           0 :     aStr.append("</h3>");
    1953             : 
    1954           0 :     for(sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; nSdPage++)
    1955             :     {
    1956           0 :         OUString aPageName = maPageNames[nSdPage];
    1957           0 :         aStr.append("<div align=\"left\">");
    1958           0 :         if(mbFrames)
    1959           0 :             aStr.append(StringToHTMLString(aPageName));
    1960             :         else
    1961           0 :             aStr.append(CreateLink(maHTMLFiles[nSdPage], aPageName));
    1962           0 :         aStr.append("</div>\r\n");
    1963           0 :     }
    1964           0 :     aStr.append("</td>\r\n");
    1965             : 
    1966             :     // document information
    1967           0 :     aStr.append("<td valign=\"top\" align=\"left\" width=\"75%\">\r\n");
    1968             : 
    1969           0 :     if (!maAuthor.isEmpty())
    1970             :     {
    1971           0 :         aStr.append("<p><strong>");
    1972           0 :         aStr.append(RESTOHTML(STR_HTMLEXP_AUTHOR));
    1973           0 :         aStr.append(":</strong> ");
    1974           0 :         aStr.append(StringToHTMLString(maAuthor));
    1975           0 :         aStr.append("</p>\r\n");
    1976             :     }
    1977             : 
    1978           0 :     if (!maEMail.isEmpty())
    1979             :     {
    1980           0 :         aStr.append("<p><strong>");
    1981           0 :         aStr.append(RESTOHTML(STR_HTMLEXP_EMAIL));
    1982           0 :         aStr.append(":</strong> <a href=\"mailto:");
    1983           0 :         aStr.append(maEMail);
    1984           0 :         aStr.append("\">");
    1985           0 :         aStr.append(StringToHTMLString(maEMail));
    1986           0 :         aStr.append("</a></p>\r\n");
    1987             :     }
    1988             : 
    1989           0 :     if (!maHomePage.isEmpty())
    1990             :     {
    1991           0 :         aStr.append("<p><strong>");
    1992           0 :         aStr.append(RESTOHTML(STR_HTMLEXP_HOMEPAGE));
    1993           0 :         aStr.append(":</strong> <a href=\"");
    1994           0 :         aStr.append(maHomePage);
    1995           0 :         aStr.append("\">");
    1996           0 :         aStr.append(StringToHTMLString(maHomePage));
    1997           0 :         aStr.append("</a> </p>\r\n");
    1998             :     }
    1999             : 
    2000           0 :     if (!maInfo.isEmpty())
    2001             :     {
    2002           0 :         aStr.append("<p><strong>");
    2003           0 :         aStr.append(RESTOHTML(STR_HTMLEXP_INFO));
    2004           0 :         aStr.append(":</strong><br>\r\n");
    2005           0 :         aStr.append(StringToHTMLString(maInfo));
    2006           0 :         aStr.append("</p>\r\n");
    2007             :     }
    2008             : 
    2009           0 :     if(mbDownload)
    2010             :     {
    2011           0 :         aStr.append("<p><a href=\"");
    2012           0 :         aStr.append(maDocFileName);
    2013           0 :         aStr.append("\">");
    2014           0 :         aStr.append(RESTOHTML(STR_HTMLEXP_DOWNLOAD));
    2015           0 :         aStr.append("</a></p>\r\n");
    2016             :     }
    2017             : 
    2018           0 :     for(sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; nSdPage++)
    2019             :     {
    2020             :         OUString aText(
    2021           0 :             "<img src=\"" +
    2022           0 :             maThumbnailFiles[nSdPage] +
    2023           0 :             "\" width=\"256\" height=\"192\" alt=\"" +
    2024           0 :             StringToHTMLString(maPageNames[nSdPage]) +
    2025           0 :             "\">");
    2026             : 
    2027           0 :         aStr.append(CreateLink(maHTMLFiles[nSdPage], aText));
    2028           0 :         aStr.append("\r\n");
    2029           0 :     }
    2030             : 
    2031           0 :     aStr.append("</td></tr></table></center>\r\n");
    2032             : 
    2033           0 :     aStr.append("</body>\r\n</html>");
    2034             : 
    2035           0 :     bool bOk = WriteHtml(maIndex, false, aStr.makeStringAndClear());
    2036             : 
    2037           0 :     if (mpProgress)
    2038           0 :         mpProgress->SetState(++mnPagesWritten);
    2039             : 
    2040           0 :     return bOk;
    2041             : }
    2042             : 
    2043             : // create note pages (for frames)
    2044             : 
    2045           0 : bool HtmlExport::CreateNotesPages()
    2046             : {
    2047           0 :     bool bOk = true;
    2048             : 
    2049           0 :     SdrOutliner* pOutliner = mpDoc->GetInternalOutliner();
    2050           0 :     for( sal_uInt16 nSdPage = 0; bOk && nSdPage < mnSdPageCount; nSdPage++ )
    2051             :     {
    2052           0 :         SdPage* pPage = maNotesPages[nSdPage];
    2053           0 :         if( mbDocColors )
    2054           0 :             SetDocColors( pPage );
    2055             : 
    2056             :         // Html head
    2057           0 :         OUStringBuffer aStr(maHTMLHeader);
    2058           0 :         aStr.append(CreateMetaCharset());
    2059           0 :         aStr.append("  <title>");
    2060           0 :         aStr.append(StringToHTMLString(maPageNames[0]));
    2061           0 :         aStr.append("</title>\r\n</head>\r\n");
    2062           0 :         aStr.append(CreateBodyTag());
    2063             : 
    2064           0 :         if(pPage)
    2065           0 :             aStr.append(CreateTextForNotesPage( pOutliner, pPage, true, maBackColor ));
    2066             : 
    2067           0 :         aStr.append("</body>\r\n</html>");
    2068             : 
    2069           0 :         OUString aFileName("note" + OUString::number(nSdPage));
    2070           0 :         bOk = WriteHtml(aFileName, true, aStr.makeStringAndClear());
    2071             : 
    2072           0 :         if (mpProgress)
    2073           0 :             mpProgress->SetState(++mnPagesWritten);
    2074           0 :     }
    2075             : 
    2076           0 :     pOutliner->Clear();
    2077             : 
    2078           0 :     return bOk;
    2079             : }
    2080             : 
    2081             : // create outline pages (for frames)
    2082             : 
    2083           0 : bool HtmlExport::CreateOutlinePages()
    2084             : {
    2085           0 :     bool bOk = true;
    2086             : 
    2087           0 :     if( mbDocColors )
    2088             :     {
    2089           0 :         SetDocColors();
    2090             :     }
    2091             : 
    2092             :     // page 0 will be the closed outline, page 1 the opened
    2093           0 :     for (sal_Int32 nPage = 0; nPage < (mbImpress?2:1) && bOk; ++nPage)
    2094             :     {
    2095             :         // Html head
    2096           0 :         OUStringBuffer aStr(maHTMLHeader);
    2097           0 :         aStr.append(CreateMetaCharset());
    2098           0 :         aStr.append("  <title>");
    2099           0 :         aStr.append(StringToHTMLString(maPageNames[0]));
    2100           0 :         aStr.append("</title>\r\n</head>\r\n");
    2101           0 :         aStr.append(CreateBodyTag());
    2102             : 
    2103           0 :         SdrOutliner* pOutliner = mpDoc->GetInternalOutliner();
    2104           0 :         for(sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; nSdPage++)
    2105             :         {
    2106           0 :             SdPage* pPage = maPages[ nSdPage ];
    2107             : 
    2108           0 :             aStr.append("<div align=\"left\">");
    2109           0 :             OUString aLink("JavaScript:parent.NavigateAbs(" +
    2110           0 :                 OUString::number(nSdPage) + ")");
    2111             : 
    2112           0 :             OUString aTitle = CreateTextForTitle(pOutliner, pPage, maBackColor);
    2113           0 :             if (aTitle.isEmpty())
    2114           0 :                 aTitle = maPageNames[nSdPage];
    2115             : 
    2116           0 :             lclAppendStyle(aStr, "p", getParagraphStyle(pOutliner, 0));
    2117           0 :             aStr.append(CreateLink(aLink, aTitle));
    2118           0 :             aStr.append("</p>");
    2119             : 
    2120           0 :             if(nPage==1)
    2121             :             {
    2122           0 :                 aStr.append(CreateTextForPage( pOutliner, pPage, false, maBackColor ));
    2123             :             }
    2124           0 :             aStr.append("</div>\r\n");
    2125           0 :         }
    2126           0 :         pOutliner->Clear();
    2127             : 
    2128           0 :         aStr.append("</body>\r\n</html>");
    2129             : 
    2130           0 :         OUString aFileName("outline" + OUString::number(nPage));
    2131           0 :         bOk = WriteHtml(aFileName, true, aStr.makeStringAndClear());
    2132             : 
    2133           0 :         if (mpProgress)
    2134           0 :             mpProgress->SetState(++mnPagesWritten);
    2135           0 :     }
    2136             : 
    2137           0 :     return bOk;
    2138             : }
    2139             : 
    2140             : // set file name
    2141           0 : void HtmlExport::CreateFileNames()
    2142             : {
    2143             :     // create lists with new file names
    2144           0 :     maHTMLFiles.resize(mnSdPageCount);
    2145           0 :     maImageFiles.resize(mnSdPageCount);
    2146           0 :     maThumbnailFiles.resize(mnSdPageCount);
    2147           0 :     maPageNames.resize(mnSdPageCount);
    2148           0 :     maTextFiles.resize(mnSdPageCount);
    2149             : 
    2150           0 :     mbHeader = false;   // headline on overview page?
    2151             : 
    2152           0 :     for (sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; nSdPage++)
    2153             :     {
    2154           0 :         OUString aHTMLFileName;
    2155           0 :         if(nSdPage == 0 && !mbContentsPage && !mbFrames )
    2156           0 :             aHTMLFileName = maIndex;
    2157             :         else
    2158             :         {
    2159           0 :             aHTMLFileName = "img" + OUString::number(nSdPage) + maHTMLExtension;
    2160             :         }
    2161             : 
    2162           0 :         maHTMLFiles[nSdPage] = aHTMLFileName;
    2163             : 
    2164           0 :         OUString aImageFileName = "img" + OUString::number(nSdPage);
    2165           0 :         if( meFormat==FORMAT_GIF )
    2166           0 :             aImageFileName += ".gif";
    2167           0 :         else if( meFormat==FORMAT_JPG )
    2168           0 :             aImageFileName += ".jpg";
    2169             :         else
    2170           0 :             aImageFileName += ".png";
    2171             : 
    2172           0 :         maImageFiles[nSdPage] = aImageFileName;
    2173             : 
    2174           0 :         OUString aThumbnailFileName = "thumb" + OUString::number(nSdPage);
    2175           0 :         if( meFormat!=FORMAT_JPG )
    2176           0 :             aThumbnailFileName += ".png";
    2177             :         else
    2178           0 :             aThumbnailFileName += ".jpg";
    2179             : 
    2180           0 :         maThumbnailFiles[nSdPage] = aThumbnailFileName;
    2181             : 
    2182           0 :         maTextFiles[nSdPage] = "text" + OUString::number(nSdPage) + maHTMLExtension;
    2183             : 
    2184           0 :         SdPage* pSdPage = maPages[ nSdPage ];
    2185             : 
    2186             :         // get slide title from page name
    2187           0 :         maPageNames[nSdPage] = pSdPage->GetName();
    2188           0 :     }
    2189             : 
    2190           0 :     if(!mbContentsPage && mbFrames)
    2191           0 :         maFramePage = maIndex;
    2192             :     else
    2193             :     {
    2194           0 :         maFramePage = "siframes" + maHTMLExtension;
    2195             :     }
    2196           0 : }
    2197             : 
    2198           0 : OUString HtmlExport::getDocumentTitle()
    2199             : {
    2200             :     // check for a title object in this page, if its the first
    2201             :     // title it becomes this documents title for the content
    2202             :     // page
    2203           0 :     if( !mbHeader )
    2204             :     {
    2205           0 :         if(mbImpress)
    2206             :         {
    2207             :             // if there is a non-empty title object, use their first passage
    2208             :             // as page title
    2209           0 :             SdPage* pSdPage = mpDoc->GetSdPage(0, PK_STANDARD);
    2210           0 :             SdrObject* pTitleObj = pSdPage->GetPresObj(PRESOBJ_TITLE);
    2211           0 :             if (pTitleObj && !pTitleObj->IsEmptyPresObj())
    2212             :             {
    2213           0 :                 OutlinerParaObject* pParaObject = pTitleObj->GetOutlinerParaObject();
    2214           0 :                 if (pParaObject)
    2215             :                 {
    2216             :                     const EditTextObject& rEditTextObject =
    2217           0 :                         pParaObject->GetTextObject();
    2218           0 :                     OUString aTest(rEditTextObject.GetText(0));
    2219           0 :                     if (!aTest.isEmpty())
    2220           0 :                         mDocTitle = aTest;
    2221             :                 }
    2222             :             }
    2223             : 
    2224           0 :             mDocTitle = mDocTitle.replace(0xff, ' ');
    2225             :         }
    2226             : 
    2227           0 :         if (mDocTitle.isEmpty())
    2228             :         {
    2229           0 :             mDocTitle = maDocFileName;
    2230           0 :             sal_Int32 nDot = mDocTitle.indexOf('.');
    2231           0 :             if (nDot > 0)
    2232           0 :                 mDocTitle = mDocTitle.copy(0, nDot);
    2233             :         }
    2234           0 :         mbHeader = true;
    2235             :     }
    2236             : 
    2237           0 :     return mDocTitle;
    2238             : }
    2239             : 
    2240             : static const char* JS_NavigateAbs =
    2241             :     "function NavigateAbs( nPage )\r\n"
    2242             :     "{\r\n"
    2243             :     "  frames[\"show\"].location.href = \"img\" + nPage + \".$EXT\";\r\n"
    2244             :     "  //frames[\"notes\"].location.href = \"note\" + nPage + \".$EXT\";\r\n"
    2245             :     "  nCurrentPage = nPage;\r\n"
    2246             :     "  if(nCurrentPage==0)\r\n"
    2247             :     "  {\r\n"
    2248             :     "    frames[\"navbar1\"].location.href = \"navbar0.$EXT\";\r\n"
    2249             :     "  }\r\n"
    2250             :     "  else if(nCurrentPage==nPageCount-1)\r\n"
    2251             :     "  {\r\n"
    2252             :     "    frames[\"navbar1\"].location.href = \"navbar2.$EXT\";\r\n"
    2253             :     "  }\r\n"
    2254             :     "  else\r\n"
    2255             :     "  {\r\n"
    2256             :     "    frames[\"navbar1\"].location.href = \"navbar1.$EXT\";\r\n"
    2257             :     "  }\r\n"
    2258             :     "}\r\n\r\n";
    2259             : 
    2260             : static const char* JS_NavigateRel =
    2261             :     "function NavigateRel( nDelta )\r\n"
    2262             :     "{\r\n"
    2263             :     "  var nPage = parseInt(nCurrentPage) + parseInt(nDelta);\r\n"
    2264             :     "  if( (nPage >= 0) && (nPage < nPageCount) )\r\n"
    2265             :     "  {\r\n"
    2266             :     "    NavigateAbs( nPage );\r\n"
    2267             :     "  }\r\n"
    2268             :     "}\r\n\r\n";
    2269             : 
    2270             : static const char* JS_ExpandOutline =
    2271             :     "function ExpandOutline()\r\n"
    2272             :     "{\r\n"
    2273             :     "  frames[\"navbar2\"].location.href = \"navbar4.$EXT\";\r\n"
    2274             :     "  frames[\"outline\"].location.href = \"outline1.$EXT\";\r\n"
    2275             :     "}\r\n\r\n";
    2276             : 
    2277             : static const char * JS_CollapseOutline =
    2278             :     "function CollapseOutline()\r\n"
    2279             :     "{\r\n"
    2280             :     "  frames[\"navbar2\"].location.href = \"navbar3.$EXT\";\r\n"
    2281             :     "  frames[\"outline\"].location.href = \"outline0.$EXT\";\r\n"
    2282             :     "}\r\n\r\n";
    2283             : 
    2284             : // create page with the frames
    2285             : 
    2286           0 : bool HtmlExport::CreateFrames()
    2287             : {
    2288           0 :     OUString aTmp;
    2289             :     OUStringBuffer aStr(
    2290             :         "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\r\n"
    2291             :         "    \"http://www.w3.org/TR/html4/frameset.dtd\">\r\n"
    2292           0 :         "<html>\r\n<head>\r\n");
    2293             : 
    2294           0 :     aStr.append(CreateMetaCharset());
    2295           0 :     aStr.append("  <title>");
    2296           0 :     aStr.append(StringToHTMLString(maPageNames[0]));
    2297           0 :     aStr.append("</title>\r\n");
    2298             : 
    2299           0 :     aStr.append("<script type=\"text/javascript\">\r\n<!--\r\n");
    2300             : 
    2301           0 :     aStr.append("var nCurrentPage = 0;\r\nvar nPageCount = ");
    2302           0 :     aStr.append(OUString::number(mnSdPageCount));
    2303           0 :     aStr.append(";\r\n\r\n");
    2304             : 
    2305           0 :     OUString aFunction = OUString::createFromAscii(JS_NavigateAbs);
    2306             : 
    2307           0 :     if(mbNotes)
    2308             :     {
    2309           0 :         aFunction = aFunction.replaceAll("//", "");
    2310             :     }
    2311             : 
    2312             :     // substitute HTML file extension
    2313           0 :     OUString aPlaceHolder(".$EXT");
    2314           0 :     aFunction = aFunction.replaceAll(aPlaceHolder, maHTMLExtension);
    2315           0 :     aStr.append(aFunction);
    2316             : 
    2317           0 :     aTmp = OUString::createFromAscii(JS_NavigateRel);
    2318           0 :     aTmp = aTmp.replaceAll(aPlaceHolder, maHTMLExtension);
    2319           0 :     aStr.append(aTmp);
    2320             : 
    2321           0 :     if(mbImpress)
    2322             :     {
    2323           0 :         aTmp = OUString::createFromAscii(JS_ExpandOutline);
    2324           0 :         aTmp = aTmp.replaceAll(aPlaceHolder, maHTMLExtension);
    2325           0 :         aStr.append(aTmp);
    2326             : 
    2327           0 :         aTmp = OUString::createFromAscii(JS_CollapseOutline);
    2328           0 :         aTmp = aTmp.replaceAll(aPlaceHolder, maHTMLExtension);
    2329           0 :         aStr.append(aTmp);
    2330             :     }
    2331           0 :     aStr.append("// -->\r\n</script>\r\n");
    2332             : 
    2333           0 :     aStr.append("</head>\r\n");
    2334             : 
    2335           0 :     aStr.append("<frameset cols=\"*,");
    2336           0 :     aStr.append(OUString::number((mnWidthPixel + 16)));
    2337           0 :     aStr.append("\">\r\n");
    2338           0 :     if(mbImpress)
    2339             :     {
    2340           0 :         aStr.append("  <frameset rows=\"42,*\">\r\n");
    2341           0 :         aStr.append("    <frame src=\"navbar3");
    2342           0 :         aStr.append(maHTMLExtension);
    2343           0 :         aStr.append("\" name=\"navbar2\" marginwidth=\"4\" marginheight=\"4\" scrolling=\"no\">\r\n");
    2344             :     }
    2345           0 :     aStr.append("    <frame src=\"outline0");
    2346           0 :     aStr.append(maHTMLExtension);
    2347           0 :     aStr.append("\" name=\"outline\">\r\n");
    2348           0 :     if(mbImpress)
    2349           0 :         aStr.append("  </frameset>\r\n");
    2350             : 
    2351           0 :     if(mbNotes)
    2352             :     {
    2353           0 :         aStr.append("  <frameset rows=\"42,");
    2354           0 :         aStr.append(OUString::number((int)((double)mnWidthPixel * 0.75) + 16));
    2355           0 :         aStr.append(",*\">\r\n");
    2356             :     }
    2357             :     else
    2358           0 :         aStr.append("  <frameset rows=\"42,*\">\r\n");
    2359             : 
    2360           0 :     aStr.append("    <frame src=\"navbar0");
    2361           0 :     aStr.append(maHTMLExtension);
    2362           0 :     aStr.append("\" name=\"navbar1\" marginwidth=\"4\" marginheight=\"4\" scrolling=\"no\">\r\n");
    2363             : 
    2364           0 :     aStr.append("    <frame src=\"");
    2365           0 :     aStr.append(maHTMLFiles[0]);
    2366           0 :     aStr.append("\" name=\"show\" marginwidth=\"4\" marginheight=\"4\">\r\n");
    2367             : 
    2368           0 :     if(mbNotes)
    2369             :     {
    2370           0 :         aStr.append("    <frame src=\"note0");
    2371           0 :         aStr.append(maHTMLExtension);
    2372           0 :         aStr.append("\" name=\"notes\">\r\n");
    2373             :     }
    2374           0 :     aStr.append("  </frameset>\r\n");
    2375             : 
    2376           0 :     aStr.append("<noframes>\r\n");
    2377           0 :     aStr.append(CreateBodyTag());
    2378           0 :     aStr.append(RESTOHTML(STR_HTMLEXP_NOFRAMES));
    2379           0 :     aStr.append("\r\n</noframes>\r\n</frameset>\r\n</html>");
    2380             : 
    2381           0 :     bool bOk = WriteHtml(maFramePage, false, aStr.makeStringAndClear());
    2382             : 
    2383           0 :     if (mpProgress)
    2384           0 :         mpProgress->SetState(++mnPagesWritten);
    2385             : 
    2386           0 :     return bOk;
    2387             : }
    2388             : 
    2389             : // create button bar for standard
    2390             : // we create the following html files
    2391             : // navbar0.htm navigation bar graphic for the first page
    2392             : // navbar1.htm navigation bar graphic for the second until second last page
    2393             : // navbar2.htm navigation bar graphic for the last page
    2394             : // navbar3.htm navigation outline closed
    2395             : // navbar4.htm navigation outline open
    2396           0 : bool HtmlExport::CreateNavBarFrames()
    2397             : {
    2398           0 :     bool bOk = true;
    2399           0 :     OUString aButton;
    2400             : 
    2401           0 :     if( mbDocColors )
    2402             :     {
    2403           0 :         SetDocColors();
    2404           0 :         maBackColor = maFirstPageColor;
    2405             :     }
    2406             : 
    2407           0 :     for( int nFile = 0; nFile < 3 && bOk; nFile++ )
    2408             :     {
    2409           0 :         OUStringBuffer aStr(maHTMLHeader);
    2410           0 :         aStr.append(CreateMetaCharset());
    2411           0 :         aStr.append("  <title>");
    2412           0 :         aStr.append(StringToHTMLString(maPageNames[0]));
    2413           0 :         aStr.append("</title>\r\n</head>\r\n");
    2414           0 :         aStr.append(CreateBodyTag());
    2415           0 :         aStr.append("<center>\r\n");
    2416             : 
    2417             :         // first page
    2418           0 :         aButton = SD_RESSTR(STR_HTMLEXP_FIRSTPAGE);
    2419           0 :         if(mnButtonThema != -1)
    2420           0 :             aButton = CreateImage(GetButtonName((nFile == 0 || mnSdPageCount == 1?
    2421           0 :                                   BTN_FIRST_0:BTN_FIRST_1)), aButton);
    2422             : 
    2423           0 :         if(nFile != 0 && mnSdPageCount > 1)
    2424           0 :             aButton = CreateLink("JavaScript:parent.NavigateAbs(0)", aButton);
    2425             : 
    2426           0 :         aStr.append(aButton);
    2427           0 :         aStr.append("\r\n");
    2428             : 
    2429             :         // to the previous page
    2430           0 :         aButton = SD_RESSTR(STR_PUBLISH_BACK);
    2431           0 :         if(mnButtonThema != -1)
    2432           0 :             aButton = CreateImage(GetButtonName((nFile == 0 || mnSdPageCount == 1?
    2433           0 :                                     BTN_PREV_0:BTN_PREV_1)), aButton);
    2434             : 
    2435           0 :         if(nFile != 0 && mnSdPageCount > 1)
    2436           0 :             aButton = CreateLink("JavaScript:parent.NavigateRel(-1)", aButton);
    2437             : 
    2438           0 :         aStr.append(aButton);
    2439           0 :         aStr.append("\r\n");
    2440             : 
    2441             :         // to the next page
    2442           0 :         aButton = SD_RESSTR(STR_PUBLISH_NEXT);
    2443           0 :         if(mnButtonThema != -1)
    2444           0 :             aButton = CreateImage(GetButtonName((nFile ==2 || mnSdPageCount == 1?
    2445           0 :                                     BTN_NEXT_0:BTN_NEXT_1)), aButton);
    2446             : 
    2447           0 :         if(nFile != 2 && mnSdPageCount > 1)
    2448           0 :             aButton = CreateLink("JavaScript:parent.NavigateRel(1)", aButton);
    2449             : 
    2450           0 :         aStr.append(aButton);
    2451           0 :         aStr.append("\r\n");
    2452             : 
    2453             :         // to the last page
    2454           0 :         aButton = SD_RESSTR(STR_HTMLEXP_LASTPAGE);
    2455           0 :         if(mnButtonThema != -1)
    2456           0 :             aButton = CreateImage(GetButtonName((nFile ==2 || mnSdPageCount == 1?
    2457           0 :                                   BTN_LAST_0:BTN_LAST_1)), aButton);
    2458             : 
    2459           0 :         if(nFile != 2 && mnSdPageCount > 1)
    2460             :         {
    2461           0 :             OUString aLink("JavaScript:parent.NavigateAbs(" +
    2462           0 :                 OUString::number(mnSdPageCount-1) + ")");
    2463             : 
    2464           0 :             aButton = CreateLink(aLink, aButton);
    2465             :         }
    2466             : 
    2467           0 :         aStr.append(aButton);
    2468           0 :         aStr.append("\r\n");
    2469             : 
    2470             :         // content
    2471           0 :         if (mbContentsPage)
    2472             :         {
    2473           0 :             aButton = SD_RESSTR(STR_PUBLISH_OUTLINE);
    2474           0 :             if(mnButtonThema != -1)
    2475           0 :                 aButton = CreateImage(GetButtonName(BTN_INDEX), aButton);
    2476             : 
    2477             :             // to the overview
    2478           0 :             aStr.append(CreateLink(maIndex, aButton, "_top"));
    2479           0 :             aStr.append("\r\n");
    2480             :         }
    2481             : 
    2482             :         // text mode
    2483           0 :         if(mbImpress)
    2484             :         {
    2485           0 :             aButton = SD_RESSTR(STR_HTMLEXP_SETTEXT);
    2486           0 :             if(mnButtonThema != -1)
    2487           0 :                 aButton = CreateImage(GetButtonName(BTN_TEXT), aButton);
    2488             : 
    2489           0 :             OUString aText0("text0" + maHTMLExtension);
    2490           0 :             aStr.append(CreateLink(aText0, aButton, "_top"));
    2491           0 :             aStr.append("\r\n");
    2492             :         }
    2493             : 
    2494             :         // and finished...
    2495           0 :         aStr.append("</center>\r\n");
    2496           0 :         aStr.append("</body>\r\n</html>");
    2497             : 
    2498           0 :         OUString aFileName("navbar" + OUString::number(nFile));
    2499             : 
    2500           0 :         bOk = WriteHtml(aFileName, true, aStr.makeStringAndClear());
    2501             : 
    2502           0 :         if (mpProgress)
    2503           0 :             mpProgress->SetState(++mnPagesWritten);
    2504           0 :     }
    2505             : 
    2506             :     // the navigation bar outliner closed...
    2507           0 :     if(bOk)
    2508             :     {
    2509           0 :         OUStringBuffer aStr(maHTMLHeader);
    2510           0 :         aStr.append(CreateMetaCharset());
    2511           0 :         aStr.append("  <title>");
    2512           0 :         aStr.append(StringToHTMLString(maPageNames[0]));
    2513           0 :         aStr.append("</title>\r\n</head>\r\n");
    2514           0 :         aStr.append(CreateBodyTag());
    2515             : 
    2516           0 :         aButton = SD_RESSTR(STR_HTMLEXP_OUTLINE);
    2517           0 :         if(mnButtonThema != -1)
    2518           0 :             aButton = CreateImage(GetButtonName(BTN_MORE), aButton);
    2519             : 
    2520           0 :         aStr.append(CreateLink("JavaScript:parent.ExpandOutline()", aButton));
    2521           0 :         aStr.append("</body>\r\n</html>");
    2522             : 
    2523           0 :         bOk = WriteHtml("navbar3", true, aStr.makeStringAndClear());
    2524             : 
    2525           0 :         if (mpProgress)
    2526           0 :             mpProgress->SetState(++mnPagesWritten);
    2527             :     }
    2528             : 
    2529             :     // ... and the outliner open
    2530           0 :     if( bOk )
    2531             :     {
    2532           0 :         OUStringBuffer aStr(maHTMLHeader);
    2533           0 :         aStr.append(CreateMetaCharset());
    2534           0 :         aStr.append("  <title>");
    2535           0 :         aStr.append(StringToHTMLString(maPageNames[0]));
    2536           0 :         aStr.append("</title>\r\n</head>\r\n");
    2537           0 :         aStr.append(CreateBodyTag());
    2538             : 
    2539           0 :         aButton = SD_RESSTR(STR_HTMLEXP_NOOUTLINE);
    2540           0 :         if(mnButtonThema != -1)
    2541           0 :             aButton = CreateImage(GetButtonName(BTN_LESS), aButton);
    2542             : 
    2543           0 :         aStr.append(CreateLink("JavaScript:parent.CollapseOutline()", aButton));
    2544           0 :         aStr.append("</body>\r\n</html>");
    2545             : 
    2546           0 :         bOk = WriteHtml("navbar4", true, aStr.makeStringAndClear());
    2547             : 
    2548           0 :         if (mpProgress)
    2549           0 :             mpProgress->SetState(++mnPagesWritten);
    2550             : 
    2551             :     }
    2552             : 
    2553           0 :     return bOk;
    2554             : }
    2555             : 
    2556             : // create button bar for standard
    2557           0 : OUString HtmlExport::CreateNavBar( sal_uInt16 nSdPage, bool bIsText ) const
    2558             : {
    2559             :     // prepare button bar
    2560           0 :     OUString aStrNavFirst(SD_RESSTR(STR_HTMLEXP_FIRSTPAGE));
    2561           0 :     OUString aStrNavPrev(SD_RESSTR(STR_PUBLISH_BACK));
    2562           0 :     OUString aStrNavNext(SD_RESSTR(STR_PUBLISH_NEXT));
    2563           0 :     OUString aStrNavLast(SD_RESSTR(STR_HTMLEXP_LASTPAGE));
    2564           0 :     OUString aStrNavContent(SD_RESSTR(STR_PUBLISH_OUTLINE));
    2565           0 :     OUString aStrNavText;
    2566           0 :     if( bIsText )
    2567             :     {
    2568           0 :         aStrNavText = SD_RESSTR(STR_HTMLEXP_SETGRAPHIC);
    2569             :     }
    2570             :     else
    2571             :     {
    2572           0 :         aStrNavText = SD_RESSTR(STR_HTMLEXP_SETTEXT);
    2573             :     }
    2574             : 
    2575           0 :     if(!bIsText && mnButtonThema != -1)
    2576             :     {
    2577           0 :         if(nSdPage<1 || mnSdPageCount == 1)
    2578             :         {
    2579           0 :             aStrNavFirst = CreateImage(GetButtonName(BTN_FIRST_0), aStrNavFirst);
    2580           0 :             aStrNavPrev  = CreateImage(GetButtonName(BTN_PREV_0), aStrNavPrev);
    2581             :         }
    2582             :         else
    2583             :         {
    2584           0 :             aStrNavFirst = CreateImage(GetButtonName(BTN_FIRST_1), aStrNavFirst);
    2585           0 :             aStrNavPrev  = CreateImage(GetButtonName(BTN_PREV_1), aStrNavPrev);
    2586             :         }
    2587             : 
    2588           0 :         if(nSdPage == mnSdPageCount-1 || mnSdPageCount == 1)
    2589             :         {
    2590           0 :             aStrNavNext    = CreateImage(GetButtonName(BTN_NEXT_0), aStrNavNext);
    2591           0 :             aStrNavLast    = CreateImage(GetButtonName(BTN_LAST_0), aStrNavLast);
    2592             :         }
    2593             :         else
    2594             :         {
    2595           0 :             aStrNavNext    = CreateImage(GetButtonName(BTN_NEXT_1), aStrNavNext);
    2596           0 :             aStrNavLast    = CreateImage(GetButtonName(BTN_LAST_1), aStrNavLast);
    2597             :         }
    2598             : 
    2599           0 :         aStrNavContent = CreateImage(GetButtonName(BTN_INDEX), aStrNavContent);
    2600           0 :         aStrNavText    = CreateImage(GetButtonName(BTN_TEXT), aStrNavText);
    2601             :     }
    2602             : 
    2603           0 :     OUStringBuffer aStr("<center>\r\n"); //<table><tr>\r\n");
    2604             : 
    2605             :     // first page
    2606           0 :     if(nSdPage > 0)
    2607           0 :         aStr.append(CreateLink( bIsText ? maTextFiles[0] : maHTMLFiles[0],aStrNavFirst));
    2608             :     else
    2609           0 :         aStr.append(aStrNavFirst);
    2610           0 :     aStr.append(' ');
    2611             : 
    2612             :     // to Previous page
    2613           0 :     if(nSdPage > 0)
    2614           0 :         aStr.append(CreateLink( bIsText ? maTextFiles[nSdPage-1]
    2615           0 :                                         : maHTMLFiles[nSdPage-1], aStrNavPrev));
    2616             :     else
    2617           0 :         aStr.append(aStrNavPrev);
    2618           0 :     aStr.append(' ');
    2619             : 
    2620             :     // to Next page
    2621           0 :     if(nSdPage < mnSdPageCount-1)
    2622           0 :         aStr.append(CreateLink( bIsText ? maTextFiles[nSdPage+1]
    2623           0 :                                         : maHTMLFiles[nSdPage+1], aStrNavNext));
    2624             :     else
    2625           0 :         aStr.append(aStrNavNext);
    2626           0 :     aStr.append(' ');
    2627             : 
    2628             :     // to Last page
    2629           0 :     if(nSdPage < mnSdPageCount-1)
    2630           0 :         aStr.append(CreateLink( bIsText ? maTextFiles[mnSdPageCount-1]
    2631           0 :                                         : maHTMLFiles[mnSdPageCount-1],
    2632           0 :                                 aStrNavLast));
    2633             :     else
    2634           0 :         aStr.append(aStrNavLast);
    2635           0 :     aStr.append(' ');
    2636             : 
    2637             :     // to Index page
    2638           0 :     if (mbContentsPage)
    2639             :     {
    2640           0 :         aStr.append(CreateLink(maIndex, aStrNavContent));
    2641           0 :         aStr.append(' ');
    2642             :     }
    2643             : 
    2644             :     // Text/Graphics
    2645           0 :     if(mbImpress)
    2646             :     {
    2647           0 :         aStr.append(CreateLink( bIsText ? (mbFrames ? maFramePage : maHTMLFiles[nSdPage])
    2648           0 :                                         : maTextFiles[nSdPage], aStrNavText));
    2649             : 
    2650             :     }
    2651             : 
    2652           0 :     aStr.append("</center><br>\r\n");
    2653             : 
    2654           0 :     return aStr.makeStringAndClear();
    2655             : }
    2656             : 
    2657             : // export navigation graphics from button set
    2658           0 : bool HtmlExport::CreateBitmaps()
    2659             : {
    2660           0 :     if(mnButtonThema != -1 && mpButtonSet.get() )
    2661             :     {
    2662           0 :         for( int nButton = 0; nButton != SAL_N_ELEMENTS(pButtonNames); nButton++ )
    2663             :         {
    2664           0 :             if(!mbFrames && (nButton == BTN_MORE || nButton == BTN_LESS))
    2665           0 :                 continue;
    2666             : 
    2667           0 :             if(!mbImpress && (nButton == BTN_TEXT || nButton == BTN_MORE || nButton == BTN_LESS ))
    2668           0 :                 continue;
    2669             : 
    2670           0 :             OUString aFull(maExportPath);
    2671           0 :             aFull += GetButtonName(nButton);
    2672           0 :             mpButtonSet->exportButton( mnButtonThema, aFull, GetButtonName(nButton) );
    2673           0 :         }
    2674             :     }
    2675           0 :     return true;
    2676             : }
    2677             : 
    2678             : // creates the <body> tag, including the specified color attributes
    2679           1 : OUString HtmlExport::CreateBodyTag() const
    2680             : {
    2681           1 :     OUStringBuffer aStr( "<body" );
    2682             : 
    2683           1 :     if( mbUserAttr || mbDocColors )
    2684             :     {
    2685           0 :         Color aTextColor( maTextColor );
    2686           0 :         if( (aTextColor == COL_AUTO) && (!maBackColor.IsDark()) )
    2687           0 :             aTextColor = COL_BLACK;
    2688             : 
    2689           0 :         aStr.append(" text=\"");
    2690           0 :         aStr.append(ColorToHTMLString( aTextColor ));
    2691           0 :         aStr.append("\" bgcolor=\"");
    2692           0 :         aStr.append(ColorToHTMLString( maBackColor ));
    2693           0 :         aStr.append("\" link=\"");
    2694           0 :         aStr.append(ColorToHTMLString( maLinkColor ));
    2695           0 :         aStr.append("\" vlink=\"");
    2696           0 :         aStr.append(ColorToHTMLString( maVLinkColor ));
    2697           0 :         aStr.append("\" alink=\"");
    2698           0 :         aStr.append(ColorToHTMLString( maALinkColor ));
    2699           0 :         aStr.append("\"");
    2700             :     }
    2701             : 
    2702           1 :     aStr.append(">\r\n");
    2703             : 
    2704           1 :     return aStr.makeStringAndClear();
    2705             : }
    2706             : 
    2707             : // creates a hyperlink
    2708           0 : OUString HtmlExport::CreateLink( const OUString& aLink,
    2709             :                                  const OUString& aText,
    2710             :                                  const OUString& aTarget )
    2711             : {
    2712           0 :     OUStringBuffer aStr( "<a href=\"" );
    2713           0 :     aStr.append(aLink);
    2714           0 :     if (!aTarget.isEmpty())
    2715             :     {
    2716           0 :         aStr.append("\" target=\"");
    2717           0 :         aStr.append(aTarget);
    2718             :     }
    2719           0 :     aStr.append("\">");
    2720           0 :     aStr.append(aText);
    2721           0 :     aStr.append("</a>");
    2722             : 
    2723           0 :     return aStr.makeStringAndClear();
    2724             : }
    2725             : 
    2726             : // creates a image tag
    2727           0 : OUString HtmlExport::CreateImage( const OUString& aImage, const OUString& aAltText,
    2728             :                                 sal_Int16 nWidth,
    2729             :                                 sal_Int16 nHeight )
    2730             : {
    2731           0 :     OUStringBuffer aStr( "<img src=\"");
    2732           0 :     aStr.append(aImage);
    2733           0 :     aStr.append("\" border=0");
    2734             : 
    2735           0 :     if (!aAltText.isEmpty())
    2736             :     {
    2737           0 :         aStr.append(" alt=\"");
    2738           0 :         aStr.append(aAltText);
    2739           0 :         aStr.append('"');
    2740             :     }
    2741             :     else
    2742             :     {
    2743             :         // Agerskov: HTML 4.01 has to have an alt attribute even if it is an empty string
    2744           0 :         aStr.append(" alt=\"\"");
    2745             :      }
    2746             : 
    2747           0 :     if(nWidth > -1)
    2748             :     {
    2749           0 :         aStr.append(" width=" + OUString::number(nWidth));
    2750             :     }
    2751             : 
    2752           0 :     if(nHeight > -1)
    2753             :     {
    2754           0 :         aStr.append(" height=" + OUString::number(nHeight));
    2755             :     }
    2756             : 
    2757           0 :     aStr.append('>');
    2758             : 
    2759           0 :     return aStr.makeStringAndClear();
    2760             : }
    2761             : 
    2762             : // create area for a circle; we expect pixel coordinates
    2763           0 : OUString HtmlExport::ColorToHTMLString( Color aColor )
    2764             : {
    2765             :     static const char hex[] = "0123456789ABCDEF";
    2766           0 :     OUStringBuffer aStr( "#xxxxxx" );
    2767           0 :     aStr[1] = hex[(aColor.GetRed() >> 4) & 0xf];
    2768           0 :     aStr[2] = hex[aColor.GetRed() & 0xf];
    2769           0 :     aStr[3] = hex[(aColor.GetGreen() >> 4) & 0xf];
    2770           0 :     aStr[4] = hex[aColor.GetGreen() & 0xf];
    2771           0 :     aStr[5] = hex[(aColor.GetBlue() >> 4) & 0xf];
    2772           0 :     aStr[6] = hex[aColor.GetBlue() & 0xf];
    2773             : 
    2774           0 :     return aStr.makeStringAndClear();
    2775             : }
    2776             : 
    2777             : // create area for a circle; we expect pixel coordinates
    2778           0 : OUString HtmlExport::CreateHTMLCircleArea( sal_uLong nRadius,
    2779             :                                          sal_uLong nCenterX,
    2780             :                                          sal_uLong nCenterY,
    2781             :                                          const OUString& rHRef )
    2782             : {
    2783             :     OUString aStr(
    2784           0 :         "<area shape=\"circle\" alt=\"\" coords=\"" +
    2785           0 :         OUString::number(nCenterX) + "," +
    2786           0 :         OUString::number(nCenterY) + "," +
    2787           0 :         OUString::number(nRadius) +
    2788           0 :         "\" href=\"" + rHRef + "\">\n");
    2789             : 
    2790           0 :     return aStr;
    2791             : }
    2792             : 
    2793             : // create area for a polygon; we expect pixel coordinates
    2794           0 : OUString HtmlExport::CreateHTMLPolygonArea( const ::basegfx::B2DPolyPolygon& rPolyPolygon,
    2795             :     Size aShift, double fFactor, const OUString& rHRef )
    2796             : {
    2797           0 :     OUStringBuffer aStr;
    2798           0 :     const sal_uInt32 nNoOfPolygons(rPolyPolygon.count());
    2799             : 
    2800           0 :     for ( sal_uInt32 nXPoly = 0L; nXPoly < nNoOfPolygons; nXPoly++ )
    2801             :     {
    2802           0 :         const ::basegfx::B2DPolygon& aPolygon = rPolyPolygon.getB2DPolygon(nXPoly);
    2803           0 :         const sal_uInt32 nNoOfPoints(aPolygon.count());
    2804             : 
    2805           0 :         aStr.append("<area shape=\"polygon\" alt=\"\" coords=\"");
    2806             : 
    2807           0 :         for ( sal_uInt32 nPoint = 0L; nPoint < nNoOfPoints; nPoint++ )
    2808             :         {
    2809           0 :             const ::basegfx::B2DPoint aB2DPoint(aPolygon.getB2DPoint(nPoint));
    2810           0 :             Point aPnt(FRound(aB2DPoint.getX()), FRound(aB2DPoint.getY()));
    2811             :             // coordinates are relative to the physical page origin, not the
    2812             :             // origin of ordinates
    2813           0 :             aPnt.Move(aShift.Width(), aShift.Height());
    2814             : 
    2815           0 :             aPnt.X() = (long)(aPnt.X() * fFactor);
    2816           0 :             aPnt.Y() = (long)(aPnt.Y() * fFactor);
    2817           0 :             aStr.append(OUString::number(aPnt.X()) + "," + OUString::number(aPnt.Y()));
    2818             : 
    2819           0 :             if (nPoint < nNoOfPoints - 1)
    2820           0 :                 aStr.append(',');
    2821           0 :         }
    2822           0 :         aStr.append("\" href=\"" + rHRef + "\">\n");
    2823           0 :     }
    2824             : 
    2825           0 :     return aStr.makeStringAndClear();
    2826             : }
    2827             : 
    2828             : // create area for a rectangle; we expect pixel coordinates
    2829           0 : OUString HtmlExport::CreateHTMLRectArea( const Rectangle& rRect,
    2830             :                                        const OUString& rHRef )
    2831             : {
    2832             :     OUString aStr(
    2833           0 :         "<area shape=\"rect\" alt=\"\" coords=\"" +
    2834           0 :         OUString::number(rRect.Left()) + "," +
    2835           0 :         OUString::number(rRect.Top()) + "," +
    2836           0 :         OUString::number(rRect.Right()) + "," +
    2837           0 :         OUString::number(rRect.Bottom()) +
    2838           0 :         "\" href=\"" + rHRef + "\">\n");
    2839             : 
    2840           0 :     return aStr;
    2841             : }
    2842             : 
    2843             : // escapes a string for html
    2844          26 : OUString HtmlExport::StringToHTMLString( const OUString& rString )
    2845             : {
    2846          26 :     SvMemoryStream aMemStm;
    2847          26 :     HTMLOutFuncs::Out_String( aMemStm, rString, RTL_TEXTENCODING_UTF8 );
    2848          26 :     aMemStm.WriteChar( (char) 0 );
    2849          26 :     sal_Int32 nLength = strlen(static_cast<char const *>(aMemStm.GetData()));
    2850          26 :     return OUString( static_cast<char const *>(aMemStm.GetData()), nLength, RTL_TEXTENCODING_UTF8 );
    2851             : }
    2852             : 
    2853             : // creates a url for a specific page
    2854           0 : OUString HtmlExport::CreatePageURL( sal_uInt16 nPgNum )
    2855             : {
    2856           0 :     if(mbFrames)
    2857             :     {
    2858           0 :         return OUString("JavaScript:parent.NavigateAbs(" +
    2859           0 :                         OUString::number(nPgNum) + ")");
    2860             :     }
    2861             :     else
    2862           0 :         return maHTMLFiles[nPgNum];
    2863             : }
    2864             : 
    2865           0 : bool HtmlExport::CopyScript( const OUString& rPath, const OUString& rSource, const OUString& rDest, bool bUnix /* = false */ )
    2866             : {
    2867           0 :     INetURLObject   aURL( SvtPathOptions().GetConfigPath() );
    2868           0 :     OUStringBuffer aScriptBuf;
    2869             : 
    2870           0 :     aURL.Append( OUString("webcast") );
    2871           0 :     aURL.Append( rSource );
    2872             : 
    2873           0 :     meEC.SetContext( STR_HTMLEXP_ERROR_OPEN_FILE, rSource );
    2874             : 
    2875           0 :     sal_uLong       nErr = 0;
    2876           0 :     SvStream*   pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), StreamMode::READ );
    2877             : 
    2878           0 :     if( pIStm )
    2879             :     {
    2880           0 :         OString aLine;
    2881             : 
    2882           0 :         while( pIStm->ReadLine( aLine ) )
    2883             :         {
    2884           0 :             aScriptBuf.appendAscii( aLine.getStr() );
    2885           0 :             if( bUnix )
    2886             :             {
    2887           0 :                 aScriptBuf.append("\n");
    2888             :             }
    2889             :             else
    2890             :             {
    2891           0 :                 aScriptBuf.append("\r\n");
    2892             :             }
    2893             :         }
    2894             : 
    2895           0 :         nErr = pIStm->GetError();
    2896           0 :         delete pIStm;
    2897             :     }
    2898             : 
    2899           0 :     if( nErr != 0 )
    2900             :     {
    2901           0 :         ErrorHandler::HandleError( nErr );
    2902           0 :         return (bool) nErr;
    2903             :     }
    2904             : 
    2905           0 :     OUString aScript(aScriptBuf.makeStringAndClear());
    2906           0 :     aScript = aScript.replaceAll("$$1", getDocumentTitle());
    2907           0 :     aScript = aScript.replaceAll("$$2", RESTOHTML(STR_WEBVIEW_SAVE));
    2908           0 :     aScript = aScript.replaceAll("$$3", maCGIPath);
    2909           0 :     aScript = aScript.replaceAll("$$4", OUString::number(mnWidthPixel));
    2910           0 :     aScript = aScript.replaceAll("$$5", OUString::number(mnHeightPixel));
    2911             : 
    2912           0 :     OUString aDest(rPath + rDest);
    2913             : 
    2914           0 :     meEC.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE, rDest );
    2915             :     // write script file
    2916             :     {
    2917           0 :         EasyFile aFile;
    2918             :         SvStream* pStr;
    2919           0 :         nErr = aFile.createStream(aDest, pStr);
    2920           0 :         if(nErr == 0)
    2921             :         {
    2922             :             OString aStr(OUStringToOString(aScript,
    2923           0 :                 RTL_TEXTENCODING_UTF8));
    2924           0 :             pStr->WriteCharPtr( aStr.getStr() );
    2925             : 
    2926           0 :             nErr = aFile.close();
    2927           0 :         }
    2928             :     }
    2929             : 
    2930           0 :     if (mpProgress)
    2931           0 :         mpProgress->SetState(++mnPagesWritten);
    2932             : 
    2933           0 :     if( nErr != 0 )
    2934           0 :         ErrorHandler::HandleError( nErr );
    2935             : 
    2936           0 :     return nErr == 0;
    2937             : }
    2938             : 
    2939             : static const char * ASP_Scripts[] = { "common.inc", "webcast.asp", "show.asp", "savepic.asp", "poll.asp", "editpic.asp" };
    2940             : 
    2941             : /** creates and saves the ASP scripts for WebShow */
    2942           0 : bool HtmlExport::CreateASPScripts()
    2943             : {
    2944           0 :     for( sal_uInt16 n = 0; n < (sizeof( ASP_Scripts ) / sizeof(char *)); n++ )
    2945             :     {
    2946           0 :         OUString aScript = OUString::createFromAscii(ASP_Scripts[n]);
    2947             : 
    2948           0 :         if(!CopyScript(maExportPath, aScript, aScript))
    2949           0 :             return false;
    2950           0 :     }
    2951             : 
    2952           0 :     if (!CopyScript(maExportPath, "edit.asp", maIndex))
    2953           0 :         return false;
    2954             : 
    2955           0 :     return true;
    2956             : }
    2957             : 
    2958             : static const char *PERL_Scripts[] = { "webcast.pl", "common.pl", "editpic.pl", "poll.pl", "savepic.pl", "show.pl" };
    2959             : 
    2960             : // creates and saves the PERL scripts for WebShow
    2961           0 : bool HtmlExport::CreatePERLScripts()
    2962             : {
    2963           0 :     for( sal_uInt16 n = 0; n < (sizeof( PERL_Scripts ) / sizeof(char *)); n++ )
    2964             :     {
    2965           0 :         OUString aScript = OUString::createFromAscii(PERL_Scripts[n]);
    2966             : 
    2967           0 :         if(!CopyScript(maExportPath, aScript, aScript, true))
    2968           0 :             return false;
    2969           0 :     }
    2970             : 
    2971           0 :     if (!CopyScript(maExportPath, "edit.pl", maIndex, true))
    2972           0 :         return false;
    2973             : 
    2974           0 :     if (!CopyScript(maExportPath, "index.pl", maIndexUrl, true))
    2975           0 :         return false;
    2976             : 
    2977           0 :     return true;
    2978             : }
    2979             : 
    2980             : // creates a list with names of the saved images
    2981           0 : bool HtmlExport::CreateImageFileList()
    2982             : {
    2983           0 :     OUStringBuffer aStr;
    2984           0 :     for( sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; nSdPage++)
    2985             :     {
    2986           0 :         aStr.append(OUString::number(nSdPage + 1));
    2987           0 :         aStr.append(';');
    2988           0 :         aStr.append(maURLPath);
    2989           0 :         aStr.append(maImageFiles[nSdPage]);
    2990           0 :         aStr.append("\r\n");
    2991             :     }
    2992             : 
    2993           0 :     bool bOk = WriteHtml("picture.txt", false, aStr.makeStringAndClear());
    2994             : 
    2995           0 :     if (mpProgress)
    2996           0 :         mpProgress->SetState(++mnPagesWritten);
    2997             : 
    2998           0 :     return bOk;
    2999             : }
    3000             : 
    3001             : // creates a file with the actual page number
    3002           0 : bool HtmlExport::CreateImageNumberFile()
    3003             : {
    3004           0 :     OUString aFileName("currpic.txt");
    3005           0 :     OUString aFull(maExportPath + aFileName);
    3006             : 
    3007           0 :     meEC.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE, aFileName );
    3008           0 :     EasyFile aFile;
    3009             :     SvStream* pStr;
    3010           0 :     sal_uLong nErr = aFile.createStream(aFull, pStr);
    3011           0 :     if(nErr == 0)
    3012             :     {
    3013           0 :         pStr->WriteCharPtr( "1" );
    3014           0 :         nErr = aFile.close();
    3015             :     }
    3016             : 
    3017           0 :     if (mpProgress)
    3018           0 :         mpProgress->SetState(++mnPagesWritten);
    3019             : 
    3020           0 :     if( nErr != 0 )
    3021           0 :         ErrorHandler::HandleError( nErr );
    3022             : 
    3023           0 :     return nErr == 0;
    3024             : }
    3025             : 
    3026           0 : OUString HtmlExport::InsertSound( const OUString& rSoundFile )
    3027             : {
    3028           0 :     if (rSoundFile.isEmpty())
    3029           0 :         return rSoundFile;
    3030             : 
    3031           0 :     INetURLObject   aURL( rSoundFile );
    3032           0 :     OUString aSoundFileName = aURL.getName();
    3033             : 
    3034             :     DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
    3035             : 
    3036           0 :     OUString aStr("<embed src=\"" + aSoundFileName +
    3037           0 :         "\" hidden=\"true\" autostart=\"true\">");
    3038             : 
    3039           0 :     CopyFile(rSoundFile, maExportPath + aSoundFileName);
    3040             : 
    3041           0 :     return aStr;
    3042             : }
    3043             : 
    3044           0 : bool HtmlExport::CopyFile( const OUString& rSourceFile, const OUString& rDestFile )
    3045             : {
    3046           0 :     meEC.SetContext( STR_HTMLEXP_ERROR_COPY_FILE, rSourceFile, rDestFile );
    3047           0 :     osl::FileBase::RC Error = osl::File::copy( rSourceFile, rDestFile );
    3048             : 
    3049           0 :     if( Error != osl::FileBase::E_None )
    3050             :     {
    3051           0 :         ErrorHandler::HandleError(Error);
    3052           0 :         return false;
    3053             :     }
    3054             :     else
    3055             :     {
    3056           0 :         return true;
    3057             :     }
    3058             : }
    3059             : 
    3060           0 : bool HtmlExport::checkFileExists( Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xFileAccess, OUString const & aFileName )
    3061             : {
    3062             :     try
    3063             :     {
    3064           0 :         OUString url( maExportPath );
    3065           0 :         url += aFileName;
    3066           0 :         return xFileAccess->exists( url );
    3067             :     }
    3068           0 :     catch( com::sun::star::uno::Exception& )
    3069             :     {
    3070             :         OSL_FAIL(OString(OString("sd::HtmlExport::checkFileExists(), exception caught: ") +
    3071             :              OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), RTL_TEXTENCODING_UTF8 )).getStr() );
    3072             :     }
    3073             : 
    3074           0 :     return false;
    3075             : }
    3076             : 
    3077           0 : bool HtmlExport::checkForExistingFiles()
    3078             : {
    3079           0 :     bool bFound = false;
    3080             : 
    3081             :     try
    3082             :     {
    3083           0 :         Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
    3084           0 :         uno::Reference<ucb::XSimpleFileAccess3> xFA(ucb::SimpleFileAccess::create(xContext));
    3085             : 
    3086             :         sal_uInt16 nSdPage;
    3087           0 :         for( nSdPage = 0; !bFound && (nSdPage < mnSdPageCount); nSdPage++)
    3088             :         {
    3089           0 :             if( checkFileExists( xFA, maImageFiles[nSdPage] ) ||
    3090           0 :                 checkFileExists( xFA, maHTMLFiles[nSdPage] ) ||
    3091           0 :                 checkFileExists( xFA, maThumbnailFiles[nSdPage] ) ||
    3092           0 :                 checkFileExists( xFA, maPageNames[nSdPage] ) ||
    3093           0 :                 checkFileExists( xFA, maTextFiles[nSdPage] ) )
    3094             :             {
    3095           0 :                 bFound = true;
    3096             :             }
    3097             :         }
    3098             : 
    3099           0 :         if( !bFound && mbDownload )
    3100           0 :             bFound = checkFileExists( xFA, maDocFileName );
    3101             : 
    3102           0 :         if( !bFound && mbFrames )
    3103           0 :             bFound = checkFileExists( xFA, maFramePage );
    3104             : 
    3105           0 :         if( bFound )
    3106             :         {
    3107           0 :             ResMgr *pResMgr = ResMgr::CreateResMgr( "dbw" );
    3108           0 :             if( pResMgr )
    3109             :             {
    3110           0 :                 ResId aResId( 4077, *pResMgr );
    3111           0 :                 OUString aMsg( aResId.toString() );
    3112             : 
    3113           0 :                 OUString aSystemPath;
    3114           0 :                 osl::FileBase::getSystemPathFromFileURL( maExportPath, aSystemPath );
    3115           0 :                 aMsg = aMsg.replaceFirst( "%FILENAME", aSystemPath );
    3116           0 :                 ScopedVclPtrInstance< WarningBox > aWarning( nullptr, WB_YES_NO | WB_DEF_YES, aMsg );
    3117           0 :                 aWarning->SetImage( WarningBox::GetStandardImage() );
    3118           0 :                 bFound = ( RET_NO == aWarning->Execute() );
    3119             : 
    3120           0 :                 delete pResMgr;
    3121             :             }
    3122             :             else
    3123             :             {
    3124           0 :                 bFound = false;
    3125             :             }
    3126           0 :         }
    3127             :     }
    3128           0 :     catch( Exception& )
    3129             :     {
    3130             :         OSL_FAIL(OString(OString("sd::HtmlExport::checkForExistingFiles(), exception caught: ") +
    3131             :              OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), RTL_TEXTENCODING_UTF8 )).getStr() );
    3132           0 :         bFound = false;
    3133             :     }
    3134             : 
    3135           0 :     return bFound;
    3136             : }
    3137             : 
    3138           0 : OUString HtmlExport::GetButtonName( int nButton )
    3139             : {
    3140           0 :     return OUString::createFromAscii(pButtonNames[nButton]);
    3141             : }
    3142             : 
    3143           1 : EasyFile::EasyFile()
    3144             : {
    3145           1 :     pMedium = NULL;
    3146           1 :     pOStm = NULL;
    3147           1 :     bOpen = false;
    3148           1 : }
    3149             : 
    3150           1 : EasyFile::~EasyFile()
    3151             : {
    3152           1 :     if( bOpen )
    3153           0 :         (void)close();
    3154           1 : }
    3155             : 
    3156           1 : sal_uLong EasyFile::createStream(  const OUString& rUrl, SvStream* &rpStr )
    3157             : {
    3158           1 :     sal_uLong nErr = 0;
    3159             : 
    3160           1 :     if(bOpen)
    3161           0 :         nErr = close();
    3162             : 
    3163           1 :     OUString aFileName;
    3164             : 
    3165           1 :     if( nErr == 0 )
    3166           1 :         nErr = createFileName( rUrl, aFileName );
    3167             : 
    3168           1 :     if( nErr == 0 )
    3169             :     {
    3170           1 :         pOStm = ::utl::UcbStreamHelper::CreateStream( aFileName, StreamMode::WRITE | StreamMode::TRUNC );
    3171           1 :         if( pOStm )
    3172             :         {
    3173           1 :             bOpen = true;
    3174           1 :             nErr = pOStm->GetError();
    3175             :         }
    3176             :         else
    3177             :         {
    3178           0 :             nErr = ERRCODE_SFX_CANTCREATECONTENT;
    3179             :         }
    3180             :     }
    3181             : 
    3182           1 :     if( nErr != 0 )
    3183             :     {
    3184           0 :         bOpen = false;
    3185           0 :         delete pMedium;
    3186           0 :         delete pOStm;
    3187           0 :         pOStm = NULL;
    3188             :     }
    3189             : 
    3190           1 :     rpStr = pOStm;
    3191             : 
    3192           1 :     return nErr;
    3193             : }
    3194             : 
    3195           1 : sal_uLong EasyFile::createFileName(  const OUString& rURL, OUString& rFileName )
    3196             : {
    3197           1 :     sal_uLong nErr = 0;
    3198             : 
    3199           1 :     if( bOpen )
    3200           0 :         nErr = close();
    3201             : 
    3202           1 :     if( nErr == 0 )
    3203             :     {
    3204           1 :         INetURLObject aURL( rURL );
    3205             : 
    3206           1 :         if( aURL.GetProtocol() == INetProtocol::NotValid )
    3207             :         {
    3208           0 :             OUString aURLStr;
    3209           0 :             ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rURL, aURLStr );
    3210           0 :             aURL = INetURLObject( aURLStr );
    3211             :         }
    3212             :         DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
    3213           1 :         rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
    3214             :     }
    3215             : 
    3216           1 :     return nErr;
    3217             : }
    3218             : 
    3219           1 : sal_uLong EasyFile::close()
    3220             : {
    3221           1 :     sal_uLong nErr = 0;
    3222             : 
    3223           1 :     delete pOStm;
    3224           1 :     pOStm = NULL;
    3225             : 
    3226           1 :     bOpen = false;
    3227             : 
    3228           1 :     if( pMedium )
    3229             :     {
    3230             :         // transmitted
    3231           0 :         pMedium->Close();
    3232           0 :         pMedium->Commit();
    3233             : 
    3234           0 :         nErr = pMedium->GetError();
    3235             : 
    3236           0 :         delete pMedium;
    3237           0 :         pMedium = NULL;
    3238             :     }
    3239             : 
    3240           1 :     return nErr;
    3241             : }
    3242             : 
    3243             : // This class helps reporting errors during file i/o
    3244           1 : HtmlErrorContext::HtmlErrorContext(vcl::Window *_pWin)
    3245           1 : : ErrorContext(_pWin)
    3246             : {
    3247           1 :     mnResId = 0;
    3248           1 : }
    3249             : 
    3250           0 : bool HtmlErrorContext::GetString( sal_uLong, OUString& rCtxStr )
    3251             : {
    3252             :     DBG_ASSERT( mnResId != 0, "No error context set" );
    3253           0 :     if( mnResId == 0 )
    3254           0 :         return false;
    3255             : 
    3256           0 :     rCtxStr = SdResId( mnResId ).toString();
    3257             : 
    3258           0 :     rCtxStr = rCtxStr.replaceAll( OUString("$(URL1)"), maURL1 );
    3259           0 :     rCtxStr = rCtxStr.replaceAll( OUString("$(URL2)"), maURL2 );
    3260             : 
    3261           0 :     return true;
    3262             : }
    3263             : 
    3264           1 : void HtmlErrorContext::SetContext( sal_uInt16 nResId, const OUString& rURL )
    3265             : {
    3266           1 :     mnResId = nResId;
    3267           1 :     maURL1 = rURL;
    3268           1 :     maURL2.clear();
    3269           1 : }
    3270             : 
    3271           0 : void HtmlErrorContext::SetContext( sal_uInt16 nResId, const OUString& rURL1, const OUString& rURL2 )
    3272             : {
    3273           0 :     mnResId = nResId;
    3274           0 :     maURL1 = rURL1;
    3275           0 :     maURL2 = rURL2;
    3276          66 : }
    3277             : 
    3278             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11