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

Generated by: LCOV version 1.10