crashtesting: fix failure of forum-en-13617.odt to reload from .doc
[LibreOffice.git] / sd / source / filter / eppt / eppt.hxx
blob3d95b4380229672a0f8c9bac3817f7f8a0c82ec5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
21 #include <memory>
22 #include <utility>
23 #include <vector>
24 #include "escherex.hxx"
25 #include <sal/types.h>
26 #include <sot/storage.hxx>
27 #include <unotools/securityoptions.hxx>
28 #include "pptexsoundcollection.hxx"
30 #include "text.hxx"
32 #include <com/sun/star/presentation/AnimationEffect.hpp>
33 #include <com/sun/star/presentation/ClickAction.hpp>
35 #include "epptbase.hxx"
37 namespace com::sun::star::awt { class XControlModel; }
38 namespace com::sun::star::beans { class XPropertySet; }
39 namespace com::sun::star::beans { struct PropertyValue; }
40 namespace com::sun::star::drawing { class XShape; }
41 namespace com::sun::star::frame { class XModel; }
42 namespace com::sun::star::task { class XStatusIndicator; }
43 namespace com::sun::star::text { class XSimpleText; }
45 class SotStorage;
47 #define EPP_MAINMASTER_PERSIST_KEY 0x80010000
48 #define EPP_MAINNOTESMASTER_PERSIST_KEY 0x80020000
49 #define EPP_MAINSLIDE_PERSIST_KEY 0x80030000
50 #define EPP_MAINNOTES_PERSIST_KEY 0x80040000
52 #define EPP_Persist_Document 0x80080000
53 #define EPP_Persist_MainMaster 0x80100000
54 #define EPP_Persist_MainNotes 0x80200000
55 #define EPP_Persist_Slide 0x80400000
56 #define EPP_Persist_Notes 0x80800000
57 #define EPP_Persist_CurrentPos 0x81000000
58 #define EPP_Persist_VBAInfoAtom 0x84000000
59 #define EPP_Persist_ExObj 0x88000000
61 #define EPP_TEXTSTYLE_NORMAL 0x00000001
62 #define EPP_TEXTSTYLE_TITLE 0x00000010
63 #define EPP_TEXTSTYLE_BODY 0x00000100
64 #define EPP_TEXTSTYLE_TEXT 0x00001000
66 struct EPPTHyperlink
68 OUString aURL;
69 sal_uInt32 nType; // bit 0-7 : type ( 1: click action to a slide )
70 // ( 2: hyperlink url )
71 // bit 8-23: index
72 // bit 31 : hyperlink is attached to a shape
74 EPPTHyperlink( OUString _aURL, sal_uInt32 nT ) :
75 aURL (std::move( _aURL )),
76 nType ( nT ){};
79 enum PPTExOleObjEntryType
81 NORMAL_OLE_OBJECT, OCX_CONTROL
84 struct PPTExOleObjEntry
86 PPTExOleObjEntryType eType;
87 sal_uInt32 nOfsA; ///< offset to the EPP_ExOleObjAtom in mpExEmbed (set at creation)
88 sal_uInt32 nOfsB; ///< offset to the EPP_ExOleObjStg
90 css::uno::Reference< css::awt::XControlModel > xControlModel;
91 css::uno::Reference< css::drawing::XShape > xShape;
93 PPTExOleObjEntry(PPTExOleObjEntryType eT, sal_uInt32 nOfs)
94 : eType(eT)
95 , nOfsA(nOfs)
96 , nOfsB(0)
100 struct TextRuleEntry
102 std::unique_ptr<SvMemoryStream> pOut;
105 class TextObjBinary : public TextObj
107 public:
108 TextObjBinary( css::uno::Reference< css::text::XSimpleText > const & rXText,
109 int nInstance, FontCollection& rFontCollection, PPTExBulletProvider& rBuProv ) : TextObj( rXText, nInstance, rFontCollection, rBuProv ) {}
110 void Write( SvStream* pStrm );
111 void WriteTextSpecInfo( SvStream* pStrm );
114 struct CellBorder;
115 class PPTWriter final : public PPTWriterBase, public PPTExBulletProvider
117 sal_uInt32 mnCnvrtFlags;
118 bool mbStatus;
119 sal_uInt32 mnStatMaxValue;
120 sal_uInt32 mnLatestStatValue;
122 std::vector<OUString> maSlideNameList;
123 OUString maBaseURI;
125 css::uno::Reference< css::text::XSimpleText > mXText; // TextRef of the global text
126 sal_uInt32 mnTextStyle;
128 bool mbFontIndependentLineSpacing;
129 sal_uInt32 mnTextSize;
131 rtl::Reference<SotStorage> mrStg;
132 rtl::Reference<SotStorageStream> mpCurUserStrm;
133 rtl::Reference<SotStorageStream> mpStrm;
134 rtl::Reference<SotStorageStream> mpPicStrm;
135 std::unique_ptr<PptEscherEx> mpPptEscherEx;
137 std::vector<std::unique_ptr<PPTExOleObjEntry>> maExOleObj;
138 sal_uInt32 mnVBAOleOfs;
139 SvMemoryStream* mpVBA;
140 sal_uInt32 mnExEmbed;
141 std::unique_ptr<SvMemoryStream> mpExEmbed;
142 std::unique_ptr<SvtSecurityMapPersonalInfo> mpAuthorIDs; // map authors to remove personal info
144 sal_uInt32 mnPagesWritten;
145 sal_uInt32 mnTxId; // Identifier determined by the HOST (PP) ????
146 sal_uInt32 mnDiaMode; // 0 -> manual
147 // 1 -> semi-automatic
148 // 2 -> automatic
150 sal_uInt32 mnShapeMasterTitle;
151 sal_uInt32 mnShapeMasterBody;
153 std::vector<EPPTHyperlink> maHyperlink;
155 ppt::ExSoundCollection maSoundCollection;
157 void ImplWriteExtParaHeader( SvMemoryStream& rSt, sal_uInt32 nRef, sal_uInt32 nInstance, sal_uInt32 nSlideId );
159 sal_uInt32 ImplProgBinaryTag( SvStream* pOutStrm );
160 sal_uInt32 ImplProgBinaryTagContainer( SvStream* pOutStrm, SvMemoryStream* pBinTag );
161 sal_uInt32 ImplProgTagContainer( SvStream* pOutStrm, SvMemoryStream* pBinTag = nullptr );
162 static sal_uInt32 ImplOutlineViewInfoContainer( SvStream* pOutStrm );
163 static sal_uInt32 ImplSlideViewInfoContainer( sal_uInt32 nInstance, SvStream* pOutStrm );
164 sal_uInt32 ImplVBAInfoContainer( SvStream* pOutStrm );
165 sal_uInt32 ImplDocumentListContainer( SvStream* pOutStrm );
166 sal_uInt32 ImplMasterSlideListContainer( SvStream* pOutStrm );
168 public:
169 static void WriteCString( SvStream&, std::u16string_view, sal_uInt32 nInstance = 0 );
171 private:
173 void ImplCreateDocumentSummaryInformation();
174 bool ImplCreateCurrentUserStream();
175 static void ImplCreateHeaderFooterStrings( SvStream& rOut,
176 css::uno::Reference< css::beans::XPropertySet > const & rXPagePropSet );
177 void ImplCreateHeaderFooters( css::uno::Reference< css::beans::XPropertySet > const & rXPagePropSet );
178 virtual bool ImplCreateDocument() override;
179 void ImplCreateHyperBlob( SvMemoryStream& rStream );
180 sal_uInt32 ImplInsertBookmarkURL( const OUString& rBookmark, const sal_uInt32 nType,
181 std::u16string_view aStringVer0, std::u16string_view aStringVer1, std::u16string_view aStringVer2, std::u16string_view aStringVer3 );
182 virtual bool ImplCreateMainNotes() override;
183 void ImplWriteBackground( css::uno::Reference< css::beans::XPropertySet > const & rXBackgroundPropSet );
184 void ImplWriteVBA();
185 void ImplWriteOLE();
186 void ImplWriteAtomEnding();
188 void ImplFlipBoundingBox( EscherPropertyContainer& rPropOpt );
189 bool ImplGetText();
190 bool ImplCreatePresentationPlaceholder( const bool bMaster,
191 const sal_uInt32 StyleInstance, const sal_uInt8 PlaceHolderId );
192 static bool ImplGetEffect( const css::uno::Reference< css::beans::XPropertySet > &,
193 css::presentation::AnimationEffect& eEffect,
194 css::presentation::AnimationEffect& eTextEffect,
195 bool& bHasSound );
196 void ImplWriteClickAction( SvStream& rSt, css::presentation::ClickAction eAction, bool bMediaClickAction );
197 void ImplWriteParagraphs( SvStream& rOutStrm, TextObj& rTextObj );
198 void ImplWritePortions( SvStream& rOutStrm, TextObj& rTextObj );
199 void ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_uInt32 nAtomInstance,
200 TextRuleEntry* pTextRule, SvStream& rExtBu, EscherPropertyContainer* );
201 void ImplAdjustFirstLineLineSpacing( TextObj& rTextObj, EscherPropertyContainer& rPropOpt );
202 void ImplCreateShape( sal_uInt32 nType, ShapeFlag nFlags, EscherSolverContainer& );
203 void ImplCreateTextShape( EscherPropertyContainer&, EscherSolverContainer&, bool bFill );
205 void ImplWritePage( const PHLayout& rLayout,
206 EscherSolverContainer& rSolver,
207 PageType ePageType,
208 bool bMaster,
209 int nPageNumber = 0 );
210 bool ImplCreateCellBorder( const CellBorder* pCellBorder, sal_Int32 nX1, sal_Int32 nY1, sal_Int32 nX2, sal_Int32 nY2 );
211 void ImplCreateTable( css::uno::Reference< css::drawing::XShape > const & rXShape, EscherSolverContainer& aSolverContainer,
212 EscherPropertyContainer& aPropOpt );
214 bool ImplCloseDocument(); // we write the font, hyper and sound list
216 void ImplExportComments(const css::uno::Reference<css::drawing::XDrawPage>& xPage,
217 SvMemoryStream& rBinaryTagData10Atom);
218 virtual void ImplWriteSlide( sal_uInt32 nPageNum, sal_uInt32 nMasterID, sal_uInt16 nMode,
219 bool bHasBackground, css::uno::Reference< css::beans::XPropertySet > const & aXBackgroundPropSet ) override;
220 virtual void ImplWriteNotes( sal_uInt32 nPageNum ) override;
221 virtual void ImplWriteSlideMaster( sal_uInt32 nPageNum, css::uno::Reference< css::beans::XPropertySet > const & aXBackgroundPropSet ) override;
223 public:
224 PPTWriter( rtl::Reference<SotStorage> xSvStorage,
225 css::uno::Reference< css::frame::XModel > const & rModel,
226 css::uno::Reference< css::task::XStatusIndicator > const & rStatInd,
227 SvMemoryStream* pVBA, sal_uInt32 nCnvrtFlags );
229 virtual ~PPTWriter() override;
231 bool IsValid() const { return mbStatus; };
233 virtual void exportPPTPre( const std::vector< css::beans::PropertyValue >& ) override;
234 virtual void exportPPTPost( ) override;
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */