comphelper/qa/unit/base64_test.cxx           |    6 +++---
 comphelper/qa/unit/test_hash.cxx             |    2 +-
 comphelper/source/misc/base64.cxx            |   10 +++++-----
 comphelper/source/misc/docpasswordhelper.cxx |    6 +++---
 include/comphelper/base64.hxx                |    5 +++--
 include/comphelper/docpasswordhelper.hxx     |    4 ++--
 package/source/manifest/ManifestImport.cxx   |   12 ++++++------
 xmlsecurity/inc/xsecctl.hxx                  |    4 ++--
 xmlsecurity/source/helper/xsecverify.cxx     |   10 +++++-----
 9 files changed, 30 insertions(+), 29 deletions(-)

New commits:
commit 9c95415de877af1430ab5b7123e11dedd0ea622c
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Dec 26 10:40:24 2021 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Dec 26 23:09:20 2021 +0100

    Let comphelper::Base64::decode* take std::u16string_view
    
    Change-Id: I5b04f7adf11c61f52b7bfb0f52c8c075f838f0f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127480
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/comphelper/qa/unit/base64_test.cxx 
b/comphelper/qa/unit/base64_test.cxx
index 31e865a370a6..a1cd5d0006be 100644
--- a/comphelper/qa/unit/base64_test.cxx
+++ b/comphelper/qa/unit/base64_test.cxx
@@ -71,17 +71,17 @@ void Base64Test::testBase64Decode()
     uno::Sequence<sal_Int8> decodedSequence;
 
     uno::Sequence<sal_Int8> expectedSequence = { 0, 0, 0, 0, 0, 1, 2, 3 };
-    comphelper::Base64::decode(decodedSequence, "AAAAAAABAgM=");
+    comphelper::Base64::decode(decodedSequence, u"AAAAAAABAgM=");
     CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), 
std::cend(expectedSequence),
                               std::cbegin(decodedSequence)));
 
     expectedSequence = { 5, 2, 3, 0, 0, 1, 2, 3 };
-    comphelper::Base64::decode(decodedSequence, "BQIDAAABAgM=");
+    comphelper::Base64::decode(decodedSequence, u"BQIDAAABAgM=");
     CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), 
std::cend(expectedSequence),
                               std::cbegin(decodedSequence)));
 
     expectedSequence = { sal_Int8(sal_uInt8(200)), 31, 77, 111, 0, 1, 2, 3 };
-    comphelper::Base64::decode(decodedSequence, "yB9NbwABAgM=");
+    comphelper::Base64::decode(decodedSequence, u"yB9NbwABAgM=");
     CPPUNIT_ASSERT(std::equal(std::cbegin(expectedSequence), 
std::cend(expectedSequence),
                               std::cbegin(decodedSequence)));
 }
diff --git a/comphelper/qa/unit/test_hash.cxx b/comphelper/qa/unit/test_hash.cxx
index 0bcc3f8ed56c..64815ee56dc8 100644
--- a/comphelper/qa/unit/test_hash.cxx
+++ b/comphelper/qa/unit/test_hash.cxx
@@ -120,7 +120,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( 
"pwd", "876MLoKTq42+/DLp415iZQ==", 100000,
+    const OUString aHash = comphelper::DocPasswordHelper::GetOoxHashAsBase64( 
"pwd", u"876MLoKTq42+/DLp415iZQ==", 100000,
             comphelper::Hash::IterCount::APPEND, u"SHA-512");
     
CPPUNIT_ASSERT_EQUAL(OUString("5l3mgNHXpWiFaBPv5Yso1Xd/UifWvQWmlDnl/hsCYbFT2sJCzorjRmBCQ/3qeDu6Q/4+GIE8a1DsdaTwYh1q2g=="),
 aHash);
 }
diff --git a/comphelper/source/misc/base64.cxx 
b/comphelper/source/misc/base64.cxx
index 75274f5a73cb..d73465601adb 100644
--- a/comphelper/source/misc/base64.cxx
+++ b/comphelper/source/misc/base64.cxx
@@ -136,20 +136,20 @@ void Base64::encode(OUStringBuffer& aStrBuffer, const 
uno::Sequence<sal_Int8>& a
     }
 }
 
