avmedia/source/viewer/mediawindow.cxx | 7 - basic/source/basmgr/basmgr.cxx | 3 canvas/source/factory/cf_service.cxx | 5 - codemaker/source/codemaker/global.cxx | 3 codemaker/source/commoncpp/commoncpp.cxx | 3 compilerplugins/clang/stringview.cxx | 25 +++++ connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx | 7 - cui/source/customize/SvxNotebookbarConfigPage.cxx | 6 - cui/source/dialogs/cuigaldlg.cxx | 3 cui/source/options/optpath.cxx | 3 cui/source/tabpages/macroass.cxx | 3 dbaccess/source/core/dataaccess/documentcontainer.cxx | 3 dbaccess/source/ui/dlg/ConnectionPage.cxx | 3 dbaccess/source/ui/misc/TokenWriter.cxx | 3 dbaccess/source/ui/querydesign/QueryDesignView.cxx | 5 - dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx | 9 + dbaccess/source/ui/querydesign/querycontroller.cxx | 3 dbaccess/source/ui/tabledesign/TableController.cxx | 3 desktop/source/deployment/registry/dp_registry.cxx | 7 - desktop/source/lib/init.cxx | 5 - extensions/source/abpilot/abpfinalpage.cxx | 3 filter/source/svg/svgwriter.cxx | 3 idlc/source/astscope.cxx | 2 idlc/source/idlcproduce.cxx | 3 include/o3tl/string_view.hxx | 50 +++++++++-- l10ntools/source/lngmerge.cxx | 2 oox/source/dump/dumperbase.cxx | 3 oox/source/helper/attributelist.cxx | 2 oox/source/ole/axcontrol.cxx | 2 sal/rtl/bootstrap.cxx | 5 - sc/source/core/data/documen4.cxx | 5 - sc/source/filter/html/htmlpars.cxx | 3 sc/source/filter/oox/pagesettings.cxx | 8 - sc/source/ui/cctrl/checklistmenu.cxx | 3 sc/source/ui/dbgui/asciiopt.cxx | 13 +- sc/source/ui/dbgui/dbnamdlg.cxx | 3 sc/source/ui/dbgui/imoptdlg.cxx | 13 +- sc/source/ui/dbgui/scuiimoptdlg.cxx | 5 - sc/source/ui/docshell/docfunc.cxx | 3 sc/source/ui/docshell/docsh4.cxx | 5 - sc/source/ui/docshell/docsh8.cxx | 3 sc/source/ui/miscdlgs/crnrdlg.cxx | 5 - sc/source/ui/miscdlgs/scuiautofmt.cxx | 5 - sc/source/ui/optdlg/tpusrlst.cxx | 7 - sc/source/ui/view/viewdata.cxx | 3 sd/source/core/CustomAnimationPreset.cxx | 3 sd/source/filter/ppt/pptin.cxx | 3 sd/source/ui/dlg/tpaction.cxx | 3 sdext/source/minimizer/optimizerdialog.cxx | 3 sfx2/source/appl/newhelp.cxx | 9 + sfx2/source/bastyp/mieclip.cxx | 2 sfx2/source/doc/autoredactdialog.cxx | 3 sfx2/source/doc/objmisc.cxx | 3 starmath/source/edit.cxx | 3 starmath/source/mathml/mathmlimport.cxx | 3 starmath/source/ooxmlimport.cxx | 3 svx/source/gallery2/galini.cxx | 5 - sw/source/core/doc/docfld.cxx | 3 sw/source/core/doc/docredln.cxx | 3 sw/source/core/fields/cellfml.cxx | 2 sw/source/core/fields/dbfld.cxx | 5 - sw/source/core/unocore/unosect.cxx | 3 sw/source/filter/ww8/docxattributeoutput.cxx | 2 sw/source/filter/ww8/ww8atr.cxx | 3 sw/source/ui/dbui/mmresultdialogs.cxx | 2 sw/source/ui/dialog/uiregionsw.cxx | 5 - sw/source/ui/index/cnttab.cxx | 2 sw/source/ui/misc/bookmark.cxx | 3 sw/source/ui/misc/glosbib.cxx | 5 - sw/source/uibase/dochdl/gloshdl.cxx | 3 sw/source/uibase/dochdl/swdtflvr.cxx | 4 sw/source/uibase/misc/glosdoc.cxx | 9 + sw/source/uibase/utlui/gloslst.cxx | 3 sw/source/uibase/wrtsh/wrtsh2.cxx | 5 - test/source/helper/transferable.cxx | 5 - unotools/source/config/useroptions.cxx | 3 vcl/qa/cppunit/pdfexport/pdfexport.cxx | 3 vcl/qt5/QtTransferable.cxx | 3 vcl/source/app/salvtables.cxx | 3 vcl/source/control/combobox.cxx | 7 - vcl/source/graphic/UnoGraphicProvider.cxx | 2 vcl/source/image/ImplImageTree.cxx | 5 - vcl/source/opengl/x11/context.cxx | 3 vcl/unx/generic/dtrans/X11_selection.cxx | 13 +- vcl/unx/gtk3/a11y/atktextattributes.cxx | 5 - vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx | 3 vcl/unx/gtk3/gtkinst.cxx | 5 - writerperfect/qa/unit/EPUBExportTest.cxx | 3 xmloff/source/style/PageMasterPropHdl.cxx | 3 89 files changed, 286 insertions(+), 153 deletions(-)
New commits: commit e4ff847fe0796420ba8023b70cad8589f5f19e9f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sat Apr 9 09:55:12 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Apr 10 12:59:38 2022 +0200 loplugin:stringview check for getToken and trim since we now have o3tl versions of those that work on string_view. Also improve those o3tl functions to support both string_view and u16string_view Change-Id: Iacab2996becec62aa78a5597c52d983bb784749a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132755 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx index 521e624db386..c4ad7f0bad35 100644 --- a/avmedia/source/viewer/mediawindow.cxx +++ b/avmedia/source/viewer/mediawindow.cxx @@ -40,6 +40,7 @@ #include <comphelper/propertysequence.hxx> #include <memory> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME 3.0 @@ -231,7 +232,7 @@ bool MediaWindow::executeMediaURLDialog(weld::Window* pParent, OUString& rURL, b if( !aAllTypes.isEmpty() ) aAllTypes.append(aSeparator); - aAllTypes.append(aWildcard + filter.second.getToken( 0, ';', nIndex )); + aAllTypes.append(OUString::Concat(aWildcard) + o3tl::getToken(filter.second, 0, ';', nIndex )); } } @@ -247,7 +248,7 @@ bool MediaWindow::executeMediaURLDialog(weld::Window* pParent, OUString& rURL, b if( !aTypes.isEmpty() ) aTypes.append(aSeparator); - aTypes.append(aWildcard + filter.second.getToken( 0, ';', nIndex )); + aTypes.append(OUString::Concat(aWildcard) + o3tl::getToken(filter.second, 0, ';', nIndex )); } // add single filters @@ -348,7 +349,7 @@ bool MediaWindow::isMediaURL(const OUString& rURL, const OUString& rReferer, boo { for( sal_Int32 nIndex = 0; nIndex >= 0; ) { - if( aExt.equalsIgnoreAsciiCase( filter.second.getToken( 0, ';', nIndex ) ) ) + if( aExt.equalsIgnoreAsciiCase( o3tl::getToken(filter.second, 0, ';', nIndex ) ) ) return true; } } diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 4dadf17d8f3f..013c5eec851f 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -31,6 +31,7 @@ #include <basic/sbmod.hxx> #include <unotools/transliterationwrapper.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <basic/sberrors.hxx> #include <basic/sbuno.hxx> @@ -1538,7 +1539,7 @@ ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, std::u for (;;) { aBuff.append( "\"" ); - aBuff.append( sArgs2.getToken(0, ',', nPos) ); + aBuff.append( o3tl::getToken(sArgs2, 0, ',', nPos) ); aBuff.append( "\"" ); if (nPos<0) break; diff --git a/canvas/source/factory/cf_service.cxx b/canvas/source/factory/cf_service.cxx index 3323b8675a15..a56551832801 100644 --- a/canvas/source/factory/cf_service.cxx +++ b/canvas/source/factory/cf_service.cxx @@ -36,6 +36,7 @@ #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <o3tl/functional.hxx> +#include <o3tl/string_view.hxx> #include <vcl/skia/SkiaHelper.hxx> #include <unotools/configmgr.hxx> @@ -372,7 +373,7 @@ Reference<XInterface> CanvasFactory::lookupAndUse( const bool bIsAcceleratedImpl( std::any_of(aAccelImpls.begin(), aAccelImpls.end(), [&aCurrName](OUString const& src) - { return aCurrName == src.trim(); } + { return aCurrName == o3tl::trim(src); } )); // check whether given canvas service is listed in the @@ -380,7 +381,7 @@ Reference<XInterface> CanvasFactory::lookupAndUse( const bool bIsAAImpl( std::any_of(aAAImpls.begin(), aAAImpls.end(), [&aCurrName](OUString const& src) - { return aCurrName == src.trim(); } + { return aCurrName == o3tl::trim(src); } )); // try to instantiate canvas *only* if either accel and AA diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx index 6d831b45dca8..1310a0b05608 100644 --- a/codemaker/source/codemaker/global.cxx +++ b/codemaker/source/codemaker/global.cxx @@ -22,6 +22,7 @@ #include <rtl/ustring.hxx> #include <osl/thread.h> #include <osl/file.hxx> +#include <o3tl/string_view.hxx> #include <string.h> #include <string_view> @@ -115,7 +116,7 @@ OString createFileNameFromType( const OString& destination, sal_Int32 nIndex = 0; do { - buffer.append(fileName.getToken(0, token, nIndex)); + buffer.append(o3tl::getToken(fileName, 0, token, nIndex)); if( nIndex == -1 ) break; diff --git a/codemaker/source/commoncpp/commoncpp.cxx b/codemaker/source/commoncpp/commoncpp.cxx index c7dc2bdeb26c..117afaca2c8a 100644 --- a/codemaker/source/commoncpp/commoncpp.cxx +++ b/codemaker/source/commoncpp/commoncpp.cxx @@ -29,6 +29,7 @@ #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <sal/types.h> +#include <o3tl/string_view.hxx> #include <vector> @@ -50,7 +51,7 @@ OString scopedCppName(OString const & type, bool ns_alias) nPos = 0; do { - tmpBuf.append("::" + type.getToken(0, c, nPos)); + tmpBuf.append(OString::Concat("::") + o3tl::getToken(type, 0, c, nPos)); } while( nPos != -1 ); OString s(tmpBuf.makeStringAndClear()); diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx index 94ba6f150f1b..d7b48a43a4b8 100644 --- a/compilerplugins/clang/stringview.cxx +++ b/compilerplugins/clang/stringview.cxx @@ -282,6 +282,31 @@ void StringView::handleCXXMemberCallExpr(CXXMemberCallExpr const* expr) } return; } + if (auto const dc2 = dc1.Function("getToken")) + { + if (dc2.Class("OString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()) + { + report(DiagnosticsEngine::Warning, + "rather than getToken, pass with a view using o3tl::getToken()", + expr->getExprLoc()) + << expr->getSourceRange(); + } + return; + } + if (auto const dc2 = dc1.Function("trim")) + { + if (dc2.Class("OString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUString").Namespace("rtl").GlobalNamespace() + || dc2.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()) + { + report(DiagnosticsEngine::Warning, + "rather than trim, pass with a view using o3tl::trim()", expr->getExprLoc()) + << expr->getSourceRange(); + } + return; + } if (auto const dc2 = dc1.Function("makeStringAndClear")) { if (dc2.Class("OStringBuffer").Namespace("rtl").GlobalNamespace() diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx index ae775b6fca01..a146d0c09680 100644 --- a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx +++ b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx @@ -22,6 +22,7 @@ #include <osl/file.h> #include <rtl/byteseq.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> IniParser::IniParser(OUString const & rIniName) { @@ -62,9 +63,9 @@ IniParser::IniParser(OUString const & rIniName) ini_Section *aSection = &mAllSection[sectionName]; struct ini_NameValue nameValue; nameValue.sName = OStringToOUString( - line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US ); + o3tl::trim(line.subView(0,nIndex)), RTL_TEXTENCODING_ASCII_US ); nameValue.sValue = OStringToOUString( - line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 ); + o3tl::trim(line.subView(nIndex+1)), RTL_TEXTENCODING_UTF8 ); aSection->vVector.push_back(nameValue); @@ -76,7 +77,7 @@ IniParser::IniParser(OUString const & rIniName) if ( nIndexEnd > nIndexStart && nIndexStart >=0) { sectionName = OStringToOUString( - line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US ); + o3tl::trim(line.subView(nIndexStart + 1,nIndexEnd - nIndexStart -1)), RTL_TEXTENCODING_ASCII_US ); if (sectionName.isEmpty()) sectionName = "no name section"; } diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index af08789c67b0..9c80960c669e 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -40,6 +40,7 @@ #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <unotools/configmgr.hxx> #include <comphelper/processfactory.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/frame/theUICommandDescription.hpp> namespace uno = com::sun::star::uno; @@ -317,8 +318,9 @@ void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector<NotebookbarEnt { sal_Int32 rPos = 0; aCategoryEntry.sDisplayName - = aCurItemEntry.sDisplayName.getToken(rPos, ' ', rPos) + " | " - + sUIItemId; + = OUString::Concat( + o3tl::getToken(aCurItemEntry.sDisplayName, rPos, ' ', rPos)) + + " | " + sUIItemId; } aCategoryList.push_back(aCategoryEntry); aCurItemEntry = aCategoryEntry; diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index fd1f4a36e10d..e51f05a44e93 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -52,6 +52,7 @@ #include <svx/dialmgr.hxx> #include <svx/strings.hrc> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> using namespace ::ucbhelper; using namespace ::cppu; @@ -754,7 +755,7 @@ void TPGalleryThemeProperties::FillFilterList() { if ( !aExtensions.isEmpty() ) aExtensions += ";"; - aExtensions += aWildcard + aFilter.second.getToken( 0, ';', nIndex ); + aExtensions += OUString::Concat(aWildcard) + o3tl::getToken(aFilter.second, 0, ';', nIndex ); } } #endif diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index a6c4a2ca5ad6..1272a52f091d 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -42,6 +42,7 @@ #include <com/sun/star/util/thePathSettings.hpp> #include <tools/diagnose_ex.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> using namespace css; using namespace css::beans; @@ -368,7 +369,7 @@ IMPL_LINK_NOARG(SvxPathTabPage, StandardHdl_Impl, weld::Button&, void) sal_Int32 nInternalPos = 0; do { - if ( sInternal.getToken( 0, MULTIPATH_DELIMITER, nInternalPos ) == sOnePath ) + if ( o3tl::getToken(sInternal, 0, MULTIPATH_DELIMITER, nInternalPos ) == sOnePath ) bFound = true; } while ( !bFound && nInternalPos >= 0 ); diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx index d9b071dcff66..e80e471ff228 100644 --- a/cui/source/tabpages/macroass.cxx +++ b/cui/source/tabpages/macroass.cxx @@ -19,6 +19,7 @@ #include <macroass.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <comphelper/string.hxx> #include <comphelper/processfactory.hxx> @@ -70,7 +71,7 @@ static OUString ConvertToUIName_Impl( SvxMacro const *pMacro ) OUString aEntry = aName.getToken( nCount-1, '.' ); if ( nCount > 2 ) { - aEntry += "(" + aName.getToken( 0, '.' ) + "." + aName.getToken( nCount-2, '.' ) + ")"; + aEntry += OUString::Concat("(") + o3tl::getToken(aName, 0, '.' ) + "." + o3tl::getToken(aName, nCount-2, '.' ) + ")"; } return aEntry; } diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index 6c3598e9313c..ffbabde52f76 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -42,6 +42,7 @@ #include <vcl/svapp.hxx> #include <osl/mutex.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -611,7 +612,7 @@ void SAL_CALL ODocumentContainer::insertByHierarchicalName( const OUString& _sNa sal_Int32 index = sName.getLength(); OUString sMessage( DBA_RES(RID_STR_NO_SUB_FOLDER).replaceFirst("$folder$", - _sName.getToken(0,'/',index))); + o3tl::getToken(_sName, 0,'/',index))); throw IllegalArgumentException( sMessage, *this, 1 ); } diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx index 5b2fed5c26de..7ff32140e933 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx @@ -35,6 +35,7 @@ #include <svl/filenotation.hxx> #include <com/sun/star/ucb/XProgressHandler.hpp> #include <connectivity/CommonTools.hxx> +#include <o3tl/string_view.hxx> namespace dbaui { @@ -247,7 +248,7 @@ namespace dbaui { ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() ); m_xJavaDriver->set_text(m_xJavaDriver->get_text().trim()); // fdo#68341 - bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_xJavaDriver->get_text().trim()); + bSuccess = ::connectivity::existsJavaClassByName(xJVM, o3tl::trim(m_xJavaDriver->get_text())); } } catch(Exception&) diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index 7bfbd5d769cf..99ad22b9660e 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -55,6 +55,7 @@ #include <vcl/settings.hxx> #include <svtools/rtfout.hxx> #include <svtools/htmlcfg.hxx> +#include <o3tl/string_view.hxx> #include <connectivity/formattedcolumnvalue.hxx> #include <memory> @@ -351,7 +352,7 @@ bool ORTFImportExport::Write() m_pStream->WriteCharPtr( "\\f" ); m_pStream->WriteInt32AsString(++nTok); m_pStream->WriteCharPtr( "\\fcharset0\\fnil " ); - m_pStream->WriteOString( aFonts.getToken(0, ';', nIdx) ); + m_pStream->WriteOString( o3tl::getToken(aFonts, 0, ';', nIdx) ); m_pStream->WriteChar( ';' ); } while (nIdx>=0); } diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index ce6c45673688..42b0d3a7a817 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -25,6 +25,7 @@ #include <vcl/split.hxx> #include <tools/diagnose_ex.h> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -919,7 +920,7 @@ namespace { aWorkStr += quoteTableAlias(bMulti,field->GetAlias(),aQuote) + ::dbtools::quoteName(aQuote, aColumnName); } - aWorkStr += " " + OUString( ";ASC;DESC" ).getToken( static_cast<sal_uInt16>(eOrder), ';' ) + ","; + aWorkStr += OUString::Concat(" ") + o3tl::getToken( u";ASC;DESC", static_cast<sal_uInt16>(eOrder), ';' ) + ","; } } @@ -2171,7 +2172,7 @@ namespace if ( SQL_ISRULE(pColumnRef,general_set_fct) ) { aInfo->SetFunctionType(nFunctionType|FKT_AGGREGATE); - aInfo->SetFunction(comphelper::string::stripEnd(aColumns.getToken(0,'('), ' ')); + aInfo->SetFunction(comphelper::string::stripEnd(o3tl::getToken(aColumns,0,'('), ' ')); } else aInfo->SetFunctionType(nFunctionType|FKT_OTHER); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index ac183e9d09e9..cc2895d12c67 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -49,6 +49,7 @@ #include <vcl/commandevent.hxx> #include <vcl/svapp.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> using namespace ::svt; using namespace ::dbaui; @@ -74,8 +75,8 @@ namespace if ( !bAsterisk ) { sal_Int32 nTokenCount = comphelper::string::getTokenCount(_sFieldName, '.'); - if ( (nTokenCount == 2 && _sFieldName.getToken(1,'.')[0] == '*' ) - || (nTokenCount == 3 && _sFieldName.getToken(2,'.')[0] == '*' ) ) + if ( (nTokenCount == 2 && o3tl::getToken(_sFieldName,1,'.')[0] == '*' ) + || (nTokenCount == 3 && o3tl::getToken(_sFieldName,2,'.')[0] == '*' ) ) { bAsterisk = true; } @@ -146,7 +147,7 @@ OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent ) const OUString aTxt(DBA_RES(STR_QUERY_SORTTEXT)); for (sal_Int32 nIdx {0}; nIdx>=0;) - rOrderBox.append_text(aTxt.getToken(0, ';', nIdx)); + rOrderBox.append_text(OUString(o3tl::getToken(aTxt, 0, ';', nIdx))); m_bVisibleRow.insert(m_bVisibleRow.end(), BROW_ROW_CNT, true); @@ -492,7 +493,7 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, sal getDesignView()->fillValidFields(aTable, rComboBox); // replace with alias.* - if (aField.trim() == "*") + if (o3tl::trim(aField) == u"*") { aField = aTable + ".*"; } diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 360cd2821235..248fbc66d308 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -68,6 +68,7 @@ #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <osl/mutex.hxx> +#include <o3tl/string_view.hxx> #include <memory> #include <vector> @@ -874,7 +875,7 @@ OUString OQueryController::getPrivateTitle( ) const SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( getMutex() ); OUString aDefaultName = DBA_RES(editingView() ? STR_VIEW_TITLE : STR_QRY_TITLE); - return aDefaultName.getToken(0, ' ') + OUString::number(getCurrentStartNumber()); + return o3tl::getToken(aDefaultName, 0, ' ') + OUString::number(getCurrentStartNumber()); } } return m_sName; diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 17ad5ed2f28d..fb1e4805e0d8 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -53,6 +53,7 @@ #include <tools/diagnose_ex.h> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> +#include <o3tl/string_view.hxx> #include <algorithm> #include <functional> @@ -1443,7 +1444,7 @@ OUString OTableController::getPrivateTitle() const if ( sTitle.isEmpty() ) { OUString aName = DBA_RES(STR_TBL_TITLE); - sTitle = aName.getToken(0,' ') + OUString::number(getCurrentStartNumber()); + sTitle = o3tl::getToken(aName,0,' ') + OUString::number(getCurrentStartNumber()); } } catch( const Exception& ) diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 40239f2501b2..17b9b774a17d 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -33,6 +33,7 @@ #include <cppuhelper/compbase.hxx> #include <comphelper/sequence.hxx> #include <ucbhelper/content.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/ucb/ContentCreationException.hpp> #include <com/sun/star/uno/DeploymentException.hpp> #include <com/sun/star/lang/DisposedException.hpp> @@ -152,12 +153,12 @@ PackageRegistryImpl::~PackageRegistryImpl() } -OUString normalizeMediaType( OUString const & mediaType ) +OUString normalizeMediaType( std::u16string_view mediaType ) { OUStringBuffer buf; sal_Int32 index = 0; for (;;) { - buf.append( mediaType.getToken( 0, '/', index ).trim() ); + buf.append( o3tl::trim(o3tl::getToken(mediaType, 0, '/', index )) ); if (index < 0) break; buf.append( '/' ); @@ -491,7 +492,7 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage( iFind = m_mediaType2backend.find( normalizeMediaType( // cut parameters: - mediaType.copy( 0, q ) ) ); + mediaType.subView( 0, q ) ) ); } } if (iFind == m_mediaType2backend.end()) { diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 933a119d696d..017a5838c93b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -44,6 +44,7 @@ #include <vcl/lok.hxx> #include <o3tl/any.hxx> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> #include <osl/file.hxx> #include <osl/process.h> #include <osl/thread.h> @@ -4509,9 +4510,9 @@ static bool getFromTransferrable( // Take care of UTF-8 text here. bool bConvert = false; sal_Int32 nIndex = 0; - if (aMimeType.getToken(0, ';', nIndex) == "text/plain") + if (o3tl::getToken(aMimeType, 0, ';', nIndex) == "text/plain") { - if (aMimeType.getToken(0, ';', nIndex) == "charset=utf-8") + if (o3tl::getToken(aMimeType, 0, ';', nIndex) == "charset=utf-8") { aMimeType = "text/plain;charset=utf-16"; bConvert = true; diff --git a/extensions/source/abpilot/abpfinalpage.cxx b/extensions/source/abpilot/abpfinalpage.cxx index 6469691b1f99..045a66d3f211 100644 --- a/extensions/source/abpilot/abpfinalpage.cxx +++ b/extensions/source/abpilot/abpfinalpage.cxx @@ -27,6 +27,7 @@ #include <unotools/pathoptions.hxx> #include <svl/filenotation.hxx> #include <sfx2/docfilt.hxx> +#include <o3tl/string_view.hxx> namespace abp { @@ -101,7 +102,7 @@ namespace abp if ( pFilter ) { OUString sExt = pFilter->GetDefaultExtension(); - sPath += sExt.getToken(1,'*'); + sPath += o3tl::getToken(sExt,1,'*'); } aURL.SetURL(sPath); diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 9e7d5a5cb10d..9f889924cfb6 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -37,6 +37,7 @@ #include <xmloff/namespacemap.hxx> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> #include <i18nlangtag/languagetag.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XIndexReplace.hpp> @@ -3701,7 +3702,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, // Both the pattern and the rectangle are embedded in a <defs> element. // The comment content has the following format: "SLIDE_BACKGROUND <background-id>" const OString& sComment = pA->GetComment(); - OUString sRefId = "#" + OUString::fromUtf8( sComment.getToken(1, ' ') ); + OUString sRefId = "#" + OUString::fromUtf8( o3tl::getToken(sComment, 1, ' ') ); mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, sRefId ); SvXMLElementExport aRefElem( mrExport, XML_NAMESPACE_NONE, "use", true, true ); diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx index 0795df6eeb2c..f8309a766ef3 100644 --- a/idlc/source/astscope.cxx +++ b/idlc/source/astscope.cxx @@ -161,7 +161,7 @@ AstDeclaration* AstScope::lookupByName(const OString& scopedName) pScope = declAsScope(pDecl); if( pScope ) { - pDecl = pScope->lookupByNameLocal(scopedName.getToken(nOffset, ':', i )); + pDecl = pScope->lookupByNameLocal(o3tl::getToken(scopedName, nOffset, ':', i )); nOffset = 1; } if( !pDecl ) diff --git a/idlc/source/idlcproduce.cxx b/idlc/source/idlcproduce.cxx index e5ea206f0ff8..732647c9e715 100644 --- a/idlc/source/idlcproduce.cxx +++ b/idlc/source/idlcproduce.cxx @@ -22,6 +22,7 @@ #include <rtl/strbuf.hxx> #include <osl/file.hxx> #include <osl/thread.h> +#include <o3tl/string_view.hxx> #if defined(_WIN32) #include <io.h> @@ -63,7 +64,7 @@ static bool checkOutputPath(const OString& completeName) do { - buffer.append(sysPathName.getToken(0, SEPARATOR, nIndex)); + buffer.append(o3tl::getToken(sysPathName, 0, SEPARATOR, nIndex)); if ( !buffer.isEmpty() && nIndex != -1 ) { diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx index d9fc84a0d18b..c09352145440 100644 --- a/include/o3tl/string_view.hxx +++ b/include/o3tl/string_view.hxx @@ -41,11 +41,13 @@ inline int compareToIgnoreAsciiCase(std::u16string_view s1, std::u16string_view // given position (and if needed, it can be turned into a template to also cover std::u16string_view // etc., or extended to return the n'th token instead of just the first, or support an initial // position of npos): -inline std::string_view getToken(std::string_view sv, char delimiter, std::size_t& position) +template <typename charT, typename traits = std::char_traits<charT>> +inline std::basic_string_view<charT, traits> getToken(std::basic_string_view<charT, traits> sv, + charT delimiter, std::size_t& position) { assert(position <= sv.size()); auto const n = sv.find(delimiter, position); - std::string_view t; + std::basic_string_view<charT, traits> t; if (n == std::string_view::npos) { t = sv.substr(position); @@ -58,10 +60,20 @@ inline std::string_view getToken(std::string_view sv, char delimiter, std::size_ } return t; } +inline std::string_view getToken(std::string_view sv, char delimiter, std::size_t& position) +{ + return getToken<char>(sv, delimiter, position); +} +inline std::u16string_view getToken(std::u16string_view sv, char delimiter, std::size_t& position) +{ + return getToken<char16_t>(sv, delimiter, position); +} // Similar to OUString::getToken -inline std::u16string_view getToken(std::u16string_view pStr, sal_Int32 nToken, sal_Unicode cTok, - sal_Int32& rnIndex) +template <typename charT, typename traits = std::char_traits<charT>> +inline std::basic_string_view<charT, traits> getToken(std::basic_string_view<charT, traits> pStr, + sal_Int32 nToken, charT cTok, + sal_Int32& rnIndex) { assert(rnIndex <= static_cast<sal_Int32>(pStr.size())); @@ -69,11 +81,11 @@ inline std::u16string_view getToken(std::u16string_view pStr, sal_Int32 nToken, // negative: if (rnIndex >= 0 && nToken >= 0) { - const sal_Unicode* pOrgCharStr = pStr.data(); - const sal_Unicode* pCharStr = pOrgCharStr + rnIndex; + const charT* pOrgCharStr = pStr.data(); + const charT* pCharStr = pOrgCharStr + rnIndex; sal_Int32 nLen = pStr.size() - rnIndex; sal_Int32 nTokCount = 0; - const sal_Unicode* pCharStrStart = pCharStr; + const charT* pCharStrStart = pCharStr; while (nLen > 0) { if (*pCharStr == cTok) @@ -95,12 +107,32 @@ inline std::u16string_view getToken(std::u16string_view pStr, sal_Int32 nToken, rnIndex = pCharStr - pOrgCharStr + 1; else rnIndex = -1; - return std::u16string_view(pCharStrStart, pCharStr - pCharStrStart); + return std::basic_string_view<charT, traits>(pCharStrStart, pCharStr - pCharStrStart); } } rnIndex = -1; - return std::u16string_view(); + return std::basic_string_view<charT, traits>(); +} +inline std::string_view getToken(std::string_view sv, sal_Int32 nToken, char cTok, + sal_Int32& rnIndex) +{ + return getToken<char>(sv, nToken, cTok, rnIndex); +} +inline std::u16string_view getToken(std::u16string_view sv, sal_Int32 nToken, char16_t cTok, + sal_Int32& rnIndex) +{ + return getToken<char16_t>(sv, nToken, cTok, rnIndex); +} +inline std::string_view getToken(std::string_view sv, sal_Int32 nToken, char cTok) +{ + sal_Int32 nIndex = 0; + return getToken<char>(sv, nToken, cTok, nIndex); +} +inline std::u16string_view getToken(std::u16string_view sv, sal_Int32 nToken, char16_t cTok) +{ + sal_Int32 nIndex = 0; + return getToken<char16_t>(sv, nToken, cTok, nIndex); } // Implementations of C++20 std::basic_string_view::starts_with and diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 3accb5e4e636..f8dc6fc3c478 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -163,7 +163,7 @@ void LngParser::Merge( // seek to next group while ( nPos < mvLines.size() && !bGroup ) - bGroup = lcl_isNextGroup(sGroup, mvLines[nPos++].trim()); + bGroup = lcl_isNextGroup(sGroup, o3tl::trim(mvLines[nPos++])); while ( nPos < mvLines.size()) { OStringHashMap Text; diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index d68b382e38e4..2f7d7edc7815 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -32,6 +32,7 @@ #include <oox/helper/binaryoutputstream.hxx> #include <oox/helper/textinputstream.hxx> #include <tools/time.hxx> +#include <o3tl/string_view.hxx> #ifdef DBG_UTIL @@ -2381,7 +2382,7 @@ void XmlStreamObject::implDumpText( TextInputStream& rTextStrm ) { while( (nPos < aElem.getLength()) && (aElem[ nPos ] >= 32) ) ++nPos; if( nPos < aElem.getLength() ) - aElem = aElem.subView( 0, nPos ) + OUStringChar(' ') + aElem.copy( nPos ).trim(); + aElem = aElem.subView( 0, nPos ) + OUStringChar(' ') + o3tl::trim(aElem.subView( nPos )); ++nPos; } diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 47bfb27fc1da..a566069c3a2e 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -349,7 +349,7 @@ std::vector<sal_Int32> AttributeList::getTokenList(sal_Int32 nAttrToken) const sal_Int32 nIndex = 0; do { - aValues.push_back(AttributeConversion::decodeToken(sValue.getToken(0, ' ', nIndex))); + aValues.push_back(AttributeConversion::decodeToken(o3tl::getToken(sValue, 0, ' ', nIndex))); } while (nIndex >= 0); return aValues; diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 9b3a1491a435..b8415111d38c 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -2579,7 +2579,7 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) // Ultra hacky parser for the info sal_Int32 nLineIdx {0}; // first line will tell us if multiselect is enabled - if (data.getToken( 0, '\n', nLineIdx )=="<SELECT MULTIPLE") + if (o3tl::getToken(data, 0, '\n', nLineIdx ) == u"<SELECT MULTIPLE") mnMultiSelect = AX_SELECTION_MULTI; // skip first and last lines, no data there if (nLineIdx>0) diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index 88d4bbd59b36..a25bc615c382 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -37,6 +37,7 @@ #include <rtl/uri.hxx> #include <sal/log.hxx> #include <o3tl/lru_map.hxx> +#include <o3tl/string_view.hxx> #include <vector> #include <algorithm> @@ -350,8 +351,8 @@ Bootstrap_Impl::Bootstrap_Impl( OUString const & rIniName ) if (nIndex >= 1) { struct rtl_bootstrap_NameValue nameValue; - nameValue.sName = OStringToOUString(line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US); - nameValue.sValue = OStringToOUString(line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8); + nameValue.sName = OStringToOUString(o3tl::trim(line.subView(0,nIndex)), RTL_TEXTENCODING_ASCII_US); + nameValue.sValue = OStringToOUString(o3tl::trim(line.subView(nIndex+1)), RTL_TEXTENCODING_UTF8); SAL_INFO("sal.bootstrap", "pushing: name=" << nameValue.sName << " value=" << nameValue.sValue); diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 04732630b629..cf8d2e4a1431 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -24,6 +24,7 @@ #include <sal/log.hxx> #include <unotools/configmgr.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <document.hxx> #include <table.hxx> @@ -1190,9 +1191,9 @@ void ScDocument::CompareDocument( ScDocument& rOtherDoc ) GetName( nThisTab, aTabName ); OUString aTemplate = ScResId(STR_PROGRESS_COMPARING); sal_Int32 nIndex = 0; - OUString aProText = aTemplate.getToken( 0, '#', nIndex ) + + OUString aProText = o3tl::getToken(aTemplate, 0, '#', nIndex ) + aTabName + - aTemplate.getToken( 0, '#', nIndex ); + o3tl::getToken(aTemplate, 0, '#', nIndex ); ScProgress aProgress( GetDocumentShell(), aProText, 3*nThisEndRow, true ); // 2x FindOrder, 1x here tools::Long nProgressStart = 2*nThisEndRow; // start for here diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 9c4c01913e93..0b04ccaafee5 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -48,6 +48,7 @@ #include <vcl/svapp.hxx> #include <tools/urlobj.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <rtl/tencinfo.h> @@ -2933,7 +2934,7 @@ void ScHTMLQueryParser::FontOn( const HtmlImportInfo& rInfo ) while( nPos != -1 ) { // font list separator: VCL = ';' HTML = ',' - OUString aFName = comphelper::string::strip(rFace.getToken(0, ',', nPos), ' '); + OUString aFName = comphelper::string::strip(o3tl::getToken(rFace, 0, ',', nPos), ' '); aFontName = ScGlobal::addToken(aFontName, aFName, ';'); } if ( !aFontName.isEmpty() ) diff --git a/sc/source/filter/oox/pagesettings.cxx b/sc/source/filter/oox/pagesettings.cxx index a757d8d23d43..9c923d51a57b 100644 --- a/sc/source/filter/oox/pagesettings.cxx +++ b/sc/source/filter/oox/pagesettings.cxx @@ -423,7 +423,7 @@ private: /** Sets the passed font name if it is valid. */ void convertFontName( const OUString& rStyle ); /** Converts a font style given as string. */ - void convertFontStyle( const OUString& rStyle ); + void convertFontStyle( std::u16string_view rStyle ); /** Converts a font color given as string. */ void convertFontColor( const OUString& rColor ); @@ -827,14 +827,14 @@ void HeaderFooterParser::convertFontName( const OUString& rName ) } } -void HeaderFooterParser::convertFontStyle( const OUString& rStyle ) +void HeaderFooterParser::convertFontStyle( std::u16string_view rStyle ) { maFontModel.mbBold = maFontModel.mbItalic = false; - if (rStyle.isEmpty()) + if (rStyle.empty()) return; for( sal_Int32 nPos{ 0 }; nPos>=0; ) { - OString aToken = OUStringToOString( rStyle.getToken( 0, ' ', nPos ), RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase(); + OString aToken = OUStringToOString( o3tl::getToken(rStyle, 0, ' ', nPos ), RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase(); if( !aToken.isEmpty() ) { if( maBoldNames.count( aToken ) > 0 ) diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 3e9420ecd05b..61e3c20a5abc 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -19,6 +19,7 @@ #include <checklistmenu.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <globstr.hrc> #include <scresid.hxx> @@ -1030,7 +1031,7 @@ void ScCheckListMenuControl::addMember(const OUString& rName, const double nVal, { ScCheckListMember aMember; // tdf#46062 - indicate hidden whitespaces using quotes - aMember.maName = rName.trim() != rName ? "\"" + rName + "\"" : rName; + aMember.maName = o3tl::trim(rName) != rName ? "\"" + rName + "\"" : rName; aMember.maRealName = rName; aMember.mnValue = nVal; aMember.mbDate = false; diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index c7f920f5fb25..e73e71b76e97 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -21,6 +21,7 @@ #include <asciiopt.hxx> #include <comphelper/string.hxx> #include <osl/thread.h> +#include <o3tl/string_view.hxx> const char pStrFix[] = "FIX"; const char pStrMrg[] = "MRG"; @@ -141,13 +142,13 @@ void ScAsciiOptions::ReadFromString( const OUString& rString ) // Token 6: Import quoted field as text. if (nPos >= 0) { - bQuotedFieldAsText = rString.getToken(0, ',', nPos) == "true"; + bQuotedFieldAsText = o3tl::getToken(rString, 0, ',', nPos) == u"true"; } // Token 7: Detect special numbers. if (nPos >= 0) { - bDetectSpecialNumber = rString.getToken(0, ',', nPos) == "true"; + bDetectSpecialNumber = o3tl::getToken(rString, 0, ',', nPos) == u"true"; } else bDetectSpecialNumber = true; // default of versions that didn't add the parameter @@ -155,7 +156,7 @@ void ScAsciiOptions::ReadFromString( const OUString& rString ) // Token 8: used for "Save as shown" in export options if ( nPos >= 0 ) { - bSaveAsShown = rString.getToken(0, ',', nPos) == "true"; + bSaveAsShown = o3tl::getToken(rString, 0, ',', nPos) == u"true"; } else bSaveAsShown = true; // default value @@ -163,7 +164,7 @@ void ScAsciiOptions::ReadFromString( const OUString& rString ) // Token 9: used for "Save cell formulas" in export options if ( nPos >= 0 ) { - bSaveFormulas = rString.getToken(0, ',', nPos) == "true"; + bSaveFormulas = o3tl::getToken(rString, 0, ',', nPos) == u"true"; } else bSaveFormulas = false; @@ -171,7 +172,7 @@ void ScAsciiOptions::ReadFromString( const OUString& rString ) // Token 10: Boolean for Trim spaces. if (nPos >= 0) { - bRemoveSpace = rString.getToken(0, ',', nPos) == "true"; + bRemoveSpace = o3tl::getToken(rString, 0, ',', nPos) == u"true"; } else bRemoveSpace = false; @@ -187,7 +188,7 @@ void ScAsciiOptions::ReadFromString( const OUString& rString ) if (nPos >= 0) { // If present, defaults to "false". - bEvaluateFormulas = rString.getToken(0, ',', nPos) == "true"; + bEvaluateFormulas = o3tl::getToken(rString, 0, ',', nPos) == u"true"; } else bEvaluateFormulas = true; // default of versions that didn't add the parameter diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index a0f6f209347c..a2ac72209e93 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -26,6 +26,7 @@ #include <unotools/charclass.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> +#include <o3tl/string_view.hxx> #include <reffact.hxx> #include <document.hxx> @@ -509,7 +510,7 @@ IMPL_LINK_NOARG(ScDbNameDlg, RemoveBtnHdl, weld::Button&, void) return; OUString aStrDelMsg = ScResId( STR_QUERY_DELENTRY ); - OUString sMsg{ aStrDelMsg.getToken(0, '#') + aStrEntry + aStrDelMsg.getToken(1, '#') }; + OUString sMsg{ o3tl::getToken(aStrDelMsg, 0, '#') + aStrEntry + o3tl::getToken(aStrDelMsg, 1, '#') }; std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, sMsg)); diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx index 7c161da22754..3acb3cd00e36 100644 --- a/sc/source/ui/dbgui/imoptdlg.cxx +++ b/sc/source/ui/dbgui/imoptdlg.cxx @@ -22,6 +22,7 @@ #include <comphelper/string.hxx> #include <unotools/charclass.hxx> #include <osl/thread.h> +#include <o3tl/string_view.hxx> #include <global.hxx> const char pStrFix[] = "FIX"; @@ -71,15 +72,15 @@ ScImportOptions::ScImportOptions( const OUString& rStr ) { // look at the same positions as in ScAsciiOptions if ( nTokenCount >= 7 ) - bQuoteAllText = rStr.getToken(3, ',', nIdx) == "true"; // 7th token + bQuoteAllText = o3tl::getToken(rStr, 3, ',', nIdx) == u"true"; // 7th token if ( nTokenCount >= 8 ) - bSaveNumberAsSuch = rStr.getToken(0, ',', nIdx) == "true"; + bSaveNumberAsSuch = o3tl::getToken(rStr, 0, ',', nIdx) == u"true"; if ( nTokenCount >= 9 ) - bSaveAsShown = rStr.getToken(0, ',', nIdx) == "true"; + bSaveAsShown = o3tl::getToken(rStr, 0, ',', nIdx) == u"true"; if ( nTokenCount >= 10 ) - bSaveFormulas = rStr.getToken(0, ',', nIdx) == "true"; + bSaveFormulas = o3tl::getToken(rStr, 0, ',', nIdx) == u"true"; if ( nTokenCount >= 11 ) - bRemoveSpace = rStr.getToken(0, ',', nIdx) == "true"; + bRemoveSpace = o3tl::getToken(rStr, 0, ',', nIdx) == u"true"; if ( nTokenCount >= 12 ) { const OUString aTok(rStr.getToken(0, ',', nIdx)); @@ -92,7 +93,7 @@ ScImportOptions::ScImportOptions( const OUString& rStr ) } if ( nTokenCount >= 13 ) // If present, defaults to "false". - bEvaluateFormulas = rStr.getToken(0, ',', nIdx) == "true"; + bEvaluateFormulas = o3tl::getToken(rStr, 0, ',', nIdx) == u"true"; } } diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx index 30bd89823f89..242fd50be66e 100644 --- a/sc/source/ui/dbgui/scuiimoptdlg.cxx +++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx @@ -28,6 +28,7 @@ #include <rtl/tencinfo.h> #include <imoptdlg.hxx> #include <svx/txencbox.hxx> +#include <o3tl/string_view.hxx> // ScDelimiterTable @@ -58,8 +59,8 @@ sal_uInt16 ScDelimiterTable::GetCode( std::u16string_view rDel ) const sal_Int32 nIdx {0}; // Check even tokens: start from 0 and then skip 1 token at each iteration - if (rDel != theDelTab.getToken( 0, cSep, nIdx )) - while (nIdx>0 && rDel != theDelTab.getToken( 1, cSep, nIdx )); + if (rDel != o3tl::getToken(theDelTab, 0, cSep, nIdx )) + while (nIdx>0 && rDel != o3tl::getToken(theDelTab, 1, cSep, nIdx )); if (nIdx>0) return static_cast<sal_Unicode>(theDelTab.getToken( 0, cSep, nIdx ).toInt32()); diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 2f4ee0492aa2..411658e1136a 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -21,6 +21,7 @@ #include <comphelper/lok.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <sfx2/app.hxx> #include <editeng/editobj.hxx> #include <editeng/justifyitem.hxx> @@ -5235,7 +5236,7 @@ void ScDocFunc::CreateOneName( ScRangeName& rList, else { OUString aTemplate = ScResId( STR_CREATENAME_REPLACE ); - OUString aMessage = aTemplate.getToken( 0, '#' ) + aName + aTemplate.getToken( 1, '#' ); + OUString aMessage = o3tl::getToken(aTemplate, 0, '#' ) + aName + o3tl::getToken(aTemplate, 1, '#' ); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(ScDocShell::GetActiveDialogParent(), VclMessageType::Question, VclButtonsType::YesNo, diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 15ba7c8abba4..b0f16fd8cb15 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -58,6 +58,7 @@ using namespace ::com::sun::star; #include <sal/log.hxx> #include <unotools/charclass.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> @@ -330,9 +331,9 @@ void ScDocShell::Execute( SfxRequest& rReq ) if (!bIsNewArea) { OUString aTemplate = ScResId( STR_IMPORT_REPLACE ); - OUString aMessage = aTemplate.getToken( 0, '#' ) + OUString aMessage = o3tl::getToken(aTemplate, 0, '#' ) + sTarget - + aTemplate.getToken( 1, '#' ); + + o3tl::getToken(aTemplate, 1, '#' ); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, VclMessageType::Question, VclButtonsType::YesNo, diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 35fd94055f8e..55a6bbd16bdd 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -35,6 +35,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdbc/DataType.hpp> @@ -477,7 +478,7 @@ void lcl_GetColumnTypes( if ( nIdx>0 ) { aString = aString.replaceAll(" ", ""); - switch ( aString.getToken( 0, ',', nIdx )[0] ) + switch ( o3tl::getToken(aString, 0, ',', nIdx )[0] ) { case 'L' : nDbType = sdbc::DataType::BIT; diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx index d62e57f2e00a..980b92161c87 100644 --- a/sc/source/ui/miscdlgs/crnrdlg.cxx +++ b/sc/source/ui/miscdlgs/crnrdlg.cxx @@ -25,6 +25,7 @@ #include <crnrdlg.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> +#include <o3tl/string_view.hxx> #include <memory> namespace @@ -570,9 +571,9 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, RemoveBtnHdl, weld::Button&, void) return; OUString aStrDelMsg = ScResId( STR_QUERY_DELENTRY ); - OUString aMsg = aStrDelMsg.getToken( 0, '#' ) + OUString aMsg = o3tl::getToken(aStrDelMsg, 0, '#' ) + aRangeStr - + aStrDelMsg.getToken( 1, '#' ); + + o3tl::getToken(aStrDelMsg, 1, '#' ); if (RET_YES != QUERYBOX(m_xDialog.get(), aMsg)) return; diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index d08c93b3e5dc..ecf446081c13 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -23,6 +23,7 @@ #include <vcl/weld.hxx> #include <sfx2/strings.hrc> #include <sfx2/sfxresid.hxx> +#include <o3tl/string_view.hxx> #include <strings.hrc> #include <global.hxx> #include <globstr.hrc> @@ -243,9 +244,9 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RemoveHdl, weld::Button&, void) { if ( (nIndex > 0) && (m_xLbFormat->n_children() > 0) ) { - OUString aMsg = aStrDelMsg.getToken( 0, '#' ) + OUString aMsg = o3tl::getToken(aStrDelMsg, 0, '#' ) + m_xLbFormat->get_selected_text() - + aStrDelMsg.getToken( 1, '#' ); + + o3tl::getToken(aStrDelMsg, 1, '#' ); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, diff --git a/sc/source/ui/optdlg/tpusrlst.cxx b/sc/source/ui/optdlg/tpusrlst.cxx index 55351cdcf8fc..6553d64de926 100644 --- a/sc/source/ui/optdlg/tpusrlst.cxx +++ b/sc/source/ui/optdlg/tpusrlst.cxx @@ -24,6 +24,7 @@ #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <document.hxx> #include <tabvwsh.hxx> @@ -284,7 +285,7 @@ void ScTpUserLists::MakeListStr( OUString& rListStr ) for(sal_Int32 nIdx=0; nIdx>=0;) { - aStr.append(comphelper::string::strip(rListStr.getToken(0, LF, nIdx), ' ')); + aStr.append(comphelper::string::strip(o3tl::getToken(rListStr, 0, LF, nIdx), ' ')); aStr.append(cDelimiter); } @@ -591,9 +592,9 @@ IMPL_LINK( ScTpUserLists, BtnClickHdl, weld::Button&, rBtn, void ) if ( mxLbLists->n_children() > 0 ) { sal_Int32 nRemovePos = mxLbLists->get_selected_index(); - OUString aMsg = aStrQueryRemove.getToken( 0, '#' ) + OUString aMsg = o3tl::getToken(aStrQueryRemove, 0, '#' ) + mxLbLists->get_text( nRemovePos ) - + aStrQueryRemove.getToken( 1, '#' ); + + o3tl::getToken(aStrQueryRemove, 1, '#' ); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index d7aa279c7413..841f2f6ea4d3 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -21,6 +21,7 @@ #include <editeng/eeitem.hxx> #include <o3tl/safeint.hxx> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> #include <sfx2/lokhelper.hxx> #include <sfx2/viewfrm.hxx> #include <editeng/adjustitem.hxx> @@ -3323,7 +3324,7 @@ void ScViewData::ReadUserData(const OUString& rData) sal_Int32 nIdx {0}; OUString aZoomStr = rData.getToken(0, ';', nMainIdx); // Zoom/PageZoom/Mode - sal_Unicode cMode = aZoomStr.getToken(2, '/', nIdx)[0]; // 0 or "0"/"1" + sal_Unicode cMode = o3tl::getToken(aZoomStr, 2, '/', nIdx)[0]; // 0 or "0"/"1" SetPagebreakMode( cMode == '1' ); // SetPagebreakMode must always be called due to CalcPPT / RecalcPixPos() diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx index e6b9fff68807..d7c19401dc81 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -36,6 +36,7 @@ #include <unotools/syslocaleoptions.hxx> #include <tools/stream.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <vcl/svapp.hxx> #include <unotools/ucbstreamhelper.hxx> @@ -192,7 +193,7 @@ bool CustomAnimationPreset::hasProperty( std::u16string_view rProperty )const sal_Int32 nPos = 0; do { - if (maProperty.getToken(0, ';', nPos) == rProperty) + if (o3tl::getToken(maProperty, 0, ';', nPos) == rProperty) return true; } while (nPos >= 0); diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index 3d9ed7dfc14a..1e7abd43bdfd 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -40,6 +40,7 @@ #include <svx/xlineit0.hxx> #include <sfx2/docinf.hxx> +#include <o3tl/string_view.hxx> #include <strings.hrc> #include <strings.hxx> @@ -425,7 +426,7 @@ bool ImplSdPPTImport::Import() do { aStringAry[nTokenCount] = - OUStringToOString(aString.getToken( 0, ',', nPos ), RTL_TEXTENCODING_UTF8); + OUStringToOString(o3tl::getToken(aString, 0, ',', nPos ), RTL_TEXTENCODING_UTF8); } while ( ++nTokenCount < SAL_N_ELEMENTS(aStringAry) && nPos >= 0 ); diff --git a/sd/source/ui/dlg/tpaction.cxx b/sd/source/ui/dlg/tpaction.cxx index 03f3080ba22e..c5ccd758a321 100644 --- a/sd/source/ui/dlg/tpaction.cxx +++ b/sd/source/ui/dlg/tpaction.cxx @@ -44,6 +44,7 @@ #include <sfx2/filedlghelper.hxx> #include <svx/drawitem.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <View.hxx> #include <sdresid.hxx> #include <tpaction.hxx> @@ -314,7 +315,7 @@ void SdTPAction::Reset( const SfxItemSet* rAttrs ) case presentation::ClickAction_DOCUMENT: { if( comphelper::string::getTokenCount(aFileName, DOCUMENT_TOKEN) == 2 ) - m_xLbTreeDocument->SelectEntry( aFileName.getToken( 1, DOCUMENT_TOKEN ) ); + m_xLbTreeDocument->SelectEntry( o3tl::getToken(aFileName, 1, DOCUMENT_TOKEN ) ); } break; diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index bdfca5f326cd..fbdd95c3c57d 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -41,6 +41,7 @@ #include <svtools/sfxecode.hxx> #include <svtools/ehdl.hxx> #include <tools/urlobj.hxx> +#include <o3tl/string_view.hxx> #include <bitmaps.hlst> using namespace ::com::sun::star::io; @@ -708,7 +709,7 @@ namespace bool lcl_mapResolution(OUString& rResolution, const OUString& rImageResolution) { - if (rImageResolution.getToken(1, ';')!=rResolution) + if (o3tl::getToken(rImageResolution, 1, ';')!=rResolution) return false; rResolution = rImageResolution.getToken(0, ';'); return true; diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index ff323c78cf78..e175b7458726 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -27,6 +27,7 @@ #include <sal/log.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <sfx2/strings.hrc> #include <helpids.h> @@ -220,7 +221,7 @@ void ContentTabPage_Impl::InitRoot() sal_Int32 nIdx = 0; OUString aTitle = aRow.getToken( 0, '\t', nIdx ); OUString aURL = aRow.getToken( 0, '\t', nIdx ); - sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0]; + sal_Unicode cFolder = o3tl::getToken(aRow, 0, '\t', nIdx )[0]; bool bIsFolder = ( '1' == cFolder ); OUString sId; if (bIsFolder) @@ -259,7 +260,7 @@ IMPL_LINK(ContentTabPage_Impl, ExpandingHdl, const weld::TreeIter&, rIter, bool) sal_Int32 nIdx = 0; OUString aTitle = aRow.getToken( 0, '\t', nIdx ); OUString aURL = aRow.getToken( 0, '\t', nIdx ); - sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0]; + sal_Unicode cFolder = o3tl::getToken(aRow, 0, '\t', nIdx )[0]; bool bIsFolder = ( '1' == cFolder ); if ( bIsFolder ) { @@ -940,7 +941,7 @@ SearchTabPage_Impl::SearchTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow while ( nIdx > 0 ) { m_xSearchED->append_text( INetURLObject::decode( - aUserData.getToken(0, ';', nIdx), + o3tl::getToken(aUserData, 0, ';', nIdx), INetURLObject::DecodeMechanism::WithCharset ) ); } } @@ -2328,7 +2329,7 @@ IMPL_LINK_NOARG(SfxHelpWindow_Impl, OpenHdl, LinkParamNone*, void) { sal_Int32 nIdx{ 0 }; aId = aEntry.getToken( 0, '#', nIdx ); - aAnchor += aEntry.getToken( 0, '#', nIdx ); + aAnchor += o3tl::getToken(aEntry, 0, '#', nIdx ); } else aId = aEntry; diff --git a/sfx2/source/bastyp/mieclip.cxx b/sfx2/source/bastyp/mieclip.cxx index 4d6d74e1fca0..3036b4eb488e 100644 --- a/sfx2/source/bastyp/mieclip.cxx +++ b/sfx2/source/bastyp/mieclip.cxx @@ -43,7 +43,7 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream ) rStream.ResetError(); if( rStream.ReadLine( sLine ) && - sLine.getToken( 0, ':', nIndex ) == "Version" ) + o3tl::getToken(sLine, 0, ':', nIndex ) == "Version" ) { while( rStream.ReadLine( sLine ) ) { diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx index ea1fa8fb218c..c789538dd4fd 100644 --- a/sfx2/source/doc/autoredactdialog.cxx +++ b/sfx2/source/doc/autoredactdialog.cxx @@ -18,6 +18,7 @@ #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <unotools/viewoptions.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> @@ -149,7 +150,7 @@ OUString TargetsTable::GetNameProposal() const RedactionTarget* pTarget = weld::fromId<RedactionTarget*>(m_xControl->get_id(i)); const OUString& sName = pTarget->sName; sal_Int32 nIndex = 0; - if (sName.getToken(0, ' ', nIndex) == sDefaultTargetName) + if (o3tl::getToken(sName, 0, ' ', nIndex) == sDefaultTargetName) { sal_Int32 nCurrTargetId = sName.getToken(0, ' ', nIndex).toInt32(); nHighestTargetId = std::max<sal_Int32>(nHighestTargetId, nCurrTargetId); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 33c5213d25b1..7d3e2cb8262b 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -27,6 +27,7 @@ #include <svtools/svparser.hxx> #include <cppuhelper/exc_hlp.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/awt/XTopWindow.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -1469,7 +1470,7 @@ void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue& rKV ) { sal_Int32 nIdx{ 0 }; const sal_Int32 nTime{ aValue.getToken( 0, ';', nIdx ).toInt32() }; - const OUString aURL{ comphelper::string::strip(aValue.getToken( 0, ';', nIdx ), ' ') }; + const OUString aURL{ comphelper::string::strip(o3tl::getToken(aValue, 0, ';', nIdx ), ' ') }; uno::Reference<document::XDocumentProperties> xDocProps( pDoc->getDocProperties()); if( aURL.startsWithIgnoreAsciiCase( "url=" ) ) diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 0b14c492ed23..6a6bbbf1162a 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -32,6 +32,7 @@ #include <svl/stritem.hxx> #include <sfx2/viewfrm.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <edit.hxx> #include <smmod.hxx> @@ -305,7 +306,7 @@ bool SmEditTextWindow::KeyInput(const KeyEvent& rKEvt) SmModule *pMod = SM_MOD(); if (pMod && !pMod->GetConfig()->IsAutoCloseBrackets()) autoClose = false; - else if (selected.trim() == "<?>") + else if (o3tl::trim(selected) == u"<?>") autoClose = true; else if (selected.isEmpty() && !aSelection.HasRange()) { diff --git a/starmath/source/mathml/mathmlimport.cxx b/starmath/source/mathml/mathmlimport.cxx index 6b96cd9a4ed1..f8c845e93dee 100644 --- a/starmath/source/mathml/mathmlimport.cxx +++ b/starmath/source/mathml/mathmlimport.cxx @@ -59,6 +59,7 @@ one go*/ #include <svx/dialmgr.hxx> #include <svx/strings.hrc> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <mathmlattr.hxx> #include <xparsmlbase.hxx> @@ -1520,7 +1521,7 @@ void SmXMLSpaceContext_Impl::startFastElement( switch (aIter.getToken()) { case XML_WIDTH: - if (!ParseMathMLAttributeLengthValue(sValue.trim(), aLV) + if (!ParseMathMLAttributeLengthValue(o3tl::trim(sValue), aLV) || !lcl_CountBlanks(aLV, &nWide, &nNarrow)) SAL_WARN("starmath", "ignore mspace's width: " << sValue); break; diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx index d14a4d2023b6..b096d80ba1f1 100644 --- a/starmath/source/ooxmlimport.cxx +++ b/starmath/source/ooxmlimport.cxx @@ -19,6 +19,7 @@ #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> using namespace oox::formulaimport; @@ -602,7 +603,7 @@ OUString SmOoxmlImport::handleR() { XmlStream::Tag rtag = m_rStream.ensureOpeningTag( M_TOKEN( t )); if( rtag.attribute( OOX_TOKEN( xml, space )) != "preserve" ) - text.append(rtag.text.trim()); + text.append(o3tl::trim(rtag.text)); else text.append(rtag.text); m_rStream.ensureClosingTag( M_TOKEN( t )); diff --git a/svx/source/gallery2/galini.cxx b/svx/source/gallery2/galini.cxx index 0d11f5c89577..d825fd1471d2 100644 --- a/svx/source/gallery2/galini.cxx +++ b/svx/source/gallery2/galini.cxx @@ -21,6 +21,7 @@ #include <i18nlangtag/languagetag.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <o3tl/string_view.hxx> #include <memory> OUString GalleryBinaryEngineEntry::ReadStrFromIni(std::u16string_view aKeyName ) const @@ -54,9 +55,9 @@ OUString GalleryBinaryEngineEntry::ReadStrFromIni(std::u16string_view aKeyName ) if( ( n = aLine.indexOf( '=' ) ) >= 1) { aKey = OStringToOUString( - aLine.copy( 0, n ).trim(), RTL_TEXTENCODING_ASCII_US ); + o3tl::trim(aLine.subView( 0, n )), RTL_TEXTENCODING_ASCII_US ); aValue = OStringToOUString( - aLine.copy( n + 1 ).trim(), RTL_TEXTENCODING_UTF8 ); + o3tl::trim(aLine.subView( n + 1 )), RTL_TEXTENCODING_UTF8 ); if( ( n = aKey.indexOf( '[' ) ) >= 1 ) { diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 652af8a188b9..32957daa832a 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -28,6 +28,7 @@ #ifndef UNX #include <unotools/transliterationwrapper.hxx> #endif +#include <o3tl/string_view.hxx> #include <doc.hxx> #include <IDocumentFieldsAccess.hxx> #include <IDocumentMarkAccess.hxx> @@ -583,7 +584,7 @@ void SwDoc::AddUsedDBToList( std::vector<OUString>& rDBNameList, const OUString& #ifdef UNX for( const auto &sName : rDBNameList ) - if( rDBName == sName.getToken(0, ';') ) + if( rDBName == o3tl::getToken(sName, 0, ';') ) return; #else const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 107d6f9afc95..8c82eaba9948 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -30,6 +30,7 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <unotools/datetime.hxx> #include <sfx2/viewsh.hxx> +#include <o3tl/string_view.hxx> #include <swmodule.hxx> #include <doc.hxx> #include <docredln.hxx> @@ -835,7 +836,7 @@ bool SwRedlineTable::isMoved( size_type rPos ) const // pair at tracked moving: same text by trimming trailing white spaces if ( abs(pPaM->GetText().getLength() - pPairPaM->GetText().getLength()) <= 2 && - sTrimmed == pPairPaM->GetText().trim() ) + sTrimmed == o3tl::trim(pPairPaM->GetText()) ) { pRedline->SetMoved(); pPair->SetMoved(); diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index eb8eff09c06d..12bfec75a4ff 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -755,7 +755,7 @@ const SwTable* SwTableFormula::FindTable( SwDoc& rDoc, std::u16string_view rNm ) SwFrameFormat* pFormat = rTableFormats[ --nFormatCnt ]; // if we are called from Sw3Writer, a number is dependent on the format name SwTableBox* pFBox; - if ( rNm == pFormat->GetName().getToken(0, 0x0a) && + if ( rNm == o3tl::getToken(pFormat->GetName(), 0, 0x0a) && nullptr != ( pTmpTable = SwTable::FindTable( pFormat ) ) && nullptr != (pFBox = pTmpTable->GetTabSortBoxes()[0] ) && pFBox->GetSttNd() && diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index e78a089caa35..7263997feb0a 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -32,6 +32,7 @@ #include <dbfld.hxx> #include <dbmgr.hxx> #include <unofldmid.h> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star; @@ -226,9 +227,9 @@ OUString SwDBField::GetFieldName() const if (sContent.getLength() > 1) { sContent += OUStringChar(DB_DELIM) - + rDBName.getToken(1, DB_DELIM) + + o3tl::getToken(rDBName, 1, DB_DELIM) + OUStringChar(DB_DELIM) - + rDBName.getToken(2, DB_DELIM); + + o3tl::getToken(rDBName, 2, DB_DELIM); } return lcl_DBSeparatorConvert(sContent); } diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 148a308497d2..292cfdb8ea89 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -62,6 +62,7 @@ #include <editeng/lrspitem.hxx> #include <comphelper/servicehelper.hxx> #include <comphelper/string.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; @@ -697,7 +698,7 @@ void SwXTextSection::Impl::SetPropertyValues_Impl( const OUString sFileName( sTmp + OUStringChar(sfx2::cTokenSeparator) + aLink.FilterName + OUStringChar(sfx2::cTokenSeparator) + - pSectionData->GetLinkFileName().getToken(2, sfx2::cTokenSeparator)); + o3tl::getToken(pSectionData->GetLinkFileName(), 2, sfx2::cTokenSeparator)); pSectionData->SetLinkFileName(sFileName); if (sFileName.getLength() < 3) { diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f42af8e003df..1e2d490e653c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2530,7 +2530,7 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag(); std::map<OUString, uno::Any>::const_iterator aStoredFormula = rGrabBag.find("CellFormulaConverted"); if ( aStoredFormula != rGrabBag.end() && sActualFormula.indexOf('=') == 0 && - sActualFormula.copy(1).trim() == aStoredFormula->second.get<OUString>().trim() ) + o3tl::trim(sActualFormula.subView(1)) == o3tl::trim(aStoredFormula->second.get<OUString>()) ) { aStoredFormula = rGrabBag.find("CellFormula"); if ( aStoredFormula != rGrabBag.end() ) diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index dac2745b2117..d038bac90953 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -78,6 +78,7 @@ #include <editeng/paperinf.hxx> #include <svx/xfillit0.hxx> #include <svx/xflgrit.hxx> +#include <o3tl/string_view.hxx> #include <fmtfld.hxx> #include <fchrfmt.hxx> #include <fmtfsize.hxx> @@ -3310,7 +3311,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::Table: { ww::eField eField = ww::eEquals; - OUString aExpand = " =" + pField->GetFieldName().trim(); + OUString aExpand = OUString::Concat(" =") + o3tl::trim(pField->GetFieldName()); GetExport().OutputField(pField, eField, aExpand); } break; diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx index ed7acab698c5..1727a1bbb758 100644 --- a/sw/source/ui/dbui/mmresultdialogs.cxx +++ b/sw/source/ui/dbui/mmresultdialogs.cxx @@ -1210,7 +1210,7 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, SendDocumentsHdl_Impl, weld::Button&, voi sAttachment += "."; sAttachment = comphelper::string::setToken(sAttachment, nTokenCount, '.', sExtension); } - else if (sAttachment.getToken( nTokenCount - 1, '.') != sExtension) + else if (o3tl::getToken(sAttachment, nTokenCount - 1, '.') != sExtension) sAttachment += sExtension; aDesc.sAttachmentName = sAttachment; aDesc.sMimeType = sMimeType; diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index 68182fa018d5..a06a060f2edc 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -35,6 +35,7 @@ #include <editeng/sizeitem.hxx> #include <svtools/htmlcfg.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <uitool.hxx> #include <IMark.hxx> @@ -220,7 +221,7 @@ void SectRepr::SetFile( std::u16string_view rFile ) { sNewFile += OUStringChar(sfx2::cTokenSeparator); if( !rFile.empty() ) // Filter only with FileName - sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator ); + sNewFile += o3tl::getToken(sOldFileName, 1, sfx2::cTokenSeparator ); sNewFile += OUStringChar(sfx2::cTokenSeparator) + sSub; } @@ -297,7 +298,7 @@ OUString SectRepr::GetFile() const return sLinkFile.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n ) .replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &n ); } - return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ), + return INetURLObject::decode( o3tl::getToken(sLinkFile, 0, sfx2::cTokenSeparator ), INetURLObject::DecodeMechanism::Unambiguous ); } diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 6c2d324b63d8..4c2e769ac889 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -3508,7 +3508,7 @@ IMPL_LINK_NOARG(SwTOXStylesTabPage, AssignHdl, weld::Button&, void) if (nLevPos == -1 || nTemplPos == -1) return; - const OUString aStr(m_xLevelLB->get_text(nLevPos).getToken(0, aDeliStart) + const OUString aStr(o3tl::getToken(m_xLevelLB->get_text(nLevPos), 0, aDeliStart) + OUStringChar(aDeliStart) + m_xParaLayLB->get_selected_text() + OUStringChar(aDeliEnd)); diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 3ddd08d14b6d..257e9c4a052f 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -22,6 +22,7 @@ #include <svl/stritem.hxx> #include <unotools/viewoptions.hxx> #include <vcl/weld.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/text/XBookmarksSupplier.hpp> #include <officecfg/Office/Common.hxx> @@ -501,7 +502,7 @@ OUString BookmarkTable::GetNameProposal() const sw::mark::IMark* pBookmark = weld::fromId<sw::mark::IMark*>(m_xControl->get_id(i)); const OUString& sName = pBookmark->GetName(); sal_Int32 nIndex = 0; - if (sName.getToken(0, ' ', nIndex) == sDefaultBookmarkName) + if (o3tl::getToken(sName, 0, ' ', nIndex) == sDefaultBookmarkName) { sal_Int32 nCurrBookmarkId = sName.getToken(0, ' ', nIndex).toInt32(); nHighestBookmarkId = std::max<sal_Int32>(nHighestBookmarkId, nCurrBookmarkId); diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx index 74e81a87f9e1..76ab41f80bb4 100644 --- a/sw/source/ui/misc/glosbib.cxx +++ b/sw/source/ui/misc/glosbib.cxx @@ -24,6 +24,7 @@ #include <unotools/tempfile.hxx> #include <unotools/pathoptions.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <swtypes.hxx> #include <glosbib.hxx> @@ -151,7 +152,7 @@ void SwGlossaryGroupDlg::Apply() } } const OUString sMsg(SwResId(STR_QUERY_DELETE_GROUP1) - + removedStr.getToken(0, '\t', nIdx) + + o3tl::getToken(removedStr, 0, '\t', nIdx) + SwResId(STR_QUERY_DELETE_GROUP2)); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_pParent, @@ -265,7 +266,7 @@ IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, weld::Button&, rButton, void ) if(bDelete) { it = std::find_if(m_RenamedArr.begin(), m_RenamedArr.end(), - [&sEntry](OUString& s) { return s.getToken(0, RENAME_TOKEN_DELIM) == sEntry; }); + [&sEntry](OUString& s) { return o3tl::getToken(s, 0, RENAME_TOKEN_DELIM) == sEntry; }); if (it != m_RenamedArr.end()) { m_RenamedArr.erase(it); diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index c92b3fe80be8..216d4a137b13 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -24,6 +24,7 @@ #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> #include <unotools/transliterationwrapper.hxx> +#include <o3tl/string_view.hxx> #include <docsh.hxx> #include <wrtsh.hxx> #include <view.hxx> @@ -119,7 +120,7 @@ void SwGlossaryHdl::SetCurGroup(const OUString &rGrp, bool bApi, bool bAlwaysCre const OUString sPath = sGroup.getToken(1, GLOS_DELIM); sal_uInt16 nComparePath = o3tl::narrowing<sal_uInt16>(sPath.toInt32()); if(nCurrentPath == nComparePath && - sGroup.getToken(0, GLOS_DELIM) == sCurBase) + o3tl::getToken(sGroup, 0, GLOS_DELIM) == sCurBase) bPathEqual = true; } diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 8ae7f1c964aa..3e77f22ff042 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1497,7 +1497,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0; if ( nRows == 1 ) { - const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t'); + const sal_Int32 nCols = comphelper::string::getTokenCount(o3tl::getToken(aExpand, 0, '\n'), '\t'); if (nCols == 1) bSingleCellTable = true; } @@ -2668,7 +2668,7 @@ bool SwTransferable::PasteDDE( const TransferableDataHelper& rData, sal_Int32 nRows = nNewlines ? nNewlines-1 : 0; if (!aExpand.endsWith("\n")) ++nRows; // last row has no newline, e.g. one single cell - const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t'); + const sal_Int32 nCols = comphelper::string::getTokenCount(o3tl::getToken(aExpand, 0, '\n'), '\t'); // don't try to insert tables that are too large for writer if (nRows > SAL_MAX_UINT16 || nCols > SAL_MAX_UINT16) diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx index e5f29f1d4aa7..991ff73d91a1 100644 --- a/sw/source/uibase/misc/glosdoc.cxx +++ b/sw/source/uibase/misc/glosdoc.cxx @@ -32,6 +32,7 @@ #include <svl/fstathelper.hxx> #include <unotools/pathoptions.hxx> #include <unotools/tempfile.hxx> +#include <o3tl/string_view.hxx> #include <swtypes.hxx> #include <glosdoc.hxx> #include <shellio.hxx> @@ -109,7 +110,7 @@ bool SwGlossaries::FindGroupName(OUString& rGroup) for(size_t i = 0; i < nCount; ++i) { const OUString sTemp(GetGroupName(i)); - if (rGroup==sTemp.getToken(0, GLOS_DELIM)) + if (rGroup == o3tl::getToken(sTemp, 0, GLOS_DELIM)) { rGroup = sTemp; return true; @@ -200,7 +201,7 @@ bool SwGlossaries::RenameGroupDoc( return false; const OUString sOldFileURL = - lcl_FullPathName(m_PathArr[nOldPath], rOldGroup.getToken(0, GLOS_DELIM)); + lcl_FullPathName(m_PathArr[nOldPath], o3tl::getToken(rOldGroup, 0, GLOS_DELIM)); if (!FStatHelper::IsDocument( sOldFileURL )) { @@ -274,7 +275,7 @@ std::unique_ptr<SwTextBlocks> SwGlossaries::GetGlosDoc( const OUString &rName, b if (static_cast<size_t>(nPath) < m_PathArr.size()) { const OUString sFileURL = - lcl_FullPathName(m_PathArr[nPath], rName.getToken(0, GLOS_DELIM)); + lcl_FullPathName(m_PathArr[nPath], o3tl::getToken(rName, 0, GLOS_DELIM)); bool bExist = false; if(!bCreate) @@ -490,7 +491,7 @@ OUString SwGlossaries::GetCompleteGroupName( const OUString& rGroupName ) } else { - if (sGroupName == sGrpName.getToken(0, GLOS_DELIM)) + if (sGroupName == o3tl::getToken(sGrpName, 0, GLOS_DELIM)) return sGrpName; } } diff --git a/sw/source/uibase/utlui/gloslst.cxx b/sw/source/uibase/utlui/gloslst.cxx index a1a68a9771d9..55e202186aa0 100644 --- a/sw/source/uibase/utlui/gloslst.cxx +++ b/sw/source/uibase/utlui/gloslst.cxx @@ -22,6 +22,7 @@ #include <unotools/pathoptions.hxx> #include <unotools/transliterationwrapper.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <swtypes.hxx> #include <swmodule.hxx> #include <shellio.hxx> @@ -259,7 +260,7 @@ void SwGlossaryList::Update() FillGroup(pGroup.get(), pGlossaries); OUString sName = rPathArr[nPath] + "/" + - pGroup->sName.getToken(0, GLOS_DELIM) + sExt; + o3tl::getToken(pGroup->sName, 0, GLOS_DELIM) + sExt; FStatHelper::GetModifiedDateTimeOfFile( sName, &pGroup->aDateModified, &pGroup->aDateModified ); diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx index e53580e6a746..e9d47e1db0c2 100644 --- a/sw/source/uibase/wrtsh/wrtsh2.cxx +++ b/sw/source/uibase/wrtsh/wrtsh2.cxx @@ -28,6 +28,7 @@ #include <sfx2/viewfrm.hxx> #include <sot/exchange.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <fmtinfmt.hxx> #include <wrtsh.hxx> #include <docsh.hxx> @@ -596,10 +597,10 @@ void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk, else { SwSectionData aSection( SectionType::FileLink, GetUniqueSectionName() ); - OUString aLinkFile = rBkmk.GetURL().getToken(0, '#') + OUString aLinkFile = o3tl::getToken(rBkmk.GetURL(), 0, '#') + OUStringChar(sfx2::cTokenSeparator) + OUStringChar(sfx2::cTokenSeparator) - + rBkmk.GetURL().getToken(1, '#'); + + o3tl::getToken(rBkmk.GetURL(), 1, '#'); aSection.SetLinkFileName( aLinkFile ); aSection.SetProtectFlag( true ); const SwSection* pIns = InsertSection( aSection ); diff --git a/test/source/helper/transferable.cxx b/test/source/helper/transferable.cxx index e8990d925d18..201b3c50e442 100644 --- a/test/source/helper/transferable.cxx +++ b/test/source/helper/transferable.cxx @@ -9,6 +9,7 @@ #include <test/helper/transferable.hxx> #include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp> +#include <o3tl/string_view.hxx> using namespace css; @@ -23,9 +24,9 @@ OString OOO_DLLPUBLIC_TEST getTextSelection( // Take care of UTF-8 text here. bool bConvert = false; sal_Int32 nIndex = 0; - if (mimeType.getToken(0, ';', nIndex) == "text/plain") + if (o3tl::getToken(mimeType, 0, ';', nIndex) == "text/plain") { - if (mimeType.getToken(0, ';', nIndex) == "charset=utf-8") + if (o3tl::getToken(mimeType, 0, ';', nIndex) == "charset=utf-8") { mimeType = "text/plain;charset=utf-16"; bConvert = true; diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx index 448850fb84fc..b26d2a5015bc 100644 --- a/unotools/source/config/useroptions.cxx +++ b/unotools/source/config/useroptions.cxx @@ -38,6 +38,7 @@ #include <i18nlangtag/mslangid.hxx> #include <i18nlangtag/languagetag.hxx> #include <o3tl/enumarray.hxx> +#include <o3tl/string_view.hxx> #include <tools/diagnose_ex.h> using namespace utl; @@ -218,7 +219,7 @@ OUString SvtUserOptions::Impl::GetFullName () const sFullName = GetToken(UserOptToken::FirstName).trim(); if (!sFullName.isEmpty()) sFullName += " "; - sFullName += GetToken(UserOptToken::FathersName).trim(); + sFullName += o3tl::trim(GetToken(UserOptToken::FathersName)); if (!sFullName.isEmpty()) sFullName += " "; sFullName += GetToken(UserOptToken::LastName); diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 0ebf70becdb3..42d9e15668e3 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -42,6 +42,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <unotools/streamwrap.hxx> #include <rtl/math.hxx> +#include <o3tl/string_view.hxx> #include <vcl/filter/PDFiumLibrary.hxx> #include <comphelper/propertyvalue.hxx> @@ -1679,7 +1680,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115967) if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Text) continue; OUString sChar = pPageObject->getText(pTextPage); - sText += sChar.trim(); + sText += o3tl::trim(sChar); } CPPUNIT_ASSERT_EQUAL(OUString("m=750abc"), sText); } diff --git a/vcl/qt5/QtTransferable.cxx b/vcl/qt5/QtTransferable.cxx index ed31a54d769e..51178038dad2 100644 --- a/vcl/qt5/QtTransferable.cxx +++ b/vcl/qt5/QtTransferable.cxx @@ -12,6 +12,7 @@ #include <comphelper/sequence.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <QtWidgets/QApplication> @@ -24,7 +25,7 @@ static bool lcl_textMimeInfo(const OUString& rMimeString, bool& bHaveNoCharset, bool& bHaveUTF8) { sal_Int32 nIndex = 0; - if (rMimeString.getToken(0, ';', nIndex) == "text/plain") + if (o3tl::getToken(rMimeString, 0, ';', nIndex) == u"text/plain") { OUString aToken(rMimeString.getToken(0, ';', nIndex)); if (aToken == "charset=utf-16") diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 88b50c50c203..d7c3d31e50d5 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/awt/XWindowPeer.hpp> #include <o3tl/safeint.hxx> #include <o3tl/sorted_vector.hxx> +#include <o3tl/string_view.hxx> #include <officecfg/Office/Common.hxx> #include <salframe.hxx> #include <salinst.hxx> @@ -3493,7 +3494,7 @@ int SalInstanceTreeView::to_external_model(int col) const bool SalInstanceTreeView::IsDummyEntry(SvTreeListEntry* pEntry) const { - return m_xTreeView->GetEntryText(pEntry).trim() == "<dummy>"; + return o3tl::trim(m_xTreeView->GetEntryText(pEntry)) == u"<dummy>"; } SvTreeListEntry* SalInstanceTreeView::GetPlaceHolderChild(SvTreeListEntry* pEntry) const diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 1f728ce03ab4..44d7fc5f5b8a 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -34,6 +34,7 @@ #include <listbox.hxx> #include <comphelper/lok.hxx> #include <tools/json_writer.hxx> +#include <o3tl/string_view.hxx> namespace { @@ -94,14 +95,14 @@ struct ComboBox::Impl }; -static void lcl_GetSelectedEntries( ::std::set< sal_Int32 >& rSelectedPos, const OUString& rText, sal_Unicode cTokenSep, const ImplEntryList& rEntryList ) +static void lcl_GetSelectedEntries( ::std::set< sal_Int32 >& rSelectedPos, std::u16string_view rText, sal_Unicode cTokenSep, const ImplEntryList& rEntryList ) { - if (rText.isEmpty()) + if (rText.empty()) return; sal_Int32 nIdx{0}; do { - const sal_Int32 nPos = rEntryList.FindEntry(comphelper::string::strip(rText.getToken(0, cTokenSep, nIdx), ' ')); + const sal_Int32 nPos = rEntryList.FindEntry(comphelper::string::strip(o3tl::getToken(rText, 0, cTokenSep, nIdx), ' ')); if ( nPos != LISTBOX_ENTRY_NOTFOUND ) rSelectedPos.insert( nPos ); } while (nIdx>=0); diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index e0ef1342e619..466a8d4c8760 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -127,7 +127,7 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadMemory( const OUS uno::Reference< ::graphic::XGraphic > xRet; sal_Int32 nIndex = 0; - if( rResourceURL.getToken( 0, '/', nIndex ) == "private:memorygraphic" ) + if( o3tl::getToken(rResourceURL, 0, '/', nIndex ) == u"private:memorygraphic" ) { sal_Int64 nGraphicAddress = rResourceURL.getToken( 0, '/', nIndex ).toInt64(); diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx index a54514eb4b2e..4c2e63c57cae 100644 --- a/vcl/source/image/ImplImageTree.cxx +++ b/vcl/source/image/ImplImageTree.cxx @@ -56,6 +56,7 @@ #include <vcl/pngwrite.hxx> #include <bitmap/BitmapLightenFilter.hxx> +#include <o3tl/string_view.hxx> using namespace css; @@ -593,8 +594,8 @@ void ImplImageTree::parseLinkFile(std::shared_ptr<SvStream> const & xStream) continue; sal_Int32 nIndex = 0; - aLink = OStringToOUString(aLine.getToken(0, ' ', nIndex), RTL_TEXTENCODING_UTF8); - aOriginal = OStringToOUString(aLine.getToken(0, ' ', nIndex), RTL_TEXTENCODING_UTF8); + aLink = OStringToOUString(o3tl::getToken(aLine, 0, ' ', nIndex), RTL_TEXTENCODING_UTF8); + aOriginal = OStringToOUString(o3tl::getToken(aLine, 0, ' ', nIndex), RTL_TEXTENCODING_UTF8); // skip comments, or incomplete entries if (aLink.isEmpty() || aLink[0] == '#' || aOriginal.isEmpty()) diff --git a/vcl/source/opengl/x11/context.cxx b/vcl/source/opengl/x11/context.cxx index f8a3118e03f4..97822b3105a5 100644 --- a/vcl/source/opengl/x11/context.cxx +++ b/vcl/source/opengl/x11/context.cxx @@ -25,6 +25,7 @@ #include <vcl/opengl/OpenGLContext.hxx> #include <vcl/opengl/OpenGLHelper.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> static std::vector<GLXContext> g_vShareList; static bool g_bAnyCurrent; @@ -492,7 +493,7 @@ GLX11Window::GLX11Window() bool GLX11Window::HasGLXExtension( const char* name ) const { for (sal_Int32 i = 0; i != -1;) { - if (GLXExtensions.getToken(0, ' ', i) == name) { + if (o3tl::getToken(GLXExtensions, 0, ' ', i) == name) { return true; } } diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index 1c6ec92f1b87..4370f01901ca 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -45,6 +45,7 @@ #include "bmp.hxx" #include <vcl/svapp.hxx> +#include <o3tl/string_view.hxx> // pointer bitmaps #include "copydata_curs.h" @@ -170,7 +171,7 @@ rtl_TextEncoding x11::getTextPlainEncoding( const OUString& rMimeType ) rtl_TextEncoding aEncoding = RTL_TEXTENCODING_DONTKNOW; OUString aMimeType( rMimeType.toAsciiLowerCase() ); sal_Int32 nIndex = 0; - if( aMimeType.getToken( 0, ';', nIndex ) == "text/plain" ) + if( o3tl::getToken(aMimeType, 0, ';', nIndex ) == u"text/plain" ) { if( aMimeType.getLength() == 10 ) // only "text/plain" aEncoding = RTL_TEXTENCODING_ISO_8859_1; @@ -180,9 +181,9 @@ rtl_TextEncoding x11::getTextPlainEncoding( const OUString& rMimeType ) { OUString aToken = aMimeType.getToken( 0, ';', nIndex ); sal_Int32 nPos = 0; - if( aToken.getToken( 0, '=', nPos ) == "charset" ) + if( o3tl::getToken(aToken, 0, '=', nPos ) == u"charset" ) { - OString aEncToken = OUStringToOString( aToken.getToken( 0, '=', nPos ), RTL_TEXTENCODING_ISO_8859_1 ); + OString aEncToken = OUStringToOString( o3tl::getToken(aToken, 0, '=', nPos ), RTL_TEXTENCODING_ISO_8859_1 ); aEncoding = rtl_getTextEncodingFromUnixCharset( aEncToken.getStr() ); if( aEncoding == RTL_TEXTENCODING_DONTKNOW ) { @@ -606,9 +607,9 @@ bool SelectionManager::convertData( aFlavor.MimeType = convertTypeFromNative( nType, nSelection, rFormat ); sal_Int32 nIndex = 0; - if( aFlavor.MimeType.getToken( 0, ';', nIndex ) == "text/plain" ) + if( o3tl::getToken(aFlavor.MimeType, 0, ';', nIndex ) == u"text/plain" ) { - if( aFlavor.MimeType.getToken( 0, ';', nIndex ) == "charset=utf-16" ) + if( o3tl::getToken(aFlavor.MimeType, 0, ';', nIndex ) == u"charset=utf-16" ) aFlavor.DataType = cppu::UnoType<OUString>::get(); else aFlavor.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); @@ -1322,7 +1323,7 @@ bool SelectionManager::getPasteDataTypes( Atom selection, Sequence< DataFlavor > pFlavors->MimeType = convertTypeFromNative( *pAtoms, selection, nFormat ); pFlavors->DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); sal_Int32 nIndex = 0; - if( pFlavors->MimeType.getToken( 0, ';', nIndex ) == "text/plain" ) + if( o3tl::getToken(pFlavors->MimeType, 0, ';', nIndex ) == u"text/plain" ) { OUString aToken(pFlavors->MimeType.getToken( 0, ';', nIndex )); // omit text/plain;charset=unicode since it is not well defined diff --git a/vcl/unx/gtk3/a11y/atktextattributes.cxx b/vcl/unx/gtk3/a11y/atktextattributes.cxx index f73d79aefe3f..c127333caf43 100644 --- a/vcl/unx/gtk3/a11y/atktextattributes.cxx +++ b/vcl/unx/gtk3/a11y/atktextattributes.cxx @@ -38,6 +38,7 @@ #include <i18nlangtag/languagetag.hxx> #include <tools/UnitConversion.hxx> +#include <o3tl/string_view.hxx> #include <stdio.h> #include <string.h> @@ -1230,9 +1231,9 @@ attribute_set_new_from_extended_attributes( OUString sProperty = sExtendedAttrs.getToken( 0, ';', nIndex ); sal_Int32 nColonPos = 0; - OString sPropertyName = OUStringToOString( sProperty.getToken( 0, ':', nColonPos ), + OString sPropertyName = OUStringToOString( o3tl::getToken(sProperty, 0, ':', nColonPos ), RTL_TEXTENCODING_UTF8 ); - OString sPropertyValue = OUStringToOString( sProperty.getToken( 0, ':', nColonPos ), + OString sPropertyValue = OUStringToOString( o3tl::getToken(sProperty, 0, ':', nColonPos ), RTL_TEXTENCODING_UTF8 ); pSet = attribute_set_prepend( pSet, diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx index dc5d1a381827..f83e861e9706 100644 --- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx @@ -47,6 +47,7 @@ #include <tools/urlobj.hxx> #include <unotools/ucbhelper.hxx> +#include <o3tl/string_view.hxx> #include <algorithm> #include <set> @@ -1942,7 +1943,7 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O { g_warning( "Duff filter token '%s'\n", OUStringToOString( - rType.getToken( 0, ';', nIndex ), RTL_TEXTENCODING_UTF8 ).getStr() ); + o3tl::getToken(rType, 0, ';', nIndex ), RTL_TEXTENCODING_UTF8 ).getStr() ); } #endif } diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index ff024e662037..6941df209dae 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -71,6 +71,7 @@ #include <officecfg/Office/Common.hxx> #include <rtl/bootstrap.hxx> #include <o3tl/unreachable.hxx> +#include <o3tl/string_view.hxx> #include <svl/zforlist.hxx> #include <svl/zformat.hxx> #include <tools/helpers.hxx> @@ -674,7 +675,7 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo aFlavor.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); sal_Int32 nIndex(0); - if (aFlavor.MimeType.getToken(0, ';', nIndex) == "text/plain") + if (o3tl::getToken(aFlavor.MimeType, 0, ';', nIndex) == u"text/plain") { bHaveText = true; OUString aToken(aFlavor.MimeType.getToken(0, ';', nIndex)); @@ -1417,7 +1418,7 @@ std::vector<GtkTargetEntry> VclToGtkHelper::FormatsToGtk(const css::uno::Sequenc for (const css::datatransfer::DataFlavor& rFlavor : rFormats) { sal_Int32 nIndex(0); - if (rFlavor.MimeType.getToken(0, ';', nIndex) == "text/plain") + if (o3tl::getToken(rFlavor.MimeType, 0, ';', nIndex) == u"text/plain") { bHaveText = true; OUString aToken(rFlavor.MimeType.getToken(0, ';', nIndex)); diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index c1769607605a..15e70733dda5 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -29,6 +29,7 @@ #include <unotools/mediadescriptor.hxx> #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; @@ -150,7 +151,7 @@ OUString EPUBExportTest::getCss(std::map<OUString, std::vector<OUString>>& rCss, OUString aKeyValue = rKeyValue.trim(); std::vector<OUString> aTokens = comphelper::string::split(aKeyValue, ':'); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aTokens.size()); - if (aTokens[0].trim() == rKey) + if (o3tl::trim(aTokens[0]) == rKey) { aRet = aTokens[1].trim(); if (aRet.endsWith(";")) diff --git a/xmloff/source/style/PageMasterPropHdl.cxx b/xmloff/source/style/PageMasterPropHdl.cxx index e1a67e6a322e..c1fb9010b70f 100644 --- a/xmloff/source/style/PageMasterPropHdl.cxx +++ b/xmloff/source/style/PageMasterPropHdl.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/style/NumberingType.hpp> #include <comphelper/types.hxx> #include <comphelper/extract.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -287,7 +288,7 @@ bool XMLPMPropHdl_Print::importXML( do { - bFound = (sAttrValue == rStrImpValue.getToken( 0, ' ', nTokenIndex )); + bFound = (sAttrValue == o3tl::getToken(rStrImpValue, 0, ' ', nTokenIndex )); } while ( (nTokenIndex >= 0) && !bFound );