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 9200 : EffectPropertiesContext::EffectPropertiesContext( ContextHandler2Helper& rParent,
25 : EffectProperties& rEffectProperties ) throw()
26 : : ContextHandler2( rParent )
27 9200 : , mrEffectProperties( rEffectProperties )
28 : {
29 9200 : }
30 :
31 18400 : EffectPropertiesContext::~EffectPropertiesContext()
32 : {
33 18400 : }
34 :
35 7712 : void EffectPropertiesContext::saveUnsupportedAttribs( Effect& rEffect, const AttributeList& rAttribs )
36 : {
37 7712 : if( rAttribs.hasAttribute( XML_algn ) )
38 442 : rEffect.maAttribs["algn"] = makeAny( rAttribs.getString( XML_algn, "" ) );
39 7712 : if( rAttribs.hasAttribute( XML_blurRad ) )
40 7550 : rEffect.maAttribs["blurRad"] = makeAny( rAttribs.getInteger( XML_blurRad, 0 ) );
41 7712 : if( rAttribs.hasAttribute( XML_dir ) )
42 7558 : rEffect.maAttribs["dir"] = makeAny( rAttribs.getInteger( XML_dir, 0 ) );
43 7712 : if( rAttribs.hasAttribute( XML_dist ) )
44 7640 : rEffect.maAttribs["dist"] = makeAny( rAttribs.getInteger( XML_dist, 0 ) );
45 7712 : if( rAttribs.hasAttribute( XML_kx ) )
46 0 : rEffect.maAttribs["kx"] = makeAny( rAttribs.getInteger( XML_kx, 0 ) );
47 7712 : if( rAttribs.hasAttribute( XML_ky ) )
48 0 : rEffect.maAttribs["ky"] = makeAny( rAttribs.getInteger( XML_ky, 0 ) );
49 7712 : if( rAttribs.hasAttribute( XML_rotWithShape ) )
50 7586 : rEffect.maAttribs["rotWithShape"] = makeAny( rAttribs.getInteger( XML_rotWithShape, 0 ) );
51 7712 : if( rAttribs.hasAttribute( XML_sx ) )
52 4 : rEffect.maAttribs["sx"] = makeAny( rAttribs.getInteger( XML_sx, 0 ) );
53 7712 : if( rAttribs.hasAttribute( XML_sy ) )
54 34 : rEffect.maAttribs["sy"] = makeAny( rAttribs.getInteger( XML_sy, 0 ) );
55 7712 : if( rAttribs.hasAttribute( XML_rad ) )
56 54 : rEffect.maAttribs["rad"] = makeAny( rAttribs.getInteger( XML_rad, 0 ) );
57 7712 : if( rAttribs.hasAttribute( XML_endA ) )
58 24 : rEffect.maAttribs["endA"] = makeAny( rAttribs.getInteger( XML_endA, 0 ) );
59 7712 : if( rAttribs.hasAttribute( XML_endPos ) )
60 30 : rEffect.maAttribs["endPos"] = makeAny( rAttribs.getInteger( XML_endPos, 0 ) );
61 7712 : if( rAttribs.hasAttribute( XML_fadeDir ) )
62 0 : rEffect.maAttribs["fadeDir"] = makeAny( rAttribs.getInteger( XML_fadeDir, 0 ) );
63 7712 : if( rAttribs.hasAttribute( XML_stA ) )
64 30 : rEffect.maAttribs["stA"] = makeAny( rAttribs.getInteger( XML_stA, 0 ) );
65 7712 : if( rAttribs.hasAttribute( XML_stPos ) )
66 0 : rEffect.maAttribs["stPos"] = makeAny( rAttribs.getInteger( XML_stPos, 0 ) );
67 7712 : if( rAttribs.hasAttribute( XML_grow ) )
68 0 : rEffect.maAttribs["grow"] = makeAny( rAttribs.getInteger( XML_grow, 0 ) );
69 7712 : }
70 :
71 7712 : ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
72 : {
73 7712 : sal_Int32 nPos = mrEffectProperties.maEffects.size();
74 7712 : mrEffectProperties.maEffects.push_back( new Effect() );
75 7712 : switch( nElement )
76 : {
77 : case A_TOKEN( outerShdw ):
78 : {
79 7574 : mrEffectProperties.maEffects[nPos].msName = "outerShdw";
80 7574 : saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
81 :
82 7574 : mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
83 7574 : mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
84 7574 : return new ColorContext( *this, mrEffectProperties.maEffects[nPos].moColor );
85 : }
86 : break;
87 : case A_TOKEN( innerShdw ):
88 : {
89 54 : mrEffectProperties.maEffects[nPos].msName = "innerShdw";
90 54 : saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
91 :
92 54 : mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
93 54 : mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
94 54 : 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 84 : if( nElement == A_TOKEN( glow ) )
103 42 : mrEffectProperties.maEffects[nPos].msName = "glow";
104 42 : else if( nElement == A_TOKEN( softEdge ) )
105 12 : mrEffectProperties.maEffects[nPos].msName = "softEdge";
106 30 : else if( nElement == A_TOKEN( reflection ) )
107 30 : mrEffectProperties.maEffects[nPos].msName = "reflection";
108 0 : else if( nElement == A_TOKEN( blur ) )
109 0 : mrEffectProperties.maEffects[nPos].msName = "blur";
110 84 : saveUnsupportedAttribs( mrEffectProperties.maEffects[nPos], rAttribs );
111 84 : 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: */
|