summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@collabora.com>2013-10-10 18:03:51 +0530
committerMuthu Subramanian <sumuthu@collabora.com>2013-10-10 18:05:36 +0530
commitefbf0b412bc76149b410d0cd17c7040513d4c203 (patch)
tree698daf422384bddf97e457abb44ac4ef822d3991
parent215269e3031e31fd64e3aa38167875a042b8c80c (diff)
n#812793: clrChange applying for EMFs
Also fixed alpha clrChanges.
-rw-r--r--oox/source/drawingml/colorchoicecontext.cxx3
-rw-r--r--oox/source/drawingml/fillproperties.cxx39
-rw-r--r--svtools/source/graphic/transformer.cxx6
3 files changed, 30 insertions, 18 deletions
diff --git a/oox/source/drawingml/colorchoicecontext.cxx b/oox/source/drawingml/colorchoicecontext.cxx
index b33b6dd87b79..bec28b042fca 100644
--- a/oox/source/drawingml/colorchoicecontext.cxx
+++ b/oox/source/drawingml/colorchoicecontext.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "oox/drawingml/drawingmltypes.hxx"
#include "oox/drawingml/colorchoicecontext.hxx"
#include "oox/helper/attributelist.hxx"
#include "oox/drawingml/color.hxx"
@@ -83,6 +84,8 @@ void ColorValueContext::onStartElement( const AttributeList& rAttribs )
switch( nElement )
{
case A_TOKEN( alpha ):
+ mrColor.addTransformation( nElement, rAttribs.getInteger( XML_val, 0 )*PER_PERCENT );
+ break;
case A_TOKEN( alphaMod ):
case A_TOKEN( alphaOff ):
case A_TOKEN( blue ):
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index dcac76b88b6c..4e6d8e1ccf81 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -71,6 +71,29 @@ Reference< XGraphic > lclCheckAndApplyDuotoneTransform( const BlipFillProperties
return xGraphic;
}
+Reference< XGraphic > lclCheckAndApplyChangeColorTransform( const BlipFillProperties &aBlipProps, Reference< XGraphic > xGraphic,
+ const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
+{
+ if( aBlipProps.maColorChangeFrom.isUsed() && aBlipProps.maColorChangeTo.isUsed() )
+ {
+ sal_Int32 nFromColor = aBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr );
+ sal_Int32 nToColor = aBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr );
+ if ( (nFromColor != nToColor) || aBlipProps.maColorChangeTo.hasTransparency() ) try
+ {
+ sal_Int16 nToTransparence = aBlipProps.maColorChangeTo.getTransparency();
+ sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) * 2.55 );
+ Reference< XGraphicTransformer > xTransformer( aBlipProps.mxGraphic, UNO_QUERY_THROW );
+ xGraphic = xTransformer->colorChange( xGraphic, nFromColor, 9, nToColor, nToAlpha );
+ }
+ catch( Exception& )
+ {
+ }
+ }
+ return xGraphic;
+}
+
+
+
BitmapMode lclGetBitmapMode( sal_Int32 nToken )
{
OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
@@ -480,21 +503,7 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
{
// created transformed graphic
Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
- if( maBlipProps.maColorChangeFrom.isUsed() && maBlipProps.maColorChangeTo.isUsed() )
- {
- sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr );
- sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr );
- if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparency() ) try
- {
- sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparency();
- sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) / 39.062 ); // ?!? correct ?!?
- Reference< XGraphicTransformer > xTransformer( maBlipProps.mxGraphic, UNO_QUERY_THROW );
- xGraphic = xTransformer->colorChange( maBlipProps.mxGraphic, nFromColor, 9, nToColor, nToAlpha );
- }
- catch( Exception& )
- {
- }
- }
+ xGraphic = lclCheckAndApplyChangeColorTransform( maBlipProps, xGraphic, rGraphicHelper, nPhClr );
rPropMap[ PROP_Graphic ] <<= xGraphic;
diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx
index 0b0381b517fd..30f07c7af197 100644
--- a/svtools/source/graphic/transformer.cxx
+++ b/svtools/source/graphic/transformer.cxx
@@ -86,7 +86,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
BitmapColor aColorTo( static_cast< sal_uInt8 >( nColorTo ), static_cast< sal_uInt8 >( nColorTo >> 8 ), static_cast< sal_uInt8 >( nColorTo >> 16 ) );
const sal_uInt8 cIndexFrom = aColorFrom.GetBlueOrIndex();
- if ( aGraphic.GetType() == GRAPHIC_BITMAP )
+ if ( aGraphic.GetType() == GRAPHIC_BITMAP || aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
{
BitmapEx aBitmapEx( aGraphic.GetBitmapEx() );
Bitmap aBitmap( aBitmapEx.GetBitmap() );
@@ -100,7 +100,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
}
else if ( aBitmapEx.IsTransparent() )
{
- if ( ( nAlphaTo == 0 ) || ( nAlphaTo == sal::static_int_cast<sal_Int8>(0xff) ) )
+ if ( nAlphaTo == sal::static_int_cast<sal_Int8>(0xff) )
{
Bitmap aMask( aBitmapEx.GetMask() );
Bitmap aMask2( aBitmap.CreateMask( aColorFrom, nTolerance ) );
@@ -111,7 +111,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
else
{
AlphaMask aAlphaMask( aBitmapEx.GetMask() );
- setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo );
+ setAlpha( aBitmap, aAlphaMask, cIndexFrom, 0xff - nAlphaTo );
aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) );
}