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

Generated by: LCOV version 1.10