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 "effectproperties.hxx"
11 : #include "oox/drawingml/drawingmltypes.hxx"
12 : #include "oox/drawingml/shapepropertymap.hxx"
13 : #include "oox/helper/graphichelper.hxx"
14 : #include "oox/token/tokens.hxx"
15 :
16 : #include <basegfx/numeric/ftools.hxx>
17 :
18 : namespace oox {
19 : namespace drawingml {
20 :
21 6299 : void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourceProps)
22 : {
23 6299 : moShadowDist.assignIfUsed( rSourceProps.moShadowDist );
24 6299 : moShadowDir.assignIfUsed( rSourceProps.moShadowDir );
25 6299 : moShadowColor.assignIfUsed( rSourceProps.moShadowColor );
26 6299 : }
27 :
28 6299 : void EffectProperties::assignUsed( const EffectProperties& rSourceProps )
29 : {
30 6299 : maShadow.assignUsed(rSourceProps.maShadow);
31 6299 : if( rSourceProps.maEffects.size() > 0 )
32 279 : maEffects = rSourceProps.maEffects;
33 6299 : }
34 :
35 3107 : void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
36 : const GraphicHelper& rGraphicHelper ) const
37 : {
38 3346 : for( boost::ptr_vector< Effect >::const_iterator it = maEffects.begin(); it != maEffects.end(); ++it )
39 239 : if( it->msName == "outerShdw" )
40 : {
41 177 : sal_Int32 nAttrDir = 0, nAttrDist = 0;
42 177 : std::map< OUString, css::uno::Any >::const_iterator attribIt = it->maAttribs.find( "dir" );
43 177 : if( attribIt != it->maAttribs.end() )
44 139 : attribIt->second >>= nAttrDir;
45 :
46 177 : attribIt = it->maAttribs.find( "dist" );
47 177 : if( attribIt != it->maAttribs.end() )
48 177 : attribIt->second >>= nAttrDist;
49 :
50 : // Negative X or Y dist indicates left or up, respectively
51 177 : double nAngle = ( static_cast<double>(nAttrDir) / PER_DEGREE ) * F_PI180;
52 177 : sal_Int32 nDist = convertEmuToHmm( nAttrDist );
53 177 : sal_Int32 nXDist = cos(nAngle) * nDist;
54 177 : sal_Int32 nYDist = sin(nAngle) * nDist;
55 :
56 177 : rPropMap.setProperty( PROP_Shadow, true );
57 177 : rPropMap.setProperty( PROP_ShadowXDistance, nXDist);
58 177 : rPropMap.setProperty( PROP_ShadowYDistance, nYDist);
59 177 : rPropMap.setProperty( PROP_ShadowColor, it->moColor.getColor(rGraphicHelper, -1 ) );
60 177 : rPropMap.setProperty( PROP_ShadowTransparence, it->moColor.getTransparency());
61 : }
62 3107 : }
63 :
64 239 : css::beans::PropertyValue Effect::getEffect()
65 : {
66 239 : css::beans::PropertyValue pRet;
67 239 : if( msName.isEmpty() )
68 0 : return pRet;
69 :
70 478 : css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() );
71 239 : sal_uInt32 i = 0;
72 1170 : for( std::map< OUString, css::uno::Any >::iterator it = maAttribs.begin(); it != maAttribs.end(); ++it )
73 : {
74 931 : aSeq[i].Name = it->first;
75 931 : aSeq[i].Value = it->second;
76 931 : i++;
77 : }
78 :
79 239 : pRet.Name = msName;
80 239 : pRet.Value = css::uno::Any( aSeq );
81 :
82 239 : return pRet;
83 : }
84 :
85 : } // namespace drawingml
86 246 : } // namespace oox
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|