[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Mar 7 11:27:04 UTC 2018
sw/qa/extras/htmlimport/htmlimport.cxx | 15 ++++++++++++++-
sw/source/filter/html/htmlplug.cxx | 10 +++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
New commits:
commit 16605d0cdc2c15ab4ae175531ba52824bf52bc70
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Mar 7 11:35:12 2018 +0100
sw XHTML import: handle media type of OLE object data
For both the native data and the replacement image.
Change-Id: I590fa037f78fe1a4dca41ec4173670f554bb9c6c
Reviewed-on: https://gerrit.libreoffice.org/50876
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 7cdf5f45dc1e..23017e40a79b 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -14,6 +14,7 @@
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
#include <tools/datetime.hxx>
#include <unotools/datetime.hxx>
#include <vcl/GraphicNativeTransform.hxx>
@@ -315,7 +316,8 @@ DECLARE_HTMLIMPORT_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
uno::Reference<document::XEmbeddedObjectSupplier2> xObject(xObjects->getByIndex(0),
uno::UNO_QUERY);
// This failed, OLE object had no replacement image.
- CPPUNIT_ASSERT(xObject->getReplacementGraphic().is());
+ uno::Reference<graphic::XGraphic> xGraphic = xObject->getReplacementGraphic();
+ CPPUNIT_ASSERT(xGraphic.is());
uno::Reference<drawing::XShape> xShape(xObject, uno::UNO_QUERY);
OutputDevice* pDevice = Application::GetDefaultDevice();
@@ -325,6 +327,17 @@ DECLARE_HTMLIMPORT_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
awt::Size aSize = xShape->getSize();
// This was only 1247, size was not set explicitly.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aLogic.getWidth()), aSize.Width);
+
+ // Check mime/media types.
+ CPPUNIT_ASSERT_EQUAL(OUString("image/png"), getProperty<OUString>(xGraphic, "MimeType"));
+
+ uno::Reference<document::XStorageBasedDocument> xStorageProvider(mxComponent, uno::UNO_QUERY);
+ uno::Reference<embed::XStorage> xStorage = xStorageProvider->getDocumentStorage();
+ auto aStreamName = getProperty<OUString>(xObject, "StreamName");
+ uno::Reference<io::XStream> xStream
+ = xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
+ // This was empty.
+ CPPUNIT_ASSERT_EQUAL(OUString("text/rtf"), getProperty<OUString>(xStream, "MediaType"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index ca7219baa8d8..83d04d3bfa1c 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -433,7 +433,7 @@ void SwHTMLParser::InsertEmbed()
if (GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURLObj) != ERRCODE_NONE)
return;
- rObj.SetGraphic(aGraphic, OUString());
+ rObj.SetGraphic(aGraphic, aType);
// Set the size of the OLE frame to the size of the graphic.
OutputDevice* pDevice = Application::GetDefaultDevice();
@@ -496,6 +496,14 @@ void SwHTMLParser::InsertEmbed()
uno::Reference<io::XStream> xOutStream
= xStorage->openStreamElement(aObjName, embed::ElementModes::READWRITE);
comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream->getOutputStream());
+
+ if (!aType.isEmpty())
+ {
+ // Set media type of the native data.
+ uno::Reference<beans::XPropertySet> xOutStreamProps(xOutStream, uno::UNO_QUERY);
+ if (xOutStreamProps.is())
+ xOutStreamProps->setPropertyValue("MediaType", uno::makeAny(aType));
+ }
}
xObj = aCnt.GetEmbeddedObject(aObjName);
}
More information about the Libreoffice-commits
mailing list