LCOV - code coverage report
Current view: top level - oox/source/ppt - timetargetelementcontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 18 53 34.0 %
Date: 2014-11-03 Functions: 9 10 90.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 "timetargetelementcontext.hxx"
      21             : 
      22             : #include "comphelper/anytostring.hxx"
      23             : #include "cppuhelper/exc_hlp.hxx"
      24             : #include <osl/diagnose.h>
      25             : 
      26             : #include <com/sun/star/uno/Any.hxx>
      27             : 
      28             : #include "oox/helper/attributelist.hxx"
      29             : #include "drawingml/embeddedwavaudiofile.hxx"
      30             : 
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::xml::sax;
      33             : using namespace ::oox::core;
      34             : 
      35             : namespace oox { namespace ppt {
      36             : 
      37             :     // CT_TLShapeTargetElement
      38          72 :     class ShapeTargetElementContext
      39             :         : public FragmentHandler2
      40             :     {
      41             :     public:
      42          36 :         ShapeTargetElementContext( FragmentHandler2& rParent, ShapeTargetElement & aValue )
      43             :             : FragmentHandler2( rParent )
      44             :                 , bTargetSet(false)
      45          36 :                 , maShapeTarget(aValue)
      46             :             {
      47          36 :             }
      48           0 :         virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) SAL_OVERRIDE
      49             :             {
      50           0 :                 switch( aElementToken )
      51             :                 {
      52             :                 case PPT_TOKEN( bg ):
      53           0 :                     bTargetSet = true;
      54           0 :                     maShapeTarget.mnType = XML_bg;
      55           0 :                     return this;
      56             :                 case PPT_TOKEN( txEl ):
      57           0 :                     bTargetSet = true;
      58           0 :                     maShapeTarget.mnType = XML_txEl;
      59           0 :                     return this;
      60             :                 case PPT_TOKEN( subSp ):
      61           0 :                     bTargetSet = true;
      62           0 :                     maShapeTarget.mnType = XML_subSp;
      63           0 :                     maShapeTarget.msSubShapeId = rAttribs.getString( XML_spid, OUString() );
      64           0 :                     return this;
      65             :                 case PPT_TOKEN( graphicEl ):
      66           0 :                     return this; // needs a:dgm for the target
      67             :                 case A_TOKEN( dgm ):
      68           0 :                     bTargetSet = true;
      69           0 :                     maShapeTarget.mnType = XML_dgm;
      70           0 :                     maShapeTarget.msSubShapeId = rAttribs.getString( XML_id, OUString() );
      71           0 :                     return this;
      72             :                 case PPT_TOKEN( oleChartEl ):
      73           0 :                     bTargetSet = true;
      74             :                     // TODO
      75           0 :                     return this;
      76             :                 case PPT_TOKEN( charRg ):
      77             :                 case PPT_TOKEN( pRg ):
      78           0 :                     if( bTargetSet && maShapeTarget.mnType == XML_txEl )
      79             :                     {
      80           0 :                         maShapeTarget.mnRangeType = getBaseToken( aElementToken );
      81           0 :                         maShapeTarget.maRange = drawingml::GetIndexRange( rAttribs.getFastAttributeList() );
      82             :                     }
      83           0 :                     return this;
      84             :                 default:
      85           0 :                     break;
      86             :                 }
      87           0 :                 return this;
      88             :             }
      89             : 
      90             :     private:
      91             :         bool bTargetSet;
      92             :         ShapeTargetElement & maShapeTarget;
      93             :     };
      94             : 
      95          64 :     TimeTargetElementContext::TimeTargetElementContext( FragmentHandler2& rParent, const AnimTargetElementPtr & pValue )
      96             :         : FragmentHandler2( rParent ),
      97          64 :             mpTarget( pValue )
      98             :     {
      99             :         OSL_ENSURE( mpTarget, "no valid target passed" );
     100          64 :     }
     101             : 
     102         128 :     TimeTargetElementContext::~TimeTargetElementContext( ) throw( )
     103             :     {
     104         128 :     }
     105             : 
     106          64 :     ::oox::core::ContextHandlerRef TimeTargetElementContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     107             :     {
     108          64 :         switch( aElementToken )
     109             :         {
     110             :         case PPT_TOKEN( inkTgt ):
     111             :         {
     112           0 :             mpTarget->mnType = XML_inkTgt;
     113           0 :             OUString aId = rAttribs.getString( XML_spid, OUString() );
     114           0 :             if( !aId.isEmpty() )
     115             :             {
     116           0 :                 mpTarget->msValue = aId;
     117             :             }
     118           0 :             return this;
     119             :         }
     120             :         case PPT_TOKEN( sldTgt ):
     121          28 :             mpTarget->mnType = XML_sldTgt;
     122          28 :             return this;
     123             :         case PPT_TOKEN( sndTgt ):
     124             :         {
     125           0 :             mpTarget->mnType = XML_sndTgt;
     126           0 :             mpTarget->msValue = drawingml::getEmbeddedWAVAudioFile( getRelations(), rAttribs );
     127           0 :             break;
     128             :         }
     129             :         case PPT_TOKEN( spTgt ):
     130             :         {
     131          36 :             mpTarget->mnType = XML_spTgt;
     132          36 :             OUString aId = rAttribs.getString( XML_spid, OUString() );
     133          36 :             mpTarget->msValue = aId;
     134          36 :             return new ShapeTargetElementContext( *this, mpTarget->maShapeTarget );
     135             :         }
     136             :         default:
     137             :             OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getBaseToken( aElementToken ) );
     138           0 :             break;
     139             :         }
     140             : 
     141           0 :         return this;
     142             :     }
     143             : 
     144         408 : } }
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10