xref: /trunk/main/oox/source/ppt/animvariantcontext.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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     {
59         if( ( aElement == mnElement ) && maColor.isUsed() )
60         {
61             maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) );
62         }
63     }
64 
65 
66     Reference< XFastContextHandler >
createFastChildContext(::sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)67     SAL_CALL AnimVariantContext::createFastChildContext( ::sal_Int32 aElementToken,
68                              const Reference< XFastAttributeList >& xAttribs )
69     {
70         Reference< XFastContextHandler > xRet;
71         AttributeList attribs(xAttribs);
72 
73         switch( aElementToken )
74         {
75         case PPT_TOKEN( boolVal ):
76         {
77             bool val = attribs.getBool( XML_val, false );
78             maValue = makeAny( val );
79             break;
80         }
81         case PPT_TOKEN( clrVal ):
82             xRet.set( new ::oox::drawingml::ColorContext( *this, maColor ) );
83             // we'll defer setting the Any until the end.
84             break;
85         case PPT_TOKEN( fltVal ):
86         {
87             double val = attribs.getDouble( XML_val, 0.0 );
88             maValue = makeAny( val );
89             break;
90         }
91         case PPT_TOKEN( intVal ):
92         {
93             sal_Int32 val = attribs.getInteger( XML_val, 0 );
94             maValue = makeAny( val );
95             break;
96         }
97         case PPT_TOKEN( strVal ):
98         {
99             OUString val = attribs.getString( XML_val, OUString() );
100             convertMeasure( val ); // ignore success or failure if it fails, use as is
101             maValue = makeAny( val );
102             break;
103         }
104         default:
105             break;
106         }
107 
108         if( !xRet.is() )
109             xRet.set( this );
110 
111         return xRet;
112     }
113 
114 
115 
116 } }
117