sc/qa/unit/data/xlsx/tdf118990.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 33 +++++++++++++++++++++++++++++++++ sc/source/filter/excel/xecontent.cxx | 3 ++- 3 files changed, 35 insertions(+), 1 deletion(-)
New commits: commit f24b0ec13c5c8edda5ffb1336b0eb6da173dfc97 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Aug 15 12:35:30 2018 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Aug 15 18:56:50 2018 +0200 tdf#118990: use full URI for absolute references Previously (since commit 7eb5e135422f1a5830a44d129300bc3fafb4627d) only path relative to reference host was stored, and host itself was dropped. That resulted in URIs like "/share/file.xlsx", even without scheme. For Windows shares, this broke UNC paths like "\\HOSTNAME\share\file.xlsx" (which are stored in XLSX by Excel as "file:///\\HOSTNAME\share\file.xlsx"), and on subsequent import, this resulted in paths on the same drive as the document (like "C:\share\file.xlsx"). With this change, we will store "file://HOSTNAME/share/file.xlsx", which is correctly processed by both LibreOffice and MS Excel. Change-Id: I3f13aa0b3ae8dc41ec28eaa1416d536469c4562a Reviewed-on: https://gerrit.libreoffice.org/59064 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/qa/unit/data/xlsx/tdf118990.xlsx b/sc/qa/unit/data/xlsx/tdf118990.xlsx new file mode 100644 index 000000000000..b680edceef0e Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf118990.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index bb134b0b1d1e..56546a588789 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -211,6 +211,8 @@ public: void testOpenDocumentAsReadOnly(); void testKeepSettingsOfBlankRows(); + void testTdf118990(); + CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); CPPUNIT_TEST(testTdf111876); @@ -320,6 +322,8 @@ public: CPPUNIT_TEST(testOpenDocumentAsReadOnly); CPPUNIT_TEST(testKeepSettingsOfBlankRows); + CPPUNIT_TEST(testTdf118990); + CPPUNIT_TEST_SUITE_END(); private: @@ -4064,6 +4068,35 @@ void ScExportTest::testKeepSettingsOfBlankRows() assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 2); } +void ScExportTest::testTdf118990() +{ + ScDocShellRef xDocSh = loadDoc("tdf118990.", FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + xDocSh = saveAndReload(xDocSh.get(), FORMAT_XLSX); + ScDocument& rDoc = xDocSh->GetDocument(); + + // TODO: also test A1, which contains a UNC reference to \\localhost\share\lookupsource.xlsx, + // but currently looses "localhost" part when normalized in INetURLObject, becoming + // file:///share/lookupsource.xlsx - which is incorrect, since it points to local filesystem + // and not to Windows network share. + +#if defined LINUX // following INetURLObject::setAbsURIRef +#define TDF118990_SCHEME "smb:" +#else // for Windows and macOS +#define TDF118990_SCHEME "file:" +#endif + + ASSERT_FORMULA_EQUAL(rDoc, ScAddress(0, 1, 0), + "VLOOKUP(B1,'" TDF118990_SCHEME "//192.168.1.1/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)", + "Wrong Windows share (using host IP) URL in A2"); + + ASSERT_FORMULA_EQUAL(rDoc, ScAddress(0, 2, 0), + "VLOOKUP(B1,'" TDF118990_SCHEME "//NETWORKHOST/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)", + "Wrong Windows share (using hostname) URL in A3"); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index cdc4269f144c..20217b48ef4e 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -459,7 +459,8 @@ OUString XclExpHyperlink::BuildFileName( sal_uInt16& rnLevel, bool& rbRel, const OUString& rUrl, const XclExpRoot& rRoot, bool bEncoded ) { INetURLObject aURLObject( rUrl ); - OUString aDosName( bEncoded ? aURLObject.GetURLPath() : aURLObject.getFSysPath( FSysStyle::Dos ) ); + OUString aDosName(bEncoded ? aURLObject.GetMainURL(INetURLObject::DecodeMechanism::ToIUri) + : aURLObject.getFSysPath(FSysStyle::Dos)); rnLevel = 0; rbRel = rRoot.IsRelUrl(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits