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 .
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>
29 #include "htmlpublishmode.hxx"
32 #include <string_view>
35 namespace basegfx
{ class B2DPolyPolygon
; }
36 namespace com::sun::star::beans
{ struct PropertyValue
; }
37 namespace com::sun::star::ucb
{ class XSimpleFileAccess3
; }
38 namespace sd
{ class DrawDocShell
; }
39 namespace tools
{ class Rectangle
; }
41 #define PUB_LOWRES_WIDTH 640
42 #define PUB_MEDRES_WIDTH 800
43 #define PUB_HIGHRES_WIDTH 1024
44 #define PUB_FHDRES_WIDTH 1920
46 #define PUB_THUMBNAIL_WIDTH 256
47 #define PUB_THUMBNAIL_HEIGHT 192
50 class OutlinerParaObject
;
59 namespace sdr::table
{ class SdrTableObj
; }
64 class HtmlErrorContext
: public ErrorContext
72 explicit HtmlErrorContext();
74 virtual bool GetString( ErrCode nErrId
, OUString
& rCtxStr
) override
;
76 void SetContext(TranslateId pResId
, const OUString
& rURL
);
77 void SetContext(TranslateId pResId
, const OUString
& rURL1
, const OUString
& rURL2
);
80 /// this class exports an Impress Document as a HTML Presentation.
81 class HtmlExport final
83 std::vector
< SdPage
* > maPages
;
84 std::vector
< SdPage
* > maNotesPages
;
88 SdDrawDocument
* mpDoc
;
89 ::sd::DrawDocShell
* mpDocSh
;
91 HtmlErrorContext meEC
;
93 HtmlPublishMode meMode
;
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
;
102 PublishingFormat meFormat
;
111 sal_Int16 mnCompression
;
112 OUString maDocFileName
;
113 OUString maFramePage
;
118 double mfSlideDuration
;
124 Color maTextColor
; ///< The following colors are used for the <body> tag if mbUserAttr is true.
129 Color maFirstPageColor
;
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
;
138 OUString maExportPath
; ///< output directory or URL.
142 PublishingScript meScript
;
144 std::unique_ptr
< ButtonSet
> mpButtonSet
;
146 static SdrTextObj
* GetLayoutTextObject(SdrPage
const * pPage
);
148 void SetDocColors( SdPage
* pPage
= nullptr );
150 bool CreateImagesForPresPages( bool bThumbnails
= false );
151 bool CreateHtmlTextForPresPages();
152 bool CreateHtmlForPresPages();
153 bool CreateContentPage();
154 void CreateFileNames();
155 void CreateBitmaps();
156 bool CreateOutlinePages();
158 bool CreateNotesPages();
159 bool CreateNavBarFrames();
161 bool CreateASPScripts();
162 bool CreatePERLScripts();
163 bool CreateImageFileList();
164 bool CreateImageNumberFile();
166 bool checkForExistingFiles();
167 bool checkFileExists( css::uno::Reference
< css::ucb::XSimpleFileAccess3
> const & xFileAccess
, std::u16string_view aFileName
);
169 OUString
const & getDocumentTitle();
170 bool SavePresentation();
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;
178 OUString
ParagraphToHTMLString( SdrOutliner
const * pOutliner
, sal_Int32 nPara
, const Color
& rBackgroundColor
);
179 OUString
TextAttribToHTMLString( SfxItemSet
const * pSet
, HtmlState
* pState
, const Color
& rBackgroundColor
);
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
);
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
);
191 OUString
CreatePageURL( sal_uInt16 nPgNum
);
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 );
197 void InitProgress( sal_uInt16 nProgrCount
);
198 void ResetProgress();
200 /// Output only the charset metadata, title etc. will be handled separately.
201 static OUString
CreateMetaCharset();
203 /// Output document metadata.
204 OUString
DocumentMetadata() const;
206 void InitExportParameters( const css::uno::Sequence
< css::beans::PropertyValue
>& rParams
);
209 void ExportWebCast();
210 void ExportSingleDocument();
212 bool WriteHtml( const OUString
& rFileName
, bool bAddExtension
, std::u16string_view rHtmlData
);
213 static OUString
GetButtonName( int nButton
);
215 void WriteOutlinerParagraph(OUStringBuffer
& aStr
, SdrOutliner
* pOutliner
,
216 OutlinerParaObject
const * pOutlinerParagraphObject
,
217 const Color
& rBackgroundColor
, bool bHeadLine
);
219 void WriteObjectGroup(OUStringBuffer
& aStr
, SdrObjGroup
const * pObjectGroup
,
220 SdrOutliner
* pOutliner
, const Color
& rBackgroundColor
, bool bHeadLine
);
222 void WriteTable(OUStringBuffer
& aStr
, sdr::table::SdrTableObj
const * pTableObject
,
223 SdrOutliner
* pOutliner
, const Color
& rBackgroundColor
);
226 HtmlExport(OUString aPath
,
227 const css::uno::Sequence
<css::beans::PropertyValue
>& rParams
,
228 SdDrawDocument
* pExpDoc
,
229 sd::DrawDocShell
* pDocShell
);
233 static OUString
ColorToHTMLString( Color aColor
);
234 static OUString
StringToHTMLString( const OUString
& rString
);
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */