[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Mar 8 12:36:52 UTC 2018
sw/qa/extras/htmlexport/data/reqif-ole-data.ole | 1
sw/qa/extras/htmlexport/htmlexport.cxx | 11 +++++
sw/qa/extras/htmlimport/htmlimport.cxx | 9 ----
sw/qa/extras/inc/swmodeltestbase.hxx | 17 ++++++++
sw/source/filter/html/htmlplug.cxx | 47 ++++++++++++++++++++++++
5 files changed, 76 insertions(+), 9 deletions(-)
New commits:
commit ae510e67cdc644c541ffa26b2f91bba71a9856d2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 8 12:10:14 2018 +0100
sw XHTML export: handle native data of OLE objects
Write the native data and refer it from the XHTML stream.
Change-Id: I8952ed07108ddc92b1d136bd9af6f21d3ed604f0
Reviewed-on: https://gerrit.libreoffice.org/50941
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/htmlexport/data/reqif-ole-data.ole b/sw/qa/extras/htmlexport/data/reqif-ole-data.ole
new file mode 100644
index 000000000000..d3dc23d793e2
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/reqif-ole-data.ole
@@ -0,0 +1 @@
+{\pict}
diff --git a/sw/qa/extras/htmlimport/data/reqif-ole-data.xhtml b/sw/qa/extras/htmlexport/data/reqif-ole-data.xhtml
similarity index 100%
rename from sw/qa/extras/htmlimport/data/reqif-ole-data.xhtml
rename to sw/qa/extras/htmlexport/data/reqif-ole-data.xhtml
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 968533eb1973..796134ee7e5d 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -346,6 +346,17 @@ DECLARE_HTMLEXPORT_TEST(testReqIfParagraph, "reqif-p.xhtml")
CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
}
+DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleData, "reqif-ole-data.xhtml")
+{
+ uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xObjects(xSupplier->getEmbeddedObjects(),
+ uno::UNO_QUERY);
+ // This was 0, <object> without URL was ignored.
+ // Then this was 0 on export, as data of OLE nodes was ignored.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xObjects->getCount());
+}
+
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index e01870143888..aa39299a9660 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -295,15 +295,6 @@ DECLARE_HTMLIMPORT_TEST(testReqIfBr, "reqif-br.xhtml")
CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("aaa\nbbb"));
}
-DECLARE_HTMLIMPORT_TEST(testReqIfOleData, "reqif-ole-data.xhtml")
-{
- uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xObjects(xSupplier->getEmbeddedObjects(),
- uno::UNO_QUERY);
- // This was 0, <object> without URL was ignored.
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xObjects->getCount());
-}
-
DECLARE_HTMLIMPORT_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
{
uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 1ac89119a6b4..b4b39aad7f27 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -739,6 +739,23 @@ protected:
{
setTestInteractionHandler(pPassword, aFilterOptions);
}
+
+ if (!maImportFilterOptions.isEmpty())
+ {
+ beans::PropertyValue aValue;
+ aValue.Name = "FilterOptions";
+ aValue.Value <<= maImportFilterOptions;
+ aFilterOptions.push_back(aValue);
+ }
+
+ if (!maImportFilterName.isEmpty())
+ {
+ beans::PropertyValue aValue;
+ aValue.Name = "FilterName";
+ aValue.Value <<= maImportFilterName;
+ aFilterOptions.push_back(aValue);
+ }
+
mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument", comphelper::containerToSequence(aFilterOptions));
if (pPassword)
{
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 83d04d3bfa1c..938411e2b4e8 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -1392,6 +1392,48 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
}
Graphic aGraphic( *pOLENd->GetGraphic() );
+
+ SwDocShell* pDocSh = rHTMLWrt.pDoc->GetDocShell();
+ bool bObjectOpened = false;
+ if (rHTMLWrt.mbXHTML && pDocSh)
+ {
+ // Map native data to an outer <object> element.
+
+ // Calculate the file name, which is meant to be the same as the
+ // replacement image, just with a .ole extension.
+ OUString aFileName;
+ if (rHTMLWrt.GetOrigFileName())
+ aFileName = *rHTMLWrt.GetOrigFileName();
+ INetURLObject aURL(aFileName);
+ OUString aName(aURL.getBase());
+ aName += "_";
+ aName += aURL.getExtension();
+ aName += "_";
+ aName += OUString::number(aGraphic.GetChecksum(), 16);
+ aURL.setBase(aName);
+ aURL.setExtension("ole");
+ aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+
+ // Write the data.
+ OUString aStreamName = pOLENd->GetOLEObj().GetCurrentPersistName();
+ uno::Reference<embed::XStorage> xStorage = pDocSh->GetStorage();
+ uno::Reference<io::XStream> xInStream
+ = xStorage->openStreamElement(aStreamName, embed::ElementModes::READ);
+ SvFileStream aOutStream(aFileName, StreamMode::WRITE);
+ uno::Reference<io::XStream> xOutStream(new utl::OStreamWrapper(aOutStream));
+ comphelper::OStorageHelper::CopyInputToOutput(xInStream->getInputStream(),
+ xOutStream->getOutputStream());
+ aFileName = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aFileName);
+
+ // 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() + "\">");
+ bObjectOpened = true;
+ rHTMLWrt.m_bLFPossible = true;
+ }
+
OUString aGraphicURL;
if(!rHTMLWrt.mbEmbedImages)
{
@@ -1419,6 +1461,11 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
pOLENd->GetTitle(), pOLENd->GetTwipSize(),
nFlags, "ole" );
+ if (bObjectOpened)
+ // Close native data.
+ rWrt.Strm().WriteOString("</" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object
+ ">");
+
return rWrt;
}
More information about the Libreoffice-commits
mailing list