fdo#77089 pass shape dimensions to graphicfilter for WMF

Change-Id: I673a76ef85038b1f304ea85faeed5b4a462cb144
This commit is contained in:
Tomaž Vajngerl 2014-04-24 18:39:27 +02:00
parent 4abaaf7663
commit c2d5b59fc6
4 changed files with 22 additions and 6 deletions

View file

@ -115,7 +115,9 @@ public:
/** Imports a graphic from the storage stream with the passed path and name. */
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
importEmbeddedGraphic( const OUString& rStreamName ) const;
importEmbeddedGraphic(
const OUString& rStreamName,
const WMF_EXTERNALHEADER* pExtHeader = NULL ) const;
/** Creates a persistent graphic object from the passed graphic.
@return The URL of the created and internally cached graphic object. */

View file

@ -70,6 +70,8 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wmf.hxx>
using namespace ::oox::core;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@ -1153,7 +1155,13 @@ OUString Shape::finalizeServiceName( XmlFilterBase& rFilter, const OUString& rSe
// import and store the graphic
if( !aGraphicPath.isEmpty() )
{
Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath );
// Transfer shape's width and heightto graphicsfilter (can be used by WMF/EMF)
WMF_EXTERNALHEADER aExtHeader;
aExtHeader.mapMode = 8; // MM_ANISOTROPIC
aExtHeader.xExt = rShapeRect.Width;
aExtHeader.yExt = rShapeRect.Height;
Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath, &aExtHeader );
if( xGraphic.is() )
maShapeProperties.setProperty(PROP_Graphic, xGraphic);
}

View file

@ -275,7 +275,7 @@ Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rG
return xGraphic;
}
Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStreamName ) const
Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStreamName, const WMF_EXTERNALHEADER* pExtHeader ) const
{
Reference< XGraphic > xGraphic;
OSL_ENSURE( !rStreamName.isEmpty(), "GraphicHelper::importEmbeddedGraphic - empty stream name" );
@ -284,7 +284,7 @@ Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStr
EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( rStreamName );
if( aIt == maEmbeddedGraphics.end() )
{
xGraphic = importGraphic( mxStorage->openInputStream( rStreamName ) );
xGraphic = importGraphic(mxStorage->openInputStream(rStreamName), pExtHeader);
if( xGraphic.is() )
maEmbeddedGraphics[ rStreamName ] = xGraphic;
}

View file

@ -21,6 +21,7 @@
#include <boost/optional.hpp>
#include "oox/vml/vmlshape.hxx"
#include <vcl/wmf.hxx>
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@ -997,8 +998,13 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
// set the replacement graphic
if( !aGraphicPath.isEmpty() )
{
Reference< XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath );
if( xGraphic.is() )
WMF_EXTERNALHEADER aExtHeader;
aExtHeader.mapMode = 8;
aExtHeader.xExt = rShapeRect.Width;
aExtHeader.yExt = rShapeRect.Height;
Reference< XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic(aGraphicPath, &aExtHeader);
if (xGraphic.is())
aOleProps.setProperty( PROP_Graphic, xGraphic);
}