diff options
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 10 | ||||
-rw-r--r-- | svl/qa/unit/test_URIHelper.cxx | 5 | ||||
-rw-r--r-- | tools/qa/cppunit/test_urlobj.cxx | 10 | ||||
-rw-r--r-- | tools/source/fsys/urlobj.cxx | 11 | ||||
-rw-r--r-- | ucb/Library_ucpfile1.mk | 1 | ||||
-rw-r--r-- | ucb/source/ucp/file/prov.cxx | 19 |
6 files changed, 33 insertions, 23 deletions
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index e9ad4b5eade4..b67dcd50aac5 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -4223,12 +4223,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 e4dfbb9dd939..11b7d0359b2a 100644 --- a/svl/qa/unit/test_URIHelper.cxx +++ b/svl/qa/unit/test_URIHelper.cxx @@ -295,7 +295,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 0e25decab713..127e01067ec8 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"), @@ -63,7 +67,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"), diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index e07cfd04035e..64daa11c9415 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1445,6 +1445,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 7c5c66e23e6e..9a7052e17304 100644 --- a/ucb/source/ucp/file/prov.cxx +++ b/ucb/source/ucp/file/prov.cxx @@ -20,8 +20,6 @@ #include <osl/security.hxx> #include <osl/file.hxx> #include <osl/socket.h> -#include <tools/urlobj.hxx> -#include <ucbhelper/content.hxx> #include <cppuhelper/queryinterface.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -170,24 +168,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 ) ); } |