GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / ppt / commonbehaviorcontext.cxx
blob5cc23c562a08977e10ee28b26eec18464173a325
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "comphelper/anytostring.hxx"
21 #include "cppuhelper/exc_hlp.hxx"
22 #include <rtl/ustrbuf.hxx>
24 #include <com/sun/star/animations/XTimeContainer.hpp>
25 #include <com/sun/star/animations/XAnimationNode.hpp>
26 #include <com/sun/star/animations/XAnimate.hpp>
28 #include "oox/core/fragmenthandler.hxx"
30 #include "commonbehaviorcontext.hxx"
31 #include "commontimenodecontext.hxx"
32 #include "timetargetelementcontext.hxx"
33 #include "pptfilterhelpers.hxx"
35 #include <string.h>
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;
42 namespace oox { namespace ppt {
44 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 , mbIsInAttrName( false )
54 CommonBehaviorContext::~CommonBehaviorContext( ) throw( )
60 void CommonBehaviorContext::onEndElement()
62 switch( getCurrentElement() )
64 case PPT_TOKEN( cBhvr ):
66 if( !maAttributes.empty() )
68 OUStringBuffer sAttributes;
69 std::list< Attribute >::const_iterator iter;
70 for(iter = maAttributes.begin(); iter != maAttributes.end(); ++iter)
72 if( !sAttributes.isEmpty() )
74 sAttributes.appendAscii( ";" );
76 sAttributes.append( iter->name );
78 OUString sTmp( sAttributes.makeStringAndClear() );
79 mpNode->getNodeProperties()[ NP_ATTRIBUTENAME ] = makeAny( sTmp );
81 break;
83 case PPT_TOKEN( attrNameLst ):
84 mbInAttrList = false;
85 break;
86 case PPT_TOKEN( attrName ):
87 if( mbIsInAttrName )
89 const ImplAttributeNameConversion *attrConv = gImplConversionList;
90 while( attrConv->mpMSName != NULL )
92 if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) )
94 Attribute attr;
95 attr.name = OUString::intern( attrConv->mpAPIName,
96 strlen(attrConv->mpAPIName),
97 RTL_TEXTENCODING_ASCII_US );
98 attr.type = attrConv->meAttribute;
99 maAttributes.push_back( attr );
100 SAL_INFO("oox.ppt", "OOX: attrName is " << OUSTRING_TO_CSTR( msCurrentAttribute ) << " -> " << attrConv->mpAPIName );
101 break;
103 attrConv++;
105 mbIsInAttrName = false;
107 break;
108 default:
109 break;
114 void CommonBehaviorContext::onCharacters( const OUString& aChars )
116 if( mbIsInAttrName )
118 msCurrentAttribute += aChars;
123 ::oox::core::ContextHandlerRef CommonBehaviorContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
125 switch ( aElementToken )
127 case PPT_TOKEN( cTn ):
128 return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode );
129 case PPT_TOKEN( tgtEl ):
130 return new TimeTargetElementContext( *this, mpNode->getTarget() );
131 case PPT_TOKEN( attrNameLst ):
132 mbInAttrList = true;
133 return this;
134 case PPT_TOKEN( attrName ):
136 if( mbInAttrList )
138 mbIsInAttrName = true;
139 msCurrentAttribute = OUString();
141 else
143 SAL_INFO("oox.ppt", "OOX: Attribute Name outside an Attribute List" );
145 return this;
147 default:
148 break;
151 return this;
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */