LCOV - code coverage report
Current view: top level - oox/source/ppt - commonbehaviorcontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 48 52 92.3 %
Date: 2015-06-13 12:38:46 Functions: 8 8 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 "comphelper/anytostring.hxx"
      21             : #include "cppuhelper/exc_hlp.hxx"
      22             : #include <rtl/ustrbuf.hxx>
      23             : 
      24             : #include <com/sun/star/animations/XTimeContainer.hpp>
      25             : #include <com/sun/star/animations/XAnimationNode.hpp>
      26             : #include <com/sun/star/animations/XAnimate.hpp>
      27             : 
      28             : #include "oox/core/fragmenthandler.hxx"
      29             : 
      30             : #include "commonbehaviorcontext.hxx"
      31             : #include "commontimenodecontext.hxx"
      32             : #include "timetargetelementcontext.hxx"
      33             : #include "pptfilterhelpers.hxx"
      34             : 
      35             : #include <string.h>
      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          16 :     CommonBehaviorContext::CommonBehaviorContext( FragmentHandler2& rParent,
      45             :             const Reference< XFastAttributeList >& xAttribs,
      46             :             const TimeNodePtr & pNode )
      47             :         : TimeNodeContext( rParent, PPT_TOKEN( cBhvr ), xAttribs, pNode )
      48             :             , mbInAttrList( false )
      49          16 :             , mbIsInAttrName( false )
      50             :     {
      51          16 :     }
      52             : 
      53          32 :     CommonBehaviorContext::~CommonBehaviorContext( ) throw( )
      54             :     {
      55          32 :     }
      56             : 
      57          30 :     void CommonBehaviorContext::onEndElement()
      58             :     {
      59          30 :         switch( getCurrentElement() )
      60             :         {
      61             :         case PPT_TOKEN( cBhvr ):
      62             :         {
      63          16 :             if( !maAttributes.empty() )
      64             :             {
      65           7 :                 OUStringBuffer sAttributes;
      66           7 :                 std::list< Attribute >::const_iterator iter;
      67          14 :                 for(iter = maAttributes.begin(); iter != maAttributes.end(); ++iter)
      68             :                 {
      69           7 :                     if( !sAttributes.isEmpty() )
      70             :                     {
      71           0 :                         sAttributes.appendAscii( ";" );
      72             :                     }
      73           7 :                     sAttributes.append( iter->name );
      74             :                 }
      75          14 :                 OUString sTmp( sAttributes.makeStringAndClear() );
      76          14 :                 mpNode->getNodeProperties()[ NP_ATTRIBUTENAME ] = makeAny( sTmp );
      77             :             }
      78          16 :             break;
      79             :         }
      80             :         case PPT_TOKEN( attrNameLst ):
      81           7 :             mbInAttrList = false;
      82           7 :             break;
      83             :         case PPT_TOKEN( attrName ):
      84           7 :             if( mbIsInAttrName )
      85             :             {
      86           7 :                 const ImplAttributeNameConversion *attrConv = gImplConversionList;
      87         147 :                 while( attrConv->mpMSName != NULL )
      88             :                 {
      89         140 :                     if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) )
      90             :                     {
      91           7 :                         Attribute attr;
      92          14 :                         attr.name = OUString::intern( attrConv->mpAPIName,
      93           7 :                                                              strlen(attrConv->mpAPIName),
      94           7 :                                                              RTL_TEXTENCODING_ASCII_US );
      95           7 :                         attr.type = attrConv->meAttribute;
      96           7 :                         maAttributes.push_back( attr );
      97             :                         SAL_INFO("oox.ppt", "OOX: attrName is " << OUSTRING_TO_CSTR( msCurrentAttribute ) << " -> " << attrConv->mpAPIName );
      98           7 :                         break;
      99             :                     }
     100         133 :                     attrConv++;
     101             :                 }
     102           7 :                 mbIsInAttrName = false;
     103             :             }
     104           7 :             break;
     105             :         default:
     106           0 :             break;
     107             :         }
     108          30 :     }
     109             : 
     110           7 :     void CommonBehaviorContext::onCharacters( const OUString& aChars )
     111             :     {
     112           7 :         if( mbIsInAttrName )
     113             :         {
     114           7 :             msCurrentAttribute += aChars;
     115             :         }
     116           7 :     }
     117             : 
     118          46 :     ::oox::core::ContextHandlerRef CommonBehaviorContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     119             :     {
     120          46 :         switch ( aElementToken )
     121             :         {
     122             :         case PPT_TOKEN( cTn ):
     123          16 :             return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode );
     124             :         case PPT_TOKEN( tgtEl ):
     125          16 :             return new TimeTargetElementContext( *this, mpNode->getTarget() );
     126             :         case PPT_TOKEN( attrNameLst ):
     127           7 :             mbInAttrList = true;
     128           7 :             return this;
     129             :         case PPT_TOKEN( attrName ):
     130             :         {
     131           7 :             if( mbInAttrList )
     132             :             {
     133           7 :                 mbIsInAttrName = true;
     134           7 :                 msCurrentAttribute.clear();
     135             :             }
     136             :             else
     137             :             {
     138             :                 SAL_INFO("oox.ppt", "OOX: Attribute Name outside an Attribute List" );
     139             :             }
     140           7 :             return this;
     141             :         }
     142             :         default:
     143           0 :             break;
     144             :         }
     145             : 
     146           0 :         return this;
     147             :     }
     148             : 
     149         246 : } }
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11