fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / ppt / dgmlayout.cxx
blob681f5b532a7a51f5f59fc9a5ee9d30a8fdfa1795
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 "oox/ppt/dgmlayout.hxx"
21 #include "oox/drawingml/theme.hxx"
22 #include "oox/drawingml/themefragmenthandler.hxx"
23 #include "drawingml/diagram/diagram.hxx"
24 #include "oox/dump/pptxdumper.hxx"
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/xml/dom/XDocument.hpp>
31 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
32 #include <com/sun/star/container/XChild.hpp>
34 #include <services.hxx>
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::xml::sax;
39 using namespace oox::core;
40 using namespace ::oox::drawingml;
42 namespace oox { namespace ppt {
44 OUString SAL_CALL QuickDiagrammingLayout_getImplementationName()
46 return OUString( "com.sun.star.comp.Impress.oox.QuickDiagrammingLayout" );
49 uno::Sequence< OUString > SAL_CALL QuickDiagrammingLayout_getSupportedServiceNames()
51 const OUString aServiceName = "com.sun.star.comp.ooxpptx.dgm.layout";
52 const Sequence< OUString > aSeq( &aServiceName, 1 );
53 return aSeq;
56 uno::Reference< uno::XInterface > SAL_CALL QuickDiagrammingLayout_createInstance( const Reference< XComponentContext >& rxContext ) throw( Exception )
58 return (cppu::OWeakObject*)new QuickDiagrammingLayout( rxContext );
61 QuickDiagrammingLayout::QuickDiagrammingLayout( const Reference< XComponentContext >& rxContext )
62 : XmlFilterBase( rxContext ),
63 mpThemePtr(new drawingml::Theme())
66 bool QuickDiagrammingLayout::importDocument() throw (css::uno::RuntimeException)
68 Reference<drawing::XShape> xParentShape(getParentShape(),
69 UNO_QUERY_THROW);
70 Reference<drawing::XShapes> xParentShapes(xParentShape,
71 UNO_QUERY_THROW);
72 Reference<beans::XPropertySet> xPropSet(xParentShape,
73 UNO_QUERY_THROW);
75 // can we grab the theme from the master page?
76 Reference<container::XChild> xChild(xParentShape,
77 UNO_QUERY);
78 if( xChild.is() )
80 // TODO: cater for diagram shapes inside groups
81 Reference<drawing::XMasterPageTarget> xMasterPageTarget(xChild->getParent(),
82 UNO_QUERY);
83 if( xMasterPageTarget.is() )
85 uno::Reference<drawing::XDrawPage> xMasterPage(
86 xMasterPageTarget->getMasterPage());
88 Reference<beans::XPropertySet> xPropSet2(xMasterPage,
89 UNO_QUERY_THROW);
90 Reference<xml::dom::XDocument> xThemeFragment;
91 xPropSet2->getPropertyValue("PPTTheme") >>= xThemeFragment;
93 importFragment(
94 new ThemeFragmentHandler(
95 *this, OUString(), *mpThemePtr ),
96 Reference<xml::sax::XFastSAXSerializable>(
97 xThemeFragment,
98 UNO_QUERY_THROW));
102 Reference<xml::dom::XDocument> xDataModelDom;
103 Reference<xml::dom::XDocument> xLayoutDom;
104 Reference<xml::dom::XDocument> xQStyleDom;
105 Reference<xml::dom::XDocument> xColorStyleDom;
107 xPropSet->getPropertyValue("DiagramData") >>= xDataModelDom;
108 xPropSet->getPropertyValue("DiagramLayout") >>= xLayoutDom;
109 xPropSet->getPropertyValue("DiagramQStyle") >>= xQStyleDom;
110 xPropSet->getPropertyValue("DiagramColorStyle") >>= xColorStyleDom;
112 oox::drawingml::ShapePtr pShape(
113 new oox::drawingml::Shape( "com.sun.star.drawing.DiagramShape" ) );
114 drawingml::loadDiagram(pShape,
115 *this,
116 xDataModelDom,
117 xLayoutDom,
118 xQStyleDom,
119 xColorStyleDom);
121 // don't add pShape itself, but only its children
122 pShape->setXShape(getParentShape());
124 const awt::Size& rSize=xParentShape->getSize();
125 const awt::Point& rPoint=xParentShape->getPosition();
126 const long nScaleFactor=360;
127 const awt::Rectangle aRect(nScaleFactor*rPoint.X,
128 nScaleFactor*rPoint.Y,
129 nScaleFactor*rSize.Width,
130 nScaleFactor*rSize.Height);
131 basegfx::B2DHomMatrix aMatrix;
132 pShape->addChildren( *this,
133 mpThemePtr.get(),
134 xParentShapes,
135 aMatrix,
136 &aRect );
138 return true;
141 bool QuickDiagrammingLayout::exportDocument() throw()
143 return false;
146 const ::oox::drawingml::Theme* QuickDiagrammingLayout::getCurrentTheme() const
148 return mpThemePtr.get();
151 const oox::drawingml::table::TableStyleListPtr QuickDiagrammingLayout::getTableStyles()
153 return oox::drawingml::table::TableStyleListPtr();
156 ::oox::vml::Drawing* QuickDiagrammingLayout::getVmlDrawing()
158 return 0;
161 ::oox::drawingml::chart::ChartConverter* QuickDiagrammingLayout::getChartConverter()
163 return 0;
166 OUString QuickDiagrammingLayout::getImplementationName() throw (css::uno::RuntimeException, std::exception)
168 return QuickDiagrammingLayout_getImplementationName();
171 ::oox::ole::VbaProject* QuickDiagrammingLayout::implCreateVbaProject() const
173 return 0;
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */