cui/source/dialogs/QrCodeGenDialog.cxx                             |    2 +-
 sal/cppunittester/cppunittester.cxx                                |    3 +--
 unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx |    3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)

New commits:
commit 9c6b7283e366788c629b237cb2a3045ce926fed6
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Fri May 5 08:31:35 2023 +0200
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Fri May 5 10:11:54 2023 +0200

    loplugin:unnecessarygetstr
    
    The plugin in its current form is probably not intending to find these 
cases.
    But it happened to do so on macOS with libc++, where the std::basic_string 
ctors
    taking a final defaulted Allocator argument are instead implemented by a 
pair of
    overloaded ctors, one taking no Allocator at all (see
    671d1c6cd14b28b5960ad56086299bd69533dfd8 "Adapt loplugin:unnecessarygetstr 
to
    libc++").
    
    But these changes here are useful regardless, so lets leave it at that.
    
    Change-Id: I2776671e2953182bdcad36432951a75f82412ebb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151410
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx 
b/cui/source/dialogs/QrCodeGenDialog.cxx
index 817be7f21ede..6982ca7f8e69 100644
--- a/cui/source/dialogs/QrCodeGenDialog.cxx
+++ b/cui/source/dialogs/QrCodeGenDialog.cxx
@@ -138,7 +138,7 @@ OString GenerateQRCode(std::u16string_view aQRText, 
tools::Long aQRECC, int aQRB
     }
 
     OString o = OUStringToOString(aQRText, RTL_TEXTENCODING_UTF8);
-    std::string QRText(o.getStr(), o.getLength());
+    std::string QRText(o);
     ZXing::BarcodeFormat format = 
ZXing::BarcodeFormatFromString(GetBarCodeType(aQRType));
     auto writer = 
ZXing::MultiFormatWriter(format).setMargin(aQRBorder).setEccLevel(bqrEcc);
     writer.setEncoding(ZXing::CharacterSet::UTF8);
diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index c859ee5e102f..6729903edd5d 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -91,8 +91,7 @@ std::string convertLazy(std::u16string_view s16) {
     OString s8(OUStringToOString(s16, osl_getThreadTextEncoding()));
     static_assert(sizeof (sal_Int32) <= sizeof (std::string::size_type), "must 
be at least the same size");
         // ensure following cast is legitimate
-    return std::string(
-        s8.getStr(), static_cast< std::string::size_type >(s8.getLength()));
+    return std::string(s8);
 }
 
 //Output how long each test took
diff --git a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx 
b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
index 764f49d79bf5..5a76cbdb11c1 100644
--- a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
+++ b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
@@ -39,8 +39,7 @@ std::string convert(std::u16string_view s16) {
     OString s8(OUStringToOString(s16, osl_getThreadTextEncoding()));
     static_assert(sizeof (sal_Int32) <= sizeof (std::string::size_type), "got 
to be at least equal");
         // ensure following cast is legitimate
-    return std::string(
-        s8.getStr(), static_cast< std::string::size_type >(s8.getLength()));
+    return std::string(s8);
 }
 
 class Prot : public CppUnit::Protector

Reply via email to