[Libreoffice-commits] core.git: include/tools tools/qa tools/source
Giuseppe Castagno
giuseppe.castagno at acca-esse.eu
Mon Oct 5 04:11:51 PDT 2015
include/tools/urlobj.hxx | 11 ++++++++++
tools/qa/cppunit/test_urlobj.cxx | 40 +++++++++++++++++++++++++++++++++++++++
tools/source/fsys/urlobj.cxx | 16 +++++++++++++++
3 files changed, 67 insertions(+)
New commits:
commit 8ea85c264f22c76d393c0f78e9db7df51e2c868d
Author: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
Date: Sun Aug 30 20:24:39 2015 +0200
Add isSchemeEqualTo(), isAnyKnownWebDAVScheme() to INetURLObject
...which will be used when rebasing
<https://gerrit.libreoffice.org/#/c/17189>
"tdf#82744: fix WebDAV lock/unlock behaviour - part 3" on top of
d3de490437df4c9093f32e97fc185066d64c0f46
"Add vnd.sun.star.webdavs URL scheme."
Change-Id: I19bd715d755a6f070b95ce897d8a1bbb4910d537
Reviewed-on: https://gerrit.libreoffice.org/18151
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx
index 7778666..d487851 100644
--- a/include/tools/urlobj.hxx
+++ b/include/tools/urlobj.hxx
@@ -390,6 +390,17 @@ public:
inline INetProtocol GetProtocol() const { return m_eScheme; }
+ bool isSchemeEqualTo(INetProtocol scheme) const { return scheme == m_eScheme; }
+
+ bool isSchemeEqualTo(OUString const & scheme) const;
+
+ /** Check if the scheme is one of the WebDAV scheme
+ * we know about.
+ *
+ * @return true is one othe scheme either public scheme or private scheme.
+ */
+ bool isAnyKnownWebDAVScheme() const;
+
/** Return the URL 'prefix' for a given scheme.
@param eTheScheme One of the supported URL schemes.
diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx
index b591156..6115bc8 100644
--- a/tools/qa/cppunit/test_urlobj.cxx
+++ b/tools/qa/cppunit/test_urlobj.cxx
@@ -329,6 +329,44 @@ namespace tools_urlobj
CPPUNIT_ASSERT(strm == 0);
}
+ void urlobjTest_isSchemeEqualTo() {
+ CPPUNIT_ASSERT(INetURLObject().isSchemeEqualTo(INetProtocol::NotValid));
+ CPPUNIT_ASSERT(!INetURLObject().isSchemeEqualTo(""));
+ CPPUNIT_ASSERT(
+ INetURLObject("http://example.org").isSchemeEqualTo(
+ INetProtocol::Http));
+ CPPUNIT_ASSERT(
+ !INetURLObject("http://example.org").isSchemeEqualTo(
+ INetProtocol::Https));
+ CPPUNIT_ASSERT(
+ INetURLObject("http://example.org").isSchemeEqualTo("Http"));
+ CPPUNIT_ASSERT(
+ !INetURLObject("http://example.org").isSchemeEqualTo("dav"));
+ CPPUNIT_ASSERT(
+ INetURLObject("dav://example.org").isSchemeEqualTo("dav"));
+ }
+
+ void urlobjTest_isAnyKnownWebDAVScheme() {
+ CPPUNIT_ASSERT(
+ INetURLObject("http://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ INetURLObject("https://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ INetURLObject("vnd.sun.star.webdav://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ INetURLObject("vnd.sun.star.webdavs://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ !INetURLObject("ftp://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ !INetURLObject("file://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ !INetURLObject("dav://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ !INetURLObject("davs://example.org").isAnyKnownWebDAVScheme());
+ CPPUNIT_ASSERT(
+ !INetURLObject("vnd.sun.star.pkg://example.org").isAnyKnownWebDAVScheme());
+ }
+
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
@@ -343,6 +381,8 @@ namespace tools_urlobj
CPPUNIT_TEST( urlobjCmisTest );
CPPUNIT_TEST( urlobjTest_emptyPath );
CPPUNIT_TEST( urlobjTest_data );
+ CPPUNIT_TEST( urlobjTest_isSchemeEqualTo );
+ CPPUNIT_TEST( urlobjTest_isAnyKnownWebDAVScheme );
CPPUNIT_TEST_SUITE_END( );
}; // class createPool
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 51887b7..115d676 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -3911,6 +3911,22 @@ OUString INetURLObject::getExternalURL(DecodeMechanism eMechanism,
return aTheExtURIRef;
}
+bool INetURLObject::isSchemeEqualTo(OUString const & scheme) const {
+ return m_aScheme.isPresent()
+ && (rtl_ustr_compareIgnoreAsciiCase_WithLength(
+ scheme.getStr(), scheme.getLength(),
+ m_aAbsURIRef.getStr() + m_aScheme.getBegin(),
+ m_aScheme.getLength())
+ == 0);
+}
+
+bool INetURLObject::isAnyKnownWebDAVScheme() const {
+ return ( isSchemeEqualTo( INetProtocol::Http ) ||
+ isSchemeEqualTo( INetProtocol::Https ) ||
+ isSchemeEqualTo( INetProtocol::VndSunStarWebdav ) ||
+ isSchemeEqualTo( "vnd.sun.star.webdavs" ) );
+}
+
// static
OUString INetURLObject::GetScheme(INetProtocol eTheScheme)
{
More information about the Libreoffice-commits
mailing list