LCOV - code coverage report
Current view: top level - oox/source/drawingml - effectproperties.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 43 44 97.7 %
Date: 2014-11-03 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10