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 : #ifndef INCLUDED_SD_SOURCE_FILTER_HTML_HTMLEX_HXX
21 : #define INCLUDED_SD_SOURCE_FILTER_HTML_HTMLEX_HXX
22 :
23 : #include <com/sun/star/beans/PropertyValue.hpp>
24 : #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
25 : #include <vcl/gdimtf.hxx>
26 : #include <svl/itemset.hxx>
27 : #include "resltn.hxx"
28 : #include <svtools/colrdlg.hxx>
29 : #include <svtools/ehdl.hxx>
30 :
31 : #include "strings.hrc"
32 : #include "DrawDocShell.hxx"
33 : #include "Window.hxx"
34 : #include "ViewShell.hxx"
35 : #include "assclass.hxx"
36 :
37 : #include "sdresid.hxx"
38 : #include "htmlpublishmode.hxx"
39 :
40 : #include <vector>
41 : #include <boost/scoped_ptr.hpp>
42 :
43 : #define PUB_LOWRES_WIDTH 640
44 : #define PUB_LOWRES_HEIGHT 480
45 : #define PUB_MEDRES_WIDTH 800
46 : #define PUB_MEDRES_HEIGHT 600
47 : #define PUB_HIGHRES_WIDTH 1024
48 : #define PUB_HIGHRES_HEIGHT 768
49 :
50 : #define PUB_THUMBNAIL_WIDTH 256
51 : #define PUB_THUMBNAIL_HEIGHT 192
52 :
53 : class SfxProgress;
54 : class SdrOutliner;
55 : class SdPage;
56 : class HtmlState;
57 : class SdrTextObj;
58 : class SdrObjGroup;
59 : namespace sdr { namespace table { class SdrTableObj; } }
60 : class SdrPage;
61 : class SdDrawDocument;
62 : class ButtonSet;
63 :
64 : class HtmlErrorContext : public ErrorContext
65 : {
66 : private:
67 : sal_uInt16 mnResId;
68 : OUString maURL1;
69 : OUString maURL2;
70 :
71 : public:
72 : HtmlErrorContext(vcl::Window *pWin=0);
73 2 : virtual ~HtmlErrorContext() {};
74 :
75 : virtual bool GetString( sal_uLong nErrId, OUString& rCtxStr ) SAL_OVERRIDE;
76 :
77 : void SetContext( sal_uInt16 nResId, const OUString& rURL );
78 : void SetContext( sal_uInt16 nResId, const OUString& rURL1, const OUString& rURL2 );
79 : };
80 :
81 : /// this class exports an Impress Document as a HTML Presentation.
82 : class HtmlExport
83 : {
84 : std::vector< SdPage* > maPages;
85 : std::vector< SdPage* > maNotesPages;
86 :
87 : OUString maPath;
88 :
89 : SdDrawDocument* mpDoc;
90 : ::sd::DrawDocShell* mpDocSh;
91 :
92 : HtmlErrorContext meEC;
93 :
94 : HtmlPublishMode meMode;
95 : SfxProgress* mpProgress;
96 : bool mbImpress;
97 : sal_uInt16 mnSdPageCount;
98 : sal_uInt16 mnPagesWritten;
99 : bool mbContentsPage;
100 : sal_Int16 mnButtonThema;
101 : sal_uInt16 mnWidthPixel;
102 : sal_uInt16 mnHeightPixel;
103 : PublishingFormat meFormat;
104 : bool mbHeader;
105 : bool mbNotes;
106 : bool mbFrames;
107 : OUString maIndex;
108 : OUString maEMail;
109 : OUString maAuthor;
110 : OUString maHomePage;
111 : OUString maInfo;
112 : sal_Int16 mnCompression;
113 : OUString maDocFileName;
114 : OUString maFramePage;
115 : OUString mDocTitle;
116 : bool mbDownload;
117 :
118 : bool mbAutoSlide;
119 : double mfSlideDuration;
120 : bool mbSlideSound;
121 : bool mbHiddenSlides;
122 : bool mbEndless;
123 :
124 : bool mbUserAttr;
125 : Color maTextColor; ///< The following colors are used for the <body> tag if mbUserAttr is true.
126 : Color maBackColor;
127 : Color maLinkColor;
128 : Color maVLinkColor;
129 : Color maALinkColor;
130 : Color maFirstPageColor;
131 : bool mbDocColors;
132 :
133 : OUString maHTMLExtension;
134 : std::vector<OUString> maHTMLFiles;
135 : std::vector<OUString> maImageFiles;
136 : std::vector<OUString> maThumbnailFiles;
137 : std::vector<OUString> maPageNames;
138 : std::vector<OUString> maTextFiles;
139 :
140 : OUString maExportPath; ///< output directory or URL.
141 : OUString maIndexUrl;
142 : OUString maURLPath;
143 : OUString maCGIPath;
144 : PublishingScript meScript;
145 :
146 : const OUString maHTMLHeader;
147 :
148 : boost::scoped_ptr< ButtonSet > mpButtonSet;
149 :
150 : SdrTextObj* GetLayoutTextObject(SdrPage* pPage);
151 :
152 : void SetDocColors( SdPage* pPage = NULL );
153 :
154 : bool CreateImagesForPresPages( bool bThumbnails = false );
155 : bool CreateHtmlTextForPresPages();
156 : bool CreateHtmlForPresPages();
157 : bool CreateContentPage();
158 : void CreateFileNames();
159 : bool CreateBitmaps();
160 : bool CreateOutlinePages();
161 : bool CreateFrames();
162 : bool CreateNotesPages();
163 : bool CreateNavBarFrames();
164 :
165 : bool CreateASPScripts();
166 : bool CreatePERLScripts();
167 : bool CreateImageFileList();
168 : bool CreateImageNumberFile();
169 :
170 : bool checkForExistingFiles();
171 : bool checkFileExists( ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xFileAccess, OUString const & aFileName );
172 :
173 : OUString getDocumentTitle();
174 : bool SavePresentation();
175 :
176 : OUString CreateLink( const OUString& aLink, const OUString& aText,
177 : const OUString& aTarget = OUString()) const;
178 : OUString CreateImage( const OUString& aImage, const OUString& aAltText, sal_Int16 nWidth = -1, sal_Int16 nHeight = -1 ) const;
179 : OUString CreateNavBar( sal_uInt16 nSdPage, bool bIsText ) const;
180 : OUString CreateBodyTag() const;
181 :
182 : OUString ParagraphToHTMLString( SdrOutliner* pOutliner, sal_Int32 nPara, const Color& rBackgroundColor );
183 : OUString TextAttribToHTMLString( SfxItemSet* pSet, HtmlState* pState, const Color& rBackgroundColor );
184 :
185 : OUString CreateTextForTitle( SdrOutliner* pOutliner, SdPage* pPage, const Color& rBackgroundColor );
186 : OUString CreateTextForPage( SdrOutliner* pOutliner, SdPage* pPage, bool bHeadLine, const Color& rBackgroundColor );
187 : OUString CreateTextForNotesPage( SdrOutliner* pOutliner, SdPage* pPage, bool bHeadLine, const Color& rBackgroundColor );
188 :
189 : OUString CreateHTMLCircleArea( sal_uLong nRadius, sal_uLong nCenterX,
190 : sal_uLong nCenterY, const OUString& rHRef ) const;
191 : OUString CreateHTMLPolygonArea( const ::basegfx::B2DPolyPolygon& rPolyPoly, Size aShift, double fFactor, const OUString& rHRef ) const;
192 : OUString CreateHTMLRectArea( const Rectangle& rRect,
193 : const OUString& rHRef ) const;
194 :
195 : OUString CreatePageURL( sal_uInt16 nPgNum );
196 :
197 : OUString InsertSound( const OUString& rSoundFile );
198 : bool CopyFile( const OUString& rSourceFile, const OUString& rDestFile );
199 : bool CopyScript( const OUString& rPath, const OUString& rSource, const OUString& rDest, bool bUnix = false );
200 :
201 : void InitProgress( sal_uInt16 nProgrCount );
202 : void ResetProgress();
203 :
204 : /// Output only the charset metadata, title etc. will be handled separately.
205 : OUString CreateMetaCharset() const;
206 :
207 : /// Output document metadata.
208 : OUString DocumentMetadata() const;
209 :
210 : void InitExportParameters( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rParams);
211 : void ExportHtml();
212 : void ExportKiosk();
213 : void ExportWebCast();
214 : void ExportSingleDocument();
215 :
216 : bool WriteHtml( const OUString& rFileName, bool bAddExtension, const OUString& rHtmlData );
217 : OUString GetButtonName( int nButton ) const;
218 :
219 : void WriteOutlinerParagraph(OUStringBuffer& aStr, SdrOutliner* pOutliner,
220 : OutlinerParaObject* pOutlinerParagraphObject,
221 : const Color& rBackgroundColor, bool bHeadLine);
222 :
223 : void WriteObjectGroup(OUStringBuffer& aStr, SdrObjGroup* pObjectGroup,
224 : SdrOutliner* pOutliner, const Color& rBackgroundColor, bool bHeadLine);
225 :
226 : void WriteTable(OUStringBuffer& aStr, sdr::table::SdrTableObj* pTableObject,
227 : SdrOutliner* pOutliner, const Color& rBackgroundColor);
228 :
229 : public:
230 : HtmlExport(const OUString& aPath,
231 : const css::uno::Sequence<css::beans::PropertyValue>& rParams,
232 : SdDrawDocument* pExpDoc,
233 : sd::DrawDocShell* pDocShell);
234 :
235 : virtual ~HtmlExport();
236 :
237 : static OUString ColorToHTMLString( Color aColor );
238 : static OUString StringToHTMLString( const OUString& rString );
239 : };
240 :
241 : #endif // INCLUDED_SD_SOURCE_FILTER_HTML_HTMLEX_HXX
242 :
243 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|