summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-04-07 16:51:29 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-04-09 10:09:30 +0000
commit1353fbe84644d73ae0e5267b48a387063606d0de (patch)
tree6c7f3c98a085e5d60be0d0c2fc8bb1841bb85535
parent1de82ad2fc25a6b16236034df37d48348c8c7ac5 (diff)
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 (cherry picked from commit 2a7fdf2a7bb7345c49c988dfd1fcdb41cebb8a1e) Reviewed-on: https://gerrit.libreoffice.org/8903 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--embeddedobj/Library_emboleobj.mk1
-rw-r--r--embeddedobj/source/msole/graphconvert.cxx12
2 files changed, 13 insertions, 0 deletions
diff --git a/embeddedobj/Library_emboleobj.mk b/embeddedobj/Library_emboleobj.mk
index 96f03ee16ca5..e10110bab636 100644
--- a/embeddedobj/Library_emboleobj.mk
+++ b/embeddedobj/Library_emboleobj.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_libraries,emboleobj,\
sal \
tl \
utl \
+ vcl \
$(gb_UWINAPI) \
))
diff --git a/embeddedobj/source/msole/graphconvert.cxx b/embeddedobj/source/msole/graphconvert.cxx
index 9883c490cb16..1f467adafb73 100644
--- a/embeddedobj/source/msole/graphconvert.cxx
+++ b/embeddedobj/source/msole/graphconvert.cxx
@@ -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