1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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 using namespace ::oox::core
;
19 using namespace ::com::sun::star::uno
;
20 using namespace ::com::sun::star::xml::sax
;
22 // CT_EffectProperties
24 namespace oox
{ namespace drawingml
{
26 EffectPropertiesContext::EffectPropertiesContext( ContextHandler2Helper
const& rParent
,
27 EffectProperties
& rEffectProperties
) throw()
28 : ContextHandler2( rParent
)
29 , mrEffectProperties( rEffectProperties
)
33 EffectPropertiesContext::~EffectPropertiesContext()
37 void EffectPropertiesContext::saveUnsupportedAttribs( Effect
& rEffect
, const AttributeList
& rAttribs
)
39 if( rAttribs
.hasAttribute( XML_algn
) )
40 rEffect
.maAttribs
["algn"] <<= rAttribs
.getString( XML_algn
, "" );
41 if( rAttribs
.hasAttribute( XML_blurRad
) )
42 rEffect
.maAttribs
["blurRad"] <<= rAttribs
.getInteger( XML_blurRad
, 0 );
43 if( rAttribs
.hasAttribute( XML_dir
) )
44 rEffect
.maAttribs
["dir"] <<= rAttribs
.getInteger( XML_dir
, 0 );
45 if( rAttribs
.hasAttribute( XML_dist
) )
46 rEffect
.maAttribs
["dist"] <<= rAttribs
.getInteger( XML_dist
, 0 );
47 if( rAttribs
.hasAttribute( XML_kx
) )
48 rEffect
.maAttribs
["kx"] <<= rAttribs
.getInteger( XML_kx
, 0 );
49 if( rAttribs
.hasAttribute( XML_ky
) )
50 rEffect
.maAttribs
["ky"] <<= rAttribs
.getInteger( XML_ky
, 0 );
51 if( rAttribs
.hasAttribute( XML_rotWithShape
) )
52 rEffect
.maAttribs
["rotWithShape"] <<= rAttribs
.getInteger( XML_rotWithShape
, 0 );
53 if( rAttribs
.hasAttribute( XML_sx
) )
54 rEffect
.maAttribs
["sx"] <<= rAttribs
.getInteger( XML_sx
, 0 );
55 if( rAttribs
.hasAttribute( XML_sy
) )
56 rEffect
.maAttribs
["sy"] <<= rAttribs
.getInteger( XML_sy
, 0 );
57 if( rAttribs
.hasAttribute( XML_rad
) )
58 rEffect
.maAttribs
["rad"] <<= rAttribs
.getInteger( XML_rad
, 0 );
59 if( rAttribs
.hasAttribute( XML_endA
) )
60 rEffect
.maAttribs
["endA"] <<= rAttribs
.getInteger( XML_endA
, 0 );
61 if( rAttribs
.hasAttribute( XML_endPos
) )
62 rEffect
.maAttribs
["endPos"] <<= rAttribs
.getInteger( XML_endPos
, 0 );
63 if( rAttribs
.hasAttribute( XML_fadeDir
) )
64 rEffect
.maAttribs
["fadeDir"] <<= rAttribs
.getInteger( XML_fadeDir
, 0 );
65 if( rAttribs
.hasAttribute( XML_stA
) )
66 rEffect
.maAttribs
["stA"] <<= rAttribs
.getInteger( XML_stA
, 0 );
67 if( rAttribs
.hasAttribute( XML_stPos
) )
68 rEffect
.maAttribs
["stPos"] <<= rAttribs
.getInteger( XML_stPos
, 0 );
69 if( rAttribs
.hasAttribute( XML_grow
) )
70 rEffect
.maAttribs
["grow"] <<= rAttribs
.getInteger( XML_grow
, 0 );
73 ContextHandlerRef
EffectPropertiesContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
75 sal_Int32 nPos
= mrEffectProperties
.m_Effects
.size();
76 mrEffectProperties
.m_Effects
.push_back(std::make_unique
<Effect
>());
79 case A_TOKEN( outerShdw
):
81 mrEffectProperties
.m_Effects
[nPos
]->msName
= "outerShdw";
82 saveUnsupportedAttribs(*mrEffectProperties
.m_Effects
[nPos
], rAttribs
);
84 mrEffectProperties
.maShadow
.moShadowDist
= rAttribs
.getInteger( XML_dist
, 0 );
85 mrEffectProperties
.maShadow
.moShadowDir
= rAttribs
.getInteger( XML_dir
, 0 );
86 return new ColorContext(*this, mrEffectProperties
.m_Effects
[nPos
]->moColor
);
89 case A_TOKEN( innerShdw
):
91 mrEffectProperties
.m_Effects
[nPos
]->msName
= "innerShdw";
92 saveUnsupportedAttribs(*mrEffectProperties
.m_Effects
[nPos
], rAttribs
);
94 mrEffectProperties
.maShadow
.moShadowDist
= rAttribs
.getInteger( XML_dist
, 0 );
95 mrEffectProperties
.maShadow
.moShadowDir
= rAttribs
.getInteger( XML_dir
, 0 );
96 return new ColorContext(*this, mrEffectProperties
.m_Effects
[nPos
]->moColor
);
100 case A_TOKEN( softEdge
):
101 case A_TOKEN( reflection
):
102 case A_TOKEN( blur
):
104 if( nElement
== A_TOKEN( glow
) )
105 mrEffectProperties
.m_Effects
[nPos
]->msName
= "glow";
106 else if( nElement
== A_TOKEN( softEdge
) )
107 mrEffectProperties
.m_Effects
[nPos
]->msName
= "softEdge";
108 else if( nElement
== A_TOKEN( reflection
) )
109 mrEffectProperties
.m_Effects
[nPos
]->msName
= "reflection";
110 else if( nElement
== A_TOKEN( blur
) )
111 mrEffectProperties
.m_Effects
[nPos
]->msName
= "blur";
112 saveUnsupportedAttribs(*mrEffectProperties
.m_Effects
[nPos
], rAttribs
);
113 return new ColorContext(*this, mrEffectProperties
.m_Effects
[nPos
]->moColor
);
118 mrEffectProperties
.m_Effects
.pop_back();
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */