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@redhat.com>
This commit is contained in:
Stephan Bergmann 2021-09-22 17:17:16 +02:00
parent d1e14030e8
commit 7885c1cb80
8 changed files with 41 additions and 26 deletions

View file

@ -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!" );

View file

@ -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

View file

@ -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 );

View file

@ -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 ); }

View file

@ -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() );

View file

@ -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;

View file

@ -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

View file

@ -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,