1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "animvariantcontext.hxx" 25 26 #include "comphelper/anytostring.hxx" 27 #include "cppuhelper/exc_hlp.hxx" 28 #include <osl/diagnose.h> 29 30 #include <com/sun/star/uno/Any.hxx> 31 #include <rtl/ustring.hxx> 32 33 #include "oox/helper/attributelist.hxx" 34 #include "oox/core/fragmenthandler.hxx" 35 #include "oox/core/xmlfilterbase.hxx" 36 #include "oox/drawingml/colorchoicecontext.hxx" 37 #include "pptfilterhelpers.hxx" 38 39 using ::rtl::OUString; 40 using namespace ::oox::core; 41 using namespace ::com::sun::star::uno; 42 using namespace ::com::sun::star::xml::sax; 43 44 namespace oox { namespace ppt { 45 AnimVariantContext(ContextHandler & rParent,sal_Int32 aElement,Any & aValue)46 AnimVariantContext::AnimVariantContext( ContextHandler& rParent, sal_Int32 aElement, Any & aValue ) 47 : ContextHandler( rParent ) 48 , mnElement( aElement ) 49 , maValue( aValue ) 50 { 51 } 52 ~AnimVariantContext()53 AnimVariantContext::~AnimVariantContext( ) throw( ) 54 { 55 } 56 endFastElement(sal_Int32 aElement)57 void SAL_CALL AnimVariantContext::endFastElement( sal_Int32 aElement ) 58 throw ( SAXException, RuntimeException) 59 { 60 if( ( aElement == mnElement ) && maColor.isUsed() ) 61 { 62 maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) ); 63 } 64 } 65 66 67 Reference< XFastContextHandler > createFastChildContext(::sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)68 SAL_CALL AnimVariantContext::createFastChildContext( ::sal_Int32 aElementToken, 69 const Reference< XFastAttributeList >& xAttribs ) 70 throw ( SAXException, RuntimeException ) 71 { 72 Reference< XFastContextHandler > xRet; 73 AttributeList attribs(xAttribs); 74 75 switch( aElementToken ) 76 { 77 case PPT_TOKEN( boolVal ): 78 { 79 bool val = attribs.getBool( XML_val, false ); 80 maValue = makeAny( val ); 81 break; 82 } 83 case PPT_TOKEN( clrVal ): 84 xRet.set( new ::oox::drawingml::ColorContext( *this, maColor ) ); 85 // we'll defer setting the Any until the end. 86 break; 87 case PPT_TOKEN( fltVal ): 88 { 89 double val = attribs.getDouble( XML_val, 0.0 ); 90 maValue = makeAny( val ); 91 break; 92 } 93 case PPT_TOKEN( intVal ): 94 { 95 sal_Int32 val = attribs.getInteger( XML_val, 0 ); 96 maValue = makeAny( val ); 97 break; 98 } 99 case PPT_TOKEN( strVal ): 100 { 101 OUString val = attribs.getString( XML_val, OUString() ); 102 convertMeasure( val ); // ignore success or failure if it fails, use as is 103 maValue = makeAny( val ); 104 break; 105 } 106 default: 107 break; 108 } 109 110 if( !xRet.is() ) 111 xRet.set( this ); 112 113 return xRet; 114 } 115 116 117 118 } } 119