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

Generated by: LCOV version 1.10