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