LCOV - code coverage report
Current view: top level - oox/source/ppt - pptshapegroupcontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 38 46 82.6 %
Date: 2015-06-13 12:38:46 Functions: 6 6 100.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 <memory>
      21             : #include <com/sun/star/xml/sax/FastToken.hpp>
      22             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      23             : #include <com/sun/star/container/XNamed.hpp>
      24             : 
      25             : #include "oox/helper/attributelist.hxx"
      26             : #include "oox/ppt/pptshape.hxx"
      27             : #include "oox/ppt/pptgraphicshapecontext.hxx"
      28             : #include "oox/ppt/pptshapecontext.hxx"
      29             : #include "oox/ppt/pptshapegroupcontext.hxx"
      30             : #include "oox/drawingml/graphicshapecontext.hxx"
      31             : #include "oox/drawingml/lineproperties.hxx"
      32             : #include "oox/drawingml/drawingmltypes.hxx"
      33             : #include "drawingml/customshapegeometry.hxx"
      34             : #include "drawingml/shapepropertiescontext.hxx"
      35             : #include "drawingml/textbodycontext.hxx"
      36             : #include "oox/drawingml/connectorshapecontext.hxx"
      37             : #include "oox/drawingml/fillproperties.hxx"
      38             : #include "extdrawingfragmenthandler.hxx"
      39             : 
      40             : using namespace oox::core;
      41             : using namespace ::com::sun::star;
      42             : using namespace ::com::sun::star::uno;
      43             : using namespace ::com::sun::star::drawing;
      44             : using namespace ::com::sun::star::beans;
      45             : using namespace ::com::sun::star::text;
      46             : using namespace ::com::sun::star::xml::sax;
      47             : 
      48             : namespace oox { namespace ppt {
      49             : 
      50         305 : PPTShapeGroupContext::PPTShapeGroupContext(
      51             :         ContextHandler2Helper& rParent,
      52             :         const oox::ppt::SlidePersistPtr& rSlidePersistPtr,
      53             :         const ShapeLocation eShapeLocation,
      54             :         oox::drawingml::ShapePtr pMasterShapePtr,
      55             :         oox::drawingml::ShapePtr pGroupShapePtr )
      56             : : ShapeGroupContext( rParent, pMasterShapePtr, pGroupShapePtr )
      57             : , mpSlidePersistPtr( rSlidePersistPtr )
      58             : , meShapeLocation( eShapeLocation )
      59         305 : , pGraphicShape( nullptr )
      60             : {
      61         305 : }
      62             : 
      63        2803 : ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      64             : {
      65        2803 :     if( getNamespace( aElementToken ) == NMSP_dsp )
      66         158 :         aElementToken = NMSP_ppt | getBaseToken( aElementToken );
      67             : 
      68        2803 :     switch( aElementToken )
      69             :     {
      70             :     case PPT_TOKEN( cNvPr ):
      71             :     {
      72         305 :         mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
      73         305 :         mpGroupShapePtr->setId( rAttribs.getString( XML_id ).get() );
      74         305 :         mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() );
      75         305 :         break;
      76             :     }
      77             :     case PPT_TOKEN( ph ):
      78           0 :         mpGroupShapePtr->setSubType( rAttribs.getToken( XML_type, FastToken::DONTKNOW ) );
      79           0 :         if( rAttribs.hasAttribute( XML_idx ) )
      80           0 :             mpGroupShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() );
      81           0 :         break;
      82             :     // nvSpPr CT_ShapeNonVisual end
      83             : 
      84             :     case PPT_TOKEN( grpSpPr ):
      85         305 :         return new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr );
      86             :     case PPT_TOKEN( spPr ):
      87           0 :         return new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr );
      88             : /*
      89             :     case PPT_TOKEN( style ):
      90             :         return new ShapeStyleContext( getParser() );
      91             : */
      92             :     case PPT_TOKEN( cxnSp ):        // connector shape
      93           5 :         return new oox::drawingml::ConnectorShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.ConnectorShape" ) ) );
      94             :     case PPT_TOKEN( grpSp ):        // group shape
      95           4 :         return new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) );
      96             :     case PPT_TOKEN( sp ):           // Shape
      97             :         {
      98        1226 :             std::shared_ptr<PPTShape> pShape( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) );
      99        1226 :             if( rAttribs.getBool( XML_useBgFill, false ) )
     100             :             {
     101           0 :                 ::oox::drawingml::FillProperties &aFill = pShape->getFillProperties();
     102           0 :                 aFill.moFillType = XML_solidFill;
     103             :                 // This is supposed to fill with slide (background) color, but
     104             :                 // TODO: We are using white here, because thats the closest we can assume (?)
     105           0 :                 aFill.maFillColor.setSrgbClr( API_RGB_WHITE );
     106             :             }
     107        1226 :             pShape->setModelId(rAttribs.getString( XML_modelId ).get());
     108        1226 :             return new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, pShape );
     109             :         }
     110             :     case PPT_TOKEN( pic ):          // CT_Picture
     111          14 :         return new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr,  oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) );
     112             :     case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame
     113             :         {
     114          34 :             pGraphicShape = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) );
     115          34 :             return new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, pGraphicShape, true );
     116             :         }
     117             :     }
     118             : 
     119        1215 :     return this;
     120             : }
     121             : 
     122          34 : void PPTShapeGroupContext::importExtDrawings( )
     123             : {
     124          34 :     if( pGraphicShape )
     125             :     {
     126          43 :         for( ::std::vector<OUString>::const_iterator aIt = pGraphicShape->getExtDrawings().begin(), aEnd = pGraphicShape->getExtDrawings().end();
     127             :                     aIt != aEnd; ++aIt )
     128             :             {
     129          27 :                 getFilter().importFragment( new ExtDrawingFragmentHandler( getFilter(), getFragmentPathFromRelId( *aIt ),
     130             :                                                                            mpSlidePersistPtr,
     131             :                                                                            meShapeLocation,
     132             :                                                                            mpMasterShapePtr,
     133             :                                                                            mpGroupShapePtr,
     134          27 :                                                                            pGraphicShape ) );
     135             :                 // Apply font color imported from color fragment
     136           9 :                 if( pGraphicShape->getFontRefColorForNodes().isUsed() )
     137           4 :                     applyFontRefColor(mpGroupShapePtr, pGraphicShape->getFontRefColorForNodes());
     138             :             }
     139          34 :             pGraphicShape = oox::drawingml::ShapePtr( nullptr );
     140             :     }
     141          34 : }
     142             : 
     143         127 : void PPTShapeGroupContext::applyFontRefColor(oox::drawingml::ShapePtr pShape, const oox::drawingml::Color& rFontRefColor)
     144             : {
     145         127 :     pShape->getShapeStyleRefs()[XML_fontRef].maPhClr = rFontRefColor;
     146         127 :     std::vector< oox::drawingml::ShapePtr >& vChildren = pShape->getChildren();
     147         250 :     for( std::vector< oox::drawingml::ShapePtr >::iterator aIter = vChildren.begin(); aIter != vChildren.end(); ++aIter )
     148             :     {
     149         123 :         applyFontRefColor( *aIter ,rFontRefColor);
     150             :     }
     151         127 : }
     152             : 
     153         246 : } }
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11