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 "effectproperties.hxx"
11 #include "oox/drawingml/drawingmltypes.hxx"
12 #include "oox/drawingml/shapepropertymap.hxx"
13 #include "oox/helper/graphichelper.hxx"
14 #include <oox/token/properties.hxx>
15 #include <oox/token/tokens.hxx>
17 #include <basegfx/numeric/ftools.hxx>
18 #include <o3tl/make_unique.hxx>
23 void EffectShadowProperties::assignUsed(const EffectShadowProperties
& rSourceProps
)
25 moShadowDist
.assignIfUsed( rSourceProps
.moShadowDist
);
26 moShadowDir
.assignIfUsed( rSourceProps
.moShadowDir
);
27 moShadowColor
.assignIfUsed( rSourceProps
.moShadowColor
);
30 void EffectProperties::assignUsed( const EffectProperties
& rSourceProps
)
32 maShadow
.assignUsed(rSourceProps
.maShadow
);
33 if (!rSourceProps
.m_Effects
.empty())
36 m_Effects
.reserve(rSourceProps
.m_Effects
.size());
37 for (auto const& it
: rSourceProps
.m_Effects
)
39 m_Effects
.push_back(o3tl::make_unique
<Effect
>(*it
));
44 void EffectProperties::pushToPropMap( PropertyMap
& rPropMap
,
45 const GraphicHelper
& rGraphicHelper
) const
47 for (auto const& it
: m_Effects
)
49 if( it
->msName
== "outerShdw" )
51 sal_Int32 nAttrDir
= 0, nAttrDist
= 0;
52 std::map
< OUString
, css::uno::Any
>::const_iterator attribIt
= it
->maAttribs
.find( "dir" );
53 if( attribIt
!= it
->maAttribs
.end() )
54 attribIt
->second
>>= nAttrDir
;
56 attribIt
= it
->maAttribs
.find( "dist" );
57 if( attribIt
!= it
->maAttribs
.end() )
58 attribIt
->second
>>= nAttrDist
;
60 // Negative X or Y dist indicates left or up, respectively
61 double nAngle
= ( static_cast<double>(nAttrDir
) / PER_DEGREE
) * F_PI180
;
62 sal_Int32 nDist
= convertEmuToHmm( nAttrDist
);
63 sal_Int32 nXDist
= cos(nAngle
) * nDist
;
64 sal_Int32 nYDist
= sin(nAngle
) * nDist
;
66 rPropMap
.setProperty( PROP_Shadow
, true );
67 rPropMap
.setProperty( PROP_ShadowXDistance
, nXDist
);
68 rPropMap
.setProperty( PROP_ShadowYDistance
, nYDist
);
69 rPropMap
.setProperty( PROP_ShadowColor
, it
->moColor
.getColor(rGraphicHelper
) );
70 rPropMap
.setProperty( PROP_ShadowTransparence
, it
->moColor
.getTransparency());
75 css::beans::PropertyValue
Effect::getEffect()
77 css::beans::PropertyValue aRet
;
78 if( msName
.isEmpty() )
81 css::uno::Sequence
< css::beans::PropertyValue
> aSeq( maAttribs
.size() );
83 for( std::map
< OUString
, css::uno::Any
>::iterator it
= maAttribs
.begin(); it
!= maAttribs
.end(); ++it
)
85 aSeq
[i
].Name
= it
->first
;
86 aSeq
[i
].Value
= it
->second
;
96 } // namespace drawingml
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */