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 "oox/ppt/dgmlayout.hxx"
21 #include "oox/drawingml/theme.hxx"
22 #include "oox/drawingml/themefragmenthandler.hxx"
23 #include "oox/drawingml/diagram/diagram.hxx"
24 #include "oox/dump/pptxdumper.hxx"
26 #include <com/sun/star/drawing/XShape.hpp>
27 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
28 #include <com/sun/star/xml/dom/XDocument.hpp>
29 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
30 #include <com/sun/star/container/XChild.hpp>
32 using namespace ::com::sun::star
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::xml::sax
;
35 using namespace oox::core
;
36 using namespace ::oox::drawingml
;
38 namespace oox
{ namespace ppt
{
40 OUString SAL_CALL
QuickDiagrammingLayout_getImplementationName() throw()
42 return OUString( "com.sun.star.comp.Impress.oox.QuickDiagrammingLayout" );
45 uno::Sequence
< OUString
> SAL_CALL
QuickDiagrammingLayout_getSupportedServiceNames() throw()
47 const OUString aServiceName
= "com.sun.star.comp.ooxpptx.dgm.layout";
48 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
52 uno::Reference
< uno::XInterface
> SAL_CALL
QuickDiagrammingLayout_createInstance( const Reference
< XComponentContext
>& rxContext
) throw( Exception
)
54 return (cppu::OWeakObject
*)new QuickDiagrammingLayout( rxContext
);
57 QuickDiagrammingLayout::QuickDiagrammingLayout( const Reference
< XComponentContext
>& rxContext
)
58 : XmlFilterBase( rxContext
),
59 mpThemePtr(new drawingml::Theme())
62 bool QuickDiagrammingLayout::importDocument() throw()
64 Reference
<drawing::XShape
> xParentShape(getParentShape(),
66 Reference
<drawing::XShapes
> xParentShapes(xParentShape
,
68 Reference
<beans::XPropertySet
> xPropSet(xParentShape
,
71 // can we grab the theme from the master page?
72 Reference
<container::XChild
> xChild(xParentShape
,
76 // TODO: cater for diagram shapes inside groups
77 Reference
<drawing::XMasterPageTarget
> xMasterPageTarget(xChild
->getParent(),
79 if( xMasterPageTarget
.is() )
81 uno::Reference
<drawing::XDrawPage
> xMasterPage(
82 xMasterPageTarget
->getMasterPage());
84 Reference
<beans::XPropertySet
> xPropSet2(xMasterPage
,
86 Reference
<xml::dom::XDocument
> xThemeFragment
;
87 xPropSet2
->getPropertyValue("PPTTheme") >>= xThemeFragment
;
90 new ThemeFragmentHandler(
91 *this, OUString(), *mpThemePtr
),
92 Reference
<xml::sax::XFastSAXSerializable
>(
98 Reference
<xml::dom::XDocument
> xDataModelDom
;
99 Reference
<xml::dom::XDocument
> xLayoutDom
;
100 Reference
<xml::dom::XDocument
> xQStyleDom
;
101 Reference
<xml::dom::XDocument
> xColorStyleDom
;
103 xPropSet
->getPropertyValue("DiagramData") >>= xDataModelDom
;
104 xPropSet
->getPropertyValue("DiagramLayout") >>= xLayoutDom
;
105 xPropSet
->getPropertyValue("DiagramQStyle") >>= xQStyleDom
;
106 xPropSet
->getPropertyValue("DiagramColorStyle") >>= xColorStyleDom
;
108 oox::drawingml::ShapePtr
pShape(
109 new oox::drawingml::Shape( "com.sun.star.drawing.DiagramShape" ) );
110 drawingml::loadDiagram(pShape
,
117 // don't add pShape itself, but only its children
118 pShape
->setXShape(getParentShape());
120 const awt::Size
& rSize
=xParentShape
->getSize();
121 const awt::Point
& rPoint
=xParentShape
->getPosition();
122 const long nScaleFactor
=360;
123 const awt::Rectangle
aRect(nScaleFactor
*rPoint
.X
,
124 nScaleFactor
*rPoint
.Y
,
125 nScaleFactor
*rSize
.Width
,
126 nScaleFactor
*rSize
.Height
);
127 basegfx::B2DHomMatrix aMatrix
;
128 pShape
->addChildren( *this,
137 bool QuickDiagrammingLayout::exportDocument() throw()
142 const ::oox::drawingml::Theme
* QuickDiagrammingLayout::getCurrentTheme() const
144 return mpThemePtr
.get();
147 sal_Int32
QuickDiagrammingLayout::getSchemeClr( sal_Int32 nColorSchemeToken
) const
149 sal_Int32 nColor
= 0;
151 mpThemePtr
->getClrScheme().getColor( nColorSchemeToken
,
156 const oox::drawingml::table::TableStyleListPtr
QuickDiagrammingLayout::getTableStyles()
158 return oox::drawingml::table::TableStyleListPtr();
161 ::oox::vml::Drawing
* QuickDiagrammingLayout::getVmlDrawing()
166 ::oox::drawingml::chart::ChartConverter
* QuickDiagrammingLayout::getChartConverter()
171 OUString
QuickDiagrammingLayout::implGetImplementationName() const
173 return QuickDiagrammingLayout_getImplementationName();
176 ::oox::ole::VbaProject
* QuickDiagrammingLayout::implCreateVbaProject() const
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */