loplugin:stringviewparam convert methods using indexOf

.. and lastIndexOf, which convert to find and rfind

Change-Id: I6c4156cf904774c0d867f85a4c2785dba7593f62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132445
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2022-04-02 13:31:19 +02:00
parent 0dfa444f39
commit 1927b51993
73 changed files with 204 additions and 207 deletions
+6 -12
View File
@@ -971,20 +971,14 @@ void EditorWindow::SetSourceInBasic()
// Returns the position of the last character of any of the following
// EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found
sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex )
sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex )
{
sal_Int32 iRetPos = -1;
size_t iLF = rStr.find( LINE_SEP, fromIndex );
if( iLF != std::u16string_view::npos )
return iLF;
sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex );
if( iLF != -1 )
{
iRetPos = iLF;
}
else
{
iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex );
}
return iRetPos;
size_t iCR = rStr.find( LINE_SEP_CR, fromIndex );
return iCR == std::u16string_view::npos ? -1 : iCR;
}
void EditorWindow::CreateEditEngine()
+1 -1
View File
@@ -53,7 +53,7 @@ constexpr auto LINE_SEP_CR = 0x0D;
constexpr auto LINE_SEP = 0x0A;
// Implementation: baside2b.cxx
sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex );
sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex );
// Meaning of bToBeKilled:
// While being in a reschedule-loop, I may not destroy the window.
+1 -1
View File
@@ -60,7 +60,7 @@ void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep, sal
}
static bool ImpStrChr( const OUString& str, sal_Unicode c ) { return str.indexOf(c) >= 0; }
static bool ImpStrChr( std::u16string_view str, sal_Unicode c ) { return str.find(c) != std::u16string_view::npos; }
// scanning a string according to BASIC-conventions
+7 -7
View File
@@ -48,16 +48,16 @@ bool dumpNamespaceOpen(
}
bool dumpNamespaceClose(
FileStream & out, OUString const & entityName, bool fullModuleType)
FileStream & out, std::u16string_view entityName, bool fullModuleType)
{
bool bOutput = false;
bool bFirst = true;
for (sal_Int32 i = 0; i >= 0;) {
i = entityName.indexOf('.', i);
if (i >= 0) {
for (size_t i = 0; i != std::u16string_view::npos;) {
i = entityName.find('.', i);
if (i != std::u16string_view::npos) {
++i;
}
if (fullModuleType || i >= 0) {
if (fullModuleType || i != std::u16string_view::npos) {
if (!bFirst) {
out << " ";
}
@@ -69,8 +69,8 @@ bool dumpNamespaceClose(
return bOutput;
}
void dumpTypeIdentifier(FileStream & out, OUString const & entityName) {
out << entityName.subView(entityName.lastIndexOf('.') + 1);
void dumpTypeIdentifier(FileStream & out, std::u16string_view entityName) {
out << entityName.substr(entityName.rfind('.') + 1);
}
}
+3 -2
View File
@@ -20,6 +20,7 @@
#pragma once
#include <sal/config.h>
#include <string_view>
namespace rtl
{
@@ -31,9 +32,9 @@ namespace codemaker::cppumaker
{
bool dumpNamespaceOpen(FileStream& out, rtl::OUString const& entityName, bool fullModuleType);
bool dumpNamespaceClose(FileStream& out, rtl::OUString const& entityName, bool fullModuleType);
bool dumpNamespaceClose(FileStream& out, std::u16string_view entityName, bool fullModuleType);
void dumpTypeIdentifier(FileStream& out, rtl::OUString const& entityName);
void dumpTypeIdentifier(FileStream& out, std::u16string_view entityName);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+2 -1
View File
@@ -137,7 +137,8 @@ DeclRefExpr const* relevantCXXMemberCallExpr(CXXMemberCallExpr const* expr)
else if (auto const i = d->getIdentifier())
{
auto const n = i->getName();
if (n == "endsWith" || n == "isEmpty" || n == "startsWith" || n == "subView")
if (n == "endsWith" || n == "isEmpty" || n == "startsWith" || n == "subView"
|| n == "indexOf" || n == "lastIndexOf")
{
good = true;
}
+4 -4
View File
@@ -148,14 +148,14 @@ sal_Int32 Data::parseSegment(
}
OUString Data::fullTemplateName(
OUString const & component, OUString const & name)
std::u16string_view component, std::u16string_view name)
{
if (component.indexOf(':') != -1 || name.indexOf(':') != -1) {
if (component.find(':') != std::u16string_view::npos || name.find(':') != std::u16string_view::npos) {
throw css::uno::RuntimeException(
"bad component/name pair containing colon " + component + "/" +
OUString::Concat("bad component/name pair containing colon ") + component + "/" +
name);
}
return component + ":" + name;
return OUString::Concat(component) + ":" + name;
}
bool Data::equalTemplateNames(
+1 -1
View File
@@ -58,7 +58,7 @@ struct Data {
bool * setElement, OUString * templateName);
static OUString fullTemplateName(
OUString const & component, OUString const & name);
std::u16string_view component, std::u16string_view name);
//TODO: better rules under which circumstances a short template name matches
static bool equalTemplateNames(
+2 -2
View File
@@ -115,8 +115,8 @@ bool parseBoolean(xmlreader::Span const & text) {
}
OUString parseTemplateReference(
OUString const & component, bool hasNodeType,
OUString const & nodeType, OUString const * defaultTemplateName)
std::u16string_view component, bool hasNodeType,
std::u16string_view nodeType, OUString const * defaultTemplateName)
{
if (!hasNodeType) {
if (defaultTemplateName != nullptr) {
+2 -2
View File
@@ -38,8 +38,8 @@ Type parseType(
bool parseBoolean(xmlreader::Span const & text);
OUString parseTemplateReference(
OUString const & component, bool hasNodeType,
OUString const & nodeType, OUString const * defaultTemplateName);
std::u16string_view component, bool hasNodeType,
std::u16string_view nodeType, OUString const * defaultTemplateName);
}
@@ -165,15 +165,15 @@ namespace connectivity
namespace dbtools
{
static bool isCharOk(sal_Unicode c,const OUString& _rSpecials)
static bool isCharOk(sal_Unicode c, std::u16string_view _rSpecials)
{
return ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) ||
c == '_' || _rSpecials.indexOf(c) != -1);
c == '_' || _rSpecials.find(c) != std::u16string_view::npos);
}
bool isValidSQLName(const OUString& rName,const OUString& _rSpecials)
bool isValidSQLName(const OUString& rName, std::u16string_view _rSpecials)
{
// Test for correct naming (in SQL sense)
// This is important for table names for example
@@ -202,7 +202,7 @@ bool isValidSQLName(const OUString& rName,const OUString& _rSpecials)
}
// Creates a new name if necessary
OUString convertName2SQLName(const OUString& rName,const OUString& _rSpecials)
OUString convertName2SQLName(const OUString& rName, std::u16string_view _rSpecials)
{
if(isValidSQLName(rName,_rSpecials))
return rName;
+1 -1
View File
@@ -1015,7 +1015,7 @@ bool ODbaseTable::CreateImpl()
{
OSL_ENSURE(!m_pFileStream, "SequenceError");
if ( m_pConnection->isCheckEnabled() && ::dbtools::convertName2SQLName(m_Name,OUString()) != m_Name )
if ( m_pConnection->isCheckEnabled() && ::dbtools::convertName2SQLName(m_Name, u"") != m_Name )
{
const OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
STR_SQL_NAME_ERROR,
+3 -3
View File
@@ -288,11 +288,11 @@ namespace
return aPureMethod;
}
OUString GetEventDisplayImage(const OUString &rURL)
OUString GetEventDisplayImage(std::u16string_view rURL)
{
if (rURL.isEmpty())
if (rURL.empty())
return OUString();
sal_Int32 nIndex = rURL.indexOf(aVndSunStarUNO);
size_t nIndex = rURL.find(aVndSunStarUNO);
bool bUNO = nIndex == 0;
return bUNO ? OUString(RID_SVXBMP_COMPONENT) : OUString(RID_SVXBMP_MACRO);
}
+11 -4
View File
@@ -67,10 +67,11 @@ std::vector<OUString> lcl_splitColumnPart(const OUString& sColumnPart)
return sReturn;
}
sal_Int32 lcl_getAutoIncrementDefault(const OUString& sColumnDef)
sal_Int32 lcl_getAutoIncrementDefault(std::u16string_view sColumnDef)
{
// TODO what if there are more spaces?
if (sColumnDef.indexOf("GENERATED BY DEFAULT AS IDENTITY") > 0)
size_t nPos = sColumnDef.find(u"GENERATED BY DEFAULT AS IDENTITY");
if (nPos != std::u16string_view::npos && nPos > 0)
{
// TODO parse starting sequence stated by "START WITH"
return 0;
@@ -93,9 +94,15 @@ OUString lcl_getDefaultValue(const OUString& sColumnDef)
return OUString{};
}
bool lcl_isNullable(const OUString& sColumnDef) { return sColumnDef.indexOf("NOT NULL") < 0; }
bool lcl_isNullable(std::u16string_view sColumnDef)
{
return sColumnDef.find(u"NOT NULL") == std::u16string_view::npos;
}
bool lcl_isPrimaryKey(const OUString& sColumnDef) { return sColumnDef.indexOf("PRIMARY KEY") >= 0; }
bool lcl_isPrimaryKey(std::u16string_view sColumnDef)
{
return sColumnDef.find(u"PRIMARY KEY") != std::u16string_view::npos;
}
sal_Int32 lcl_getDataTypeFromHsql(std::u16string_view sTypeName)
{
@@ -159,18 +159,18 @@ namespace sdbtools
{
}
static ::connectivity::ErrorCondition validateName_getErrorCondition( const OUString& _rName )
static ::connectivity::ErrorCondition validateName_getErrorCondition( std::u16string_view _rName )
{
if ( ( _rName.indexOf( u'"' ) >= 0 )
|| ( _rName.indexOf( u'\'' ) >= 0 )
|| ( _rName.indexOf( u'`' ) >= 0 )
|| ( _rName.indexOf( u'\x0091' ) >= 0 )
|| ( _rName.indexOf( u'\x0092' ) >= 0 )
|| ( _rName.indexOf( u'\x00B4' ) >= 0 ) // removed unparsable chars
if ( ( _rName.find( u'"' ) != std::u16string_view::npos )
|| ( _rName.find( u'\'' ) != std::u16string_view::npos )
|| ( _rName.find( u'`' ) != std::u16string_view::npos )
|| ( _rName.find( u'\x0091' ) != std::u16string_view::npos )
|| ( _rName.find( u'\x0092' ) != std::u16string_view::npos )
|| ( _rName.find( u'\x00B4' ) != std::u16string_view::npos ) // removed unparsable chars
)
return ErrorCondition::DB_QUERY_NAME_WITH_QUOTES;
if ( _rName.indexOf( '/') >= 0 )
if ( _rName.find( '/') != std::u16string_view::npos )
return ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES;
return 0;
+2 -2
View File
@@ -21,12 +21,12 @@
namespace dbaui
{
static bool isCharOk(sal_Unicode _cChar,bool _bFirstChar, const OUString& _sAllowedChars)
static bool isCharOk(sal_Unicode _cChar,bool _bFirstChar, std::u16string_view _sAllowedChars)
{
return (
(_cChar >= 'A' && _cChar <= 'Z') ||
_cChar == '_' ||
_sAllowedChars.indexOf(_cChar) != -1 ||
_sAllowedChars.find(_cChar) != std::u16string_view::npos ||
(!_bFirstChar && (_cChar >= '0' && _cChar <= '9')) ||
(_cChar >= 'a' && _cChar <= 'z')
);
+2 -2
View File
@@ -49,7 +49,7 @@ namespace dbaui
OFieldDescription const * _pSrcField,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
const OUString& _sExtraChars,
std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase);
@@ -57,7 +57,7 @@ namespace dbaui
weld::TreeView const * _pLeft,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
const OUString& _sExtraChars,
std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase);
+1 -1
View File
@@ -395,7 +395,7 @@ namespace dbaui
OUString convertColumnName( const TColumnFindFunctor& _rCmpFunctor,
const OUString& _sColumnName,
const OUString& _sExtraChars,
std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen);
TOTypeInfoSP convertType(const TOTypeInfoSP&_pType, bool& _bNotConvert);
+2 -2
View File
@@ -275,7 +275,7 @@ void OWizColumnSelect::createNewColumn( weld::TreeView* _pListbox,
OFieldDescription const * _pSrcField,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
const OUString& _sExtraChars,
std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase)
{
@@ -301,7 +301,7 @@ void OWizColumnSelect::moveColumn( weld::TreeView* _pRight,
weld::TreeView const * _pLeft,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
const OUString& _sExtraChars,
std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase)
{
+1 -1
View File
@@ -1359,7 +1359,7 @@ void OCopyTableWizard::setOperation( const sal_Int16 _nOperation )
OUString OCopyTableWizard::convertColumnName(const TColumnFindFunctor& _rCmpFunctor,
const OUString& _sColumnName,
const OUString& _sExtraChars,
std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen)
{
OUString sAlias = _sColumnName;
@@ -35,13 +35,13 @@ using namespace com::sun::star::beans;
namespace {
OUString supportedByType( const OUString& clipBoardFormat, const OUString& resultString, const OUString& checkType)
OUString supportedByType( const OUString& clipBoardFormat, std::u16string_view resultString, const OUString& checkType)
{
OUString sTypeName;
if ( clipBoardFormat.match("doctype:") )
{
OUString tryStr = clipBoardFormat.copy(8);
if (resultString.indexOf(tryStr) >= 0)
std::u16string_view tryStr = clipBoardFormat.subView(8);
if (resultString.find(tryStr) != std::u16string_view::npos)
{
sTypeName = checkType;
}
@@ -419,7 +419,7 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp )
if( xStorable.is() )
{
OUString const ext(".xml");
utl::TempFile aTempFile(OUString(), true, &ext);
utl::TempFile aTempFile(u"", true, &ext);
OUString aTempFileURL( aTempFile.GetURL() );
const application_info_impl* pAppInfo = getApplicationInfo( m_xFilterInfo->maExportService );
@@ -579,7 +579,7 @@ void XMLFilterTestDialog::import( const OUString& rURL )
if( m_xCBXDisplaySource->get_active() )
{
OUString const ext(".xml");
TempFile aTempFile(OUString(), true, &ext);
TempFile aTempFile(u"", true, &ext);
OUString aTempFileURL( aTempFile.GetURL() );
Reference< XImportFilter > xImporter( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.documentconversion.XSLTFilter", mxContext ), UNO_QUERY );
+1 -1
View File
@@ -41,7 +41,7 @@ class AddonMenuManager
static bool HasAddonMenuElements();
// Check if the context string matches the provided xModel context
static bool IsCorrectContext(std::u16string_view rModuleIdentifier, const OUString& rContext);
static bool IsCorrectContext(std::u16string_view rModuleIdentifier, std::u16string_view rContext);
// Create the Add-Ons menu
static VclPtr<PopupMenu> CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame );
+1 -1
View File
@@ -60,7 +60,7 @@ struct ReferencePathInfo
namespace MenuBarMerger
{
bool IsCorrectContext(
const OUString& aContext, std::u16string_view aModuleIdentifier );
std::u16string_view aContext, std::u16string_view aModuleIdentifier );
void RetrieveReferencePath( const OUString&,
std::vector< OUString >& aReferencePath );
+1 -1
View File
@@ -62,7 +62,7 @@ struct ReferenceToolbarPathInfo
class ToolBarMerger
{
public:
static bool IsCorrectContext( const OUString& aContext, std::u16string_view aModuleIdentifier );
static bool IsCorrectContext( std::u16string_view aContext, std::u16string_view aModuleIdentifier );
static void ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence,
AddonToolbarItemContainer& rContainer );
+3 -4
View File
@@ -281,15 +281,14 @@ void AddonMenuManager::GetMenuEntry( const Sequence< PropertyValue >& rAddonMenu
}
// Check if the context string matches the provided xModel context
bool AddonMenuManager::IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& rContext )
bool AddonMenuManager::IsCorrectContext( std::u16string_view rModuleIdentifier, std::u16string_view rContext )
{
if ( rContext.isEmpty() )
if ( rContext.empty() )
return true;
if ( !rModuleIdentifier.empty() )
{
sal_Int32 nIndex = rContext.indexOf( rModuleIdentifier );
return ( nIndex >= 0 );
return rContext.find( rModuleIdentifier ) != std::u16string_view::npos;
}
return false;
@@ -82,7 +82,7 @@ class TargetHelper
@param sName
the new frame name, which should be checked.
*/
static bool isValidNameForFrame(const OUString& sName);
static bool isValidNameForFrame(std::u16string_view sName);
};
} // namespace framework
+3 -3
View File
@@ -43,12 +43,12 @@ bool TargetHelper::matchSpecialTarget(std::u16string_view sCheckTarget ,
}
}
bool TargetHelper::isValidNameForFrame(const OUString& sName)
bool TargetHelper::isValidNameForFrame(std::u16string_view sName)
{
// some special targets are really special ones :-)
// E.g. the are really used to locate one frame inside the frame tree.
if (
(sName.isEmpty() ) ||
(sName.empty() ) ||
(TargetHelper::matchSpecialTarget(sName, ESpecialTarget::HelpTask)) ||
(TargetHelper::matchSpecialTarget(sName, ESpecialTarget::Beamer) )
)
@@ -56,7 +56,7 @@ bool TargetHelper::isValidNameForFrame(const OUString& sName)
// all other names must be checked more general
// special targets starts with a "_".
return (sName.indexOf('_') != 0);
return (sName.find('_') != 0);
}
} // namespace framework
+2 -2
View File
@@ -56,9 +56,9 @@ namespace framework
*/
bool MenuBarMerger::IsCorrectContext(
const OUString& rContext, std::u16string_view rModuleIdentifier )
std::u16string_view rContext, std::u16string_view rModuleIdentifier )
{
return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
return ( rContext.empty() || ( rContext.find( rModuleIdentifier ) != std::u16string_view::npos ));
}
void MenuBarMerger::RetrieveReferencePath(
+2 -2
View File
@@ -92,10 +92,10 @@ using namespace ::com::sun::star;
*/
bool ToolBarMerger::IsCorrectContext(
const OUString& rContext,
std::u16string_view rContext,
std::u16string_view rModuleIdentifier )
{
return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
return ( rContext.empty() || ( rContext.find( rModuleIdentifier ) != std::u16string_view::npos ));
}
/**
@@ -83,15 +83,14 @@ AddonsToolBarFactory::AddonsToolBarFactory(
{
}
bool IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& aContextList )
bool IsCorrectContext( std::u16string_view rModuleIdentifier, std::u16string_view aContextList )
{
if ( aContextList.isEmpty() )
if ( aContextList.empty() )
return true;
if ( !rModuleIdentifier.empty() )
{
sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier );
return ( nIndex >= 0 );
return aContextList.find( rModuleIdentifier ) != std::u16string_view::npos;
}
return false;
+2 -2
View File
@@ -519,7 +519,7 @@ namespace dbtools
@see isValidSQLName
*/
OOO_DLLPUBLIC_DBTOOLS OUString convertName2SQLName(const OUString& _rName,const OUString& _rSpecials);
OOO_DLLPUBLIC_DBTOOLS OUString convertName2SQLName(const OUString& _rName, std::u16string_view _rSpecials);
/** checks whether the given name is a valid SQL name
@@ -528,7 +528,7 @@ namespace dbtools
@see convertName2SQLName
*/
OOO_DLLPUBLIC_DBTOOLS bool isValidSQLName( const OUString& _rName, const OUString& _rSpecials );
OOO_DLLPUBLIC_DBTOOLS bool isValidSQLName( const OUString& _rName, std::u16string_view _rSpecials );
OOO_DLLPUBLIC_DBTOOLS
void showError( const SQLExceptionInfo& _rInfo,
+1 -1
View File
@@ -102,7 +102,7 @@ public:
// file names -------------------------------------------------------------
static OUString convertFileNameToUrl( const OUString& rFileName );
static sal_Int32 getFileNamePos( const OUString& rFileUrl );
static sal_Int32 getFileNamePos( std::u16string_view rFileUrl );
static OUString getFileNameExtension( const OUString& rFileUrl );
// input streams ----------------------------------------------------------
+1 -1
View File
@@ -251,7 +251,7 @@ public:
SAL_DLLPRIVATE void DoBackup_Impl();
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent );
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
const OUString& aPrefix,
std::u16string_view aPrefix,
const OUString& aExtension,
const OUString& aDestDir );
+1 -1
View File
@@ -172,7 +172,7 @@ public:
FileDialogHelper(sal_Int16 nDialogType,
FileDialogFlags nFlags,
const OUString& aFilterUIName,
const OUString& aExtName,
std::u16string_view aExtName,
const OUString& rStandardDir,
const css::uno::Sequence< OUString >& rDenyList,
weld::Window* pPreferredParent);
+1 -1
View File
@@ -68,7 +68,7 @@ public:
@param bCreateParentDirs If rLeadingChars contains a slash, this will create the required
parent directories.
*/
TempFile( const OUString& rLeadingChars, bool _bStartWithZero=true, const OUString* pExtension=nullptr,
TempFile( std::u16string_view rLeadingChars, bool _bStartWithZero=true, const OUString* pExtension=nullptr,
const OUString* pParent=nullptr, bool bCreateParentDirs=false );
TempFile(TempFile && other) noexcept;
+3 -3
View File
@@ -315,10 +315,10 @@ protected:
public:
static OUString FormatTime(const tools::Time& rNewTime, TimeFieldFormat eFormat, TimeFormat eHourFormat, bool bDuration, const LocaleDataWrapper& rLocaleData);
static bool TextToTime(std::u16string_view rStr, tools::Time& rTime, TimeFieldFormat eFormat, bool bDuration, const LocaleDataWrapper& rLocaleDataWrapper, bool _bSkipInvalidCharacters = true);
static int GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, int nCursor,
static int GetTimeArea(TimeFieldFormat eFormat, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper);
static tools::Time SpinTime(bool bUp, const tools::Time& rTime, TimeFieldFormat eFormat,
bool bDuration, const OUString& rText, int nCursor,
bool bDuration, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper);
virtual ~TimeFormatter() override;
@@ -423,7 +423,7 @@ protected:
public:
static OUString FormatDate(const Date& rNewDate, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleData, const Formatter::StaticFormatter& rStaticFormatter);
static bool TextToDate(const OUString& rStr, Date& rTime, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleDataWrapper, const CalendarWrapper& rCalendarWrapper);
static int GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper);
static int GetDateArea(ExtDateFieldFormat eFormat, std::u16string_view rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper);
virtual ~DateFormatter() override;
+5 -5
View File
@@ -117,13 +117,13 @@ void handleCommand(
void InitPoFile(
std::string_view rProject, const OString& rInPath,
const OString& rPotDir, const OString& rOutPath )
std::string_view rPotDir, const OString& rOutPath )
{
//Create directory for po file
{
OUString outDir =
OStringToOUString(
rPotDir.subView(0,rPotDir.lastIndexOf('/')), RTL_TEXTENCODING_UTF8);
rPotDir.substr(0,rPotDir.rfind('/')), RTL_TEXTENCODING_UTF8);
OUString outDirUrl;
if (osl::FileBase::getFileURLFromSystemPath(outDir, outDirUrl)
!= osl::FileBase::E_None)
@@ -174,7 +174,7 @@ bool fileExists(const OString& fileName)
OString gDestRoot;
bool handleFile(std::string_view rProject, const OUString& rUrl, const OString& rPotDir)
bool handleFile(std::string_view rProject, const OUString& rUrl, std::string_view rPotDir)
{
struct Command {
std::u16string_view extension;
@@ -216,7 +216,7 @@ bool handleFile(std::string_view rProject, const OUString& rUrl, const OString&
if (bSimpleModuleCase)
sOutPath = gDestRoot + "/" + rProject + "/messages.pot";
else
sOutPath = rPotDir + ".pot";
sOutPath = OString::Concat(rPotDir) + ".pot";
if (!fileExists(sOutPath))
{
@@ -280,7 +280,7 @@ bool handleFile(std::string_view rProject, const OUString& rUrl, const OString&
void handleFilesOfDir(
std::vector<OUString>& aFiles, std::string_view rProject,
const OString& rPotDir )
std::string_view rPotDir )
{
///Handle files in lexical order
std::sort(aFiles.begin(), aFiles.end());
+3 -3
View File
@@ -24,11 +24,11 @@ namespace
{
//Find ascii escaped unicode
sal_Int32 lcl_IndexOfUnicode(
const OString& rSource, const sal_Int32 nFrom = 0 )
std::string_view rSource, const sal_Int32 nFrom = 0 )
{
const OString sHexDigits = "0123456789abcdefABCDEF";
sal_Int32 nIndex = rSource.indexOf( "\\u", nFrom );
if( nIndex == -1 )
size_t nIndex = rSource.find( "\\u", nFrom );
if( nIndex == std::string_view::npos )
{
return -1;
}
+3 -3
View File
@@ -58,7 +58,7 @@ namespace
// Update id and content of the topic
xmlNodePtr lcl_UpdateTopic(
const xmlNodePtr pCurrent, const OString& rXhpRoot )
const xmlNodePtr pCurrent, std::string_view rXhpRoot )
{
xmlNodePtr pReturn = pCurrent;
xmlChar* pID = xmlGetProp(pReturn, reinterpret_cast<const xmlChar*>("id"));
@@ -71,7 +71,7 @@ namespace
{
OString sNewID =
OString::Concat(sID.subView( 0, nFirstSlash + 1 )) +
rXhpRoot.subView( rXhpRoot.lastIndexOf('/') + 1 ) +
rXhpRoot.substr( rXhpRoot.rfind('/') + 1 ) +
sID.subView( sID.indexOf( '/', nFirstSlash + 1 ) );
xmlSetProp(
pReturn, reinterpret_cast<const xmlChar*>("id"),
@@ -79,7 +79,7 @@ namespace
}
const OString sXhpPath =
rXhpRoot +
OString::Concat(rXhpRoot) +
sID.subView(sID.indexOf('/', nFirstSlash + 1));
xmlDocPtr pXhpFile = xmlParseFile( sXhpPath.getStr() );
// if xhpfile is missing than put this topic into comment
+4 -4
View File
@@ -92,14 +92,14 @@ static uno::Reference< XLinguServiceManager2 > GetLngSvcMgr_Impl()
return xRes;
}
static bool getTag(const OString &rLine, const char *pTagName,
static bool getTag(std::string_view rLine, const char *pTagName,
OString &rTagValue)
{
sal_Int32 nPos = rLine.indexOf(pTagName);
if (nPos == -1)
size_t nPos = rLine.find(pTagName);
if (nPos == std::string_view::npos)
return false;
rTagValue = comphelper::string::strip(rLine.subView(nPos + strlen(pTagName)),
rTagValue = comphelper::string::strip(rLine.substr(nPos + strlen(pTagName)),
' ');
return true;
}
+3 -3
View File
@@ -673,13 +673,13 @@ uno::Sequence< OUString > SAL_CALL DicList::getSupportedServiceNames( )
static sal_Int32 lcl_GetToken( OUString &rToken,
const OUString &rText, sal_Int32 nPos, const OUString &rDelim )
const OUString &rText, sal_Int32 nPos, std::u16string_view rDelim )
{
sal_Int32 nRes = -1;
if (rText.isEmpty() || nPos >= rText.getLength())
rToken.clear();
else if (rDelim.isEmpty())
else if (rDelim.empty())
{
rToken = rText;
if (!rToken.isEmpty())
@@ -690,7 +690,7 @@ static sal_Int32 lcl_GetToken( OUString &rToken,
sal_Int32 i;
for (i = nPos; i < rText.getLength(); ++i)
{
if (-1 != rDelim.indexOf( rText[i] ))
if (std::string_view::npos != rDelim.find( rText[i] ))
break;
}
+3 -3
View File
@@ -71,10 +71,10 @@ OUString InputOutputHelper::convertFileNameToUrl( const OUString& rFileName )
return OUString();
}
sal_Int32 InputOutputHelper::getFileNamePos( const OUString& rFileUrl )
sal_Int32 InputOutputHelper::getFileNamePos( std::u16string_view rFileUrl )
{
sal_Int32 nSepPos = rFileUrl.lastIndexOf( '/' );
return (nSepPos < 0) ? 0 : (nSepPos + 1);
size_t nSepPos = rFileUrl.find( '/' );
return (nSepPos == std::u16string_view::npos) ? 0 : (nSepPos + 1);
}
OUString InputOutputHelper::getFileNameExtension( const OUString& rFileUrl )
+7 -7
View File
@@ -750,11 +750,11 @@ RegError ORegistry::deleteKey(RegKeyHandle hKey, std::u16string_view keyName)
return eraseKey(m_openKeyTable[ROOT], sFullKeyName);
}
RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName)
RegError ORegistry::eraseKey(ORegKey* pKey, std::u16string_view keyName)
{
RegError _ret = RegError::NO_ERROR;
if (keyName.isEmpty())
if (keyName.empty())
{
return RegError::INVALID_KEYNAME;
}
@@ -762,18 +762,18 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName)
OUString sFullKeyName(pKey->getName());
OUString sFullPath(sFullKeyName);
OUString sRelativKey;
sal_Int32 lastIndex = keyName.lastIndexOf('/');
size_t lastIndex = keyName.rfind('/');
if (lastIndex >= 0)
if (lastIndex != std::u16string_view::npos)
{
sRelativKey += keyName.subView(lastIndex + 1);
sRelativKey += keyName.substr(lastIndex + 1);
if (sFullKeyName.getLength() > 1)
sFullKeyName += keyName;
else
sFullKeyName += keyName.subView(1);
sFullKeyName += keyName.substr(1);
sFullPath = sFullKeyName.copy(0, keyName.lastIndexOf('/') + 1);
sFullPath = sFullKeyName.copy(0, keyName.rfind('/') + 1);
} else
{
if (sFullKeyName.getLength() > 1)
+1 -1
View File
@@ -102,7 +102,7 @@ public:
friend class ORegKey;
private:
RegError eraseKey(ORegKey* pKey, const OUString& keyName);
RegError eraseKey(ORegKey* pKey, std::u16string_view keyName);
RegError deleteSubkeysAndValues(ORegKey* pKey);
+1 -1
View File
@@ -153,7 +153,7 @@ public:
static OUString SC_DLLPUBLIC GetQuotedToken(const OUString &rIn, sal_Int32 nToken, const OUString& rQuotedPairs,
sal_Unicode cTok, sal_Int32& rIndex );
static bool SC_DLLPUBLIC isMultiline( const OUString& rStr );
static bool SC_DLLPUBLIC isMultiline( std::u16string_view rStr );
static ScInputStringType parseInputString(
SvNumberFormatter& rFormatter, const OUString& rStr, LanguageType eLang );
+2 -8
View File
@@ -421,15 +421,9 @@ OUString ScStringUtil::GetQuotedToken(const OUString &rIn, sal_Int32 nToken, con
}
}
bool ScStringUtil::isMultiline( const OUString& rStr )
bool ScStringUtil::isMultiline( std::u16string_view rStr )
{
if (rStr.indexOf('\n') != -1)
return true;
if (rStr.indexOf('\r') != -1)
return true;
return false;
return rStr.find_first_of(u"\n\r") != std::u16string_view::npos;
}
ScInputStringType ScStringUtil::parseInputString(
+2 -2
View File
@@ -1107,9 +1107,9 @@ void ScInputHandler::HideTipBelow()
namespace
{
bool lcl_hasSingleToken(const OUString& s, sal_Unicode c)
bool lcl_hasSingleToken(std::u16string_view s, sal_Unicode c)
{
return !s.isEmpty() && s.indexOf(c)<0;
return !s.empty() && s.find(c) == std::u16string_view::npos;
}
}
+1 -1
View File
@@ -3422,7 +3422,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream)
OUString sTmpDir = aTmpDir.GetURL();
OUString sExtension(".dbf");
utl::TempFile aTempInput(OUString(), true, &sExtension, &sTmpDir);
utl::TempFile aTempInput(u"", true, &sExtension, &sTmpDir);
aTempInput.EnableKillingFile();
SvStream* pInputStream = aTempInput.GetStream(StreamMode::WRITE);
+2 -2
View File
@@ -120,9 +120,9 @@ bool isExcel40(const uno::Reference<io::XInputStream>& xInStream)
return true;
}
bool isTemplate(const OUString& rType)
bool isTemplate(std::u16string_view rType)
{
return rType.indexOf("_VorlageTemplate") != -1;
return rType.find(u"_VorlageTemplate") != std::u16string_view::npos;
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ private:
{
FileFormat* pFormat = getFormat(HTML);
OUString aExt = "." + OUString::createFromAscii(pFormat->pName);
utl::TempFile aTempFile(OUString(), true, &aExt);
utl::TempFile aTempFile(u"", true, &aExt);
aTempFile.EnableKillingFile();
exportTo(xDocShRef.get(), pFormat, aTempFile);
return parseHtml(aTempFile);
+6 -6
View File
@@ -65,25 +65,25 @@ public:
/** Use a heuristic based on the URL of a top-level template folder to
assign a priority that is used to sort the folders.
*/
int Classify (const OUString& rsURL)
int Classify (std::u16string_view rsURL)
{
int nPriority (0);
if (rsURL.isEmpty())
if (rsURL.empty())
nPriority = 100;
else if (rsURL.indexOf("presnt")>=0)
else if (rsURL.find(u"presnt") != std::u16string_view::npos)
{
nPriority = 30;
}
else if (rsURL.indexOf("layout")>=0)
else if (rsURL.find(u"layout") != std::u16string_view::npos)
{
nPriority = 20;
}
else if (rsURL.indexOf("educate")>=0)
else if (rsURL.find(u"educate") != std::u16string_view::npos)
{
nPriority = 40;
}
else if (rsURL.indexOf("finance")>=0)
else if (rsURL.find(u"finance") != std::u16string_view::npos)
{
nPriority = 40;
}
+1 -1
View File
@@ -961,7 +961,7 @@ static bool impl_showOfflineHelp(const OUString& rURL, weld::Widget* pDialogPare
if (flatpak::isFlatpak() && !flatpak::createTemporaryHtmlDirectory(&parent)) {
return false;
}
::utl::TempFile aTempFile("NewHelp", true, &aExtension, parent, false );
::utl::TempFile aTempFile(u"NewHelp", true, &aExtension, parent, false );
SvStream* pStream = aTempFile.GetStream(StreamMode::WRITE);
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
+4 -4
View File
@@ -2398,7 +2398,7 @@ FileDialogHelper::FileDialogHelper(
sal_Int16 nDialogType,
FileDialogFlags nFlags,
const OUString& aFilterUIName,
const OUString& aExtName,
std::u16string_view aExtName,
const OUString& rStandardDir,
const css::uno::Sequence< OUString >& rDenyList,
weld::Window* pPreferredParent )
@@ -2407,9 +2407,9 @@ FileDialogHelper::FileDialogHelper(
{
// the wildcard here is expected in form "*.extension"
OUString aWildcard;
if ( aExtName.indexOf( '*' ) != 0 )
if ( aExtName.find( '*' ) != 0 )
{
if ( !aExtName.isEmpty() && aExtName.indexOf( '.' ) != 0 )
if ( !aExtName.empty() && aExtName.find( '.' ) != 0 )
aWildcard = "*.";
else
aWildcard = "*";
@@ -2848,7 +2848,7 @@ ErrCode FileOpenDialog_Impl( weld::Window* pParent,
// read-only to discourage editing (which would invalidate existing
// signatures).
if (nFlags & FileDialogFlags::SignPDF)
pDialog.reset(new FileDialogHelper(nDialogType, nFlags, SfxResId(STR_SFX_FILTERNAME_PDF), "pdf", rStandardDir, rDenyList, pParent));
pDialog.reset(new FileDialogHelper(nDialogType, nFlags, SfxResId(STR_SFX_FILTERNAME_PDF), u"pdf", rStandardDir, rDenyList, pParent));
else
pDialog.reset(new FileDialogHelper(nDialogType, nFlags, OUString(), nDialog, SfxFilterFlags::NONE, SfxFilterFlags::NONE, rStandardDir, rDenyList, pParent));
+3 -3
View File
@@ -2513,7 +2513,7 @@ void SfxMedium::Transfer_Impl()
void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
const OUString& aPrefix,
std::u16string_view aPrefix,
const OUString& aExtension,
const OUString& aDestDir )
{
@@ -4271,7 +4271,7 @@ OUString SfxMedium::CreateTempCopyWithExt( const OUString& aURL )
sal_Int32 nPrefixLen = aURL.lastIndexOf( '.' );
OUString aExt = ( nPrefixLen == -1 ) ? OUString() : aURL.copy( nPrefixLen );
OUString aNewTempFileURL = ::utl::TempFile( OUString(), true, &aExt ).GetURL();
OUString aNewTempFileURL = ::utl::TempFile( u"", true, &aExt ).GetURL();
if ( !aNewTempFileURL.isEmpty() )
{
INetURLObject aSource( aURL );
@@ -4344,7 +4344,7 @@ OUString SfxMedium::SwitchDocumentToTempFile()
OUString const aExt = (nPrefixLen == -1)
? OUString()
: aOrigURL.copy(nPrefixLen);
OUString aNewURL = ::utl::TempFile( OUString(), true, &aExt ).GetURL();
OUString aNewURL = ::utl::TempFile( u"", true, &aExt ).GetURL();
// TODO/LATER: In future the aLogicName should be set to shared folder URL
// and a temporary file should be created. Transport_Impl should be impossible then.
+2 -2
View File
@@ -863,14 +863,14 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
// this is a PDF export
// the filter options has been shown already
const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, "pdf", rStandardDir, rDenyList, pFrameWin ));
pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, u"pdf", rStandardDir, rDenyList, pFrameWin ));
pFileDlg->SetCurrentFilter( aFilterUIName );
}
else if ((nStoreMode & EPUBEXPORT_REQUESTED) && !aPreselectedFilterPropsHM.empty())
{
// This is an EPUB export, the filter options has been shown already.
const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
pFileDlg.reset(new sfx2::FileDialogHelper(aDialogMode, aDialogFlags, aFilterUIName, "epub", rStandardDir, rDenyList, pFrameWin));
pFileDlg.reset(new sfx2::FileDialogHelper(aDialogMode, aDialogFlags, aFilterUIName, u"epub", rStandardDir, rDenyList, pFrameWin));
pFileDlg->SetCurrentFilter(aFilterUIName);
}
else
+2 -2
View File
@@ -662,9 +662,9 @@ void SmEditWindow::SelPrevMark()
}
// returns true iff 'rText' contains a mark
static bool HasMark(const OUString& rText)
static bool HasMark(std::u16string_view rText)
{
return rText.indexOf("<?>") != -1;
return rText.find(u"<?>") != std::u16string_view::npos;
}
ESelection SmEditWindow::GetSelection() const
@@ -55,12 +55,14 @@ InspectorTextPanel::InspectorTextPanel(weld::Widget* pParent)
mpListBoxStyles->set_column_fixed_widths(aWidths);
}
static bool GetPropertyValues(const OUString& rPropName, const uno::Any& rAny, OUString& rString)
static bool GetPropertyValues(std::u16string_view rPropName, const uno::Any& rAny,
OUString& rString)
{
// Hide Asian and Complex properties
if (!SvtCJKOptions::IsCJKFontEnabled() && rPropName.indexOf("Asian") != -1)
if (!SvtCJKOptions::IsCJKFontEnabled() && rPropName.find(u"Asian") != std::u16string_view::npos)
return false;
if (!SvtCTLOptions().IsCTLFontEnabled() && rPropName.indexOf("Complex") != -1)
if (!SvtCTLOptions().IsCTLFontEnabled()
&& rPropName.find(u"Complex") != std::u16string_view::npos)
return false;
if (bool bValue; rAny >>= bValue)
@@ -77,14 +79,14 @@ static bool GetPropertyValues(const OUString& rPropName, const uno::Any& rAny, O
}
else if (tools::Long nValueLong; rAny >>= nValueLong)
{
if (rPropName.indexOf("Color") != -1)
if (rPropName.find(u"Color") != std::u16string_view::npos)
rString = "0x" + OUString::number(nValueLong, 16);
else
rString = OUString::number(nValueLong);
}
else if (double fValue; rAny >>= fValue)
{
if (rPropName.indexOf("Weight") != -1)
if (rPropName.find(u"Weight") != std::u16string_view::npos)
rString = SvxResId(fValue > 100 ? RID_BOLD : RID_NORMAL);
else
rString = OUString::number((round(fValue * 100)) / 100.00);
+1 -1
View File
@@ -196,7 +196,7 @@ void SwDocTest::testFileNameFields()
{
//Here's a file name with some chars in it that will be %% encoded, when expanding
//SwFileNameFields we want to restore the original readable filename
utl::TempFile aTempFile("demo [name]");
utl::TempFile aTempFile(u"demo [name]");
aTempFile.EnableKillingFile();
INetURLObject aTempFileURL(aTempFile.GetURL());
+3 -3
View File
@@ -1547,7 +1547,7 @@ sal_uInt16 SwHTMLWriter::GetHTMLFontSize( sal_uInt32 nHeight ) const
// Paragraphs with Table of Contents and other index styles will be typeset with
// dot leaders at the position of the last tabulator in PrintLayout (CSS2) mode
sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rStr )
sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, std::u16string_view rStr )
{
if (m_bCfgPrintLayout && ((nPoolId >= RES_POOLCOLL_TOX_CNTNT1 && nPoolId <= RES_POOLCOLL_TOX_CNTNT5) ||
(nPoolId >= RES_POOLCOLL_TOX_IDX1 && nPoolId <= RES_POOLCOLL_TOX_IDX3) ||
@@ -1555,9 +1555,9 @@ sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& r
nPoolId == RES_POOLCOLL_TOX_ILLUS1 || nPoolId == RES_POOLCOLL_TOX_TABLES1 ||
nPoolId == RES_POOLCOLL_TOX_OBJECT1 ||
(nPoolId >= RES_POOLCOLL_TOX_AUTHORITIES1 && nPoolId <= RES_POOLCOLL_TOX_USER10))) {
sal_Int32 i = rStr.lastIndexOf('\t');
size_t i = rStr.rfind('\t');
// there are only ASCII (Latin-1) characters after the tabulator
if (i > -1 && OUStringToOString(rStr.subView(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
if (i != std::u16string_view::npos && OUStringToOString(rStr.substr(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
return i;
}
return -1;
+1 -1
View File
@@ -595,7 +595,7 @@ public:
FieldUnit GetCSS1Unit() const { return m_eCSS1Unit; }
sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rText );
sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, std::u16string_view rText );
/// Determines the prefix string needed to respect the requested namespace alias.
OString GetNamespace() const;
+1 -1
View File
@@ -95,7 +95,7 @@ SwMailMergeLayoutPage::SwMailMergeLayoutPage(weld::Container* pPage, SwMailMerge
//creating with extension is not supported by a static method :-(
OUString const sExt(
comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(),'*'));
utl::TempFile aTempFile( OUString(), true, &sExt );
utl::TempFile aTempFile( u"", true, &sExt );
m_sExampleURL = aTempFile.GetURL();
aTempFile.EnableKillingFile();
}
+1 -1
View File
@@ -78,7 +78,7 @@ OUString lcl_CheckFileName( const OUString& rNewFilePath,
OUString rSG = SwGlossaries::GetExtension();
//generate generic name
utl::TempFile aTemp("group", true, &rSG, &rNewFilePath);
utl::TempFile aTemp(u"group", true, &rSG, &rNewFilePath);
aTemp.EnableKillingFile();
INetURLObject aTempURL( aTemp.GetURL() );
+1 -1
View File
@@ -766,7 +766,7 @@ uno::Any SAL_CALL SwXMailMerge::execute(
FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
OUString aExtension(comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(), '*'));
utl::TempFile aTempFile( "SwMM", true, &aExtension );
utl::TempFile aTempFile( u"SwMM", true, &aExtension );
m_aTmpFileName = aTempFile.GetURL();
Reference< XStorable > xStorable( xCurModel, UNO_QUERY );
+2 -2
View File
@@ -298,12 +298,12 @@ OUString DecodeURI(OUString const& rURI)
return rtl::Uri::decode(rURI, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
}
OUString ConnectionEndPointString(OUString const& rHostName, sal_uInt16 const nPort)
OUString ConnectionEndPointString(std::u16string_view rHostName, sal_uInt16 const nPort)
{
OUStringBuffer aBuf;
// Is host a numeric IPv6 address?
if ((rHostName.indexOf(':') != -1) && (rHostName[0] != '['))
if ((rHostName.find(':') != std::u16string_view::npos) && (rHostName[0] != '['))
{
aBuf.append("[");
aBuf.append(rHostName);
+1 -1
View File
@@ -87,7 +87,7 @@ public:
OUString EncodeSegment(OUString const& rSegment);
OUString DecodeURI(OUString const& rURI);
OUString ConnectionEndPointString(OUString const& rHost, sal_uInt16 nPort);
OUString ConnectionEndPointString(std::u16string_view rHost, sal_uInt16 nPort);
} // namespace http_dav_ucp
+3 -3
View File
@@ -136,7 +136,7 @@ class InternetProxyDecider_Impl :
mutable HostnameCache m_aHostnames;
private:
bool shouldUseProxy( const OUString & rHost,
bool shouldUseProxy( std::u16string_view rHost,
sal_Int32 nPort,
bool bUseFullyQualified ) const;
public:
@@ -399,13 +399,13 @@ void InternetProxyDecider_Impl::dispose()
}
bool InternetProxyDecider_Impl::shouldUseProxy( const OUString & rHost,
bool InternetProxyDecider_Impl::shouldUseProxy( std::u16string_view rHost,
sal_Int32 nPort,
bool bUseFullyQualified ) const
{
OUStringBuffer aBuffer;
if ( ( rHost.indexOf( ':' ) != -1 ) &&
if ( ( rHost.find( ':' ) != std::u16string_view::npos ) &&
( rHost[ 0 ] != '[' ) )
{
// host is given as numeric IPv6 address
+2 -2
View File
@@ -26,9 +26,9 @@ namespace unoidl::detail {
namespace {
std::vector< OUString > translateAnnotations(OUString const & documentation) {
std::vector< OUString > translateAnnotations(std::u16string_view documentation) {
std::vector< OUString > ans;
if (documentation.indexOf("@deprecated") != -1) {
if (documentation.find(u"@deprecated") != std::u16string_view::npos) {
//TODO: this check is somewhat crude
ans.push_back("deprecated");
}
+4 -4
View File
@@ -886,10 +886,10 @@ void checkMap(
}
}
bool valid(OUString const & identifier) {
for (sal_Int32 i = 0;; ++i) {
i = identifier.indexOf('_', i);
if (i == -1) {
bool valid(std::u16string_view identifier) {
for (size_t i = 0;; ++i) {
i = identifier.find('_', i);
if (i == std::u16string_view::npos) {
return true;
}
if (!rtl::isAsciiUpperCase(identifier[0]) || identifier[i - 1] == '_') {
+5 -5
View File
@@ -247,17 +247,17 @@ namespace
};
static OUString lcl_createName(
const OUString& rLeadingChars, Tokens & tokens, const OUString* pExtension,
std::u16string_view rLeadingChars, Tokens & tokens, const OUString* pExtension,
const OUString* pParent, bool bDirectory, bool bKeep, bool bLock,
bool bCreateParentDirs )
{
OUString aName = ConstructTempDir_Impl( pParent, bCreateParentDirs );
if ( bCreateParentDirs )
{
sal_Int32 nOffset = rLeadingChars.lastIndexOf("/");
size_t nOffset = rLeadingChars.rfind(u"/");
OUString aDirName;
if (-1 != nOffset)
aDirName = aName + rLeadingChars.subView( 0, nOffset );
if (std::u16string_view::npos != nOffset)
aDirName = aName + rLeadingChars.substr( 0, nOffset );
else
aDirName = aName;
TempDirCreatedObserver observer;
@@ -365,7 +365,7 @@ TempFile::TempFile( const OUString* pParent, bool bDirectory )
aName = CreateTempName_Impl( pParent, true, bDirectory );
}
TempFile::TempFile( const OUString& rLeadingChars, bool _bStartWithZero,
TempFile::TempFile( std::u16string_view rLeadingChars, bool _bStartWithZero,
const OUString* pExtension, const OUString* pParent,
bool bCreateParentDirs )
: bIsDirectory( false )
+14 -14
View File
@@ -1617,7 +1617,7 @@ bool DateFormatter::ImplAllowMalformedInput() const
return !IsEnforceValidValue();
}
int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper)
int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, std::u16string_view rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper)
{
sal_Int8 nDateArea = 0;
@@ -1629,12 +1629,12 @@ int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText
else
{
// search area
sal_Int32 nPos = 0;
size_t nPos = 0;
OUString aDateSep = ImplGetDateSep(rLocaleDataWrapper, eFormat);
for ( sal_Int8 i = 1; i <= 3; i++ )
{
nPos = rText.indexOf( aDateSep, nPos );
if (nPos < 0 || nPos >= nCursor)
nPos = rText.find( aDateSep, nPos );
if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
{
nDateArea = i;
break;
@@ -2581,7 +2581,7 @@ bool TimeFormatter::ImplAllowMalformedInput() const
return !IsEnforceValidValue();
}
int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, int nCursor,
int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper)
{
int nTimeArea = 0;
@@ -2590,18 +2590,18 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
if (eFormat != TimeFieldFormat::F_SEC_CS)
{
//Which area is the cursor in of HH:MM:SS.TT
for ( sal_Int32 i = 1, nPos = 0; i <= 4; i++ )
for ( size_t i = 1, nPos = 0; i <= 4; i++ )
{
sal_Int32 nPos1 = rText.indexOf(rLocaleDataWrapper.getTimeSep(), nPos);
sal_Int32 nPos2 = rText.indexOf(rLocaleDataWrapper.getTime100SecSep(), nPos);
size_t nPos1 = rText.find(rLocaleDataWrapper.getTimeSep(), nPos);
size_t nPos2 = rText.find(rLocaleDataWrapper.getTime100SecSep(), nPos);
//which ever comes first, bearing in mind that one might not be there
if (nPos1 >= 0 && nPos2 >= 0)
if (nPos1 != std::u16string_view::npos && nPos2 != std::u16string_view::npos)
nPos = std::min(nPos1, nPos2);
else if (nPos1 >= 0)
else if (nPos1 != std::u16string_view::npos)
nPos = nPos1;
else
nPos = nPos2;
if (nPos < 0 || nPos >= nCursor)
if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
{
nTimeArea = i;
break;
@@ -2612,8 +2612,8 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
}
else
{
sal_Int32 nPos = rText.indexOf(rLocaleDataWrapper.getTime100SecSep());
if (nPos < 0 || nPos >= nCursor)
size_t nPos = rText.find(rLocaleDataWrapper.getTime100SecSep());
if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
nTimeArea = 3;
else
nTimeArea = 4;
@@ -2623,7 +2623,7 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
}
tools::Time TimeFormatter::SpinTime(bool bUp, const tools::Time& rTime, TimeFieldFormat eFormat,
bool bDuration, const OUString& rText, int nCursor,
bool bDuration, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper)
{
tools::Time aTime(rTime);
+3 -3
View File
@@ -181,13 +181,13 @@ bool lcl_mapContainsRange(
}
bool lcl_tableOfRangeMatches(
const OUString & rRange,
std::u16string_view rRange,
std::u16string_view rTableName )
{
// both strings are non-empty and the table name is part of the range
return ( !rRange.isEmpty() &&
return ( !rRange.empty() &&
!rTableName.empty() &&
(rRange.indexOf( rTableName ) != -1 ));
(rRange.find( rTableName ) != std::u16string_view::npos ));
}
} // anonymous namespace
+4 -4
View File
@@ -19,19 +19,19 @@
#include <rtl/ustring.hxx>
#include <xmlmultiimagehelper.hxx>
#include <o3tl/string_view.hxx>
#include <comphelper/graphicmimetype.hxx>
using namespace ::com::sun::star;
namespace
{
OUString getMimeTypeForURL(const OUString& rString)
OUString getMimeTypeForURL(std::u16string_view rString)
{
OUString sMimeType;
if (rString.startsWith("vnd.sun.star.Package"))
if (o3tl::starts_with(rString, u"vnd.sun.star.Package"))
{
OString aExtension = OUStringToOString(rString.subView(rString.lastIndexOf(".") + 1), RTL_TEXTENCODING_ASCII_US);
OString aExtension = OUStringToOString(rString.substr(rString.rfind('.') + 1), RTL_TEXTENCODING_ASCII_US);
sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aExtension);
}
return sMimeType;