fdo#77140 embeddedobj: avoid unneeded conversion in ConvertBufferToFormat()
The primary reason is not performance: on export currently we loose some EMF+ properties. While it would be good to fix all those problems one by one, this is a small fix to avoid all kind of roundtrip problems in this situation. Change-Id: If5e1c1eabd8290f36b538e374c9707ae17097786
This commit is contained in:
parent
6ac0e1399a
commit
2a7fdf2a7b
2 changed files with 13 additions and 0 deletions
|
@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_libraries,emboleobj,\
|
|||
sal \
|
||||
tl \
|
||||
utl \
|
||||
vcl \
|
||||
$(gb_UWINAPI) \
|
||||
))
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/seqstream.hxx>
|
||||
#include <tools/stream.hxx>
|
||||
#include <vcl/graphicfilter.hxx>
|
||||
|
||||
#include "mtnotification.hxx"
|
||||
#include "oleembobj.hxx"
|
||||
|
@ -48,6 +49,17 @@ sal_Bool ConvertBufferToFormat( void* pBuf,
|
|||
// produces sequence with data in requested format and returns it in aResult
|
||||
if ( pBuf )
|
||||
{
|
||||
// First, in case the buffer is already in the requested format, then avoid a conversion.
|
||||
SvMemoryStream aMemoryStream(pBuf, nBufSize, STREAM_READ);
|
||||
GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
|
||||
sal_uInt16 nRetFormat = 0;
|
||||
if (rFilter.CanImportGraphic(OUString(), aMemoryStream, GRFILTER_FORMAT_DONTKNOW, &nRetFormat) == GRFILTER_OK &&
|
||||
rFilter.GetImportFormatMediaType(nRetFormat) == aMimeType)
|
||||
{
|
||||
aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemoryStream.GetData() ), aMemoryStream.Seek( STREAM_SEEK_TO_END ) );
|
||||
return sal_True;
|
||||
}
|
||||
|
||||
uno::Sequence < sal_Int8 > aData( (sal_Int8*)pBuf, nBufSize );
|
||||
uno::Reference < io::XInputStream > xIn = new comphelper::SequenceInputStream( aData );
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue