[Libreoffice-commits] core.git: ucb/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 22 18:00:55 UTC 2021


 ucb/source/ucp/hierarchy/hierarchydatasource.cxx |    9 +++++----
 ucb/source/ucp/hierarchy/hierarchydatasource.hxx |    3 ++-
 ucb/source/ucp/tdoc/tdoc_content.cxx             |   11 ++++++-----
 ucb/source/ucp/tdoc/tdoc_content.hxx             |   10 +++++++---
 ucb/source/ucp/tdoc/tdoc_provider.cxx            |    4 ++--
 ucb/source/ucp/tdoc/tdoc_provider.hxx            |    8 ++++++--
 ucb/source/ucp/webdav-neon/DAVProperties.cxx     |   16 ++++++++--------
 ucb/source/ucp/webdav-neon/DAVProperties.hxx     |    6 +++++-
 8 files changed, 41 insertions(+), 26 deletions(-)

New commits:
commit 7885c1cb80568930270e55b3ae450eccc66aca94
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 22 17:17:16 2021 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Sep 22 20:00:17 2021 +0200

    Extend loplugin:stringviewparam to starts/endsWith: ucb
    
    Change-Id: I086d02ec4a2ea6d4b439ec34665d8271a67c63dd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122472
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
index a74524e70f35..8e77576134bb 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
@@ -39,6 +39,7 @@
 #include <com/sun/star/util/XChangesBatch.hpp>
 #include <com/sun/star/util/XChangesNotifier.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <o3tl/string_view.hxx>
 #include <ucbhelper/macros.hxx>
 #include <mutex>
 
@@ -443,18 +444,18 @@ HierarchyDataSource::getConfigProvider()
 
 
 bool HierarchyDataSource::createConfigPath(
-                const OUString & rInPath, OUString & rOutPath )
+                std::u16string_view rInPath, OUString & rOutPath )
 {
-    if ( !rInPath.isEmpty() )
+    if ( !rInPath.empty() )
     {
-        if ( rInPath.startsWith( "/" ) )
+        if ( o3tl::starts_with( rInPath, u"/" ) )
         {
             OSL_FAIL( "HierarchyDataSource::createConfigPath - "
                         "Leading slash in node path!" );
             return false;
         }
 
-        if ( rInPath.endsWith( "/" ) )
+        if ( o3tl::ends_with( rInPath, u"/" ) )
         {
             OSL_FAIL( "HierarchyDataSource::createConfigPath - "
                         "Trailing slash in node path!" );
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
index 9806f98f8036..24b3a18491d6 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.hxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <cppuhelper/implbase.hxx>
 #include <memory>
+#include <string_view>
 
 namespace comphelper { class OInterfaceContainerHelper2; }
 
@@ -75,7 +76,7 @@ private:
 
     css::uno::Reference< css::lang::XMultiServiceFactory > getConfigProvider();
 
-    static bool createConfigPath( const OUString & rInPath, OUString & rOutPath );
+    static bool createConfigPath( std::u16string_view rInPath, OUString & rOutPath );
 };
 
 } // namespace hierarchy_ucp
diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx
index dcb800ee91c8..5a1335e1efc9 100644
--- a/ucb/source/ucp/tdoc/tdoc_content.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_content.cxx
@@ -28,6 +28,7 @@
 
 #include <string_view>
 
+#include <o3tl/string_view.hxx>
 #include <tools/diagnose_ex.h>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/beans/IllegalTypeException.hpp>
@@ -1709,7 +1710,7 @@ void Content::notifyDocumentClosed()
 
 
 uno::Reference< ucb::XContent >
-Content::queryChildContent( const OUString & rRelativeChildUri )
+Content::queryChildContent( std::u16string_view rRelativeChildUri )
 {
     osl::Guard< osl::Mutex > aGuard( m_aMutex );
 
@@ -1717,10 +1718,10 @@ Content::queryChildContent( const OUString & rRelativeChildUri )
     OUStringBuffer aBuf( aMyId );
     if ( !aMyId.endsWith("/") )
         aBuf.append( "/" );
-    if ( !rRelativeChildUri.startsWith("/") )
+    if ( !o3tl::starts_with(rRelativeChildUri, u"/") )
         aBuf.append( rRelativeChildUri );
     else
-        aBuf.append( rRelativeChildUri.subView(1) );
+        aBuf.append( rRelativeChildUri.substr(1) );
 
     uno::Reference< ucb::XContentIdentifier > xChildId
         = new ::ucbhelper::ContentIdentifier( aBuf.makeStringAndClear() );
@@ -1741,7 +1742,7 @@ Content::queryChildContent( const OUString & rRelativeChildUri )
 }
 
 
-void Content::notifyChildRemoved( const OUString & rRelativeChildUri )
+void Content::notifyChildRemoved( std::u16string_view rRelativeChildUri )
 {
     osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
 
@@ -1765,7 +1766,7 @@ void Content::notifyChildRemoved( const OUString & rRelativeChildUri )
 }
 
 
-void Content::notifyChildInserted( const OUString & rRelativeChildUri )
+void Content::notifyChildInserted( std::u16string_view rRelativeChildUri )
 {
     osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex );
 
diff --git a/ucb/source/ucp/tdoc/tdoc_content.hxx b/ucb/source/ucp/tdoc/tdoc_content.hxx
index 56117b1b0853..9a920c1bb376 100644
--- a/ucb/source/ucp/tdoc/tdoc_content.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_content.hxx
@@ -19,6 +19,10 @@
 
 #pragma once
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <ucbhelper/contenthelper.hxx>
 #include <com/sun/star/ucb/XContentCreator.hpp>
 #include "tdoc_provider.hxx"
@@ -190,7 +194,7 @@ private:
         const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv );
 
     css::uno::Reference< css::ucb::XContent >
-    queryChildContent( const OUString & rRelativeChildUri );
+    queryChildContent( std::u16string_view rRelativeChildUri );
 
     /// @throws css::ucb::CommandFailedException
     /// @throws css::task::DocumentPasswordRequest
@@ -266,8 +270,8 @@ public:
                        const OUString& rContentId );
 
     void notifyDocumentClosed();
-    void notifyChildRemoved( const OUString & rRelativeChildUri );
-    void notifyChildInserted( const OUString & rRelativeChildUri );
+    void notifyChildRemoved( std::u16string_view rRelativeChildUri );
+    void notifyChildInserted( std::u16string_view rRelativeChildUri );
 
     rtl::Reference< ContentProvider > getContentProvider() const
     { return rtl::Reference< ContentProvider >( m_pProvider ); }
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx
index 93d49ca2108b..23fd324a550b 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx
@@ -229,7 +229,7 @@ ContentProvider::createDocumentContent(
 
 
 // virtual
-void ContentProvider::notifyDocumentClosed( const OUString & rDocId )
+void ContentProvider::notifyDocumentClosed( std::u16string_view rDocId )
 {
     osl::MutexGuard aGuard( getContentListMutex() );
 
@@ -287,7 +287,7 @@ void ContentProvider::notifyDocumentClosed( const OUString & rDocId )
 
 
 // virtual
-void ContentProvider::notifyDocumentOpened( const OUString & rDocId )
+void ContentProvider::notifyDocumentOpened( std::u16string_view rDocId )
 {
     osl::MutexGuard aGuard( getContentListMutex() );
 
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.hxx b/ucb/source/ucp/tdoc/tdoc_provider.hxx
index 406252ff23d3..44bc239f7c6e 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.hxx
@@ -19,6 +19,10 @@
 
 #pragma once
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <rtl/ref.hxx>
 #include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
 #include <com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.hpp>
@@ -129,8 +133,8 @@ public:
     queryDocumentModel( const OUString & rUri ) const;
 
     // interface OfficeDocumentsEventListener
-    void notifyDocumentOpened( const OUString & rDocId );
-    void notifyDocumentClosed( const OUString & rDocId );
+    void notifyDocumentOpened( std::u16string_view rDocId );
+    void notifyDocumentClosed( std::u16string_view rDocId );
 
 private:
     rtl::Reference< OfficeDocumentsManager > m_xDocsMgr;
diff --git a/ucb/source/ucp/webdav-neon/DAVProperties.cxx b/ucb/source/ucp/webdav-neon/DAVProperties.cxx
index 575385f5d2d8..b1a4a0273ef8 100644
--- a/ucb/source/ucp/webdav-neon/DAVProperties.cxx
+++ b/ucb/source/ucp/webdav-neon/DAVProperties.cxx
@@ -35,38 +35,38 @@
 
 using namespace webdav_ucp;
 
-void DAVProperties::createNeonPropName( const OUString & rFullName,
+void DAVProperties::createNeonPropName( std::u16string_view rFullName,
                                         NeonPropName & rName )
 {
-    if ( rFullName.startsWith( "DAV:" ) )
+    if ( o3tl::starts_with( rFullName, u"DAV:" ) )
     {
         rName.nspace = "DAV:";
         rName.name
             = strdup( OUStringToOString(
-                        rFullName.subView( RTL_CONSTASCII_LENGTH( "DAV:" ) ),
+                        rFullName.substr( RTL_CONSTASCII_LENGTH( "DAV:" ) ),
                         RTL_TEXTENCODING_UTF8 ).getStr() );
     }
-    else if ( rFullName.startsWith( "http://apache.org/dav/props/" ) )
+    else if ( o3tl::starts_with( rFullName, u"http://apache.org/dav/props/" ) )
     {
         rName.nspace = "http://apache.org/dav/props/";
         rName.name
             = strdup( OUStringToOString(
-                        rFullName.subView(
+                        rFullName.substr(
                             RTL_CONSTASCII_LENGTH(
                                 "http://apache.org/dav/props/" ) ),
                         RTL_TEXTENCODING_UTF8 ).getStr() );
     }
-    else if ( rFullName.startsWith( "http://ucb.openoffice.org/dav/props/" ) )
+    else if ( o3tl::starts_with( rFullName, u"http://ucb.openoffice.org/dav/props/" ) )
     {
         rName.nspace = "http://ucb.openoffice.org/dav/props/";
         rName.name
             = strdup( OUStringToOString(
-                        rFullName.subView(
+                        rFullName.substr(
                             RTL_CONSTASCII_LENGTH(
                                 "http://ucb.openoffice.org/dav/props/" ) ),
                         RTL_TEXTENCODING_UTF8 ).getStr() );
     }
-    else if ( rFullName.startsWith( "<prop:" ) )
+    else if ( o3tl::starts_with( rFullName, u"<prop:" ) )
     {
         // Support for 3rd party namespaces/props
 
diff --git a/ucb/source/ucp/webdav-neon/DAVProperties.hxx b/ucb/source/ucp/webdav-neon/DAVProperties.hxx
index 633359b5f78f..3eeddcb847e1 100644
--- a/ucb/source/ucp/webdav-neon/DAVProperties.hxx
+++ b/ucb/source/ucp/webdav-neon/DAVProperties.hxx
@@ -27,6 +27,10 @@
  ************************************************************************/
 #pragma once
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <config_lgpl.h>
 #include <rtl/ustring.hxx>
 #include "NeonTypes.hxx"
@@ -49,7 +53,7 @@ struct DAVProperties
     static constexpr OUStringLiteral SUPPORTEDLOCK = u"DAV:supportedlock";
     static constexpr OUStringLiteral EXECUTABLE = u"http://apache.org/dav/props/executable";
 
-    static void createNeonPropName( const OUString & rFullName,
+    static void createNeonPropName( std::u16string_view rFullName,
                                     NeonPropName & rName );
     static void createUCBPropName ( const char * nspace,
                                     const char * name,


More information about the Libreoffice-commits mailing list