LibreOffice Module sd (master) 1
htmlex.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <resltn.hxx>
23#include <rtl/ustrbuf.hxx>
24#include <tools/color.hxx>
25#include <tools/solar.h>
26#include <vcl/errinf.hxx>
27#include <unotools/resmgr.hxx>
28
29#include "htmlpublishmode.hxx"
30
31#include <memory>
32#include <string_view>
33#include <vector>
34
35namespace basegfx { class B2DPolyPolygon; }
36namespace com::sun::star::beans { struct PropertyValue; }
37namespace com::sun::star::ucb { class XSimpleFileAccess3; }
38namespace sd { class DrawDocShell; }
39namespace tools { class Rectangle; }
40
41#define PUB_LOWRES_WIDTH 640
42#define PUB_MEDRES_WIDTH 800
43#define PUB_HIGHRES_WIDTH 1024
44#define PUB_FHDRES_WIDTH 1920
45
46#define PUB_THUMBNAIL_WIDTH 256
47#define PUB_THUMBNAIL_HEIGHT 192
48
49class ErrCode;
51class SfxItemSet;
52class Size;
53class SfxProgress;
54class SdrOutliner;
55class SdPage;
56class HtmlState;
57class SdrTextObj;
58class SdrObjGroup;
59namespace sdr::table { class SdrTableObj; }
60class SdrPage;
61class SdDrawDocument;
62class ButtonSet;
63
65{
66private:
68 OUString maURL1;
69 OUString maURL2;
70
71public:
72 explicit HtmlErrorContext();
73
74 virtual bool GetString( ErrCode nErrId, OUString& rCtxStr ) override;
75
76 void SetContext(TranslateId pResId, const OUString& rURL);
77 void SetContext(TranslateId pResId, const OUString& rURL1, const OUString& rURL2);
78};
79
81class HtmlExport final
82{
83 std::vector< SdPage* > maPages;
84 std::vector< SdPage* > maNotesPages;
85
86 OUString maPath;
87
90
92
94 std::unique_ptr<SfxProgress> mpProgress;
96 sal_uInt16 mnSdPageCount;
97 sal_uInt16 mnPagesWritten;
99 sal_Int16 mnButtonThema;
100 sal_uInt16 mnWidthPixel;
101 sal_uInt16 mnHeightPixel;
106 OUString maIndex;
107 OUString maEMail;
108 OUString maAuthor;
109 OUString maHomePage;
110 OUString maInfo;
111 sal_Int16 mnCompression;
113 OUString maFramePage;
114 OUString mDocTitle;
116
122
131
132 std::vector<OUString> maHTMLFiles;
133 std::vector<OUString> maImageFiles;
134 std::vector<OUString> maThumbnailFiles;
135 std::vector<OUString> maPageNames;
136 std::vector<OUString> maTextFiles;
137
138 OUString maExportPath;
139 OUString maIndexUrl;
140 OUString maURLPath;
141 OUString maCGIPath;
143
144 std::unique_ptr< ButtonSet > mpButtonSet;
145
146 static SdrTextObj* GetLayoutTextObject(SdrPage const * pPage);
147
148 void SetDocColors( SdPage* pPage = nullptr );
149
150 bool CreateImagesForPresPages( bool bThumbnails = false );
153 bool CreateContentPage();
154 void CreateFileNames();
155 void CreateBitmaps();
156 bool CreateOutlinePages();
157 bool CreateFrames();
158 bool CreateNotesPages();
159 bool CreateNavBarFrames();
160
161 bool CreateASPScripts();
162 bool CreatePERLScripts();
163 bool CreateImageFileList();
165
167 bool checkFileExists( css::uno::Reference< css::ucb::XSimpleFileAccess3 > const & xFileAccess, std::u16string_view aFileName );
168
169 OUString const & getDocumentTitle();
170 bool SavePresentation();
171
172 static OUString CreateLink( std::u16string_view aLink, std::u16string_view aText,
173 std::u16string_view aTarget = std::u16string_view());
174 static OUString CreateImage( std::u16string_view aImage, std::u16string_view aAltText );
175 OUString CreateNavBar( sal_uInt16 nSdPage, bool bIsText ) const;
176 OUString CreateBodyTag() const;
177
178 OUString ParagraphToHTMLString( SdrOutliner const * pOutliner, sal_Int32 nPara, const Color& rBackgroundColor );
179 OUString TextAttribToHTMLString( SfxItemSet const * pSet, HtmlState* pState, const Color& rBackgroundColor );
180
181 OUString CreateTextForTitle( SdrOutliner* pOutliner, SdPage* pPage, const Color& rBackgroundColor );
182 OUString CreateTextForPage( SdrOutliner* pOutliner, SdPage const * pPage, bool bHeadLine, const Color& rBackgroundColor );
183 OUString CreateTextForNotesPage( SdrOutliner* pOutliner, SdPage* pPage, const Color& rBackgroundColor );
184
185 static OUString CreateHTMLCircleArea( sal_uLong nRadius, sal_uLong nCenterX,
186 sal_uLong nCenterY, std::u16string_view rHRef );
187 static OUString CreateHTMLPolygonArea( const ::basegfx::B2DPolyPolygon& rPolyPoly, Size aShift, double fFactor, std::u16string_view rHRef );
188 static OUString CreateHTMLRectArea( const ::tools::Rectangle& rRect,
189 std::u16string_view rHRef );
190
191 OUString CreatePageURL( sal_uInt16 nPgNum );
192
193 OUString InsertSound( const OUString& rSoundFile );
194 bool CopyFile( const OUString& rSourceFile, const OUString& rDestFile );
195 bool CopyScript( std::u16string_view rPath, const OUString& rSource, const OUString& rDest, bool bUnix = false );
196
197 void InitProgress( sal_uInt16 nProgrCount );
198 void ResetProgress();
199
201 static OUString CreateMetaCharset();
202
204 OUString DocumentMetadata() const;
205
206 void InitExportParameters( const css::uno::Sequence< css::beans::PropertyValue >& rParams);
207 void ExportHtml();
208 void ExportKiosk();
209 void ExportWebCast();
211
212 bool WriteHtml( const OUString& rFileName, bool bAddExtension, std::u16string_view rHtmlData );
213 static OUString GetButtonName( int nButton );
214
215 void WriteOutlinerParagraph(OUStringBuffer& aStr, SdrOutliner* pOutliner,
216 OutlinerParaObject const * pOutlinerParagraphObject,
217 const Color& rBackgroundColor, bool bHeadLine);
218
219 void WriteObjectGroup(OUStringBuffer& aStr, SdrObjGroup const * pObjectGroup,
220 SdrOutliner* pOutliner, const Color& rBackgroundColor, bool bHeadLine);
221
222 void WriteTable(OUStringBuffer& aStr, sdr::table::SdrTableObj const * pTableObject,
223 SdrOutliner* pOutliner, const Color& rBackgroundColor);
224
225 public:
226 HtmlExport(OUString aPath,
227 const css::uno::Sequence<css::beans::PropertyValue>& rParams,
228 SdDrawDocument* pExpDoc,
229 sd::DrawDocShell* pDocShell);
230
231 ~HtmlExport();
232
233 static OUString ColorToHTMLString( Color aColor );
234 static OUString StringToHTMLString( const OUString& rString );
235};
236
237/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool GetString(ErrCode nErrId, OUString &rCtxStr) override
Definition: htmlex.cxx:3148
void SetContext(TranslateId pResId, const OUString &rURL)
Definition: htmlex.cxx:3162
OUString maURL1
Definition: htmlex.hxx:68
OUString maURL2
Definition: htmlex.hxx:69
TranslateId mpResId
Definition: htmlex.hxx:67
this class exports an Impress Document as a HTML Presentation.
Definition: htmlex.hxx:82
bool mbImpress
Definition: htmlex.hxx:95
bool mbEndless
Definition: htmlex.hxx:121
OUString DocumentMetadata() const
Output document metadata.
Definition: htmlex.cxx:1053
std::vector< OUString > maThumbnailFiles
Definition: htmlex.hxx:134
static OUString CreateHTMLPolygonArea(const ::basegfx::B2DPolyPolygon &rPolyPoly, Size aShift, double fFactor, std::u16string_view rHRef)
Definition: htmlex.cxx:2745
bool mbHeader
Definition: htmlex.hxx:103
void WriteObjectGroup(OUStringBuffer &aStr, SdrObjGroup const *pObjectGroup, SdrOutliner *pOutliner, const Color &rBackgroundColor, bool bHeadLine)
Definition: htmlex.cxx:1277
bool mbUserAttr
Definition: htmlex.hxx:123
bool mbAutoSlide
Definition: htmlex.hxx:117
static OUString CreateImage(std::u16string_view aImage, std::u16string_view aAltText)
Definition: htmlex.cxx:2694
void ExportSingleDocument()
Definition: htmlex.cxx:624
void WriteTable(OUStringBuffer &aStr, sdr::table::SdrTableObj const *pTableObject, SdrOutliner *pOutliner, const Color &rBackgroundColor)
Definition: htmlex.cxx:1249
PublishingFormat meFormat
Definition: htmlex.hxx:102
PublishingScript meScript
Definition: htmlex.hxx:142
sal_uInt16 mnSdPageCount
Definition: htmlex.hxx:96
OUString TextAttribToHTMLString(SfxItemSet const *pSet, HtmlState *pState, const Color &rBackgroundColor)
Definition: htmlex.cxx:1430
void CreateBitmaps()
Definition: htmlex.cxx:2631
OUString const & getDocumentTitle()
Definition: htmlex.cxx:2172
static OUString GetButtonName(int nButton)
Definition: htmlex.cxx:3073
std::vector< OUString > maHTMLFiles
Definition: htmlex.hxx:132
bool CreateOutlinePages()
Definition: htmlex.cxx:2056
sal_Int16 mnButtonThema
Definition: htmlex.hxx:99
static OUString CreateHTMLCircleArea(sal_uLong nRadius, sal_uLong nCenterX, sal_uLong nCenterY, std::u16string_view rHRef)
Definition: htmlex.cxx:2729
std::vector< SdPage * > maPages
Definition: htmlex.hxx:83
OUString maInfo
Definition: htmlex.hxx:110
void ExportHtml()
Definition: htmlex.cxx:694
::sd::DrawDocShell * mpDocSh
Definition: htmlex.hxx:89
bool CreateASPScripts()
creates and saves the ASP scripts for WebShow
Definition: htmlex.cxx:2891
~HtmlExport()
Definition: htmlex.cxx:398
bool CreateHtmlForPresPages()
Definition: htmlex.cxx:1518
OUString CreateTextForTitle(SdrOutliner *pOutliner, SdPage *pPage, const Color &rBackgroundColor)
creates an outliner text for the title objects of a page
Definition: htmlex.cxx:1170
bool CreatePERLScripts()
Definition: htmlex.cxx:2907
void WriteOutlinerParagraph(OUStringBuffer &aStr, SdrOutliner *pOutliner, OutlinerParaObject const *pOutlinerParagraphObject, const Color &rBackgroundColor, bool bHeadLine)
Definition: htmlex.cxx:1300
bool SavePresentation()
Definition: htmlex.cxx:924
std::unique_ptr< SfxProgress > mpProgress
Definition: htmlex.hxx:94
sal_Int16 mnCompression
Definition: htmlex.hxx:111
OUString CreatePageURL(sal_uInt16 nPgNum)
Definition: htmlex.cxx:2805
OUString ParagraphToHTMLString(SdrOutliner const *pOutliner, sal_Int32 nPara, const Color &rBackgroundColor)
Definition: htmlex.cxx:1390
OUString mDocTitle
Definition: htmlex.hxx:114
std::vector< OUString > maPageNames
Definition: htmlex.hxx:135
Color maLinkColor
Definition: htmlex.hxx:126
bool mbContentsPage
Definition: htmlex.hxx:98
sal_uInt16 mnHeightPixel
Definition: htmlex.hxx:101
void InitProgress(sal_uInt16 nProgrCount)
Definition: htmlex.cxx:836
bool CreateImageNumberFile()
Definition: htmlex.cxx:2949
OUString maHomePage
Definition: htmlex.hxx:109
SdDrawDocument * mpDoc
Definition: htmlex.hxx:88
static OUString CreateLink(std::u16string_view aLink, std::u16string_view aText, std::u16string_view aTarget=std::u16string_view())
Definition: htmlex.cxx:2679
std::vector< SdPage * > maNotesPages
Definition: htmlex.hxx:84
std::vector< OUString > maImageFiles
Definition: htmlex.hxx:133
bool CreateContentPage()
Definition: htmlex.cxx:1887
OUString CreateTextForPage(SdrOutliner *pOutliner, SdPage const *pPage, bool bHeadLine, const Color &rBackgroundColor)
Definition: htmlex.cxx:1191
OUString maExportPath
output directory or URL.
Definition: htmlex.hxx:138
Color maTextColor
The following colors are used for the <body> tag if mbUserAttr is true.
Definition: htmlex.hxx:124
HtmlExport(OUString aPath, const css::uno::Sequence< css::beans::PropertyValue > &rParams, SdDrawDocument *pExpDoc, sd::DrawDocShell *pDocShell)
Definition: htmlex.cxx:346
bool mbHiddenSlides
Definition: htmlex.hxx:120
void SetDocColors(SdPage *pPage=nullptr)
Definition: htmlex.cxx:793
bool CreateNotesPages()
Definition: htmlex.cxx:2018
bool CreateHtmlTextForPresPages()
Definition: htmlex.cxx:1075
Color maBackColor
Definition: htmlex.hxx:125
static OUString CreateMetaCharset()
Output only the charset metadata, title etc. will be handled separately.
Definition: htmlex.cxx:1041
OUString CreateNavBar(sal_uInt16 nSdPage, bool bIsText) const
Definition: htmlex.cxx:2531
void CreateFileNames()
Definition: htmlex.cxx:2115
static OUString CreateHTMLRectArea(const ::tools::Rectangle &rRect, std::u16string_view rHRef)
Definition: htmlex.cxx:2780
bool CreateImagesForPresPages(bool bThumbnails=false)
Definition: htmlex.cxx:958
bool CreateFrames()
Definition: htmlex.cxx:2260
sal_uInt16 mnWidthPixel
Definition: htmlex.hxx:100
OUString CreateBodyTag() const
Definition: htmlex.cxx:2650
void ExportWebCast()
Definition: htmlex.cxx:862
sal_uInt16 mnPagesWritten
Definition: htmlex.hxx:97
bool CreateImageFileList()
Definition: htmlex.cxx:2927
static OUString StringToHTMLString(const OUString &rString)
Definition: htmlex.cxx:2795
HtmlErrorContext meEC
Definition: htmlex.hxx:91
static SdrTextObj * GetLayoutTextObject(SdrPage const *pPage)
Definition: htmlex.cxx:1022
bool CreateNavBarFrames()
Definition: htmlex.cxx:2372
OUString maDocFileName
Definition: htmlex.hxx:112
bool checkForExistingFiles()
Definition: htmlex.cxx:3022
OUString maAuthor
Definition: htmlex.hxx:108
bool mbNotes
Definition: htmlex.hxx:104
bool mbDownload
Definition: htmlex.hxx:115
Color maVLinkColor
Definition: htmlex.hxx:127
Color maALinkColor
Definition: htmlex.hxx:128
OUString maPath
Definition: htmlex.hxx:86
OUString maIndexUrl
Definition: htmlex.hxx:139
bool checkFileExists(css::uno::Reference< css::ucb::XSimpleFileAccess3 > const &xFileAccess, std::u16string_view aFileName)
Definition: htmlex.cxx:3007
OUString maFramePage
Definition: htmlex.hxx:113
bool CopyScript(std::u16string_view rPath, const OUString &rSource, const OUString &rDest, bool bUnix=false)
Definition: htmlex.cxx:2816
std::vector< OUString > maTextFiles
Definition: htmlex.hxx:136
OUString CreateTextForNotesPage(SdrOutliner *pOutliner, SdPage *pPage, const Color &rBackgroundColor)
Definition: htmlex.cxx:1360
void InitExportParameters(const css::uno::Sequence< css::beans::PropertyValue > &rParams)
Definition: htmlex.cxx:403
Color maFirstPageColor
Definition: htmlex.hxx:129
void ExportKiosk()
Definition: htmlex.cxx:846
OUString maURLPath
Definition: htmlex.hxx:140
bool mbDocColors
Definition: htmlex.hxx:130
double mfSlideDuration
Definition: htmlex.hxx:118
OUString maIndex
Definition: htmlex.hxx:106
bool CopyFile(const OUString &rSourceFile, const OUString &rDestFile)
Definition: htmlex.cxx:2991
bool WriteHtml(const OUString &rFileName, bool bAddExtension, std::u16string_view rHtmlData)
exports the given html data into a non unicode file in the current export path with the given filenam...
Definition: htmlex.cxx:1142
bool mbFrames
Definition: htmlex.hxx:105
bool mbSlideSound
Definition: htmlex.hxx:119
OUString maCGIPath
Definition: htmlex.hxx:141
OUString InsertSound(const OUString &rSoundFile)
Definition: htmlex.cxx:2973
std::unique_ptr< ButtonSet > mpButtonSet
Definition: htmlex.hxx:144
static OUString ColorToHTMLString(Color aColor)
Definition: htmlex.cxx:2714
void ResetProgress()
Definition: htmlex.cxx:841
HtmlPublishMode meMode
Definition: htmlex.hxx:93
OUString maEMail
Definition: htmlex.hxx:107
HtmlPublishMode
PublishingFormat
Definition: resltn.hxx:23
PublishingScript
Definition: resltn.hxx:30
sal_uIntPtr sal_uLong