[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Mar 8 17:36:28 UTC 2018
sw/qa/extras/htmlexport/htmlexport.cxx | 10 +++++-----
sw/source/filter/html/htmlflywriter.cxx | 12 ++++++++++++
sw/source/filter/html/htmlplug.cxx | 9 ++++++++-
3 files changed, 25 insertions(+), 6 deletions(-)
New commits:
commit ad628045f62b0656c58d2e195e33186c055c2196
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 8 14:58:01 2018 +0100
sw XHTML export: handle media type for OLE objects
Both native data and replacement graphic.
Change-Id: I2f89493e56e9d22a54aa3e4175d8b750c33d98f0
Reviewed-on: https://gerrit.libreoffice.org/50964
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index e3c1f33321bb..2f9ff7dbbf07 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -379,10 +379,6 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
// This was only 1247, size was not set explicitly.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aLogic.getWidth()), aSize.Width);
- if (mbExported)
- // The below is not yet working for export.
- return;
-
// Check mime/media types.
CPPUNIT_ASSERT_EQUAL(OUString("image/png"), getProperty<OUString>(xGraphic, "MimeType"));
@@ -391,9 +387,13 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
auto aStreamName = getProperty<OUString>(xObject, "StreamName");
uno::Reference<io::XStream> xStream
= xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
- // This was empty.
+ // This was empty when either import or export handling was missing.
CPPUNIT_ASSERT_EQUAL(OUString("text/rtf"), getProperty<OUString>(xStream, "MediaType"));
+ if (mbExported)
+ // The below is not yet working for export.
+ return;
+
// Check alternate text (it was empty).
CPPUNIT_ASSERT_EQUAL(OUString("OLE Object"), getProperty<OUString>(xObject, "Title").trim());
}
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index de06ac48a199..ba9a62260543 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1385,6 +1385,18 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
aHtml.attribute(aAttribute, sBuffer.makeStringAndClear().getStr());
}
+ if (nFrameOpts & HtmlFrmOpts::Replacement)
+ {
+ // Handle XHTML type attribute for OLE replacement images.
+ uno::Reference<beans::XPropertySet> xGraphic(rGraphic.GetXGraphic(), uno::UNO_QUERY);
+ if (xGraphic.is())
+ {
+ OUString aMimeType;
+ xGraphic->getPropertyValue("MimeType") >>= aMimeType;
+ aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_type, aMimeType.toUtf8());
+ }
+ }
+
// Events
if (SfxItemState::SET == rItemSet.GetItemState(RES_FRMMACRO, true, &pItem))
{
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 4d272872aa8f..7ad6b589e2b3 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -1424,12 +1424,19 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
comphelper::OStorageHelper::CopyInputToOutput(xInStream->getInputStream(),
xOutStream->getOutputStream());
aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
+ uno::Reference<beans::XPropertySet> xOutStreamProps(xInStream, uno::UNO_QUERY);
+ OUString aFileType;
+ if (xOutStreamProps.is())
+ xOutStreamProps->getPropertyValue("MediaType") >>= aFileType;
// Refer to this data.
if (rHTMLWrt.m_bLFPossible)
rHTMLWrt.OutNewLine();
rWrt.Strm().WriteOString("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object);
- rWrt.Strm().WriteOString(" data=\"" + aFileName.toUtf8() + "\">");
+ rWrt.Strm().WriteOString(" data=\"" + aFileName.toUtf8() + "\"");
+ if (!aFileType.isEmpty())
+ rWrt.Strm().WriteOString(" type=\"" + aFileType.toUtf8() + "\"");
+ rWrt.Strm().WriteOString(">");
bObjectOpened = true;
rHTMLWrt.m_bLFPossible = true;
}
More information about the Libreoffice-commits
mailing list