1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SD_SOURCE_FILTER_HTML_HTMLEX_HXX
21 #define INCLUDED_SD_SOURCE_FILTER_HTML_HTMLEX_HXX
24 #include <rtl/ustrbuf.hxx>
25 #include <tools/color.hxx>
26 #include <tools/solar.h>
27 #include <vcl/errinf.hxx>
29 #include "htmlpublishmode.hxx"
34 namespace basegfx
{ class B2DPolyPolygon
; }
35 namespace com::sun::star::beans
{ struct PropertyValue
; }
36 namespace com::sun::star::ucb
{ class XSimpleFileAccess3
; }
37 namespace sd
{ class DrawDocShell
; }
38 namespace tools
{ class Rectangle
; }
40 #define PUB_LOWRES_WIDTH 640
41 #define PUB_MEDRES_WIDTH 800
42 #define PUB_HIGHRES_WIDTH 1024
44 #define PUB_THUMBNAIL_WIDTH 256
45 #define PUB_THUMBNAIL_HEIGHT 192
48 class OutlinerParaObject
;
57 namespace sdr::table
{ class SdrTableObj
; }
62 class HtmlErrorContext
: public ErrorContext
70 explicit HtmlErrorContext();
72 virtual bool GetString( ErrCode nErrId
, OUString
& rCtxStr
) override
;
74 void SetContext(const char* pResId
, const OUString
& rURL
);
75 void SetContext(const char* pResId
, const OUString
& rURL1
, const OUString
& rURL2
);
78 /// this class exports an Impress Document as a HTML Presentation.
79 class HtmlExport final
81 std::vector
< SdPage
* > maPages
;
82 std::vector
< SdPage
* > maNotesPages
;
86 SdDrawDocument
* mpDoc
;
87 ::sd::DrawDocShell
* mpDocSh
;
89 HtmlErrorContext meEC
;
91 HtmlPublishMode meMode
;
92 std::unique_ptr
<SfxProgress
> mpProgress
;
94 sal_uInt16 mnSdPageCount
;
95 sal_uInt16 mnPagesWritten
;
97 sal_Int16 mnButtonThema
;
98 sal_uInt16 mnWidthPixel
;
99 sal_uInt16 mnHeightPixel
;
100 PublishingFormat meFormat
;
109 sal_Int16 mnCompression
;
110 OUString maDocFileName
;
111 OUString maFramePage
;
116 double mfSlideDuration
;
122 Color maTextColor
; ///< The following colors are used for the <body> tag if mbUserAttr is true.
127 Color maFirstPageColor
;
130 std::vector
<OUString
> maHTMLFiles
;
131 std::vector
<OUString
> maImageFiles
;
132 std::vector
<OUString
> maThumbnailFiles
;
133 std::vector
<OUString
> maPageNames
;
134 std::vector
<OUString
> maTextFiles
;
136 OUString maExportPath
; ///< output directory or URL.
140 PublishingScript meScript
;
142 std::unique_ptr
< ButtonSet
> mpButtonSet
;
144 static SdrTextObj
* GetLayoutTextObject(SdrPage
const * pPage
);
146 void SetDocColors( SdPage
* pPage
= nullptr );
148 bool CreateImagesForPresPages( bool bThumbnails
= false );
149 bool CreateHtmlTextForPresPages();
150 bool CreateHtmlForPresPages();
151 bool CreateContentPage();
152 void CreateFileNames();
153 void CreateBitmaps();
154 bool CreateOutlinePages();
156 bool CreateNotesPages();
157 bool CreateNavBarFrames();
159 bool CreateASPScripts();
160 bool CreatePERLScripts();
161 bool CreateImageFileList();
162 bool CreateImageNumberFile();
164 bool checkForExistingFiles();
165 bool checkFileExists( css::uno::Reference
< css::ucb::XSimpleFileAccess3
> const & xFileAccess
, OUString
const & aFileName
);
167 OUString
const & getDocumentTitle();
168 bool SavePresentation();
170 static OUString
CreateLink( const OUString
& aLink
, const OUString
& aText
,
171 const OUString
& aTarget
= OUString());
172 static OUString
CreateImage( const OUString
& aImage
, const OUString
& aAltText
);
173 OUString
CreateNavBar( sal_uInt16 nSdPage
, bool bIsText
) const;
174 OUString
CreateBodyTag() const;
176 OUString
ParagraphToHTMLString( SdrOutliner
const * pOutliner
, sal_Int32 nPara
, const Color
& rBackgroundColor
);
177 OUString
TextAttribToHTMLString( SfxItemSet
const * pSet
, HtmlState
* pState
, const Color
& rBackgroundColor
);
179 OUString
CreateTextForTitle( SdrOutliner
* pOutliner
, SdPage
* pPage
, const Color
& rBackgroundColor
);
180 OUString
CreateTextForPage( SdrOutliner
* pOutliner
, SdPage
const * pPage
, bool bHeadLine
, const Color
& rBackgroundColor
);
181 OUString
CreateTextForNotesPage( SdrOutliner
* pOutliner
, SdPage
* pPage
, const Color
& rBackgroundColor
);
183 static OUString
CreateHTMLCircleArea( sal_uLong nRadius
, sal_uLong nCenterX
,
184 sal_uLong nCenterY
, const OUString
& rHRef
);
185 static OUString
CreateHTMLPolygonArea( const ::basegfx::B2DPolyPolygon
& rPolyPoly
, Size aShift
, double fFactor
, const OUString
& rHRef
);
186 static OUString
CreateHTMLRectArea( const ::tools::Rectangle
& rRect
,
187 const OUString
& rHRef
);
189 OUString
CreatePageURL( sal_uInt16 nPgNum
);
191 OUString
InsertSound( const OUString
& rSoundFile
);
192 bool CopyFile( const OUString
& rSourceFile
, const OUString
& rDestFile
);
193 bool CopyScript( const OUString
& rPath
, const OUString
& rSource
, const OUString
& rDest
, bool bUnix
= false );
195 void InitProgress( sal_uInt16 nProgrCount
);
196 void ResetProgress();
198 /// Output only the charset metadata, title etc. will be handled separately.
199 static OUString
CreateMetaCharset();
201 /// Output document metadata.
202 OUString
DocumentMetadata() const;
204 void InitExportParameters( const css::uno::Sequence
< css::beans::PropertyValue
>& rParams
);
207 void ExportWebCast();
208 void ExportSingleDocument();
210 bool WriteHtml( const OUString
& rFileName
, bool bAddExtension
, const OUString
& rHtmlData
);
211 static OUString
GetButtonName( int nButton
);
213 void WriteOutlinerParagraph(OUStringBuffer
& aStr
, SdrOutliner
* pOutliner
,
214 OutlinerParaObject
const * pOutlinerParagraphObject
,
215 const Color
& rBackgroundColor
, bool bHeadLine
);
217 void WriteObjectGroup(OUStringBuffer
& aStr
, SdrObjGroup
const * pObjectGroup
,
218 SdrOutliner
* pOutliner
, const Color
& rBackgroundColor
, bool bHeadLine
);
220 void WriteTable(OUStringBuffer
& aStr
, sdr::table::SdrTableObj
const * pTableObject
,
221 SdrOutliner
* pOutliner
, const Color
& rBackgroundColor
);
224 HtmlExport(const OUString
& aPath
,
225 const css::uno::Sequence
<css::beans::PropertyValue
>& rParams
,
226 SdDrawDocument
* pExpDoc
,
227 sd::DrawDocShell
* pDocShell
);
231 static OUString
ColorToHTMLString( Color aColor
);
232 static OUString
StringToHTMLString( const OUString
& rString
);
235 #endif // INCLUDED_SD_SOURCE_FILTER_HTML_HTMLEX_HXX
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */