xref: /trunk/main/oox/source/ppt/animvariantcontext.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "animvariantcontext.hxx"
29 
30 #include "comphelper/anytostring.hxx"
31 #include "cppuhelper/exc_hlp.hxx"
32 #include <osl/diagnose.h>
33 
34 #include <com/sun/star/uno/Any.hxx>
35 #include <rtl/ustring.hxx>
36 
37 #include "oox/helper/attributelist.hxx"
38 #include "oox/core/fragmenthandler.hxx"
39 #include "oox/core/xmlfilterbase.hxx"
40 #include "oox/drawingml/colorchoicecontext.hxx"
41 #include "pptfilterhelpers.hxx"
42 
43 using ::rtl::OUString;
44 using namespace ::oox::core;
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::xml::sax;
47 
48 namespace oox { namespace ppt {
49 
50     AnimVariantContext::AnimVariantContext( ContextHandler& rParent, sal_Int32 aElement, Any & aValue )
51         : ContextHandler( rParent )
52             , mnElement( aElement )
53             , maValue( aValue )
54     {
55     }
56 
57     AnimVariantContext::~AnimVariantContext( ) throw( )
58     {
59     }
60 
61     void SAL_CALL AnimVariantContext::endFastElement( sal_Int32 aElement )
62         throw ( SAXException, RuntimeException)
63     {
64         if( ( aElement == mnElement ) && maColor.isUsed() )
65         {
66             maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) );
67         }
68     }
69 
70 
71     Reference< XFastContextHandler >
72     SAL_CALL AnimVariantContext::createFastChildContext( ::sal_Int32 aElementToken,
73                              const Reference< XFastAttributeList >& xAttribs )
74         throw ( SAXException, RuntimeException )
75     {
76         Reference< XFastContextHandler > xRet;
77         AttributeList attribs(xAttribs);
78 
79         switch( aElementToken )
80         {
81         case PPT_TOKEN( boolVal ):
82         {
83             bool val = attribs.getBool( XML_val, false );
84             maValue = makeAny( val );
85             break;
86         }
87         case PPT_TOKEN( clrVal ):
88             xRet.set( new ::oox::drawingml::ColorContext( *this, maColor ) );
89             // we'll defer setting the Any until the end.
90             break;
91         case PPT_TOKEN( fltVal ):
92         {
93             double val = attribs.getDouble( XML_val, 0.0 );
94             maValue = makeAny( val );
95             break;
96         }
97         case PPT_TOKEN( intVal ):
98         {
99             sal_Int32 val = attribs.getInteger( XML_val, 0 );
100             maValue = makeAny( val );
101             break;
102         }
103         case PPT_TOKEN( strVal ):
104         {
105             OUString val = attribs.getString( XML_val, OUString() );
106             convertMeasure( val ); // ignore success or failure if it fails, use as is
107             maValue = makeAny( val );
108             break;
109         }
110         default:
111             break;
112         }
113 
114         if( !xRet.is() )
115             xRet.set( this );
116 
117         return xRet;
118     }
119 
120 
121 
122 } }
123