LCOV - code coverage report
Current view: top level - libreoffice/oox/source/drawingml - fillproperties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 86 224 38.4 %
Date: 2012-12-17 Functions: 9 12 75.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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "oox/drawingml/fillproperties.hxx"
      21             : 
      22             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include <com/sun/star/awt/Gradient.hpp>
      25             : #include <com/sun/star/text/GraphicCrop.hpp>
      26             : #include <com/sun/star/awt/Size.hpp>
      27             : #include <com/sun/star/drawing/BitmapMode.hpp>
      28             : #include <com/sun/star/drawing/ColorMode.hpp>
      29             : #include <com/sun/star/drawing/FillStyle.hpp>
      30             : #include <com/sun/star/drawing/RectanglePoint.hpp>
      31             : #include <com/sun/star/graphic/XGraphicTransformer.hpp>
      32             : #include "oox/helper/graphichelper.hxx"
      33             : #include "oox/drawingml/drawingmltypes.hxx"
      34             : #include "oox/drawingml/shapepropertymap.hxx"
      35             : #include "oox/token/tokens.hxx"
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::drawing;
      39             : using namespace ::com::sun::star::graphic;
      40             : 
      41             : using ::com::sun::star::uno::Reference;
      42             : using ::com::sun::star::uno::Exception;
      43             : using ::com::sun::star::uno::UNO_QUERY;
      44             : using ::com::sun::star::uno::UNO_QUERY_THROW;
      45             : using ::com::sun::star::geometry::IntegerRectangle2D;
      46             : 
      47             : namespace oox {
      48             : namespace drawingml {
      49             : 
      50             : // ============================================================================
      51             : 
      52             : namespace {
      53             : 
      54           0 : BitmapMode lclGetBitmapMode( sal_Int32 nToken )
      55             : {
      56             :     OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
      57           0 :     switch( nToken )
      58             :     {
      59           0 :         case XML_tile:      return BitmapMode_REPEAT;
      60           0 :         case XML_stretch:   return BitmapMode_STRETCH;
      61             :     }
      62           0 :     return BitmapMode_NO_REPEAT;
      63             : }
      64             : 
      65           0 : RectanglePoint lclGetRectanglePoint( sal_Int32 nToken )
      66             : {
      67             :     OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
      68           0 :     switch( nToken )
      69             :     {
      70           0 :         case XML_tl:    return RectanglePoint_LEFT_TOP;
      71           0 :         case XML_t:     return RectanglePoint_MIDDLE_TOP;
      72           0 :         case XML_tr:    return RectanglePoint_RIGHT_TOP;
      73           0 :         case XML_l:     return RectanglePoint_LEFT_MIDDLE;
      74           0 :         case XML_ctr:   return RectanglePoint_MIDDLE_MIDDLE;
      75           0 :         case XML_r:     return RectanglePoint_RIGHT_MIDDLE;
      76           0 :         case XML_bl:    return RectanglePoint_LEFT_BOTTOM;
      77           0 :         case XML_b:     return RectanglePoint_MIDDLE_BOTTOM;
      78           0 :         case XML_br:    return RectanglePoint_RIGHT_BOTTOM;
      79             :     }
      80           0 :     return RectanglePoint_LEFT_TOP;
      81             : }
      82             : 
      83           0 : const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const Reference< XGraphic >& rxGraphic )
      84             : {
      85           0 :     awt::Size aSizeHmm( 0, 0 );
      86             :     try
      87             :     {
      88           0 :         Reference< beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
      89           0 :         if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "Size100thMM" ) ) >>= aSizeHmm )
      90             :         {
      91           0 :             if( !aSizeHmm.Width && !aSizeHmm.Height )
      92             :             {   // MAPMODE_PIXEL USED :-(
      93           0 :                 awt::Size aSourceSizePixel( 0, 0 );
      94           0 :                 if( xGraphicPropertySet->getPropertyValue( CREATE_OUSTRING( "SizePixel" ) ) >>= aSourceSizePixel )
      95           0 :                     aSizeHmm = rGraphicHelper.convertScreenPixelToHmm( aSourceSizePixel );
      96             :             }
      97           0 :         }
      98             :     }
      99           0 :     catch( Exception& )
     100             :     {
     101             :     }
     102           0 :     return aSizeHmm;
     103             : }
     104             : 
     105             : } // namespace
     106             : 
     107             : // ============================================================================
     108             : 
     109         190 : void GradientFillProperties::assignUsed( const GradientFillProperties& rSourceProps )
     110             : {
     111         190 :     if( !rSourceProps.maGradientStops.empty() )
     112           0 :         maGradientStops = rSourceProps.maGradientStops;
     113         190 :     moFillToRect.assignIfUsed( rSourceProps.moFillToRect );
     114         190 :     moTileRect.assignIfUsed( rSourceProps.moTileRect );
     115         190 :     moGradientPath.assignIfUsed( rSourceProps.moGradientPath );
     116         190 :     moShadeAngle.assignIfUsed( rSourceProps.moShadeAngle );
     117         190 :     moShadeFlip.assignIfUsed( rSourceProps.moShadeFlip );
     118         190 :     moShadeScaled.assignIfUsed( rSourceProps.moShadeScaled );
     119         190 :     moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
     120         190 : }
     121             : 
     122             : // ============================================================================
     123             : 
     124         190 : void PatternFillProperties::assignUsed( const PatternFillProperties& rSourceProps )
     125             : {
     126         190 :     maPattFgColor.assignIfUsed( rSourceProps.maPattFgColor );
     127         190 :     maPattBgColor.assignIfUsed( rSourceProps.maPattBgColor );
     128         190 :     moPattPreset.assignIfUsed( rSourceProps.moPattPreset );
     129         190 : }
     130             : 
     131             : // ============================================================================
     132             : 
     133         190 : void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps )
     134             : {
     135         190 :     if( rSourceProps.mxGraphic.is() )
     136           0 :         mxGraphic = rSourceProps.mxGraphic;
     137         190 :     moBitmapMode.assignIfUsed( rSourceProps.moBitmapMode );
     138         190 :     moFillRect.assignIfUsed( rSourceProps.moFillRect );
     139         190 :     moTileOffsetX.assignIfUsed( rSourceProps.moTileOffsetX );
     140         190 :     moTileOffsetY.assignIfUsed( rSourceProps.moTileOffsetY );
     141         190 :     moTileScaleX.assignIfUsed( rSourceProps.moTileScaleX );
     142         190 :     moTileScaleY.assignIfUsed( rSourceProps.moTileScaleY );
     143         190 :     moTileAlign.assignIfUsed( rSourceProps.moTileAlign );
     144         190 :     moTileFlip.assignIfUsed( rSourceProps.moTileFlip );
     145         190 :     moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
     146         190 :     moColorEffect.assignIfUsed( rSourceProps.moColorEffect );
     147         190 :     moBrightness.assignIfUsed( rSourceProps.moBrightness );
     148         190 :     moContrast.assignIfUsed( rSourceProps.moContrast );
     149         190 :     maColorChangeFrom.assignIfUsed( rSourceProps.maColorChangeFrom );
     150         190 :     maColorChangeTo.assignIfUsed( rSourceProps.maColorChangeTo );
     151         190 : }
     152             : 
     153             : // ============================================================================
     154             : 
     155         190 : void FillProperties::assignUsed( const FillProperties& rSourceProps )
     156             : {
     157         190 :     moFillType.assignIfUsed( rSourceProps.moFillType );
     158         190 :     maFillColor.assignIfUsed( rSourceProps.maFillColor );
     159         190 :     maGradientProps.assignUsed( rSourceProps.maGradientProps );
     160         190 :     maPatternProps.assignUsed( rSourceProps.maPatternProps );
     161         190 :     maBlipProps.assignUsed( rSourceProps.maBlipProps );
     162         190 : }
     163             : 
     164         122 : Color FillProperties::getBestSolidColor() const
     165             : {
     166         122 :     Color aSolidColor;
     167         122 :     if( moFillType.has() ) switch( moFillType.get() )
     168             :     {
     169             :         case XML_solidFill:
     170          42 :             aSolidColor = maFillColor;
     171          42 :         break;
     172             :         case XML_gradFill:
     173           0 :             if( !maGradientProps.maGradientStops.empty() )
     174           0 :                 aSolidColor = maGradientProps.maGradientStops.begin()->second;
     175           0 :         break;
     176             :         case XML_pattFill:
     177           0 :             aSolidColor = maPatternProps.maPattBgColor.isUsed() ? maPatternProps.maPattBgColor : maPatternProps.maPattFgColor;
     178           0 :         break;
     179             :     }
     180         122 :     return aSolidColor;
     181             : }
     182             : 
     183         128 : void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
     184             :         const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const
     185             : {
     186         128 :     if( moFillType.has() )
     187             :     {
     188         128 :         FillStyle eFillStyle = FillStyle_NONE;
     189             :         OSL_ASSERT((moFillType.get() & sal_Int32(0xFFFF0000))==0);
     190         128 :         switch( moFillType.get() )
     191             :         {
     192             :             case XML_noFill:
     193          98 :                 eFillStyle = FillStyle_NONE;
     194          98 :             break;
     195             : 
     196             :             case XML_solidFill:
     197          30 :                 if( maFillColor.isUsed() )
     198             :                 {
     199          30 :                     rPropMap.setProperty( SHAPEPROP_FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
     200          30 :                     if( maFillColor.hasTransparency() )
     201           0 :                         rPropMap.setProperty( SHAPEPROP_FillTransparency, maFillColor.getTransparency() );
     202          30 :                     eFillStyle = FillStyle_SOLID;
     203             :                 }
     204          30 :             break;
     205             : 
     206             :             case XML_gradFill:
     207             :                 // do not create gradient struct if property is not supported...
     208           0 :                 if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) )
     209             :                 {
     210           0 :                     sal_Int32 nEndTrans     = 0;
     211           0 :                     sal_Int32 nStartTrans   = 0;
     212           0 :                     awt::Gradient aGradient;
     213           0 :                     aGradient.Angle = 900;
     214           0 :                     aGradient.StartIntensity = 100;
     215           0 :                     aGradient.EndIntensity = 100;
     216             : 
     217           0 :                     size_t nColorCount = maGradientProps.maGradientStops.size();
     218           0 :                     if( nColorCount > 1 )
     219             :                     {
     220           0 :                         aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr );
     221           0 :                         aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr );
     222           0 :                         if( maGradientProps.maGradientStops.rbegin()->second.hasTransparency() )
     223           0 :                             nEndTrans = maGradientProps.maGradientStops.rbegin()->second.getTransparency()*255/100;
     224           0 :                         if( maGradientProps.maGradientStops.begin()->second.hasTransparency() )
     225           0 :                             nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
     226             :                     }
     227             : 
     228             :                     // "rotate with shape" not set, or set to false -> do not rotate
     229           0 :                     if ( !maGradientProps.moRotateWithShape.get( false ) )
     230           0 :                         nShapeRotation = 0;
     231             : 
     232           0 :                     sal_Int32 nDmlAngle = 0;
     233           0 :                     if( maGradientProps.moGradientPath.has() )
     234             :                     {
     235           0 :                         aGradient.Style = (maGradientProps.moGradientPath.get() == XML_circle) ? awt::GradientStyle_ELLIPTICAL : awt::GradientStyle_RECT;
     236             :                         // position of gradient center (limited to [30%;70%], otherwise gradient is too hidden)
     237           0 :                         IntegerRectangle2D aFillToRect = maGradientProps.moFillToRect.get( IntegerRectangle2D( 0, 0, MAX_PERCENT, MAX_PERCENT ) );
     238           0 :                         sal_Int32 nCenterX = (MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
     239           0 :                         aGradient.XOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterX / PER_PERCENT, 30, 70 );
     240           0 :                         sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
     241           0 :                         aGradient.YOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterY / PER_PERCENT, 30, 70 );
     242           0 :                         ::std::swap( aGradient.StartColor, aGradient.EndColor );
     243           0 :                         ::std::swap( nStartTrans, nEndTrans );
     244           0 :                         nDmlAngle = nShapeRotation;
     245             :                     }
     246             :                     else
     247             :                     {
     248             :                         /*  Try to detect a VML axial gradient. This type of
     249             :                             gradient is simulated by a 3-point linear gradient.
     250             :                             Even if its a multi-color linear gradient, its probably better to assume
     251             :                             axial gradient, when there are 3 or more points.
     252             :                          */
     253           0 :                         bool bAxial = (nColorCount >= 3);
     254           0 :                         aGradient.Style = bAxial ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
     255           0 :                         nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) - nShapeRotation;
     256             :                         // convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
     257           0 :                         aGradient.Angle = static_cast< sal_Int16 >( (4500 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
     258           0 :                         if( bAxial )
     259             :                         {
     260           0 :                             GradientFillProperties::GradientStopMap::const_iterator aIt = maGradientProps.maGradientStops.begin();
     261             :                             // Try to find the axial median
     262           0 :                             for(size_t i=0;i<nColorCount;i+=3)
     263           0 :                                 ++aIt;
     264             :                             // API StartColor is inner color in axial gradient
     265             :                             // aIt->second.hasColor() kind would be better than Color != API_RGB_WHITE
     266           0 :                             if( aGradient.StartColor == aGradient.EndColor &&
     267           0 :                                 ( !aIt->second.hasTransparency() || aIt->second.getColor( rGraphicHelper, nPhClr ) != API_RGB_WHITE ) )
     268             :                             {
     269           0 :                                 aGradient.StartColor = aIt->second.getColor( rGraphicHelper, nPhClr );
     270             :                             }
     271             : 
     272           0 :                             if( nStartTrans == nEndTrans && aIt->second.hasTransparency() )
     273           0 :                                 nStartTrans = aIt->second.getTransparency()*255/100;
     274             :                         }
     275             :                     }
     276             : 
     277             :                     // push gradient or named gradient to property map
     278           0 :                     if( rPropMap.setProperty( SHAPEPROP_FillGradient, aGradient ) )
     279           0 :                         eFillStyle = FillStyle_GRADIENT;
     280             : 
     281             :                     // push gradient transparency to property map
     282           0 :                     if( nStartTrans != 0 || nEndTrans != 0 )
     283             :                     {
     284           0 :                         awt::Gradient aGrad(aGradient);
     285           0 :                         uno::Any aVal;
     286           0 :                         aGrad.EndColor = (sal_Int32)( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
     287           0 :                         aGrad.StartColor = (sal_Int32)( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
     288           0 :                         aVal <<= aGrad;
     289           0 :                         rPropMap.setProperty( SHAPEPROP_GradientTransparency, aGrad );
     290             :                     }
     291             : 
     292             :                 }
     293           0 :             break;
     294             : 
     295             :             case XML_blipFill:
     296             :                 // do not start complex graphic transformation if property is not supported...
     297           0 :                 if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapUrl ) )
     298             :                 {
     299             :                     // TODO: "rotate with shape" is not possible with our current core
     300             : 
     301           0 :                     OUString aGraphicUrl = rGraphicHelper.createGraphicObject( maBlipProps.mxGraphic );
     302             :                     // push bitmap or named bitmap to property map
     303           0 :                     if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( SHAPEPROP_FillBitmapUrl, aGraphicUrl ) )
     304           0 :                         eFillStyle = FillStyle_BITMAP;
     305             : 
     306             :                     // set other bitmap properties, if bitmap has been inserted into the map
     307           0 :                     if( eFillStyle == FillStyle_BITMAP )
     308             :                     {
     309             :                         // bitmap mode (single, repeat, stretch)
     310           0 :                         BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) );
     311           0 :                         rPropMap.setProperty( SHAPEPROP_FillBitmapMode, eBitmapMode );
     312             : 
     313             :                         // additional settings for repeated bitmap
     314           0 :                         if( eBitmapMode == BitmapMode_REPEAT )
     315             :                         {
     316             :                             // anchor position inside bitmap
     317           0 :                             RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) );
     318           0 :                             rPropMap.setProperty( SHAPEPROP_FillBitmapRectanglePoint, eRectPoint );
     319             : 
     320           0 :                             awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic );
     321           0 :                             if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) )
     322             :                             {
     323             :                                 // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm
     324           0 :                                 double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
     325           0 :                                 sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 );
     326           0 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapSizeX, nFillBmpSizeX );
     327           0 :                                 double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
     328           0 :                                 sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
     329           0 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapSizeY, nFillBmpSizeY );
     330             : 
     331             :                                 // offset of the first bitmap tile (given as EMUs), convert to percent
     332           0 :                                 sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 );
     333           0 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetX, nTileOffsetX );
     334           0 :                                 sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
     335           0 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetY, nTileOffsetY );
     336             :                             }
     337             :                         }
     338           0 :                     }
     339             :                 }
     340           0 :             break;
     341             : 
     342             :             case XML_pattFill:
     343             :             {
     344             :                 // todo
     345           0 :                 Color aColor = getBestSolidColor();
     346           0 :                 if( aColor.isUsed() )
     347             :                 {
     348           0 :                     rPropMap.setProperty( SHAPEPROP_FillColor, aColor.getColor( rGraphicHelper, nPhClr ) );
     349           0 :                     if( aColor.hasTransparency() )
     350           0 :                         rPropMap.setProperty( SHAPEPROP_FillTransparency, aColor.getTransparency() );
     351           0 :                     eFillStyle = FillStyle_SOLID;
     352           0 :                 }
     353             :             }
     354           0 :             break;
     355             : 
     356             :             case XML_grpFill:
     357             :                 // todo
     358           0 :                 eFillStyle = FillStyle_NONE;
     359           0 :             break;
     360             :         }
     361             : 
     362             :         // set final fill style property
     363         128 :         rPropMap.setProperty( SHAPEPROP_FillStyle, eFillStyle );
     364             :     }
     365         128 : }
     366             : 
     367             : // ============================================================================
     368             : 
     369          28 : void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const
     370             : {
     371          28 :     if( maBlipProps.mxGraphic.is() )
     372             :     {
     373             :         // created transformed graphic
     374          28 :         Reference< XGraphic > xGraphic = maBlipProps.mxGraphic;
     375          28 :         if( maBlipProps.maColorChangeFrom.isUsed() && maBlipProps.maColorChangeTo.isUsed() )
     376             :         {
     377           0 :             sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr );
     378           0 :             sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr );
     379           0 :             if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparency() ) try
     380             :             {
     381           0 :                 sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparency();
     382           0 :                 sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) / 39.062 );   // ?!? correct ?!?
     383           0 :                 Reference< XGraphicTransformer > xTransformer( maBlipProps.mxGraphic, UNO_QUERY_THROW );
     384           0 :                 xGraphic = xTransformer->colorChange( maBlipProps.mxGraphic, nFromColor, 9, nToColor, nToAlpha );
     385             :             }
     386           0 :             catch( Exception& )
     387             :             {
     388             :             }
     389             :         }
     390             : 
     391          28 :         OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
     392          28 :         if( !aGraphicUrl.isEmpty() )
     393          28 :             rPropMap[ PROP_GraphicURL ] <<= aGraphicUrl;
     394             : 
     395             :         // cropping
     396          28 :         if ( maBlipProps.moClipRect.has() )
     397             :         {
     398          10 :             geometry::IntegerRectangle2D oClipRect( maBlipProps.moClipRect.get() );
     399          10 :             awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
     400          10 :             if ( aOriginalSize.Width && aOriginalSize.Height )
     401             :             {
     402          10 :                 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
     403          10 :                 if ( oClipRect.X1 )
     404           0 :                     aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 );
     405          10 :                 if ( oClipRect.Y1 )
     406           0 :                     aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 );
     407          10 :                 if ( oClipRect.X2 )
     408           0 :                     aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 );
     409          10 :                 if ( oClipRect.Y2 )
     410           0 :                     aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 );
     411          10 :                 rPropMap[ PROP_GraphicCrop ] <<= aGraphCrop;
     412             :             }
     413          28 :         }
     414             :     }
     415             : 
     416             :     // color effect
     417          28 :     ColorMode eColorMode = ColorMode_STANDARD;
     418          28 :     switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
     419             :     {
     420           0 :         case XML_biLevel:   eColorMode = ColorMode_MONO;    break;
     421           0 :         case XML_grayscl:   eColorMode = ColorMode_GREYS;   break;
     422             :     }
     423          28 :     rPropMap[ PROP_GraphicColorMode ] <<= eColorMode;
     424             : 
     425             :     // brightness and contrast
     426          28 :     sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
     427          28 :     if( nBrightness != 0 )
     428           0 :         rPropMap[ PROP_AdjustLuminance ] <<= nBrightness;
     429          28 :     sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
     430          28 :     if( nContrast != 0 )
     431           0 :         rPropMap[ PROP_AdjustContrast ] <<= nContrast;
     432             : 
     433             :     // Media content
     434          28 :     if( !maAudio.msEmbed.isEmpty() )
     435           0 :         rPropMap[ PROP_MediaURL ] <<= maAudio.msEmbed;
     436          28 : }
     437             : 
     438             : // ============================================================================
     439             : 
     440             : } // namespace drawingml
     441         174 : } // namespace oox
     442             : 
     443             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10