diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-05-04 10:48:07 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-05-04 11:27:54 +0200 |
commit | 800085d4fb0831f2065e86bfd99164cd89998fcd (patch) | |
tree | 2c72fb49fcc07692bc999dfeab5dde4e9fd47ec8 /sw | |
parent | f3fc0116ff5258bdee68518ae3ae53f59e8dbbd5 (diff) |
sw reqif-xhtml import, embedded objects: handle Ole10Native stream
This is the import side of commit
1392fd6a7eaf9f507639096984c2a0108f254795 (sw reqif-xhtml export,
embedded objects: handle Ole10Native stream, 2020-04-30).
Change-Id: Ib98620f06c471a58e75b0e6c0230d37820dbc928
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93402
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_htmlexport.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_htmlexport.mk b/sw/CppunitTest_sw_htmlexport.mk index c85c5b8212cd..f1e2342ad1ba 100644 --- a/sw/CppunitTest_sw_htmlexport.mk +++ b/sw/CppunitTest_sw_htmlexport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_htmlexport, \ msfilter \ sal \ sfx \ + sot \ sw \ svt \ test \ diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 54334aade9f5..d05da8ad4943 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -32,6 +32,7 @@ #include <rtl/strbuf.hxx> #include <svtools/rtftoken.h> #include <filter/msfilter/rtfutil.hxx> +#include <sot/storage.hxx> class HtmlExportTest : public SwModelTestBase, public HtmlTestTools { @@ -1019,6 +1020,36 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOle1PDF) // i.e. we did not work with the Ole10Native stream, rather created an OLE1 wrapper around the // OLE1-in-OLE2 data, resulting in additional size. CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0x99ed), nData); + + // Now import this back and check the ODT result. + mxComponent->dispose(); + mxComponent.clear(); + uno::Sequence<beans::PropertyValue> aLoadProperties = { + comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), + comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), + }; + mxComponent + = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument", aLoadProperties); + xStorable.set(mxComponent, uno::UNO_QUERY); + utl::TempFile aTempFile; + aStoreProperties = { + comphelper::makePropertyValue("FilterName", OUString("writer8")), + }; + xStorable->storeToURL(aTempFile.GetURL(), aStoreProperties); + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess + = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), + aTempFile.GetURL()); + uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("Object 2"), + uno::UNO_QUERY); + std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + tools::SvRef<SotStorage> pStorage = new SotStorage(*pStream); + tools::SvRef<SotStorageStream> pOleNative = pStorage->OpenSotStream("\1Ole10Native"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 39409 + // - Actual : 0 + // i.e. we didn't handle the case when the ole1 payload was not an ole2 container. Note how the + // expected value is the same as nData above + 4 bytes, since this data is length-prefixed. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(39409), pOleNative->GetSize()); } CPPUNIT_PLUGIN_IMPLEMENT(); |