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 .
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 );
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(),
72 Reference
<drawing::XShapes
> xParentShapes(xParentShape
,
74 Reference
<beans::XPropertySet
> xPropSet(xParentShape
,
77 // can we grab the theme from the master page?
78 Reference
<container::XChild
> xChild(xParentShape
,
82 // TODO: cater for diagram shapes inside groups
83 Reference
<drawing::XMasterPageTarget
> xMasterPageTarget(xChild
->getParent(),
85 if( xMasterPageTarget
.is() )
87 uno::Reference
<drawing::XDrawPage
> xMasterPage(
88 xMasterPageTarget
->getMasterPage());
90 Reference
<beans::XPropertySet
> xPropSet2(xMasterPage
,
92 Reference
<xml::dom::XDocument
> xThemeFragment
;
93 xPropSet2
->getPropertyValue("PPTTheme") >>= xThemeFragment
;
96 new ThemeFragmentHandler(
97 *this, OUString(), *mpThemePtr
),
98 Reference
<xml::sax::XFastSAXSerializable
>(
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
,
123 // don't add pShape itself, but only its children
124 pShape
->setXShape(getParentShape());
126 basegfx::B2DHomMatrix aMatrix
;
127 pShape
->addChildren( *this,
135 bool QuickDiagrammingLayout::exportDocument() throw()
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()
155 ::oox::drawingml::chart::ChartConverter
* QuickDiagrammingLayout::getChartConverter()
160 OUString
QuickDiagrammingLayout::getImplementationName()
162 return QuickDiagrammingLayout_getImplementationName();
165 ::oox::ole::VbaProject
* QuickDiagrammingLayout::implCreateVbaProject() const
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */