[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sc/qa sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 20 04:26:39 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 7a0cad5a5667406b37b9ad6ec1e86d79784ce0ee
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Aug 15 12:35:30 2018 +0300
Commit:     Aron Budea <aron.budea at collabora.com>
CommitDate: Mon Aug 20 06:26:18 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.
    
    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)
    
    Change-Id: I3f13aa0b3ae8dc41ec28eaa1416d536469c4562a
    Reviewed-on: https://gerrit.libreoffice.org/59166
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Aron Budea <aron.budea at 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 916eea9229c1..2370836399a8 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -206,6 +206,8 @@ public:
     void testHiddenRepeatedRowsODS();
     void testHyperlinkTargetFrameODS();
 
+    void testTdf118990();
+
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
     CPPUNIT_TEST(testTdf111876);
@@ -311,6 +313,8 @@ public:
     CPPUNIT_TEST(testHiddenRepeatedRowsODS);
     CPPUNIT_TEST(testHyperlinkTargetFrameODS);
 
+    CPPUNIT_TEST(testTdf118990);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3996,6 +4000,35 @@ void ScExportTest::testHyperlinkTargetFrameODS()
     CPPUNIT_ASSERT_EQUAL(OUString("_blank"), aTargetFrameExport);
 }
 
+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 29523aa81c9d..b79815d67781 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();
 


More information about the Libreoffice-commits mailing list