LCOV - code coverage report
Current view: top level - libreoffice/oox/source/ppt - dgmlayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 73 4.1 %
Date: 2012-12-27 Functions: 3 15 20.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      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"
      25             : 
      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>
      31             : 
      32             : using ::rtl::OUString;
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::xml::sax;
      36             : using namespace oox::core;
      37             : using namespace ::oox::drawingml;
      38             : 
      39             : namespace oox { namespace ppt {
      40             : 
      41          14 : OUString SAL_CALL QuickDiagrammingLayout_getImplementationName() throw()
      42             : {
      43          14 :     return CREATE_OUSTRING( "com.sun.star.comp.Impress.oox.QuickDiagrammingLayout" );
      44             : }
      45             : 
      46           0 : uno::Sequence< OUString > SAL_CALL QuickDiagrammingLayout_getSupportedServiceNames() throw()
      47             : {
      48           0 :     const OUString aServiceName = CREATE_OUSTRING( "com.sun.star.comp.ooxpptx.dgm.layout" );
      49           0 :     const Sequence< OUString > aSeq( &aServiceName, 1 );
      50           0 :     return aSeq;
      51             : }
      52             : 
      53           0 : uno::Reference< uno::XInterface > SAL_CALL QuickDiagrammingLayout_createInstance( const Reference< XComponentContext >& rxContext ) throw( Exception )
      54             : {
      55           0 :     return (cppu::OWeakObject*)new QuickDiagrammingLayout( rxContext );
      56             : }
      57             : 
      58           0 : QuickDiagrammingLayout::QuickDiagrammingLayout( const Reference< XComponentContext >& rxContext )
      59             :     : XmlFilterBase( rxContext ),
      60           0 :     mpThemePtr(new drawingml::Theme())
      61           0 : {}
      62             : 
      63           0 : bool QuickDiagrammingLayout::importDocument() throw()
      64             : {
      65           0 :     Reference<drawing::XShape>  xParentShape(getParentShape(),
      66           0 :                                              UNO_QUERY_THROW);
      67             :     Reference<drawing::XShapes> xParentShapes(xParentShape,
      68           0 :                                               UNO_QUERY_THROW);
      69             :     Reference<beans::XPropertySet> xPropSet(xParentShape,
      70           0 :                                             UNO_QUERY_THROW);
      71             : 
      72             :     // can we grab the theme from the master page?
      73             :     Reference<container::XChild> xChild(xParentShape,
      74           0 :                                         UNO_QUERY);
      75           0 :     if( xChild.is() )
      76             :     {
      77             :         // TODO: cater for diagram shapes inside groups
      78           0 :         Reference<drawing::XMasterPageTarget> xMasterPageTarget(xChild->getParent(),
      79           0 :                                                                 UNO_QUERY);
      80           0 :         if( xMasterPageTarget.is() )
      81             :         {
      82             :             uno::Reference<drawing::XDrawPage> xMasterPage(
      83           0 :                 xMasterPageTarget->getMasterPage());
      84             : 
      85             :             Reference<beans::XPropertySet> xPropSet2(xMasterPage,
      86           0 :                                                      UNO_QUERY_THROW);
      87           0 :             Reference<xml::dom::XDocument> xThemeFragment;
      88           0 :             xPropSet2->getPropertyValue(
      89           0 :                 CREATE_OUSTRING("PPTTheme")) >>= xThemeFragment;
      90             : 
      91             :             importFragment(
      92             :                 new ThemeFragmentHandler(
      93           0 :                     *this, OUString(), *mpThemePtr ),
      94             :                 Reference<xml::sax::XFastSAXSerializable>(
      95             :                     xThemeFragment,
      96           0 :                     UNO_QUERY_THROW));
      97           0 :         }
      98             :     }
      99             : 
     100           0 :     Reference<xml::dom::XDocument> xDataModelDom;
     101           0 :     Reference<xml::dom::XDocument> xLayoutDom;
     102           0 :     Reference<xml::dom::XDocument> xQStyleDom;
     103           0 :     Reference<xml::dom::XDocument> xColorStyleDom;
     104             : 
     105           0 :     xPropSet->getPropertyValue(
     106           0 :         CREATE_OUSTRING("DiagramData")) >>= xDataModelDom;
     107           0 :     xPropSet->getPropertyValue(
     108           0 :         CREATE_OUSTRING("DiagramLayout")) >>= xLayoutDom;
     109           0 :     xPropSet->getPropertyValue(
     110           0 :         CREATE_OUSTRING("DiagramQStyle")) >>= xQStyleDom;
     111           0 :     xPropSet->getPropertyValue(
     112           0 :         CREATE_OUSTRING("DiagramColorStyle")) >>= xColorStyleDom;
     113             : 
     114             :     oox::drawingml::ShapePtr pShape(
     115           0 :         new oox::drawingml::Shape( "com.sun.star.drawing.DiagramShape" ) );
     116             :     drawingml::loadDiagram(pShape,
     117             :                            *this,
     118             :                            xDataModelDom,
     119             :                            xLayoutDom,
     120             :                            xQStyleDom,
     121           0 :                            xColorStyleDom);
     122             : 
     123             :     // don't add pShape itself, but only its children
     124           0 :     pShape->setXShape(getParentShape());
     125             : 
     126           0 :     const awt::Size& rSize=xParentShape->getSize();
     127           0 :     const awt::Point& rPoint=xParentShape->getPosition();
     128           0 :     const long nScaleFactor=360;
     129             :     const awt::Rectangle aRect(nScaleFactor*rPoint.X,
     130             :                                nScaleFactor*rPoint.Y,
     131             :                                nScaleFactor*rSize.Width,
     132           0 :                                nScaleFactor*rSize.Height);
     133           0 :     basegfx::B2DHomMatrix aMatrix;
     134             :     pShape->addChildren( *this,
     135           0 :                          mpThemePtr.get(),
     136             :                          xParentShapes,
     137             :                          aMatrix,
     138           0 :                          &aRect );
     139             : 
     140           0 :     return true;
     141             : }
     142             : 
     143           0 : bool QuickDiagrammingLayout::exportDocument() throw()
     144             : {
     145           0 :     return false;
     146             : }
     147             : 
     148           0 : const ::oox::drawingml::Theme* QuickDiagrammingLayout::getCurrentTheme() const
     149             : {
     150           0 :     return mpThemePtr.get();
     151             : }
     152             : 
     153           0 : sal_Int32 QuickDiagrammingLayout::getSchemeClr( sal_Int32 nColorSchemeToken ) const
     154             : {
     155           0 :     sal_Int32 nColor = 0;
     156           0 :     if( mpThemePtr )
     157           0 :         mpThemePtr->getClrScheme().getColor( nColorSchemeToken,
     158           0 :                                              nColor );
     159           0 :     return nColor;
     160             : }
     161             : 
     162           0 : const oox::drawingml::table::TableStyleListPtr QuickDiagrammingLayout::getTableStyles()
     163             : {
     164           0 :     return oox::drawingml::table::TableStyleListPtr();
     165             : }
     166             : 
     167           0 : ::oox::vml::Drawing* QuickDiagrammingLayout::getVmlDrawing()
     168             : {
     169           0 :     return 0;
     170             : }
     171             : 
     172           0 : ::oox::drawingml::chart::ChartConverter* QuickDiagrammingLayout::getChartConverter()
     173             : {
     174           0 :     return 0;
     175             : }
     176             : 
     177           0 : OUString QuickDiagrammingLayout::implGetImplementationName() const
     178             : {
     179           0 :     return QuickDiagrammingLayout_getImplementationName();
     180             : }
     181             : 
     182           0 : ::oox::ole::VbaProject* QuickDiagrammingLayout::implCreateVbaProject() const
     183             : {
     184           0 :     return 0;
     185             : }
     186             : 
     187          51 : }}
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10