LibreOffice Module oox (master)  1
animvariantcontext.cxx
Go to the documentation of this file.
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 <com/sun/star/uno/Any.hxx>
23 #include <rtl/ustring.hxx>
24 
28 #include <oox/token/namespaces.hxx>
29 #include <oox/token/tokens.hxx>
30 
31 using namespace ::oox::core;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::xml::sax;
34 
35 namespace oox::ppt {
36  AnimVariantContext::AnimVariantContext( FragmentHandler2 const & rParent, sal_Int32 aElement, Any & aValue )
37  : FragmentHandler2( rParent )
38  , mnElement( aElement )
39  , maValue( aValue )
40  {
41  }
42 
44  {
45  }
46 
48  {
50  {
51  maValue <<= maColor.getColor( getFilter().getGraphicHelper() );
52  }
53  }
54 
55  ContextHandlerRef AnimVariantContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
56  {
57  switch( aElementToken )
58  {
59  case PPT_TOKEN( boolVal ):
60  {
61  bool val = rAttribs.getBool( XML_val, false );
62  maValue <<= val;
63  return this;
64  }
65  case PPT_TOKEN( clrVal ):
66  return new ::oox::drawingml::ColorContext( *this, maColor );
67  // we'll defer setting the Any until the end.
68  case PPT_TOKEN( fltVal ):
69  {
70  double val = rAttribs.getDouble( XML_val, 0.0 );
71  maValue <<= val;
72  return this;
73  }
74  case PPT_TOKEN( intVal ):
75  {
76  sal_Int32 val = rAttribs.getInteger( XML_val, 0 );
77  maValue <<= val;
78  return this;
79  }
80  case PPT_TOKEN( strVal ):
81  {
82  OUString val = rAttribs.getString( XML_val, OUString() );
83  maValue <<= val;
84  return this;
85  }
86  default:
87  break;
88  }
89 
90  return this;
91  }
92 
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptValue< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
bool isCurrentElement(sal_Int32 nElement) const
Returns true, if nElement contains the identifier of the currently processed element.
OptValue< double > getDouble(sal_Int32 nAttrToken) const
Returns the double value of the specified attribute.
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
AnimVariantContext(::oox::core::FragmentHandler2 const &rParent,::sal_Int32 aElement, css::uno::Any &aValue)
::Color getColor(const GraphicHelper &rGraphicHelper,::Color nPhClr=API_RGB_TRANSPARENT) const
Returns the final RGB color value.
Definition: color.cxx:481
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:87
virtual void onEndElement() override
Will be called when the current element is about to be left.
Provides access to attribute values of an element.
virtual ~AnimVariantContext() noexcept override
::oox::drawingml::Color maColor
::rtl::Reference< ContextHandler > ContextHandlerRef
double maValue
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.