diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-09 09:55:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-10 12:59:38 +0200 |
commit | e4ff847fe0796420ba8023b70cad8589f5f19e9f (patch) | |
tree | 136786200de69f70dde4190c9725f35fe14b33e0 /desktop | |
parent | 5a89496ffcfcd561b3e595e01f35e0302fa00841 (diff) |
loplugin:stringview check for getToken and trim
since we now have o3tl versions of those that work on
string_view.
Also improve those o3tl functions to support both string_view
and u16string_view
Change-Id: Iacab2996becec62aa78a5597c52d983bb784749a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132755
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/deployment/registry/dp_registry.cxx | 7 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 40239f2501b2..17b9b774a17d 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -33,6 +33,7 @@ #include <cppuhelper/compbase.hxx> #include <comphelper/sequence.hxx> #include <ucbhelper/content.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/ucb/ContentCreationException.hpp> #include <com/sun/star/uno/DeploymentException.hpp> #include <com/sun/star/lang/DisposedException.hpp> @@ -152,12 +153,12 @@ PackageRegistryImpl::~PackageRegistryImpl() } -OUString normalizeMediaType( OUString const & mediaType ) +OUString normalizeMediaType( std::u16string_view mediaType ) { OUStringBuffer buf; sal_Int32 index = 0; for (;;) { - buf.append( mediaType.getToken( 0, '/', index ).trim() ); + buf.append( o3tl::trim(o3tl::getToken(mediaType, 0, '/', index )) ); if (index < 0) break; buf.append( '/' ); @@ -491,7 +492,7 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage( iFind = m_mediaType2backend.find( normalizeMediaType( // cut parameters: - mediaType.copy( 0, q ) ) ); + mediaType.subView( 0, q ) ) ); } } if (iFind == m_mediaType2backend.end()) { diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 933a119d696d..017a5838c93b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -44,6 +44,7 @@ #include <vcl/lok.hxx> #include <o3tl/any.hxx> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> #include <osl/file.hxx> #include <osl/process.h> #include <osl/thread.h> @@ -4509,9 +4510,9 @@ static bool getFromTransferrable( // Take care of UTF-8 text here. bool bConvert = false; sal_Int32 nIndex = 0; - if (aMimeType.getToken(0, ';', nIndex) == "text/plain") + if (o3tl::getToken(aMimeType, 0, ';', nIndex) == "text/plain") { - if (aMimeType.getToken(0, ';', nIndex) == "charset=utf-8") + if (o3tl::getToken(aMimeType, 0, ';', nIndex) == "charset=utf-8") { aMimeType = "text/plain;charset=utf-16"; bConvert = true; |