LCOV - code coverage report
Current view: top level - oox/source/drawingml - fillproperties.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 450 581 77.5 %
Date: 2015-06-13 12:38:46 Functions: 21 21 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             :  * 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 <iterator>
      21             : #include <boost/utility.hpp>
      22             : 
      23             : #include <oox/drawingml/fillproperties.hxx>
      24             : #include <drawingml/graphicproperties.hxx>
      25             : 
      26             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/awt/Gradient.hpp>
      29             : #include <com/sun/star/text/GraphicCrop.hpp>
      30             : #include <com/sun/star/awt/Size.hpp>
      31             : #include <com/sun/star/drawing/BitmapMode.hpp>
      32             : #include <com/sun/star/drawing/ColorMode.hpp>
      33             : #include <com/sun/star/drawing/FillStyle.hpp>
      34             : #include <com/sun/star/drawing/Hatch.hpp>
      35             : #include <com/sun/star/drawing/RectanglePoint.hpp>
      36             : #include <com/sun/star/graphic/XGraphicTransformer.hpp>
      37             : #include <oox/core/fragmenthandler.hxx>
      38             : #include "oox/helper/graphichelper.hxx"
      39             : #include "oox/drawingml/drawingmltypes.hxx"
      40             : #include "oox/drawingml/shapepropertymap.hxx"
      41             : #include "oox/token/tokens.hxx"
      42             : #include <rtl/math.hxx>
      43             : #include <osl/diagnose.h>
      44             : 
      45             : using namespace ::com::sun::star;
      46             : using namespace ::com::sun::star::drawing;
      47             : using namespace ::com::sun::star::graphic;
      48             : 
      49             : using ::com::sun::star::uno::Reference;
      50             : using ::com::sun::star::uno::Exception;
      51             : using ::com::sun::star::uno::UNO_QUERY;
      52             : using ::com::sun::star::uno::UNO_QUERY_THROW;
      53             : using ::com::sun::star::geometry::IntegerRectangle2D;
      54             : 
      55             : namespace oox {
      56             : namespace drawingml {
      57             : 
      58             : namespace {
      59             : 
      60         365 : Reference< XGraphic > lclCheckAndApplyDuotoneTransform( const BlipFillProperties& aBlipProps, Reference< XGraphic > xGraphic,
      61             :                                                         const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
      62             : {
      63         365 :     if( aBlipProps.maDuotoneColors[0].isUsed() && aBlipProps.maDuotoneColors[1].isUsed() )
      64             :     {
      65           1 :         sal_Int32 nColor1 = aBlipProps.maDuotoneColors[0].getColor( rGraphicHelper, nPhClr );
      66           1 :         sal_Int32 nColor2 = aBlipProps.maDuotoneColors[1].getColor( rGraphicHelper, nPhClr );
      67             :         try
      68             :         {
      69           1 :             Reference< XGraphicTransformer > xTransformer( aBlipProps.mxGraphic, UNO_QUERY_THROW );
      70           1 :             xGraphic = xTransformer->applyDuotone( xGraphic, nColor1, nColor2 );
      71             :         }
      72           0 :         catch( Exception& )
      73             :         {
      74             :         }
      75             :     }
      76         365 :     return xGraphic;
      77             : }
      78             : 
      79         306 : Reference< XGraphic > lclCheckAndApplyChangeColorTransform( const BlipFillProperties &aBlipProps, Reference< XGraphic > xGraphic,
      80             :                                                             const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
      81             : {
      82         306 :     if( aBlipProps.maColorChangeFrom.isUsed() && aBlipProps.maColorChangeTo.isUsed() )
      83             :     {
      84           0 :         sal_Int32 nFromColor = aBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr );
      85           0 :         sal_Int32 nToColor = aBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr );
      86           0 :         if ( (nFromColor != nToColor) || aBlipProps.maColorChangeTo.hasTransparency() ) try
      87             :         {
      88           0 :             sal_Int16 nToTransparence = aBlipProps.maColorChangeTo.getTransparency();
      89           0 :             sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) * 2.55 );
      90           0 :             Reference< XGraphicTransformer > xTransformer( aBlipProps.mxGraphic, UNO_QUERY_THROW );
      91           0 :             xGraphic = xTransformer->colorChange( xGraphic, nFromColor, 9, nToColor, nToAlpha );
      92             :         }
      93           0 :         catch( Exception& )
      94             :         {
      95             :         }
      96             :     }
      97         306 :     return xGraphic;
      98             : }
      99             : 
     100           3 : Reference< XGraphic > applyBrightnessContrast( Reference< XGraphic > xGraphic, sal_Int32 brightness, sal_Int32 contrast )
     101             : {
     102             :     try
     103             :         {
     104           3 :             Reference< XGraphicTransformer > xTransformer( xGraphic, UNO_QUERY_THROW );
     105           3 :             xGraphic = xTransformer->applyBrightnessContrast( xGraphic, brightness, contrast, true );
     106             :         }
     107           0 :         catch( Exception& )
     108             :         {
     109             :         }
     110           3 :     return xGraphic;
     111             : }
     112             : 
     113          59 : BitmapMode lclGetBitmapMode( sal_Int32 nToken )
     114             : {
     115             :     OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
     116          59 :     switch( nToken )
     117             :     {
     118           4 :         case XML_tile:      return BitmapMode_REPEAT;
     119          55 :         case XML_stretch:   return BitmapMode_STRETCH;
     120             :     }
     121           0 :     return BitmapMode_NO_REPEAT;
     122             : }
     123             : 
     124           4 : RectanglePoint lclGetRectanglePoint( sal_Int32 nToken )
     125             : {
     126             :     OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
     127           4 :     switch( nToken )
     128             :     {
     129           4 :         case XML_tl:    return RectanglePoint_LEFT_TOP;
     130           0 :         case XML_t:     return RectanglePoint_MIDDLE_TOP;
     131           0 :         case XML_tr:    return RectanglePoint_RIGHT_TOP;
     132           0 :         case XML_l:     return RectanglePoint_LEFT_MIDDLE;
     133           0 :         case XML_ctr:   return RectanglePoint_MIDDLE_MIDDLE;
     134           0 :         case XML_r:     return RectanglePoint_RIGHT_MIDDLE;
     135           0 :         case XML_bl:    return RectanglePoint_LEFT_BOTTOM;
     136           0 :         case XML_b:     return RectanglePoint_MIDDLE_BOTTOM;
     137           0 :         case XML_br:    return RectanglePoint_RIGHT_BOTTOM;
     138             :     }
     139           0 :     return RectanglePoint_LEFT_TOP;
     140             : }
     141             : 
     142           4 : const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const Reference< XGraphic >& rxGraphic )
     143             : {
     144           4 :     awt::Size aSizeHmm( 0, 0 );
     145             :     try
     146             :     {
     147           4 :         Reference< beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
     148           4 :         if( xGraphicPropertySet->getPropertyValue( "Size100thMM" ) >>= aSizeHmm )
     149             :         {
     150           4 :             if( !aSizeHmm.Width && !aSizeHmm.Height )
     151             :             {   // MAPMODE_PIXEL USED :-(
     152           1 :                 awt::Size aSourceSizePixel( 0, 0 );
     153           1 :                 if( xGraphicPropertySet->getPropertyValue( "SizePixel" ) >>= aSourceSizePixel )
     154           1 :                     aSizeHmm = rGraphicHelper.convertScreenPixelToHmm( aSourceSizePixel );
     155             :             }
     156           4 :         }
     157             :     }
     158           0 :     catch( Exception& )
     159             :     {
     160             :     }
     161           4 :     return aSizeHmm;
     162             : }
     163             : 
     164             : } // namespace
     165             : 
     166       97386 : void GradientFillProperties::assignUsed( const GradientFillProperties& rSourceProps )
     167             : {
     168       97386 :     if( !rSourceProps.maGradientStops.empty() )
     169         218 :         maGradientStops = rSourceProps.maGradientStops;
     170       97386 :     moFillToRect.assignIfUsed( rSourceProps.moFillToRect );
     171       97386 :     moTileRect.assignIfUsed( rSourceProps.moTileRect );
     172       97386 :     moGradientPath.assignIfUsed( rSourceProps.moGradientPath );
     173       97386 :     moShadeAngle.assignIfUsed( rSourceProps.moShadeAngle );
     174       97386 :     moShadeFlip.assignIfUsed( rSourceProps.moShadeFlip );
     175       97386 :     moShadeScaled.assignIfUsed( rSourceProps.moShadeScaled );
     176       97386 :     moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
     177       97386 : }
     178             : 
     179       18218 : void PatternFillProperties::assignUsed( const PatternFillProperties& rSourceProps )
     180             : {
     181       18218 :     maPattFgColor.assignIfUsed( rSourceProps.maPattFgColor );
     182       18218 :     maPattBgColor.assignIfUsed( rSourceProps.maPattBgColor );
     183       18218 :     moPattPreset.assignIfUsed( rSourceProps.moPattPreset );
     184       18218 : }
     185             : 
     186       18218 : void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps )
     187             : {
     188       18218 :     if( rSourceProps.mxGraphic.is() )
     189          54 :         mxGraphic = rSourceProps.mxGraphic;
     190       18218 :     moBitmapMode.assignIfUsed( rSourceProps.moBitmapMode );
     191       18218 :     moFillRect.assignIfUsed( rSourceProps.moFillRect );
     192       18218 :     moTileOffsetX.assignIfUsed( rSourceProps.moTileOffsetX );
     193       18218 :     moTileOffsetY.assignIfUsed( rSourceProps.moTileOffsetY );
     194       18218 :     moTileScaleX.assignIfUsed( rSourceProps.moTileScaleX );
     195       18218 :     moTileScaleY.assignIfUsed( rSourceProps.moTileScaleY );
     196       18218 :     moTileAlign.assignIfUsed( rSourceProps.moTileAlign );
     197       18218 :     moTileFlip.assignIfUsed( rSourceProps.moTileFlip );
     198       18218 :     moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
     199       18218 :     moColorEffect.assignIfUsed( rSourceProps.moColorEffect );
     200       18218 :     moBrightness.assignIfUsed( rSourceProps.moBrightness );
     201       18218 :     moContrast.assignIfUsed( rSourceProps.moContrast );
     202       18218 :     maColorChangeFrom.assignIfUsed( rSourceProps.maColorChangeFrom );
     203       18218 :     maColorChangeTo.assignIfUsed( rSourceProps.maColorChangeTo );
     204       18218 :     maDuotoneColors[0].assignIfUsed( rSourceProps.maDuotoneColors[0] );
     205       18218 :     maDuotoneColors[1].assignIfUsed( rSourceProps.maDuotoneColors[1] );
     206       18218 :     maEffect.assignUsed( rSourceProps.maEffect );
     207       18218 : }
     208             : 
     209       18218 : void FillProperties::assignUsed( const FillProperties& rSourceProps )
     210             : {
     211       18218 :     moFillType.assignIfUsed( rSourceProps.moFillType );
     212       18218 :     maFillColor.assignIfUsed( rSourceProps.maFillColor );
     213       18218 :     maGradientProps.assignUsed( rSourceProps.maGradientProps );
     214       18218 :     maPatternProps.assignUsed( rSourceProps.maPatternProps );
     215       18218 :     maBlipProps.assignUsed( rSourceProps.maBlipProps );
     216       18218 : }
     217             : 
     218        5889 : Color FillProperties::getBestSolidColor() const
     219             : {
     220        5889 :     Color aSolidColor;
     221        5889 :     if( moFillType.has() ) switch( moFillType.get() )
     222             :     {
     223             :         case XML_solidFill:
     224        2886 :             aSolidColor = maFillColor;
     225        2886 :         break;
     226             :         case XML_gradFill:
     227          24 :             if( !maGradientProps.maGradientStops.empty() )
     228             :             {
     229             :                 GradientFillProperties::GradientStopMap::const_iterator aGradientStop =
     230          24 :                     maGradientProps.maGradientStops.begin();
     231          24 :                 if (maGradientProps.maGradientStops.size() > 2)
     232          24 :                     ++aGradientStop;
     233          24 :                 aSolidColor = aGradientStop->second;
     234             :             }
     235          24 :         break;
     236             :         case XML_pattFill:
     237           0 :             aSolidColor = maPatternProps.maPattBgColor.isUsed() ? maPatternProps.maPattBgColor : maPatternProps.maPattFgColor;
     238           0 :         break;
     239             :     }
     240        5889 :     return aSolidColor;
     241             : }
     242             : 
     243             : /// Maps the hatch token to drawing::Hatch.
     244          96 : static drawing::Hatch createHatch( sal_Int32 nHatchToken, sal_Int32 nColor )
     245             : {
     246          96 :     drawing::Hatch aHatch;
     247          96 :     aHatch.Color = nColor;
     248             : 
     249             :     // best-effort mapping; we do not support all the styles in core
     250          96 :     switch ( nHatchToken )
     251             :     {
     252           2 :         case XML_pct5:       aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 250; aHatch.Angle = 450;  break;
     253           1 :         case XML_pct10:      aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 450;  break;
     254           1 :         case XML_pct20:      aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 450;  break;
     255           1 :         case XML_pct25:      aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 200; aHatch.Angle = 450;  break;
     256           3 :         case XML_pct30:      aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 175; aHatch.Angle = 450;  break;
     257           1 :         case XML_pct40:      aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 150; aHatch.Angle = 450;  break;
     258           1 :         case XML_pct50:      aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 125; aHatch.Angle = 450;  break;
     259           1 :         case XML_pct60:      aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 150; aHatch.Angle = 450;  break;
     260           1 :         case XML_pct70:      aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 125; aHatch.Angle = 450;  break;
     261           1 :         case XML_pct75:      aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 100; aHatch.Angle = 450;  break;
     262           1 :         case XML_pct80:      aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 75;  aHatch.Angle = 450;  break;
     263           1 :         case XML_pct90:      aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 50;  aHatch.Angle = 450;  break;
     264           3 :         case XML_horz:       aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 0;    break;
     265           3 :         case XML_vert:       aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 900;  break;
     266           4 :         case XML_ltHorz:     aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 0;    break;
     267           9 :         case XML_ltVert:     aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 900;  break;
     268           1 :         case XML_dkHorz:     aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 25;  aHatch.Angle = 0;    break;
     269           4 :         case XML_dkVert:     aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 25;  aHatch.Angle = 900;  break;
     270           1 :         case XML_narHorz:    aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 0;    break;
     271           2 :         case XML_narVert:    aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 900;  break;
     272           1 :         case XML_dashHorz:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 0;    break;
     273           1 :         case XML_dashVert:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 900;  break;
     274           0 :         case XML_cross:      aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 0;    break;
     275           0 :         case XML_dnDiag:     aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 1350; break;
     276           0 :         case XML_upDiag:     aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 450;  break;
     277           4 :         case XML_ltDnDiag:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 1350; break;
     278           4 :         case XML_ltUpDiag:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 450;  break;
     279           1 :         case XML_dkDnDiag:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 1350; break;
     280           1 :         case XML_dkUpDiag:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50;  aHatch.Angle = 450;  break;
     281           4 :         case XML_wdDnDiag:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 1350; break;
     282           4 :         case XML_wdUpDiag:   aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 450;  break;
     283           1 :         case XML_dashDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 1350; break;
     284           1 :         case XML_dashUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 450;  break;
     285           0 :         case XML_diagCross:  aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450;  break;
     286           4 :         case XML_smCheck:    aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 50;  aHatch.Angle = 450;  break;
     287           1 :         case XML_lgCheck:    aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450;  break;
     288           4 :         case XML_smGrid:     aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 50;  aHatch.Angle = 0;    break;
     289           4 :         case XML_lgGrid:     aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 0;    break;
     290           1 :         case XML_dotGrid:    aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 400; aHatch.Angle = 0;    break;
     291           1 :         case XML_smConfetti: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 600;  break;
     292           1 :         case XML_lgConfetti: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 600;  break;
     293           1 :         case XML_horzBrick:  aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 0;    break;
     294           1 :         case XML_diagBrick:  aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 450;  break;
     295           1 :         case XML_solidDmnd:  aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450;  break;
     296           4 :         case XML_openDmnd:   aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450;  break;
     297           1 :         case XML_dotDmnd:    aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 450;  break;
     298           1 :         case XML_plaid:      aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 200; aHatch.Angle = 900;  break;
     299           1 :         case XML_sphere:     aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 100; aHatch.Angle = 0;    break;
     300           1 :         case XML_weave:      aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 150; aHatch.Angle = 450;  break;
     301           1 :         case XML_divot:      aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 400; aHatch.Angle = 450;  break;
     302           1 :         case XML_shingle:    aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 1350; break;
     303           1 :         case XML_wave:       aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 0;    break;
     304           1 :         case XML_trellis:    aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 75;  aHatch.Angle = 450;  break;
     305           1 :         case XML_zigZag:     aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 75;  aHatch.Angle = 0;    break;
     306             :     }
     307             : 
     308          96 :     return aHatch;
     309             : }
     310             : 
     311        5215 : void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
     312             :         const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, sal_Int32 nPhClr,
     313             :         bool bFlipH, bool bFlipV ) const
     314             : {
     315        5215 :     if( moFillType.has() )
     316             :     {
     317        5133 :         FillStyle eFillStyle = FillStyle_NONE;
     318             :         OSL_ASSERT((moFillType.get() & sal_Int32(0xFFFF0000))==0);
     319        5133 :         switch( moFillType.get() )
     320             :         {
     321             :             case XML_noFill:
     322        2301 :                 eFillStyle = FillStyle_NONE;
     323        2301 :             break;
     324             : 
     325             :             case XML_solidFill:
     326        2498 :                 if( maFillColor.isUsed() )
     327             :                 {
     328        2498 :                     rPropMap.setProperty( SHAPEPROP_FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
     329        2498 :                     if( maFillColor.hasTransparency() )
     330         137 :                         rPropMap.setProperty( SHAPEPROP_FillTransparency, maFillColor.getTransparency() );
     331        2498 :                     eFillStyle = FillStyle_SOLID;
     332             :                 }
     333        2498 :             break;
     334             : 
     335             :             case XML_gradFill:
     336             :                 // do not create gradient struct if property is not supported...
     337         179 :                 if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) )
     338             :                 {
     339         179 :                     sal_Int32 nEndTrans     = 0;
     340         179 :                     sal_Int32 nStartTrans   = 0;
     341         179 :                     awt::Gradient aGradient;
     342         179 :                     aGradient.Angle = 900;
     343         179 :                     aGradient.StartIntensity = 100;
     344         179 :                     aGradient.EndIntensity = 100;
     345             : 
     346             :                     // Old code, values in aGradient overwritten in many cases by newer code below
     347         179 :                     if( maGradientProps.maGradientStops.size() > 1 )
     348             :                     {
     349         179 :                         aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr );
     350         179 :                         aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr );
     351         179 :                         if( maGradientProps.maGradientStops.rbegin()->second.hasTransparency() )
     352           1 :                             nEndTrans = maGradientProps.maGradientStops.rbegin()->second.getTransparency()*255/100;
     353         179 :                         if( maGradientProps.maGradientStops.begin()->second.hasTransparency() )
     354          26 :                             nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
     355             :                     }
     356             : 
     357             :                     // Adjust for flips
     358         179 :                     if ( bFlipH )
     359           1 :                         nShapeRotation = 180*60000 - nShapeRotation;
     360         179 :                     if ( bFlipV )
     361           0 :                         nShapeRotation = -nShapeRotation;
     362             : 
     363             :                     // "rotate with shape" not set, or set to false -> do not rotate
     364         179 :                     if ( !maGradientProps.moRotateWithShape.get( false ) )
     365         139 :                         nShapeRotation = 0;
     366             : 
     367         179 :                     sal_Int32 nDmlAngle = 0;
     368         179 :                     if( maGradientProps.moGradientPath.has() )
     369             :                     {
     370           7 :                         aGradient.Style = (maGradientProps.moGradientPath.get() == XML_circle) ? awt::GradientStyle_ELLIPTICAL : awt::GradientStyle_RECT;
     371             :                         // position of gradient center (limited to [30%;70%], otherwise gradient is too hidden)
     372           7 :                         IntegerRectangle2D aFillToRect = maGradientProps.moFillToRect.get( IntegerRectangle2D( 0, 0, MAX_PERCENT, MAX_PERCENT ) );
     373           7 :                         sal_Int32 nCenterX = (MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
     374           7 :                         aGradient.XOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterX / PER_PERCENT, 30, 70 );
     375           7 :                         sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
     376           7 :                         aGradient.YOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterY / PER_PERCENT, 30, 70 );
     377           7 :                         ::std::swap( aGradient.StartColor, aGradient.EndColor );
     378           7 :                         ::std::swap( nStartTrans, nEndTrans );
     379           7 :                         nDmlAngle = nShapeRotation;
     380             :                     }
     381             :                     else
     382             :                     {
     383             :                         // A copy of the gradient stops for local modification
     384         172 :                         GradientFillProperties::GradientStopMap aGradientStops(maGradientProps.maGradientStops);
     385             : 
     386             :                         // Add a fake gradient stop at 0% and 100% if necessary, so that the gradient always starts
     387             :                         // at 0% and ends at 100%, to make following logic clearer (?).
     388         172 :                         if( aGradientStops.find(0.0) == aGradientStops.end() )
     389             :                         {
     390             :                             // temp variable required
     391           0 :                             Color aFirstColor(aGradientStops.begin()->second);
     392           0 :                             aGradientStops[0.0] = aFirstColor;
     393             :                         }
     394             : 
     395         172 :                         if( aGradientStops.find(1.0) == aGradientStops.end() )
     396             :                         {
     397             :                             // ditto
     398           0 :                             Color aLastColor(aGradientStops.rbegin()->second);
     399           0 :                             aGradientStops[1.0] = aLastColor;
     400             :                         }
     401             : 
     402             :                         // Check if the gradient is symmetric, which we will emulate with an "axial" gradient.
     403         172 :                         bool bSymmetric(true);
     404             :                         {
     405         172 :                             GradientFillProperties::GradientStopMap::const_iterator aItA( aGradientStops.begin() );
     406         172 :                             GradientFillProperties::GradientStopMap::const_iterator aItZ( boost::prior( aGradientStops.end() ) );
     407         516 :                             while( bSymmetric && aItA->first < aItZ->first )
     408             :                             {
     409         244 :                                 if( aItA->second.getColor( rGraphicHelper, nPhClr ) != aItZ->second.getColor( rGraphicHelper, nPhClr ) ||
     410          72 :                                     aItA->second.getTransparency() != aItZ->second.getTransparency() )
     411         102 :                                     bSymmetric = false;
     412             :                                 else
     413             :                                 {
     414          70 :                                     ++aItA;
     415          70 :                                     aItZ = boost::prior(aItZ);
     416             :                                 }
     417             :                             }
     418             :                             // Don't be fooled if the middlemost stop isn't at 0.5.
     419         172 :                             if( bSymmetric && aItA == aItZ && aItA->first != 0.5 )
     420          51 :                                 bSymmetric = false;
     421             : 
     422             :                             // If symmetric, do the rest of the logic for just a half.
     423         172 :                             if( bSymmetric )
     424             :                             {
     425             :                                 // aItZ already points to the colour for the middle, but insert a fake stop at the
     426             :                                 // exact middle if necessary.
     427          19 :                                 if( aItA->first != aItZ->first )
     428             :                                 {
     429           2 :                                     Color aMiddleColor = aItZ->second;
     430           2 :                                     aGradientStops[0.5] = aMiddleColor;
     431             :                                 }
     432             :                                 // Drop the rest of the stops
     433          57 :                                 while( aGradientStops.rbegin()->first > 0.5 )
     434          19 :                                     aGradientStops.erase( aGradientStops.rbegin()->first );
     435             :                             }
     436             :                         }
     437             : 
     438             :                         SAL_INFO("oox.drawingml.gradient", "symmetric: " << (bSymmetric ? "YES" : "NO") <<
     439             :                                  ", number of stops: " << aGradientStops.size());
     440        1358 :                         for (GradientFillProperties::GradientStopMap::iterator p(aGradientStops.begin());
     441        1186 :                              p != aGradientStops.end();
     442             :                              ++p)
     443             :                             SAL_INFO("oox.drawingml.gradient", "  " << std::distance(aGradientStops.begin(), p) << ": " <<
     444             :                                      p->first << ": " <<
     445             :                                      std::hex << p->second.getColor( rGraphicHelper, nPhClr ) << std::dec <<
     446             :                                      "@" << (100-p->second.getTransparency()) << "%");
     447             : 
     448             :                         // Now estimate the simple LO style gradient (only two stops, at n% and 100%, where n ==
     449             :                         // the "border") that best emulates the gradient between begin() and prior(end()).
     450             : 
     451             :                         // First look for the largest segment in the gradient.
     452         172 :                         GradientFillProperties::GradientStopMap::iterator aIt(aGradientStops.begin());
     453         172 :                         double nWidestWidth = -1;
     454         172 :                         GradientFillProperties::GradientStopMap::iterator aWidestSegmentStart;
     455         172 :                         ++aIt;
     456         593 :                         while( aIt != aGradientStops.end() )
     457             :                         {
     458         249 :                             if( aIt->first - boost::prior(aIt)->first > nWidestWidth )
     459             :                             {
     460         226 :                                 nWidestWidth = aIt->first - boost::prior(aIt)->first;
     461         226 :                                 aWidestSegmentStart = boost::prior(aIt);
     462             :                             }
     463         249 :                             ++aIt;
     464             :                         }
     465             :                         assert( nWidestWidth > 0 );
     466             : 
     467         172 :                         double nBorder = 0;
     468         172 :                         bool bSwap(false);
     469             : 
     470             :                         // Do we have just two segments, and either one is of uniform colour, or three or more
     471             :                         // segments, and the widest one is the first or last one, and is it of uniform colour? If
     472             :                         // so, deduce the border from it, and drop that segment.
     473         842 :                         if( aGradientStops.size() == 3 &&
     474         900 :                             aGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr ) == boost::next(aGradientStops.begin())->second.getColor( rGraphicHelper, nPhClr ) &&
     475         325 :                             aGradientStops.begin()->second.getTransparency() == boost::next(aGradientStops.begin())->second.getTransparency( ) )
     476             :                         {
     477             :                             // Two segments, first is uniformly coloured
     478             :                             SAL_INFO("oox.drawingml.gradient", "two segments, first is uniformly coloured");
     479          51 :                             nBorder = boost::next(aGradientStops.begin())->first - aGradientStops.begin()->first;
     480          51 :                             aGradientStops.erase(aGradientStops.begin());
     481          51 :                             aWidestSegmentStart = aGradientStops.begin();
     482             :                         }
     483         560 :                         else if( !bSymmetric &&
     484         180 :                                  aGradientStops.size() == 3 &&
     485         467 :                                  boost::next(aGradientStops.begin())->second.getColor( rGraphicHelper, nPhClr ) == boost::prior(aGradientStops.end())->second.getColor( rGraphicHelper, nPhClr ) &&
     486         121 :                                  boost::next(aGradientStops.begin())->second.getTransparency() == boost::prior(aGradientStops.end())->second.getTransparency( ) )
     487             :                         {
     488             :                             // Two segments, second is uniformly coloured
     489             :                             SAL_INFO("oox.drawingml.gradient", "two segments, second is uniformly coloured");
     490           0 :                             nBorder = boost::prior(aGradientStops.end())->first - boost::next(aGradientStops.begin())->first;
     491           0 :                             aGradientStops.erase(boost::next(aGradientStops.begin()));
     492           0 :                             aWidestSegmentStart = aGradientStops.begin();
     493           0 :                             bSwap = true;
     494           0 :                             nShapeRotation = 180*60000 - nShapeRotation;
     495             :                         }
     496         586 :                         else if( !bSymmetric &&
     497         102 :                                  aGradientStops.size() >= 4 &&
     498         121 :                                  aWidestSegmentStart->second.getColor( rGraphicHelper, nPhClr ) == boost::next(aWidestSegmentStart)->second.getColor( rGraphicHelper, nPhClr ) &&
     499         363 :                                  aWidestSegmentStart->second.getTransparency() == boost::next(aWidestSegmentStart)->second.getTransparency() &&
     500         121 :                                  ( aWidestSegmentStart == aGradientStops.begin() ||
     501         121 :                                    boost::next(aWidestSegmentStart) == boost::prior( aGradientStops.end() ) ) )
     502             :                         {
     503             :                             // Not symmetric, three or more segments, the widest is first or last and is uniformly coloured
     504             :                             SAL_INFO("oox.drawingml.gradient", "first or last segment is widest and is uniformly coloured");
     505           0 :                             nBorder = boost::next(aWidestSegmentStart)->first - aWidestSegmentStart->first;
     506             : 
     507             :                             // If it's the last segment that is uniformly coloured, rotate the gradient 180
     508             :                             // degrees and swap start and end colours
     509           0 :                             if( boost::next(aWidestSegmentStart) == boost::prior( aGradientStops.end() ) )
     510             :                             {
     511           0 :                                 bSwap = true;
     512           0 :                                 nShapeRotation = 180*60000 - nShapeRotation;
     513             :                             }
     514             : 
     515           0 :                             aGradientStops.erase( aWidestSegmentStart++ );
     516             : 
     517             :                             // Look for which is widest now
     518           0 :                             aIt = boost::next(aGradientStops.begin());
     519           0 :                             nWidestWidth = -1;
     520           0 :                             while( aIt != aGradientStops.end() )
     521             :                             {
     522           0 :                                 if( aIt->first - boost::prior(aIt)->first > nWidestWidth )
     523             :                                 {
     524           0 :                                     nWidestWidth = aIt->first - boost::prior(aIt)->first;
     525           0 :                                     aWidestSegmentStart = boost::prior(aIt);
     526             :                                 }
     527           0 :                                 ++aIt;
     528             :                             }
     529             :                         }
     530             :                         SAL_INFO("oox.drawingml.gradient", "widest segment start: " << aWidestSegmentStart->first << ", border: " << nBorder);
     531             :                         assert( (!bSymmetric && !bSwap) || !(bSymmetric && bSwap) );
     532             : 
     533             :                         // Now we have a potential border and a largest segment. Use those.
     534             : 
     535         172 :                         aGradient.Style = bSymmetric ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
     536         172 :                         nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) - nShapeRotation;
     537             :                         // convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
     538         172 :                         aGradient.Angle = static_cast< sal_Int16 >( (4500 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
     539         344 :                         Color aStartColor, aEndColor;
     540         172 :                         if( bSymmetric )
     541             :                         {
     542          19 :                             aStartColor = boost::next(aWidestSegmentStart)->second;
     543          19 :                             aEndColor = aWidestSegmentStart->second;
     544          19 :                             nBorder *= 2;
     545             :                         }
     546         153 :                         else if( bSwap )
     547             :                         {
     548           0 :                             aStartColor = boost::next(aWidestSegmentStart)->second;
     549           0 :                             aEndColor = aWidestSegmentStart->second;
     550             :                         }
     551             :                         else
     552             :                         {
     553         153 :                             aStartColor = aWidestSegmentStart->second;
     554         153 :                             aEndColor = boost::next(aWidestSegmentStart)->second;
     555             :                         }
     556             : 
     557             :                         SAL_INFO("oox.drawingml.gradient", "start color: " << std::hex << aStartColor.getColor( rGraphicHelper, nPhClr ) << std::dec <<
     558             :                                  "@" << (100-aStartColor.getTransparency()) << "%"
     559             :                                  ", end color: " << std::hex << aEndColor.getColor( rGraphicHelper, nPhClr ) << std::dec <<
     560             :                                  "@" << (100-aEndColor.getTransparency()) << "%");
     561             : 
     562         172 :                         aGradient.StartColor = aStartColor.getColor( rGraphicHelper, nPhClr );
     563         172 :                         aGradient.EndColor = aEndColor.getColor( rGraphicHelper, nPhClr );
     564             : 
     565         172 :                         if( aStartColor.hasTransparency() )
     566          26 :                             nStartTrans = aStartColor.getTransparency()*255/100;
     567         172 :                         if( aEndColor.hasTransparency() )
     568           4 :                             nEndTrans = aEndColor.getTransparency()*255/100;
     569             : 
     570         344 :                         aGradient.Border = rtl::math::round(100*nBorder);
     571             :                     }
     572             : 
     573             :                     // push gradient or named gradient to property map
     574         179 :                     if( rPropMap.setProperty( SHAPEPROP_FillGradient, aGradient ) )
     575         179 :                         eFillStyle = FillStyle_GRADIENT;
     576             : 
     577             :                     // push gradient transparency to property map
     578         179 :                     if( nStartTrans != 0 || nEndTrans != 0 )
     579             :                     {
     580          30 :                         awt::Gradient aGrad(aGradient);
     581          30 :                         uno::Any aVal;
     582          30 :                         aGrad.EndColor = (sal_Int32)( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
     583          30 :                         aGrad.StartColor = (sal_Int32)( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
     584          30 :                         aVal <<= aGrad;
     585          30 :                         rPropMap.setProperty( SHAPEPROP_GradientTransparency, aGrad );
     586             :                     }
     587             : 
     588             :                 }
     589         179 :             break;
     590             : 
     591             :             case XML_blipFill:
     592             :                 // do not start complex graphic transformation if property is not supported...
     593          59 :                 if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapUrl ) )
     594             :                 {
     595          59 :                     Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
     596             :                     // TODO: "rotate with shape" is not possible with our current core
     597             : 
     598         118 :                     OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
     599             :                     // push bitmap or named bitmap to property map
     600          59 :                     if( !aGraphicUrl.isEmpty() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapNameFromUrl ) && rPropMap.setProperty( SHAPEPROP_FillBitmapNameFromUrl, aGraphicUrl ) )
     601          57 :                         eFillStyle = FillStyle_BITMAP;
     602           2 :                     else if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( SHAPEPROP_FillBitmapUrl, aGraphicUrl ) )
     603           2 :                         eFillStyle = FillStyle_BITMAP;
     604             : 
     605             :                     // set other bitmap properties, if bitmap has been inserted into the map
     606          59 :                     if( eFillStyle == FillStyle_BITMAP )
     607             :                     {
     608             :                         // bitmap mode (single, repeat, stretch)
     609          59 :                         BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) );
     610          59 :                         rPropMap.setProperty( SHAPEPROP_FillBitmapMode, eBitmapMode );
     611             : 
     612             :                         // additional settings for repeated bitmap
     613          59 :                         if( eBitmapMode == BitmapMode_REPEAT )
     614             :                         {
     615             :                             // anchor position inside bitmap
     616           4 :                             RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) );
     617           4 :                             rPropMap.setProperty( SHAPEPROP_FillBitmapRectanglePoint, eRectPoint );
     618             : 
     619           4 :                             awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic );
     620           4 :                             if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) )
     621             :                             {
     622             :                                 // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm
     623           4 :                                 double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
     624           4 :                                 sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 );
     625           4 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapSizeX, nFillBmpSizeX );
     626           4 :                                 double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
     627           4 :                                 sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
     628           4 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapSizeY, nFillBmpSizeY );
     629             : 
     630             :                                 // offset of the first bitmap tile (given as EMUs), convert to percent
     631           4 :                                 sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 );
     632           4 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetX, nTileOffsetX );
     633           4 :                                 sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
     634           4 :                                 rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetY, nTileOffsetY );
     635             :                             }
     636             :                         }
     637          55 :                         else if ( eBitmapMode == BitmapMode_STRETCH && maBlipProps.moFillRect.has() )
     638             :                         {
     639          55 :                             geometry::IntegerRectangle2D aFillRect( maBlipProps.moFillRect.get() );
     640          55 :                             awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
     641          55 :                             if ( aOriginalSize.Width && aOriginalSize.Height )
     642             :                             {
     643          55 :                                 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
     644          55 :                                 if ( aFillRect.X1 )
     645          37 :                                     aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X1 ) / 100000 );
     646          55 :                                 if ( aFillRect.Y1 )
     647          18 :                                     aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y1 ) / 100000 );
     648          55 :                                 if ( aFillRect.X2 )
     649          37 :                                     aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 100000 );
     650          55 :                                 if ( aFillRect.Y2 )
     651          18 :                                     aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
     652          55 :                                 rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
     653             :                             }
     654             :                         }
     655          59 :                     }
     656             :                 }
     657          59 :             break;
     658             : 
     659             :             case XML_pattFill:
     660             :             {
     661          96 :                 if( rPropMap.supportsProperty( SHAPEPROP_FillHatch ) )
     662             :                 {
     663          96 :                     Color aColor( maPatternProps.maPattFgColor );
     664          96 :                     if( aColor.isUsed() && maPatternProps.moPattPreset.has() )
     665             :                     {
     666             :                         // we do not support hatches that have background
     667             :                         // color too, so all this is some best-effort approach
     668          96 :                         eFillStyle = FillStyle_HATCH;
     669          96 :                         rPropMap.setProperty( SHAPEPROP_FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) );
     670             :                     }
     671           0 :                     else if ( maPatternProps.maPattBgColor.isUsed() )
     672             :                     {
     673           0 :                         aColor = maPatternProps.maPattBgColor;
     674           0 :                         rPropMap.setProperty( SHAPEPROP_FillColor, aColor.getColor( rGraphicHelper, nPhClr ) );
     675           0 :                         if( aColor.hasTransparency() )
     676           0 :                             rPropMap.setProperty( SHAPEPROP_FillTransparency, aColor.getTransparency() );
     677           0 :                         eFillStyle = FillStyle_SOLID;
     678          96 :                     }
     679             :                 }
     680             :             }
     681          96 :             break;
     682             : 
     683             :             case XML_grpFill:
     684             :                 // todo
     685           0 :                 eFillStyle = FillStyle_NONE;
     686           0 :             break;
     687             :         }
     688             : 
     689             :         // set final fill style property
     690        5133 :         rPropMap.setProperty( SHAPEPROP_FillStyle, eFillStyle );
     691             :     }
     692        5215 : }
     693             : 
     694         405 : void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const
     695             : {
     696         405 :     sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
     697         405 :     sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
     698         405 :     if( maBlipProps.mxGraphic.is() )
     699             :     {
     700             :         // created transformed graphic
     701         306 :         Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
     702         306 :         xGraphic = lclCheckAndApplyChangeColorTransform( maBlipProps, xGraphic, rGraphicHelper, nPhClr );
     703             :         // MSO uses a different algorithm for contrast+brightness, LO applies contrast before brightness,
     704             :         // while MSO apparently applies half of brightness before contrast and half after. So if only
     705             :         // contrast or brightness need to be altered, the result is the same, but if both are involved,
     706             :         // there's no way to map that, so just force a conversion of the image.
     707         306 :         if( nBrightness != 0 && nContrast != 0 )
     708             :         {
     709           3 :             xGraphic = applyBrightnessContrast( xGraphic, nBrightness, nContrast );
     710           3 :             nBrightness = 0;
     711           3 :             nContrast = 0;
     712             :         }
     713         306 :         rPropMap.setProperty(PROP_Graphic, xGraphic);
     714             : 
     715             :         // do we still need to set GraphicURL as well? (TODO)
     716         612 :         OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
     717         306 :         if( !aGraphicUrl.isEmpty() )
     718         306 :             rPropMap.setProperty(PROP_GraphicURL, aGraphicUrl);
     719             : 
     720             :         // cropping
     721         306 :         if ( maBlipProps.moClipRect.has() )
     722             :         {
     723          81 :             geometry::IntegerRectangle2D oClipRect( maBlipProps.moClipRect.get() );
     724          81 :             awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
     725          81 :             if ( aOriginalSize.Width && aOriginalSize.Height )
     726             :             {
     727          81 :                 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
     728          81 :                 if ( oClipRect.X1 )
     729          13 :                     aGraphCrop.Left = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 );
     730          81 :                 if ( oClipRect.Y1 )
     731          14 :                     aGraphCrop.Top = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 );
     732          81 :                 if ( oClipRect.X2 )
     733          13 :                     aGraphCrop.Right = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 );
     734          81 :                 if ( oClipRect.Y2 )
     735          13 :                     aGraphCrop.Bottom = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 );
     736          81 :                 rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
     737             :             }
     738         306 :         }
     739             :     }
     740             : 
     741             :     // color effect
     742         405 :     ColorMode eColorMode = ColorMode_STANDARD;
     743         405 :     switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
     744             :     {
     745           1 :         case XML_biLevel:   eColorMode = ColorMode_MONO;    break;
     746           4 :         case XML_grayscl:   eColorMode = ColorMode_GREYS;   break;
     747             :     }
     748         405 :     rPropMap.setProperty(PROP_GraphicColorMode, eColorMode);
     749             : 
     750             :     // brightness and contrast
     751         405 :     if( nBrightness != 0 )
     752           0 :         rPropMap.setProperty(PROP_AdjustLuminance, nBrightness);
     753         405 :     if( nContrast != 0 )
     754           0 :         rPropMap.setProperty(PROP_AdjustContrast, nContrast);
     755             : 
     756             :     // Media content
     757             :     assert(m_xMediaStream.is() != m_sMediaPackageURL.isEmpty());
     758         405 :     if (m_xMediaStream.is() && !m_sMediaPackageURL.isEmpty())
     759             :     {
     760           2 :         rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
     761           2 :         rPropMap.setProperty(PROP_MediaURL, m_sMediaPackageURL);
     762             :     }
     763         405 : }
     764             : 
     765       21102 : bool ArtisticEffectProperties::isEmpty() const
     766             : {
     767       21102 :     return msName.isEmpty();
     768             : }
     769             : 
     770          19 : css::beans::PropertyValue ArtisticEffectProperties::getEffect()
     771             : {
     772          19 :     css::beans::PropertyValue pRet;
     773          19 :     if( msName.isEmpty() )
     774           0 :         return pRet;
     775             : 
     776          38 :     css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() + 1 );
     777          19 :     sal_uInt32 i = 0;
     778          46 :     for( std::map< OUString, css::uno::Any >::iterator it = maAttribs.begin(); it != maAttribs.end(); ++it )
     779             :     {
     780          27 :         aSeq[i].Name = it->first;
     781          27 :         aSeq[i].Value = it->second;
     782          27 :         i++;
     783             :     }
     784             : 
     785          19 :     if( mrOleObjectInfo.maEmbeddedData.hasElements() )
     786             :     {
     787          19 :         css::uno::Sequence< css::beans::PropertyValue > aGraphicSeq( 2 );
     788          19 :         aGraphicSeq[0].Name = "Id";
     789          19 :         aGraphicSeq[0].Value = uno::makeAny( mrOleObjectInfo.maProgId );
     790          19 :         aGraphicSeq[1].Name = "Data";
     791          19 :         aGraphicSeq[1].Value = uno::makeAny( mrOleObjectInfo.maEmbeddedData );
     792             : 
     793          19 :         aSeq[i].Name = "OriginalGraphic";
     794          19 :         aSeq[i].Value = uno::makeAny( aGraphicSeq );
     795             :     }
     796             : 
     797          19 :     pRet.Name = msName;
     798          19 :     pRet.Value = css::uno::Any( aSeq );
     799             : 
     800          19 :     return pRet;
     801             : }
     802             : 
     803       18218 : void ArtisticEffectProperties::assignUsed( const ArtisticEffectProperties& rSourceProps )
     804             : {
     805       18218 :     if( !rSourceProps.isEmpty() )
     806             :     {
     807           0 :         msName = rSourceProps.msName;
     808           0 :         maAttribs = rSourceProps.maAttribs;
     809             :     }
     810       18218 : }
     811             : 
     812          46 : OUString ArtisticEffectProperties::getEffectString( sal_Int32 nToken )
     813             : {
     814          46 :     switch( nToken )
     815             :     {
     816             :         // effects
     817           0 :         case OOX_TOKEN( a14, artisticBlur ):                return OUString( "artisticBlur" );
     818           0 :         case OOX_TOKEN( a14, artisticCement ):              return OUString( "artisticCement" );
     819           0 :         case OOX_TOKEN( a14, artisticChalkSketch ):         return OUString( "artisticChalkSketch" );
     820           0 :         case OOX_TOKEN( a14, artisticCrisscrossEtching ):   return OUString( "artisticCrisscrossEtching" );
     821           0 :         case OOX_TOKEN( a14, artisticCutout ):              return OUString( "artisticCutout" );
     822           0 :         case OOX_TOKEN( a14, artisticFilmGrain ):           return OUString( "artisticFilmGrain" );
     823           0 :         case OOX_TOKEN( a14, artisticGlass ):               return OUString( "artisticGlass" );
     824           0 :         case OOX_TOKEN( a14, artisticGlowDiffused ):        return OUString( "artisticGlowDiffused" );
     825           0 :         case OOX_TOKEN( a14, artisticGlowEdges ):           return OUString( "artisticGlowEdges" );
     826           3 :         case OOX_TOKEN( a14, artisticLightScreen ):         return OUString( "artisticLightScreen" );
     827           0 :         case OOX_TOKEN( a14, artisticLineDrawing ):         return OUString( "artisticLineDrawing" );
     828           3 :         case OOX_TOKEN( a14, artisticMarker ):              return OUString( "artisticMarker" );
     829           0 :         case OOX_TOKEN( a14, artisticMosiaicBubbles ):      return OUString( "artisticMosiaicBubbles" );
     830           0 :         case OOX_TOKEN( a14, artisticPaintStrokes ):        return OUString( "artisticPaintStrokes" );
     831           0 :         case OOX_TOKEN( a14, artisticPaintBrush ):          return OUString( "artisticPaintBrush" );
     832           0 :         case OOX_TOKEN( a14, artisticPastelsSmooth ):       return OUString( "artisticPastelsSmooth" );
     833           4 :         case OOX_TOKEN( a14, artisticPencilGrayscale ):     return OUString( "artisticPencilGrayscale" );
     834           3 :         case OOX_TOKEN( a14, artisticPencilSketch ):        return OUString( "artisticPencilSketch" );
     835           3 :         case OOX_TOKEN( a14, artisticPhotocopy ):           return OUString( "artisticPhotocopy" );
     836           0 :         case OOX_TOKEN( a14, artisticPlasticWrap ):         return OUString( "artisticPlasticWrap" );
     837           0 :         case OOX_TOKEN( a14, artisticTexturizer ):          return OUString( "artisticTexturizer" );
     838           3 :         case OOX_TOKEN( a14, artisticWatercolorSponge ):    return OUString( "artisticWatercolorSponge" );
     839           0 :         case OOX_TOKEN( a14, artisticBrightnessContrast ):  return OUString( "artisticBrightnessContrast" );
     840           0 :         case OOX_TOKEN( a14, artisticColorTemperature ):    return OUString( "artisticColorTemperature" );
     841           0 :         case OOX_TOKEN( a14, artisticSaturation ):          return OUString( "artisticSaturation" );
     842           0 :         case OOX_TOKEN( a14, artisticSharpenSoften ):       return OUString( "artisticSharpenSoften" );
     843             : 
     844             :         // attributes
     845           0 :         case XML_visible:           return OUString( "visible" );
     846          12 :         case XML_trans:             return OUString( "trans" );
     847           0 :         case XML_crackSpacing:      return OUString( "crackSpacing" );
     848           3 :         case XML_pressure:          return OUString( "pressure" );
     849           0 :         case XML_numberOfShades:    return OUString( "numberOfShades" );
     850           0 :         case XML_grainSize:         return OUString( "grainSize" );
     851           0 :         case XML_intensity:         return OUString( "intensity" );
     852           0 :         case XML_smoothness:        return OUString( "smoothness" );
     853           3 :         case XML_gridSize:          return OUString( "gridSize" );
     854           3 :         case XML_pencilSize:        return OUString( "pencilSize" );
     855           3 :         case XML_size:              return OUString( "size" );
     856           3 :         case XML_brushSize:         return OUString( "brushSize" );
     857           0 :         case XML_scaling:           return OUString( "scaling" );
     858           0 :         case XML_detail:            return OUString( "detail" );
     859           0 :         case XML_bright:            return OUString( "bright" );
     860           0 :         case XML_contrast:          return OUString( "contrast" );
     861           0 :         case XML_colorTemp:         return OUString( "colorTemp" );
     862           0 :         case XML_sat:               return OUString( "sat" );
     863           0 :         case XML_amount:            return OUString( "amount" );
     864             :     }
     865             :     SAL_WARN( "oox.drawingml", "ArtisticEffectProperties::getEffectString - unexpected token" );
     866           0 :     return OUString();
     867             : }
     868             : 
     869         129 : sal_Int32 ArtisticEffectProperties::getEffectToken( const OUString& sName )
     870             : {
     871             :     // effects
     872         129 :     if( sName == "artisticBlur" )
     873           0 :         return XML_artisticBlur;
     874         129 :     else if( sName == "artisticCement" )
     875           0 :         return XML_artisticCement;
     876         129 :     else if( sName == "artisticChalkSketch" )
     877           0 :         return XML_artisticChalkSketch;
     878         129 :     else if( sName == "artisticCrisscrossEtching" )
     879           0 :         return XML_artisticCrisscrossEtching;
     880         129 :     else if( sName == "artisticCutout" )
     881           0 :         return XML_artisticCutout;
     882         129 :     else if( sName == "artisticFilmGrain" )
     883           0 :         return XML_artisticFilmGrain;
     884         129 :     else if( sName == "artisticGlass" )
     885           0 :         return XML_artisticGlass;
     886         129 :     else if( sName == "artisticGlowDiffused" )
     887           0 :         return XML_artisticGlowDiffused;
     888         129 :     else if( sName == "artisticGlowEdges" )
     889           0 :         return XML_artisticGlowEdges;
     890         129 :     else if( sName == "artisticLightScreen" )
     891           1 :         return XML_artisticLightScreen;
     892         128 :     else if( sName == "artisticLineDrawing" )
     893           0 :         return XML_artisticLineDrawing;
     894         128 :     else if( sName == "artisticMarker" )
     895           1 :         return XML_artisticMarker;
     896         127 :     else if( sName == "artisticMosiaicBubbles" )
     897           0 :         return XML_artisticMosiaicBubbles;
     898         127 :     else if( sName == "artisticPaintStrokes" )
     899           0 :         return XML_artisticPaintStrokes;
     900         127 :     else if( sName == "artisticPaintBrush" )
     901           0 :         return XML_artisticPaintBrush;
     902         127 :     else if( sName == "artisticPastelsSmooth" )
     903           0 :         return XML_artisticPastelsSmooth;
     904         127 :     else if( sName == "artisticPencilGrayscale" )
     905           1 :         return XML_artisticPencilGrayscale;
     906         126 :     else if( sName == "artisticPencilSketch" )
     907           1 :         return XML_artisticPencilSketch;
     908         125 :     else if( sName == "artisticPhotocopy" )
     909           1 :         return XML_artisticPhotocopy;
     910         124 :     else if( sName == "artisticPlasticWrap" )
     911           0 :         return XML_artisticPlasticWrap;
     912         124 :     else if( sName == "artisticTexturizer" )
     913           0 :         return XML_artisticTexturizer;
     914         124 :     else if( sName == "artisticWatercolorSponge" )
     915           1 :         return XML_artisticWatercolorSponge;
     916         123 :     else if( sName == "artisticBrightnessContrast" )
     917           0 :         return XML_artisticBrightnessContrast;
     918         123 :     else if( sName == "artisticColorTemperature" )
     919           0 :         return XML_artisticColorTemperature;
     920         123 :     else if( sName == "artisticSaturation" )
     921           0 :         return XML_artisticSaturation;
     922         123 :     else if( sName == "artisticSharpenSoften" )
     923           0 :         return XML_artisticSharpenSoften;
     924             : 
     925             :     // attributes
     926         123 :     else if( sName == "visible" )
     927           0 :         return XML_visible;
     928         123 :     else if( sName == "trans" )
     929           4 :         return XML_trans;
     930         119 :     else if( sName == "crackSpacing" )
     931           0 :         return XML_crackSpacing;
     932         119 :     else if( sName == "pressure" )
     933           1 :         return XML_pressure;
     934         118 :     else if( sName == "numberOfShades" )
     935           0 :         return XML_numberOfShades;
     936         118 :     else if( sName == "grainSize" )
     937           0 :         return XML_grainSize;
     938         118 :     else if( sName == "intensity" )
     939           0 :         return XML_intensity;
     940         118 :     else if( sName == "smoothness" )
     941           0 :         return XML_smoothness;
     942         118 :     else if( sName == "gridSize" )
     943           1 :         return XML_gridSize;
     944         117 :     else if( sName == "pencilSize" )
     945           1 :         return XML_pencilSize;
     946         116 :     else if( sName == "size" )
     947           1 :         return XML_size;
     948         115 :     else if( sName == "brushSize" )
     949           1 :         return XML_brushSize;
     950         114 :     else if( sName == "scaling" )
     951           0 :         return XML_scaling;
     952         114 :     else if( sName == "detail" )
     953           0 :         return XML_detail;
     954         114 :     else if( sName == "bright" )
     955           0 :         return XML_bright;
     956         114 :     else if( sName == "contrast" )
     957           0 :         return XML_contrast;
     958         114 :     else if( sName == "colorTemp" )
     959           0 :         return XML_colorTemp;
     960         114 :     else if( sName == "sat" )
     961           0 :         return XML_sat;
     962         114 :     else if( sName == "amount" )
     963           0 :         return XML_amount;
     964             : 
     965             :     SAL_WARN( "oox.drawingml", "ArtisticEffectProperties::getEffectToken - unexpected token name" );
     966         114 :     return XML_none;
     967             : }
     968             : 
     969             : } // namespace drawingml
     970         246 : } // namespace oox
     971             : 
     972             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11