LibreOffice Module oox (master)  1
effectpropertiescontext.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 
11 #include "effectproperties.hxx"
14 #include <oox/token/namespaces.hxx>
15 #include <oox/token/tokens.hxx>
16 
17 using namespace ::oox::core;
18 using namespace ::com::sun::star::uno;
19 using namespace ::com::sun::star::xml::sax;
20 
21 // CT_EffectProperties
22 
23 namespace oox::drawingml {
24 
26  EffectProperties& rEffectProperties ) noexcept
27 : ContextHandler2( rParent )
28 , mrEffectProperties( rEffectProperties )
29 {
30 }
31 
33 {
34 }
35 
37 {
38  if( rAttribs.hasAttribute( XML_algn ) )
39  rEffect.maAttribs["algn"] <<= rAttribs.getString( XML_algn, "" );
40  if( rAttribs.hasAttribute( XML_blurRad ) )
41  rEffect.maAttribs["blurRad"] <<= rAttribs.getInteger( XML_blurRad, 0 );
42  if( rAttribs.hasAttribute( XML_dir ) )
43  rEffect.maAttribs["dir"] <<= rAttribs.getInteger( XML_dir, 0 );
44  if( rAttribs.hasAttribute( XML_dist ) )
45  rEffect.maAttribs["dist"] <<= rAttribs.getInteger( XML_dist, 0 );
46  if( rAttribs.hasAttribute( XML_kx ) )
47  rEffect.maAttribs["kx"] <<= rAttribs.getInteger( XML_kx, 0 );
48  if( rAttribs.hasAttribute( XML_ky ) )
49  rEffect.maAttribs["ky"] <<= rAttribs.getInteger( XML_ky, 0 );
50  if( rAttribs.hasAttribute( XML_rotWithShape ) )
51  rEffect.maAttribs["rotWithShape"] <<= rAttribs.getInteger( XML_rotWithShape, 0 );
52  if( rAttribs.hasAttribute( XML_sx ) )
53  rEffect.maAttribs["sx"] <<= rAttribs.getInteger( XML_sx, 0 );
54  if( rAttribs.hasAttribute( XML_sy ) )
55  rEffect.maAttribs["sy"] <<= rAttribs.getInteger( XML_sy, 0 );
56  if( rAttribs.hasAttribute( XML_rad ) )
57  rEffect.maAttribs["rad"] <<= rAttribs.getInteger( XML_rad, 0 );
58  if( rAttribs.hasAttribute( XML_endA ) )
59  rEffect.maAttribs["endA"] <<= rAttribs.getInteger( XML_endA, 0 );
60  if( rAttribs.hasAttribute( XML_endPos ) )
61  rEffect.maAttribs["endPos"] <<= rAttribs.getInteger( XML_endPos, 0 );
62  if( rAttribs.hasAttribute( XML_fadeDir ) )
63  rEffect.maAttribs["fadeDir"] <<= rAttribs.getInteger( XML_fadeDir, 0 );
64  if( rAttribs.hasAttribute( XML_stA ) )
65  rEffect.maAttribs["stA"] <<= rAttribs.getInteger( XML_stA, 0 );
66  if( rAttribs.hasAttribute( XML_stPos ) )
67  rEffect.maAttribs["stPos"] <<= rAttribs.getInteger( XML_stPos, 0 );
68  if( rAttribs.hasAttribute( XML_grow ) )
69  rEffect.maAttribs["grow"] <<= rAttribs.getInteger( XML_grow, 0 );
70 }
71 
73 {
74  sal_Int32 nPos = mrEffectProperties.m_Effects.size();
75  mrEffectProperties.m_Effects.push_back(std::make_unique<Effect>());
76  switch( nElement )
77  {
78  case A_TOKEN( outerShdw ):
79  {
80  mrEffectProperties.m_Effects[nPos]->msName = "outerShdw";
82 
83  mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
84  mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
85  mrEffectProperties.maShadow.moShadowSx = rAttribs.getInteger( XML_sx, 0 );
86  mrEffectProperties.maShadow.moShadowSy = rAttribs.getInteger( XML_sy, 0 );
87  mrEffectProperties.maShadow.moShadowBlur = rAttribs.getInteger( XML_blurRad, 0 );
88  return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
89  }
90  break;
91  case A_TOKEN( innerShdw ):
92  {
93  mrEffectProperties.m_Effects[nPos]->msName = "innerShdw";
95 
96  mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
97  mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
98  return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
99  }
100  break;
101  case A_TOKEN( glow ):
102  {
103  mrEffectProperties.maGlow.moGlowRad = rAttribs.getInteger( XML_rad, 0 );
104  // undo push_back to effects
105  mrEffectProperties.m_Effects.pop_back();
107 
108  }
109  case A_TOKEN( softEdge ):
110  {
111  mrEffectProperties.maSoftEdge.moRad = rAttribs.getInteger(XML_rad, 0);
112  return this; // no inner elements
113  }
114  case A_TOKEN( reflection ):
115  case A_TOKEN( blur ):
116  {
117  if (nElement == A_TOKEN(reflection))
118  mrEffectProperties.m_Effects[nPos]->msName = "reflection";
119  else if( nElement == A_TOKEN( blur ) )
120  mrEffectProperties.m_Effects[nPos]->msName = "blur";
122  return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
123  }
124  break;
125  }
126 
127  mrEffectProperties.m_Effects.pop_back();
128  return nullptr;
129 }
130 
131 }
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< std::unique_ptr< Effect > > m_Effects
Stores all effect properties, including those not supported by core yet.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
static void saveUnsupportedAttribs(Effect &rEffect, const AttributeList &rAttribs)
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
EffectSoftEdgeProperties maSoftEdge
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
Context handler for elements that contain a color value element (a:scrgbClr, a:srgbClr, a:hslClr, a:sysClr, a:schemeClr, a:prstClr).
Provides access to attribute values of an element.
exports com.sun.star. reflection
EffectPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, EffectProperties &rEffectProperties) noexcept
Helper class that provides a context stack.
std::map< OUString, css::uno::Any > maAttribs
sal_uInt16 nPos