1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: htmlex.cxx,v $
10 * $Revision: 1.34.80.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <com/sun/star/document/XExporter.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/document/XFilter.hpp>
39 #include <rtl/uri.hxx>
40 #include <comphelper/processfactory.hxx>
41 #include <osl/file.hxx>
42 #include <tools/fsys.hxx>
43 #include <svtools/pathoptions.hxx>
44 #include <svtools/FilterConfigItem.hxx>
45 #ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX
46 #include <unotools/ucbstreamhelper.hxx>
48 #include <unotools/localfilehelper.hxx>
49 #include <com/sun/star/frame/XStorable.hpp>
50 #include <sfx2/progress.hxx>
51 #include <sfx2/progress.hxx>
52 #include <vcl/wrkwin.hxx>
53 #include <svtools/aeitem.hxx>
54 #include <svx/svditer.hxx>
55 #include <svtools/imaprect.hxx>
56 #include <svtools/imapcirc.hxx>
57 #include <svtools/imappoly.hxx>
58 #include <vcl/msgbox.hxx>
59 #include <sfx2/app.hxx>
60 #include <svx/outlobj.hxx>
61 #include <svx/editobj.hxx>
62 #include <svx/svdopath.hxx>
63 #include <svx/xoutbmp.hxx>
64 #include <svtools/htmlout.hxx>
65 #include <sfx2/docfile.hxx>
66 #include <vcl/cvtgrf.hxx>
67 #include <svtools/colorcfg.hxx>
68 #include <svtools/filter.hxx>
69 #include <svx/colritem.hxx>
70 #include <svx/editeng.hxx>
71 #include <svx/wghtitem.hxx>
72 #include <svx/udlnitem.hxx>
73 #include <svx/postitem.hxx>
74 #include <svx/crsditem.hxx>
75 #include <svx/flditem.hxx>
76 #include <sfx2/dispatch.hxx>
77 #include <sfx2/fcontnr.hxx>
78 #include <svtools/style.hxx>
79 #define _SVSTDARR_USHORTS
80 #include <svtools/svstdarr.hxx>
82 //#include <svx/svdetc.hxx>
84 #include <svx/frmdiritem.hxx>
85 #include <svx/svdoutl.hxx>
86 #include <svx/impgrf.hxx> // FillFilter()
87 #include <tools/urlobj.hxx> // INetURLObject
88 #include <vcl/bmpacc.hxx>
89 #include <svtools/sfxecode.hxx>
90 #include <svx/impgrf.hxx>
91 #include <com/sun/star/beans/PropertyState.hpp>
92 #include <tools/resmgr.hxx>
93 #include "comphelper/anytostring.hxx"
94 #include "cppuhelper/exc_hlp.hxx"
96 #include "drawdoc.hxx"
97 #include "Outliner.hxx"
101 #include "anminfo.hxx"
102 #include "imapinfo.hxx"
103 #include "sdresid.hxx"
104 #include "buttonset.hxx"
105 #include <basegfx/polygon/b2dpolygon.hxx>
107 using ::rtl::OUString
;
108 using ::rtl::OString
;
109 using namespace ::com::sun::star
;
110 using namespace ::com::sun::star::uno
;
111 using namespace ::com::sun::star::beans
;
112 using namespace ::com::sun::star::frame
;
113 using namespace ::com::sun::star::lang
;
114 using namespace ::com::sun::star::document
;
116 #define KEY_QUALITY "JPG-EXPORT-QUALITY"
118 // Parameter aus Itemset abfragen
120 #define RESTOHTML( res ) StringToHTMLString(String(SdResId(res)))
121 #define S2H( str ) StringToHTMLString( str )
123 // bei Aenderungen auch NUM_BUTTONS in pubdlg.hxx aendern!!
124 const char *pButtonNames
[NUM_BUTTONS
] =
126 "first-inactive.png",
130 "right-inactive.png",
140 #define BTN_FIRST_0 0
141 #define BTN_FIRST_1 1
154 #define CALC_OPTIONS "9,34,SYSTEM"
156 // *********************************************************************
157 // Hilfsklasse fuer das simple erzeugen von Dateien lokal/remote
158 // *********************************************************************
171 ULONG
createStream( const String
& rUrl
, SvStream
*& rpStr
);
172 ULONG
createFileName( const String
& rUrl
, String
& rFileName
);
176 // *********************************************************************
177 // Hilfsklasse fuer das einbinden von Textattributen in die Html-Ausgabe
178 // *********************************************************************
194 HtmlState( Color aDefColor
);
196 String
SetWeight( bool bWeight
);
197 String
SetItalic( bool bItalic
);
198 String
SetUnderline( bool bUnderline
);
199 String
SetColor( Color aColor
);
200 String
SetStrikeout( bool bStrike
);
201 String
SetLink( const String
& aLink
, const String
& aTarget
);
205 // =====================================================================
206 // alle noch offennen Tags schliessen
207 // =====================================================================
208 String
HtmlState::Flush()
212 aStr
+= SetWeight(false);
213 aStr
+= SetItalic(false);
214 aStr
+= SetUnderline(false);
215 aStr
+= SetStrikeout(false);
216 aStr
+= SetColor(maDefColor
);
217 aStr
+= SetLink(aEmpty
,aEmpty
);
222 // =====================================================================
223 // c'tor mit Defaultfarbe fuer die Seite
224 // =====================================================================
225 HtmlState::HtmlState( Color aDefColor
)
233 maDefColor
= aDefColor
;
236 // =====================================================================
237 // aktiviert/deaktiviert Fettdruck
238 // =====================================================================
239 String
HtmlState::SetWeight( bool bWeight
)
243 if(bWeight
&& !mbWeight
)
244 aStr
.AppendAscii( "<b>" );
245 else if(!bWeight
&& mbWeight
)
246 aStr
.AppendAscii( "</b>" );
252 // =====================================================================
253 // aktiviert/deaktiviert Italic
254 // =====================================================================
255 String
HtmlState::SetItalic( bool bItalic
)
259 if(bItalic
&& !mbItalic
)
260 aStr
.AppendAscii( "<i>" );
261 else if(!bItalic
&& mbItalic
)
262 aStr
.AppendAscii( "</i>" );
268 // =====================================================================
269 // aktiviert/deaktiviert Unterstrichen
270 // =====================================================================
271 String
HtmlState::SetUnderline( bool bUnderline
)
275 if(bUnderline
&& !mbUnderline
)
276 aStr
.AppendAscii( "<u>" );
277 else if(!bUnderline
&& mbUnderline
)
278 aStr
.AppendAscii( "</u>" );
280 mbUnderline
= bUnderline
;
284 // =====================================================================
285 // aktiviert/deaktiviert Durchstreichen
286 // =====================================================================
287 String
HtmlState::SetStrikeout( bool bStrike
)
291 if(bStrike
&& !mbStrike
)
292 aStr
.AppendAscii( "<strike>" );
293 else if(!bStrike
&& mbStrike
)
294 aStr
.AppendAscii( "</strike>" );
300 // =====================================================================
301 // Setzt die angegebenne Textfarbe
302 // =====================================================================
303 String
HtmlState::SetColor( Color aColor
)
307 if(mbColor
&& aColor
== maColor
)
312 aStr
.AppendAscii( "</font>" );
316 if(aColor
!= maDefColor
)
320 aStr
.AppendAscii( "<font color=\"" );
321 aStr
+= HtmlExport::ColorToHTMLString(aColor
);
322 aStr
.AppendAscii( "\">" );
330 // =====================================================================
331 // aktiviert/deaktiviert einen Hyperlink
332 // =====================================================================
333 String
HtmlState::SetLink( const String
& aLink
, const String
& aTarget
)
337 if(mbLink
&&maLink
== aLink
&&maTarget
==aTarget
)
342 aStr
.AppendAscii( "</a>" );
348 aStr
.AppendAscii( "<a href=\"" );
349 aStr
+= HtmlExport::StringToURL(aLink
);
352 aStr
.AppendAscii( "\" target=\"" );
355 aStr
.AppendAscii( "\">" );
364 // *********************************************************************
365 // class HtmlExport Methoden
366 // *********************************************************************
368 static String
getParagraphStyle( SdrOutliner
* pOutliner
, USHORT nPara
)
370 SfxItemSet
aParaSet( pOutliner
->GetParaAttribs( nPara
) );
372 String
sStyle( RTL_CONSTASCII_USTRINGPARAM("direction:") );
373 if( static_cast<const SvxFrameDirectionItem
*>(aParaSet
.GetItem( EE_PARA_WRITINGDIR
))->GetValue() == FRMDIR_HORI_RIGHT_TOP
)
375 sStyle
+= String( RTL_CONSTASCII_USTRINGPARAM("rtl;") );
379 sStyle
+= String( RTL_CONSTASCII_USTRINGPARAM("ltr;") );
384 // =====================================================================
385 // Konstruktor fuer die Html Export Hilfsklasse
386 // =====================================================================
387 HtmlExport::HtmlExport(
389 const Sequence
< PropertyValue
>& rParams
,
390 SdDrawDocument
* pExpDoc
,
391 ::sd::DrawDocShell
* pDocShell
)
394 mpDocSh( pDocShell
),
396 meMode( PUBLISH_HTML
),
397 mbContentsPage(false),
399 mnWidthPixel( PUB_LOWRES_WIDTH
),
400 meFormat( FORMAT_JPG
),
405 mbHiddenSlides(true),
408 maHTMLExtension(SdResId(STR_HTMLEXP_DEFAULT_EXTENSION
)),
413 maIndexUrl(RTL_CONSTASCII_USTRINGPARAM("index")),
414 meScript( SCRIPT_ASP
),
415 maHTMLHeader( RTL_CONSTASCII_USTRINGPARAM(
416 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\r\n"
417 " \"http://www.w3.org/TR/html4/transitional.dtd\">\r\n"
418 "<html>\r\n<head>\r\n" ) ),
419 mpButtonSet( new ButtonSet() )
421 bool bChange
= mpDoc
->IsChanged();
423 maIndexUrl
+= maHTMLExtension
;
425 InitExportParameters( rParams
);
433 case PUBLISH_WEBCAST
:
441 mpDoc
->SetChanged(bChange
);
444 HtmlExport::~HtmlExport()
446 // ------------------------------------------------------------------
448 // ------------------------------------------------------------------
449 if(mpImageFiles
&& mpHTMLFiles
&& mpPageNames
&& mpTextFiles
)
451 for ( USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
; nSdPage
++)
453 delete mpImageFiles
[nSdPage
];
454 delete mpHTMLFiles
[nSdPage
];
455 delete mpPageNames
[nSdPage
];
456 delete mpTextFiles
[nSdPage
];
460 delete[] mpImageFiles
;
461 delete[] mpHTMLFiles
;
462 delete[] mpPageNames
;
463 delete[] mpTextFiles
;
466 /** get common export parameters from item set */
467 void HtmlExport::InitExportParameters( const Sequence
< PropertyValue
>& rParams
)
469 mbImpress
= mpDoc
&& mpDoc
->GetDocumentType() == DOCUMENT_TYPE_IMPRESS
;
471 sal_Int32 nArgs
= rParams
.getLength();
472 const PropertyValue
* pParams
= rParams
.getConstArray();
476 if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PublishMode" ) ) )
479 pParams
->Value
>>= temp
;
480 meMode
= (HtmlPublishMode
)temp
;
482 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IndexURL" ) ) )
484 pParams
->Value
>>= aStr
;
487 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Format" ) ) )
490 pParams
->Value
>>= temp
;
491 meFormat
= (PublishingFormat
)temp
;
493 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Compression" ) ) )
495 pParams
->Value
>>= aStr
;
499 xub_StrLen nPos
= aTmp
.Search( '%' );
500 if(nPos
!= STRING_NOTFOUND
)
502 mnCompression
= (INT16
)aTmp
.ToInt32();
505 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Width" ) ) )
508 pParams
->Value
>>= temp
;
509 mnWidthPixel
= (sal_uInt16
)temp
;
511 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "UseButtonSet" ) ) )
514 pParams
->Value
>>= temp
;
515 mnButtonThema
= (sal_Int16
)temp
;
517 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsExportNotes" ) ) )
521 sal_Bool temp
= sal_False
;
522 pParams
->Value
>>= temp
;
526 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsExportContentsPage" ) ) )
528 sal_Bool temp
= sal_False
;
529 pParams
->Value
>>= temp
;
530 mbContentsPage
= temp
;
532 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Author" ) ) )
534 pParams
->Value
>>= aStr
;
537 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "EMail" ) ) )
539 pParams
->Value
>>= aStr
;
542 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "HomepageURL" ) ) )
544 pParams
->Value
>>= aStr
;
547 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "UserText" ) ) )
549 pParams
->Value
>>= aStr
;
552 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "EnableDownload" ) ) )
554 sal_Bool temp
= sal_False
;
555 pParams
->Value
>>= temp
;
558 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SlideSound" ) ) )
560 sal_Bool temp
= sal_True
;
561 pParams
->Value
>>= temp
;
564 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "HiddenSlides" ) ) )
566 sal_Bool temp
= sal_True
;
567 pParams
->Value
>>= temp
;
568 mbHiddenSlides
= temp
;
570 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BackColor" ) ) )
573 pParams
->Value
>>= temp
;
577 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "TextColor" ) ) )
580 pParams
->Value
>>= temp
;
584 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "LinkColor" ) ) )
587 pParams
->Value
>>= temp
;
591 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VLinkColor" ) ) )
594 pParams
->Value
>>= temp
;
598 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ALinkColor" ) ) )
601 pParams
->Value
>>= temp
;
605 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsUseDocumentColors" ) ) )
607 sal_Bool temp
= sal_False
;
608 pParams
->Value
>>= temp
;
611 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "KioskSlideDuration" ) ) )
613 sal_Int32 temp
= sal_False
;
614 pParams
->Value
>>= temp
;
615 mnSlideDuration
= temp
;
618 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "KioskEndless" ) ) )
620 sal_Bool temp
= sal_False
;
621 pParams
->Value
>>= temp
;
624 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "WebCastCGIURL" ) ) )
626 pParams
->Value
>>= aStr
;
629 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "WebCastTargetURL" ) ) )
631 pParams
->Value
>>= aStr
;
634 else if( pParams
->Name
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "WebCastScriptLanguage" ) ) )
636 pParams
->Value
>>= aStr
;
637 if( aStr
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "asp" ) ) )
639 meScript
= SCRIPT_ASP
;
643 meScript
= SCRIPT_PERL
;
648 DBG_ERROR("Unknown property for html export detected!");
654 if( meMode
== PUBLISH_KIOSK
)
656 mbContentsPage
= false;
661 // calculate image sizes
662 SdPage
* pPage
= mpDoc
->GetSdPage(0, PK_STANDARD
);
663 Size
aTmpSize( pPage
->GetSize() );
664 double dRatio
=((double)aTmpSize
.Width())/aTmpSize
.Height();
667 switch( mnWidthPixel )
681 mnHeightPixel
= (USHORT
)(mnWidthPixel
/dRatio
);
683 //------------------------------------------------------------------
684 // Ziel ausklamuestern...
686 INetURLObject
aINetURLObj( maPath
);
687 DBG_ASSERT( aINetURLObj
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
689 maExportPath
= aINetURLObj
.GetPartBeforeLastName(); // with trailing '/'
690 maIndex
= aINetURLObj
.GetLastName();
692 mnSdPageCount
= mpDoc
->GetSdPageCount( PK_STANDARD
);
693 // USHORT nHiddenSlides = 0;
694 for( USHORT nPage
= 0; nPage
< mnSdPageCount
; nPage
++ )
696 pPage
= mpDoc
->GetSdPage( nPage
, PK_STANDARD
);
698 if( mbHiddenSlides
|| !pPage
->IsExcluded() )
700 maPages
.push_back( pPage
);
701 maNotesPages
.push_back( mpDoc
->GetSdPage( nPage
, PK_NOTES
) );
704 mnSdPageCount
= maPages
.size();
706 mbFrames
= meMode
== PUBLISH_FRAMES
;
708 maDocFileName
= maIndex
;
711 ///////////////////////////////////////////////////////////////////////
712 // Exportiert das im Konstruktor angegebenne Impress Dokument nach HTML
713 ///////////////////////////////////////////////////////////////////////
714 void HtmlExport::ExportHtml()
718 if( maTextColor
== COL_AUTO
)
720 if( !maBackColor
.IsDark() )
721 maTextColor
= COL_BLACK
;
724 else if( mbDocColors
)
726 // Standard Farben fuer das Farbschema 'Aus Dokument'
728 maFirstPageColor
= maBackColor
;
731 // get name for downloadable presentation if needed
734 // Separator such und Extension ausblenden
735 USHORT nSepPos
= maDocFileName
.Search( sal_Unicode('.') );
737 if(nSepPos
!= STRING_NOTFOUND
)
738 maDocFileName
.Erase(nSepPos
);
740 maDocFileName
.AppendAscii( ".odp" );
745 USHORT nProgrCount
= mnSdPageCount
;
746 nProgrCount
+= mbImpress
?mnSdPageCount
:0;
747 nProgrCount
+= mbContentsPage
?1:0;
748 nProgrCount
+= (mbFrames
&& mbNotes
)?mnSdPageCount
:0;
749 nProgrCount
+= (mbFrames
)?8:0;
750 InitProgress( nProgrCount
);
752 mpDocSh
->SetWaitCursor( true );
754 //------------------------------------------------------------------
755 // Exceptions sind doch was schoennes...
759 // this is not a true while
762 if( checkForExistingFiles() )
765 if( !CreateImagesForPresPages() )
768 if( !CreateHtmlForPresPages() )
772 if( !CreateHtmlTextForPresPages() )
777 if( !CreateFrames() )
780 if( !CreateOutlinePages() )
783 if( !CreateNavBarFrames() )
786 if( mbNotes
&& mbImpress
)
787 if( !CreateNotesPages() )
793 if( !CreateContentPage() )
796 if( !CreateBitmaps() )
799 mpDocSh
->SetWaitCursor( false );
808 // if we get to this point the export was
809 // canceled by the user after an error
810 mpDocSh
->SetWaitCursor( false );
814 ///////////////////////////////////////////////////////////////////////
816 void HtmlExport::SetDocColors( SdPage
* pPage
)
819 pPage
= mpDoc
->GetSdPage(0, PK_STANDARD
);
821 svtools::ColorConfig aConfig
;
822 maVLinkColor
= Color(aConfig
.GetColorValue(svtools::LINKSVISITED
).nColor
);
823 maALinkColor
= Color(aConfig
.GetColorValue(svtools::LINKS
).nColor
);
824 maLinkColor
= Color(aConfig
.GetColorValue(svtools::LINKS
).nColor
);
825 maTextColor
= Color(COL_BLACK
);
827 SfxStyleSheet
* pSheet
= NULL
;
829 if( mpDoc
->GetDocumentType() == DOCUMENT_TYPE_IMPRESS
)
831 // Standard Textfarbe aus Outline-Vorlage der ersten Seite
832 pSheet
= pPage
->GetStyleSheetForPresObj(PRESOBJ_OUTLINE
);
834 pSheet
= pPage
->GetStyleSheetForPresObj(PRESOBJ_TEXT
);
836 pSheet
= pPage
->GetStyleSheetForPresObj(PRESOBJ_TITLE
);
840 pSheet
= mpDoc
->GetDefaultStyleSheet();
844 SfxItemSet
& rSet
= pSheet
->GetItemSet();
845 if(rSet
.GetItemState(EE_CHAR_COLOR
,TRUE
) == SFX_ITEM_ON
)
846 maTextColor
= ((SvxColorItem
*)rSet
.GetItem(EE_CHAR_COLOR
,TRUE
))->GetValue();
849 // Standard Hintergrundfarbe aus Background der MasterPage der ersten Seite
850 maBackColor
= pPage
->GetPageBackgroundColor();
852 if( maTextColor
== COL_AUTO
)
854 if( !maBackColor
.IsDark() )
855 maTextColor
= COL_BLACK
;
859 ///////////////////////////////////////////////////////////////////////
861 void HtmlExport::InitProgress( USHORT nProgrCount
)
863 String
aStr(SdResId(STR_CREATE_PAGES
));
864 mpProgress
= new SfxProgress( mpDocSh
, aStr
, nProgrCount
);
867 ///////////////////////////////////////////////////////////////////////
869 void HtmlExport::ResetProgress()
875 ///////////////////////////////////////////////////////////////////////
877 void HtmlExport::ExportKiosk()
880 InitProgress( 2*mnSdPageCount
);
883 if( !checkForExistingFiles() )
885 if( CreateImagesForPresPages() )
886 CreateHtmlForPresPages();
892 ///////////////////////////////////////////////////////////////////////
893 // Export Document with WebCast (TM) Technology
894 ///////////////////////////////////////////////////////////////////////
895 void HtmlExport::ExportWebCast()
898 InitProgress( mnSdPageCount
+ 9 );
900 mpDocSh
->SetWaitCursor( TRUE
);
905 if(maCGIPath
.Len() == 0)
906 maCGIPath
.Assign( sal_Unicode('.') );
908 if( maCGIPath
.GetChar( maCGIPath
.Len() - 1 ) != sal_Unicode('/') )
909 maCGIPath
.Append( sal_Unicode('/') );
911 if( meScript
== SCRIPT_ASP
)
913 maURLPath
.AssignAscii( "./" );
918 if(maURLPath
.Len() == 0)
919 maURLPath
.Assign( sal_Unicode('.') );
921 if( maURLPath
.GetChar( maURLPath
.Len() - 1 ) != sal_Unicode('/') )
922 maURLPath
.Append( sal_Unicode('/') );
925 // this is not a true while
928 if( checkForExistingFiles() )
931 if(!CreateImagesForPresPages())
934 if( meScript
== SCRIPT_ASP
)
936 if(!CreateASPScripts())
941 if(!CreatePERLScripts())
945 if(!CreateImageFileList())
948 if(!CreateImageNumberFile())
954 mpDocSh
->SetWaitCursor( false );
958 ///////////////////////////////////////////////////////////////////////
959 // Save the presentation as a downloadable file in the dest directory
960 ///////////////////////////////////////////////////////////////////////
962 bool HtmlExport::SavePresentation()
964 meEC
.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE
, maDocFileName
);
966 OUString
aURL( maExportPath
);
967 aURL
+= maDocFileName
;
970 mpDocSh
->EnableSetModified( true );
974 uno::Reference
< frame::XStorable
> xStorable( mpDoc
->getUnoModel(), uno::UNO_QUERY
);
977 uno::Sequence
< beans::PropertyValue
> aProperties( 2 );
978 aProperties
[ 0 ].Name
= OUString(RTL_CONSTASCII_USTRINGPARAM("Overwrite"));
979 aProperties
[ 0 ].Value
<<= (sal_Bool
)sal_True
;
980 aProperties
[ 1 ].Name
= OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName"));
981 aProperties
[ 1 ].Value
<<= OUString(RTL_CONSTASCII_USTRINGPARAM("impress8"));
982 xStorable
->storeToURL( aURL
, aProperties
);
984 mpDocSh
->EnableSetModified( false );
993 mpDocSh
->EnableSetModified( false );
998 // =====================================================================
999 // Image-Dateien anlegen
1000 // =====================================================================
1001 bool HtmlExport::CreateImagesForPresPages()
1005 Reference
< XMultiServiceFactory
> xMSF( ::comphelper::getProcessServiceFactory() );
1009 Reference
< XExporter
> xGraphicExporter( xMSF
->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicExportFilter") ) ), UNO_QUERY
);
1010 Reference
< XFilter
> xFilter( xGraphicExporter
, UNO_QUERY
);
1012 DBG_ASSERT( xFilter
.is(), "no com.sun.star.drawing.GraphicExportFilter?" );
1016 Sequence
< PropertyValue
> aFilterData(((meFormat
==FORMAT_JPG
)&&(mnCompression
!= -1))? 3 : 2);
1017 aFilterData
[0].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("PixelWidth") );
1018 aFilterData
[0].Value
<<= (sal_Int32
)mnWidthPixel
;
1019 aFilterData
[1].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("PixelHeight") );
1020 aFilterData
[1].Value
<<= (sal_Int32
)mnHeightPixel
;
1021 if((meFormat
==FORMAT_JPG
)&&(mnCompression
!= -1))
1023 aFilterData
[2].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("Quality") );
1024 aFilterData
[2].Value
<<= (sal_Int32
)mnCompression
;
1027 Sequence
< PropertyValue
> aDescriptor( 3 );
1028 aDescriptor
[0].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("URL") );
1029 aDescriptor
[1].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("FilterName") );
1031 if( meFormat
== FORMAT_PNG
)
1032 sFormat
= OUString( RTL_CONSTASCII_USTRINGPARAM("PNG") );
1033 else if( meFormat
== FORMAT_GIF
)
1034 sFormat
= OUString( RTL_CONSTASCII_USTRINGPARAM("GIF") );
1036 sFormat
= OUString( RTL_CONSTASCII_USTRINGPARAM("JPG") );
1038 aDescriptor
[1].Value
<<= sFormat
;
1039 aDescriptor
[2].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("FilterData") );
1040 aDescriptor
[2].Value
<<= aFilterData
;
1042 for (USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
; nSdPage
++)
1044 SdPage
* pPage
= maPages
[ nSdPage
];
1046 OUString
aFull(maExportPath
);
1047 aFull
+= *mpImageFiles
[nSdPage
];
1049 aDescriptor
[0].Value
<<= aFull
;
1051 Reference
< XComponent
> xPage( pPage
->getUnoPage(), UNO_QUERY
);
1052 xGraphicExporter
->setSourceDocument( xPage
);
1053 xFilter
->filter( aDescriptor
);
1056 mpProgress
->SetState(++mnPagesWritten
);
1067 // =====================================================================
1068 // Ermittelt das SdrTextObject mit dem Layout Text dieser Seite
1069 // =====================================================================
1070 SdrTextObj
* HtmlExport::GetLayoutTextObject(SdrPage
* pPage
)
1072 ULONG nObjectCount
= pPage
->GetObjCount();
1073 SdrObject
* pObject
= NULL
;
1074 SdrTextObj
* pResult
= NULL
;
1076 for (ULONG nObject
= 0; nObject
< nObjectCount
; nObject
++)
1078 pObject
= pPage
->GetObj(nObject
);
1079 if (pObject
->GetObjInventor() == SdrInventor
&&
1080 pObject
->GetObjIdentifier() == OBJ_OUTLINETEXT
)
1082 pResult
= (SdrTextObj
*)pObject
;
1089 // =====================================================================
1090 // HTML-Text Versionen fuer Impress Seiten erzeugen
1091 // =====================================================================
1093 String
HtmlExport::WriteMetaCharset() const
1096 const sal_Char
*pCharSet
= rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8
);
1099 aStr
.AppendAscii( " <meta HTTP-EQUIV=CONTENT-TYPE CONTENT=\"text/html; charset=" );
1100 aStr
.AppendAscii( pCharSet
);
1101 aStr
.AppendAscii( "\">\r\n" );
1106 bool HtmlExport::CreateHtmlTextForPresPages()
1110 SdrOutliner
* pOutliner
= mpDoc
->GetInternalOutliner();
1112 for(USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
&& bOk
; nSdPage
++)
1114 SdPage
* pPage
= maPages
[ nSdPage
];
1118 SetDocColors( pPage
);
1119 // maBackColor = pPage->GetPageBackgroundColor();
1123 String
aStr(maHTMLHeader
);
1124 aStr
+= WriteMetaCharset();
1125 aStr
.AppendAscii( " <title>" );
1126 aStr
+= StringToHTMLString( *mpPageNames
[nSdPage
] );
1127 aStr
.AppendAscii( "</title>\r\n" );
1128 aStr
.AppendAscii( "</head>\r\n" );
1129 aStr
+= CreateBodyTag();
1131 // Navigationsleiste
1132 aStr
+= CreateNavBar(nSdPage
, true);
1135 String
sTitleText( CreateTextForTitle(pOutliner
,pPage
, pPage
->GetPageBackgroundColor()) );
1136 aStr
.AppendAscii( "<h1 style=\"");
1137 aStr
.Append( getParagraphStyle( pOutliner
, 0 ) );
1138 aStr
.AppendAscii( "\">" );
1140 aStr
.AppendAscii( "</h1>\r\n" );
1142 // Gliederungstext schreiben
1143 aStr
+= CreateTextForPage( pOutliner
, pPage
, true, pPage
->GetPageBackgroundColor() );
1148 SdPage
* pNotesPage
= maNotesPages
[ nSdPage
];
1149 String
aNotesStr( CreateTextForNotesPage( pOutliner
, pNotesPage
, true, maBackColor
) );
1151 if( aNotesStr
.Len() )
1153 aStr
.AppendAscii( "<br>\r\n<h3>" );
1154 aStr
+= RESTOHTML(STR_HTMLEXP_NOTES
);
1155 aStr
.AppendAscii( ":</h3>\r\n" );
1162 aStr
.AppendAscii( "</body>\r\n</html>" );
1164 bOk
= WriteHtml( *mpTextFiles
[nSdPage
], false, aStr
);
1167 mpProgress
->SetState(++mnPagesWritten
);
1176 /** exports the given html data into a non unicode file in the current export path with
1177 the given filename */
1178 bool HtmlExport::WriteHtml( const String
& rFileName
, bool bAddExtension
, const String
& rHtmlData
)
1182 String
aFileName( rFileName
);
1184 aFileName
+= maHTMLExtension
;
1186 meEC
.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE
, rFileName
);
1189 String
aFull( maExportPath
);
1191 nErr
= aFile
.createStream(aFull
, pStr
);
1194 ByteString
aStr( rHtmlData
, RTL_TEXTENCODING_UTF8
) ;
1195 *pStr
<< aStr
.GetBuffer();
1196 nErr
= aFile
.close();
1200 ErrorHandler::HandleError(nErr
);
1205 // =====================================================================
1207 /** Erzeugt den Outliner Text fuer das Titelobjekt einer Seite
1209 String
HtmlExport::CreateTextForTitle( SdrOutliner
* pOutliner
, SdPage
* pPage
, const Color
& rBackgroundColor
)
1211 SdrTextObj
* pTO
= (SdrTextObj
*)pPage
->GetPresObj(PRESOBJ_TITLE
);
1213 pTO
= GetLayoutTextObject(pPage
);
1215 if (pTO
&& !pTO
->IsEmptyPresObj())
1217 OutlinerParaObject
* pOPO
= pTO
->GetOutlinerParaObject();
1218 if(pOPO
&& pOutliner
->GetParagraphCount() != 0)
1221 pOutliner
->SetText(*pOPO
);
1222 return ParagraphToHTMLString(pOutliner
,0, rBackgroundColor
);
1229 // =====================================================================
1230 // Erzeugt den Outliner Text fuer eine Seite
1231 // =====================================================================
1232 String
HtmlExport::CreateTextForPage( SdrOutliner
* pOutliner
,
1234 bool bHeadLine
, const Color
& rBackgroundColor
)
1238 SdrTextObj
* pTO
= (SdrTextObj
*)pPage
->GetPresObj(PRESOBJ_TEXT
);
1240 pTO
= GetLayoutTextObject(pPage
);
1242 if (pTO
&& !pTO
->IsEmptyPresObj())
1244 OutlinerParaObject
* pOPO
= pTO
->GetOutlinerParaObject();
1248 pOutliner
->SetText( *pOPO
);
1250 ULONG nCount
= pOutliner
->GetParagraphCount();
1252 Paragraph
* pPara
= NULL
;
1253 sal_Int16 nActDepth
= -1;
1256 for (ULONG nPara
= 0; nPara
< nCount
; nPara
++)
1258 pPara
= pOutliner
->GetParagraph(nPara
);
1262 const sal_Int16 nDepth
= (USHORT
) pOutliner
->GetDepth( (USHORT
) nPara
);
1263 aParaText
= ParagraphToHTMLString(pOutliner
,nPara
,rBackgroundColor
);
1265 if(aParaText
.Len() == 0)
1268 if(nDepth
< nActDepth
)
1272 aStr
.AppendAscii( "</ul>" );
1275 while(nDepth
< nActDepth
);
1277 else if(nDepth
> nActDepth
)
1281 aStr
.AppendAscii( "<ul>" );
1284 while( nDepth
> nActDepth
);
1287 String
sStyle( getParagraphStyle( pOutliner
, nPara
) );
1290 aStr
.AppendAscii( "<li style=\"");
1291 aStr
.Append( sStyle
);
1292 aStr
.AppendAscii( "\">" );
1295 if(nActDepth
<= 0 && bHeadLine
)
1297 if( nActDepth
== 0 )
1299 aStr
.AppendAscii( "<h2>" );
1303 aStr
.AppendAscii( "<h2 style=\"");
1304 aStr
.Append( sStyle
);
1305 aStr
.AppendAscii( "\">" );
1309 if(nActDepth
== 0 && bHeadLine
)
1310 aStr
.AppendAscii( "</h2>" );
1312 aStr
.AppendAscii( "</li>" );
1313 aStr
.AppendAscii( "\r\n" );
1316 while( nActDepth
>= 0 )
1318 aStr
.AppendAscii( "</ul>" );
1327 // =====================================================================
1328 // Erzeugt den Outliner Text fuer eine Notizseite
1329 // =====================================================================
1330 String
HtmlExport::CreateTextForNotesPage( SdrOutliner
* pOutliner
,
1333 const Color
& rBackgroundColor
)
1337 SdrTextObj
* pTO
= (SdrTextObj
*)pPage
->GetPresObj(PRESOBJ_NOTES
);
1339 if (pTO
&& !pTO
->IsEmptyPresObj())
1341 OutlinerParaObject
* pOPO
= pTO
->GetOutlinerParaObject();
1345 pOutliner
->SetText( *pOPO
);
1347 ULONG nCount
= pOutliner
->GetParagraphCount();
1348 for (ULONG nPara
= 0; nPara
< nCount
; nPara
++)
1350 aStr
.AppendAscii("<p style=\"");
1351 aStr
.Append( getParagraphStyle( pOutliner
, nPara
) );
1352 aStr
.AppendAscii("\">");
1353 aStr
+= ParagraphToHTMLString( pOutliner
, nPara
,rBackgroundColor
);
1354 aStr
.AppendAscii( "</p>\r\n" );
1362 // =====================================================================
1363 // Wandelt einen Paragraphen des Outliners in Html
1364 // =====================================================================
1365 String
HtmlExport::ParagraphToHTMLString( SdrOutliner
* pOutliner
, ULONG nPara
, const Color
& rBackgroundColor
)
1369 if(NULL
== pOutliner
)
1373 EditEngine
& rEditEngine
= *(EditEngine
*)&pOutliner
->GetEditEngine();
1374 bool bOldUpdateMode
= rEditEngine
.GetUpdateMode();
1375 rEditEngine
.SetUpdateMode(TRUE
);
1377 Paragraph
* pPara
= pOutliner
->GetParagraph(nPara
);
1381 HtmlState
aState( (mbUserAttr
|| mbDocColors
) ? maTextColor
: Color(COL_BLACK
) );
1382 SvUShorts aPortionList
;
1383 rEditEngine
.GetPortions( (USHORT
) nPara
, aPortionList
);
1384 USHORT nPortionCount
= aPortionList
.Count();
1387 for( USHORT nPortion
= 0; nPortion
< nPortionCount
; nPortion
++ )
1389 USHORT nPos2
= aPortionList
.GetObject(nPortion
);
1391 ESelection
aSelection( (USHORT
) nPara
, nPos1
, (USHORT
) nPara
, nPos2
);
1393 SfxItemSet
aSet( rEditEngine
.GetAttribs( aSelection
) );
1395 String
aPortion(StringToHTMLString(rEditEngine
.GetText( aSelection
)));
1397 aStr
+= TextAttribToHTMLString( &aSet
, &aState
, rBackgroundColor
);
1402 aStr
+= aState
.Flush();
1403 rEditEngine
.SetUpdateMode(bOldUpdateMode
);
1408 // =====================================================================
1409 // Erzeugt anhand der Attribute im angegebennen Set und dem gegebennen
1410 // HtmlState die noetigen Html-Tags um die Attribute zu uebernehmen
1411 // =====================================================================
1412 String
HtmlExport::TextAttribToHTMLString( SfxItemSet
* pSet
, HtmlState
* pState
, const Color
& rBackgroundColor
)
1419 String aLink
, aTarget
;
1420 if ( pSet
->GetItemState( EE_FEATURE_FIELD
) == SFX_ITEM_ON
)
1422 SvxFieldItem
* pItem
= (SvxFieldItem
*)pSet
->GetItem( EE_FEATURE_FIELD
);
1425 SvxURLField
* pURL
= PTR_CAST(SvxURLField
, pItem
->GetField());
1428 aLink
= pURL
->GetURL();
1429 aTarget
= pURL
->GetTargetFrame();
1437 if ( pSet
->GetItemState( EE_CHAR_WEIGHT
) == SFX_ITEM_ON
)
1439 bTemp
= ((const SvxWeightItem
&)pSet
->Get( EE_CHAR_WEIGHT
)).GetWeight() == WEIGHT_BOLD
;
1440 aTemp
= pState
->SetWeight( bTemp
);
1442 aStr
.Insert( aTemp
, 0 );
1447 if ( pSet
->GetItemState( EE_CHAR_UNDERLINE
) == SFX_ITEM_ON
)
1449 bTemp
= ((const SvxUnderlineItem
&)pSet
->Get( EE_CHAR_UNDERLINE
)).GetLineStyle() != UNDERLINE_NONE
;
1450 aTemp
= pState
->SetUnderline( bTemp
);
1452 aStr
.Insert( aTemp
, 0 );
1457 if ( pSet
->GetItemState( EE_CHAR_STRIKEOUT
) == SFX_ITEM_ON
)
1459 bTemp
= ((const SvxCrossedOutItem
&)pSet
->Get( EE_CHAR_STRIKEOUT
)).GetStrikeout() != STRIKEOUT_NONE
;
1460 aTemp
= pState
->SetStrikeout( bTemp
);
1462 aStr
.Insert( aTemp
, 0 );
1467 if ( pSet
->GetItemState( EE_CHAR_ITALIC
) == SFX_ITEM_ON
)
1469 bTemp
= ((const SvxPostureItem
&)pSet
->Get( EE_CHAR_ITALIC
)).GetPosture() != ITALIC_NONE
;
1470 aTemp
= pState
->SetItalic( bTemp
);
1472 aStr
.Insert( aTemp
, 0 );
1479 if ( pSet
->GetItemState( EE_CHAR_COLOR
) == SFX_ITEM_ON
)
1481 Color aTextColor
= ((const SvxColorItem
&) pSet
->Get( EE_CHAR_COLOR
)).GetValue();
1482 if( aTextColor
== COL_AUTO
)
1484 if( !rBackgroundColor
.IsDark() )
1485 aTextColor
= COL_BLACK
;
1487 aStr
+= pState
->SetColor( aTextColor
);
1492 aStr
.Insert( pState
->SetLink(aLink
, aTarget
), 0 );
1494 aStr
+= pState
->SetLink(aLink
, aTarget
);
1499 // =====================================================================
1500 // HTML-Wrapper fuer Bild-Dateien erzeugen
1501 // =====================================================================
1502 bool HtmlExport::CreateHtmlForPresPages()
1506 List aClickableObjects
;
1508 for(USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
&& bOk
; nSdPage
++)
1510 // Klickbare Objekte finden (auch auf der Masterpage) und
1511 // in Liste stellen. In umgekehrter Zeichenreihenfolge in
1512 // die Liste stellen, da in HTML bei Ueberlappungen die
1513 // _erstgenannte_ Area wirkt.
1515 SdPage
* pPage
= maPages
[ nSdPage
];
1519 SetDocColors( pPage
);
1522 bool bMasterDone
= false;
1524 while (!bMasterDone
)
1526 // TRUE = rueckwaerts
1527 SdrObjListIter
aIter(*pPage
, IM_DEEPWITHGROUPS
, TRUE
);
1529 SdrObject
* pObject
= aIter
.Next();
1532 SdAnimationInfo
* pInfo
= mpDoc
->GetAnimationInfo(pObject
);
1533 SdIMapInfo
* pIMapInfo
= mpDoc
->GetIMapInfo(pObject
);
1536 (pInfo
->meClickAction
== presentation::ClickAction_BOOKMARK
||
1537 pInfo
->meClickAction
== presentation::ClickAction_DOCUMENT
||
1538 pInfo
->meClickAction
== presentation::ClickAction_PREVPAGE
||
1539 pInfo
->meClickAction
== presentation::ClickAction_NEXTPAGE
||
1540 pInfo
->meClickAction
== presentation::ClickAction_FIRSTPAGE
||
1541 pInfo
->meClickAction
== presentation::ClickAction_LASTPAGE
)) ||
1544 aClickableObjects
.Insert(pObject
, LIST_APPEND
);
1547 pObject
= aIter
.Next();
1549 // jetzt zur Masterpage oder beenden
1550 if (!pPage
->IsMasterPage())
1551 pPage
= (SdPage
*)(&(pPage
->TRG_GetMasterPage()));
1555 ULONG nClickableObjectCount
= aClickableObjects
.Count();
1558 String
aStr(maHTMLHeader
);
1559 aStr
+= WriteMetaCharset();
1560 aStr
.AppendAscii( " <title>" );
1561 aStr
+= StringToHTMLString(*mpPageNames
[nSdPage
]);
1562 aStr
.AppendAscii( "</title>\r\n" );
1564 // insert timing information
1565 pPage
= maPages
[ nSdPage
];
1566 if( meMode
== PUBLISH_KIOSK
)
1569 bool bEndless
= false;
1572 if( pPage
->GetPresChange() != PRESCHANGE_MANUAL
)
1574 nSecs
= pPage
->GetTime();
1575 bEndless
= mpDoc
->getPresentationSettings().mbEndless
;
1580 nSecs
= mnSlideDuration
;
1581 bEndless
= mbEndless
;
1586 if( nSdPage
< (mnSdPageCount
-1) || bEndless
)
1588 aStr
.AppendAscii( "<meta http-equiv=\"refresh\" content=\"" );
1589 aStr
+= String::CreateFromInt32(nSecs
);
1590 aStr
.AppendAscii( "; URL=" );
1592 int nPage
= nSdPage
+ 1;
1593 if( nPage
== mnSdPageCount
)
1596 aStr
+= StringToURL(*mpHTMLFiles
[nPage
]);
1598 aStr
.AppendAscii( "\">\r\n" );
1603 aStr
.AppendAscii( "</head>\r\n" );
1606 aStr
+= CreateBodyTag();
1608 if( mbSlideSound
&& pPage
->IsSoundOn() )
1609 aStr
+= InsertSound( pPage
->GetSoundFile() );
1611 // Navigationsleiste
1613 aStr
+= CreateNavBar( nSdPage
, false );
1615 aStr
.AppendAscii( "<center>" );
1616 aStr
.AppendAscii( "<img src=\"" );
1617 aStr
+= StringToURL( *mpImageFiles
[nSdPage
] );
1618 aStr
.AppendAscii( "\" alt=\"\"" );
1620 if (nClickableObjectCount
> 0)
1621 aStr
.AppendAscii( " USEMAP=\"#map0\"" );
1623 aStr
.AppendAscii( "></center>\r\n" );
1626 if(mbNotes
&& !mbFrames
)
1628 SdrOutliner
* pOutliner
= mpDoc
->GetInternalOutliner();
1629 SdPage
* pNotesPage
= maNotesPages
[ nSdPage
];
1630 String
aNotesStr( CreateTextForNotesPage( pOutliner
, pNotesPage
, true, maBackColor
) );
1633 if( aNotesStr
.Len() )
1635 aStr
.AppendAscii( "<h3>" );
1636 aStr
+= RESTOHTML(STR_HTMLEXP_NOTES
);
1637 aStr
.AppendAscii( ":</h3><br>\r\n\r\n<p>" );
1640 aStr
.AppendAscii( "\r\n</p>\r\n" );
1644 // ggfs. Imagemap erzeugen
1645 if (nClickableObjectCount
> 0)
1647 aStr
.AppendAscii( "<map name=\"map0\">\r\n" );
1649 for (ULONG nObject
= 0; nObject
< nClickableObjectCount
; nObject
++)
1651 SdrObject
* pObject
= (SdrObject
*)aClickableObjects
.GetObject(nObject
);
1652 SdAnimationInfo
* pInfo
= mpDoc
->GetAnimationInfo(pObject
);
1653 SdIMapInfo
* pIMapInfo
= mpDoc
->GetIMapInfo(pObject
);
1655 Rectangle
aRect(pObject
->GetCurrentBoundRect());
1656 Point
aLogPos(aRect
.TopLeft());
1657 bool bIsSquare
= aRect
.GetWidth() == aRect
.GetHeight();
1659 ULONG nPageWidth
= pPage
->GetSize().Width() - pPage
->GetLftBorder() -
1660 pPage
->GetRgtBorder();
1662 // das BoundRect bezieht sich auf den physikalischen
1663 // Seitenursprung, nicht auf den Koordinatenursprung
1664 aRect
.Move(-pPage
->GetLftBorder(), -pPage
->GetUppBorder());
1666 double fLogicToPixel
= ((double)mnWidthPixel
) / nPageWidth
;
1667 aRect
.Left() = (long)(aRect
.Left() * fLogicToPixel
);
1668 aRect
.Top() = (long)(aRect
.Top() * fLogicToPixel
);
1669 aRect
.Right() = (long)(aRect
.Right() * fLogicToPixel
);
1670 aRect
.Bottom() = (long)(aRect
.Bottom() * fLogicToPixel
);
1671 long nRadius
= aRect
.GetWidth() / 2;
1674 /*************************************************************
1675 |* wenn das Objekt eine eigene Imagemap enthaelt, werden ihre
1676 |* Areas in diese Imagemap eingefuegt
1677 \************************************************************/
1680 const ImageMap
& rIMap
= pIMapInfo
->GetImageMap();
1681 UINT16 nAreaCount
= rIMap
.GetIMapObjectCount();
1682 for (UINT16 nArea
= 0; nArea
< nAreaCount
; nArea
++)
1684 IMapObject
* pArea
= rIMap
.GetIMapObject(nArea
);
1685 UINT16 nType
= pArea
->GetType();
1686 String
aURL( pArea
->GetURL() );
1688 // ggfs. Seiten- oder Objektnamen umwandeln in den
1689 // Namen der entsprechenden HTML-Datei
1691 USHORT nPgNum
= mpDoc
->GetPageByName( aURL
, bIsMasterPage
);
1692 SdrObject
* pObj
= NULL
;
1694 if (nPgNum
== SDRPAGE_NOTFOUND
)
1696 // Ist das Bookmark ein Objekt?
1697 pObj
= mpDoc
->GetObj( aURL
);
1699 nPgNum
= pObj
->GetPage()->GetPageNum();
1701 if (nPgNum
!= SDRPAGE_NOTFOUND
)
1703 nPgNum
= (nPgNum
- 1) / 2; // SdrPageNum --> SdPageNum
1704 aURL
= CreatePageURL(nPgNum
);
1709 case IMAP_OBJ_RECTANGLE
:
1711 Rectangle
aArea(((IMapRectangleObject
*)pArea
)->
1712 GetRectangle(false));
1714 // Umrechnung in Pixelkoordinaten
1715 aArea
.Move(aLogPos
.X() - pPage
->GetLftBorder(),
1716 aLogPos
.Y() - pPage
->GetUppBorder());
1717 aArea
.Left() = (long)(aArea
.Left() * fLogicToPixel
);
1718 aArea
.Top() = (long)(aArea
.Top() * fLogicToPixel
);
1719 aArea
.Right() = (long)(aArea
.Right() * fLogicToPixel
);
1720 aArea
.Bottom() = (long)(aArea
.Bottom() * fLogicToPixel
);
1722 aStr
+= CreateHTMLRectArea(aArea
, aURL
);
1726 case IMAP_OBJ_CIRCLE
:
1728 Point
aCenter(((IMapCircleObject
*)pArea
)->
1730 aCenter
+= Point(aLogPos
.X() - pPage
->GetLftBorder(),
1731 aLogPos
.Y() - pPage
->GetUppBorder());
1732 aCenter
.X() = (long)(aCenter
.X() * fLogicToPixel
);
1733 aCenter
.Y() = (long)(aCenter
.Y() * fLogicToPixel
);
1735 ULONG nCircleRadius
= (((IMapCircleObject
*)pArea
)->
1737 nCircleRadius
= (ULONG
)(nCircleRadius
* fLogicToPixel
);
1738 aStr
+= CreateHTMLCircleArea(nCircleRadius
,
1739 aCenter
.X(), aCenter
.Y(),
1744 case IMAP_OBJ_POLYGON
:
1746 Polygon
aArea(((IMapPolygonObject
*)pArea
)->GetPolygon(false));
1747 aStr
+= CreateHTMLPolygonArea(::basegfx::B2DPolyPolygon(aArea
.getB2DPolygon()), Size(aLogPos
.X() - pPage
->GetLftBorder(), aLogPos
.Y() - pPage
->GetUppBorder()), fLogicToPixel
, aURL
);
1753 DBG_WARNING("unbekannter IMAP_OBJ_Typ");
1762 /*************************************************************
1763 |* wenn es eine presentation::ClickAction gibt, Bookmark bestimmen und eine
1764 |* Area fuer das ganze Objekt erzeugen
1765 \************************************************************/
1769 presentation::ClickAction eClickAction
= pInfo
->meClickAction
;
1771 switch( eClickAction
)
1773 case presentation::ClickAction_BOOKMARK
:
1776 USHORT nPgNum
= mpDoc
->GetPageByName( pInfo
->GetBookmark(), bIsMasterPage
);
1777 SdrObject
* pObj
= NULL
;
1779 if( nPgNum
== SDRPAGE_NOTFOUND
)
1781 // Ist das Bookmark ein Objekt?
1782 pObj
= mpDoc
->GetObj(pInfo
->GetBookmark());
1784 nPgNum
= pObj
->GetPage()->GetPageNum();
1787 if( SDRPAGE_NOTFOUND
!= nPgNum
)
1788 aHRef
= CreatePageURL(( nPgNum
- 1 ) / 2 );
1792 case presentation::ClickAction_DOCUMENT
:
1793 aHRef
= pInfo
->GetBookmark();
1796 case presentation::ClickAction_PREVPAGE
:
1798 ULONG nPage
= nSdPage
;
1802 nPage
= nSdPage
- 1;
1804 aHRef
= CreatePageURL( (USHORT
) nPage
);
1808 case presentation::ClickAction_NEXTPAGE
:
1810 ULONG nPage
= nSdPage
;
1811 if (nSdPage
== mnSdPageCount
- 1)
1812 nPage
= mnSdPageCount
- 1;
1814 nPage
= nSdPage
+ 1;
1816 aHRef
= CreatePageURL( (USHORT
) nPage
);
1820 case presentation::ClickAction_FIRSTPAGE
:
1821 aHRef
= CreatePageURL(0);
1824 case presentation::ClickAction_LASTPAGE
:
1825 aHRef
= CreatePageURL(mnSdPageCount
- 1);
1836 if (pObject
->GetObjInventor() == SdrInventor
&&
1837 pObject
->GetObjIdentifier() == OBJ_CIRC
&&
1840 aStr
+= CreateHTMLCircleArea(aRect
.GetWidth() / 2,
1841 aRect
.Left() + nRadius
,
1842 aRect
.Top() + nRadius
,
1846 else if (pObject
->GetObjInventor() == SdrInventor
&&
1847 (pObject
->GetObjIdentifier() == OBJ_PATHLINE
||
1848 pObject
->GetObjIdentifier() == OBJ_PLIN
||
1849 pObject
->GetObjIdentifier() == OBJ_POLY
))
1851 aStr
+= CreateHTMLPolygonArea(((SdrPathObj
*)pObject
)->GetPathPoly(), Size(-pPage
->GetLftBorder(), -pPage
->GetUppBorder()), fLogicToPixel
, aHRef
);
1853 // was anderes: das BoundRect nehmen
1856 aStr
+= CreateHTMLRectArea(aRect
, aHRef
);
1863 aStr
.AppendAscii( "</map>\r\n" );
1865 aClickableObjects
.Clear();
1867 aStr
.AppendAscii( "</body>\r\n</html>" );
1869 bOk
= WriteHtml( *mpHTMLFiles
[nSdPage
], false, aStr
);
1872 mpProgress
->SetState(++mnPagesWritten
);
1878 // =====================================================================
1879 // Uebersichtsseite erzeugen
1880 // =====================================================================
1881 bool HtmlExport::CreateContentPage()
1890 String
aStr(maHTMLHeader
);
1891 aStr
+= WriteMetaCharset();
1892 aStr
.AppendAscii( " <title>" );
1893 aStr
+= StringToHTMLString(*mpPageNames
[0]);
1894 aStr
.AppendAscii( "</title>\r\n</head>\r\n" );
1895 aStr
+= CreateBodyTag();
1898 aStr
.AppendAscii( "<center>\r\n" );
1902 aStr
.AppendAscii( "<h1>" );
1903 aStr
+= getDocumentTitle();
1904 aStr
.AppendAscii( "</h1><br>\r\n" );
1907 aStr
.AppendAscii( "<h2>" );
1909 // #92564# Solaris compiler bug workaround
1911 aStr
+= CreateLink( maFramePage
,
1912 RESTOHTML(STR_HTMLEXP_CLICKSTART
) );
1914 aStr
+= CreateLink( StringToHTMLString(*mpHTMLFiles
[0]),
1915 RESTOHTML(STR_HTMLEXP_CLICKSTART
) );
1917 aStr
.AppendAscii( "</h2>\r\n</center>\r\n" );
1919 aStr
.AppendAscii( "<center><table width=\"90%\"><tr>\r\n" );
1921 // Inhaltsverzeichnis
1922 aStr
.AppendAscii( "<td valign=\"top\" align=\"left\" width=\"50%\">\r\n" );
1923 aStr
.AppendAscii( "<h3>" );
1924 aStr
+= RESTOHTML(STR_HTMLEXP_CONTENTS
);
1925 aStr
.AppendAscii( "</h3>" );
1927 for(USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
; nSdPage
++)
1929 String aPageName
= *mpPageNames
[nSdPage
];
1930 aStr
.AppendAscii( "<div align=\"left\">" );
1932 aStr
+= StringToHTMLString(aPageName
);
1934 aStr
+= CreateLink(*mpHTMLFiles
[nSdPage
], aPageName
);
1935 aStr
.AppendAscii( "</div>\r\n" );
1937 aStr
.AppendAscii( "</td>\r\n" );
1940 aStr
.AppendAscii( "<td valign=\"top\" width=\"50%\">\r\n" );
1944 aStr
.AppendAscii( "<p><strong>" );
1945 aStr
+= RESTOHTML(STR_HTMLEXP_AUTHOR
);
1946 aStr
.AppendAscii( ":</strong> " );
1947 aStr
+= StringToHTMLString(maAuthor
);
1948 aStr
.AppendAscii( "</p>\r\n" );
1953 aStr
.AppendAscii( "<p><strong>" );
1954 aStr
+= RESTOHTML(STR_HTMLEXP_EMAIL
);
1955 aStr
.AppendAscii( ":</strong> <a href=\"mailto:" );
1956 aStr
+= StringToURL(maEMail
);
1957 aStr
.AppendAscii( "\">" );
1958 aStr
+= StringToHTMLString(maEMail
);
1959 aStr
.AppendAscii( "</a></p>\r\n" );
1962 if(maHomePage
.Len())
1964 aStr
.AppendAscii( "<p><strong>" );
1965 aStr
+= RESTOHTML(STR_HTMLEXP_HOMEPAGE
);
1966 aStr
.AppendAscii( ":</strong> <a href=\"" );
1967 aStr
+= StringToURL(maHomePage
);
1968 aStr
.AppendAscii( "\">" );
1969 aStr
+= StringToHTMLString(maHomePage
);
1970 aStr
.AppendAscii( "</a> </p>\r\n" );
1975 aStr
.AppendAscii( "<p><strong>" );
1976 aStr
+= RESTOHTML(STR_HTMLEXP_INFO
);
1977 aStr
.AppendAscii( ":</strong><br>\r\n" );
1978 aStr
+= StringToHTMLString(maInfo
);
1979 aStr
.AppendAscii( "</p>\r\n" );
1984 aStr
.AppendAscii( "<p><a href=\"" );
1985 aStr
+= StringToURL(maDocFileName
);
1986 aStr
.AppendAscii( "\">" );
1987 aStr
+= RESTOHTML(STR_HTMLEXP_DOWNLOAD
);
1988 aStr
.AppendAscii( "</a></p>\r\n" );
1991 aStr
.AppendAscii( "</td></tr></table></center>\r\n" );
1993 aStr
.AppendAscii( "</body>\r\n</html>" );
1995 bool bOk
= WriteHtml( maIndex
, false, aStr
);
1998 mpProgress
->SetState(++mnPagesWritten
);
2003 // =====================================================================
2004 // Notiz Seiten erzeugen (fuer Frames)
2005 // =====================================================================
2006 bool HtmlExport::CreateNotesPages()
2010 SdrOutliner
* pOutliner
= mpDoc
->GetInternalOutliner();
2011 for( USHORT nSdPage
= 0; bOk
&& nSdPage
< mnSdPageCount
; nSdPage
++ )
2013 SdPage
* pPage
= maNotesPages
[nSdPage
];
2015 SetDocColors( pPage
);
2018 String
aStr(maHTMLHeader
);
2019 aStr
+= WriteMetaCharset();
2020 aStr
.AppendAscii( " <title>" );
2021 aStr
+= StringToHTMLString(*mpPageNames
[0]);
2022 aStr
.AppendAscii( "</title>\r\n</head>\r\n" );
2023 aStr
+= CreateBodyTag();
2026 aStr
+= CreateTextForNotesPage( pOutliner
, pPage
, true, maBackColor
);
2028 aStr
.AppendAscii( "</body>\r\n</html>" );
2030 String
aFileName( RTL_CONSTASCII_USTRINGPARAM("note") );
2031 aFileName
+= String::CreateFromInt32(nSdPage
);
2032 bOk
= WriteHtml( aFileName
, true, aStr
);
2035 mpProgress
->SetState(++mnPagesWritten
);
2043 // =====================================================================
2044 // Outline Seiten erzeugen (fuer Frames)
2045 // =====================================================================
2046 bool HtmlExport::CreateOutlinePages()
2055 // Seite 0 wird der zugeklappte Outline, Seite 1 der aufgeklappte
2056 for( int nPage
= 0; nPage
< (mbImpress
?2:1) && bOk
; nPage
++ )
2059 String
aStr(maHTMLHeader
);
2060 aStr
+= WriteMetaCharset();
2061 aStr
.AppendAscii( " <title>" );
2062 aStr
+= StringToHTMLString(*mpPageNames
[0]);
2063 aStr
.AppendAscii( "</title>\r\n</head>\r\n" );
2064 aStr
+= CreateBodyTag();
2066 SdrOutliner
* pOutliner
= mpDoc
->GetInternalOutliner();
2067 for(USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
; nSdPage
++)
2069 SdPage
* pPage
= maPages
[ nSdPage
];
2071 aStr
.AppendAscii( "<div align=\"left\">" );
2072 String
aLink( RTL_CONSTASCII_USTRINGPARAM( "JavaScript:parent.NavigateAbs(" ) );
2073 aLink
+= String::CreateFromInt32(nSdPage
);
2074 aLink
.Append( sal_Unicode(')') );
2076 String aTitle
= CreateTextForTitle(pOutliner
,pPage
, maBackColor
);
2077 if(aTitle
.Len() == 0)
2078 aTitle
= *mpPageNames
[nSdPage
];
2080 aStr
.AppendAscii("<p style=\"");
2081 aStr
.Append( getParagraphStyle( pOutliner
, 0 ) );
2082 aStr
.AppendAscii("\">");
2083 aStr
+= CreateLink(aLink
, aTitle
);
2084 aStr
.AppendAscii("</p>");
2088 aStr
+= CreateTextForPage( pOutliner
, pPage
, false, maBackColor
);
2090 aStr
.AppendAscii( "</div>\r\n" );
2094 aStr
.AppendAscii( "</body>\r\n</html>" );
2096 String
aFileName( RTL_CONSTASCII_USTRINGPARAM("outline") );
2097 aFileName
+= String::CreateFromInt32(nPage
);
2098 bOk
= WriteHtml( aFileName
, true, aStr
);
2101 mpProgress
->SetState(++mnPagesWritten
);
2107 // =====================================================================
2108 // Dateinamen festlegen
2109 // =====================================================================
2110 void HtmlExport::CreateFileNames()
2112 // Listen mit neuen Dateinamen anlegen
2113 mpHTMLFiles
= new String
*[mnSdPageCount
];
2114 mpImageFiles
= new String
*[mnSdPageCount
];
2115 mpPageNames
= new String
*[mnSdPageCount
];
2116 mpTextFiles
= new String
*[mnSdPageCount
];
2118 mbHeader
= false; // Ueberschrift auf Uebersichtsseite?
2120 for (USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
; nSdPage
++)
2123 if(nSdPage
== 0 && !mbContentsPage
&& !mbFrames
)
2124 pName
= new String(maIndex
);
2127 pName
= new String( RTL_CONSTASCII_USTRINGPARAM("img") );
2128 *pName
+= String::CreateFromInt32(nSdPage
);
2129 *pName
+= maHTMLExtension
;
2132 mpHTMLFiles
[nSdPage
] = pName
;
2134 pName
= new String( RTL_CONSTASCII_USTRINGPARAM("img") );
2135 *pName
+= String::CreateFromInt32(nSdPage
);
2136 if( meFormat
==FORMAT_GIF
)
2137 pName
->AppendAscii( ".gif" );
2138 else if( meFormat
==FORMAT_JPG
)
2139 pName
->AppendAscii( ".jpg" );
2141 pName
->AppendAscii( ".png" );
2143 mpImageFiles
[nSdPage
] = pName
;
2145 pName
= new String( RTL_CONSTASCII_USTRINGPARAM("text"));
2146 *pName
+= String::CreateFromInt32(nSdPage
);
2147 *pName
+= maHTMLExtension
;
2148 mpTextFiles
[nSdPage
] = pName
;
2150 SdPage
* pSdPage
= maPages
[ nSdPage
];
2152 // get slide title from page name
2153 String
* pPageTitle
= new String();
2154 *pPageTitle
= pSdPage
->GetName();
2155 mpPageNames
[nSdPage
] = pPageTitle
;
2158 if(!mbContentsPage
&& mbFrames
)
2159 maFramePage
= maIndex
;
2162 maFramePage
.AssignAscii( "siframes" );
2163 maFramePage
+= maHTMLExtension
;
2167 String
HtmlExport::getDocumentTitle()
2169 // check for a title object in this page, if its the first
2170 // title it becomes this documents title for the content
2176 // falls es ein nicht-leeres Titelobjekt gibt, dessen ersten Absatz
2177 // als Seitentitel benutzen
2178 SdPage
* pSdPage
= mpDoc
->GetSdPage(0, PK_STANDARD
);
2179 SdrObject
* pTitleObj
= pSdPage
->GetPresObj(PRESOBJ_TITLE
);
2180 if (pTitleObj
&& !pTitleObj
->IsEmptyPresObj())
2182 OutlinerParaObject
* pParaObject
= pTitleObj
->GetOutlinerParaObject();
2185 const EditTextObject
& rEditTextObject
=
2186 pParaObject
->GetTextObject();
2187 if (&rEditTextObject
)
2189 String
aTest(rEditTextObject
.GetText(0));
2190 if (aTest
.Len() > 0)
2196 for( UINT16 i
= 0; i
< mDocTitle
.Len(); i
++ )
2197 if( mDocTitle
.GetChar(i
) == (sal_Unicode
)0xff)
2198 mDocTitle
.SetChar(i
, sal_Unicode(' ') );
2201 if( !mDocTitle
.Len() )
2203 mDocTitle
= maDocFileName
;
2204 int nDot
= mDocTitle
.Search( '.' );
2206 mDocTitle
.Erase( (USHORT
)nDot
);
2215 var nCurrentPage = 0;
2216 var nPageCount = JSCRIPT2;
2218 function NavigateAbs( nPage )
2220 frames[\"show\"].location.href = \"img\" + nPage + \".htm\";
2221 frames[\"notes\"].location.href = \"note\" + nPage + \".htm\";
2222 nCurrentPage = nPage;
2225 frames[\"navbar1\"].location.href = \"navbar0.htm\";
2227 else if(nCurrentPage==nPageCount-1)
2229 frames[\"navbar1\"].location.href = \"navbar2.htm\";
2232 frames[\"navbar1\"].location.href = \"navbar1.htm\";
2236 function NavigateRel( nDelta )
2238 var nPage = parseInt(nCurrentPage) + parseInt(nDelta);
2239 if( (nPage >= 0) && (nPage < nPageCount) )
2241 NavigateAbs( nPage );
2245 function ExpandOutline()
2247 frames[\"navbar2\"].location.href = \"navbar4.htm\";
2248 frames[\"outline\"].location.href = \"outline1.htm\";
2251 function CollapseOutline()
2253 frames[\"navbar2\"].location.href = \"navbar3.htm\";
2254 frames[\"outline\"].location.href = \"outline0.htm\";
2258 static const char* JS_NavigateAbs
=
2259 "function NavigateAbs( nPage )\r\n"
2261 " frames[\"show\"].location.href = \"img\" + nPage + \".$EXT\";\r\n"
2262 " //frames[\"notes\"].location.href = \"note\" + nPage + \".$EXT\";\r\n"
2263 " nCurrentPage = nPage;\r\n"
2264 " if(nCurrentPage==0)\r\n"
2266 " frames[\"navbar1\"].location.href = \"navbar0.$EXT\";\r\n"
2268 " else if(nCurrentPage==nPageCount-1)\r\n"
2270 " frames[\"navbar1\"].location.href = \"navbar2.$EXT\";\r\n"
2274 " frames[\"navbar1\"].location.href = \"navbar1.$EXT\";\r\n"
2278 static const char* JS_NavigateRel
=
2279 "function NavigateRel( nDelta )\r\n"
2281 " var nPage = parseInt(nCurrentPage) + parseInt(nDelta);\r\n"
2282 " if( (nPage >= 0) && (nPage < nPageCount) )\r\n"
2284 " NavigateAbs( nPage );\r\n"
2288 static const char* JS_ExpandOutline
=
2289 "function ExpandOutline()\r\n"
2291 " frames[\"navbar2\"].location.href = \"navbar4.$EXT\";\r\n"
2292 " frames[\"outline\"].location.href = \"outline1.$EXT\";\r\n"
2295 static const char * JS_CollapseOutline
=
2296 "function CollapseOutline()\r\n"
2298 " frames[\"navbar2\"].location.href = \"navbar3.$EXT\";\r\n"
2299 " frames[\"outline\"].location.href = \"outline0.$EXT\";\r\n"
2302 // ====================================================================
2303 // Seite mit den Frames erzeugen
2304 // ====================================================================
2305 bool HtmlExport::CreateFrames()
2308 String
aStr( RTL_CONSTASCII_USTRINGPARAM(
2309 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\r\n"
2310 " \"http://www.w3.org/TR/html4/frameset.dtd\">\r\n"
2311 "<html>\r\n<head>\r\n" ) );
2313 aStr
+= WriteMetaCharset();
2314 aStr
.AppendAscii( " <title>" );
2315 aStr
+= StringToHTMLString(*mpPageNames
[0]);
2316 aStr
.AppendAscii( "</title>\r\n" );
2318 aStr
.AppendAscii( "<script type=\"text/javascript\">\r\n<!--\r\n" );
2320 aStr
.AppendAscii( "var nCurrentPage = 0;\r\nvar nPageCount = " );
2321 aStr
+= String::CreateFromInt32(mnSdPageCount
);
2322 aStr
.AppendAscii( ";\r\n\r\n" );
2325 aFunction
.AssignAscii(JS_NavigateAbs
);
2330 String
aSlash( RTL_CONSTASCII_USTRINGPARAM( "//" ) );
2331 aFunction
.SearchAndReplaceAll( aSlash
, aEmpty
);
2334 // substitute HTML file extension
2335 String
aPlaceHolder(RTL_CONSTASCII_USTRINGPARAM(".$EXT"));
2336 aFunction
.SearchAndReplaceAll(aPlaceHolder
, maHTMLExtension
);
2339 aTmp
.AssignAscii( JS_NavigateRel
);
2340 aTmp
.SearchAndReplaceAll(aPlaceHolder
, maHTMLExtension
);
2345 aTmp
.AssignAscii( JS_ExpandOutline
);
2346 aTmp
.SearchAndReplaceAll(aPlaceHolder
, maHTMLExtension
);
2349 aTmp
.AssignAscii( JS_CollapseOutline
);
2350 aTmp
.SearchAndReplaceAll(aPlaceHolder
, maHTMLExtension
);
2353 aStr
.AppendAscii( "// -->\r\n</script>\r\n" );
2355 aStr
.AppendAscii( "</head>\r\n" );
2357 aStr
.AppendAscii( "<frameset cols=\"*," );
2358 aStr
+= String::CreateFromInt32((mnWidthPixel
+ 16));
2359 aStr
.AppendAscii( "\">\r\n" );
2362 aStr
.AppendAscii( " <frameset rows=\"42,*\">\r\n" );
2363 aStr
.AppendAscii( " <frame src=\"navbar3" );
2364 aStr
+= StringToURL(maHTMLExtension
);
2365 aStr
.AppendAscii( "\" name=\"navbar2\" marginwidth=\"4\" marginheight=\"4\" scrolling=\"no\">\r\n" );
2367 aStr
.AppendAscii( " <frame src=\"outline0" );
2368 aStr
+= StringToURL(maHTMLExtension
);
2369 aStr
.AppendAscii( "\" name=\"outline\">\r\n" );
2371 aStr
.AppendAscii( " </frameset>\r\n" );
2375 aStr
.AppendAscii( " <frameset rows=\"42," );
2376 aStr
+= String::CreateFromInt32((int)((double)mnWidthPixel
* 0.75) + 16);
2377 aStr
.AppendAscii( ",*\">\r\n" );
2380 aStr
.AppendAscii( " <frameset rows=\"42,*\">\r\n" );
2382 aStr
.AppendAscii( " <frame src=\"navbar0" );
2383 aStr
+= StringToURL(maHTMLExtension
);
2384 aStr
.AppendAscii( "\" name=\"navbar1\" marginwidth=\"4\" marginheight=\"4\" scrolling=\"no\">\r\n" );
2386 aStr
.AppendAscii( " <frame src=\"" );
2387 aStr
+= StringToURL(*mpHTMLFiles
[0]);
2388 aStr
.AppendAscii( "\" name=\"show\" marginwidth=\"4\" marginheight=\"4\">\r\n" );
2392 aStr
.AppendAscii( " <frame src=\"note0" );
2393 aStr
+= StringToURL(maHTMLExtension
);
2394 aStr
.AppendAscii( "\" name=\"notes\">\r\n" );
2396 aStr
.AppendAscii( " </frameset>\r\n" );
2398 aStr
.AppendAscii( "<noframes>\r\n" );
2399 aStr
+= CreateBodyTag();
2400 aStr
+= RESTOHTML(STR_HTMLEXP_NOFRAMES
);
2401 aStr
.AppendAscii( "\r\n</noframes>\r\n</frameset>\r\n</html>" );
2403 bool bOk
= WriteHtml( maFramePage
, false, aStr
);
2406 mpProgress
->SetState(++mnPagesWritten
);
2411 // ====================================================================
2412 // Buttonleiste fuer Standard ausgeben
2413 // Es werden 4 html files erstellt
2414 // navbar0.htm Navigationsleiste Grafik fuer erste Seite
2415 // navbar1.htm Navigationsleiste Grafik fuer zweite bis vorletzte Seite
2416 // navbar2.htm Navigationsleiste Grafik fuer letzte Seite
2417 // navbar3.htm Navigationsleiste Outline zugeklappt
2418 // navbar4.htm Navigationsleiste Outline aufgeklappt
2419 // ====================================================================
2420 bool HtmlExport::CreateNavBarFrames()
2428 maBackColor
= maFirstPageColor
;
2431 for( int nFile
= 0; nFile
< 3 && bOk
; nFile
++ )
2433 String
aStr(maHTMLHeader
);
2434 aStr
+= WriteMetaCharset();
2435 aStr
.AppendAscii( " <title>" );
2436 aStr
+= StringToHTMLString(*mpPageNames
[0]);
2437 aStr
.AppendAscii( "</title>\r\n</head>\r\n" );
2438 aStr
+= CreateBodyTag();
2439 aStr
.AppendAscii( "<center>\r\n" );
2442 aButton
= String(SdResId(STR_HTMLEXP_FIRSTPAGE
));
2443 if(mnButtonThema
!= -1)
2444 aButton
= CreateImage(GetButtonName((nFile
== 0 || mnSdPageCount
== 1?
2445 BTN_FIRST_0
:BTN_FIRST_1
)), aButton
);
2447 if(nFile
!= 0 && mnSdPageCount
> 1)
2448 aButton
= CreateLink( String(RTL_CONSTASCII_USTRINGPARAM("JavaScript:parent.NavigateAbs(0)")), aButton
);
2451 aStr
.AppendAscii( "\r\n" );
2453 // zur vorherigen Seite
2454 aButton
= String(SdResId(STR_PUBLISH_BACK
));
2455 if(mnButtonThema
!= -1)
2456 aButton
= CreateImage(GetButtonName((nFile
== 0 || mnSdPageCount
== 1?
2457 BTN_PREV_0
:BTN_PREV_1
)), aButton
);
2459 if(nFile
!= 0 && mnSdPageCount
> 1)
2460 aButton
= CreateLink( String(RTL_CONSTASCII_USTRINGPARAM("JavaScript:parent.NavigateRel(-1)")), aButton
);
2463 aStr
.AppendAscii( "\r\n" );
2465 // zur naechsten Seite
2466 aButton
= String(SdResId(STR_PUBLISH_NEXT
));
2467 if(mnButtonThema
!= -1)
2468 aButton
= CreateImage(GetButtonName((nFile
==2 || mnSdPageCount
== 1?
2469 BTN_NEXT_0
:BTN_NEXT_1
)), aButton
);
2471 if(nFile
!= 2 && mnSdPageCount
> 1)
2472 aButton
= CreateLink(String(RTL_CONSTASCII_USTRINGPARAM("JavaScript:parent.NavigateRel(1)")), aButton
);
2475 aStr
.AppendAscii( "\r\n" );
2477 // zur letzten Seite
2478 aButton
= String(SdResId(STR_HTMLEXP_LASTPAGE
));
2479 if(mnButtonThema
!= -1)
2480 aButton
= CreateImage(GetButtonName((nFile
==2 || mnSdPageCount
== 1?
2481 BTN_LAST_0
:BTN_LAST_1
)), aButton
);
2483 if(nFile
!= 2 && mnSdPageCount
> 1)
2485 String
aLink(RTL_CONSTASCII_USTRINGPARAM("JavaScript:parent.NavigateAbs("));
2486 aLink
+= String::CreateFromInt32(mnSdPageCount
-1);
2487 aLink
.AppendAscii( ")" );
2488 aButton
= CreateLink( aLink
, aButton
);
2492 aStr
.AppendAscii( "\r\n" );
2497 aButton
= String(SdResId(STR_PUBLISH_OUTLINE
));
2498 if(mnButtonThema
!= -1)
2499 aButton
= CreateImage(GetButtonName(BTN_INDEX
), aButton
);
2502 aStr
+= CreateLink(maIndex
, aButton
, String(RTL_CONSTASCII_USTRINGPARAM("_top")));
2503 aStr
.AppendAscii( "\r\n" );
2509 aButton
= String(SdResId(STR_HTMLEXP_SETTEXT
));
2510 if(mnButtonThema
!= -1)
2511 aButton
= CreateImage(GetButtonName(BTN_TEXT
), aButton
);
2513 String
aText0( RTL_CONSTASCII_USTRINGPARAM("text0"));
2514 aText0
+= maHTMLExtension
;
2515 aStr
+= CreateLink( aText0
, aButton
, String(RTL_CONSTASCII_USTRINGPARAM("_top")));
2516 aStr
.AppendAscii( "\r\n" );
2520 aStr
.AppendAscii( "</center>\r\n" );
2521 aStr
.AppendAscii( "</body>\r\n</html>" );
2523 String
aFileName( RTL_CONSTASCII_USTRINGPARAM("navbar") );
2524 aFileName
+= String::CreateFromInt32(nFile
);
2526 bOk
= WriteHtml( aFileName
, true, aStr
);
2529 mpProgress
->SetState(++mnPagesWritten
);
2532 // Jetzt kommt die Navigatonsleiste Outliner zugeklappt...
2535 String
aStr(maHTMLHeader
);
2536 aStr
+= WriteMetaCharset();
2537 aStr
.AppendAscii( " <title>" );
2538 aStr
+= StringToHTMLString(*mpPageNames
[0]);
2539 aStr
.AppendAscii( "</title>\r\n</head>\r\n" );
2540 aStr
+= CreateBodyTag();
2542 aButton
= String(SdResId(STR_HTMLEXP_OUTLINE
));
2543 if(mnButtonThema
!= -1)
2544 aButton
= CreateImage(GetButtonName(BTN_MORE
), aButton
);
2546 aStr
+= CreateLink(String(RTL_CONSTASCII_USTRINGPARAM("JavaScript:parent.ExpandOutline()")), aButton
);
2547 aStr
.AppendAscii( "</body>\r\n</html>" );
2549 String
aFileName( RTL_CONSTASCII_USTRINGPARAM("navbar3") );
2551 bOk
= WriteHtml( aFileName
, true, aStr
);
2554 mpProgress
->SetState(++mnPagesWritten
);
2557 // ... und jetzt Outliner aufgeklappt
2560 String
aStr(maHTMLHeader
);
2561 aStr
+= WriteMetaCharset();
2562 aStr
.AppendAscii( " <title>" );
2563 aStr
+= StringToHTMLString(*mpPageNames
[0]);
2564 aStr
.AppendAscii( "</title>\r\n</head>\r\n" );
2565 aStr
+= CreateBodyTag();
2567 aButton
= String(SdResId(STR_HTMLEXP_NOOUTLINE
));
2568 if(mnButtonThema
!= -1)
2569 aButton
= CreateImage(GetButtonName(BTN_LESS
), aButton
);
2571 aStr
+= CreateLink(String(RTL_CONSTASCII_USTRINGPARAM("JavaScript:parent.CollapseOutline()")), aButton
);
2572 aStr
.AppendAscii( "</body>\r\n</html>" );
2574 String
aFileName( RTL_CONSTASCII_USTRINGPARAM("navbar4") );
2575 bOk
= WriteHtml( aFileName
, true, aStr
);
2578 mpProgress
->SetState(++mnPagesWritten
);
2585 // ====================================================================
2586 // Buttonleiste fuer Standard ausgeben
2587 // ====================================================================
2588 String
HtmlExport::CreateNavBar( USHORT nSdPage
, bool bIsText
) const
2590 // Navigationsleiste vorbereiten
2591 String
aStrNavFirst( SdResId(STR_HTMLEXP_FIRSTPAGE
) );
2592 String
aStrNavPrev( SdResId(STR_PUBLISH_BACK
) );
2593 String
aStrNavNext( SdResId(STR_PUBLISH_NEXT
) );
2594 String
aStrNavLast( SdResId(STR_HTMLEXP_LASTPAGE
) );
2595 String
aStrNavContent( SdResId(STR_PUBLISH_OUTLINE
) );
2599 aStrNavText
= String( SdResId(STR_HTMLEXP_SETGRAPHIC
) );
2603 aStrNavText
= String( SdResId(STR_HTMLEXP_SETTEXT
) );
2606 if(!bIsText
&& mnButtonThema
!= -1)
2608 if(nSdPage
<1 || mnSdPageCount
== 1)
2610 aStrNavFirst
= CreateImage(GetButtonName(BTN_FIRST_0
), aStrNavFirst
);
2611 aStrNavPrev
= CreateImage(GetButtonName(BTN_PREV_0
), aStrNavPrev
);
2615 aStrNavFirst
= CreateImage(GetButtonName(BTN_FIRST_1
), aStrNavFirst
);
2616 aStrNavPrev
= CreateImage(GetButtonName(BTN_PREV_1
), aStrNavPrev
);
2619 if(nSdPage
== mnSdPageCount
-1 || mnSdPageCount
== 1)
2621 aStrNavNext
= CreateImage(GetButtonName(BTN_NEXT_0
), aStrNavNext
);
2622 aStrNavLast
= CreateImage(GetButtonName(BTN_LAST_0
), aStrNavLast
);
2626 aStrNavNext
= CreateImage(GetButtonName(BTN_NEXT_1
), aStrNavNext
);
2627 aStrNavLast
= CreateImage(GetButtonName(BTN_LAST_1
), aStrNavLast
);
2630 aStrNavContent
= CreateImage(GetButtonName(BTN_INDEX
), aStrNavContent
);
2631 aStrNavText
= CreateImage(GetButtonName(BTN_TEXT
), aStrNavText
);
2634 String
aStr( RTL_CONSTASCII_USTRINGPARAM("<center>\r\n")); //<table><tr>\r\n");
2638 aStr
+= CreateLink(bIsText
?*mpTextFiles
[0]:*mpHTMLFiles
[0],aStrNavFirst
);
2640 aStr
+= aStrNavFirst
;
2641 aStr
.Append(sal_Unicode(' '));
2645 aStr
+= CreateLink( bIsText
?*mpTextFiles
[nSdPage
-1]:
2646 *mpHTMLFiles
[nSdPage
-1], aStrNavPrev
);
2648 aStr
+= aStrNavPrev
;
2649 aStr
.Append(sal_Unicode(' '));
2652 if(nSdPage
< mnSdPageCount
-1)
2653 aStr
+= CreateLink( bIsText
?*mpTextFiles
[nSdPage
+1]:
2654 *mpHTMLFiles
[nSdPage
+1], aStrNavNext
);
2656 aStr
+= aStrNavNext
;
2657 aStr
.Append(sal_Unicode(' '));
2660 if(nSdPage
< mnSdPageCount
-1)
2661 aStr
+= CreateLink( bIsText
?*mpTextFiles
[mnSdPageCount
-1]:
2662 *mpHTMLFiles
[mnSdPageCount
-1],
2665 aStr
+= aStrNavLast
;
2666 aStr
.Append(sal_Unicode(' '));
2671 aStr
+= CreateLink(maIndex
, aStrNavContent
);
2672 aStr
.Append(sal_Unicode(' '));
2678 aStr
+= CreateLink( bIsText
?(mbFrames
?maFramePage
:*mpHTMLFiles
[nSdPage
]):
2679 *mpTextFiles
[nSdPage
], aStrNavText
);
2683 aStr
.AppendAscii( "</center><br>\r\n" );
2688 /** export navigation graphics from button set */
2689 bool HtmlExport::CreateBitmaps()
2691 if(mnButtonThema
!= -1 && mpButtonSet
.get() )
2693 for( int nButton
= 0; nButton
< NUM_BUTTONS
; nButton
++ )
2695 if(!mbFrames
&& (nButton
== BTN_MORE
|| nButton
== BTN_LESS
))
2698 if(!mbImpress
&& (nButton
== BTN_TEXT
|| nButton
== BTN_MORE
|| nButton
== BTN_LESS
))
2701 OUString
aFull(maExportPath
);
2702 aFull
+= GetButtonName(nButton
);
2703 mpButtonSet
->exportButton( mnButtonThema
, aFull
, GetButtonName(nButton
) );
2709 // =====================================================================
2710 // Erzeugt den <body> Tag, inkl. der eingestellten Farbattribute
2711 // =====================================================================
2712 String
HtmlExport::CreateBodyTag() const
2714 String
aStr( RTL_CONSTASCII_USTRINGPARAM("<body") );
2716 if( mbUserAttr
|| mbDocColors
)
2718 Color
aTextColor( maTextColor
);
2719 if( (aTextColor
== COL_AUTO
) && (!maBackColor
.IsDark()) )
2720 aTextColor
= COL_BLACK
;
2722 aStr
.AppendAscii( " text=\"" );
2723 aStr
+= ColorToHTMLString( aTextColor
);
2724 aStr
.AppendAscii( "\" bgcolor=\"" );
2725 aStr
+= ColorToHTMLString( maBackColor
);
2726 aStr
.AppendAscii( "\" link=\"" );
2727 aStr
+= ColorToHTMLString( maLinkColor
);
2728 aStr
.AppendAscii( "\" vlink=\"" );
2729 aStr
+= ColorToHTMLString( maVLinkColor
);
2730 aStr
.AppendAscii( "\" alink=\"" );
2731 aStr
+= ColorToHTMLString( maALinkColor
);
2732 aStr
.AppendAscii( "\"" );
2735 aStr
.AppendAscii( ">\r\n" );
2740 // =====================================================================
2741 // Erzeugt einen Hyperlink
2742 // =====================================================================
2743 String
HtmlExport::CreateLink( const String
& aLink
,
2744 const String
& aText
,
2745 const String
& aTarget
) const
2747 String
aStr( RTL_CONSTASCII_USTRINGPARAM("<a href=\""));
2748 aStr
+= StringToURL(aLink
);
2751 aStr
.AppendAscii( "\" target=\"" );
2754 aStr
.AppendAscii( "\">" );
2756 aStr
.AppendAscii( "</a>" );
2761 // =====================================================================
2762 // Erzeugt ein Image-tag
2763 // =====================================================================
2764 String
HtmlExport::CreateImage( const String
& aImage
, const String
& aAltText
,
2766 INT16 nHeight
) const
2768 String
aStr( RTL_CONSTASCII_USTRINGPARAM("<img src=\""));
2769 aStr
+= StringToURL(aImage
);
2770 aStr
.AppendAscii( "\" border=0" );
2774 aStr
.AppendAscii( " alt=\"" );
2776 aStr
.Append(sal_Unicode('"'));
2780 // Agerskov: HTML 4.01 has to have an alt attribut even if it is an empty string
2781 aStr
.AppendAscii( " alt=\"\"" );
2786 aStr
.AppendAscii( " width=" );
2787 aStr
+= String::CreateFromInt32(nWidth
);
2792 aStr
.AppendAscii( " height=" );
2793 aStr
+= String::CreateFromInt32(nHeight
);
2796 aStr
.Append(sal_Unicode('>'));
2801 // =====================================================================
2802 // Area fuer Kreis erzeugen; es werden Pixelkoordinaten erwartet
2803 // =====================================================================
2804 String
HtmlExport::ColorToHTMLString( Color aColor
)
2806 static char hex
[] = "0123456789ABCDEF";
2807 String
aStr( RTL_CONSTASCII_USTRINGPARAM("#xxxxxx"));
2808 aStr
.SetChar(1, hex
[(aColor
.GetRed() >> 4) & 0xf] );
2809 aStr
.SetChar(2, hex
[aColor
.GetRed() & 0xf] );
2810 aStr
.SetChar(3, hex
[(aColor
.GetGreen() >> 4) & 0xf] );
2811 aStr
.SetChar(4, hex
[aColor
.GetGreen() & 0xf] );
2812 aStr
.SetChar(5, hex
[(aColor
.GetBlue() >> 4) & 0xf] );
2813 aStr
.SetChar(6, hex
[aColor
.GetBlue() & 0xf] );
2818 // =====================================================================
2819 // Area fuer Kreis erzeugen; es werden Pixelkoordinaten erwartet
2820 // =====================================================================
2821 String
HtmlExport::CreateHTMLCircleArea( ULONG nRadius
,
2824 const String
& rHRef
) const
2826 String
aStr( RTL_CONSTASCII_USTRINGPARAM("<area shape=\"circle\" alt=\"\" coords=\"" ));
2828 aStr
+= String::CreateFromInt32(nCenterX
);
2829 aStr
.Append(sal_Unicode(','));
2830 aStr
+= String::CreateFromInt32(nCenterY
);
2831 aStr
.Append(sal_Unicode(','));
2832 aStr
+= String::CreateFromInt32(nRadius
);
2833 aStr
.AppendAscii( "\" href=\"" );
2834 aStr
+= StringToURL(rHRef
);
2835 aStr
.AppendAscii( "\">\n" );
2841 // =====================================================================
2842 // Area fuer Polygon erzeugen; es werden Pixelkoordinaten erwartet
2843 // =====================================================================
2844 String
HtmlExport::CreateHTMLPolygonArea( const ::basegfx::B2DPolyPolygon
& rPolyPolygon
,
2845 Size aShift
, double fFactor
, const String
& rHRef
) const
2848 const sal_uInt32
nNoOfPolygons(rPolyPolygon
.count());
2850 for ( sal_uInt32 nXPoly
= 0L; nXPoly
< nNoOfPolygons
; nXPoly
++ )
2852 const ::basegfx::B2DPolygon
& aPolygon
= rPolyPolygon
.getB2DPolygon(nXPoly
);
2853 const sal_uInt32
nNoOfPoints(aPolygon
.count());
2855 aStr
.AppendAscii( "<area shape=\"polygon\" alt=\"\" coords=\"" );
2857 for ( sal_uInt32 nPoint
= 0L; nPoint
< nNoOfPoints
; nPoint
++ )
2859 const ::basegfx::B2DPoint
aB2DPoint(aPolygon
.getB2DPoint(nPoint
));
2860 Point
aPnt(FRound(aB2DPoint
.getX()), FRound(aB2DPoint
.getY()));
2861 // das Koordinaten beziehen sich auf den
2862 // physikalischen Seitenursprung, nicht auf den
2863 // Koordinatenursprung
2864 aPnt
.Move(aShift
.Width(), aShift
.Height());
2866 aPnt
.X() = (long)(aPnt
.X() * fFactor
);
2867 aPnt
.Y() = (long)(aPnt
.Y() * fFactor
);
2868 aStr
+= String::CreateFromInt32(aPnt
.X());
2869 aStr
.Append(sal_Unicode(','));
2870 aStr
+= String::CreateFromInt32(aPnt
.Y());
2872 if (nPoint
< nNoOfPoints
- 1)
2873 aStr
.Append( sal_Unicode(',') );
2875 aStr
.AppendAscii( "\" href=\"" );
2876 aStr
+= StringToURL(rHRef
);
2877 aStr
.AppendAscii( "\">\n" );
2883 // =====================================================================
2884 // Area fuer Rechteck erzeugen; es werden Pixelkoordinaten erwartet
2885 // =====================================================================
2886 String
HtmlExport::CreateHTMLRectArea( const Rectangle
& rRect
,
2887 const String
& rHRef
) const
2889 String
aStr( RTL_CONSTASCII_USTRINGPARAM("<area shape=\"rect\" alt=\"\" coords=\"") );
2891 aStr
+= String::CreateFromInt32(rRect
.Left());
2892 aStr
.Append(sal_Unicode(','));
2893 aStr
+= String::CreateFromInt32(rRect
.Top());
2894 aStr
.Append(sal_Unicode(','));
2895 aStr
+= String::CreateFromInt32(rRect
.Right());
2896 aStr
.Append(sal_Unicode(','));
2897 aStr
+= String::CreateFromInt32(rRect
.Bottom());
2898 aStr
.AppendAscii( "\" href=\"" );
2899 aStr
+= StringToURL(rHRef
);
2900 aStr
.AppendAscii( "\">\n" );
2905 // =====================================================================
2906 // StringToHTMLString, konvertiert einen String in
2907 // seine HTML-Repraesentation (Umlaute etc.)
2908 // =====================================================================
2909 String
HtmlExport::StringToHTMLString( const String
& rString
)
2911 SvMemoryStream aMemStm
;
2912 HTMLOutFuncs::Out_String( aMemStm
, rString
, RTL_TEXTENCODING_UTF8
);
2913 aMemStm
<< (char) 0;
2914 return String( (char*)aMemStm
.GetData(), RTL_TEXTENCODING_UTF8
);
2917 // =====================================================================
2918 // Erzeugt die URL einer bestimmten Seite
2919 // =====================================================================
2920 String
HtmlExport::CreatePageURL( USHORT nPgNum
)
2924 String
aUrl( RTL_CONSTASCII_USTRINGPARAM("JavaScript:parent.NavigateAbs("));
2925 aUrl
+= String::CreateFromInt32(nPgNum
);
2926 aUrl
.Append(sal_Unicode(')'));
2930 return *mpHTMLFiles
[nPgNum
];
2933 bool HtmlExport::CopyScript( const String
& rPath
, const String
& rSource
, const String
& rDest
, bool bUnix
/* = false */ )
2935 INetURLObject
aURL( SvtPathOptions().GetConfigPath() );
2938 aURL
.Append( String( RTL_CONSTASCII_USTRINGPARAM("webcast") ) );
2939 aURL
.Append( rSource
);
2941 meEC
.SetContext( STR_HTMLEXP_ERROR_OPEN_FILE
, rSource
);
2944 SvStream
* pIStm
= ::utl::UcbStreamHelper::CreateStream( aURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
2950 while( pIStm
->ReadLine( aLine
) )
2952 aScript
.AppendAscii( aLine
.GetBuffer() );
2955 aScript
.AppendAscii( "\n" );
2959 aScript
.AppendAscii( "\r\n" );
2963 nErr
= pIStm
->GetError();
2969 ErrorHandler::HandleError( nErr
);
2974 aScript
.SearchAndReplaceAll( String(RTL_CONSTASCII_USTRINGPARAM("$$1")), getDocumentTitle() );
2976 const String
aSaveStr( RESTOHTML( STR_WEBVIEW_SAVE
));
2977 aScript
.SearchAndReplaceAll( String(RTL_CONSTASCII_USTRINGPARAM("$$2")), aSaveStr
);
2979 aScript
.SearchAndReplaceAll( String(RTL_CONSTASCII_USTRINGPARAM("$$3")), maCGIPath
);
2981 aScript
.SearchAndReplaceAll( String(RTL_CONSTASCII_USTRINGPARAM("$$4")), String::CreateFromInt32(mnWidthPixel
) );
2982 aScript
.SearchAndReplaceAll( String(RTL_CONSTASCII_USTRINGPARAM("$$5")), String::CreateFromInt32(mnHeightPixel
) );
2985 String
aDest( rPath
);
2988 meEC
.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE
, rDest
);
2989 // write script file
2993 nErr
= aFile
.createStream(aDest
, pStr
);
2996 ByteString
aStr( aScript
, RTL_TEXTENCODING_UTF8
);
2997 *pStr
<< aStr
.GetBuffer();
2999 nErr
= aFile
.close();
3004 mpProgress
->SetState(++mnPagesWritten
);
3007 ErrorHandler::HandleError( nErr
);
3012 static const char * ASP_Scripts
[] = { "common.inc", "webcast.asp", "show.asp", "savepic.asp", "poll.asp", "editpic.asp" };
3014 /** erzeugt und speichert die f�r WebShow ben�tigte ASP Scripte */
3015 bool HtmlExport::CreateASPScripts()
3017 for( USHORT n
= 0; n
< (sizeof( ASP_Scripts
) / sizeof(char *)); n
++ )
3021 aScript
.AssignAscii( ASP_Scripts
[n
] );
3022 if(!CopyScript(maExportPath
, aScript
, aScript
))
3026 if(!CopyScript(maExportPath
, String(RTL_CONSTASCII_USTRINGPARAM("edit.asp")), maIndex
))
3033 static const char *PERL_Scripts
[] = { "webcast.pl", "common.pl", "editpic.pl", "poll.pl", "savepic.pl", "show.pl" };
3035 /** erzeugt und speichert die f�r WebShow ben�tigte PERL Scripte */
3036 bool HtmlExport::CreatePERLScripts()
3038 for( USHORT n
= 0; n
< (sizeof( PERL_Scripts
) / sizeof(char *)); n
++ )
3041 aScript
.AssignAscii( PERL_Scripts
[n
] );
3042 if(!CopyScript(maExportPath
, aScript
, aScript
, true))
3046 if(!CopyScript(maExportPath
, String( RTL_CONSTASCII_USTRINGPARAM("edit.pl")), maIndex
, true ))
3049 if(!CopyScript(maExportPath
, String( RTL_CONSTASCII_USTRINGPARAM("index.pl")), maIndexUrl
, true ))
3055 /** Erzeugt eine Liste mit den Namen der gespeicherten Images */
3056 bool HtmlExport::CreateImageFileList()
3059 for( USHORT nSdPage
= 0; nSdPage
< mnSdPageCount
; nSdPage
++)
3061 aStr
+= String::CreateFromInt32( nSdPage
+ 1 );
3062 aStr
.Append(sal_Unicode(';'));
3064 aStr
+= *mpImageFiles
[nSdPage
];
3065 aStr
.AppendAscii( "\r\n" );
3068 String
aFileName( RTL_CONSTASCII_USTRINGPARAM("picture.txt") );
3069 bool bOk
= WriteHtml( aFileName
, false, aStr
);
3072 mpProgress
->SetState(++mnPagesWritten
);
3077 /** Erzeugt das File mit der aktuellen Seitennumer */
3078 bool HtmlExport::CreateImageNumberFile()
3080 String
aFull( maExportPath
);
3081 String
aFileName( RTL_CONSTASCII_USTRINGPARAM("currpic.txt") );
3084 meEC
.SetContext( STR_HTMLEXP_ERROR_CREATE_FILE
, aFileName
);
3087 ULONG nErr
= aFile
.createStream(aFull
, pStr
);
3090 *pStr
<< (const char *)"1";
3091 nErr
= aFile
.close();
3095 mpProgress
->SetState(++mnPagesWritten
);
3098 ErrorHandler::HandleError( nErr
);
3103 // =====================================================================
3105 String
HtmlExport::InsertSound( const String
& rSoundFile
)
3107 if( rSoundFile
.Len() == 0 )
3110 String
aStr( RTL_CONSTASCII_USTRINGPARAM("<embed src=\"") );
3111 INetURLObject
aURL( rSoundFile
);
3113 DBG_ASSERT( aURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
3115 aStr
+= String(aURL
.getName());
3116 aStr
.AppendAscii( "\" hidden=\"true\" autostart=\"true\">" );
3118 CopyFile( rSoundFile
, maExportPath
);
3123 // =====================================================================
3125 bool HtmlExport::CopyFile( const String
& rSourceFile
, const String
& rDestPath
)
3127 DirEntry
aSourceEntry( rSourceFile
);
3128 DirEntry
aDestEntry( rDestPath
);
3130 meEC
.SetContext( STR_HTMLEXP_ERROR_COPY_FILE
, aSourceEntry
.GetName(), rDestPath
);
3131 FSysError nError
= aSourceEntry
.CopyTo( aDestEntry
, FSYS_ACTION_COPYFILE
);
3133 if( nError
!= FSYS_ERR_OK
)
3135 ErrorHandler::HandleError(nError
);
3144 // =====================================================================
3146 bool HtmlExport::checkFileExists( Reference
< ::com::sun::star::ucb::XSimpleFileAccess
>& xFileAccess
, String
const & aFileName
)
3150 OUString
url( maExportPath
);
3152 return xFileAccess
->exists( url
);
3154 catch( com::sun::star::uno::Exception
& e
)
3157 DBG_ERROR((OString("sd::HtmlExport::checkFileExists(), exception caught: ") +
3158 rtl::OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), RTL_TEXTENCODING_UTF8
)).getStr() );
3164 // ---------------------------------------------------------------------
3166 bool HtmlExport::checkForExistingFiles()
3168 bool bFound
= false;
3172 Reference
< XMultiServiceFactory
> xMsf( ::comphelper::getProcessServiceFactory() );
3173 Reference
< ::com::sun::star::ucb::XSimpleFileAccess
> xFA( xMsf
->createInstance(
3174 OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))), UNO_QUERY_THROW
);
3177 for( nSdPage
= 0; !bFound
&& (nSdPage
< mnSdPageCount
); nSdPage
++)
3179 if( (mpImageFiles
[nSdPage
] && checkFileExists( xFA
, *mpImageFiles
[nSdPage
] )) ||
3180 (mpHTMLFiles
[nSdPage
] && checkFileExists( xFA
, *mpHTMLFiles
[nSdPage
] )) ||
3181 (mpPageNames
[nSdPage
] && checkFileExists( xFA
, *mpPageNames
[nSdPage
] )) ||
3182 (mpTextFiles
[nSdPage
] && checkFileExists( xFA
, *mpTextFiles
[nSdPage
] )) )
3188 if( !bFound
&& mbDownload
)
3189 bFound
= checkFileExists( xFA
, maDocFileName
);
3191 if( !bFound
&& mbFrames
)
3192 bFound
= checkFileExists( xFA
, maFramePage
);
3196 ResMgr
*pResMgr
= CREATERESMGR( dbw
);
3199 ResId
aResId( 4077, *pResMgr
);
3200 String
aMsg( aResId
);
3202 OUString aSystemPath
;
3203 osl::FileBase::getSystemPathFromFileURL( maExportPath
, aSystemPath
);
3204 aMsg
.SearchAndReplaceAscii( "%FILENAME", aSystemPath
);
3205 WarningBox
aWarning( 0, WB_YES_NO
| WB_DEF_YES
, aMsg
);
3206 aWarning
.SetImage( WarningBox::GetStandardImage() );
3207 bFound
= ( RET_NO
== aWarning
.Execute() );
3217 catch( Exception
& e
)
3220 DBG_ERROR((OString("sd::HtmlExport::checkForExistingFiles(), exception caught: ") +
3221 rtl::OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), RTL_TEXTENCODING_UTF8
)).getStr() );
3228 // ---------------------------------------------------------------------
3230 String
HtmlExport::StringToURL( const String
& rURL
)
3234 return StringToHTMLString(rURL);
3235 OUString aURL( StringToHTMLString(rURL) );
3237 aURL = Uri::encode( aURL, rtl_UriCharClassUric, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8);
3238 return String( aURL );
3242 String
HtmlExport::GetButtonName( int nButton
) const
3245 aName
.AssignAscii( pButtonNames
[nButton
] );
3249 // =====================================================================
3250 EasyFile::EasyFile()
3257 // =====================================================================
3258 EasyFile::~EasyFile()
3264 // =====================================================================
3265 ULONG
EasyFile::createStream( const String
& rUrl
, SvStream
* &rpStr
)
3275 nErr
= createFileName( rUrl
, aFileName
);
3279 pOStm
= ::utl::UcbStreamHelper::CreateStream( aFileName
, STREAM_WRITE
| STREAM_TRUNC
);
3283 nErr
= pOStm
->GetError();
3287 nErr
= ERRCODE_SFX_CANTCREATECONTENT
;
3304 // =====================================================================
3305 ULONG
EasyFile::createFileName( const String
& rURL
, String
& rFileName
)
3314 INetURLObject
aURL( rURL
);
3316 if( aURL
.GetProtocol() == INET_PROT_NOT_VALID
)
3319 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rURL
, aURLStr
);
3320 aURL
= INetURLObject( aURLStr
);
3322 DBG_ASSERT( aURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
3323 rFileName
= aURL
.GetMainURL( INetURLObject::NO_DECODE
);
3329 // =====================================================================
3330 ULONG
EasyFile::close()
3345 nErr
= pMedium
->GetError();
3354 // =====================================================================
3355 // This class helps reporting errors during file i/o
3356 // =====================================================================
3358 HtmlErrorContext::HtmlErrorContext(Window
*_pWin
)
3359 : ErrorContext(_pWin
)
3364 // =====================================================================
3366 BOOL
HtmlErrorContext::GetString( ULONG
, String
& rCtxStr
)
3368 DBG_ASSERT( mnResId
!= 0, "No error context set" );
3372 rCtxStr
= String( SdResId( mnResId
) );
3374 rCtxStr
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM("$(URL1)")), maURL1
);
3375 rCtxStr
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM("$(URL2)")), maURL2
);
3380 // =====================================================================
3382 void HtmlErrorContext::SetContext( USHORT nResId
)
3389 // =====================================================================
3391 void HtmlErrorContext::SetContext( USHORT nResId
, const String
& rURL
)
3398 // =====================================================================
3400 void HtmlErrorContext::SetContext( USHORT nResId
, const String
& rURL1
, const String
& rURL2
)
3407 // =====================================================================