xref: /aoo41x/main/sd/source/filter/html/htmlex.hxx (revision 67e470da)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_HTMLEX_HXX
25 #define _SD_HTMLEX_HXX
26 
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
29 #include <vcl/gdimtf.hxx>
30 #include <svl/itemset.hxx>
31 #include "resltn.hxx"       // enum PublishingResolution
32 #include <svtools/colrdlg.hxx>
33 #include <svtools/ehdl.hxx>
34 
35 #include "strings.hrc"
36 #include "DrawDocShell.hxx"
37 #include "Window.hxx"
38 #include "ViewShell.hxx"
39 #include "assclass.hxx"
40 
41 #ifndef _SD_RESID_HXX
42 #include "sdresid.hxx"
43 #endif
44 #include "pubdlg.hxx"
45 
46 #include <vector>
47 #include <boost/scoped_ptr.hpp>
48 
49 #define NUM_BUTTONS 12
50 
51 #define PUB_LOWRES_WIDTH	640
52 #define PUB_LOWRES_HEIGHT	480
53 #define PUB_MEDRES_WIDTH	800
54 #define PUB_MEDRES_HEIGHT	600
55 #define PUB_HIGHRES_WIDTH	1024
56 #define PUB_HIGHRES_HEIGHT	768
57 
58 class List;
59 class SfxProgress;
60 class SdrOutliner;
61 class SdPage;
62 class HtmlState;
63 class SdrTextObj;
64 class SdrPage;
65 class SdDrawDocument;
66 class ButtonSet;
67 
68 namespace sd {
69 class View;
70 }
71 
72 class HtmlErrorContext : public ErrorContext
73 {
74 private:
75 	sal_uInt16	mnResId;
76 	String	maURL1;
77 	String	maURL2;
78 
79 public:
80 					HtmlErrorContext(Window *pWin=0);
~HtmlErrorContext()81 					~HtmlErrorContext() {};
82 
83 	virtual sal_Bool	GetString( sal_uLong nErrId, String& rCtxStr );
84 
85 	void			SetContext( sal_uInt16 nResId, const String& rURL );
86 	void			SetContext( sal_uInt16 nResId, const String& rURL1, const String& rURL2 );
87 };
88 
89 // =====================================================================
90 // this class exports an Impress Document as a HTML Presentation
91 // =====================================================================
92 class HtmlExport
93 {
94     std::vector< SdPage* > maPages;
95     std::vector< SdPage* > maNotesPages;
96 
97 	String maPath;
98 
99 	SdDrawDocument* mpDoc;
100 	::sd::DrawDocShell* mpDocSh;
101 
102 	HtmlErrorContext meEC;
103 
104 	HtmlPublishMode meMode;
105 	SfxProgress* mpProgress;
106 	bool mbImpress;
107 	sal_uInt16 mnSdPageCount;
108 	sal_uInt16 mnPagesWritten;
109 	bool mbContentsPage;
110 	sal_Int16 mnButtonThema;
111 	sal_uInt16 mnWidthPixel;
112 	sal_uInt16 mnHeightPixel;
113 	PublishingFormat meFormat;
114 	bool mbHeader;
115 	bool mbNotes;
116 	bool mbFrames;
117 	bool mbKiosk;
118 	String maIndex;
119 	String maEMail;
120 	String maAuthor;
121 	String maHomePage;
122 	String maInfo;
123 	sal_Int16 mnCompression;
124 	String maDocFileName;
125 	String maFramePage;
126 	String mDocTitle;
127 	bool mbDownload;
128 
129 	bool mbAutoSlide;
130 	sal_uInt32	mnSlideDuration;
131 	bool mbSlideSound;
132     bool mbHiddenSlides;
133 	bool mbEndless;
134 
135 	bool mbUserAttr;			// die folgenden Farben werden fuer das <body>
136 	Color maTextColor;			// tag genutzt, wenn mbUserAttr true ist
137 	Color maBackColor;
138 	Color maLinkColor;
139 	Color maVLinkColor;
140 	Color maALinkColor;
141 	Color maFirstPageColor;
142 	bool mbDocColors;
143 
144 	String	 maHTMLExtension;
145 	String** mpHTMLFiles;
146 	String** mpImageFiles;
147 	String** mpPageNames;
148 	String** mpTextFiles;
149 
150 	String maExportPath;			// Das Ausgabeverzeichnes bzw. die URL
151 	String maIndexUrl;
152 	String maURLPath;
153 	String maCGIPath;
154 	PublishingScript meScript;
155 
156 	const String maHTMLHeader;
157 
158 	boost::scoped_ptr< ButtonSet > mpButtonSet;
159 
160 	SdrTextObj* GetLayoutTextObject(SdrPage* pPage);
161 
162 	void SetDocColors( SdPage* pPage = NULL );
163 
164 	bool	CreateImagesForPresPages();
165 	bool	CreateHtmlTextForPresPages();
166 	bool	CreateHtmlForPresPages();
167 	bool	CreateContentPage();
168 	void	CreateFileNames();
169 	bool	CreateBitmaps();
170 	bool	CreateOutlinePages();
171 	bool	CreateFrames();
172 	bool	CreateNotesPages();
173 	bool	CreateNavBarFrames();
174 
175 	bool	CreateASPScripts();
176 	bool	CreatePERLScripts();
177 	bool	CreateImageFileList();
178 	bool	CreateImageNumberFile();
179 
180 	bool	checkForExistingFiles();
181 	bool	checkFileExists( ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xFileAccess, String const & aFileName );
182 
183 	String getDocumentTitle();
184 	bool	SavePresentation();
185 
186 	String	CreateLink( const String& aLink, const String& aText,
187 						const String& aTarget = String()) const;
188 	String	CreateImage( const String& aImage, const String& aAltText, sal_Int16 nWidth = -1, sal_Int16 nHeight = -1 ) const;
189 	String	CreateNavBar( sal_uInt16 nSdPage, bool bIsText ) const;
190 	String	CreateBodyTag() const;
191 
192 	String	ParagraphToHTMLString( SdrOutliner* pOutliner, sal_uLong nPara, const Color& rBackgroundColor );
193 	String	TextAttribToHTMLString( SfxItemSet* pSet, HtmlState* pState, const Color& rBackgroundColor );
194 
195 	String	CreateTextForTitle( SdrOutliner* pOutliner, SdPage* pPage, const Color& rBackgroundColor );
196 	String	CreateTextForPage( SdrOutliner* pOutliner, SdPage* pPage, bool bHeadLine, const Color& rBackgroundColor );
197 	String	CreateTextForNotesPage( SdrOutliner* pOutliner, SdPage* pPage, bool bHeadLine, const Color& rBackgroundColor );
198 
199 	String	CreateHTMLCircleArea( sal_uLong nRadius, sal_uLong nCenterX,
200 								  sal_uLong nCenterY, const String& rHRef ) const;
201 	String	CreateHTMLPolygonArea( const ::basegfx::B2DPolyPolygon& rPolyPoly, Size aShift, double fFactor, const String& rHRef ) const;
202 	String	CreateHTMLRectArea( const Rectangle& rRect,
203 								const String& rHRef ) const;
204 
205 	String	CreatePageURL( sal_uInt16 nPgNum );
206 
207 	String InsertSound( const String& rSoundFile );
208 	bool CopyFile( const String& rSourceFile, const String& rDestPath );
209 	bool CopyScript( const String& rPath, const String& rSource, const String& rDest, bool bUnix = false );
210 
211 	void InitProgress( sal_uInt16 nProgrCount );
212 	void ResetProgress();
213 
214 	String WriteMetaCharset() const;
215 
216 	void InitExportParameters( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rParams);
217 	void ExportHtml();
218 	void ExportKiosk();
219 	void ExportWebCast();
220 
221 	bool WriteHtml( const String& rFileName, bool bAddExtension, const String& rHtmlData );
222 	String GetButtonName( int nButton ) const;
223 
224  public:
225 	 HtmlExport( rtl::OUString aPath, const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rParams, SdDrawDocument* pExpDoc, ::sd::DrawDocShell* pDocShell );
226 	virtual ~HtmlExport();
227 
228 	static String	ColorToHTMLString( Color aColor );
229 	static String	StringToHTMLString( const String& rString );
230 	static String	StringToURL( const String& rURL );
231 };
232 
233 #endif // _SD_HTMLEX_HXX
234