merge the formfield patch from ooo-build
[ooovba.git] / oox / source / ppt / animvariantcontext.cxx
blobf3b9de2dbf7ac5a46fcbcbdee1c74ae08810cc08
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animvariantcontext.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "animvariantcontext.hxx"
33 #include "comphelper/anytostring.hxx"
34 #include "cppuhelper/exc_hlp.hxx"
35 #include <osl/diagnose.h>
37 #include <com/sun/star/uno/Any.hxx>
38 #include <rtl/ustring.hxx>
40 #include "oox/helper/attributelist.hxx"
41 #include "oox/core/namespaces.hxx"
42 #include "oox/core/fragmenthandler.hxx"
43 #include "oox/core/xmlfilterbase.hxx"
44 #include "oox/drawingml/colorchoicecontext.hxx"
45 #include "pptfilterhelpers.hxx"
46 #include "tokens.hxx"
48 using ::rtl::OUString;
49 using namespace ::oox::core;
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::xml::sax;
53 namespace oox { namespace ppt {
55 AnimVariantContext::AnimVariantContext( ContextHandler& rParent, sal_Int32 aElement, Any & aValue )
56 : ContextHandler( rParent )
57 , mnElement( aElement )
58 , maValue( aValue )
62 AnimVariantContext::~AnimVariantContext( ) throw( )
66 void SAL_CALL AnimVariantContext::endFastElement( sal_Int32 aElement )
67 throw ( SAXException, RuntimeException)
69 if( ( aElement == mnElement ) && maColor.isUsed() )
71 maValue = makeAny( maColor.getColor( getFilter() ) );
76 Reference< XFastContextHandler >
77 SAL_CALL AnimVariantContext::createFastChildContext( ::sal_Int32 aElementToken,
78 const Reference< XFastAttributeList >& xAttribs )
79 throw ( SAXException, RuntimeException )
81 Reference< XFastContextHandler > xRet;
82 AttributeList attribs(xAttribs);
84 switch( aElementToken )
86 case NMSP_PPT|XML_boolVal:
88 bool val = attribs.getBool( XML_val, false );
89 maValue = makeAny( val );
90 break;
92 case NMSP_PPT|XML_clrVal:
93 xRet.set( new ::oox::drawingml::ColorContext( *this, maColor ) );
94 // we'll defer setting the Any until the end.
95 break;
96 case NMSP_PPT|XML_fltVal:
98 double val = attribs.getDouble( XML_val, 0.0 );
99 maValue = makeAny( val );
100 break;
102 case NMSP_PPT|XML_intVal:
104 sal_Int32 val = attribs.getInteger( XML_val, 0 );
105 maValue = makeAny( val );
106 break;
108 case NMSP_PPT|XML_strVal:
110 OUString val = attribs.getString( XML_val, OUString() );
111 convertMeasure( val ); // ignore success or failure if it fails, use as is
112 maValue = makeAny( val );
113 break;
115 default:
116 break;
119 if( !xRet.is() )
120 xRet.set( this );
122 return xRet;