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

Generated by: LCOV version 1.10