summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-13 14:05:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-13 16:55:35 +0200
commitdae0083c69e91fff3c4f5db762e4189bbdc6eb7f (patch)
treebf8b13913860fa9685fa355e39bc7d1c3cc0b703 /svl
parenta5343a89f898468178f04c241de0b2c2a314a1b5 (diff)
use more string_view in svl
Change-Id: I9b6a074eb6342808d02a69f3ed1fa713e81d2608 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132958 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/misc/inettype.cxx18
-rw-r--r--svl/source/passwordcontainer/passwordcontainer.cxx23
-rw-r--r--svl/source/passwordcontainer/passwordcontainer.hxx4
3 files changed, 26 insertions, 19 deletions
diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx
index c1d4e4b1ba6e..25b92d390e2c 100644
--- a/svl/source/misc/inettype.cxx
+++ b/svl/source/misc/inettype.cxx
@@ -392,26 +392,26 @@ INetContentType INetContentTypes::GetContentTypeFromURL(OUString const & rURL)
}
//static
-bool INetContentTypes::GetExtensionFromURL(OUString const & rURL,
+bool INetContentTypes::GetExtensionFromURL(std::u16string_view rURL,
OUString & rExtension)
{
- sal_Int32 nSlashPos = 0;
- sal_Int32 i = 0;
- while (i >= 0)
+ size_t nSlashPos = 0;
+ size_t i = 0;
+ while (i != std::u16string_view::npos)
{
nSlashPos = i;
- i = rURL.indexOf('/', i + 1);
+ i = rURL.find('/', i + 1);
}
if (nSlashPos != 0)
{
- sal_Int32 nLastDotPos = i = rURL.indexOf('.', nSlashPos);
- while (i >= 0)
+ size_t nLastDotPos = i = rURL.find('.', nSlashPos);
+ while (i != std::u16string_view::npos)
{
nLastDotPos = i;
- i = rURL.indexOf('.', i + 1);
+ i = rURL.find('.', i + 1);
}
if (nLastDotPos >- 0)
- rExtension = rURL.copy(nLastDotPos + 1);
+ rExtension = rURL.substr(nLastDotPos + 1);
return true;
}
return false;
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
index 04eb0951f0ac..66cfda5e9aad 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -412,7 +412,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& )
}
}
-std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view aLine, const OUString& aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
+std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view aLine, std::u16string_view aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
{
if( !aMasterPasswd.isEmpty() )
{
@@ -428,10 +428,13 @@ std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view
code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0};
- if (!aIV.isEmpty())
+ if (!aIV.empty())
{
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
- iv[ ind ] = static_cast<char>(aIV.copy( ind*2, 2 ).toUInt32(16));
+ {
+ auto tmp = aIV.substr( ind*2, 2 );
+ iv[ ind ] = static_cast<char>(rtl_ustr_toInt64_WithLength(tmp.data(), 16, tmp.size()));
+ }
}
rtlCipherError result = rtl_cipher_init (
@@ -469,7 +472,7 @@ std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view
"Can't decode!", css::uno::Reference<css::uno::XInterface>(), mode);
}
-OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPasswd)
+OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, std::u16string_view aIV, const OUString& aMasterPasswd)
{
if( !aMasterPasswd.isEmpty() )
{
@@ -487,10 +490,13 @@ OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines
code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0};
- if (!aIV.isEmpty())
+ if (!aIV.empty())
{
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
- iv[ ind ] = static_cast<char>(aIV.copy( ind*2, 2 ).toUInt32(16));
+ {
+ auto tmp = aIV.substr( ind*2, 2 );
+ iv[ ind ] = static_cast<char>(rtl_ustr_toInt64_WithLength(tmp.data(), 16, tmp.size()));
+ }
}
rtlCipherError result = rtl_cipher_init (
@@ -837,12 +843,13 @@ OUString PasswordContainer::RequestPasswordFromUser( PasswordRequestMode aRMode,
}
// Mangle the key to match an old bug
-static OUString ReencodeAsOldHash(const OUString& rPass)
+static OUString ReencodeAsOldHash(std::u16string_view rPass)
{
OUStringBuffer aBuffer;
for (int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ++ind)
{
- unsigned char i = static_cast<char>(rPass.copy(ind * 2, 2).toUInt32(16));
+ auto tmp = rPass.substr(ind * 2, 2);
+ unsigned char i = static_cast<char>(rtl_ustr_toInt64_WithLength(tmp.data(), 16, tmp.size()));
aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4)));
aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15)));
}
diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx
index 7924f53bff83..1f1d2569d4de 100644
--- a/svl/source/passwordcontainer/passwordcontainer.hxx
+++ b/svl/source/passwordcontainer/passwordcontainer.hxx
@@ -316,10 +316,10 @@ private:
const css::uno::Reference< css::task::XInteractionHandler >& Handler );
/// @throws css::uno::RuntimeException
- static ::std::vector< OUString > DecodePasswords( std::u16string_view aLine, const OUString& aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
+ static ::std::vector< OUString > DecodePasswords( std::u16string_view aLine, std::u16string_view aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
/// @throws css::uno::RuntimeException
- static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPassword );
+ static OUString EncodePasswords(const std::vector< OUString >& lines, std::u16string_view aIV, const OUString& aMasterPassword );
public:
PasswordContainer( const css::uno::Reference< css::uno::XComponentContext >& );