use more string_view
found by tweaking the loplugin:stringview and making it whitelist getLength Change-Id: Ic15d3703d1fb07658e99e1db1c89e2fa5bc70c19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132771 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -51,7 +51,7 @@ namespace basegfx::internal
|
||||
|
||||
bool importDoubleAndSpaces(double& o_fRetval,
|
||||
sal_Int32& io_rPos,
|
||||
const OUString& rStr,
|
||||
std::u16string_view rStr,
|
||||
const sal_Int32 nLen );
|
||||
|
||||
bool importFlagAndSpaces(sal_Int32& o_nRetval,
|
||||
|
||||
@@ -74,12 +74,12 @@ namespace basegfx::utils
|
||||
|
||||
bool importFromSvgD(
|
||||
B2DPolyPolygon& o_rPolyPolygon,
|
||||
const OUString& rSvgDStatement,
|
||||
std::u16string_view rSvgDStatement,
|
||||
bool bHandleRelativeNextPointCompatible,
|
||||
PointIndexSet* pHelpPointIndexSet)
|
||||
{
|
||||
o_rPolyPolygon.clear();
|
||||
const sal_Int32 nLen(rSvgDStatement.getLength());
|
||||
const sal_Int32 nLen(rSvgDStatement.size());
|
||||
sal_Int32 nPos(0);
|
||||
double nLastX( 0.0 );
|
||||
double nLastY( 0.0 );
|
||||
@@ -664,10 +664,10 @@ namespace basegfx::utils
|
||||
}
|
||||
|
||||
bool importFromSvgPoints( B2DPolygon& o_rPoly,
|
||||
const OUString& rSvgPointsAttribute )
|
||||
std::u16string_view rSvgPointsAttribute )
|
||||
{
|
||||
o_rPoly.clear();
|
||||
const sal_Int32 nLen(rSvgPointsAttribute.getLength());
|
||||
const sal_Int32 nLen(rSvgPointsAttribute.size());
|
||||
sal_Int32 nPos(0);
|
||||
double nX, nY;
|
||||
|
||||
|
||||
@@ -46,9 +46,10 @@ namespace basegfx::internal
|
||||
|
||||
static bool getDoubleChar(double& o_fRetval,
|
||||
sal_Int32& io_rPos,
|
||||
const OUString& rStr)
|
||||
std::u16string_view rStr)
|
||||
{
|
||||
sal_Unicode aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
|
||||
const sal_Int64 nStrSize = rStr.size();
|
||||
sal_Unicode aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
|
||||
OUStringBuffer sNumberString;
|
||||
|
||||
// sign
|
||||
@@ -63,7 +64,7 @@ namespace basegfx::internal
|
||||
{
|
||||
sNumberString.append(rStr[io_rPos]);
|
||||
io_rPos++;
|
||||
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
|
||||
aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
|
||||
}
|
||||
|
||||
// point
|
||||
@@ -71,7 +72,7 @@ namespace basegfx::internal
|
||||
{
|
||||
sNumberString.append(rStr[io_rPos]);
|
||||
io_rPos++;
|
||||
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
|
||||
aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
|
||||
}
|
||||
|
||||
// numbers after point
|
||||
@@ -79,7 +80,7 @@ namespace basegfx::internal
|
||||
{
|
||||
sNumberString.append(rStr[io_rPos]);
|
||||
io_rPos++;
|
||||
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
|
||||
aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
|
||||
}
|
||||
|
||||
// 'e'
|
||||
@@ -87,14 +88,14 @@ namespace basegfx::internal
|
||||
{
|
||||
sNumberString.append(rStr[io_rPos]);
|
||||
io_rPos++;
|
||||
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
|
||||
aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
|
||||
|
||||
// sign for 'e'
|
||||
if(aChar == '+' || aChar == '-')
|
||||
{
|
||||
sNumberString.append(rStr[io_rPos]);
|
||||
io_rPos++;
|
||||
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
|
||||
aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
|
||||
}
|
||||
|
||||
// number for 'e'
|
||||
@@ -102,7 +103,7 @@ namespace basegfx::internal
|
||||
{
|
||||
sNumberString.append(rStr[io_rPos]);
|
||||
io_rPos++;
|
||||
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
|
||||
aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +122,7 @@ namespace basegfx::internal
|
||||
|
||||
bool importDoubleAndSpaces(double& o_fRetval,
|
||||
sal_Int32& io_rPos,
|
||||
const OUString& rStr,
|
||||
std::u16string_view rStr,
|
||||
const sal_Int32 nLen )
|
||||
{
|
||||
if( !getDoubleChar(o_fRetval, io_rPos, rStr) )
|
||||
|
||||
@@ -215,9 +215,9 @@ namespace comphelper
|
||||
}
|
||||
|
||||
|
||||
sal_Unicode OCommonAccessibleText::implGetCharacter( const OUString& rText, sal_Int32 nIndex )
|
||||
sal_Unicode OCommonAccessibleText::implGetCharacter( std::u16string_view rText, sal_Int32 nIndex )
|
||||
{
|
||||
if ( !implIsValidIndex( nIndex, rText.getLength() ) )
|
||||
if ( !implIsValidIndex( nIndex, rText.size() ) )
|
||||
throw IndexOutOfBoundsException();
|
||||
|
||||
return rText[nIndex];
|
||||
|
||||
@@ -197,7 +197,7 @@ bool DocPasswordHelper::IsModifyPasswordCorrect( std::u16string_view aPassword,
|
||||
|
||||
|
||||
sal_uInt32 DocPasswordHelper::GetWordHashAsUINT32(
|
||||
const OUString& aUString )
|
||||
std::u16string_view aUString )
|
||||
{
|
||||
static const sal_uInt16 pInitialCode[] = {
|
||||
0xE1F0, // 1
|
||||
@@ -236,7 +236,7 @@ sal_uInt32 DocPasswordHelper::GetWordHashAsUINT32(
|
||||
};
|
||||
|
||||
sal_uInt32 nResult = 0;
|
||||
sal_uInt32 nLen = aUString.getLength();
|
||||
size_t nLen = aUString.size();
|
||||
|
||||
if ( nLen )
|
||||
{
|
||||
@@ -246,7 +246,7 @@ sal_uInt32 DocPasswordHelper::GetWordHashAsUINT32(
|
||||
sal_uInt16 nHighResult = pInitialCode[nLen - 1];
|
||||
sal_uInt16 nLowResult = 0;
|
||||
|
||||
for ( sal_uInt32 nInd = 0; nInd < nLen; nInd++ )
|
||||
for ( size_t nInd = 0; nInd < nLen; nInd++ )
|
||||
{
|
||||
// NO Encoding during conversion!
|
||||
// The specification says that the low byte should be used in case it is not NULL
|
||||
|
||||
@@ -81,18 +81,18 @@ static sal_uInt8 GetDigit_Impl( char aChar )
|
||||
}
|
||||
|
||||
|
||||
uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassIDRepresentation( const OUString& aClassID )
|
||||
uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassIDRepresentation( std::u16string_view aClassID )
|
||||
{
|
||||
sal_Int32 nLength = aClassID.getLength();
|
||||
size_t nLength = aClassID.size();
|
||||
if ( nLength == 36 )
|
||||
{
|
||||
OString aCharClassID = OUStringToOString( aClassID, RTL_TEXTENCODING_ASCII_US );
|
||||
uno::Sequence< sal_Int8 > aResult( 16 );
|
||||
auto pResult = aResult.getArray();
|
||||
|
||||
sal_Int32 nStrPointer = 0;
|
||||
size_t nStrPointer = 0;
|
||||
sal_Int32 nSeqInd = 0;
|
||||
while( nSeqInd < 16 && nStrPointer + 1 < nLength )
|
||||
while( nSeqInd < 16 && nStrPointer + 1U < nLength )
|
||||
{
|
||||
sal_uInt8 nDigit1 = GetDigit_Impl( aCharClassID[nStrPointer++] );
|
||||
sal_uInt8 nDigit2 = GetDigit_Impl( aCharClassID[nStrPointer++] );
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <comphelper/storagehelper.hxx>
|
||||
#include <comphelper/sequence.hxx>
|
||||
#include <cppuhelper/exc_hlp.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
|
||||
#if HAVE_FEATURE_GPGME
|
||||
# include <context.h>
|
||||
@@ -561,27 +562,27 @@ bool OStorageHelper::IsValidZipEntryFileName(
|
||||
}
|
||||
|
||||
|
||||
bool OStorageHelper::PathHasSegment( const OUString& aPath, const OUString& aSegment )
|
||||
bool OStorageHelper::PathHasSegment( std::u16string_view aPath, std::u16string_view aSegment )
|
||||
{
|
||||
bool bResult = false;
|
||||
const sal_Int32 nPathLen = aPath.getLength();
|
||||
const sal_Int32 nSegLen = aSegment.getLength();
|
||||
const size_t nPathLen = aPath.size();
|
||||
const size_t nSegLen = aSegment.size();
|
||||
|
||||
if ( !aSegment.isEmpty() && nPathLen >= nSegLen )
|
||||
if ( !aSegment.empty() && nPathLen >= nSegLen )
|
||||
{
|
||||
OUString aEndSegment = "/" + aSegment;
|
||||
OUString aEndSegment = OUString::Concat("/") + aSegment;
|
||||
OUString aInternalSegment = aEndSegment + "/";
|
||||
|
||||
if ( aPath.indexOf( aInternalSegment ) >= 0 )
|
||||
if ( aPath.find( aInternalSegment ) != std::u16string_view::npos )
|
||||
bResult = true;
|
||||
|
||||
if ( !bResult && aPath.startsWith( aSegment ) )
|
||||
if ( !bResult && o3tl::starts_with(aPath, aSegment ) )
|
||||
{
|
||||
if ( nPathLen == nSegLen || aPath[nSegLen] == '/' )
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
if ( !bResult && nPathLen > nSegLen && aPath.subView( nPathLen - nSegLen - 1, nSegLen + 1 ) == aEndSegment )
|
||||
if ( !bResult && nPathLen > nSegLen && aPath.substr( nPathLen - nSegLen - 1, nSegLen + 1 ) == aEndSegment )
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -308,8 +308,8 @@ bool XMLFilterJarHelper::copyFile( const Reference< XHierarchicalNameAccess >& x
|
||||
{
|
||||
OUString szPackagePath( encodeZipUri( rURL.copy( sVndSunStarPackage.getLength() ) ) );
|
||||
|
||||
if ( ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, ".." )
|
||||
|| ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, "." ) )
|
||||
if ( ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, u".." )
|
||||
|| ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, u"." ) )
|
||||
throw lang::IllegalArgumentException();
|
||||
|
||||
if( xIfc->hasByHierarchicalName( szPackagePath ) )
|
||||
|
||||
@@ -507,7 +507,7 @@ namespace basegfx::utils
|
||||
@return true, if the string was successfully parsed
|
||||
*/
|
||||
BASEGFX_DLLPUBLIC bool importFromSvgPoints( B2DPolygon& o_rPoly,
|
||||
const OUString& rSvgPointsAttribute );
|
||||
std::u16string_view rSvgPointsAttribute );
|
||||
|
||||
/** Write poly-polygon to SVG.
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace basegfx::utils
|
||||
*/
|
||||
BASEGFX_DLLPUBLIC bool importFromSvgD(
|
||||
B2DPolyPolygon& o_rPolyPoly,
|
||||
const OUString& rSvgDAttribute,
|
||||
std::u16string_view rSvgDAttribute,
|
||||
bool bHandleRelativeNextPointCompatible,
|
||||
PointIndexSet* pHelpPointIndexSet);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace comphelper
|
||||
static bool implIsValidBoundary( css::i18n::Boundary const & rBoundary, sal_Int32 nLength );
|
||||
static bool implIsValidIndex( sal_Int32 nIndex, sal_Int32 nLength );
|
||||
static bool implIsValidRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex, sal_Int32 nLength );
|
||||
static sal_Unicode implGetCharacter( const OUString& rText, sal_Int32 nIndex );
|
||||
static sal_Unicode implGetCharacter( std::u16string_view rText, sal_Int32 nIndex );
|
||||
static OUString implGetTextRange( const OUString& rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex );
|
||||
virtual OUString implGetText() = 0;
|
||||
virtual css::lang::Locale implGetLocale() = 0;
|
||||
|
||||
@@ -145,8 +145,7 @@ public:
|
||||
The hash represented by sal_uInt32
|
||||
*/
|
||||
|
||||
static sal_uInt32 GetWordHashAsUINT32(
|
||||
const OUString& aString );
|
||||
static sal_uInt32 GetWordHashAsUINT32( std::u16string_view aString );
|
||||
|
||||
|
||||
/** This helper function generates the hash code based on the algorithm
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
static OUString GetStringClassIDRepresentation( const css::uno::Sequence< sal_Int8 >& aClassID );
|
||||
|
||||
static css::uno::Sequence< sal_Int8 > GetSequenceClassIDRepresentation( const OUString& aClassID );
|
||||
static css::uno::Sequence< sal_Int8 > GetSequenceClassIDRepresentation( std::u16string_view aClassID );
|
||||
|
||||
|
||||
css::uno::Reference< css::container::XNameAccess > GetObjConfiguration();
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
static bool IsValidZipEntryFileName( const OUString& aName, bool bSlashAllowed );
|
||||
static bool IsValidZipEntryFileName( const sal_Unicode *pChar, sal_Int32 nLength, bool bSlashAllowed );
|
||||
|
||||
static bool PathHasSegment( const OUString& aPath, const OUString& aSegment );
|
||||
static bool PathHasSegment( std::u16string_view aPath, std::u16string_view aSegment );
|
||||
|
||||
// Methods to allow easy use of hierarchical names inside storages
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
static bool CallApproveHandler(const css::uno::Reference< css::task::XInteractionHandler >& xHandler, const css::uno::Any& rRequest, bool bAllowAbort);
|
||||
|
||||
static bool SetWritableForUserOnly( const OUString& aURL );
|
||||
static sal_uInt32 CreatePasswordToModifyHash( const OUString& aPasswd, bool bWriter );
|
||||
static sal_uInt32 CreatePasswordToModifyHash( std::u16string_view aPasswd, bool bWriter );
|
||||
|
||||
private:
|
||||
enum class ShowLockResult { NoLock, Succeeded, Try };
|
||||
|
||||
@@ -43,9 +43,9 @@ private:
|
||||
return (gethex(high) << 4) + gethex(low);
|
||||
}
|
||||
|
||||
void parse(OString const& rString)
|
||||
void parse(std::string_view rString)
|
||||
{
|
||||
if (rString.getLength() != 38)
|
||||
if (rString.size() != 38)
|
||||
return;
|
||||
|
||||
if (rString[0] != '{' || rString[37] != '}' || rString[9] != '-' || rString[14] != '-'
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
Guid() { maGuidArray.fill(0); }
|
||||
|
||||
/// parse the GUID from the string
|
||||
Guid(OString const& rString)
|
||||
Guid(std::string_view rString)
|
||||
{
|
||||
maGuidArray.fill(0);
|
||||
parse(rString);
|
||||
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
const OString &rIsoLang,
|
||||
const OString &rResTyp );
|
||||
|
||||
static bool IsTokenClosed(const OString &rToken);
|
||||
static bool IsTokenClosed(std::string_view rToken);
|
||||
|
||||
public:
|
||||
CfgParser();
|
||||
|
||||
@@ -25,15 +25,15 @@ namespace helper {
|
||||
|
||||
/// Escape all given character in the text
|
||||
OString escapeAll(
|
||||
const OString& rText, const OString& rUnEscaped, const OString& rEscaped );
|
||||
std::string_view rText, std::string_view rUnEscaped, std::string_view rEscaped );
|
||||
/// Unescape all given character in the text
|
||||
OString unEscapeAll(
|
||||
const OString& rText, const OString& rEscaped, std::string_view rUnEscaped );
|
||||
std::string_view rText, std::string_view rEscaped, std::string_view rUnEscaped );
|
||||
|
||||
/// Convert special characters to XML entity references
|
||||
OString QuotHTML( const OString &rString );
|
||||
OString QuotHTML( std::string_view rString );
|
||||
/// Convert XML entity references to single characters
|
||||
OString UnQuotHTML( const OString& rString );
|
||||
OString UnQuotHTML( std::string_view rString );
|
||||
|
||||
/// Check whether text is a valid XML expression
|
||||
bool isWellFormedXML( std::string_view text );
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
PoEntry();
|
||||
PoEntry( const OString& rSourceFile, std::string_view rResType, std::string_view rGroupId,
|
||||
std::string_view rLocalId, const OString& rHelpText, const OString& rText,
|
||||
std::string_view rLocalId, std::string_view rHelpText, const OString& rText,
|
||||
const TYPE eType );
|
||||
~PoEntry();
|
||||
|
||||
|
||||
@@ -134,9 +134,9 @@ CfgParser::~CfgParser()
|
||||
{
|
||||
}
|
||||
|
||||
bool CfgParser::IsTokenClosed(const OString &rToken)
|
||||
bool CfgParser::IsTokenClosed(std::string_view rToken)
|
||||
{
|
||||
return rToken[rToken.getLength() - 2] == '/';
|
||||
return rToken[rToken.size() - 2] == '/';
|
||||
}
|
||||
|
||||
void CfgParser::AddText(
|
||||
|
||||
+24
-22
@@ -12,6 +12,7 @@
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#include <o3tl/safeint.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
#include <rtl/strbuf.hxx>
|
||||
|
||||
#include <helper.hxx>
|
||||
@@ -19,16 +20,16 @@
|
||||
namespace helper {
|
||||
|
||||
OString escapeAll(
|
||||
const OString& rText, const OString& rUnEscaped, const OString& rEscaped )
|
||||
std::string_view rText, std::string_view rUnEscaped, std::string_view rEscaped )
|
||||
{
|
||||
assert( rEscaped.getLength() == 2*rUnEscaped.getLength() );
|
||||
assert( rEscaped.size() == 2*rUnEscaped.size() );
|
||||
OStringBuffer sReturn;
|
||||
for ( sal_Int32 nIndex = 0; nIndex < rText.getLength(); ++nIndex )
|
||||
for ( size_t nIndex = 0; nIndex < rText.size(); ++nIndex )
|
||||
{
|
||||
sal_Int32 nUnEscapedOne = rUnEscaped.indexOf(rText[nIndex]);
|
||||
if( nUnEscapedOne != -1 )
|
||||
size_t nUnEscapedOne = rUnEscaped.find(rText[nIndex]);
|
||||
if( nUnEscapedOne != std::string_view::npos )
|
||||
{
|
||||
sReturn.append(rEscaped.subView(nUnEscapedOne*2,2));
|
||||
sReturn.append(rEscaped.substr(nUnEscapedOne*2,2));
|
||||
}
|
||||
else
|
||||
sReturn.append(rText[nIndex]);
|
||||
@@ -38,17 +39,17 @@ OString escapeAll(
|
||||
|
||||
|
||||
OString unEscapeAll(
|
||||
const OString& rText, const OString& rEscaped, std::string_view rUnEscaped)
|
||||
std::string_view rText, std::string_view rEscaped, std::string_view rUnEscaped)
|
||||
{
|
||||
assert( o3tl::make_unsigned(rEscaped.getLength()) == 2*rUnEscaped.length() );
|
||||
assert( rEscaped.size() == 2*rUnEscaped.length() );
|
||||
OStringBuffer sReturn;
|
||||
const sal_Int32 nLength = rText.getLength();
|
||||
for ( sal_Int32 nIndex = 0; nIndex < nLength; ++nIndex )
|
||||
const size_t nLength = rText.size();
|
||||
for ( size_t nIndex = 0; nIndex < nLength; ++nIndex )
|
||||
{
|
||||
if( rText[nIndex] == '\\' && nIndex+1 < nLength )
|
||||
{
|
||||
sal_Int32 nEscapedOne = rEscaped.indexOf(rText.subView(nIndex,2));
|
||||
if( nEscapedOne != -1 )
|
||||
size_t nEscapedOne = rEscaped.find(rText.substr(nIndex,2));
|
||||
if( nEscapedOne != std::string_view::npos )
|
||||
{
|
||||
sReturn.append(rUnEscaped[nEscapedOne/2]);
|
||||
++nIndex;
|
||||
@@ -65,10 +66,10 @@ OString unEscapeAll(
|
||||
}
|
||||
|
||||
|
||||
OString QuotHTML(const OString &rString)
|
||||
OString QuotHTML(std::string_view rString)
|
||||
{
|
||||
OStringBuffer sReturn;
|
||||
for (sal_Int32 i = 0; i < rString.getLength(); ++i)
|
||||
for (size_t i = 0; i < rString.size(); ++i)
|
||||
{
|
||||
switch (rString[i])
|
||||
{
|
||||
@@ -85,7 +86,7 @@ OString QuotHTML(const OString &rString)
|
||||
sReturn.append("'");
|
||||
break;
|
||||
case '&':
|
||||
if (rString.match("&", i))
|
||||
if (o3tl::starts_with(rString.substr(i), "&"))
|
||||
sReturn.append('&');
|
||||
else
|
||||
sReturn.append("&");
|
||||
@@ -98,23 +99,24 @@ OString QuotHTML(const OString &rString)
|
||||
return sReturn.makeStringAndClear();
|
||||
}
|
||||
|
||||
OString UnQuotHTML( const OString& rString )
|
||||
OString UnQuotHTML( std::string_view rString )
|
||||
{
|
||||
OStringBuffer sReturn;
|
||||
for (sal_Int32 i = 0; i != rString.getLength();) {
|
||||
if (rString.match("&", i)) {
|
||||
for (size_t i = 0; i != rString.size();) {
|
||||
auto tmp = rString.substr(i);
|
||||
if (o3tl::starts_with(tmp, "&")) {
|
||||
sReturn.append('&');
|
||||
i += RTL_CONSTASCII_LENGTH("&");
|
||||
} else if (rString.match("<", i)) {
|
||||
} else if (o3tl::starts_with(tmp, "<")) {
|
||||
sReturn.append('<');
|
||||
i += RTL_CONSTASCII_LENGTH("<");
|
||||
} else if (rString.match(">", i)) {
|
||||
} else if (o3tl::starts_with(tmp, ">")) {
|
||||
sReturn.append('>');
|
||||
i += RTL_CONSTASCII_LENGTH(">");
|
||||
} else if (rString.match(""", i)) {
|
||||
} else if (o3tl::starts_with(tmp, """)) {
|
||||
sReturn.append('"');
|
||||
i += RTL_CONSTASCII_LENGTH(""");
|
||||
} else if (rString.match("'", i)) {
|
||||
} else if (o3tl::starts_with(tmp, "'")) {
|
||||
sReturn.append('\'');
|
||||
i += RTL_CONSTASCII_LENGTH("'");
|
||||
} else {
|
||||
|
||||
+13
-13
@@ -80,9 +80,9 @@ public:
|
||||
namespace
|
||||
{
|
||||
// Convert a normal string to msg/po output string
|
||||
OString lcl_GenMsgString(const OString& rString)
|
||||
OString lcl_GenMsgString(std::string_view rString)
|
||||
{
|
||||
if ( rString.isEmpty() )
|
||||
if ( rString.empty() )
|
||||
return "\"\"";
|
||||
|
||||
OString sResult =
|
||||
@@ -107,11 +107,11 @@ namespace
|
||||
}
|
||||
|
||||
// Convert msg string to normal form
|
||||
OString lcl_GenNormString(const OString& rString)
|
||||
OString lcl_GenNormString(std::string_view rString)
|
||||
{
|
||||
return
|
||||
helper::unEscapeAll(
|
||||
rString.copy(1,rString.getLength()-2),
|
||||
rString.substr(1,rString.size()-2),
|
||||
"\\n""\\t""\\r""\\\\""\\\"",
|
||||
"\n""\t""\r""\\""\"");
|
||||
}
|
||||
@@ -150,7 +150,7 @@ void GenPoEntry::writeToFile(std::ofstream& rOFStream) const
|
||||
<< std::endl;
|
||||
if ( !m_sMsgStrPlural.empty() )
|
||||
for(auto & line : m_sMsgStrPlural)
|
||||
rOFStream << line.copy(0,10) << lcl_GenMsgString(line.copy(10)) << std::endl;
|
||||
rOFStream << line.copy(0,10) << lcl_GenMsgString(line.subView(10)) << std::endl;
|
||||
else
|
||||
rOFStream << "msgstr "
|
||||
<< lcl_GenMsgString(m_sMsgStr) << std::endl;
|
||||
@@ -192,29 +192,29 @@ void GenPoEntry::readFromFile(std::ifstream& rIFStream)
|
||||
}
|
||||
else if (sLine.startsWith("msgctxt "))
|
||||
{
|
||||
m_sMsgCtxt = lcl_GenNormString(sLine.copy(8));
|
||||
m_sMsgCtxt = lcl_GenNormString(sLine.subView(8));
|
||||
pLastMsg = &m_sMsgCtxt;
|
||||
}
|
||||
else if (sLine.startsWith("msgid "))
|
||||
{
|
||||
m_sMsgId = lcl_GenNormString(sLine.copy(6));
|
||||
m_sMsgId = lcl_GenNormString(sLine.subView(6));
|
||||
pLastMsg = &m_sMsgId;
|
||||
}
|
||||
else if (sLine.startsWith("msgid_plural "))
|
||||
{
|
||||
m_sMsgIdPlural = lcl_GenNormString(sLine.copy(13));
|
||||
m_sMsgIdPlural = lcl_GenNormString(sLine.subView(13));
|
||||
pLastMsg = &m_sMsgIdPlural;
|
||||
}
|
||||
else if (sLine.startsWith("msgstr "))
|
||||
{
|
||||
m_sMsgStr = lcl_GenNormString(sLine.copy(7));
|
||||
m_sMsgStr = lcl_GenNormString(sLine.subView(7));
|
||||
pLastMsg = &m_sMsgStr;
|
||||
}
|
||||
else if (sLine.startsWith("msgstr["))
|
||||
{
|
||||
// assume there are no more than 10 plural forms...
|
||||
// and that plural strings are never split to multi-line in po
|
||||
m_sMsgStrPlural.push_back(sLine.subView(0,10) + lcl_GenNormString(sLine.copy(10)));
|
||||
m_sMsgStrPlural.push_back(sLine.subView(0,10) + lcl_GenNormString(sLine.subView(10)));
|
||||
}
|
||||
else if (sLine.startsWith("\"") && pLastMsg)
|
||||
{
|
||||
@@ -241,7 +241,7 @@ PoEntry::PoEntry()
|
||||
|
||||
PoEntry::PoEntry(
|
||||
const OString& rSourceFile, std::string_view rResType, std::string_view rGroupId,
|
||||
std::string_view rLocalId, const OString& rHelpText,
|
||||
std::string_view rLocalId, std::string_view rHelpText,
|
||||
const OString& rText, const TYPE eType )
|
||||
: m_bIsInitialized( false )
|
||||
{
|
||||
@@ -253,7 +253,7 @@ PoEntry::PoEntry(
|
||||
throw NOGROUPID;
|
||||
else if ( rText.isEmpty() )
|
||||
throw NOSTRING;
|
||||
else if ( rHelpText.getLength() == 5 )
|
||||
else if ( rHelpText.size() == 5 )
|
||||
throw WRONGHELPTEXT;
|
||||
|
||||
m_pGenPo.reset( new GenPoEntry() );
|
||||
@@ -277,7 +277,7 @@ PoEntry::PoEntry(
|
||||
m_pGenPo->setMsgCtxt(sMsgCtxt);
|
||||
m_pGenPo->setMsgId(rText);
|
||||
m_pGenPo->setExtractCom(OStringConcatenation(
|
||||
( !rHelpText.isEmpty() ? rHelpText + "\n" : OString()) +
|
||||
( !rHelpText.empty() ? OString::Concat(rHelpText) + "\n" : OString()) +
|
||||
genKeyId( m_pGenPo->getReference().front() + rGroupId + rLocalId + rResType + rText ) ));
|
||||
m_bIsInitialized = true;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ uno::Reference< drawing::XShape > OReportDrawPage::CreateShape( SdrObject *pObj
|
||||
OUString sName;
|
||||
xObj = pObj->getSdrModelFromSdrObject().GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject(
|
||||
::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(
|
||||
"80243D39-6741-46C5-926E-069164FF87BB"), sName );
|
||||
u"80243D39-6741-46C5-926E-069164FF87BB"), sName );
|
||||
OSL_ENSURE(xObj.is(),"Embedded Object could not be created!");
|
||||
|
||||
/**************************************************
|
||||
|
||||
@@ -3044,11 +3044,11 @@ const std::shared_ptr<const SfxFilter>& SfxMedium::GetFilter() const
|
||||
return pImpl->m_pFilter;
|
||||
}
|
||||
|
||||
sal_uInt32 SfxMedium::CreatePasswordToModifyHash( const OUString& aPasswd, bool bWriter )
|
||||
sal_uInt32 SfxMedium::CreatePasswordToModifyHash( std::u16string_view aPasswd, bool bWriter )
|
||||
{
|
||||
sal_uInt32 nHash = 0;
|
||||
|
||||
if ( !aPasswd.isEmpty() )
|
||||
if ( !aPasswd.empty() )
|
||||
{
|
||||
if ( bWriter )
|
||||
{
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace slideshow::internal
|
||||
class PathAnimation : public NumberAnimation
|
||||
{
|
||||
public:
|
||||
PathAnimation( const OUString& rSVGDPath,
|
||||
PathAnimation( std::u16string_view rSVGDPath,
|
||||
sal_Int16 nAdditive,
|
||||
const ShapeManagerSharedPtr& rShapeManager,
|
||||
const ::basegfx::B2DVector& rSlideSize,
|
||||
|
||||
@@ -53,10 +53,10 @@
|
||||
|
||||
namespace {
|
||||
|
||||
bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) {
|
||||
if (s1.getLength() == s2.getLength()) {
|
||||
for (sal_Int32 i = 0; i < s1.getLength();) {
|
||||
if (s1[i] == '%' && s2[i] == '%' && s1.getLength() - i > 2
|
||||
bool equalIgnoreEscapeCase(std::u16string_view s1, std::u16string_view s2) {
|
||||
if (s1.size() == s2.size()) {
|
||||
for (size_t i = 0; i < s1.size();) {
|
||||
if (s1[i] == '%' && s2[i] == '%' && s1.size() - i > 2
|
||||
&& rtl::isAsciiHexDigit(s1[i + 1])
|
||||
&& rtl::isAsciiHexDigit(s1[i + 2])
|
||||
&& rtl::isAsciiHexDigit(s2[i + 1])
|
||||
@@ -77,9 +77,9 @@ bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) {
|
||||
}
|
||||
}
|
||||
|
||||
sal_Int32 parseScheme(OUString const & uriReference) {
|
||||
if (uriReference.getLength() >= 2 && rtl::isAsciiAlpha(uriReference[0])) {
|
||||
for (sal_Int32 i = 0; i < uriReference.getLength(); ++i) {
|
||||
sal_Int32 parseScheme(std::u16string_view uriReference) {
|
||||
if (uriReference.size() >= 2 && rtl::isAsciiAlpha(uriReference[0])) {
|
||||
for (size_t i = 0; i < uriReference.size(); ++i) {
|
||||
sal_Unicode c = uriReference[i];
|
||||
if (c == ':') {
|
||||
return i;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <sal/types.h>
|
||||
#include <o3tl/safeint.hxx>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
@@ -49,8 +50,8 @@ int getHexWeight(sal_Unicode c) {
|
||||
: -1;
|
||||
}
|
||||
|
||||
int parseEscaped(OUString const & part, sal_Int32 * index) {
|
||||
if (part.getLength() - *index < 3 || part[*index] != '%') {
|
||||
int parseEscaped(std::u16string_view part, sal_Int32 * index) {
|
||||
if (part.size() - *index < 3 || part[*index] != '%') {
|
||||
return -1;
|
||||
}
|
||||
int n1 = getHexWeight(part[*index + 1]);
|
||||
@@ -63,10 +64,10 @@ int parseEscaped(OUString const & part, sal_Int32 * index) {
|
||||
}
|
||||
|
||||
OUString parsePart(
|
||||
OUString const & part, bool namePart, sal_Int32 * index)
|
||||
std::u16string_view part, bool namePart, sal_Int32 * index)
|
||||
{
|
||||
OUStringBuffer buf(64);
|
||||
while (*index < part.getLength()) {
|
||||
while (o3tl::make_unsigned(*index) < part.size()) {
|
||||
sal_Unicode c = part[*index];
|
||||
if (namePart ? c == '?' : c == '&' || c == '=') {
|
||||
break;
|
||||
@@ -150,25 +151,25 @@ OUString encodeNameOrParamFragment(OUString const & fragment) {
|
||||
RTL_TEXTENCODING_UTF8);
|
||||
}
|
||||
|
||||
bool parseSchemeSpecificPart(OUString const & part) {
|
||||
sal_Int32 len = part.getLength();
|
||||
bool parseSchemeSpecificPart(std::u16string_view part) {
|
||||
size_t len = part.size();
|
||||
sal_Int32 i = 0;
|
||||
if (parsePart(part, true, &i).isEmpty() || part[0] == '/') {
|
||||
return false;
|
||||
}
|
||||
if (i == len) {
|
||||
if (o3tl::make_unsigned(i) == len) {
|
||||
return true;
|
||||
}
|
||||
for (;;) {
|
||||
++i; // skip '?' or '&'
|
||||
if (parsePart(part, false, &i).isEmpty() || i == len
|
||||
if (parsePart(part, false, &i).isEmpty() || o3tl::make_unsigned(i) == len
|
||||
|| part[i] != '=')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
++i;
|
||||
parsePart(part, false, &i);
|
||||
if (i == len) {
|
||||
if (o3tl::make_unsigned(i) == len) {
|
||||
return true;
|
||||
}
|
||||
if (part[i] != '&') {
|
||||
|
||||
@@ -185,8 +185,8 @@ void PackageUri::init() const
|
||||
if ( m_aPath.indexOf( "//" ) != -1
|
||||
|| m_aPath.indexOf( "%2F" ) != -1
|
||||
|| m_aPath.indexOf( "%2f" ) != -1
|
||||
|| ::comphelper::OStorageHelper::PathHasSegment( m_aPath, ".." )
|
||||
|| ::comphelper::OStorageHelper::PathHasSegment( m_aPath, "." ) )
|
||||
|| ::comphelper::OStorageHelper::PathHasSegment( m_aPath, u".." )
|
||||
|| ::comphelper::OStorageHelper::PathHasSegment( m_aPath, u"." ) )
|
||||
{
|
||||
// error, but remember that we did an init().
|
||||
m_aPath = "/";
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <o3tl/unreachable.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <unoidl/unoidl.hxx>
|
||||
|
||||
@@ -165,11 +166,11 @@ template<typename T> rtl::Reference<T> getCurrentPad(
|
||||
return pad;
|
||||
}
|
||||
|
||||
bool nameHasSameIdentifierAs(OUString const & name, OUString const & identifier)
|
||||
bool nameHasSameIdentifierAs(std::u16string_view name, std::u16string_view identifier)
|
||||
{
|
||||
sal_Int32 i = name.lastIndexOf('.') + 1;
|
||||
return identifier.getLength() == name.getLength() - i
|
||||
&& name.match(identifier, i);
|
||||
size_t i = name.rfind('.') + 1;
|
||||
return identifier.size() == name.size() - i
|
||||
&& o3tl::starts_with(name.substr(i), identifier);
|
||||
}
|
||||
|
||||
bool coerce(
|
||||
|
||||
@@ -126,9 +126,9 @@ private:
|
||||
OUString uri_;
|
||||
};
|
||||
|
||||
bool isValidFileName(OUString const & name, bool directory) {
|
||||
for (sal_Int32 i = 0;; ++i) {
|
||||
if (i == name.getLength()) {
|
||||
bool isValidFileName(std::u16string_view name, bool directory) {
|
||||
for (size_t i = 0;; ++i) {
|
||||
if (i == name.size()) {
|
||||
if (i == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ bool isValidFileName(OUString const & name, bool directory) {
|
||||
if (i == 0 || name[i - 1] == '_') {
|
||||
return false;
|
||||
}
|
||||
return !directory && name.subView(i + 1) == u"idl";
|
||||
return !directory && name.substr(i + 1) == u"idl";
|
||||
} else if (c == '_') {
|
||||
//TODO: Ignore case of name[0] only for case-insensitive file systems:
|
||||
if (i == 0 || name[i - 1] == '_') {
|
||||
|
||||
@@ -183,14 +183,14 @@ bool isSimpleType(std::u16string_view type) {
|
||||
// <other> ::= <capital> | "a"--"z" | "0"--"9"
|
||||
// <capital> ::= "A"--"Z"
|
||||
//
|
||||
bool isIdentifier(OUString const & type, bool scoped) {
|
||||
if (type.isEmpty()) {
|
||||
bool isIdentifier(std::u16string_view type, bool scoped) {
|
||||
if (type.empty()) {
|
||||
return false;
|
||||
}
|
||||
for (sal_Int32 i = 0; i != type.getLength(); ++i) {
|
||||
for (size_t i = 0; i != type.size(); ++i) {
|
||||
sal_Unicode c = type[i];
|
||||
if (c == '.') {
|
||||
if (!scoped || i == 0 || i == type.getLength() - 1
|
||||
if (!scoped || i == 0 || i == type.size() - 1
|
||||
|| type[i - 1] == '.')
|
||||
{
|
||||
return false;
|
||||
@@ -247,11 +247,11 @@ void checkTypeName(
|
||||
}
|
||||
|
||||
void checkEntityName(
|
||||
rtl::Reference< MappedFile > const & file, OUString const & name)
|
||||
rtl::Reference< MappedFile > const & file, std::u16string_view name)
|
||||
{
|
||||
if (isSimpleType(name) || !isIdentifier(name, false)) {
|
||||
throw FileFormatException(
|
||||
file->uri, "UNOIDL format: bad entity name \"" + name + "\"");
|
||||
file->uri, OUString::Concat("UNOIDL format: bad entity name \"") + name + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user