LCOV - code coverage report
Current view: top level - oox/source/ppt - pptgraphicshapecontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 47 65 72.3 %
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/ppt/pptshape.hxx"
      27             : #include "oox/ppt/pptgraphicshapecontext.hxx"
      28             : #include "oox/ppt/pptshapepropertiescontext.hxx"
      29             : #include "oox/ppt/slidepersist.hxx"
      30             : #include "drawingml/shapestylecontext.hxx"
      31             : #include "oox/token/namespaces.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 <oox/token/tokens.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          12 : PPTGraphicShapeContext::PPTGraphicShapeContext( ContextHandler2Helper& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr )
      51             : : oox::drawingml::GraphicShapeContext( rParent, pMasterShapePtr, pShapePtr )
      52          12 : , mpSlidePersistPtr( pSlidePersistPtr )
      53             : {
      54          12 : }
      55             : 
      56          94 : ContextHandlerRef PPTGraphicShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      57             : {
      58          94 :     switch( aElementToken )
      59             :     {
      60             :     // nvSpPr CT_ShapeNonVisual begin
      61             : //  case NMSP_PPT|XML_drElemPr:
      62             : //      break;
      63             :     case PPT_TOKEN(cNvPr):
      64          12 :         mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
      65          12 :         mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
      66          12 :         break;
      67             :     case PPT_TOKEN(ph):
      68             :     {
      69           4 :         sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) );
      70           4 :         mpShapePtr->setSubType( nSubType );
      71           4 :         OUString sIdx( rAttribs.getString( XML_idx ).get() );
      72           4 :         bool bHasIdx = !sIdx.isEmpty();
      73           4 :         sal_Int32 nIdx = sIdx.toInt32();
      74           4 :         if( rAttribs.hasAttribute( XML_idx ) )
      75           0 :             mpShapePtr->setSubTypeIndex( nIdx );
      76             : 
      77           4 :         if ( nSubType || bHasIdx )
      78             :         {
      79           4 :             PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
      80           4 :             if ( pPPTShapePtr )
      81             :             {
      82           4 :                 oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
      83           4 :                 oox::drawingml::ShapePtr pPlaceholder;
      84             : 
      85           4 :                 if ( bHasIdx && eShapeLocation == Slide )
      86             :                 {
      87             :                     // TODO: use id to shape map
      88           0 :                     SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
      89           0 :                     if ( pMasterPersist.get() && rAttribs.hasAttribute( XML_idx ) )
      90           0 :                         pPlaceholder = PPTShape::findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
      91             :                 }
      92           4 :                 if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
      93             :                 {
      94             :                     // inheriting properties from placeholder objects by cloning shape
      95             : 
      96           4 :                     sal_Int32 nFirstPlaceholder = 0;
      97           4 :                     sal_Int32 nSecondPlaceholder = 0;
      98           4 :                     switch( nSubType )
      99             :                     {
     100             :                         case XML_ctrTitle :     // slide/layout
     101           0 :                             nFirstPlaceholder = XML_ctrTitle;
     102           0 :                             nSecondPlaceholder = XML_title;
     103           0 :                             break;
     104             :                         case XML_subTitle :     // slide/layout
     105           0 :                             nFirstPlaceholder = XML_subTitle;
     106           0 :                             nSecondPlaceholder = XML_title;
     107           0 :                             break;
     108             :                         case XML_obj :          // slide/layout
     109           4 :                             nFirstPlaceholder = XML_body;
     110           4 :                             break;
     111             :                         case XML_dt :           // slide/layout/master/notes/notesmaster/handoutmaster
     112             :                         case XML_sldNum :       // slide/layout/master/notes/notesmaster/handoutmaster
     113             :                         case XML_ftr :          // slide/layout/master/notes/notesmaster/handoutmaster
     114             :                         case XML_hdr :          // notes/notesmaster/handoutmaster
     115             :                         case XML_body :         // slide/layout/master/notes/notesmaster
     116             :                         case XML_title :        // slide/layout/master/
     117             :                         case XML_chart :        // slide/layout
     118             :                         case XML_tbl :          // slide/layout
     119             :                         case XML_clipArt :      // slide/layout
     120             :                         case XML_dgm :          // slide/layout
     121             :                         case XML_media :        // slide/layout
     122             :                         case XML_sldImg :       // notes/notesmaster
     123             :                         case XML_pic :          // slide/layout
     124           0 :                             nFirstPlaceholder = nSubType;
     125             :                         default:
     126           0 :                             break;
     127             :                     }
     128           4 :                     if ( nFirstPlaceholder )
     129             :                     {
     130           4 :                         if ( eShapeLocation == Layout )     // for layout objects the referenced object can be found within the same shape tree
     131           0 :                             pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
     132           0 :                                     pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren(), true );
     133           4 :                         else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects
     134             :                         {
     135           4 :                             SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
     136           4 :                             if ( pMasterPersist.get() )
     137           8 :                                 pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
     138          12 :                                         pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
     139             :                         }
     140             :                     }
     141             :                 }
     142           4 :                 if ( pPlaceholder.get() )
     143             :                 {
     144           4 :                     bool bUseText = true;
     145           4 :                     switch( pPlaceholder->getSubType() )
     146             :                     {
     147             :                         case XML_title :
     148             :                         case XML_body :
     149             :                         case XML_ctrTitle :
     150             :                         case XML_subTitle :
     151             :                         case XML_dt :
     152             :                         case XML_sldNum :
     153             :                         case XML_ftr :
     154             :                         case XML_hdr :
     155             :                         case XML_obj :
     156             :                         case XML_chart :
     157             :                         case XML_tbl :
     158             :                         case XML_clipArt :
     159             :                         case XML_dgm :
     160             :                         case XML_media :
     161             :                         case XML_sldImg :
     162             :                         case XML_pic :
     163           4 :                             bUseText = false;
     164             :                     }
     165           4 :                     mpShapePtr->applyShapeReference( *pPlaceholder.get(), bUseText );
     166           4 :                     PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
     167           4 :                     if ( pPPTShape )
     168           4 :                         pPPTShape->setReferenced( true );
     169           4 :                     pPPTShapePtr->setPlaceholder( pPlaceholder );
     170           4 :                 }
     171             :             }
     172             :         }
     173           4 :         break;
     174             :     }
     175             :     // nvSpPr CT_ShapeNonVisual end
     176             : 
     177             :     case PPT_TOKEN(spPr):
     178          12 :         return new PPTShapePropertiesContext( *this, *mpShapePtr );
     179             : 
     180             :     case PPT_TOKEN(style):
     181           0 :         return new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr );
     182             : 
     183             :     case PPT_TOKEN(txBody):
     184             :     {
     185           0 :         oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
     186           0 :         mpShapePtr->setTextBody( xTextBody );
     187           0 :         return new oox::drawingml::TextBodyContext( *this, *xTextBody );
     188             :     }
     189             :     }
     190             : 
     191          82 :     return GraphicShapeContext::onCreateContext( aElementToken, rAttribs );
     192             : }
     193             : 
     194         408 : } }
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10