LCOV - code coverage report
Current view: top level - oox/source/ppt - conditioncontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 51 73 69.9 %
Date: 2015-06-13 12:38:46 Functions: 10 10 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 "conditioncontext.hxx"
      21             : 
      22             : #include "comphelper/anytostring.hxx"
      23             : #include "cppuhelper/exc_hlp.hxx"
      24             : #include <osl/diagnose.h>
      25             : 
      26             : #include <com/sun/star/animations/XTimeContainer.hpp>
      27             : #include <com/sun/star/animations/XAnimationNode.hpp>
      28             : #include <com/sun/star/animations/AnimationEndSync.hpp>
      29             : #include <com/sun/star/animations/EventTrigger.hpp>
      30             : 
      31             : #include "oox/helper/attributelist.hxx"
      32             : #include "oox/ppt/animationspersist.hxx"
      33             : #include "animationtypes.hxx"
      34             : 
      35             : #include "timetargetelementcontext.hxx"
      36             : 
      37             : using namespace ::oox::core;
      38             : using namespace ::com::sun::star::uno;
      39             : using namespace ::com::sun::star::xml::sax;
      40             : using namespace ::com::sun::star::animations;
      41             : 
      42             : namespace oox { namespace ppt {
      43             : 
      44          57 :     CondContext::CondContext( FragmentHandler2& rParent, const Reference< XFastAttributeList >& xAttribs,
      45             :                 const TimeNodePtr & pNode, AnimationCondition & aValue )
      46             :         :  TimeNodeContext( rParent, PPT_TOKEN( cond ), xAttribs, pNode )
      47          57 :         , maCond( aValue )
      48             :     {
      49          57 :         maEvent.Trigger =  EventTrigger::NONE;
      50          57 :         maEvent.Repeat = 0;
      51             : 
      52          57 :         AttributeList attribs( xAttribs );
      53          57 :         if( attribs.hasAttribute( XML_evt ) )
      54             :         {
      55          20 :             sal_Int32 nEvent = xAttribs->getOptionalValueToken( XML_evt, 0 );
      56          20 :             switch( nEvent )
      57             :             {
      58             :             case XML_onBegin:
      59           3 :                 maEvent.Trigger = EventTrigger::ON_BEGIN;
      60           3 :                 break;
      61             :             case XML_onEnd:
      62           0 :                 maEvent.Trigger = EventTrigger::ON_END;
      63           0 :                 break;
      64             :             case XML_begin:
      65           0 :                 maEvent.Trigger = EventTrigger::BEGIN_EVENT;
      66           0 :                 break;
      67             :             case XML_end:
      68           1 :                 maEvent.Trigger = EventTrigger::END_EVENT;
      69           1 :                 break;
      70             :             case XML_onClick:
      71           2 :                 maEvent.Trigger = EventTrigger::ON_CLICK;
      72           2 :                 break;
      73             :             case XML_onDblClick:
      74           0 :                 maEvent.Trigger = EventTrigger::ON_DBL_CLICK;
      75           0 :                 break;
      76             :             case XML_onMouseOver:
      77           0 :                 maEvent.Trigger = EventTrigger::ON_MOUSE_ENTER;
      78           0 :                 break;
      79             :             case XML_onMouseOut:
      80           0 :                 maEvent.Trigger = EventTrigger::ON_MOUSE_LEAVE;
      81           0 :                 break;
      82             :             case XML_onNext:
      83           7 :                 maEvent.Trigger = EventTrigger::ON_NEXT;
      84           7 :                 break;
      85             :             case XML_onPrev:
      86           7 :                 maEvent.Trigger = EventTrigger::ON_PREV;
      87           7 :                 break;
      88             :             case XML_onStopAudio:
      89           0 :                 maEvent.Trigger = EventTrigger::ON_STOP_AUDIO;
      90           0 :                 break;
      91             :             default:
      92           0 :                 break;
      93             :             }
      94             :         }
      95          57 :         if( attribs.hasAttribute( XML_delay ) || ( maEvent.Trigger == EventTrigger::NONE ) )
      96             :         {
      97          57 :             maEvent.Offset = GetTime( xAttribs->getOptionalValue( XML_delay ) );
      98          57 :         }
      99          57 :     }
     100             : 
     101         171 :     CondContext::~CondContext( ) throw( )
     102             :     {
     103          57 :         if( maCond.mnType == 0 )
     104             :         {
     105          53 :             maCond.maValue = (maEvent.Trigger == EventTrigger::NONE) ? maEvent.Offset : makeAny( maEvent );
     106             :         }
     107         114 :     }
     108             : 
     109          20 :     ::oox::core::ContextHandlerRef CondContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     110             :     {
     111          20 :         switch( aElementToken )
     112             :         {
     113             :         case PPT_TOKEN( rtn ):
     114             :         {
     115             :             // ST_TLTriggerRuntimeNode { first, last, all }
     116             :             sal_Int32 aTok;
     117             :             sal_Int16 nEnum;
     118           1 :             aTok = rAttribs.getToken( XML_val, XML_first );
     119           1 :             switch( aTok )
     120             :             {
     121             :             case XML_first:
     122           0 :                 nEnum = AnimationEndSync::FIRST;
     123           0 :                 break;
     124             :             case XML_last:
     125           0 :                 nEnum = AnimationEndSync::LAST;
     126           0 :                 break;
     127             :             case XML_all:
     128           1 :                 nEnum = AnimationEndSync::ALL;
     129           1 :                 break;
     130             :             default:
     131           0 :                 break;
     132             :             }
     133           1 :             maCond.mnType = aElementToken;
     134           1 :             maCond.maValue = makeAny( nEnum );
     135           1 :             return this;
     136             :         }
     137             :         case PPT_TOKEN( tn ):
     138             :         {
     139           3 :             maCond.mnType = aElementToken;
     140           3 :             sal_uInt32 nId = rAttribs.getUnsigned( XML_val, 0 );
     141           3 :             maCond.maValue = makeAny( nId );
     142           3 :             return this;
     143             :         }
     144             :         case PPT_TOKEN( tgtEl ):
     145             :             // CT_TLTimeTargetElement
     146          16 :             return new TimeTargetElementContext( *this, maCond.getTarget() );
     147             :         default:
     148           0 :             break;
     149             :         }
     150             : 
     151           0 :         return this;
     152             : 
     153             :     }
     154             : 
     155             :     /** CT_TLTimeConditionList */
     156          53 :     CondListContext::CondListContext(
     157             :             FragmentHandler2& rParent, sal_Int32  aElement,
     158             :             const Reference< XFastAttributeList >& xAttribs,
     159             :             const TimeNodePtr & pNode,
     160             :             AnimationConditionList & aCond )
     161             :         : TimeNodeContext( rParent, aElement, xAttribs, pNode )
     162          53 :         , maConditions( aCond )
     163             :     {
     164          53 :     }
     165             : 
     166         106 :     CondListContext::~CondListContext( )
     167          53 :         throw( )
     168             :     {
     169         106 :     }
     170             : 
     171          56 :     ::oox::core::ContextHandlerRef CondListContext::onCreateContext( sal_Int32 aElement, const AttributeList& rAttribs )
     172             :     {
     173          56 :         switch( aElement )
     174             :         {
     175             :         case PPT_TOKEN( cond ):
     176             :             // add a condition to the list
     177          56 :             maConditions.push_back( AnimationCondition() );
     178          56 :             return new CondContext( *this, rAttribs.getFastAttributeList(), mpNode, maConditions.back() );
     179             :         default:
     180           0 :             break;
     181             :         }
     182           0 :         return this;
     183             :     }
     184             : 
     185         246 : } }
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11