comphelper/qa/unit/test_hash.cxx | 2 +- comphelper/source/misc/docpasswordhelper.cxx | 10 +++++----- comphelper/source/misc/hash.cxx | 6 +++--- include/comphelper/docpasswordhelper.hxx | 6 +++--- include/comphelper/hash.hxx | 2 +- include/oox/crypto/AgileEngine.hxx | 14 +++++++------- include/oox/crypto/CryptoEngine.hxx | 2 +- include/oox/crypto/Standard2007Engine.hxx | 2 +- oox/qa/unit/CryptoTest.cxx | 16 ++++++++-------- oox/source/crypto/AgileEngine.cxx | 14 +++++++------- oox/source/crypto/Standard2007Engine.cxx | 2 +- sc/inc/tabprotection.hxx | 8 ++++---- sc/source/core/data/tabprotection.cxx | 12 ++++++------ sc/source/ui/docshell/docfunc.cxx | 2 +- sc/source/ui/inc/docfunc.hxx | 2 +- sc/source/ui/inc/viewfunc.hxx | 2 +- sc/source/ui/view/tabvwsh3.cxx | 2 +- sc/source/ui/view/viewfunc.cxx | 2 +- 18 files changed, 53 insertions(+), 53 deletions(-)
New commits: commit 234b42d44933f371f386340d6918111f15264c3a Author: Arnaud VERSINI <arnaud.vers...@pm.me> AuthorDate: Sun May 4 17:59:32 2025 +0200 Commit: Arnaud Versini <arnaud.vers...@libreoffice.org> CommitDate: Mon Jun 9 16:26:55 2025 +0200 comphelper : use more u16string_view instead of const OUString& Change-Id: Ie571697e63a97e7a6d306ee6f551c4bcf9aa99fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184941 Reviewed-by: Arnaud Versini <arnaud.vers...@pm.me> Tested-by: Jenkins diff --git a/comphelper/qa/unit/test_hash.cxx b/comphelper/qa/unit/test_hash.cxx index 93933f84b9a3..af239006b7e5 100644 --- a/comphelper/qa/unit/test_hash.cxx +++ b/comphelper/qa/unit/test_hash.cxx @@ -104,7 +104,7 @@ void TestHash::testSHA512_NoSaltNoSpin() // tdf#104250 https://bugs.documentfoundation.org/attachment.cgi?id=129104 void TestHash::testSHA512_saltspin() { - const OUString aHash = comphelper::DocPasswordHelper::GetOoxHashAsBase64( u"pwd"_ustr, u"876MLoKTq42+/DLp415iZQ==", 100000, + const OUString aHash = comphelper::DocPasswordHelper::GetOoxHashAsBase64( u"pwd", u"876MLoKTq42+/DLp415iZQ==", 100000, comphelper::Hash::IterCount::APPEND, u"SHA-512"); CPPUNIT_ASSERT_EQUAL(u"5l3mgNHXpWiFaBPv5Yso1Xd/UifWvQWmlDnl/hsCYbFT2sJCzorjRmBCQ/3qeDu6Q/4+GIE8a1DsdaTwYh1q2g=="_ustr, aHash); } diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx index b09555b169dc..a22dc4771f13 100644 --- a/comphelper/source/misc/docpasswordhelper.cxx +++ b/comphelper/source/misc/docpasswordhelper.cxx @@ -120,7 +120,7 @@ DocPasswordHelper::GenerateNewModifyPasswordInfoOOXML(std::u16string_view aPassw sal_Int32 const nIterationCount = 100000; OUString sAlgorithm(u"SHA-512"_ustr); - const OUString sHash(GetOoxHashAsBase64(OUString(aPassword), sSalt, nIterationCount, + const OUString sHash(GetOoxHashAsBase64(aPassword, sSalt, nIterationCount, comphelper::Hash::IterCount::APPEND, sAlgorithm)); if (!sHash.isEmpty()) @@ -239,7 +239,7 @@ bool DocPasswordHelper::IsModifyPasswordCorrect( std::u16string_view aPassword, aHash >>= sHash; if (!sSalt.isEmpty() && !sHash.isEmpty()) { - const OUString aNewHash(GetOoxHashAsBase64(OUString(aPassword), sSalt, nCount, + const OUString aNewHash(GetOoxHashAsBase64(aPassword, sSalt, nCount, comphelper::Hash::IterCount::APPEND, sAlgorithm)); if (!aNewHash.isEmpty()) @@ -362,7 +362,7 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence( std::vector<unsigned char> DocPasswordHelper::GetOoxHashAsVector( - const OUString& rPassword, + std::u16string_view rPassword, const std::vector<unsigned char>& rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, @@ -387,7 +387,7 @@ std::vector<unsigned char> DocPasswordHelper::GetOoxHashAsVector( css::uno::Sequence<sal_Int8> DocPasswordHelper::GetOoxHashAsSequence( - const OUString& rPassword, + std::u16string_view rPassword, std::u16string_view rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, @@ -407,7 +407,7 @@ css::uno::Sequence<sal_Int8> DocPasswordHelper::GetOoxHashAsSequence( } OUString DocPasswordHelper::GetOoxHashAsBase64( - const OUString& rPassword, + std::u16string_view rPassword, std::u16string_view rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, diff --git a/comphelper/source/misc/hash.cxx b/comphelper/source/misc/hash.cxx index 164a15b01cdf..96c8804bf6fc 100644 --- a/comphelper/source/misc/hash.cxx +++ b/comphelper/source/misc/hash.cxx @@ -264,14 +264,14 @@ std::vector<unsigned char> Hash::calculateHash( } std::vector<unsigned char> Hash::calculateHash( - const OUString& rPassword, + std::u16string_view rPassword, const std::vector<unsigned char>& rSaltValue, sal_uInt32 nSpinCount, IterCount eIterCount, HashType eType) { - const unsigned char* pPassBytes = reinterpret_cast<const unsigned char*>(rPassword.getStr()); - const size_t nPassBytesLen = rPassword.getLength() * 2; + const unsigned char* pPassBytes = reinterpret_cast<const unsigned char*>(rPassword.data()); + const size_t nPassBytesLen = rPassword.length() * 2; #ifdef OSL_BIGENDIAN // Swap UTF16-BE to UTF16-LE std::vector<unsigned char> vPass; diff --git a/include/comphelper/docpasswordhelper.hxx b/include/comphelper/docpasswordhelper.hxx index 9d8409c3bf46..4f10cc0c2bb5 100644 --- a/include/comphelper/docpasswordhelper.hxx +++ b/include/comphelper/docpasswordhelper.hxx @@ -238,7 +238,7 @@ public: @return the raw hash value as sal_Int8 sequence. */ static css::uno::Sequence<sal_Int8> GetOoxHashAsSequence( - const OUString& rPassword, + std::u16string_view rPassword, std::u16string_view rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, @@ -284,7 +284,7 @@ public: compared against a stored base64 encoded hash value. */ static OUString GetOoxHashAsBase64( - const OUString& rPassword, + std::u16string_view rPassword, std::u16string_view rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, @@ -328,7 +328,7 @@ public: @return the raw the hash value. */ static std::vector<unsigned char> GetOoxHashAsVector( - const OUString& rPassword, + std::u16string_view rPassword, const std::vector<unsigned char>& rSaltValue, sal_uInt32 nSpinCount, comphelper::Hash::IterCount eIterCount, diff --git a/include/comphelper/hash.hxx b/include/comphelper/hash.hxx index 30bcb289ec97..b6c226f82c84 100644 --- a/include/comphelper/hash.hxx +++ b/include/comphelper/hash.hxx @@ -117,7 +117,7 @@ public: Salt that will be prepended to password data. */ static std::vector<unsigned char> calculateHash( - const rtl::OUString& rPassword, + std::u16string_view rPassword, const std::vector<unsigned char>& rSaltValue, sal_uInt32 nSpinCount, IterCount eIterCount, diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx index 787a311c4487..7124333c2efc 100644 --- a/include/oox/crypto/AgileEngine.hxx +++ b/include/oox/crypto/AgileEngine.hxx @@ -75,7 +75,7 @@ private: AgileEncryptionInfo mInfo; AgileEncryptionPreset meEncryptionPreset; - void calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal); + void calculateHashFinal(std::u16string_view rPassword, std::vector<sal_uInt8>& aHashFinal); void calculateBlock( std::vector<sal_uInt8> const & rBlock, @@ -103,10 +103,10 @@ public: // Decryption - void decryptEncryptionKey(OUString const & rPassword); - bool decryptAndCheckVerifierHash(OUString const & rPassword); + void decryptEncryptionKey(std::u16string_view rPassword); + bool decryptAndCheckVerifierHash(std::u16string_view rPassword); - bool generateEncryptionKey(OUString const & rPassword) override; + bool generateEncryptionKey(std::u16string_view rPassword) override; bool readEncryptionInfo(css::uno::Reference<css::io::XInputStream> & rxInputStream) override; bool decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& aOutputStream) override; @@ -126,14 +126,14 @@ public: bool setupEncryption(OUString const & rPassword) override; - bool generateAndEncryptVerifierHash(OUString const & rPassword); + bool generateAndEncryptVerifierHash(std::u16string_view rPassword); bool encryptHmacKey(); bool encryptHmacValue(); - bool encryptEncryptionKey(OUString const & rPassword); + bool encryptEncryptionKey(std::u16string_view rPassword); void setupEncryptionParameters(AgileEncryptionParameters const & rAgileEncryptionParameters); - bool setupEncryptionKey(OUString const & rPassword); + bool setupEncryptionKey(std::u16string_view rPassword); }; } // namespace comphelper::crypto diff --git a/include/oox/crypto/CryptoEngine.hxx b/include/oox/crypto/CryptoEngine.hxx index 49009ac7e2c1..1b14bb924e8b 100644 --- a/include/oox/crypto/CryptoEngine.hxx +++ b/include/oox/crypto/CryptoEngine.hxx @@ -41,7 +41,7 @@ public: // Decryption virtual bool readEncryptionInfo(css::uno::Reference<css::io::XInputStream> & rxInputStream) = 0; - virtual bool generateEncryptionKey(const OUString& rPassword) = 0; + virtual bool generateEncryptionKey(std::u16string_view rPassword) = 0; virtual bool decrypt( BinaryXInputStream& aInputStream, diff --git a/include/oox/crypto/Standard2007Engine.hxx b/include/oox/crypto/Standard2007Engine.hxx index 24f12bf97f7a..60543ce48b13 100644 --- a/include/oox/crypto/Standard2007Engine.hxx +++ b/include/oox/crypto/Standard2007Engine.hxx @@ -31,7 +31,7 @@ public: bool readEncryptionInfo(css::uno::Reference<css::io::XInputStream> & rxInputStream) override; - virtual bool generateEncryptionKey(OUString const & rPassword) override; + virtual bool generateEncryptionKey(std::u16string_view rPassword) override; virtual bool decrypt( BinaryXInputStream& aInputStream, diff --git a/oox/qa/unit/CryptoTest.cxx b/oox/qa/unit/CryptoTest.cxx index dd3ff5c3fe12..90a56620ce56 100644 --- a/oox/qa/unit/CryptoTest.cxx +++ b/oox/qa/unit/CryptoTest.cxx @@ -145,28 +145,28 @@ void CryptoTest::testAgileEncryptionVerifier() { 100000, 16, 128, 20, 16, u"AES"_ustr, u"ChainingModeCBC"_ustr, u"SHA1"_ustr }); CPPUNIT_ASSERT_EQUAL(true, aEngine.generateAndEncryptVerifierHash(aPassword)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); aEngine.setupEncryptionParameters( { 100000, 16, 128, 48, 16, u"AES"_ustr, u"ChainingModeCBC"_ustr, u"SHA384"_ustr }); CPPUNIT_ASSERT_EQUAL(true, aEngine.generateAndEncryptVerifierHash(aPassword)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); aEngine.setupEncryptionParameters( { 100000, 16, 192, 48, 16, u"AES"_ustr, u"ChainingModeCBC"_ustr, u"SHA384"_ustr }); CPPUNIT_ASSERT_EQUAL(true, aEngine.generateAndEncryptVerifierHash(aPassword)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); aEngine.setupEncryptionParameters( { 100000, 16, 256, 64, 16, u"AES"_ustr, u"ChainingModeCBC"_ustr, u"SHA512"_ustr }); CPPUNIT_ASSERT_EQUAL(true, aEngine.generateAndEncryptVerifierHash(aPassword)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); } @@ -216,7 +216,7 @@ void CryptoTest::testAgileEncryptionInfoWritingAndParsing() CPPUNIT_ASSERT_EQUAL(u"SHA1"_ustr, rInfo.hashAlgorithm); CPPUNIT_ASSERT_EQUAL(toString(aKeyDataSalt), toString(rInfo.keyDataSalt)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); } } @@ -262,7 +262,7 @@ void CryptoTest::testAgileEncryptionInfoWritingAndParsing() CPPUNIT_ASSERT_EQUAL(u"SHA384"_ustr, rInfo.hashAlgorithm); CPPUNIT_ASSERT_EQUAL(toString(aKeyDataSalt), toString(rInfo.keyDataSalt)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); } } @@ -307,7 +307,7 @@ void CryptoTest::testAgileEncryptionInfoWritingAndParsing() CPPUNIT_ASSERT_EQUAL(u"SHA384"_ustr, rInfo.hashAlgorithm); CPPUNIT_ASSERT_EQUAL(toString(aKeyDataSalt), toString(rInfo.keyDataSalt)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); } } @@ -352,7 +352,7 @@ void CryptoTest::testAgileEncryptionInfoWritingAndParsing() CPPUNIT_ASSERT_EQUAL(u"SHA512"_ustr, rInfo.hashAlgorithm); CPPUNIT_ASSERT_EQUAL(toString(aKeyDataSalt), toString(rInfo.keyDataSalt)); - CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong"_ustr)); + CPPUNIT_ASSERT_EQUAL(false, aEngine.decryptAndCheckVerifierHash(u"Wrong")); CPPUNIT_ASSERT_EQUAL(true, aEngine.decryptAndCheckVerifierHash(aPassword)); } } diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx index a74533f95849..5c02305512d5 100644 --- a/oox/source/crypto/AgileEngine.cxx +++ b/oox/source/crypto/AgileEngine.cxx @@ -304,7 +304,7 @@ void AgileEngine::encryptBlock( aEncryptor.update(rOutput, rInput); } -void AgileEngine::calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal) +void AgileEngine::calculateHashFinal(std::u16string_view rPassword, std::vector<sal_uInt8>& aHashFinal) { aHashFinal = comphelper::DocPasswordHelper::GetOoxHashAsVector( rPassword, mInfo.saltValue, mInfo.spinCount, @@ -328,7 +328,7 @@ bool generateBytes(std::vector<sal_uInt8> & rBytes, sal_Int32 nSize) } // end anonymous namespace -bool AgileEngine::decryptAndCheckVerifierHash(OUString const & rPassword) +bool AgileEngine::decryptAndCheckVerifierHash(std::u16string_view rPassword) { std::vector<sal_uInt8>& encryptedHashValue = mInfo.encryptedVerifierHashValue; size_t encryptedHashValueSize = encryptedHashValue.size(); @@ -353,7 +353,7 @@ bool AgileEngine::decryptAndCheckVerifierHash(OUString const & rPassword) return std::equal(hash.begin(), hash.end(), hashValue.begin()); } -void AgileEngine::decryptEncryptionKey(OUString const & rPassword) +void AgileEngine::decryptEncryptionKey(std::u16string_view rPassword) { sal_Int32 nKeySize = mInfo.keyBits / 8; @@ -371,7 +371,7 @@ void AgileEngine::decryptEncryptionKey(OUString const & rPassword) } // TODO: Rename -bool AgileEngine::generateEncryptionKey(OUString const & rPassword) +bool AgileEngine::generateEncryptionKey(std::u16string_view rPassword) { bool bResult = decryptAndCheckVerifierHash(rPassword); @@ -597,7 +597,7 @@ bool AgileEngine::readEncryptionInfo(uno::Reference<io::XInputStream> & rxInputS return false; } -bool AgileEngine::generateAndEncryptVerifierHash(OUString const & rPassword) +bool AgileEngine::generateAndEncryptVerifierHash(std::u16string_view rPassword) { if (!generateBytes(mInfo.saltValue, mInfo.saltSize)) return false; @@ -692,7 +692,7 @@ bool AgileEngine::encryptHmacValue() return true; } -bool AgileEngine::encryptEncryptionKey(OUString const & rPassword) +bool AgileEngine::encryptEncryptionKey(std::u16string_view rPassword) { sal_Int32 nKeySize = mInfo.keyBits / 8; @@ -745,7 +745,7 @@ void AgileEngine::setupEncryptionParameters(AgileEncryptionParameters const & rA mInfo.encryptedVerifierHashValue.resize(comphelper::roundUp(mInfo.hashSize, mInfo.blockSize), 0); } -bool AgileEngine::setupEncryptionKey(OUString const & rPassword) +bool AgileEngine::setupEncryptionKey(std::u16string_view rPassword) { if (!generateAndEncryptVerifierHash(rPassword)) return false; diff --git a/oox/source/crypto/Standard2007Engine.cxx b/oox/source/crypto/Standard2007Engine.cxx index a9fb8d3c2339..e9d8064c5808 100644 --- a/oox/source/crypto/Standard2007Engine.cxx +++ b/oox/source/crypto/Standard2007Engine.cxx @@ -116,7 +116,7 @@ bool Standard2007Engine::calculateEncryptionKey(std::u16string_view rPassword) return true; } -bool Standard2007Engine::generateEncryptionKey(const OUString& password) +bool Standard2007Engine::generateEncryptionKey(std::u16string_view password) { mKey.clear(); /* diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx index a799012fbcd4..8fc6705c6177 100644 --- a/sc/inc/tabprotection.hxx +++ b/sc/inc/tabprotection.hxx @@ -53,7 +53,7 @@ struct ScOoxPasswordHash maHashValue.clear(); maSaltValue.clear(); } - bool verifyPassword( const OUString& aPassText ) const; + bool verifyPassword( std::u16string_view aPassText ) const; }; namespace ScPassHashHelper @@ -89,7 +89,7 @@ public: ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) = 0; virtual void setPasswordHash( const OUString& rAlgorithmName, const OUString& rHashValue, const OUString& rSaltValue, sal_uInt32 nSpinCount ) = 0; - virtual bool verifyPassword(const OUString& aPassText) const = 0; + virtual bool verifyPassword(std::u16string_view aPassText) const = 0; }; class SAL_DLLPUBLIC_RTTI ScDocProtection final : public ScPassHashProtectable @@ -121,7 +121,7 @@ public: ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) override; virtual void setPasswordHash( const OUString& rAlgorithmName, const OUString& rHashValue, const OUString& rSaltValue, sal_uInt32 nSpinCount ) override; - SC_DLLPUBLIC virtual bool verifyPassword(const OUString& aPassText) const override; + SC_DLLPUBLIC virtual bool verifyPassword(std::u16string_view aPassText) const override; SC_DLLPUBLIC bool isOptionEnabled(Option eOption) const; SC_DLLPUBLIC void setOption(Option eOption, bool bEnabled); @@ -205,7 +205,7 @@ public: ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) override; virtual void setPasswordHash( const OUString& rAlgorithmName, const OUString& rHashValue, const OUString& rSaltValue, sal_uInt32 nSpinCount ) override; - virtual bool verifyPassword(const OUString& aPassText) const override; + virtual bool verifyPassword(std::u16string_view aPassText) const override; bool isOptionEnabled(Option eOption) const; void setOption(Option eOption, bool bEnabled); diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx index 789ef20168a7..c98176defac9 100644 --- a/sc/source/core/data/tabprotection.cxx +++ b/sc/source/core/data/tabprotection.cxx @@ -90,7 +90,7 @@ ScPasswordHash ScPassHashHelper::getHashTypeFromURI(std::u16string_view rURI) return PASSHASH_UNSPECIFIED; } -bool ScOoxPasswordHash::verifyPassword( const OUString& aPassText ) const +bool ScOoxPasswordHash::verifyPassword( std::u16string_view aPassText ) const { if (!hasPassword()) return false; @@ -132,7 +132,7 @@ public: ScPasswordHash eHash, ScPasswordHash eHash2); void setPasswordHash( const OUString& rAlgorithmName, const OUString& rHashValue, const OUString& rSaltValue, sal_uInt32 nSpinCount ); - bool verifyPassword(const OUString& aPassText) const; + bool verifyPassword(std::u16string_view aPassText) const; bool isOptionEnabled(SCSIZE nOptId) const; void setOption(SCSIZE nOptId, bool bEnabled); @@ -354,7 +354,7 @@ void ScTableProtectionImpl::setPasswordHash( const OUString& rAlgorithmName, con maPasswordHash.mnSpinCount = nSpinCount; } -bool ScTableProtectionImpl::verifyPassword(const OUString& aPassText) const +bool ScTableProtectionImpl::verifyPassword(std::u16string_view aPassText) const { #if DEBUG_TAB_PROTECTION fprintf(stdout, "ScTableProtectionImpl::verifyPassword: input = '%s' ", @@ -362,7 +362,7 @@ bool ScTableProtectionImpl::verifyPassword(const OUString& aPassText) const #endif if (mbEmptyPass) - return aPassText.isEmpty(); + return aPassText.empty(); if (!maPassText.isEmpty()) // Clear text password exists, and this one takes precedence. @@ -597,7 +597,7 @@ void ScDocProtection::setPasswordHash( const OUString& rAlgorithmName, const OUS mpImpl->setPasswordHash( rAlgorithmName, rHashValue, rSaltValue, nSpinCount); } -bool ScDocProtection::verifyPassword(const OUString& aPassText) const +bool ScDocProtection::verifyPassword(std::u16string_view aPassText) const { return mpImpl->verifyPassword(aPassText); } @@ -682,7 +682,7 @@ void ScTableProtection::setPasswordHash( const OUString& rAlgorithmName, const O mpImpl->setPasswordHash( rAlgorithmName, rHashValue, rSaltValue, nSpinCount); } -bool ScTableProtection::verifyPassword(const OUString& aPassText) const +bool ScTableProtection::verifyPassword(std::u16string_view aPassText) const { return mpImpl->verifyPassword(aPassText); } diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index d5444001390f..1aed6cc9ae4a 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -4055,7 +4055,7 @@ bool ScDocFunc::Protect( SCTAB nTab, const OUString& rPassword ) return true; } -bool ScDocFunc::Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi ) +bool ScDocFunc::Unprotect( SCTAB nTab, std::u16string_view rPassword, bool bApi ) { ScDocument& rDoc = rDocShell.GetDocument(); diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index 53f0bcc27104..7a41b8d51636 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -169,7 +169,7 @@ public: void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ); bool Protect( SCTAB nTab, const OUString& rPassword ); - bool Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi ); + bool Unprotect( SCTAB nTab, std::u16string_view rPassword, bool bApi ); void ClearItems( const ScMarkData& rMark, const sal_uInt16* pWhich, bool bApi ); bool ChangeIndent( const ScMarkData& rMark, bool bIncrement, bool bApi ); diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 36cbb20853e8..abded6a51b71 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -200,7 +200,7 @@ public: void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect ); void ProtectDoc( const OUString& rPassword ); - bool Unprotect( SCTAB nTab, const OUString& rPassword ); + bool Unprotect( SCTAB nTab, std::u16string_view rPassword ); void DeleteCells( DelCellCmd eCmd ); bool InsertCells( InsCellCmd eCmd, bool bRecord = true, bool bPartOfPaste = false, size_t nCount = 0); diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index 8ffc39903d57..2d61476276b3 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -240,7 +240,7 @@ void ScTabViewShell::ExecProtectTable( SfxRequest& rReq ) } else // this sheet is not password-protected. - Unprotect(nTab, OUString()); + Unprotect(nTab, std::u16string_view()); if (!pReqArgs) { diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index b00eee599775..3d8e4b921498 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2812,7 +2812,7 @@ void ScViewFunc::ProtectDoc( const OUString& rPassword ) UpdateLayerLocks(); //! broadcast to all views } -bool ScViewFunc::Unprotect( SCTAB nTab, const OUString& rPassword ) +bool ScViewFunc::Unprotect( SCTAB nTab, std::u16string_view rPassword ) { ScMarkData& rMark = GetViewData().GetMarkData(); ScDocShell& rDocSh = GetViewData().GetDocShell();