LCOV - code coverage report
Current view: top level - oox/source/ppt - pptshapecontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 62 62 100.0 %
Date: 2015-06-13 12:38:46 Functions: 4 4 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/drawing/LineStyle.hpp>
      22             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      23             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      24             : #include <com/sun/star/container/XNamed.hpp>
      25             : 
      26             : #include "oox/helper/attributelist.hxx"
      27             : #include "oox/ppt/pptshape.hxx"
      28             : #include "oox/ppt/pptshapecontext.hxx"
      29             : #include "oox/ppt/pptshapepropertiescontext.hxx"
      30             : #include "oox/ppt/slidepersist.hxx"
      31             : #include "drawingml/shapestylecontext.hxx"
      32             : #include "drawingml/fillpropertiesgroupcontext.hxx"
      33             : #include "oox/drawingml/lineproperties.hxx"
      34             : #include "oox/drawingml/drawingmltypes.hxx"
      35             : #include "drawingml/customshapegeometry.hxx"
      36             : #include "drawingml/textbodycontext.hxx"
      37             : #include "drawingml/transform2dcontext.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             : // CT_Shape
      50        1226 : PPTShapeContext::PPTShapeContext( ContextHandler2Helper& rParent, const SlidePersistPtr& rSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr )
      51             : : oox::drawingml::ShapeContext( rParent, pMasterShapePtr, pShapePtr )
      52        1226 : , mpSlidePersistPtr( rSlidePersistPtr )
      53             : {
      54        1226 : }
      55             : 
      56        8825 : ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      57             : {
      58        8825 :     if( getNamespace( aElementToken ) == NMSP_dsp )
      59         742 :         aElementToken = NMSP_ppt | getBaseToken( aElementToken );
      60             : 
      61        8825 :     switch( aElementToken )
      62             :     {
      63             :         // nvSpPr CT_ShapeNonVisual begin
      64             :         //  case PPT_TOKEN( drElemPr ):
      65             :         //      break;
      66             :         case PPT_TOKEN( cNvPr ):
      67             :         {
      68        1226 :             mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
      69        1226 :             mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
      70        1226 :             mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
      71        1226 :             break;
      72             :         }
      73             :         case PPT_TOKEN( ph ):
      74             :         {
      75         780 :             sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) );
      76         780 :             mpShapePtr->setSubType( nSubType );
      77         780 :             if( rAttribs.hasAttribute( XML_idx ) )
      78         433 :                 mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() );
      79         780 :             if ( nSubType )
      80             :             {
      81         780 :                 PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
      82         780 :                 if ( pPPTShapePtr )
      83             :                 {
      84         780 :                     oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
      85         780 :                     if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) )
      86             :                     {
      87             :                         // inheriting properties from placeholder objects by cloning shape
      88         342 :                         sal_Int32 nFirstPlaceholder = 0;
      89         342 :                         sal_Int32 nSecondPlaceholder = 0;
      90         342 :                         switch( nSubType )
      91             :                         {
      92             :                             case XML_ctrTitle :     // slide/layout
      93          41 :                                   nFirstPlaceholder = XML_ctrTitle;
      94          41 :                                   nSecondPlaceholder = XML_title;
      95          41 :                               break;
      96             : 
      97             :                               case XML_subTitle :       // slide/layout
      98          65 :                                   nFirstPlaceholder = XML_subTitle;
      99          65 :                                   nSecondPlaceholder = XML_body;
     100          65 :                               break;
     101             : 
     102             :                              case XML_obj :         // slide/layout
     103          14 :                                   nFirstPlaceholder = XML_obj;
     104          14 :                                   nSecondPlaceholder = XML_body;
     105          14 :                               break;
     106             : 
     107             :                             case XML_dt :           // slide/layout/master/notes/notesmaster/handoutmaster
     108             :                               case XML_sldNum :     // slide/layout/master/notes/notesmaster/handoutmaster
     109             :                               case XML_ftr :            // slide/layout/master/notes/notesmaster/handoutmaster
     110             :                               case XML_hdr :            // notes/notesmaster/handoutmaster
     111             :                               case XML_body :           // slide/layout/master/notes/notesmaster
     112             :                               case XML_title :      // slide/layout/master/
     113             :                               case XML_chart :      // slide/layout
     114             :                               case XML_tbl :            // slide/layout
     115             :                               case XML_clipArt :        // slide/layout
     116             :                               case XML_dgm :            // slide/layout
     117             :                               case XML_media :      // slide/layout
     118             :                               case XML_sldImg :     // notes/notesmaster
     119             :                               case XML_pic :            // slide/layout
     120         222 :                                   nFirstPlaceholder = nSubType;
     121             :                               default:
     122         222 :                                   break;
     123             :                         }
     124         342 :                           if ( nFirstPlaceholder )
     125             :                           {
     126         342 :                               oox::drawingml::ShapePtr pPlaceholder;
     127         342 :                               if ( eShapeLocation == Layout )       // for layout objects the referenced object can be found within the same shape tree
     128             :                               {
     129         572 :                                   pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
     130         858 :                                           pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren(), true );
     131             :                               }
     132          56 :                               else if ( eShapeLocation == Slide )   // normal slide shapes have to search within the corresponding master tree for referenced objects
     133             :                               {
     134          56 :                                   SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
     135          56 :                                   if ( pMasterPersist.get() )
     136             :                                   {
     137         112 :                                       pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
     138         168 :                                               pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
     139          56 :                                   }
     140             :                               }
     141         342 :                               if ( pPlaceholder.get() )
     142             :                               {
     143             :                                   SAL_INFO("oox.ppt","shape " << mpShapePtr->getId() <<
     144             :                                           " will get shape reference " << pPlaceholder->getId() << " applied");
     145         337 :                                   mpShapePtr->applyShapeReference( *pPlaceholder.get() );
     146         337 :                                   PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
     147         337 :                                   if ( pPPTShape )
     148         337 :                                       pPPTShape->setReferenced( true );
     149         337 :                                   pPPTShapePtr->setPlaceholder( pPlaceholder );
     150         342 :                               }
     151             :                           }
     152             :                     }
     153             :                   }
     154             : 
     155             :               }
     156         780 :               break;
     157             :         }
     158             : 
     159             :         // nvSpPr CT_ShapeNonVisual end
     160             : 
     161             :         case PPT_TOKEN( spPr ):
     162        1226 :             return new PPTShapePropertiesContext( *this, *mpShapePtr );
     163             : 
     164             :         case PPT_TOKEN( style ):
     165         209 :             return new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr );
     166             : 
     167             :         case PPT_TOKEN( txBody ):
     168             :         {
     169         957 :             oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody( mpShapePtr->getTextBody() ) );
     170         957 :             xTextBody->getTextProperties().maPropertyMap.setProperty( PROP_FontIndependentLineSpacing, true );
     171         957 :             mpShapePtr->setTextBody( xTextBody );
     172         957 :             return new oox::drawingml::TextBodyContext( *this, *xTextBody );
     173             :         }
     174             :         case PPT_TOKEN( txXfrm ):
     175             :         {
     176          66 :             return new oox::drawingml::Transform2DContext( *this, rAttribs, *mpShapePtr, true );
     177             :         }
     178             :     }
     179             : 
     180        6367 :     return this;
     181             : }
     182             : 
     183         246 : } }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11