From 35e471bb4d1388cf5afcdcee214cf5111edf44e3 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 11 Dec 2020 17:44:34 +0100 Subject: Adapt the remaining OUString functions to std string_view ...for LIBO_INTERNAL_ONLY. These had been missed by 1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take std::u16string_view parameters" because they did not match the multi-overload pattern that was addressed there, but they nevertheless benefit from being changed just as well (witness e.g. the various resulting changes from copy() to subView()). This showed a conversion from OStringChar to std::string_view to be missing (while the corresponding conversion form OUStringChar to std::u16string_view was already present). The improvement to loplugin:stringadd became necessary to fix > [CPT] compilerplugins/clang/test/stringadd.cxx > error: 'error' diagnostics expected but not seen: > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd] > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd] > 2 errors generated. Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- xmloff/source/chart/MultiPropertySetHandler.hxx | 3 ++- xmloff/source/core/xmlimp.cxx | 2 +- xmloff/source/core/xmlmultiimagehelper.cxx | 2 +- xmloff/source/style/GradientStyle.cxx | 2 +- xmloff/source/style/TransGradientStyle.cxx | 2 +- xmloff/source/text/txtparai.cxx | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/chart/MultiPropertySetHandler.hxx b/xmloff/source/chart/MultiPropertySetHandler.hxx index ddbd9881f5de..a89e1c1ee7ed 100644 --- a/xmloff/source/chart/MultiPropertySetHandler.hxx +++ b/xmloff/source/chart/MultiPropertySetHandler.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -94,7 +95,7 @@ class OUStringComparison { public: /// Compare two strings. Returns true if the first is before the second. - bool operator() (const OUString & a, const OUString & b) const + bool operator() (const OUString & a, std::u16string_view b) const { return (a.compareTo (b) < 0); } diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 94eafa9f8ab2..5f1e7ec1b20a 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1604,7 +1604,7 @@ bool SvXMLImport::IsODFVersionConsistent( const OUString& aODFVersion ) // the check returns sal_False only if the storage version could be retrieved bool bResult = true; - if ( !aODFVersion.isEmpty() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 ) + if ( !aODFVersion.isEmpty() && aODFVersion.compareTo( u"" ODFVER_012_TEXT ) >= 0 ) { // check the consistency only for the ODF1.2 and later ( according to content.xml ) // manifest.xml might have no version, it should be checked here and the correct version should be set diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx index f48ae6e9a576..4ed4ddd96b03 100644 --- a/xmloff/source/core/xmlmultiimagehelper.cxx +++ b/xmloff/source/core/xmlmultiimagehelper.cxx @@ -31,7 +31,7 @@ namespace OUString sMimeType; if (rString.startsWith("vnd.sun.star.Package")) { - OString aExtension = OUStringToOString(rString.copy(rString.lastIndexOf(".") + 1), RTL_TEXTENCODING_ASCII_US); + OString aExtension = OUStringToOString(rString.subView(rString.lastIndexOf(".") + 1), RTL_TEXTENCODING_ASCII_US); sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aExtension); } return sMimeType; diff --git a/xmloff/source/style/GradientStyle.cxx b/xmloff/source/style/GradientStyle.cxx index 63e65f2d4965..221023d6e072 100644 --- a/xmloff/source/style/GradientStyle.cxx +++ b/xmloff/source/style/GradientStyle.cxx @@ -117,7 +117,7 @@ void XMLGradientStyleImport::importXML( break; case XML_ELEMENT(DRAW, XML_GRADIENT_ANGLE): { - auto const cmp12(rImport.GetODFVersion().compareTo(ODFVER_012_TEXT)); + auto const cmp12(rImport.GetODFVersion().compareTo(u"" ODFVER_012_TEXT)); bool const bSuccess = ::sax::Converter::convertAngle(aGradient.Angle, aStrValue, // tdf#89475 try to detect borked OOo angles diff --git a/xmloff/source/style/TransGradientStyle.cxx b/xmloff/source/style/TransGradientStyle.cxx index bae840c67348..8f7fe41d1444 100644 --- a/xmloff/source/style/TransGradientStyle.cxx +++ b/xmloff/source/style/TransGradientStyle.cxx @@ -134,7 +134,7 @@ void XMLTransGradientStyleImport::importXML( break; case XML_ELEMENT(DRAW, XML_GRADIENT_ANGLE): { - auto const cmp12(rImport.GetODFVersion().compareTo(ODFVER_012_TEXT)); + auto const cmp12(rImport.GetODFVersion().compareTo(u"" ODFVER_012_TEXT)); bool const bSuccess = ::sax::Converter::convertAngle(aGradient.Angle, aStrValue, // tdf#89475 try to detect borked OOo angles diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index aee55e50ae6c..733946a98b40 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -2072,7 +2072,7 @@ XMLNumberedParaContext::XMLNumberedParaContext( i_rImport.GetTextImport()->GetTextListHelper() ); if (m_ListId.isEmpty()) { - SAL_WARN_IF(0 <= i_rImport.GetODFVersion().compareTo("1.2"), "xmloff.text", "invalid numbered-paragraph: no list-id (1.2)"); + SAL_WARN_IF(0 <= i_rImport.GetODFVersion().compareTo(u"1.2"), "xmloff.text", "invalid numbered-paragraph: no list-id (1.2)"); m_ListId = rTextListsHelper.GetNumberedParagraphListId(m_Level, StyleName); SAL_WARN_IF(m_ListId.isEmpty(), "xmloff.text", "numbered-paragraph: no ListId"); -- cgit