diff options
author | Muthu Subramanian <sumuthu@suse.com> | 2013-07-17 12:59:40 +0530 |
---|---|---|
committer | Muthu Subramanian <sumuthu@suse.com> | 2013-07-17 13:02:07 +0530 |
commit | 8b716072410bcfd252739fb953d5ac198e27a895 (patch) | |
tree | 64c119dbc0db723bce6a205aaf8f189a128f7415 /oox/source/drawingml | |
parent | 09fb28de3b29c426afa4c37e36268e883aa55923 (diff) |
n#820077: Import images with duotone filter.
Also, contains implementation for a simple duotone filter.
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 18 | ||||
-rw-r--r-- | oox/source/drawingml/fillpropertiesgroupcontext.cxx | 25 |
2 files changed, 42 insertions, 1 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index d1d097ff4ead..92b4b0a89ca2 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -149,6 +149,8 @@ void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps ) moContrast.assignIfUsed( rSourceProps.moContrast ); maColorChangeFrom.assignIfUsed( rSourceProps.maColorChangeFrom ); maColorChangeTo.assignIfUsed( rSourceProps.maColorChangeTo ); + maDuotoneColors[0].assignIfUsed( rSourceProps.maDuotoneColors[0] ); + maDuotoneColors[1].assignIfUsed( rSourceProps.maDuotoneColors[1] ); } // ============================================================================ @@ -372,9 +374,23 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, // do not start complex graphic transformation if property is not supported... if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapUrl ) ) { + Reference< XGraphic > xGraphic = maBlipProps.mxGraphic; + if( maBlipProps.maDuotoneColors[0].isUsed() && maBlipProps.maDuotoneColors[1].isUsed() ) + { + sal_Int32 nColor1 = maBlipProps.maDuotoneColors[0].getColor( rGraphicHelper, nPhClr ); + sal_Int32 nColor2 = maBlipProps.maDuotoneColors[1].getColor( rGraphicHelper, nPhClr ); + try + { + Reference< XGraphicTransformer > xTransformer( maBlipProps.mxGraphic, UNO_QUERY_THROW ); + xGraphic = xTransformer->applyDuotone( maBlipProps.mxGraphic, nColor1, nColor2 ); + } + catch( Exception& ) + { + } + } // TODO: "rotate with shape" is not possible with our current core - OUString aGraphicUrl = rGraphicHelper.createGraphicObject( maBlipProps.mxGraphic ); + OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic ); // push bitmap or named bitmap to property map if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( SHAPEPROP_FillBitmapUrl, aGraphicUrl ) ) eFillStyle = FillStyle_BITMAP; diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index 0d84d3a6bb90..8483e81b9b8d 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -179,6 +179,9 @@ ContextHandlerRef BlipContext::onCreateContext( case A_TOKEN( clrChange ): return new ColorChangeContext( *this, rAttribs, mrBlipProps ); + case A_TOKEN( duotone ): + return new DuotoneContext( *this, rAttribs, mrBlipProps ); + case A_TOKEN( lum ): mrBlipProps.moBrightness = rAttribs.getInteger( XML_bright ); mrBlipProps.moContrast = rAttribs.getInteger( XML_contrast ); @@ -187,6 +190,28 @@ ContextHandlerRef BlipContext::onCreateContext( return 0; } +DuotoneContext::DuotoneContext( ContextHandler2Helper& rParent, + const AttributeList& /*rAttribs*/, BlipFillProperties& rBlipProps ) : + ContextHandler2( rParent ), + mrBlipProps( rBlipProps ), + mnColorIndex( 0 ) +{ + mrBlipProps.maDuotoneColors[0].setUnused(); + mrBlipProps.maDuotoneColors[1].setUnused(); +} + +DuotoneContext::~DuotoneContext() +{ +} + +::oox::core::ContextHandlerRef DuotoneContext::onCreateContext( + sal_Int32 /*nElement*/, const AttributeList& /*rAttribs*/ ) +{ + if( mnColorIndex < 2 ) + return new ColorValueContext( *this, mrBlipProps.maDuotoneColors[mnColorIndex++] ); + return 0; +} + BlipFillContext::BlipFillContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, BlipFillProperties& rBlipProps ) : ContextHandler2( rParent ), |