Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "animvariantcontext.hxx"
21 :
22 : #include "comphelper/anytostring.hxx"
23 : #include "cppuhelper/exc_hlp.hxx"
24 : #include <osl/diagnose.h>
25 :
26 : #include <com/sun/star/uno/Any.hxx>
27 : #include <rtl/ustring.hxx>
28 :
29 : #include "oox/helper/attributelist.hxx"
30 : #include "oox/core/fragmenthandler.hxx"
31 : #include "oox/core/xmlfilterbase.hxx"
32 : #include "oox/drawingml/colorchoicecontext.hxx"
33 : #include "pptfilterhelpers.hxx"
34 :
35 : using namespace ::oox::core;
36 : using namespace ::com::sun::star::uno;
37 : using namespace ::com::sun::star::xml::sax;
38 :
39 : namespace oox { namespace ppt {
40 :
41 0 : AnimVariantContext::AnimVariantContext( FragmentHandler2& rParent, sal_Int32 aElement, Any & aValue )
42 : : FragmentHandler2( rParent )
43 : , mnElement( aElement )
44 0 : , maValue( aValue )
45 : {
46 0 : }
47 :
48 0 : AnimVariantContext::~AnimVariantContext( ) throw( )
49 : {
50 0 : }
51 :
52 0 : void AnimVariantContext::onEndElement()
53 : {
54 0 : if( isCurrentElement( mnElement ) && maColor.isUsed() )
55 : {
56 0 : maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) );
57 : }
58 0 : }
59 :
60 :
61 0 : ContextHandlerRef AnimVariantContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
62 : {
63 0 : switch( aElementToken )
64 : {
65 : case PPT_TOKEN( boolVal ):
66 : {
67 0 : bool val = rAttribs.getBool( XML_val, false );
68 0 : maValue = makeAny( val );
69 0 : return this;
70 : }
71 : case PPT_TOKEN( clrVal ):
72 0 : return new ::oox::drawingml::ColorContext( *this, maColor );
73 : // we'll defer setting the Any until the end.
74 : case PPT_TOKEN( fltVal ):
75 : {
76 0 : double val = rAttribs.getDouble( XML_val, 0.0 );
77 0 : maValue = makeAny( val );
78 0 : return this;
79 : }
80 : case PPT_TOKEN( intVal ):
81 : {
82 0 : sal_Int32 val = rAttribs.getInteger( XML_val, 0 );
83 0 : maValue = makeAny( val );
84 0 : return this;
85 : }
86 : case PPT_TOKEN( strVal ):
87 : {
88 0 : OUString val = rAttribs.getString( XML_val, OUString() );
89 0 : convertMeasure( val ); // ignore success or failure if it fails, use as is
90 0 : maValue = makeAny( val );
91 0 : return this;
92 : }
93 : default:
94 0 : break;
95 : }
96 :
97 0 : return this;
98 : }
99 :
100 :
101 :
102 0 : } }
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|