summaryrefslogtreecommitdiff
path: root/xmloff/source/draw/shapeexport.cxx
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-11-29 21:12:32 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-11-30 17:42:42 +0100
commit32efde5cef2b8516a9decd0bf7091d7def1da971 (patch)
treed92e02b3834b08b8e02ef8ca7adfcd2ded509107 /xmloff/source/draw/shapeexport.cxx
parentb17c29d493a1fc588524d6da332254fbb959f0db (diff)
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 <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'xmloff/source/draw/shapeexport.cxx')
-rw-r--r--xmloff/source/draw/shapeexport.cxx11
1 files changed, 11 insertions, 0 deletions
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 <com/sun/star/document/XStorageBasedDocument.hpp>
#include <comphelper/classids.hxx>
+#include <comphelper/graphicmimetype.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/storagehelper.hxx>
@@ -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<io::XInputStream> 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() )