LCOV - code coverage report
Current view: top level - oox/source/ppt - pptgraphicshapecontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 47 65 72.3 %
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/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          14 : PPTGraphicShapeContext::PPTGraphicShapeContext( ContextHandler2Helper& rParent, const SlidePersistPtr& rSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr )
      51             : : oox::drawingml::GraphicShapeContext( rParent, pMasterShapePtr, pShapePtr )
      52          14 : , mpSlidePersistPtr( rSlidePersistPtr )
      53             : {
      54          14 : }
      55             : 
      56          99 : ContextHandlerRef PPTGraphicShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      57             : {
      58          99 :     switch( aElementToken )
      59             :     {
      60             :     // nvSpPr CT_ShapeNonVisual begin
      61             : //  case NMSP_PPT|XML_drElemPr:
      62             : //      break;
      63             :     case PPT_TOKEN(cNvPr):
      64          14 :         mpShapePtr->setId( rAttribs.getString( XML_id ).get() );
      65          14 :         mpShapePtr->setName( rAttribs.getString( XML_name ).get() );
      66          14 :         break;
      67             :     case PPT_TOKEN(ph):
      68             :     {
      69           2 :         sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) );
      70           2 :         mpShapePtr->setSubType( nSubType );
      71           2 :         OUString sIdx( rAttribs.getString( XML_idx ).get() );
      72           2 :         bool bHasIdx = !sIdx.isEmpty();
      73           2 :         sal_Int32 nIdx = sIdx.toInt32();
      74           2 :         if( rAttribs.hasAttribute( XML_idx ) )
      75           0 :             mpShapePtr->setSubTypeIndex( nIdx );
      76             : 
      77           2 :         if ( nSubType || bHasIdx )
      78             :         {
      79           2 :             PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
      80           2 :             if ( pPPTShapePtr )
      81             :             {
      82           2 :                 oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
      83           2 :                 oox::drawingml::ShapePtr pPlaceholder;
      84             : 
      85           2 :                 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           2 :                 if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
      93             :                 {
      94             :                     // inheriting properties from placeholder objects by cloning shape
      95             : 
      96           2 :                     sal_Int32 nFirstPlaceholder = 0;
      97           2 :                     sal_Int32 nSecondPlaceholder = 0;
      98           2 :                     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           2 :                             nFirstPlaceholder = XML_body;
     110           2 :                             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           2 :                     if ( nFirstPlaceholder )
     129             :                     {
     130           2 :                         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           2 :                         else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects
     134             :                         {
     135           2 :                             SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
     136           2 :                             if ( pMasterPersist.get() )
     137           4 :                                 pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder,
     138           6 :                                         pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() );
     139             :                         }
     140             :                     }
     141             :                 }
     142           2 :                 if ( pPlaceholder.get() )
     143             :                 {
     144           2 :                     bool bUseText = true;
     145           2 :                     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           2 :                             bUseText = false;
     164             :                     }
     165           2 :                     mpShapePtr->applyShapeReference( *pPlaceholder.get(), bUseText );
     166           2 :                     PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
     167           2 :                     if ( pPPTShape )
     168           2 :                         pPPTShape->setReferenced( true );
     169           2 :                     pPPTShapePtr->setPlaceholder( pPlaceholder );
     170           2 :                 }
     171             :             }
     172             :         }
     173           2 :         break;
     174             :     }
     175             :     // nvSpPr CT_ShapeNonVisual end
     176             : 
     177             :     case PPT_TOKEN(spPr):
     178          14 :         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          85 :     return GraphicShapeContext::onCreateContext( aElementToken, rAttribs );
     192             : }
     193             : 
     194         246 : } }
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11