From 32efde5cef2b8516a9decd0bf7091d7def1da971 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 29 Nov 2017 21:12:32 +0100 Subject: tdf#113696 Add mimetype to image element Otherwise browsers don't recognize base64 encoded svg files. Change-Id: I54d0b87c52a1ca9da1d820751ae32159b88ed28f Reviewed-on: https://gerrit.libreoffice.org/45528 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- xmloff/source/draw/shapeexport.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'xmloff/source/draw/shapeexport.cxx') diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 3f7f1d54ec18..29d3c74a84af 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -82,6 +82,7 @@ #include #include +#include #include #include @@ -2352,6 +2353,16 @@ void XMLShapeExport::ImpExportGraphicObjectShape( } { + // We can't guess the mimetype from sImageURL because the image type might be changed + // while creating the stream (by SvXMLGraphicInputStream). So we first need to create + // the stream, get the mime type and then write the stream. + uno::Reference xInputStream( + mrExport.GetEmbeddedGraphicObjectStream(sImageURL)); + OUString aMimeType( + comphelper::GraphicMimeTypeHelper::GetMimeTypeForImageStream(xInputStream)); + if (!aMimeType.isEmpty()) + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", aMimeType); + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true); if( !sImageURL.isEmpty() ) -- cgit