Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / oox / source / ppt / dgmlayout.cxx
blobb68214ce0952446a680f1b91dda68c05a9b04e2b
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 #include <basegfx/matrix/b2dhommatrix.hxx>
21 #include "oox/ppt/dgmlayout.hxx"
22 #include "oox/drawingml/theme.hxx"
23 #include "oox/drawingml/themefragmenthandler.hxx"
24 #include "drawingml/diagram/diagram.hxx"
25 #include "oox/dump/pptxdumper.hxx"
27 #include <com/sun/star/awt/Rectangle.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/drawing/XShape.hpp>
30 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
31 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <com/sun/star/xml/dom/XDocument.hpp>
33 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
34 #include <com/sun/star/container/XChild.hpp>
36 #include <services.hxx>
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::xml::sax;
41 using namespace oox::core;
42 using namespace ::oox::drawingml;
44 namespace oox { namespace ppt {
46 OUString SAL_CALL QuickDiagrammingLayout_getImplementationName()
48 return OUString( "com.sun.star.comp.Impress.oox.QuickDiagrammingLayout" );
51 uno::Sequence< OUString > SAL_CALL QuickDiagrammingLayout_getSupportedServiceNames()
53 const OUString aServiceName = "com.sun.star.comp.ooxpptx.dgm.layout";
54 const Sequence< OUString > aSeq( &aServiceName, 1 );
55 return aSeq;
58 uno::Reference< uno::XInterface > SAL_CALL QuickDiagrammingLayout_createInstance( const Reference< XComponentContext >& rxContext )
60 return static_cast<cppu::OWeakObject*>(new QuickDiagrammingLayout( rxContext ));
63 QuickDiagrammingLayout::QuickDiagrammingLayout( const Reference< XComponentContext >& rxContext )
64 : XmlFilterBase( rxContext ),
65 mpThemePtr(new drawingml::Theme())
68 bool QuickDiagrammingLayout::importDocument()
70 Reference<drawing::XShape> xParentShape(getParentShape(),
71 UNO_QUERY_THROW);
72 Reference<drawing::XShapes> xParentShapes(xParentShape,
73 UNO_QUERY_THROW);
74 Reference<beans::XPropertySet> xPropSet(xParentShape,
75 UNO_QUERY_THROW);
77 // can we grab the theme from the master page?
78 Reference<container::XChild> xChild(xParentShape,
79 UNO_QUERY);
80 if( xChild.is() )
82 // TODO: cater for diagram shapes inside groups
83 Reference<drawing::XMasterPageTarget> xMasterPageTarget(xChild->getParent(),
84 UNO_QUERY);
85 if( xMasterPageTarget.is() )
87 uno::Reference<drawing::XDrawPage> xMasterPage(
88 xMasterPageTarget->getMasterPage());
90 Reference<beans::XPropertySet> xPropSet2(xMasterPage,
91 UNO_QUERY_THROW);
92 Reference<xml::dom::XDocument> xThemeFragment;
93 xPropSet2->getPropertyValue("PPTTheme") >>= xThemeFragment;
95 importFragment(
96 new ThemeFragmentHandler(
97 *this, OUString(), *mpThemePtr ),
98 Reference<xml::sax::XFastSAXSerializable>(
99 xThemeFragment,
100 UNO_QUERY_THROW));
104 Reference<xml::dom::XDocument> xDataModelDom;
105 Reference<xml::dom::XDocument> xLayoutDom;
106 Reference<xml::dom::XDocument> xQStyleDom;
107 Reference<xml::dom::XDocument> xColorStyleDom;
109 xPropSet->getPropertyValue("DiagramData") >>= xDataModelDom;
110 xPropSet->getPropertyValue("DiagramLayout") >>= xLayoutDom;
111 xPropSet->getPropertyValue("DiagramQStyle") >>= xQStyleDom;
112 xPropSet->getPropertyValue("DiagramColorStyle") >>= xColorStyleDom;
114 oox::drawingml::ShapePtr pShape(
115 new oox::drawingml::Shape( "com.sun.star.drawing.DiagramShape" ) );
116 drawingml::loadDiagram(pShape,
117 *this,
118 xDataModelDom,
119 xLayoutDom,
120 xQStyleDom,
121 xColorStyleDom);
123 // don't add pShape itself, but only its children
124 pShape->setXShape(getParentShape());
126 basegfx::B2DHomMatrix aMatrix;
127 pShape->addChildren( *this,
128 mpThemePtr.get(),
129 xParentShapes,
130 aMatrix );
132 return true;
135 bool QuickDiagrammingLayout::exportDocument() throw()
137 return false;
140 const ::oox::drawingml::Theme* QuickDiagrammingLayout::getCurrentTheme() const
142 return mpThemePtr.get();
145 const oox::drawingml::table::TableStyleListPtr QuickDiagrammingLayout::getTableStyles()
147 return oox::drawingml::table::TableStyleListPtr();
150 ::oox::vml::Drawing* QuickDiagrammingLayout::getVmlDrawing()
152 return nullptr;
155 ::oox::drawingml::chart::ChartConverter* QuickDiagrammingLayout::getChartConverter()
157 return nullptr;
160 OUString QuickDiagrammingLayout::getImplementationName()
162 return QuickDiagrammingLayout_getImplementationName();
165 ::oox::ole::VbaProject* QuickDiagrammingLayout::implCreateVbaProject() const
167 return nullptr;
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */