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 :
10 : #include "effectpropertiescontext.hxx"
11 : #include "effectproperties.hxx"
12 : #include "oox/drawingml/drawingmltypes.hxx"
13 : #include "drawingml/fillpropertiesgroupcontext.hxx"
14 : #include "oox/helper/attributelist.hxx"
15 :
16 : using namespace ::oox::core;
17 : using namespace ::com::sun::star::uno;
18 : using namespace ::com::sun::star::xml::sax;
19 :
20 : // CT_EffectProperties
21 :
22 : namespace oox { namespace drawingml {
23 :
24 5198 : EffectPropertiesContext::EffectPropertiesContext( ContextHandler2Helper& rParent,
25 : EffectProperties& rEffectProperties ) throw()
26 : : ContextHandler2( rParent )
27 5198 : , mrEffectProperties( rEffectProperties )
28 : {
29 5198 : }
30 :
31 10396 : EffectPropertiesContext::~EffectPropertiesContext()
32 : {
33 10396 : }
34 :
35 4182 : void EffectPropertiesContext::saveUnsupportedAttribs( Effect& rEffect, const AttributeList& rAttribs )
36 : {
37 4182 : if( rAttribs.hasAttribute( XML_algn ) )
38 280 : rEffect.maAttribs["algn"] = makeAny( rAttribs.getString( XML_algn, "" ) );
39 4182 : if( rAttribs.hasAttribute( XML_blurRad ) )
40 4091 : rEffect.maAttribs["blurRad"] = makeAny( rAttribs.getInteger( XML_blurRad, 0 ) );
41 4182 : if( rAttribs.hasAttribute( XML_dir ) )
42 4097 : rEffect.maAttribs["dir"] = makeAny( rAttribs.getInteger( XML_dir, 0 ) );
43 4182 : if( rAttribs.hasAttribute( XML_dist ) )
44 4130 : rEffect.maAttribs["dist"] = makeAny( rAttribs.getInteger( XML_dist, 0 ) );
45 4182 : if( rAttribs.hasAttribute( XML_kx ) )
46 0 : rEffect.maAttribs["kx"] = makeAny( rAttribs.getInteger( XML_kx, 0 ) );
47 4182 : if( rAttribs.hasAttribute( XML_ky ) )
48 0 : rEffect.maAttribs["ky"] = makeAny( rAttribs.getInteger( XML_ky, 0 ) );
49 4182 : if( rAttribs.hasAttribute( XML_rotWithShape ) )
50 4109 : rEffect.maAttribs["rotWithShape"] = makeAny( rAttribs.getInteger( XML_rotWithShape, 0 ) );
51 4182 : if( rAttribs.hasAttribute( XML_sx ) )
52 2 : rEffect.maAttribs["sx"] = makeAny( rAttribs.getInteger( XML_sx, 0 ) );
53 4182 : if( rAttribs.hasAttribute( XML_sy ) )
54 25 : rEffect.maAttribs["sy"] = makeAny( rAttribs.getInteger( XML_sy, 0 ) );
55 4182 : if( rAttribs.hasAttribute( XML_rad ) )
56 35 : rEffect.maAttribs["rad"] = makeAny( rAttribs.getInteger( XML_rad, 0 ) );
57 4182 : if( rAttribs.hasAttribute( XML_endA ) )
58 20 : rEffect.maAttribs["endA"] = makeAny( rAttribs.getInteger( XML_endA, 0 ) );
59 4182 : if( rAttribs.hasAttribute( XML_endPos ) )
60 23 : rEffect.maAttribs["endPos"] = makeAny( rAttribs.getInteger( XML_endPos, 0 ) );
61 4182 : if( rAttribs.hasAttribute( XML_fadeDir ) )
62 0 : rEffect.maAttribs["fadeDir"] = makeAny( rAttribs.getInteger( XML_fadeDir, 0 ) );
63 4182 : if( rAttribs.hasAttribute( XML_stA ) )
64 23 : rEffect.maAttribs["stA"] = makeAny( rAttribs.getInteger( XML_stA, 0 ) );
65 4182 : if( rAttribs.hasAttribute( XML_stPos ) )
66 0 : rEffect.maAttribs["stPos"] = makeAny( rAttribs.getInteger( XML_stPos, 0 ) );
67 4182 : if( rAttribs.hasAttribute( XML_grow ) )
68 0 : rEffect.maAttribs["grow"] = makeAny( rAttribs.getInteger( XML_grow, 0 ) );
69 4182 : }
70 :
71 4182 : ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
72 : {
73 4182 : sal_Int32 nPos = mrEffectProperties.maEffects.size();
74 4182 : mrEffectProperties.maEffects.push_back( new Effect() );
75 4182 : switch( nElement )
76 : {
77 : case A_TOKEN( outerShdw ):
78 : {
79 4097 : mrEffectProperties.maEffects[nPos].msName = "outerShdw";
80 4097 : saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
81 :
82 4097 : mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
83 4097 : mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
84 4097 : return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
85 : }
86 : break;
87 : case A_TOKEN( innerShdw ):
88 : {
89 27 : mrEffectProperties.maEffects[nPos].msName = "innerShdw";
90 27 : saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
91 :
92 27 : mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
93 27 : mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
94 27 : return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
95 : }
96 : break;
97 : case A_TOKEN( glow ):
98 : case A_TOKEN( softEdge ):
99 : case A_TOKEN( reflection ):
100 : case A_TOKEN( blur ):
101 : {
102 58 : if( nElement == A_TOKEN( glow ) )
103 29 : mrEffectProperties.maEffects[nPos].msName = "glow";
104 29 : else if( nElement == A_TOKEN( softEdge ) )
105 6 : mrEffectProperties.maEffects[nPos].msName = "softEdge";
106 23 : else if( nElement == A_TOKEN( reflection ) )
107 23 : mrEffectProperties.maEffects[nPos].msName = "reflection";
108 0 : else if( nElement == A_TOKEN( blur ) )
109 0 : mrEffectProperties.maEffects[nPos].msName = "blur";
110 58 : saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
111 58 : return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
112 : }
113 : break;
114 : }
115 :
116 0 : mrEffectProperties.maEffects.pop_back();
117 0 : return 0;
118 : }
119 :
120 : } }
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|