Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / oox / source / drawingml / effectpropertiescontext.cxx
blobdc7f85517ea256a1ec25b814394796af69dcdd06
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include "effectpropertiescontext.hxx"
11 #include "effectproperties.hxx"
12 #include "oox/drawingml/drawingmltypes.hxx"
13 #include "drawingml/misccontexts.hxx"
14 #include "oox/helper/attributelist.hxx"
15 #include <oox/token/namespaces.hxx>
16 #include <oox/token/tokens.hxx>
18 #include <o3tl/make_unique.hxx>
20 using namespace ::oox::core;
21 using namespace ::com::sun::star::uno;
22 using namespace ::com::sun::star::xml::sax;
24 // CT_EffectProperties
26 namespace oox { namespace drawingml {
28 EffectPropertiesContext::EffectPropertiesContext( ContextHandler2Helper& rParent,
29 EffectProperties& rEffectProperties ) throw()
30 : ContextHandler2( rParent )
31 , mrEffectProperties( rEffectProperties )
35 EffectPropertiesContext::~EffectPropertiesContext()
39 void EffectPropertiesContext::saveUnsupportedAttribs( Effect& rEffect, const AttributeList& rAttribs )
41 if( rAttribs.hasAttribute( XML_algn ) )
42 rEffect.maAttribs["algn"] <<= rAttribs.getString( XML_algn, "" );
43 if( rAttribs.hasAttribute( XML_blurRad ) )
44 rEffect.maAttribs["blurRad"] <<= rAttribs.getInteger( XML_blurRad, 0 );
45 if( rAttribs.hasAttribute( XML_dir ) )
46 rEffect.maAttribs["dir"] <<= rAttribs.getInteger( XML_dir, 0 );
47 if( rAttribs.hasAttribute( XML_dist ) )
48 rEffect.maAttribs["dist"] <<= rAttribs.getInteger( XML_dist, 0 );
49 if( rAttribs.hasAttribute( XML_kx ) )
50 rEffect.maAttribs["kx"] <<= rAttribs.getInteger( XML_kx, 0 );
51 if( rAttribs.hasAttribute( XML_ky ) )
52 rEffect.maAttribs["ky"] <<= rAttribs.getInteger( XML_ky, 0 );
53 if( rAttribs.hasAttribute( XML_rotWithShape ) )
54 rEffect.maAttribs["rotWithShape"] <<= rAttribs.getInteger( XML_rotWithShape, 0 );
55 if( rAttribs.hasAttribute( XML_sx ) )
56 rEffect.maAttribs["sx"] <<= rAttribs.getInteger( XML_sx, 0 );
57 if( rAttribs.hasAttribute( XML_sy ) )
58 rEffect.maAttribs["sy"] <<= rAttribs.getInteger( XML_sy, 0 );
59 if( rAttribs.hasAttribute( XML_rad ) )
60 rEffect.maAttribs["rad"] <<= rAttribs.getInteger( XML_rad, 0 );
61 if( rAttribs.hasAttribute( XML_endA ) )
62 rEffect.maAttribs["endA"] <<= rAttribs.getInteger( XML_endA, 0 );
63 if( rAttribs.hasAttribute( XML_endPos ) )
64 rEffect.maAttribs["endPos"] <<= rAttribs.getInteger( XML_endPos, 0 );
65 if( rAttribs.hasAttribute( XML_fadeDir ) )
66 rEffect.maAttribs["fadeDir"] <<= rAttribs.getInteger( XML_fadeDir, 0 );
67 if( rAttribs.hasAttribute( XML_stA ) )
68 rEffect.maAttribs["stA"] <<= rAttribs.getInteger( XML_stA, 0 );
69 if( rAttribs.hasAttribute( XML_stPos ) )
70 rEffect.maAttribs["stPos"] <<= rAttribs.getInteger( XML_stPos, 0 );
71 if( rAttribs.hasAttribute( XML_grow ) )
72 rEffect.maAttribs["grow"] <<= rAttribs.getInteger( XML_grow, 0 );
75 ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
77 sal_Int32 nPos = mrEffectProperties.m_Effects.size();
78 mrEffectProperties.m_Effects.push_back(o3tl::make_unique<Effect>());
79 switch( nElement )
81 case A_TOKEN( outerShdw ):
83 mrEffectProperties.m_Effects[nPos]->msName = "outerShdw";
84 saveUnsupportedAttribs(*mrEffectProperties.m_Effects[nPos], rAttribs);
86 mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
87 mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
88 return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
90 break;
91 case A_TOKEN( innerShdw ):
93 mrEffectProperties.m_Effects[nPos]->msName = "innerShdw";
94 saveUnsupportedAttribs(*mrEffectProperties.m_Effects[nPos], rAttribs);
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);
100 break;
101 case A_TOKEN( glow ):
102 case A_TOKEN( softEdge ):
103 case A_TOKEN( reflection ):
104 case A_TOKEN( blur ):
106 if( nElement == A_TOKEN( glow ) )
107 mrEffectProperties.m_Effects[nPos]->msName = "glow";
108 else if( nElement == A_TOKEN( softEdge ) )
109 mrEffectProperties.m_Effects[nPos]->msName = "softEdge";
110 else if( nElement == A_TOKEN( reflection ) )
111 mrEffectProperties.m_Effects[nPos]->msName = "reflection";
112 else if( nElement == A_TOKEN( blur ) )
113 mrEffectProperties.m_Effects[nPos]->msName = "blur";
114 saveUnsupportedAttribs(*mrEffectProperties.m_Effects[nPos], rAttribs);
115 return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor);
117 break;
120 mrEffectProperties.m_Effects.pop_back();
121 return nullptr;
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */