LCOV - code coverage report
Current view: top level - oox/source/ppt - pptgraphicshapecontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 72 20.8 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 20 189 10.6 %

           Branch data     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 rtl::OUString;
      40                 :            : using namespace oox::core;
      41                 :            : using namespace ::com::sun::star;
      42                 :            : using namespace ::com::sun::star::uno;
      43                 :            : using namespace ::com::sun::star::drawing;
      44                 :            : using namespace ::com::sun::star::beans;
      45                 :            : using namespace ::com::sun::star::text;
      46                 :            : using namespace ::com::sun::star::xml::sax;
      47                 :            : 
      48                 :            : namespace oox { namespace ppt {
      49                 :            : 
      50                 :            : // CT_Shape
      51                 :          3 : PPTGraphicShapeContext::PPTGraphicShapeContext( ContextHandler& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr )
      52                 :            : : oox::drawingml::GraphicShapeContext( rParent, pMasterShapePtr, pShapePtr )
      53 [ +  - ][ +  - ]:          3 : , mpSlidePersistPtr( pSlidePersistPtr )
         [ +  - ][ +  - ]
      54                 :            : {
      55                 :          3 : }
      56                 :            : 
      57                 :            : // if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder
      58                 :          0 : static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
      59                 :            : {
      60         [ #  # ]:          0 :     oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, rShapes );
      61 [ #  # ][ #  # ]:          0 :     return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : PPTShape::findPlaceholder( nSecondPlaceholder, rShapes );
         [ #  # ][ #  # ]
                 [ #  # ]
      62                 :            : }
      63                 :            : 
      64                 :         18 : Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
      65                 :            : {
      66                 :         18 :     Reference< XFastContextHandler > xRet;
      67                 :            : 
      68   [ +  -  +  -  :         18 :     switch( aElementToken )
                   -  + ]
      69                 :            :     {
      70                 :            :     // nvSpPr CT_ShapeNonVisual begin
      71                 :            : //  case NMSP_PPT|XML_drElemPr:
      72                 :            : //      break;
      73                 :            :     case PPT_TOKEN(cNvPr):
      74 [ +  - ][ +  - ]:          3 :         mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
      75 [ +  - ][ +  - ]:          3 :         mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
      76                 :          3 :         break;
      77                 :            :     case PPT_TOKEN(ph):
      78                 :            :     {
      79 [ #  # ][ #  # ]:          0 :         sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) );
      80                 :          0 :         mpShapePtr->setSubType( nSubType );
      81 [ #  # ][ #  # ]:          0 :         OUString sIdx( xAttribs->getOptionalValue( XML_idx ) );
      82                 :          0 :         sal_Bool bHasIdx = !sIdx.isEmpty();
      83                 :          0 :         sal_Int32 nIdx = sIdx.toInt32();
      84 [ #  # ][ #  # ]:          0 :         if( xAttribs->hasAttribute( XML_idx ) )
                 [ #  # ]
      85         [ #  # ]:          0 :             mpShapePtr->setSubTypeIndex( nIdx );
      86                 :            : 
      87 [ #  # ][ #  # ]:          0 :         if ( nSubType || bHasIdx )
      88                 :            :         {
      89         [ #  # ]:          0 :             PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() );
      90         [ #  # ]:          0 :             if ( pPPTShapePtr )
      91                 :            :             {
      92                 :          0 :                 oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation();
      93         [ #  # ]:          0 :                 oox::drawingml::ShapePtr pPlaceholder;
      94                 :            : 
      95 [ #  # ][ #  # ]:          0 :                 if ( bHasIdx && eShapeLocation == Slide )
      96                 :            :                 {
      97                 :            :                     // TODO: use id to shape map
      98         [ #  # ]:          0 :                     SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
      99 [ #  # ][ #  # ]:          0 :                     if ( pMasterPersist.get() && xAttribs->hasAttribute( XML_idx ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     100 [ #  # ][ #  # ]:          0 :                         pPlaceholder = PPTShape::findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     101                 :            :                 }
     102 [ #  # ][ #  # ]:          0 :                 if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) )
         [ #  # ][ #  # ]
     103                 :            :                 {
     104                 :            :                     // inheriting properties from placeholder objects by cloning shape
     105                 :            : 
     106                 :          0 :                     sal_Int32 nFirstPlaceholder = 0;
     107                 :          0 :                     sal_Int32 nSecondPlaceholder = 0;
     108   [ #  #  #  #  :          0 :                     switch( nSubType )
                      # ]
     109                 :            :                     {
     110                 :            :                         case XML_ctrTitle :     // slide/layout
     111                 :          0 :                             nFirstPlaceholder = XML_ctrTitle;
     112                 :          0 :                             nSecondPlaceholder = XML_title;
     113                 :          0 :                             break;
     114                 :            :                         case XML_subTitle :     // slide/layout
     115                 :          0 :                             nFirstPlaceholder = XML_subTitle;
     116                 :          0 :                             nSecondPlaceholder = XML_title;
     117                 :          0 :                             break;
     118                 :            :                         case XML_obj :          // slide/layout
     119                 :          0 :                             nFirstPlaceholder = XML_body;
     120                 :          0 :                             break;
     121                 :            :                         case XML_dt :           // slide/layout/master/notes/notesmaster/handoutmaster
     122                 :            :                         case XML_sldNum :       // slide/layout/master/notes/notesmaster/handoutmaster
     123                 :            :                         case XML_ftr :          // slide/layout/master/notes/notesmaster/handoutmaster
     124                 :            :                         case XML_hdr :          // notes/notesmaster/handoutmaster
     125                 :            :                         case XML_body :         // slide/layout/master/notes/notesmaster
     126                 :            :                         case XML_title :        // slide/layout/master/
     127                 :            :                         case XML_chart :        // slide/layout
     128                 :            :                         case XML_tbl :          // slide/layout
     129                 :            :                         case XML_clipArt :      // slide/layout
     130                 :            :                         case XML_dgm :          // slide/layout
     131                 :            :                         case XML_media :        // slide/layout
     132                 :            :                         case XML_sldImg :       // notes/notesmaster
     133                 :            :                         case XML_pic :          // slide/layout
     134                 :          0 :                             nFirstPlaceholder = nSubType;
     135                 :            :                         default:
     136                 :          0 :                             break;
     137                 :            :                     }
     138         [ #  # ]:          0 :                     if ( nFirstPlaceholder )
     139                 :            :                     {
     140         [ #  # ]:          0 :                         if ( eShapeLocation == Layout )     // for layout objects the referenced object can be found within the same shape tree
     141 [ #  # ][ #  # ]:          0 :                             pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() );
         [ #  # ][ #  # ]
                 [ #  # ]
     142         [ #  # ]:          0 :                         else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects
     143                 :            :                         {
     144         [ #  # ]:          0 :                             SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() );
     145         [ #  # ]:          0 :                             if ( pMasterPersist.get() )
     146 [ #  # ][ #  # ]:          0 :                                 pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     147                 :            :                         }
     148                 :            :                     }
     149                 :            :                 }
     150         [ #  # ]:          0 :                 if ( pPlaceholder.get() )
     151                 :            :                 {
     152                 :          0 :                     bool bUseText = true;
     153                 :            :                     // TODO: Check if pPlaceholder->getSubType is none (i.e. none explicitly specified)
     154         [ #  # ]:          0 :                     if( pPlaceholder->getSubType() == XML_obj )
     155                 :          0 :                         bUseText = false;
     156         [ #  # ]:          0 :                     mpShapePtr->applyShapeReference( *pPlaceholder.get(), bUseText );
     157         [ #  # ]:          0 :                     PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() );
     158         [ #  # ]:          0 :                     if ( pPPTShape )
     159                 :          0 :                         pPPTShape->setReferenced( sal_True );
     160 [ #  # ][ #  # ]:          0 :                     pPPTShapePtr->setPlaceholder( pPlaceholder );
                 [ #  # ]
     161         [ #  # ]:          0 :                 }
     162                 :            :             }
     163                 :            :         }
     164                 :          0 :         break;
     165                 :            :     }
     166                 :            :     // nvSpPr CT_ShapeNonVisual end
     167                 :            : 
     168                 :            :     case PPT_TOKEN(spPr):
     169 [ +  - ][ +  - ]:          3 :         xRet = new PPTShapePropertiesContext( *this, *mpShapePtr );
                 [ +  - ]
     170                 :          3 :         break;
     171                 :            : 
     172                 :            :     case PPT_TOKEN(style):
     173 [ #  # ][ #  # ]:          0 :         xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr );
                 [ #  # ]
     174                 :          0 :         break;
     175                 :            : 
     176                 :            :     case PPT_TOKEN(txBody):
     177                 :            :     {
     178 [ #  # ][ #  # ]:          0 :         oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody );
                 [ #  # ]
     179         [ #  # ]:          0 :         mpShapePtr->setTextBody( xTextBody );
     180 [ #  # ][ #  # ]:          0 :         xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody );
                 [ #  # ]
     181         [ #  # ]:          0 :         break;
     182                 :            :     }
     183                 :            :     }
     184                 :            : 
     185         [ +  + ]:         18 :     if( !xRet.is() )
     186 [ +  - ][ +  - ]:         15 :         xRet.set( GraphicShapeContext::createFastChildContext( aElementToken, xAttribs ) );
     187                 :            : 
     188                 :         18 :     return xRet;
     189                 :            : }
     190                 :            : 
     191                 :            : 
     192 [ +  - ][ +  - ]:        285 : } }
     193                 :            : 
     194                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10