[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sc/qa sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 16 10:04:28 UTC 2018


 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 e9e18b5a3a0e9651b7161278a61c6a7ce0b9df0b
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 15 12:35:30 2018 +0300
Commit:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Thu Aug 16 12:04:04 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.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit f24b0ec13c5c8edda5ffb1336b0eb6da173dfc97)
    Reviewed-on: https://gerrit.libreoffice.org/59141
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.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 f4a1dac54de2..42921737b08a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -207,6 +207,8 @@ public:
     void testOpenDocumentAsReadOnly();
     void testKeepSettingsOfBlankRows();
 
+    void testTdf118990();
+
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
     CPPUNIT_TEST(testTdf111876);
@@ -314,6 +316,8 @@ public:
     CPPUNIT_TEST(testOpenDocumentAsReadOnly);
     CPPUNIT_TEST(testKeepSettingsOfBlankRows);
 
+    CPPUNIT_TEST(testTdf118990);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4022,6 +4026,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 aa92499f135b..2ab4cc9cc668 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -457,7 +457,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();
 


More information about the Libreoffice-commits mailing list