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

Generated by: LCOV version 1.10