summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-10 20:17:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-11 14:45:38 +0200
commit85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 (patch)
treef7d7f6fce51d1a4443608971da7d9c42b1201fa3 /sc/source/ui/dbgui
parent117688bd3f51a7a50b2620aa7dcc0c065f29d402 (diff)
loplugin:stringview add check for getToken().toInt32
where we can convert that to o3tl::toInt32(o3tl::getToken( and avoid the heap allocation of a temporary string Change-Id: Ib11c19c6e6cdc0de3e551affd3578d181e292de4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132810 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r--sc/source/ui/dbgui/asciiopt.cxx10
-rw-r--r--sc/source/ui/dbgui/csvruler.cxx3
-rw-r--r--sc/source/ui/dbgui/imoptdlg.cxx4
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx5
-rw-r--r--sc/source/ui/dbgui/scuiimoptdlg.cxx4
5 files changed, 14 insertions, 12 deletions
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
index e73e71b76e97..4a2689242465 100644
--- a/sc/source/ui/dbgui/asciiopt.cxx
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -102,7 +102,7 @@ void ScAsciiOptions::ReadFromString( const OUString& rString )
// Token 1: Text separator.
if ( nPos >= 0 )
{
- const sal_Int32 nVal = rString.getToken(0, ',', nPos).toInt32();
+ const sal_Int32 nVal = o3tl::toInt32(o3tl::getToken(rString, 0, ',', nPos));
cTextSep = static_cast<sal_Unicode>(nVal);
}
@@ -115,7 +115,7 @@ void ScAsciiOptions::ReadFromString( const OUString& rString )
// Token 3: Number of start row.
if ( nPos >= 0 )
{
- nStartRow = rString.getToken(0, ',', nPos).toInt32();
+ nStartRow = o3tl::toInt32(o3tl::getToken(rString, 0, ',', nPos));
}
// Token 4: Column info.
@@ -128,15 +128,15 @@ void ScAsciiOptions::ReadFromString( const OUString& rString )
sal_Int32 nP = 0;
for (sal_Int32 nInfo=0; nInfo<nInfoCount; ++nInfo)
{
- mvColStart[nInfo] = aToken.getToken(0, '/', nP).toInt32();
- mvColFormat[nInfo] = static_cast<sal_uInt8>(aToken.getToken(0, '/', nP).toInt32());
+ mvColStart[nInfo] = o3tl::toInt32(o3tl::getToken(aToken, 0, '/', nP));
+ mvColFormat[nInfo] = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(aToken, 0, '/', nP)));
}
}
// Token 5: Language.
if (nPos >= 0)
{
- eLang = static_cast<LanguageType>(rString.getToken(0, ',', nPos).toInt32());
+ eLang = static_cast<LanguageType>(o3tl::toInt32(o3tl::getToken(rString, 0, ',', nPos)));
}
// Token 6: Import quoted field as text.
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
index 9935cf795d30..3af7645e2431 100644
--- a/sc/source/ui/dbgui/csvruler.cxx
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -28,6 +28,7 @@
#include <vcl/ptrstyle.hxx>
#include <vcl/svapp.hxx>
#include <vcl/virdev.hxx>
+#include <o3tl/string_view.hxx>
using namespace com::sun::star::uno;
@@ -55,7 +56,7 @@ static void load_FixedWidthList(ScCsvSplits &rSplits)
sal_Int32 nIdx {0};
for(;;)
{
- const sal_Int32 n {sFixedWidthLists.getToken(0, ';', nIdx).toInt32()};
+ const sal_Int32 n = o3tl::toInt32(o3tl::getToken(sFixedWidthLists, 0, ';', nIdx));
if (nIdx<0)
{
// String ends with a semi-colon so there
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
index 3acb3cd00e36..3fbbf8f8355c 100644
--- a/sc/source/ui/dbgui/imoptdlg.cxx
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -58,14 +58,14 @@ ScImportOptions::ScImportOptions( const OUString& rStr )
bFixedWidth = true;
else
nFieldSepCode = ScAsciiOptions::GetWeightedFieldSep( aToken, true);
- nTextSepCode = static_cast<sal_Unicode>(rStr.getToken(0, ',', nIdx).toInt32());
+ nTextSepCode = static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(rStr, 0, ',', nIdx)));
aStrFont = rStr.getToken(0, ',', nIdx);
eCharSet = ScGlobal::GetCharsetValue(aStrFont);
if ( nTokenCount == 4 )
{
// compatibility with old options string: "Save as shown" as 4th token, numeric
- bSaveAsShown = rStr.getToken(0, ',', nIdx).toInt32() != 0;
+ bSaveAsShown = o3tl::toInt32(o3tl::getToken(rStr, 0, ',', nIdx)) != 0;
bQuoteAllText = true; // use old default then
}
else
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index d0af7db301a4..b3ddd1aba250 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -38,6 +38,7 @@
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
#include <comphelper/lok.hxx>
+#include <o3tl/string_view.hxx>
#include <unicode/ucsdet.h>
@@ -119,7 +120,7 @@ static void lcl_FillCombo(weld::ComboBox& rCombo, const OUString& rList, sal_Uni
{
const OUString sEntry {rList.getToken(0, '\t', nIdx)};
rCombo.append_text(sEntry);
- if (nIdx>0 && static_cast<sal_Unicode>(rList.getToken(0, '\t', nIdx).toInt32()) == cSelect)
+ if (nIdx>0 && static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(rList, 0, '\t', nIdx))) == cSelect)
aStr = sEntry;
}
while (nIdx>0);
@@ -147,7 +148,7 @@ static sal_Unicode lcl_CharFromCombo(const weld::ComboBox& rCombo, const OUStrin
if ( ScGlobal::GetTransliteration().isEqual( aStr, sToken ) )
{
sal_Int32 nTmpIdx {nIdx};
- c = static_cast<sal_Unicode>(rList.getToken(0, '\t', nTmpIdx).toInt32());
+ c = static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(rList, 0, '\t', nTmpIdx)));
}
// Skip to next token at even position
sToken = rList.getToken(1, '\t', nIdx);
diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx
index 242fd50be66e..e04f0b672939 100644
--- a/sc/source/ui/dbgui/scuiimoptdlg.cxx
+++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx
@@ -63,7 +63,7 @@ sal_uInt16 ScDelimiterTable::GetCode( std::u16string_view rDel ) const
while (nIdx>0 && rDel != o3tl::getToken(theDelTab, 1, cSep, nIdx ));
if (nIdx>0)
- return static_cast<sal_Unicode>(theDelTab.getToken( 0, cSep, nIdx ).toInt32());
+ return static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(theDelTab, 0, cSep, nIdx )));
}
return 0;
@@ -78,7 +78,7 @@ OUString ScDelimiterTable::GetDelimiter( sal_Unicode nCode ) const
do
{
sal_Int32 nPrevIdx {nIdx};
- if (nCode == static_cast<sal_Unicode>(theDelTab.getToken( 1, cSep, nIdx ).toInt32()))
+ if (nCode == static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(theDelTab, 1, cSep, nIdx ))))
return theDelTab.getToken( 0, cSep, nPrevIdx );
}
while (nIdx>0);