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 .
22 #include <oox/core/xmlfilterbase.hxx>
23 #include <oox/vml/vmldrawing.hxx>
24 #include <oox/export/shapes.hxx>
25 #include <unotools/securityoptions.hxx>
26 #include "epptbase.hxx"
28 using ::sax_fastparser::FSHelperPtr
;
39 std::vector
< sal_Int32
> mnFileIdArray
;
56 class PowerPointShapeExport
;
58 class PowerPointExport final
: public XmlFilterBase
, public PPTWriterBase
60 friend class PowerPointShapeExport
;
63 PowerPointExport(const css::uno::Reference
<css::uno::XComponentContext
> & rContext
, const css::uno::Sequence
<css::uno::Any
>& rArguments
);
65 virtual ~PowerPointExport() override
;
68 virtual bool importDocument() noexcept override
;
69 virtual bool exportDocument() override
;
71 // only needed for import, leave them empty, refactor later XmlFilterBase to export and import base?
72 virtual oox::vml::Drawing
* getVmlDrawing() override
{ return nullptr; }
73 virtual const oox::drawingml::Theme
* getCurrentTheme() const override
{ return nullptr; }
74 virtual oox::drawingml::table::TableStyleListPtr
getTableStyles() override
{ return oox::drawingml::table::TableStyleListPtr(); }
75 virtual oox::drawingml::chart::ChartConverter
* getChartConverter() override
{ return nullptr; }
77 static const char* GetSideDirection( sal_uInt8 nDirection
);
78 static const char* GetCornerDirection( sal_uInt8 nDirection
);
79 static const char* Get8Direction( sal_uInt8 nDirection
);
81 sal_Int32
GetShapeID(const css::uno::Reference
<css::drawing::XShape
>& rXShape
);
82 sal_Int32
GetNextAnimationNodeID();
84 void embedEffectAudio(const FSHelperPtr
& pFS
, const OUString
& sUrl
, OUString
& sRelId
, OUString
& sName
);
88 virtual void ImplWriteSlide( sal_uInt32 nPageNum
, sal_uInt32 nMasterNum
, sal_uInt16 nMode
,
89 bool bHasBackground
, css::uno::Reference
< css::beans::XPropertySet
> const & aXBackgroundPropSet
) override
;
90 virtual void ImplWriteNotes( sal_uInt32 nPageNum
) override
;
91 virtual void ImplWriteSlideMaster( sal_uInt32 nPageNum
, css::uno::Reference
< css::beans::XPropertySet
> const & aXBackgroundPropSet
) override
;
92 void ImplWritePPTXLayout( sal_Int32 nOffset
, sal_uInt32 nMasterNum
, const OUString
& aSlideName
);
93 static void WriteDefaultColorSchemes(const FSHelperPtr
& pFS
);
94 void WriteTheme( sal_Int32 nThemeNum
, model::Theme
* pTheme
);
96 virtual bool ImplCreateDocument() override
;
97 virtual bool ImplCreateMainNotes() override
;
98 virtual ::oox::ole::VbaProject
* implCreateVbaProject() const override
;
99 void WriteNotesMaster();
101 bool WriteComments( sal_uInt32 nPageNum
);
102 void ImplWriteBackground( const ::sax_fastparser::FSHelperPtr
& pFS
, const css::uno::Reference
< css::beans::XPropertySet
>& aXBackgroundPropSet
);
103 void WriteTransition( const ::sax_fastparser::FSHelperPtr
& pFS
);
105 sal_Int32
GetLayoutFileId( sal_Int32 nOffset
, sal_uInt32 nMasterNum
);
108 void WriteShapeTree( const ::sax_fastparser::FSHelperPtr
& pFS
, PageType ePageType
, bool bMaster
);
110 sal_uInt32
GetNewSlideId() { return mnSlideIdMax
++; }
111 sal_uInt32
GetNewSlideMasterId() { return mnSlideMasterIdMax
++; }
112 sal_Int32
GetAuthorIdAndLastIndex( const OUString
& sAuthor
, const OUString
& sInitials
, sal_Int32
& nLastIndex
);
114 // Write docProps/core.xml and docprops/custom.xml and docprops/app.xml
115 void writeDocumentProperties();
117 void WriteCustomSlideShow();
119 void AddLayoutIdAndRelation( const ::sax_fastparser::FSHelperPtr
& pFS
, sal_Int32 nLayoutFileId
);
121 virtual OUString SAL_CALL
getImplementationName() override
;
123 static void WriteDiagram(const FSHelperPtr
& pFS
, PowerPointShapeExport
& rDML
, const css::uno::Reference
<css::drawing::XShape
>& rXShape
, int nDiagramId
);
125 /** Create a new placeholder index for a master placeholder shape
127 @param rXShape Master placeholder shape
128 @returns Placeholder index
130 sal_Int32
CreateNewPlaceholderIndex(const css::uno::Reference
<css::drawing::XShape
>& rXShape
);
131 css::uno::Reference
<css::drawing::XShape
> GetReferencedPlaceholderXShape(const PlaceholderType eType
, PageType ePageType
) const;
132 void WritePlaceholderReferenceShapes(PowerPointShapeExport
& rDML
, PageType ePageType
);
134 /// Should we export as .pptm, ie. do we contain macros?
137 // Export as a template
138 bool mbExportTemplate
;
140 ::sax_fastparser::FSHelperPtr mPresentationFS
;
142 LayoutInfo mLayoutInfo
[OOXML_LAYOUT_SIZE
];
143 std::unique_ptr
<SvtSecurityMapPersonalInfo
> mpAuthorIDs
; // map authors to remove personal info
144 std::vector
< ::sax_fastparser::FSHelperPtr
> mpSlidesFSArray
;
145 sal_Int32 mnLayoutFileIdMax
;
147 sal_uInt32 mnSlideIdMax
;
148 sal_uInt32 mnSlideMasterIdMax
;
149 sal_uInt32 mnAnimationNodeIdMax
;
151 sal_uInt32 mnDiagramId
;
153 std::vector
<OUString
> maRelId
;
157 ::oox::drawingml::ShapeExport::ShapeHashMap maShapeMap
;
159 sal_Int32 mnPlaceholderIndexMax
; ///< Last used placeholder index
160 /// Map of placeholder indexes for Master placeholders
161 std::unordered_map
< css::uno::Reference
<css::drawing::XShape
>, sal_Int32
> maPlaceholderShapeToIndexMap
;
163 // Get author id to remove personal info
164 size_t GetInfoID( const OUString
& sPersonalInfo
) const { return mpAuthorIDs
->GetInfoID(sPersonalInfo
); }
165 struct AuthorComments
{
167 sal_Int32 nLastIndex
;
175 AuthorComments(sal_Int32 nId_
, sal_Int32 nLastIndex_
, OUString sInitials_
)
177 , nLastIndex(nLastIndex_
)
178 , sInitials(std::move(sInitials_
))
182 typedef std::unordered_map
< OUString
, struct AuthorComments
> AuthorsMap
;
183 AuthorsMap maAuthors
;
187 void WritePresentationProps();
189 /// If this is PPTM, output the VBA stream.
192 void WriteModifyVerifier();
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */