use more string_view

found by tweaking the stringview loplugin

Change-Id: I92203ba99642bef7951ffa146184c5562cb31d09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163744
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-02-22 12:59:26 +02:00
parent bf35f2b36f
commit 7840effb1d
41 changed files with 155 additions and 135 deletions

View file

@ -197,15 +197,15 @@ void TestString::testReverseString()
}
void TestString::testReverseCodePoints() {
CPPUNIT_ASSERT_EQUAL(OUString(), comphelper::string::reverseCodePoints(""));
CPPUNIT_ASSERT_EQUAL(OUString("cba"), comphelper::string::reverseCodePoints("abc"));
CPPUNIT_ASSERT_EQUAL(OUString(), comphelper::string::reverseCodePoints(u""));
CPPUNIT_ASSERT_EQUAL(OUString("cba"), comphelper::string::reverseCodePoints(u"abc"));
CPPUNIT_ASSERT_EQUAL(
u"w\U0010FFFFv\U00010000u"_ustr,
comphelper::string::reverseCodePoints(u"u\U00010000v\U0010FFFFw"_ustr));
comphelper::string::reverseCodePoints(u"u\U00010000v\U0010FFFFw"));
static sal_Unicode const malformed[] = {0xDC00, 0xD800};
CPPUNIT_ASSERT_EQUAL(
u"\U00010000"_ustr,
comphelper::string::reverseCodePoints(OUString(malformed, std::size(malformed))));
comphelper::string::reverseCodePoints(std::u16string_view(malformed, std::size(malformed))));
}
void TestString::testSplit()

View file

@ -525,11 +525,11 @@ OUString reverseString(std::u16string_view rStr)
return sBuf.makeStringAndClear();
}
OUString reverseCodePoints(OUString const & str) {
auto const len = str.getLength();
OUString reverseCodePoints(std::u16string_view str) {
auto const len = str.size();
OUStringBuffer buf(len);
for (auto i = len; i != 0;) {
buf.appendUtf32(str.iterateCodePoints(&i, -1));
for (sal_Int32 i = len; i != 0;) {
buf.appendUtf32(o3tl::iterateCodePoints(str, &i, -1));
}
return buf.makeStringAndClear();
}

View file

@ -84,6 +84,7 @@
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
#include <sal/types.h>
#include <o3tl/string_view.hxx>
#include "access.hxx"
#include "broadcaster.hxx"
@ -109,9 +110,9 @@ namespace {
// Conservatively forbid what is either not an XML Char (including lone
// surrogates, even though they should not appear in well-formed UNO OUString
// instances anyway), or is a slash (as it causes problems in path syntax):
bool isValidName(OUString const & name, bool setMember) {
for (sal_Int32 i = 0; i != name.getLength();) {
sal_uInt32 c = name.iterateCodePoints(&i);
bool isValidName(std::u16string_view name, bool setMember) {
for (sal_Int32 i = 0; i != static_cast<sal_Int32>(name.size());) {
sal_uInt32 c = o3tl::iterateCodePoints(name, &i);
if ((c < 0x20 && !(c == 0x09 || c == 0x0A || c == 0x0D))
|| rtl::isSurrogate(c) || c == 0xFFFE || c == 0xFFFF
|| (!setMember && c == '/'))
@ -119,7 +120,7 @@ bool isValidName(OUString const & name, bool setMember) {
return false;
}
}
return !name.isEmpty();
return !name.empty();
}
}

View file

@ -840,17 +840,17 @@ OUString getColExprForDefaultSettingVal(ConnectionSettings const *settings)
OUString("pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid, true)");
}
css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
css::uno::Sequence< sal_Int32 > string2intarray( std::u16string_view str )
{
css::uno::Sequence< sal_Int32 > ret;
const sal_Int32 strlen = str.getLength();
if( str.getLength() > 1 )
const sal_Int32 strlen = str.size();
if( strlen > 1 )
{
sal_Int32 start = 0;
sal_uInt32 c;
for (;;)
{
c = str.iterateCodePoints(&start);
c = o3tl::iterateCodePoints(str, &start);
if (!iswspace(c))
break;
if ( start == strlen)
@ -860,7 +860,7 @@ css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
return ret;
for (;;)
{
c = str.iterateCodePoints(&start);
c = o3tl::iterateCodePoints(str, &start);
if ( !iswspace(c) )
break;
if ( start == strlen)
@ -879,7 +879,7 @@ css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
break;
if ( start == strlen)
return ret;
c=str.iterateCodePoints(&start);
c = o3tl::iterateCodePoints(str, &start);
} while ( c );
do
{
@ -888,7 +888,7 @@ css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
if ( start == strlen)
return ret;
digits.append(OUString(&c, 1));
c = str.iterateCodePoints(&start);
c = o3tl::iterateCodePoints(str, &start);
} while ( c );
vec.push_back( o3tl::toInt32(digits) );
do
@ -897,11 +897,11 @@ css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
break;
if ( start == strlen)
return ret;
c = str.iterateCodePoints(&start);
c = o3tl::iterateCodePoints(str, &start);
} while ( c );
if ( c == L'}' )
break;
if ( str.iterateCodePoints(&start) != L',' )
if ( o3tl::iterateCodePoints(str, &start) != L',' )
return ret;
if ( start == strlen)
return ret;

View file

@ -131,7 +131,7 @@ void fillAttnum2attnameMap(
const OUString &schema,
const OUString &table );
css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str );
css::uno::Sequence< sal_Int32 > string2intarray( std::u16string_view str );
css::uno::Sequence< OUString > convertMappedIntArray2StringArray(
const Int2StringMap &map, const css::uno::Sequence< sal_Int32> &source );

View file

@ -770,7 +770,7 @@ bool SvxAutoCorrect::FnSetINetAttr( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
}
// DOI citation recognition
bool SvxAutoCorrect::FnSetDOIAttr( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
bool SvxAutoCorrect::FnSetDOIAttr( SvxAutoCorrDoc& rDoc, std::u16string_view rTxt,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang )
{

View file

@ -159,7 +159,7 @@ COMPHELPER_DLLPUBLIC OUString reverseString(std::u16string_view rStr);
/** Reverse an OUString's Unicode code points.
*/
COMPHELPER_DLLPUBLIC OUString reverseCodePoints(OUString const & str);
COMPHELPER_DLLPUBLIC OUString reverseCodePoints(std::u16string_view str);
namespace detail

View file

@ -419,7 +419,7 @@ public:
bool FnSetINetAttr( SvxAutoCorrDoc&, const OUString&,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang );
bool FnSetDOIAttr( SvxAutoCorrDoc&, const OUString&,
bool FnSetDOIAttr( SvxAutoCorrDoc&, std::u16string_view,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang );
bool FnChgWeightUnderl( SvxAutoCorrDoc&, const OUString&,

View file

@ -354,7 +354,7 @@ jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>>* parInfo);
* @param sUserPath colon-separated string of user classpaths
* @return list of user classpaths
*/
JVMFWK_DLLPUBLIC std::vector<OUString> jfw_convertUserPathList(OUString const& sUserPath);
JVMFWK_DLLPUBLIC std::vector<OUString> jfw_convertUserPathList(std::u16string_view sUserPath);
/** determines if a path points to a Java installation.

View file

@ -38,12 +38,12 @@ namespace com::sun::star::uno { template <class interface_type> class Reference;
class SFX2_DLLPUBLIC SfxFrameHTMLWriter
{
SAL_DLLPRIVATE static void OutMeta( SvStream& rStrm,
const char *pIndent, const OUString& rName,
const OUString& rContent, bool bHTTPEquiv,
const char *pIndent, std::u16string_view rName,
std::u16string_view rContent, bool bHTTPEquiv,
OUString *pNonConvertableChars = nullptr );
SAL_DLLPRIVATE inline static void OutMeta( SvStream& rStrm,
const char *pIndent, const char *pName,
const OUString& rContent, bool bHTTPEquiv,
std::u16string_view rContent, bool bHTTPEquiv,
OUString *pNonConvertableChars = nullptr );
public:
@ -58,7 +58,7 @@ public:
inline void SfxFrameHTMLWriter::OutMeta( SvStream& rStrm,
const char *pIndent, const char *pName,
const OUString& rContent, bool bHTTPEquiv,
std::u16string_view rContent, bool bHTTPEquiv,
OUString *pNonConvertableChars )
{
OUString sTmp = OUString::createFromAscii(pName);

View file

@ -120,7 +120,7 @@ SVL_DLLPUBLIC OUString FindFirstURLInText(OUString const & rText,
INetURLObject::EncodeMechanism eMechanism = INetURLObject::EncodeMechanism::WasEncoded,
rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
SVL_DLLPUBLIC OUString FindFirstDOIInText(OUString const & rText,
SVL_DLLPUBLIC OUString FindFirstDOIInText(std::u16string_view rText,
sal_Int32 & rBegin,
sal_Int32 & rEnd,
CharClass const & rCharClass);

View file

@ -42,14 +42,14 @@ struct HTMLOutEvent
struct HTMLOutFuncs
{
SVT_DLLPUBLIC static OString ConvertStringToHTML( const OUString& sSrc,
SVT_DLLPUBLIC static OString ConvertStringToHTML( std::u16string_view sSrc,
OUString *pNonConvertableChars = nullptr );
SVT_DLLPUBLIC static SvStream& Out_AsciiTag( SvStream&, std::string_view rStr,
bool bOn = true);
SVT_DLLPUBLIC static SvStream& Out_Char( SvStream&, sal_uInt32 cChar,
OUString *pNonConvertableChars = nullptr );
SVT_DLLPUBLIC static SvStream& Out_String( SvStream&, const OUString&,
SVT_DLLPUBLIC static SvStream& Out_String( SvStream&, std::u16string_view,
OUString *pNonConvertableChars = nullptr );
SVT_DLLPUBLIC static SvStream& Out_Hex( SvStream&, sal_uInt32 nHex, sal_uInt8 nLen );
SVT_DLLPUBLIC static SvStream& Out_Color( SvStream&, const Color&, bool bXHTML = false );
@ -64,7 +64,7 @@ struct HTMLOutFuncs
SVT_DLLPUBLIC static SvStream& OutScript( SvStream& rStrm,
const OUString& rBaseURL,
std::u16string_view rSource,
const OUString& rLanguage,
std::u16string_view rLanguage,
ScriptType eScriptType,
const OUString& rSrc,
const OUString *pSBLibrary,

View file

@ -38,7 +38,7 @@ private:
private:
/// helpers
void implSaveScreenshot(const BitmapEx& rScreenshot, const OUString& rScreenshotId);
void implSaveScreenshot(const BitmapEx& rScreenshot, std::u16string_view rScreenshotId);
void saveScreenshot(VclAbstractDialog const& rDialog);
void saveScreenshot(weld::Window& rDialog);

View file

@ -32,6 +32,7 @@
#include <osl/process.h>
#endif
#include <osl/thread.hxx>
#include <o3tl/string_view.hxx>
#include <jvmfwk/framework.hxx>
#include <vendorbase.hxx>
#include <vendorplugin.hxx>
@ -133,31 +134,36 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI
}
}
std::vector<OUString> jfw_convertUserPathList(OUString const& sUserPath)
std::vector<OUString> jfw_convertUserPathList(std::u16string_view sUserPath)
{
std::vector<OUString> result;
sal_Int32 nIdx = 0;
do
{
sal_Int32 nextColon = sUserPath.indexOf(SAL_PATHSEPARATOR, nIdx);
OUString sToken(sUserPath.subView(nIdx, nextColon > 0 ? nextColon - nIdx
: sUserPath.getLength() - nIdx));
size_t nextColon = sUserPath.find(SAL_PATHSEPARATOR, nIdx);
std::u16string_view sToken;
if (nextColon != 0 && nextColon != std::u16string_view::npos)
sToken = sUserPath.substr(nIdx, nextColon - nIdx);
else
sToken = sUserPath.substr(nIdx, sUserPath.size() - nIdx);
// Check if we are in bootstrap variable mode (class path starts with '$').
// Then the class path must be in URL format.
if (sToken.startsWith("$"))
if (o3tl::starts_with(sToken, u"$"))
{
// Detect open bootstrap variables - they might contain colons - we need to skip those.
sal_Int32 nBootstrapVarStart = sToken.indexOf("${");
if (nBootstrapVarStart >= 0)
size_t nBootstrapVarStart = sToken.find(u"${");
if (nBootstrapVarStart != std::u16string_view::npos)
{
sal_Int32 nBootstrapVarEnd = sToken.indexOf("}", nBootstrapVarStart);
if (nBootstrapVarEnd == -1)
size_t nBootstrapVarEnd = sToken.find(u"}", nBootstrapVarStart);
if (nBootstrapVarEnd == std::u16string_view::npos)
{
// Current colon is part of bootstrap variable - skip it!
nextColon = sUserPath.indexOf(SAL_PATHSEPARATOR, nextColon + 1);
sToken = sUserPath.subView(nIdx, nextColon > 0 ? nextColon - nIdx
: sUserPath.getLength() - nIdx);
nextColon = sUserPath.find(SAL_PATHSEPARATOR, nextColon + 1);
if (nextColon != 0 && nextColon != std::u16string_view::npos)
sToken = sUserPath.substr(nIdx, nextColon - nIdx);
else
sToken = sUserPath.substr(nIdx, sUserPath.size() - nIdx);
}
}
}

View file

@ -46,6 +46,7 @@
#include <linguistic/misc.hxx>
#include <linguistic/hyphdta.hxx>
#include <o3tl/string_view.hxx>
using namespace osl;
using namespace com::sun::star;

View file

@ -50,6 +50,7 @@
#include <stdio.h>
#include <osl/diagnose.h>
#include <o3tl/unit_conversion.hxx>
#include <o3tl/string_view.hxx>
#include <htmlexp.hxx>
#include <global.hxx>
@ -378,7 +379,7 @@ void ScHTMLExport::WriteHeader()
for(sal_Int32 nPos {0};;)
{
rStrm.WriteChar( '\"' );
OUT_STR( rList.getToken( 0, ';', nPos ) );
OUT_STR( o3tl::getToken( rList, 0, ';', nPos ) );
rStrm.WriteChar( '\"' );
if (nPos<0)
break;
@ -896,7 +897,7 @@ void ScHTMLExport::WriteTables()
}
if ( bAll )
OUT_COMMENT( "**************************************************************************" );
OUT_COMMENT( u"**************************************************************************" );
}
}
@ -1250,7 +1251,7 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC
for (sal_Int32 nPos {0};;)
{
OString aTmpStr = HTMLOutFuncs::ConvertStringToHTML(
rList.getToken( 0, ';', nPos ),
o3tl::getToken( rList, 0, ';', nPos ),
&aNonConvertibleChars);
aStr.append(aTmpStr);
if (nPos<0)

View file

@ -833,7 +833,7 @@ void ScCsvGrid::ImplSetTextLineSep(
InvalidateGfx();
}
void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine )
void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, std::u16string_view rTextLine )
{
if( nLine < GetFirstVisLine() ) return;
@ -848,7 +848,7 @@ void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine )
std::vector<OUString>& rStrVec = maTexts[ nLineIx ];
rStrVec.clear();
sal_uInt32 nColCount = GetColumnCount();
sal_Int32 nStrLen = rTextLine.getLength();
sal_Int32 nStrLen = rTextLine.size();
sal_Int32 nStrIx = 0;
for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx )
{
@ -856,7 +856,7 @@ void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine )
sal_Int32 nLastIx = nStrIx;
ScImportExport::CountVisualWidth( rTextLine, nLastIx, nColWidth );
sal_Int32 nLen = std::min( CSV_MAXSTRLEN, nLastIx - nStrIx );
rStrVec.push_back( rTextLine.copy( nStrIx, nLen ) );
rStrVec.push_back( OUString(rTextLine.substr( nStrIx, nLen )) );
nStrIx = nStrIx + nLen;
}
InvalidateGfx();

View file

@ -495,12 +495,12 @@ bool ScImportExport::ExportStream( SvStream& rStrm, const OUString& rBaseURL, So
// tdf#104927
// http://www.unicode.org/reports/tr11/
sal_Int32 ScImportExport::CountVisualWidth(const OUString& rStr, sal_Int32& nIdx, sal_Int32 nMaxWidth)
sal_Int32 ScImportExport::CountVisualWidth(std::u16string_view rStr, sal_Int32& nIdx, sal_Int32 nMaxWidth)
{
sal_Int32 nWidth = 0;
while(nIdx < rStr.getLength() && nWidth < nMaxWidth)
while(nIdx < static_cast<sal_Int32>(rStr.size()) && nWidth < nMaxWidth)
{
sal_uInt32 nCode = rStr.iterateCodePoints(&nIdx);
sal_uInt32 nCode = o3tl::iterateCodePoints(rStr, &nIdx);
auto nEaWidth = u_getIntPropertyValue(nCode, UCHAR_EAST_ASIAN_WIDTH);
if (nEaWidth == U_EA_FULLWIDTH || nEaWidth == U_EA_WIDE)
@ -509,10 +509,10 @@ sal_Int32 ScImportExport::CountVisualWidth(const OUString& rStr, sal_Int32& nIdx
nWidth += 1;
}
if (nIdx < rStr.getLength())
if (nIdx < static_cast<sal_Int32>(rStr.size()))
{
sal_Int32 nTmpIdx = nIdx;
sal_uInt32 nCode = rStr.iterateCodePoints(&nTmpIdx);
sal_uInt32 nCode = o3tl::iterateCodePoints(rStr, &nTmpIdx);
if (u_getIntPropertyValue(nCode, UCHAR_DEFAULT_IGNORABLE_CODE_POINT))
nIdx = nTmpIdx;
@ -520,7 +520,7 @@ sal_Int32 ScImportExport::CountVisualWidth(const OUString& rStr, sal_Int32& nIdx
return nWidth;
}
sal_Int32 ScImportExport::CountVisualWidth(const OUString& rStr)
sal_Int32 ScImportExport::CountVisualWidth(std::u16string_view rStr)
{
sal_Int32 nIdx = 0;
return CountVisualWidth(rStr, nIdx, SAL_MAX_INT32);

View file

@ -237,7 +237,7 @@ public:
sal_Int32 nLine, const OUString& rTextLine,
const OUString& rSepChars, sal_Unicode cTextSep, bool bMergeSep, bool bRemoveSpace = false );
/** Fills all cells of a line with the passed text (fixed width mode). */
void ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine );
void ImplSetTextLineFix( sal_Int32 nLine, std::u16string_view rTextLine );
/** Returns the text of the specified cell. */
OUString GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const;

View file

@ -118,12 +118,12 @@ public:
@param nMaxWidth the maximum width to count.
@return the sum of the width of counted characters.
**/
static sal_Int32 CountVisualWidth(const OUString& rStr, sal_Int32& nIdx, sal_Int32 nMaxWidth);
static sal_Int32 CountVisualWidth(std::u16string_view rStr, sal_Int32& nIdx, sal_Int32 nMaxWidth);
/** ScImportExport::CountVisualWidth
@return the sum of the visual width of the whole string.
**/
static sal_Int32 CountVisualWidth(const OUString& rStr);
static sal_Int32 CountVisualWidth(std::u16string_view rStr);
//! only if stream is only used in own (!) memory
static void SetNoEndianSwap( SvStream& rStrm );

View file

@ -374,7 +374,7 @@ OUString TextAttribToHTMLString( SfxItemSet const * pSet, HtmlState* pState )
}
// escapes a string for html
OUString StringToHTMLString( const OUString& rString )
OUString StringToHTMLString( std::u16string_view rString )
{
SvMemoryStream aMemStm;
HTMLOutFuncs::Out_String( aMemStm, rString );

View file

@ -81,7 +81,7 @@ namespace pdfi
static void sortElements( Element* pElement );
static OUString SubstituteBidiMirrored(const OUString& rString);
static OUString SubstituteBidiMirrored(std::u16string_view rString);
private:
void processGlyphLine();

View file

@ -36,6 +36,7 @@
#include <basegfx/utils/canvastools.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <i18nutil/unicode.hxx>
#include <o3tl/string_view.hxx>
using namespace com::sun::star;
@ -763,13 +764,13 @@ void PDFIProcessor::sortElements(Element* pEle)
/* Produce mirrored-image for each code point which has the Bidi_Mirrored property, within a string.
This need to be done in forward order.
*/
OUString PDFIProcessor::SubstituteBidiMirrored(const OUString& rString)
OUString PDFIProcessor::SubstituteBidiMirrored(std::u16string_view rString)
{
const sal_Int32 nLen = rString.getLength();
const sal_Int32 nLen = rString.size();
OUStringBuffer aMirror(nLen);
for (sal_Int32 i = 0; i < nLen;) {
const sal_uInt32 nCodePoint = rString.iterateCodePoints(&i);
const sal_uInt32 nCodePoint = o3tl::iterateCodePoints(rString, &i);
aMirror.appendUtf32(unicode::GetMirroredChar(nCodePoint));
}
return aMirror.makeStringAndClear();

View file

@ -50,8 +50,8 @@ char const sHTML_SC_no[] = "NO";
void SfxFrameHTMLWriter::OutMeta( SvStream& rStrm,
const char *pIndent,
const OUString& rName,
const OUString& rContent,
std::u16string_view rName,
std::u16string_view rContent,
bool bHTTPEquiv,
OUString *pNonConvertableChars )
{
@ -79,7 +79,7 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const OUString& rBaseURL,
const char *pIndent,
OUString *pNonConvertableChars )
{
OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_content_type, "text/html; charset=utf-8", true,
OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_content_type, u"text/html; charset=utf-8", true,
pNonConvertableChars );
// Title (regardless if empty)

View file

@ -167,10 +167,10 @@ private:
};
css::uno::Reference< css::uri::XUriReference > parseGeneric(
OUString const & scheme, OUString const & schemeSpecificPart)
OUString const & scheme, std::u16string_view schemeSpecificPart)
{
sal_Int32 len = schemeSpecificPart.getLength();
sal_Int32 i = 0;
size_t len = schemeSpecificPart.size();
size_t i = 0;
bool hasAuthority = false;
OUString authority;
if (len - i >= 2 && schemeSpecificPart[i] == '/'
@ -183,19 +183,19 @@ css::uno::Reference< css::uri::XUriReference > parseGeneric(
++i;
}
hasAuthority = true;
authority = schemeSpecificPart.copy(n, i - n);
authority = schemeSpecificPart.substr(n, i - n);
}
sal_Int32 n = i;
i = schemeSpecificPart.indexOf('?', i);
if (i == -1) {
i = schemeSpecificPart.find('?', i);
if (i == std::u16string_view::npos) {
i = len;
}
OUString path = schemeSpecificPart.copy(n, i - n);
OUString path( schemeSpecificPart.substr(n, i - n) );
bool hasQuery = false;
OUString query;
if (i != len) {
hasQuery = true;
query = schemeSpecificPart.copy(i + 1);
query = schemeSpecificPart.substr(i + 1);
}
return new UriReference(
scheme, hasAuthority, authority, path, hasQuery, query);

View file

@ -745,17 +745,17 @@ OUString URIHelper::FindFirstURLInText(OUString const & rText,
return OUString();
}
OUString URIHelper::FindFirstDOIInText(OUString const & rText,
OUString URIHelper::FindFirstDOIInText(std::u16string_view rText,
sal_Int32 & rBegin,
sal_Int32 & rEnd,
CharClass const & rCharClass)
{
if (rBegin > rEnd || rEnd > rText.getLength())
if (rBegin > rEnd || rEnd > static_cast<sal_Int32>(rText.size()))
return OUString();
sal_Int32 start = 7;
sal_Int32 count = rEnd-rBegin;
OUString candidate(rText.subView(rBegin, count));
OUString candidate(rText.substr(rBegin, count));
// Match with regex "doi:10\.\d{4,9}\/[-._;()\/:a-zA-Z0-9]+"
if (candidate.startsWithIgnoreAsciiCase("doi:10."))
{

View file

@ -725,10 +725,10 @@ bool NatNumTakesParameters(sal_Int16 nNum)
// is there a 3-letter bank code in NatNum12 param (but not
// followed by an equal mark, like in the date code "NNN=")?
static bool lcl_isNatNum12Currency( const OUString& sParam )
static bool lcl_isNatNum12Currency( std::u16string_view sParam )
{
sal_Int32 nUpper = 0;
sal_Int32 nLen = sParam.getLength();
sal_Int32 nLen = sParam.size();
for (sal_Int32 n = 0; n < nLen; ++n)
{
sal_Unicode c = sParam[n];

View file

@ -34,6 +34,7 @@
#include <svl/urihelper.hxx>
#include <rtl/character.hxx>
#include <tools/debug.hxx>
#include <o3tl/string_view.hxx>
#include <sstream>
@ -495,13 +496,13 @@ static OString lcl_FlushToAscii()
return aDest.makeStringAndClear();
}
OString HTMLOutFuncs::ConvertStringToHTML( const OUString& rSrc,
OString HTMLOutFuncs::ConvertStringToHTML( std::u16string_view rSrc,
OUString *pNonConvertableChars )
{
OStringBuffer aDest;
for( sal_Int32 i=0, nLen = rSrc.getLength(); i < nLen; )
for( sal_Int32 i=0, nLen = rSrc.size(); i < nLen; )
aDest.append(lcl_ConvertCharToHTML(
rSrc.iterateCodePoints(&i), pNonConvertableChars));
o3tl::iterateCodePoints(rSrc, &i), pNonConvertableChars));
aDest.append(lcl_FlushToAscii());
return aDest.makeStringAndClear();
}
@ -527,12 +528,12 @@ SvStream& HTMLOutFuncs::Out_Char( SvStream& rStream, sal_uInt32 c,
return rStream;
}
SvStream& HTMLOutFuncs::Out_String( SvStream& rStream, const OUString& rOUStr,
SvStream& HTMLOutFuncs::Out_String( SvStream& rStream, std::u16string_view rOUStr,
OUString *pNonConvertableChars )
{
sal_Int32 nLen = rOUStr.getLength();
sal_Int32 nLen = rOUStr.size();
for( sal_Int32 n = 0; n < nLen; )
HTMLOutFuncs::Out_Char( rStream, rOUStr.iterateCodePoints(&n),
HTMLOutFuncs::Out_Char( rStream, o3tl::iterateCodePoints(rOUStr, &n),
pNonConvertableChars );
HTMLOutFuncs::FlushToAscii( rStream );
return rStream;
@ -773,7 +774,7 @@ SvStream& HTMLOutFuncs::Out_ImageMap( SvStream& rStream,
SvStream& HTMLOutFuncs::OutScript( SvStream& rStrm,
const OUString& rBaseURL,
std::u16string_view rSource,
const OUString& rLanguage,
std::u16string_view rLanguage,
ScriptType eScriptType,
const OUString& rSrc,
const OUString *pSBLibrary,
@ -782,7 +783,7 @@ SvStream& HTMLOutFuncs::OutScript( SvStream& rStrm,
// script is not indented!
OStringBuffer sOut("<" OOO_STRING_SVTOOLS_HTML_script);
if( !rLanguage.isEmpty() )
if( !rLanguage.empty() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_language "=\"");
rStrm.WriteOString( sOut );

View file

@ -23,6 +23,7 @@
#include <swtypes.hxx>
#include <unotools/syslocale.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <o3tl/string_view.hxx>
#include <map>
#ifdef _NEED_TO_DEBUG_MAPPING
@ -60,11 +61,11 @@ lcl_GetSpecialExtraName(const OUString& rExtraName, const bool bIsUIName )
return rExtraName;
}
bool lcl_SuffixIsUser(const OUString & rString)
bool lcl_SuffixIsUser(std::u16string_view rString)
{
// Interesting, why the rest must be longer than 1 character? It is so
// since commit 4fbc9dd48b7cebb304010e7337b1bbc3936c7923 (2001-08-16)
return rString.getLength() > 8 && rString.endsWith(" (user)");
return rString.size() > 8 && o3tl::ends_with(rString, u" (user)");
}
void lcl_CheckSuffixAndDelete(OUString & rString)

View file

@ -259,7 +259,7 @@ SwHTMLWriter& OutHTML_DrawFrameFormatAsMarquee( SwHTMLWriter& rWrt,
HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_MARQUEE;
if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
nFrameFlags |= HTML_FRMOPTS_MARQUEE_CSS1;
OString aEndTags = rWrt.OutFrameFormatOptions(rFormat, OUString(), nFrameFlags);
OString aEndTags = rWrt.OutFrameFormatOptions(rFormat, u"", nFrameFlags);
if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
rWrt.OutCSS1_FrameFormatOptions( rFormat, nFrameFlags, &rSdrObject );

View file

@ -414,7 +414,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField,
}
}
HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.copy( nPos, nChunkLen ) );
HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.subView( nPos, nChunkLen ) );
rWrt.m_bTagOn = false;
while( nItems )
@ -423,7 +423,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField,
}
else
{
HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.copy( nPos, nChunkLen ) );
HTMLOutFuncs::Out_String( rWrt.Strm(), sExpand.subView( nPos, nChunkLen ) );
}
nPos = nEndPos;
}

View file

@ -505,7 +505,7 @@ void SwHTMLWriter::OutFrameFormat( AllHtmlFlags nMode, const SwFrameFormat& rFra
}
OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
const OUString& rAlternateText,
std::u16string_view rAlternateText,
HtmlFrmOpts nFrameOpts )
{
OString sRetEndTags;
@ -535,7 +535,7 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat,
}
// ALT
if( (nFrameOpts & HtmlFrmOpts::Alt) && !rAlternateText.isEmpty() )
if( (nFrameOpts & HtmlFrmOpts::Alt) && !rAlternateText.empty() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_alt "=\"");
Strm().WriteOString( sOut );
@ -1631,7 +1631,7 @@ static SwHTMLWriter & OutHTML_FrameFormatAsMulticol( SwHTMLWriter& rWrt,
HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_MULTICOL;
if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
nFrameFlags |= HTML_FRMOPTS_MULTICOL_CSS1;
rWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
rWrt.OutFrameFormatOptions(rFrameFormat, u"", nFrameFlags);
if( rWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr )
rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
@ -1677,7 +1677,7 @@ static SwHTMLWriter& OutHTML_FrameFormatAsSpacer( SwHTMLWriter& rWrt, const SwFr
rWrt.Strm().WriteOString( sOut );
// ALIGN, WIDTH, HEIGHT
OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, OUString(), HTML_FRMOPTS_SPACER);
OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, u"", HTML_FRMOPTS_SPACER);
rWrt.Strm().WriteChar( '>' );
if( !aEndTags.isEmpty() )
@ -1712,7 +1712,7 @@ static SwHTMLWriter& OutHTML_FrameFormatAsDivOrSpan( SwHTMLWriter& rWrt,
HtmlFrmOpts nFrameFlags = HTML_FRMOPTS_DIV;
if( rWrt.IsHTMLMode( HTMLMODE_BORDER_NONE ) )
nFrameFlags |= HtmlFrmOpts::SNoBorder;
OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, OUString(), nFrameFlags);
OString aEndTags = rWrt.OutFrameFormatOptions(rFrameFormat, u"", nFrameFlags);
rWrt.OutCSS1_FrameFormatOptions( rFrameFormat, nFrameFlags );
rWrt.Strm().WriteChar( '>' );

View file

@ -1015,7 +1015,7 @@ SwHTMLWriter& OutHTML_DrawFrameFormatAsControl( SwHTMLWriter& rWrt,
}
OString aEndTags;
if( nFrameOpts != HtmlFrmOpts::NONE )
aEndTags = rWrt.OutFrameFormatOptions(rFormat, OUString(), nFrameOpts);
aEndTags = rWrt.OutFrameFormatOptions(rFormat, u"", nFrameOpts);
if( rWrt.m_bCfgOutStyles )
{

View file

@ -426,7 +426,7 @@ OUString SwHTMLWriter::GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnot
}
void SwHTMLWriter::OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote,
const OUString& rNum,
std::u16string_view rNum,
sal_uInt16 nScript )
{
const SwEndNoteInfo *pInfo;

View file

@ -474,7 +474,7 @@ public:
void OutFootEndNoteInfo();
void OutFootEndNotes();
OUString GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnote );
void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, const OUString& rNum,
void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, std::u16string_view rNum,
sal_uInt16 nScript );
void OutBasic(const SwHTMLWriter& rHTMLWrt);
@ -509,7 +509,7 @@ public:
// ALT/ALIGN/WIDTH/HEIGHT/HSPACE/VSPACE option of current
// frame format output and maybe add a <BR CLEAR=...> at the
// beginning of rEndTags
OString OutFrameFormatOptions( const SwFrameFormat& rFrameFormat, const OUString& rAltText,
OString OutFrameFormatOptions( const SwFrameFormat& rFrameFormat, std::u16string_view rAltText,
HtmlFrmOpts nFrameOpts );
void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, const OUString& rAltText, HtmlFrmOpts nFrameOpts);

View file

@ -24,15 +24,23 @@
namespace {
void splitHelpId( const OUString& rHelpId, OUString& rDirname, OUString &rBasename )
void splitHelpId( std::u16string_view rHelpId, std::u16string_view& rDirname, std::u16string_view& rBasename )
{
sal_Int32 nIndex = rHelpId.lastIndexOf( '/' );
size_t nIndex = rHelpId.rfind( '/' );
if( nIndex > 0 )
rDirname = rHelpId.subView( 0, nIndex );
if( nIndex != 0 && nIndex != std::u16string_view::npos)
rDirname = rHelpId.substr( 0, nIndex );
if( rHelpId.getLength() > nIndex+1 )
rBasename = rHelpId.subView( nIndex+1 );
if (nIndex == std::u16string_view::npos)
{
if( rHelpId.size() > 0 )
rBasename = rHelpId;
}
else
{
if( rHelpId.size() > nIndex+1 )
rBasename = rHelpId.substr( nIndex+1 );
}
}
}
@ -71,11 +79,11 @@ void ScreenshotTest::setUp()
}
}
void ScreenshotTest::implSaveScreenshot(const BitmapEx& rScreenshot, const OUString& rScreenshotId)
void ScreenshotTest::implSaveScreenshot(const BitmapEx& rScreenshot, std::u16string_view rScreenshotId)
{
OUString aDirname, aBasename;
splitHelpId(rScreenshotId, aDirname, aBasename);
aDirname = g_aScreenshotDirectory + "/" + aDirname +
std::u16string_view aSplitDirname, aBasename;
splitHelpId(rScreenshotId, aSplitDirname, aBasename);
OUString aDirname = g_aScreenshotDirectory + "/" + aSplitDirname +
( (maCurrentLanguage == "en-US") ? OUString() : "/" + maCurrentLanguage );
auto const dirUrl = m_directories.getURLFromWorkdir(aDirname);

View file

@ -155,7 +155,7 @@ public:
virtual void SAL_CALL disposing( const lang::EventObject& Source ) override;
private:
void setNoProxyList( const OUString & rNoProxyList );
void setNoProxyList( std::u16string_view rNoProxyList );
};
@ -777,28 +777,28 @@ void SAL_CALL InternetProxyDecider_Impl::disposing(const lang::EventObject&)
void InternetProxyDecider_Impl::setNoProxyList(
const OUString & rNoProxyList )
std::u16string_view rNoProxyList )
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
m_aNoProxyList.clear();
if ( rNoProxyList.isEmpty() )
if ( rNoProxyList.empty() )
return;
// List of connection endpoints hostname[:port],
// separated by semicolon. Wildcards allowed.
sal_Int32 nPos = 0;
sal_Int32 nEnd = rNoProxyList.indexOf( ';' );
sal_Int32 nLen = rNoProxyList.getLength();
size_t nPos = 0;
size_t nEnd = rNoProxyList.find( ';' );
size_t nLen = rNoProxyList.size();
do
{
if ( nEnd == -1 )
if ( nEnd == std::u16string_view::npos )
nEnd = nLen;
OUString aToken = rNoProxyList.copy( nPos, nEnd - nPos );
OUString aToken( rNoProxyList.substr( nPos, nEnd - nPos ) );
if ( !aToken.isEmpty() )
{
@ -870,7 +870,7 @@ void InternetProxyDecider_Impl::setNoProxyList(
if ( nEnd != nLen )
{
nPos = nEnd + 1;
nEnd = rNoProxyList.indexOf( ';', nPos );
nEnd = rNoProxyList.find( ';', nPos );
}
}
while ( nEnd != nLen );

View file

@ -314,7 +314,7 @@ public:
// Helper method for input method handling: Calculate cursor index in (UTF-16) OUString,
// starting at nCursorIndex, moving number of characters (not UTF-16 codepoints) specified
// in nOffset, nChars.
static Selection CalcDeleteSurroundingSelection(const OUString& rSurroundingText,
static Selection CalcDeleteSurroundingSelection(std::u16string_view rSurroundingText,
sal_Int32 nCursorIndex, int nOffset, int nChars);
};

View file

@ -63,7 +63,7 @@ namespace vcl
~TextLayoutCommon() COVERITY_NOEXCEPT_FALSE;
private:
OUString GetCenterEllipsisString(OUString const& rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth);
OUString GetCenterEllipsisString(std::u16string_view rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth);
OUString GetEndEllipsisString(OUString const& rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth, bool bClipText);
OUString GetNewsEllipsisString(OUString const& rOrigStr, tools::Long nMaxWidth, DrawTextFlags nStyle);
};

View file

@ -7571,7 +7571,7 @@ weld::Window* SalFrame::GetFrameWeld() const
return m_xFrameWeld.get();
}
Selection SalFrame::CalcDeleteSurroundingSelection(const OUString& rSurroundingText,
Selection SalFrame::CalcDeleteSurroundingSelection(std::u16string_view rSurroundingText,
sal_Int32 nCursorIndex, int nOffset, int nChars)
{
Selection aInvalid(SAL_MAX_UINT32, SAL_MAX_UINT32);
@ -7581,9 +7581,9 @@ Selection SalFrame::CalcDeleteSurroundingSelection(const OUString& rSurroundingT
if (nOffset > 0)
{
while (nOffset && nCursorIndex < rSurroundingText.getLength())
while (nOffset && nCursorIndex < static_cast<sal_Int32>(rSurroundingText.size()))
{
rSurroundingText.iterateCodePoints(&nCursorIndex, 1);
o3tl::iterateCodePoints(rSurroundingText, &nCursorIndex, 1);
--nOffset;
}
}
@ -7591,7 +7591,7 @@ Selection SalFrame::CalcDeleteSurroundingSelection(const OUString& rSurroundingT
{
while (nOffset && nCursorIndex > 0)
{
rSurroundingText.iterateCodePoints(&nCursorIndex, -1);
o3tl::iterateCodePoints(rSurroundingText, &nCursorIndex, -1);
++nOffset;
}
}
@ -7605,9 +7605,9 @@ Selection SalFrame::CalcDeleteSurroundingSelection(const OUString& rSurroundingT
sal_Int32 nCursorEndIndex(nCursorIndex);
sal_Int32 nCount(0);
while (nCount < nChars && nCursorEndIndex < rSurroundingText.getLength())
while (nCount < nChars && nCursorEndIndex < static_cast<sal_Int32>(rSurroundingText.size()))
{
rSurroundingText.iterateCodePoints(&nCursorEndIndex, 1);
o3tl::iterateCodePoints(rSurroundingText, &nCursorEndIndex, 1);
++nCount;
}

View file

@ -65,13 +65,13 @@ namespace vcl
TextLayoutCommon::~TextLayoutCommon() COVERITY_NOEXCEPT_FALSE
{}
OUString TextLayoutCommon::GetCenterEllipsisString(OUString const& rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth)
OUString TextLayoutCommon::GetCenterEllipsisString(std::u16string_view rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth)
{
OUStringBuffer aTmpStr(rOrigStr);
// speed it up by removing all but 1.33x as many as the break pos.
sal_Int32 nEraseChars = std::max<sal_Int32>(4, rOrigStr.getLength() - (nIndex*4)/3);
while(nEraseChars < rOrigStr.getLength() && GetTextWidth(aTmpStr.toString(), 0, aTmpStr.getLength()) > nMaxWidth)
sal_Int32 nEraseChars = std::max<sal_Int32>(4, rOrigStr.size() - (nIndex*4)/3);
while(nEraseChars < static_cast<sal_Int32>(rOrigStr.size()) && GetTextWidth(aTmpStr.toString(), 0, aTmpStr.getLength()) > nMaxWidth)
{
aTmpStr = rOrigStr;
sal_Int32 i = (aTmpStr.getLength() - nEraseChars)/2;