-void Base64::decode(uno::Sequence<sal_Int8>& aBuffer, const OUString& sBuffer)
+void Base64::decode(uno::Sequence<sal_Int8>& aBuffer, std::u16string_view 
sBuffer)
 {
     sal_Int32 nCharsDecoded = decodeSomeChars( aBuffer, sBuffer );
-    OSL_ENSURE( nCharsDecoded == sBuffer.getLength(), "some bytes left in 
base64 decoding!" );
+    OSL_ENSURE( sal_uInt32(nCharsDecoded) == sBuffer.size(), "some bytes left 
in base64 decoding!" );
 }
 
-sal_Int32 Base64::decodeSomeChars(uno::Sequence<sal_Int8>& rOutBuffer, const 
OUString& rInBuffer)
+sal_Int32 Base64::decodeSomeChars(uno::Sequence<sal_Int8>& rOutBuffer, 
std::u16string_view rInBuffer)
 {
-    sal_Int32 nInBufferLen = rInBuffer.getLength();
+    sal_Int32 nInBufferLen = rInBuffer.size();
     sal_Int32 nMinOutBufferLen = (nInBufferLen / 4) * 3;
     if( rOutBuffer.getLength() < nMinOutBufferLen )
         rOutBuffer.realloc( nMinOutBufferLen );
 
-    const sal_Unicode *pInBuffer = rInBuffer.getStr();
+    const sal_Unicode *pInBuffer = rInBuffer.data();
     sal_Int8 *pOutBuffer = rOutBuffer.getArray();
     sal_Int8 *pOutBufferStart = pOutBuffer;
     sal_Int32 nCharsDecoded = 0;
diff --git a/comphelper/source/misc/docpasswordhelper.cxx 
b/comphelper/source/misc/docpasswordhelper.cxx
index a31f829ddfa9..f0f13ad74f1c 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -327,13 +327,13 @@ std::vector<unsigned char> 
DocPasswordHelper::GetOoxHashAsVector(
 
 css::uno::Sequence<sal_Int8> DocPasswordHelper::GetOoxHashAsSequence(
         const OUString& rPassword,
-        const OUString& rSaltValue,
+        std::u16string_view rSaltValue,
         sal_uInt32 nSpinCount,
         comphelper::Hash::IterCount eIterCount,
         std::u16string_view rAlgorithmName)
 {
     std::vector<unsigned char> aSaltVec;
-    if (!rSaltValue.isEmpty())
+    if (!rSaltValue.empty())
     {
         css::uno::Sequence<sal_Int8> aSaltSeq;
         comphelper::Base64::decode( aSaltSeq, rSaltValue);
@@ -347,7 +347,7 @@ css::uno::Sequence<sal_Int8> 
DocPasswordHelper::GetOoxHashAsSequence(
 
 OUString DocPasswordHelper::GetOoxHashAsBase64(
         const OUString& rPassword,
-        const OUString& rSaltValue,
+        std::u16string_view rSaltValue,
         sal_uInt32 nSpinCount,
         comphelper::Hash::IterCount eIterCount,
         std::u16string_view rAlgorithmName)
diff --git a/include/comphelper/base64.hxx b/include/comphelper/base64.hxx
index a77ac4ebe3b2..ed32b2f8bc0e 100644
--- a/include/comphelper/base64.hxx
+++ b/include/comphelper/base64.hxx
@@ -46,9 +46,10 @@ public:
     // return any chars left from conversion.
     // For text submitted through the SAX characters call, the later method
     // must be used!
-    static void decode(css::uno::Sequence<sal_Int8>& aPass, const OUString& 
sBuffer);
+    static void decode(css::uno::Sequence<sal_Int8>& aPass, 
std::u16string_view sBuffer);
 
-    static sal_Int32 decodeSomeChars(css::uno::Sequence<sal_Int8>& aPass, 
const OUString& sBuffer);
+    static sal_Int32 decodeSomeChars(css::uno::Sequence<sal_Int8>& aPass,
+                                     std::u16string_view sBuffer);
 };
 }
 
diff --git a/include/comphelper/docpasswordhelper.hxx 
b/include/comphelper/docpasswordhelper.hxx
index fc40739184bc..dc78110519dd 100644
--- a/include/comphelper/docpasswordhelper.hxx
+++ b/include/comphelper/docpasswordhelper.hxx
@@ -223,7 +223,7 @@ public:
      */
     static css::uno::Sequence<sal_Int8> GetOoxHashAsSequence(
             const OUString& rPassword,
-            const OUString& rSaltValue,
+            std::u16string_view rSaltValue,
             sal_uInt32 nSpinCount,
             comphelper::Hash::IterCount eIterCount,
              std::u16string_view rAlgorithmName);
@@ -269,7 +269,7 @@ public:
      */
     static OUString GetOoxHashAsBase64(
             const OUString& rPassword,
-            const OUString& rSaltValue,
+            std::u16string_view rSaltValue,
             sal_uInt32 nSpinCount,
             comphelper::Hash::IterCount eIterCount,
             std::u16string_view rAlgorithmName);
diff --git a/package/source/manifest/ManifestImport.cxx 
b/package/source/manifest/ManifestImport.cxx
index f02629543cf4..7fbb3cff512f 100644
--- a/package/source/manifest/ManifestImport.cxx
+++ b/package/source/manifest/ManifestImport.cxx
@@ -112,9 +112,9 @@ void ManifestImport::doEncryptedCipherValue()
     {
         aKeyInfoSequence[2].Name = "CipherValue";
         uno::Sequence < sal_Int8 > aDecodeBuffer;
-        ::comphelper::Base64::decode(aDecodeBuffer, 
aCurrentCharacters.toString());
+        ::comphelper::Base64::decode(aDecodeBuffer, aCurrentCharacters);
         aKeyInfoSequence[2].Value <<= aDecodeBuffer;
-        aCurrentCharacters = ""; // consumed
+        aCurrentCharacters.setLength(0); // consumed
     }
     else
         bIgnoreEncryptData = true;
@@ -126,9 +126,9 @@ void ManifestImport::doEncryptedKeyId()
     {
         aKeyInfoSequence[0].Name = "KeyId";
         uno::Sequence < sal_Int8 > aDecodeBuffer;
-        ::comphelper::Base64::decode(aDecodeBuffer, 
aCurrentCharacters.toString());
+        ::comphelper::Base64::decode(aDecodeBuffer, aCurrentCharacters);
         aKeyInfoSequence[0].Value <<= aDecodeBuffer;
-        aCurrentCharacters = ""; // consumed
+        aCurrentCharacters.setLength(0); // consumed
     }
     else
         bIgnoreEncryptData = true;
@@ -140,9 +140,9 @@ void ManifestImport::doEncryptedKeyPacket()
     {
         aKeyInfoSequence[1].Name = "KeyPacket";
         uno::Sequence < sal_Int8 > aDecodeBuffer;
-        ::comphelper::Base64::decode(aDecodeBuffer, 
aCurrentCharacters.toString());
+        ::comphelper::Base64::decode(aDecodeBuffer, aCurrentCharacters);
         aKeyInfoSequence[1].Value <<= aDecodeBuffer;
-        aCurrentCharacters = ""; // consumed
+        aCurrentCharacters.setLength(0); // consumed
     }
     else
         bIgnoreEncryptData = true;
diff --git a/xmlsecurity/inc/xsecctl.hxx b/xmlsecurity/inc/xsecctl.hxx
index 2d105c8690d2..adfd251b172e 100644
--- a/xmlsecurity/inc/xsecctl.hxx
+++ b/xmlsecurity/inc/xsecctl.hxx
@@ -277,8 +277,8 @@ private:
 
     void setDate(OUString const& rId, OUString const& ouDate);
     void setDescription(OUString const& rId, OUString const& rDescription);
-    void setValidSignatureImage(const OUString& rValidSigImg);
-    void setInvalidSignatureImage(const OUString& rInvalidSigImg);
+    void setValidSignatureImage(std::u16string_view rValidSigImg);
+    void setInvalidSignatureImage(std::u16string_view rInvalidSigImg);
     void setSignatureLineId(const OUString& rSignatureLineId);
 
 public:
diff --git a/xmlsecurity/source/helper/xsecverify.cxx 
b/xmlsecurity/source/helper/xsecverify.cxx
index 46f087801bd5..6c676dc3825a 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -473,7 +473,7 @@ void XSecController::setX509CertDigest(
 }
 
 namespace {
-Reference<css::graphic::XGraphic> lcl_getGraphicFromString(const OUString& 
rImage)
+Reference<css::graphic::XGraphic> lcl_getGraphicFromString(std::u16string_view 
rImage)
 {
     Sequence<sal_Int8> seq;
     comphelper::Base64::decode(seq, rImage);
@@ -493,18 +493,18 @@ Reference<css::graphic::XGraphic> 
lcl_getGraphicFromString(const OUString& rImag
 }
 }
 
-void XSecController::setValidSignatureImage(const OUString& rValidSigImg)
+void XSecController::setValidSignatureImage(std::u16string_view rValidSigImg)
 {
-    if (m_vInternalSignatureInformations.empty() || rValidSigImg.isEmpty())
+    if (m_vInternalSignatureInformations.empty() || rValidSigImg.empty())
         return;
 
     InternalSignatureInformation& rInformation = 
m_vInternalSignatureInformations.back();
     rInformation.signatureInfor.aValidSignatureImage = 
lcl_getGraphicFromString(rValidSigImg);
 }
 
-void XSecController::setInvalidSignatureImage(const OUString& rInvalidSigImg)
+void XSecController::setInvalidSignatureImage(std::u16string_view 
rInvalidSigImg)
 {
-    if (m_vInternalSignatureInformations.empty() || rInvalidSigImg.isEmpty())
+    if (m_vInternalSignatureInformations.empty() || rInvalidSigImg.empty())
         return;
 
     InternalSignatureInformation& rInformation = 
m_vInternalSignatureInformations.back();

Reply via email to