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 "epptbase.hxx"
27 using ::sax_fastparser::FSHelperPtr
;
38 std::vector
< sal_Int32
> mnFileIdArray
;
55 class PowerPointShapeExport
;
57 class PowerPointExport final
: public XmlFilterBase
, public PPTWriterBase
59 friend class PowerPointShapeExport
;
62 PowerPointExport(const css::uno::Reference
<css::uno::XComponentContext
> & rContext
, const css::uno::Sequence
<css::uno::Any
>& rArguments
);
64 virtual ~PowerPointExport() override
;
67 virtual bool importDocument() noexcept override
;
68 virtual bool exportDocument() override
;
70 // only needed for import, leave them empty, refactor later XmlFilterBase to export and import base?
71 virtual oox::vml::Drawing
* getVmlDrawing() override
{ return nullptr; }
72 virtual const oox::drawingml::Theme
* getCurrentTheme() const override
{ return nullptr; }
73 virtual oox::drawingml::table::TableStyleListPtr
getTableStyles() override
{ return oox::drawingml::table::TableStyleListPtr(); }
74 virtual oox::drawingml::chart::ChartConverter
* getChartConverter() override
{ return nullptr; }
76 static const char* GetSideDirection( sal_uInt8 nDirection
);
77 static const char* GetCornerDirection( sal_uInt8 nDirection
);
78 static const char* Get8Direction( sal_uInt8 nDirection
);
80 sal_Int32
GetShapeID(const css::uno::Reference
<css::drawing::XShape
>& rXShape
);
81 sal_Int32
GetNextAnimationNodeID();
83 void embedEffectAudio(const FSHelperPtr
& pFS
, const OUString
& sUrl
, OUString
& sRelId
, OUString
& sName
);
87 virtual void ImplWriteSlide( sal_uInt32 nPageNum
, sal_uInt32 nMasterNum
, sal_uInt16 nMode
,
88 bool bHasBackground
, css::uno::Reference
< css::beans::XPropertySet
> const & aXBackgroundPropSet
) override
;
89 virtual void ImplWriteNotes( sal_uInt32 nPageNum
) override
;
90 virtual void ImplWriteSlideMaster( sal_uInt32 nPageNum
, css::uno::Reference
< css::beans::XPropertySet
> const & aXBackgroundPropSet
) override
;
91 void ImplWritePPTXLayout( sal_Int32 nOffset
, sal_uInt32 nMasterNum
, const OUString
& aSlideName
);
92 static void WriteDefaultColorSchemes(const FSHelperPtr
& pFS
);
93 void WriteTheme( sal_Int32 nThemeNum
, model::Theme
* pTheme
);
95 virtual bool ImplCreateDocument() override
;
96 virtual bool ImplCreateMainNotes() override
;
97 virtual ::oox::ole::VbaProject
* implCreateVbaProject() const override
;
98 void WriteNotesMaster();
100 bool WriteComments( sal_uInt32 nPageNum
);
101 void ImplWriteBackground( const ::sax_fastparser::FSHelperPtr
& pFS
, const css::uno::Reference
< css::beans::XPropertySet
>& aXBackgroundPropSet
);
102 void WriteTransition( const ::sax_fastparser::FSHelperPtr
& pFS
);
104 sal_Int32
GetLayoutFileId( sal_Int32 nOffset
, sal_uInt32 nMasterNum
);
107 void WriteShapeTree( const ::sax_fastparser::FSHelperPtr
& pFS
, PageType ePageType
, bool bMaster
);
109 sal_uInt32
GetNewSlideId() { return mnSlideIdMax
++; }
110 sal_uInt32
GetNewSlideMasterId() { return mnSlideMasterIdMax
++; }
111 sal_Int32
GetAuthorIdAndLastIndex( const OUString
& sAuthor
, sal_Int32
& nLastIndex
);
113 // Write docProps/core.xml and docprops/custom.xml and docprops/app.xml
114 void writeDocumentProperties();
116 void WriteCustomSlideShow();
118 void AddLayoutIdAndRelation( const ::sax_fastparser::FSHelperPtr
& pFS
, sal_Int32 nLayoutFileId
);
120 virtual OUString SAL_CALL
getImplementationName() override
;
122 static void WriteDiagram(const FSHelperPtr
& pFS
, PowerPointShapeExport
& rDML
, const css::uno::Reference
<css::drawing::XShape
>& rXShape
, int nDiagramId
);
124 /** Create a new placeholder index for a master placeholder shape
126 @param rXShape Master placeholder shape
127 @returns Placeholder index
129 sal_Int32
CreateNewPlaceholderIndex(const css::uno::Reference
<css::drawing::XShape
>& rXShape
);
130 css::uno::Reference
<css::drawing::XShape
> GetReferencedPlaceholderXShape(const PlaceholderType eType
, PageType ePageType
) const;
131 void WritePlaceholderReferenceShapes(PowerPointShapeExport
& rDML
, PageType ePageType
);
133 /// Should we export as .pptm, ie. do we contain macros?
136 // Export as a template
137 bool mbExportTemplate
;
139 ::sax_fastparser::FSHelperPtr mPresentationFS
;
141 LayoutInfo mLayoutInfo
[OOXML_LAYOUT_SIZE
];
142 std::vector
< ::sax_fastparser::FSHelperPtr
> mpSlidesFSArray
;
143 sal_Int32 mnLayoutFileIdMax
;
145 sal_uInt32 mnSlideIdMax
;
146 sal_uInt32 mnSlideMasterIdMax
;
147 sal_uInt32 mnAnimationNodeIdMax
;
149 sal_uInt32 mnDiagramId
;
151 std::vector
<OUString
> maRelId
;
155 ::oox::drawingml::ShapeExport::ShapeHashMap maShapeMap
;
157 sal_Int32 mnPlaceholderIndexMax
; ///< Last used placeholder index
158 /// Map of placeholder indexes for Master placeholders
159 std::unordered_map
< css::uno::Reference
<css::drawing::XShape
>, sal_Int32
> maPlaceholderShapeToIndexMap
;
161 struct AuthorComments
{
163 sal_Int32 nLastIndex
;
165 typedef std::unordered_map
< OUString
, struct AuthorComments
> AuthorsMap
;
166 AuthorsMap maAuthors
;
170 void WritePresentationProps();
172 /// If this is PPTM, output the VBA stream.
175 void WriteModifyVerifier();
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */