[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sc/qa svl/qa tools/qa tools/source ucb/Library_ucpfile1.mk ucb/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 22 20:30:27 UTC 2019


 sc/qa/unit/subsequent_export-test.cxx |   10 ++++++++--
 svl/qa/unit/test_URIHelper.cxx        |    5 +++++
 tools/qa/cppunit/test_urlobj.cxx      |   34 +++++++++++++++++++++++++++++-----
 tools/source/fsys/urlobj.cxx          |   11 +++++++++++
 ucb/Library_ucpfile1.mk               |    1 -
 ucb/source/ucp/file/prov.cxx          |   19 -------------------
 6 files changed, 53 insertions(+), 27 deletions(-)

New commits:
commit 4b951ba18019b3c5daeb692d812b4b98fc2029e4
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Nov 21 17:52:01 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Nov 22 21:29:44 2019 +0100

    tdf#128598: Revert "Move dubious file: -> smb: conversion from...
    
    INetURLObject to file UCP"
    
    It turns out that there is lots of code in and around e.g.
    SfxMedium::LockOrigFileOnDemand (sfx2/source/doc/docfile.cxx) that treats
    document URLs non-generically and treats file URLs specially.  That means that
    it does not work to transparently rewrite a file URL as an smb URL in the
    underlying UCB layer.  So for libreoffice-6-4 revert the change again.  (For
    master towards LO 6.5, I plan to instead completely drop the feature of silently
    treating certain forms of file URLs on Linux as smb URLs.)
    
    This reverts commit 46c645bf4e9909f5296e75028f1f5434e83942d2.
    
    Change-Id: I94ac0637115bea36924099951efd8542854a727d
    Reviewed-on: https://gerrit.libreoffice.org/83396
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/83411
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index e8d4978259b4..35ccd32d0fe1 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -4189,12 +4189,18 @@ void ScExportTest::testTdf118990()
     // 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,'file://192.168.1.1/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)",
+                         "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,'file://NETWORKHOST/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)",
+                         "VLOOKUP(B1,'" TDF118990_SCHEME "//NETWORKHOST/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)",
                          "Wrong Windows share (using hostname) URL in A3");
 
     xDocSh->DoClose();
diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx
index a30de1540af9..233b812a54c7 100644
--- a/svl/qa/unit/test_URIHelper.cxx
+++ b/svl/qa/unit/test_URIHelper.cxx
@@ -300,7 +300,12 @@ void Test::testFindFirstURLInText() {
           "ftp://bla.bla.bla/blubber/", 3, 29 },
         { "..\\ftp://bla.bla.bla/blubber/...", nullptr, 0, 0 },
         { "..\\ftp:\\\\bla.bla.bla\\blubber/...",
+//Sync with tools/source/fsys/urlobj.cxx and changeScheme
+#ifdef LINUX
+          "smb://bla.bla.bla/blubber%2F", 7, 29 },
+#else
           "file://bla.bla.bla/blubber%2F", 7, 29 },
+#endif
         { "http://sun.com", "http://sun.com/", 0, 14 },
         { "http://sun.com/", "http://sun.com/", 0, 15 },
         { "http://www.xerox.com@www.pcworld.com/go/3990332.htm", nullptr, 0, 0 },
diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx
index 2c391fbf513d..581a19478e67 100644
--- a/tools/qa/cppunit/test_urlobj.cxx
+++ b/tools/qa/cppunit/test_urlobj.cxx
@@ -49,7 +49,11 @@ namespace tools_urlobj
         void urlobjTest_001(  )
         {
             INetURLObject aUrl( OUString( "file://10.10.1.1/sampledir/sample.file" ) );
-            CPPUNIT_ASSERT_EQUAL(INetProtocol::File, aUrl.GetProtocol());
+#ifdef LINUX
+            CPPUNIT_ASSERT_EQUAL(OUString("smb://10.10.1.1/sampledir/sample.file"),
+                                 aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
+#endif
             CPPUNIT_ASSERT_EQUAL(OUString("10.10.1.1"),
                                  aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
             CPPUNIT_ASSERT_EQUAL(OUString("/sampledir/sample.file"),
@@ -66,7 +70,11 @@ namespace tools_urlobj
             aUrl.
                 setFSysPath( "\\\\137.65.170.24\\c$\\Img0001.jpg",
                              FSysStyle::Detect );
-            CPPUNIT_ASSERT_EQUAL(INetProtocol::File, aUrl.GetProtocol());
+#ifdef LINUX
+            CPPUNIT_ASSERT_EQUAL(OUString("smb://137.65.170.24/c$/Img0001.jpg"),
+                                 aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
+#endif
             CPPUNIT_ASSERT_EQUAL(OUString("137.65.170.24"),
                                  aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
             CPPUNIT_ASSERT_EQUAL(OUString("/c$/Img0001.jpg"),
@@ -83,7 +91,11 @@ namespace tools_urlobj
             aUrl.
                 setFSysPath( "\\\\hive-winxp-x86\\pmladek\\test2.odt",
                              FSysStyle::Detect );
-            CPPUNIT_ASSERT_EQUAL(INetProtocol::File, aUrl.GetProtocol());
+#ifdef LINUX
+            CPPUNIT_ASSERT_EQUAL(OUString("smb://hive-winxp-x86/pmladek/test2.odt"),
+                                 aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
+#endif
             CPPUNIT_ASSERT_EQUAL(OUString("hive-winxp-x86"),
                                  aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
             CPPUNIT_ASSERT_EQUAL(OUString("/pmladek/test2.odt"),
@@ -93,7 +105,11 @@ namespace tools_urlobj
         void urlobjTest_004(  )
         {
             INetURLObject aUrl( OUString( "smb://10.10.1.1/sampledir/sample.file" ) );
+#ifdef LINUX
+            CPPUNIT_ASSERT_EQUAL(OUString("smb://10.10.1.1/sampledir/sample.file"),
+                                 aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE));
             CPPUNIT_ASSERT_EQUAL( INetProtocol::Smb, aUrl.GetProtocol(  ) );
+#endif
             CPPUNIT_ASSERT_EQUAL(OUString("10.10.1.1"),
                                  aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
             CPPUNIT_ASSERT_EQUAL(OUString("/sampledir/sample.file"),
@@ -108,7 +124,11 @@ namespace tools_urlobj
             INetURLObject aUrl;
             aUrl.setFSysPath( "//137.65.170.24/c$/Img0001.jpg",
                               FSysStyle::Detect );
-            CPPUNIT_ASSERT_EQUAL(INetProtocol::File, aUrl.GetProtocol());
+#ifdef LINUX
+            CPPUNIT_ASSERT_EQUAL(OUString("smb://137.65.170.24/c$/Img0001.jpg"),
+                                 aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
+#endif
             CPPUNIT_ASSERT_EQUAL(OUString("137.65.170.24"),
                                  aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
             CPPUNIT_ASSERT_EQUAL(OUString("/c$/Img0001.jpg"),
@@ -124,7 +144,11 @@ namespace tools_urlobj
             INetURLObject aUrl;
             aUrl.setFSysPath( "//hive-winxp-x86/pmladek/test2.odt",
                               FSysStyle::Detect );
-            CPPUNIT_ASSERT_EQUAL(INetProtocol::File, aUrl.GetProtocol());
+#ifdef LINUX
+            CPPUNIT_ASSERT_EQUAL(OUString("smb://hive-winxp-x86/pmladek/test2.odt"),
+                                 aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
+#endif
             CPPUNIT_ASSERT_EQUAL(OUString("hive-winxp-x86"),
                                  aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
             CPPUNIT_ASSERT_EQUAL(OUString("/pmladek/test2.odt"),
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 7ee92a3382b6..84627e501e1d 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1442,6 +1442,17 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
 
     m_aAbsURIRef = aSynAbsURIRef;
 
+    // At this point references of type "\\server\paths" have
+    // been converted to file:://server/path".
+#ifdef LINUX
+    if (m_eScheme==INetProtocol::File && !m_aHost.isEmpty()) {
+        // Change "file:://server/path" URIs to "smb:://server/path" on
+        // Linux
+        // Leave "file::path" URIs unchanged.
+        changeScheme(INetProtocol::Smb);
+    }
+#endif
+
     return true;
 }
 
diff --git a/ucb/Library_ucpfile1.mk b/ucb/Library_ucpfile1.mk
index f676eacbde3f..4505708cbac8 100644
--- a/ucb/Library_ucpfile1.mk
+++ b/ucb/Library_ucpfile1.mk
@@ -21,7 +21,6 @@ $(eval $(call gb_Library_use_libraries,ucpfile1,\
 	cppu \
 	cppuhelper \
 	sal \
-	tl \
 	ucbhelper \
 ))
 
diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index 368876d90540..4558a52b1f0d 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -21,8 +21,6 @@
 #include <osl/file.hxx>
 #include <osl/socket.h>
 #include <sal/log.hxx>
-#include <tools/urlobj.hxx>
-#include <ucbhelper/content.hxx>
 #include <cppuhelper/queryinterface.hxx>
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -172,24 +170,7 @@ FileProvider::queryContent(
                                               aUnc );
 
     if(  err )
-    {
-        // Hack to retry file://<host>/... URLs as smb URLs:
-        INetURLObject url(xIdentifier->getContentIdentifier());
-        if (url.GetProtocol() == INetProtocol::File
-            && !url.GetHost(INetURLObject::DecodeMechanism::NONE).isEmpty())
-        {
-            url.changeScheme(INetProtocol::Smb);
-            ucbhelper::Content content;
-            if (ucbhelper::Content::create(
-                    url.GetMainURL(INetURLObject::DecodeMechanism::NONE),
-                    css::uno::Reference<css::ucb::XCommandEnvironment>(), m_xContext, content))
-            {
-                return content.get();
-            }
-        }
-
         throw IllegalIdentifierException( THROW_WHERE );
-    }
 
     return Reference< XContent >( new BaseContent( m_pMyShell.get(), xIdentifier, aUnc ) );
 }


More information about the Libreoffice-commits mailing list