Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / drawingml / effectproperties.cxx
blobbbfee474b3f222b26f16aab881d6590bdb521dbe
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 "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>
19 namespace oox {
20 namespace drawingml {
22 void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourceProps)
24 moShadowDist.assignIfUsed( rSourceProps.moShadowDist );
25 moShadowDir.assignIfUsed( rSourceProps.moShadowDir );
26 moShadowColor.assignIfUsed( rSourceProps.moShadowColor );
29 void EffectProperties::assignUsed( const EffectProperties& rSourceProps )
31 maShadow.assignUsed(rSourceProps.maShadow);
32 if (!rSourceProps.m_Effects.empty())
34 m_Effects.clear();
35 m_Effects.reserve(rSourceProps.m_Effects.size());
36 for (auto const& it : rSourceProps.m_Effects)
38 m_Effects.push_back(std::make_unique<Effect>(*it));
43 void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
44 const GraphicHelper& rGraphicHelper ) const
46 for (auto const& it : m_Effects)
48 if( it->msName == "outerShdw" )
50 sal_Int32 nAttrDir = 0, nAttrDist = 0;
51 std::map< OUString, css::uno::Any >::const_iterator attribIt = it->maAttribs.find( "dir" );
52 if( attribIt != it->maAttribs.end() )
53 attribIt->second >>= nAttrDir;
55 attribIt = it->maAttribs.find( "dist" );
56 if( attribIt != it->maAttribs.end() )
57 attribIt->second >>= nAttrDist;
59 // Negative X or Y dist indicates left or up, respectively
60 double nAngle = basegfx::deg2rad(static_cast<double>(nAttrDir) / PER_DEGREE);
61 sal_Int32 nDist = convertEmuToHmm( nAttrDist );
62 sal_Int32 nXDist = cos(nAngle) * nDist;
63 sal_Int32 nYDist = sin(nAngle) * nDist;
65 rPropMap.setProperty( PROP_Shadow, true );
66 rPropMap.setProperty( PROP_ShadowXDistance, nXDist);
67 rPropMap.setProperty( PROP_ShadowYDistance, nYDist);
68 rPropMap.setProperty( PROP_ShadowColor, it->moColor.getColor(rGraphicHelper ) );
69 rPropMap.setProperty( PROP_ShadowTransparence, it->moColor.getTransparency());
74 css::beans::PropertyValue Effect::getEffect()
76 css::beans::PropertyValue aRet;
77 if( msName.isEmpty() )
78 return aRet;
80 css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() );
81 sal_uInt32 i = 0;
82 for (auto const& attrib : maAttribs)
84 aSeq[i].Name = attrib.first;
85 aSeq[i].Value = attrib.second;
86 i++;
89 aRet.Name = msName;
90 aRet.Value <<= aSeq;
92 return aRet;
95 } // namespace drawingml
96 } // namespace oox
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */