LCOV - code coverage report
Current view: top level - oox/source/ppt - pptshapecontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 62 62 100.0 %
Date: 2014-11-03 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        1794 : PPTShapeContext::PPTShapeContext( ContextHandler2Helper& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr )
      51             : : oox::drawingml::ShapeContext( rParent, pMasterShapePtr, pShapePtr )
      52        1794 : , mpSlidePersistPtr( pSlidePersistPtr )
      53             : {
      54        1794 : }
      55             : 
      56       12496 : ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      57             : {
      58       12496 :     if( getNamespace( aElementToken ) == NMSP_dsp )
      59        1470 :         aElementToken = NMSP_ppt | getBaseToken( aElementToken );
      60             : 
      61       12496 :     switch( aElementToken )
      62             :     {
      63             :         // nvSpPr CT_ShapeNonVisual begin
      64             :         //  case PPT_TOKEN( drElemPr ):
      65             :         //      break;
      66             :         case PPT_TOKEN( cNvPr ):
      67             :         {
      68        1794 :             mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
      69        1794 :             mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
      70        1794 :             mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
      71        1794 :             break;
      72             :         }
      73             :         case PPT_TOKEN( ph ):
      74             :         {
      75         976 :             sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) );
      76         976 :             mpShapePtr->setSubType( nSubType );
      77         976 :             if( rAttribs.hasAttribute( XML_idx ) )
      78         600 :                 mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() );
      79         976 :             if ( nSubType )
      80             :             {
      81         976 :                 PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
      82         976 :                 if ( pPPTShapePtr )
      83             :                 {
      84         976 :                     oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
      85         976 :                     if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) )
      86             :                     {
      87             :                         // inheriting properties from placeholder objects by cloning shape
      88         442 :                         sal_Int32 nFirstPlaceholder = 0;
      89         442 :                         sal_Int32 nSecondPlaceholder = 0;
      90         442 :                         switch( nSubType )
      91             :                         {
      92             :                             case XML_ctrTitle :     // slide/layout
      93          60 :                                   nFirstPlaceholder = XML_ctrTitle;
      94          60 :                                   nSecondPlaceholder = XML_title;
      95          60 :                               break;
      96             : 
      97             :                               case XML_subTitle :       // slide/layout
      98          76 :                                   nFirstPlaceholder = XML_subTitle;
      99          76 :                                   nSecondPlaceholder = XML_body;
     100          76 :                               break;
     101             : 
     102             :                              case XML_obj :         // slide/layout
     103          16 :                                   nFirstPlaceholder = XML_obj;
     104          16 :                                   nSecondPlaceholder = XML_body;
     105          16 :                               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         290 :                                   nFirstPlaceholder = nSubType;
     121             :                               default:
     122         290 :                                   break;
     123             :                         }
     124         442 :                           if ( nFirstPlaceholder )
     125             :                           {
     126         442 :                               oox::drawingml::ShapePtr pPlaceholder;
     127         442 :                               if ( eShapeLocation == Layout )       // for layout objects the referenced object can be found within the same shape tree
     128             :                               {
     129         724 :                                   pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
     130        1086 :                                           pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren(), true );
     131             :                               }
     132          80 :                               else if ( eShapeLocation == Slide )   // normal slide shapes have to search within the corresponding master tree for referenced objects
     133             :                               {
     134          80 :                                   SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
     135          80 :                                   if ( pMasterPersist.get() )
     136             :                                   {
     137         160 :                                       pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
     138         240 :                                               pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
     139          80 :                                   }
     140             :                               }
     141         442 :                               if ( pPlaceholder.get() )
     142             :                               {
     143             :                                   SAL_INFO("oox.ppt","shape " << mpShapePtr->getId() <<
     144             :                                           " will get shape reference " << pPlaceholder->getId() << " applied");
     145         434 :                                   mpShapePtr->applyShapeReference( *pPlaceholder.get() );
     146         434 :                                   PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
     147         434 :                                   if ( pPPTShape )
     148         434 :                                       pPPTShape->setReferenced( true );
     149         434 :                                   pPPTShapePtr->setPlaceholder( pPlaceholder );
     150         442 :                               }
     151             :                           }
     152             :                     }
     153             :                   }
     154             : 
     155             :               }
     156         976 :               break;
     157             :         }
     158             : 
     159             :         // nvSpPr CT_ShapeNonVisual end
     160             : 
     161             :         case PPT_TOKEN( spPr ):
     162        1794 :             return new PPTShapePropertiesContext( *this, *mpShapePtr );
     163             : 
     164             :         case PPT_TOKEN( style ):
     165         384 :             return new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr );
     166             : 
     167             :         case PPT_TOKEN( txBody ):
     168             :         {
     169        1272 :             oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody( mpShapePtr->getTextBody() ) );
     170        1272 :             xTextBody->getTextProperties().maPropertyMap.setProperty( PROP_FontIndependentLineSpacing, true );
     171        1272 :             mpShapePtr->setTextBody( xTextBody );
     172        1272 :             return new oox::drawingml::TextBodyContext( *this, *xTextBody );
     173             :         }
     174             :         case PPT_TOKEN( txXfrm ):
     175             :         {
     176         130 :             return new oox::drawingml::Transform2DContext( *this, rAttribs, *mpShapePtr, true );
     177             :         }
     178             :     }
     179             : 
     180        8916 :     return this;
     181             : }
     182             : 
     183         408 : } }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10