summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-05-05 08:31:35 +0200
committerStephan Bergmann <sbergman@redhat.com>2023-05-05 10:11:54 +0200
commit9c6b7283e366788c629b237cb2a3045ce926fed6 (patch)
tree8d21e3dcf201336cbea91222ea099e207039355d
parentf7e1cdf951f7f9cbb5822c49b86ba8a77a2fa878 (diff)
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 <sbergman@redhat.com>
-rw-r--r--cui/source/dialogs/QrCodeGenDialog.cxx2
-rw-r--r--sal/cppunittester/cppunittester.cxx3
-rw-r--r--unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx3
3 files changed, 3 insertions, 5 deletions
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