diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-09 09:55:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-10 12:59:38 +0200 |
commit | e4ff847fe0796420ba8023b70cad8589f5f19e9f (patch) | |
tree | 136786200de69f70dde4190c9725f35fe14b33e0 /sc | |
parent | 5a89496ffcfcd561b3e595e01f35e0302fa00841 (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/documen4.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/html/htmlpars.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/pagesettings.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/dbgui/asciiopt.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/dbgui/dbnamdlg.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/dbgui/imoptdlg.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/dbgui/scuiimoptdlg.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh8.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/crnrdlg.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/scuiautofmt.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpusrlst.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 3 |
15 files changed, 49 insertions, 35 deletions
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() |