diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-10 20:17:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-11 14:45:38 +0200 |
commit | 85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 (patch) | |
tree | f7d7f6fce51d1a4443608971da7d9c42b1201fa3 /sw/source | |
parent | 117688bd3f51a7a50b2620aa7dcc0c065f29d402 (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 'sw/source')
-rw-r--r-- | sw/source/core/doc/docfld.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddb.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddinf.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddok.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldfunc.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldpage.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldref.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/index/swuiidxmrk.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/misc/bookmark.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/misc/glosbib.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/misc/glossary.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/fldui/fldmgr.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/misc/glosdoc.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 23 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view2.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/utlui/gloslst.cxx | 4 |
21 files changed, 54 insertions, 42 deletions
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 32957daa832a..9442f4973057 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -614,7 +614,7 @@ void SwDoc::ChangeDBFields( const std::vector<OUString>& rOldNames, sal_Int32 nIdx{ 0 }; aNewDBData.sDataSource = rNewName.getToken(0, DB_DELIM, nIdx); aNewDBData.sCommand = rNewName.getToken(0, DB_DELIM, nIdx); - aNewDBData.nCommandType = rNewName.getToken(0, DB_DELIM, nIdx).toInt32(); + aNewDBData.nCommandType = o3tl::toInt32(o3tl::getToken(rNewName, 0, DB_DELIM, nIdx)); SwSectionFormats& rArr = GetSections(); for (auto n = rArr.size(); n; ) diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 90e9626c9805..8d69ef74faa9 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -90,6 +90,7 @@ #include <fntcache.hxx> #include <frameformats.hxx> #include <o3tl/numeric.hxx> +#include <o3tl/string_view.hxx> #include <svl/numformat.hxx> #include <tools/datetimeutils.hxx> #include <sal/log.hxx> @@ -3913,7 +3914,7 @@ OUString SwDoc::GetUniqueTableName() const { // Get number and set the Flag const sal_Int32 nNmLen = aName.getLength(); - size_t nNum = pFormat->GetName().copy( nNmLen ).toInt32(); + size_t nNum = o3tl::toInt32(pFormat->GetName().subView( nNmLen )); if( nNum-- && nNum < mpTableFrameFormatTable->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index cd5d0e128864..4341e2f7e3c8 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -30,6 +30,7 @@ #include <editeng/fontitem.hxx> #include <editeng/langitem.hxx> #include <editeng/acorrcfg.hxx> +#include <o3tl/string_view.hxx> #include <swwait.hxx> #include <fmtpdsc.hxx> @@ -1620,7 +1621,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) { SwNumFormat aFormat( aRule.Get( nLvl ) ); aFormat.SetPrefix( aPrefix.getToken( 0, u'\x0001', nPrefixIdx )); - aFormat.SetStart( o3tl::narrowing<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32())); + aFormat.SetStart( o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(aPrefix, 0, u'\x0001', nPrefixIdx )))); aFormat.SetSuffix( aPostfix.getToken( 0, u'\x0001' )); aFormat.SetIncludeUpperLevels( 0 ); @@ -1645,7 +1646,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) if( !n ) aFormat.SetPrefix( aPrefix.getToken( 0, u'\x0001', nPrefixIdx )); // token 0, read only on first loop - aFormat.SetStart( o3tl::narrowing<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32() )); + aFormat.SetStart( o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(aPrefix, 0, u'\x0001', nPrefixIdx )) )); aFormat.SetSuffix( aPostfix.getToken( 0, u'\x0001', nPostfixIdx )); aFormat.SetIncludeUpperLevels( MAXLEVEL ); if( n < aNumTypes.getLength() ) diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 661a0d549691..cecad8f6d370 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2922,12 +2922,12 @@ static void lcl_toxMatchTSwitch(SwWW8ImplReader const & rReader, SwTOXBase& rBas { sal_Int32 nOldIndex=nIndex; sal_uInt16 nLevel = o3tl::narrowing<sal_uInt16>( - sParams.getToken(0, ';', nIndex).toInt32()); + o3tl::toInt32(o3tl::getToken(sParams, 0, ';', nIndex))); if( -1 == nIndex ) { nIndex = nOldIndex; nLevel = o3tl::narrowing<sal_uInt16>( - sParams.getToken(0, ',', nIndex).toInt32()); + o3tl::toInt32(o3tl::getToken(sParams, 0, ',', nIndex))); } if( (0 < nLevel) && (MAXLEVEL >= nLevel) ) diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index a792c1e1afed..73a63255cc62 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -25,6 +25,7 @@ #include "flddb.hxx" #include <dbconfig.hxx> #include <dbmgr.hxx> +#include <o3tl/string_view.hxx> #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 @@ -154,7 +155,7 @@ void SwFieldDBPage::Reset(const SfxItemSet*) sal_Int32 nIdx{ 0 }; if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) { - const sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(sUserData.getToken(0, ';', nIdx).toInt32()); + const sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if (nVal != USHRT_MAX) { for (sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; ++i) diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index 0de35805ad2c..c3247352fe8a 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -21,6 +21,7 @@ #include <svl/numformat.hxx> #include <svl/zforlist.hxx> #include <svl/zformat.hxx> +#include <o3tl/string_view.hxx> #include <swtypes.hxx> #include <flddinf.hrc> @@ -125,7 +126,7 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) sal_Int32 nIdx{ 0 }; if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) { - nSelEntryData = sUserData.getToken(0, ';', nIdx).toInt32(); + nSelEntryData = o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx)); } std::vector<OUString> aLst; diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index 4546dfd34ded..25e77775a2ba 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -26,6 +26,7 @@ #include <wrtsh.hxx> #include <svl/numformat.hxx> #include <svl/zformat.hxx> +#include <o3tl/string_view.hxx> #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 @@ -155,7 +156,7 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) sal_Int32 nIdx{ 0 }; if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) { - const sal_uInt16 nVal = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32()); + const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) { for (int i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; i++) diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index a9157ccde8de..874b8fe5e90f 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -26,6 +26,7 @@ #include "fldfunc.hxx" #include "flddinf.hxx" #include <flddropdown.hxx> +#include <o3tl/string_view.hxx> #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 @@ -145,7 +146,7 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) sal_Int32 nIdx{ 0 }; if(sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) { - const sal_uInt16 nVal = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32()); + const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) { for (sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; ++i) diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index b010a1afd767..71ff3d33246e 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -36,6 +36,7 @@ #include <docufld.hxx> #include <cmdid.h> #include <sfx2/bindings.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; @@ -146,7 +147,7 @@ void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, con aReq.AppendItem(SfxStringItem (FN_PARAM_1,rPar1.getToken(0, DB_DELIM, nIdx))); aReq.AppendItem(SfxInt32Item - (FN_PARAM_3,rPar1.getToken(0, DB_DELIM, nIdx).toInt32())); + (FN_PARAM_3, o3tl::toInt32(o3tl::getToken(rPar1, 0, DB_DELIM, nIdx)))); aReq.AppendItem(SfxStringItem (FN_PARAM_2,rPar1.getToken(0, DB_DELIM, nIdx))); } @@ -188,7 +189,7 @@ void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, con aData.sDataSource = rPar1.getToken(0, DB_DELIM, nPos); aData.sCommand = rPar1.getToken(0, DB_DELIM, nPos); - aData.nCommandType = rPar1.getToken(0, DB_DELIM, nPos).toInt32(); + aData.nCommandType = o3tl::toInt32(o3tl::getToken(rPar1, 0, DB_DELIM, nPos)); sPar1 = rPar1.copy(nPos); static_cast<SwDBNameInfField*>(pTmpField.get())->SetDBData(aData); @@ -201,7 +202,7 @@ void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, con sal_Int32 nIdx{ 0 }; aData.sDataSource = rPar1.getToken(0, DB_DELIM, nIdx); aData.sCommand = rPar1.getToken(0, DB_DELIM, nIdx); - aData.nCommandType = rPar1.getToken(0, DB_DELIM, nIdx).toInt32(); + aData.nCommandType = o3tl::toInt32(o3tl::getToken(rPar1, 0, DB_DELIM, nIdx)); OUString sColumn = rPar1.getToken(0, DB_DELIM, nIdx); auto pOldType = static_cast<SwDBFieldType*>(pTmpField->GetTyp()); diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index f9dec1a8a099..0c6c4ace6e11 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -35,6 +35,7 @@ #include <comphelper/string.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #define REFFLDFLAG 0x4000 #define REFFLDFLAG_BOOKMARK 0x4800 @@ -241,7 +242,7 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) if(!IsRefresh() && sUserData.getToken(0, ';', nIdx). equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) { - const sal_uInt16 nVal = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32()); + const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) { for(sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; ++i) @@ -254,7 +255,7 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) } if (nIdx>=0 && nIdx<sUserData.getLength()) { - nFormatBoxPosition = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32()); + nFormatBoxPosition = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); } } } diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index e19881eeeed0..442dbed88f8b 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -38,6 +38,7 @@ #include <svl/itemset.hxx> #include <editeng/langitem.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <swtypes.hxx> #include <toxmgr.hxx> #include <txttxmrk.hxx> @@ -93,7 +94,7 @@ bool SplitUrlAndPage(const OUString& rText, OUString& rUrl, int& nPageNumber) return false; } - nPageNumber = xUriRef->getFragment().copy(aPagePrefix.getLength()).toInt32(); + nPageNumber = o3tl::toInt32(xUriRef->getFragment().subView(aPagePrefix.getLength())); xUriRef->clearFragment(); rUrl = xUriRef->getUriReference(); return true; diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 257e9c4a052f..c886c603953d 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -504,7 +504,7 @@ OUString BookmarkTable::GetNameProposal() const sal_Int32 nIndex = 0; if (o3tl::getToken(sName, 0, ' ', nIndex) == sDefaultBookmarkName) { - sal_Int32 nCurrBookmarkId = sName.getToken(0, ' ', nIndex).toInt32(); + sal_Int32 nCurrBookmarkId = o3tl::toInt32(o3tl::getToken(sName, 0, ' ', nIndex)); nHighestBookmarkId = std::max<sal_Int32>(nHighestBookmarkId, nCurrBookmarkId); } } diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx index 76ab41f80bb4..703b31b3a810 100644 --- a/sw/source/ui/misc/glosbib.cxx +++ b/sw/source/ui/misc/glosbib.cxx @@ -103,7 +103,7 @@ SwGlossaryGroupDlg::SwGlossaryGroupDlg(weld::Window * pParent, pData->sGroupTitle = SwResId(STR_MY_AUTOTEXT); else pData->sGroupTitle = sTitle; - pData->sPath = m_xPathLB->get_text(sGroup.getToken(1, GLOS_DELIM).toInt32()); + pData->sPath = m_xPathLB->get_text(o3tl::toInt32(o3tl::getToken(sGroup, 1, GLOS_DELIM))); const OUString sId(weld::toId(pData)); m_xGroupTLB->append(sId, pData->sGroupTitle); int nEntry = m_xGroupTLB->find_id(sId); diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 293861d880c1..58121c6734e7 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -694,7 +694,7 @@ void SwGlossaryDlg::Init() const size_t nCnt = m_pGlossaryHdl->GetGroupCnt(); std::unique_ptr<weld::TreeIter> xSelEntry; const OUString sSelStr(::GetCurrGlosGroup().getToken(0, GLOS_DELIM)); - const sal_Int32 nSelPath = ::GetCurrGlosGroup().getToken(1, GLOS_DELIM).toInt32(); + const sal_Int32 nSelPath = o3tl::toInt32(o3tl::getToken(::GetCurrGlosGroup(), 1, GLOS_DELIM)); // #i66304# - "My AutoText" comes from mytexts.bau, but should be translated static const OUStringLiteral sMyAutoTextEnglish(u"My AutoText"); const OUString sMyAutoTextTranslated(SwResId(STR_MY_AUTOTEXT)); @@ -714,7 +714,7 @@ void SwGlossaryDlg::Init() std::unique_ptr<weld::TreeIter> xEntry = m_xCategoryBox->make_iterator(); m_xCategoryBox->append(xEntry.get()); m_xCategoryBox->set_text(*xEntry, sTitle, 0); - const sal_Int32 nPath = sGroupName.getToken( 0, GLOS_DELIM, nIdx ).toInt32(); + const sal_Int32 nPath = o3tl::toInt32(o3tl::getToken(sGroupName, 0, GLOS_DELIM, nIdx )); GroupUserData* pData = new GroupUserData; pData->sGroupName = sName; diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index e0934b78ce94..bf5b82fd5f81 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -43,6 +43,7 @@ #include <sfx2/objface.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <o3tl/string_view.hxx> #include <view.hxx> #include <pview.hxx> @@ -283,7 +284,7 @@ std::shared_ptr<SwMailMergeConfigItem> SwView::EnsureMailMergeConfigItem(const S sal_Int32 nIdx{ 0 }; aDBData.sDataSource = sDBName.getToken(0, DB_DELIM, nIdx); aDBData.sCommand = sDBName.getToken(0, DB_DELIM, nIdx); - aDBData.nCommandType = sDBName.getToken(0, DB_DELIM, nIdx).toInt32(); + aDBData.nCommandType = o3tl::toInt32(o3tl::getToken(sDBName, 0, DB_DELIM, nIdx)); //set the currently used database for the wizard xMMConfig->SetCurrentDBData(aDBData); } diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 4bf95499394b..49b0584586b0 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1175,7 +1175,7 @@ bool SwFieldMgr::InsertField( sal_Int32 nIdx{ 0 }; aDBData.sDataSource = rData.m_sPar1.getToken(0, DB_DELIM, nIdx); aDBData.sCommand = rData.m_sPar1.getToken(0, DB_DELIM, nIdx); - aDBData.nCommandType = rData.m_sPar1.getToken(0, DB_DELIM, nIdx).toInt32(); + aDBData.nCommandType = o3tl::toInt32(o3tl::getToken(rData.m_sPar1, 0, DB_DELIM, nIdx)); sPar1 = rData.m_sPar1.getToken(0, DB_DELIM, nIdx); } diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx index 991ff73d91a1..291ef3cf4050 100644 --- a/sw/source/uibase/misc/glosdoc.cxx +++ b/sw/source/uibase/misc/glosdoc.cxx @@ -196,7 +196,7 @@ bool SwGlossaries::NewGroupDoc(OUString& rGroupName, const OUString& rTitle) bool SwGlossaries::RenameGroupDoc( const OUString& rOldGroup, OUString& rNewGroup, const OUString& rNewTitle ) { - sal_uInt16 nOldPath = o3tl::narrowing<sal_uInt16>(rOldGroup.getToken(1, GLOS_DELIM).toInt32()); + sal_uInt16 nOldPath = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rOldGroup, 1, GLOS_DELIM))); if (static_cast<size_t>(nOldPath) >= m_PathArr.size()) return false; @@ -209,7 +209,7 @@ bool SwGlossaries::RenameGroupDoc( return false; } - sal_uInt16 nNewPath = o3tl::narrowing<sal_uInt16>(rNewGroup.getToken(1, GLOS_DELIM).toInt32()); + sal_uInt16 nNewPath = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rNewGroup, 1, GLOS_DELIM))); if (static_cast<size_t>(nNewPath) >= m_PathArr.size()) return false; @@ -247,7 +247,7 @@ bool SwGlossaries::RenameGroupDoc( // Deletes a text block group bool SwGlossaries::DelGroupDoc(const OUString &rName) { - sal_uInt16 nPath = o3tl::narrowing<sal_uInt16>(rName.getToken(1, GLOS_DELIM).toInt32()); + sal_uInt16 nPath = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rName, 1, GLOS_DELIM))); if (static_cast<size_t>(nPath) >= m_PathArr.size()) return false; const OUString sBaseName(rName.getToken(0, GLOS_DELIM)); @@ -270,7 +270,7 @@ SwGlossaries::~SwGlossaries() // read a block document std::unique_ptr<SwTextBlocks> SwGlossaries::GetGlosDoc( const OUString &rName, bool bCreate ) const { - sal_uInt16 nPath = o3tl::narrowing<sal_uInt16>(rName.getToken(1, GLOS_DELIM).toInt32()); + sal_uInt16 nPath = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rName, 1, GLOS_DELIM))); std::unique_ptr<SwTextBlocks> pTmp; if (static_cast<size_t>(nPath) < m_PathArr.size()) { diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index c387d6938350..9bc53168c376 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -28,6 +28,7 @@ #include <hintids.hxx> #include <comphelper/string.hxx> #include <o3tl/any.hxx> +#include <o3tl/string_view.hxx> #include <officecfg/Office/Common.hxx> #include <vcl/graph.hxx> #include <vcl/inputctx.hxx> @@ -1195,17 +1196,17 @@ void SwView::ReadUserData( const OUString &rUserData, bool bBrowse ) // No it is *not* a good idea to call GetToken within Point constr. immediately, // because which parameter is evaluated first? - tools::Long nX = rUserData.getToken( 0, ';', nPos ).toInt32(), - nY = rUserData.getToken( 0, ';', nPos ).toInt32(); + tools::Long nX = o3tl::toInt32(o3tl::getToken(rUserData, 0, ';', nPos )), + nY = o3tl::toInt32(o3tl::getToken(rUserData, 0, ';', nPos )); Point aCursorPos( nX, nY ); sal_uInt16 nZoomFactor = - static_cast< sal_uInt16 >( rUserData.getToken(0, ';', nPos ).toInt32() ); + static_cast< sal_uInt16 >( o3tl::toInt32(o3tl::getToken(rUserData, 0, ';', nPos )) ); - tools::Long nLeft = rUserData.getToken(0, ';', nPos ).toInt32(), - nTop = rUserData.getToken(0, ';', nPos ).toInt32(), - nRight = rUserData.getToken(0, ';', nPos ).toInt32(), - nBottom= rUserData.getToken(0, ';', nPos ).toInt32(); + tools::Long nLeft = o3tl::toInt32(o3tl::getToken(rUserData, 0, ';', nPos )), + nTop = o3tl::toInt32(o3tl::getToken(rUserData, 0, ';', nPos )), + nRight = o3tl::toInt32(o3tl::getToken(rUserData, 0, ';', nPos )), + nBottom= o3tl::toInt32(o3tl::getToken(rUserData, 0, ';', nPos )); const tools::Long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2; if ( nBottom > (m_pWrtShell->GetDocSize().Height()+nAdd) ) @@ -1218,14 +1219,14 @@ void SwView::ReadUserData( const OUString &rUserData, bool bBrowse ) sal_Int32 nOff = 0; SvxZoomType eZoom; if( !m_pWrtShell->GetViewOptions()->getBrowseMode() ) - eZoom = static_cast<SvxZoomType>(o3tl::narrowing<sal_uInt16>(rUserData.getToken(nOff, ';', nPos ).toInt32())); + eZoom = static_cast<SvxZoomType>(o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rUserData, nOff, ';', nPos )))); else { eZoom = SvxZoomType::PERCENT; ++nOff; } - bool bSelectObj = (0 != rUserData.getToken( nOff, ';', nPos ).toInt32()) + bool bSelectObj = (0 != o3tl::toInt32(o3tl::getToken(rUserData, nOff, ';', nPos ))) && m_pWrtShell->IsObjSelectable( aCursorPos ); // restore editing position @@ -1265,8 +1266,8 @@ void SwView::ReadUserData( const OUString &rUserData, bool bBrowse ) if( !m_sNewCursorPos.isEmpty() ) { sal_Int32 nIdx{ 0 }; - const tools::Long nXTmp = m_sNewCursorPos.getToken( 0, ';', nIdx ).toInt32(); - const tools::Long nYTmp = m_sNewCursorPos.getToken( 0, ';', nIdx ).toInt32(); + const tools::Long nXTmp = o3tl::toInt32(o3tl::getToken(m_sNewCursorPos, 0, ';', nIdx )); + const tools::Long nYTmp = o3tl::toInt32(o3tl::getToken(m_sNewCursorPos, 0, ';', nIdx )); Point aCursorPos2( nXTmp, nYTmp ); bSelectObj = m_pWrtShell->IsObjSelectable( aCursorPos2 ); diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 5e7fba530d49..a9f13a02b2df 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -2731,7 +2731,7 @@ void SwView::GenerateFormLetter(bool bUseCurrentDocument) sal_Int32 nIdx {0}; aData.sDataSource = sDBName.getToken(0, DB_DELIM, nIdx); aData.sCommand = sDBName.getToken(0, DB_DELIM, nIdx); - aData.nCommandType = sDBName.getToken(0, DB_DELIM, nIdx).toInt32(); + aData.nCommandType = o3tl::toInt32(o3tl::getToken(sDBName, 0, DB_DELIM, nIdx)); } rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields AttrChangedNotify(nullptr); diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 583f159d2a33..719b2016e1b7 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -31,6 +31,7 @@ #include <vcl/commandevent.hxx> #include <vcl/weldutils.hxx> #include <sot/formats.hxx> +#include <o3tl/string_view.hxx> #include <uiitems.hxx> #include <fmtanchr.hxx> #include <fmtinfmt.hxx> @@ -5054,8 +5055,8 @@ bool NaviContentBookmark::Paste( const TransferableDataHelper& rData ) sal_Int32 nPos = 0; m_aUrl = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ); m_aDescription = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ); - m_nDefaultDrag= static_cast<RegionMode>( sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32() ); - m_nDocSh = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32(); + m_nDefaultDrag= static_cast<RegionMode>( o3tl::toInt32(o3tl::getToken(sStr, 0, NAVI_BOOKMARK_DELIM, nPos )) ); + m_nDocSh = o3tl::toInt32(o3tl::getToken(sStr, 0, NAVI_BOOKMARK_DELIM, nPos )); } return bRet; } diff --git a/sw/source/uibase/utlui/gloslst.cxx b/sw/source/uibase/utlui/gloslst.cxx index 55e202186aa0..65ca88fd0077 100644 --- a/sw/source/uibase/utlui/gloslst.cxx +++ b/sw/source/uibase/utlui/gloslst.cxx @@ -252,7 +252,7 @@ void SwGlossaryList::Update() { OUString sGrpName = pGlossaries->GetGroupName(i); const size_t nPath = static_cast<size_t>( - sGrpName.getToken(1, GLOS_DELIM).toInt32()); + o3tl::toInt32(o3tl::getToken(sGrpName, 1, GLOS_DELIM))); if( nPath < rPathArr.size() ) { std::unique_ptr<AutoTextGroup> pGroup(new AutoTextGroup); @@ -312,7 +312,7 @@ void SwGlossaryList::Update() // maybe remove deleted groups AutoTextGroup* pGroup = m_aGroupArr[i].get(); const size_t nGroupPath = static_cast<size_t>( - pGroup->sName.getToken( 1, GLOS_DELIM).toInt32()); + o3tl::toInt32(o3tl::getToken(pGroup->sName, 1, GLOS_DELIM))); // Only the groups will be checked which are registered // for the current subpath. if( nGroupPath == nPath ) |