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 | |
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>
99 files changed, 437 insertions, 365 deletions
diff --git a/comphelper/source/misc/sequenceashashmap.cxx b/comphelper/source/misc/sequenceashashmap.cxx index c6ac57326935..b2021e7b85fa 100644 --- a/comphelper/source/misc/sequenceashashmap.cxx +++ b/comphelper/source/misc/sequenceashashmap.cxx @@ -30,6 +30,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> using namespace com::sun::star; @@ -73,17 +74,17 @@ uno::Any jsonToUnoAny(const boost::property_tree::ptree& aTree) if (aTypeClass == uno::TypeClass_VOID) aAny.clear(); else if (aTypeClass == uno::TypeClass_BYTE) - aAny <<= static_cast<sal_Int8>(OString(rValue.c_str()).toInt32()); + aAny <<= static_cast<sal_Int8>(o3tl::toInt32(rValue)); else if (aTypeClass == uno::TypeClass_BOOLEAN) aAny <<= OString(rValue.c_str()).toBoolean(); else if (aTypeClass == uno::TypeClass_SHORT) - aAny <<= static_cast<sal_Int16>(OString(rValue.c_str()).toInt32()); + aAny <<= static_cast<sal_Int16>(o3tl::toInt32(rValue)); else if (aTypeClass == uno::TypeClass_UNSIGNED_SHORT) aAny <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32()); else if (aTypeClass == uno::TypeClass_LONG) - aAny <<= OString(rValue.c_str()).toInt32(); + aAny <<= o3tl::toInt32(rValue); else if (aTypeClass == uno::TypeClass_UNSIGNED_LONG) - aAny <<= static_cast<sal_uInt32>(OString(rValue.c_str()).toInt32()); + aAny <<= static_cast<sal_uInt32>(o3tl::toInt32(rValue)); else if (aTypeClass == uno::TypeClass_FLOAT) aAny <<= OString(rValue.c_str()).toFloat(); else if (aTypeClass == uno::TypeClass_DOUBLE) @@ -326,17 +327,17 @@ std::vector<css::beans::PropertyValue> JsonToPropertyValues(const OString& rJson else if (rType == "float") aValue.Value <<= OString(rValue.c_str()).toFloat(); else if (rType == "long") - aValue.Value <<= OString(rValue.c_str()).toInt32(); + aValue.Value <<= o3tl::toInt32(rValue); else if (rType == "short") - aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32()); + aValue.Value <<= sal_Int16(o3tl::toInt32(rValue)); else if (rType == "unsigned short") aValue.Value <<= sal_uInt16(OString(rValue.c_str()).toUInt32()); else if (rType == "int64") - aValue.Value <<= OString(rValue.c_str()).toInt64(); + aValue.Value <<= o3tl::toInt64(rValue); else if (rType == "int32") - aValue.Value <<= OString(rValue.c_str()).toInt32(); + aValue.Value <<= o3tl::toInt32(rValue); else if (rType == "int16") - aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32()); + aValue.Value <<= sal_Int16(o3tl::toInt32(rValue)); else if (rType == "uint64") aValue.Value <<= OString(rValue.c_str()).toUInt64(); else if (rType == "uint32") diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx index d7b48a43a4b8..e706f4b397da 100644 --- a/compilerplugins/clang/stringview.cxx +++ b/compilerplugins/clang/stringview.cxx @@ -46,7 +46,8 @@ public: return !( loplugin::isSamePathname(fn, SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx") || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx") - || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx")); + || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx") + || loplugin::isSamePathname(fn, SRCDIR "/sal/qa/rtl/oustring/rtl_OUString2.cxx")); } virtual void run() override @@ -336,33 +337,44 @@ void StringView::handleCXXMemberCallExpr(CXXMemberCallExpr const* expr) } } -/** check for calls to O[U]StringBuffer::append that could be passed as a - std::u16string_view */ bool StringView::VisitCXXMemberCallExpr(CXXMemberCallExpr const* expr) { if (ignoreLocation(expr)) { return true; } - if (!loplugin::TypeCheck(expr->getType()) - .Class("OUStringBuffer") - .Namespace("rtl") - .GlobalNamespace() - && !loplugin::TypeCheck(expr->getType()) - .Class("OStringBuffer") - .Namespace("rtl") - .GlobalNamespace()) - { - return true; - } - auto const dc = loplugin::DeclCheck(expr->getMethodDecl()); - if (dc.Function("append") || dc.Function("indexOf") || dc.Function("lastIndexOf")) + /** check for calls to O[U]StringBuffer::append that could be passed as a + std::u16string_view */ + if (loplugin::TypeCheck(expr->getType()) + .Class("OUStringBuffer") + .Namespace("rtl") + .GlobalNamespace() + || loplugin::TypeCheck(expr->getType()) + .Class("OStringBuffer") + .Namespace("rtl") + .GlobalNamespace()) { - handleSubExprThatCouldBeView(expr->getArg(0)); + auto const dc = loplugin::DeclCheck(expr->getMethodDecl()); + if (dc.Function("append") || dc.Function("indexOf") || dc.Function("lastIndexOf")) + { + handleSubExprThatCouldBeView(expr->getArg(0)); + } + else if (dc.Function("insert")) + { + handleSubExprThatCouldBeView(expr->getArg(1)); + } } - else if (dc.Function("insert")) + + // rather than getToken...toInt32, use o3tl::toInt(o3tl::getToken(...) + auto tc = loplugin::TypeCheck(expr->getImplicitObjectArgument()->getType()); + if (tc.Class("OUString").Namespace("rtl").GlobalNamespace() + || tc.Class("OString").Namespace("rtl").GlobalNamespace()) { - handleSubExprThatCouldBeView(expr->getArg(1)); + auto const dc = loplugin::DeclCheck(expr->getMethodDecl()); + if (dc.Function("toInt32") || dc.Function("toInt64")) + { + handleSubExprThatCouldBeView(expr->getImplicitObjectArgument()); + } } return true; } diff --git a/compilerplugins/clang/test/stringview.cxx b/compilerplugins/clang/test/stringview.cxx index 7e637175e259..398f14b3dd12 100644 --- a/compilerplugins/clang/test/stringview.cxx +++ b/compilerplugins/clang/test/stringview.cxx @@ -213,4 +213,9 @@ void f5(OUString s) s += OUString(std::u16string_view(u"foo")); } +void f6(OUString s) +{ + // expected-error@+1 {{rather than getToken, pass with a view using o3tl::getToken() [loplugin:stringview]}} + s.getToken(1, ' ').toInt32(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx index d1cfd7ac7f6e..289eb0c2de3e 100644 --- a/connectivity/source/commontools/dbconversion.cxx +++ b/connectivity/source/commontools/dbconversion.cxx @@ -26,6 +26,7 @@ #include <rtl/math.hxx> #include <sal/log.hxx> #include <unotools/datetime.hxx> +#include <o3tl/string_view.hxx> #include <sstream> #include <iomanip> @@ -403,7 +404,7 @@ namespace dbtools return aRet; } - css::util::Date DBTypeConversion::toDate(const OUString& _sSQLString) + css::util::Date DBTypeConversion::toDate(std::u16string_view _sSQLString) { // get the token out of a string static const sal_Unicode sDateSep = '-'; @@ -412,12 +413,12 @@ namespace dbtools sal_uInt16 nYear = 0, nMonth = 0, nDay = 0; - nYear = static_cast<sal_uInt16>(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); + nYear = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(_sSQLString, 0,sDateSep,nIndex))); if(nIndex != -1) { - nMonth = static_cast<sal_uInt16>(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); + nMonth = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(_sSQLString, 0,sDateSep,nIndex))); if(nIndex != -1) - nDay = static_cast<sal_uInt16>(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); + nDay = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(_sSQLString, 0,sDateSep,nIndex))); } return css::util::Date(nDay,nMonth,nYear); diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 962e574879cf..283fdf66885c 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -51,6 +51,7 @@ #include <resource/sharedresources.hxx> #include <i18nlangtag/languagetag.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <memory> @@ -275,9 +276,9 @@ namespace connectivity if (!sVersionString.isEmpty()) { sal_Int32 nIdx {0}; - const sal_Int32 nMajor = sVersionString.getToken(0, '.', nIdx).toInt32(); - const sal_Int32 nMinor = sVersionString.getToken(0, '.', nIdx).toInt32(); - const sal_Int32 nMicro = sVersionString.getToken(0, '.', nIdx).toInt32(); + const sal_Int32 nMajor = o3tl::toInt32(o3tl::getToken(sVersionString, 0, '.', nIdx)); + const sal_Int32 nMinor = o3tl::toInt32(o3tl::getToken(sVersionString, 0, '.', nIdx)); + const sal_Int32 nMicro = o3tl::toInt32(o3tl::getToken(sVersionString, 0, '.', nIdx)); if ( nMajor > 1 || ( nMajor == 1 && nMinor > 8 ) || ( nMajor == 1 && nMinor == 8 && nMicro > 0 ) ) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index ed23eeac64c2..23a46246278d 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -210,7 +210,7 @@ SQLParseNodeParameter::SQLParseNodeParameter( const Reference< XConnection >& _r { } -OUString OSQLParseNode::convertDateString(const SQLParseNodeParameter& rParam, const OUString& rString) +OUString OSQLParseNode::convertDateString(const SQLParseNodeParameter& rParam, std::u16string_view rString) { Date aDate = DBTypeConversion::toDate(rString); Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx index 8438fb3dcf2d..73f54d317e6f 100644 --- a/cui/source/options/dbregister.cxx +++ b/cui/source/options/dbregister.cxx @@ -36,6 +36,7 @@ #include <dialmgr.hxx> #include "dbregisterednamesconfig.hxx" #include <svx/databaseregistrationui.hxx> +#include <o3tl/string_view.hxx> #define COL_TYPE 0 @@ -179,11 +180,11 @@ void DbRegistrationOptionsPage::Reset( const SfxItemSet* rSet ) // restore column width std::vector<int> aWidths { - aUserData.getToken(0, ';', nIdx).toInt32() + o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) }; m_xPathBox->set_column_fixed_widths(aWidths); // restore sort direction - bool bUp = aUserData.getToken(0, ';', nIdx).toInt32() != 0; + bool bUp = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) != 0; m_xPathBox->set_sort_order(bUp); m_xPathBox->set_sort_indicator(bUp ? TRISTATE_TRUE : TRISTATE_FALSE, COL_TYPE); } diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 5d71363f0299..4426d9ad8a4e 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -62,6 +62,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; @@ -2651,10 +2652,10 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) if ( !sUser.isEmpty() ) { sal_Int32 nIdx {0}; - m_nSuperEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSubEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSuperProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSubProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32()); + m_nSuperEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSubEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSuperProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSubProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); m_xHighLowMF->set_max(MAX_ESC_POS, FieldUnit::PERCENT); diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 2758b0a6ed6a..b05cd467da81 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -42,7 +42,7 @@ namespace dbaccess { sal_Int32 nPos {0}; _sHostname = _sUrl.getToken(0, ':', nPos); - _nPortNumber = _sUrl.getToken(0, ':', nPos).toInt32(); + _nPortNumber = o3tl::toInt32(o3tl::getToken(_sUrl, 0, ':', nPos)); } } } diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx index 432f8b6cc150..1dee8a1f57e2 100644 --- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx @@ -28,6 +28,7 @@ #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <vcl/mnemonic.hxx> +#include <o3tl/string_view.hxx> namespace { @@ -350,7 +351,7 @@ namespace dbaui return sExtension; } - OUString OTextConnectionHelper::GetSeparator(const weld::ComboBox& rBox, const OUString& rList) + OUString OTextConnectionHelper::GetSeparator(const weld::ComboBox& rBox, std::u16string_view rList) { sal_Unicode const nTok = '\t'; int nPos(rBox.find_text(rBox.get_active_text())); @@ -360,7 +361,7 @@ namespace dbaui if ( m_xTextSeparator.get() != &rBox || nPos != (rBox.get_count()-1) ) return OUString( - static_cast< sal_Unicode >( rList.getToken((nPos*2)+1, nTok ).toInt32() )); + static_cast< sal_Unicode >( o3tl::toInt32(o3tl::getToken(rList, (nPos*2)+1, nTok )) )); // somewhat strange ... translates for instance an "32" into " " return OUString(); } @@ -373,7 +374,7 @@ namespace dbaui for(sal_Int32 nIdx {0}; nIdx>=0;) { sal_Int32 nPrevIdx {nIdx}; - if (static_cast<sal_Unicode>(rList.getToken(1, '\t', nIdx).toInt32()) == nVal) + if (static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(rList, 1, '\t', nIdx))) == nVal) { rBox.set_entry_text(rList.getToken(0, '\t', nPrevIdx)); return; diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.hxx b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx index 41921f092f82..5fface3d0512 100644 --- a/dbaccess/source/ui/dlg/TextConnectionHelper.hxx +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx @@ -71,7 +71,7 @@ namespace dbaui DECL_LINK(OnSetExtensionHdl, weld::Toggleable&, void); DECL_LINK(OnEditModified, weld::Entry&, void); - OUString GetSeparator(const weld::ComboBox& rBox, const OUString& rList); + OUString GetSeparator(const weld::ComboBox& rBox, std::u16string_view rList); void SetSeparator(weld::ComboBox& rBox, const OUString& rList, const OUString& rVal); void SetExtension(const OUString& _rVal); diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 1d36f54f3ffc..1aff45ab0cde 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -55,6 +55,7 @@ #include <config_mpl.h> #include <tools/json_writer.hxx> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> #include <lib/init.hxx> #include <svx/svxids.hrc> @@ -860,7 +861,7 @@ void DesktopLOKTest::testRowColumnHeaders() bool bNotEnoughHeaders = true; for (const boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows")) { - sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32(); + sal_Int32 nSize = o3tl::toInt32(rValue.second.get<std::string>("size")); nSize = o3tl::convert(nSize, o3tl::Length::px, o3tl::Length::twip); OString aText(rValue.second.get<std::string>("text").c_str()); @@ -889,7 +890,7 @@ void DesktopLOKTest::testRowColumnHeaders() bNotEnoughHeaders = true; for (const boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns")) { - sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32(); + sal_Int32 nSize = o3tl::toInt32(rValue.second.get<std::string>("size")); nSize = o3tl::convert(nSize, o3tl::Length::px, o3tl::Length::twip); OString aText(rValue.second.get<std::string>("text").c_str()); if (bFirstHeader) @@ -939,7 +940,7 @@ void DesktopLOKTest::testHiddenRowHeaders() sal_Int32 nIndex = 0; for (const boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows")) { - sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32(); + sal_Int32 nSize = o3tl::toInt32(rValue.second.get<std::string>("size")); if (nIndex++ == 2) { diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 6402d9f7e99b..7875d29829f8 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -33,6 +33,7 @@ #include <rtl/math.hxx> #include <vcl/introwin.hxx> #include <vcl/virdev.hxx> +#include <o3tl/string_view.hxx> #include <mutex> @@ -368,16 +369,16 @@ void SplashScreen::loadConfig() { sal_uInt8 nRed = 0; sal_Int32 idx = 0; - sal_Int32 temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sProgressFrameColor, 0, ',', idx )); if ( idx != -1 ) { nRed = static_cast< sal_uInt8 >( temp ); - temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32(); + temp = o3tl::toInt32(o3tl::getToken(sProgressFrameColor, 0, ',', idx )); } if ( idx != -1 ) { sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp ); - sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressFrameColor.getToken( 0, ',', idx ).toInt32() ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( o3tl::toInt32(o3tl::getToken(sProgressFrameColor, 0, ',', idx )) ); _cProgressFrameColor = Color( nRed, nGreen, nBlue ); } } @@ -386,16 +387,16 @@ void SplashScreen::loadConfig() { sal_uInt8 nRed = 0; sal_Int32 idx = 0; - sal_Int32 temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sProgressBarColor, 0, ',', idx )); if ( idx != -1 ) { nRed = static_cast< sal_uInt8 >( temp ); - temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32(); + temp = o3tl::toInt32(o3tl::getToken(sProgressBarColor, 0, ',', idx )); } if ( idx != -1 ) { sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp ); - sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressBarColor.getToken( 0, ',', idx ).toInt32() ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( o3tl::toInt32(o3tl::getToken(sProgressBarColor, 0, ',', idx )) ); _cProgressBarColor = Color( nRed, nGreen, nBlue ); } } @@ -404,16 +405,16 @@ void SplashScreen::loadConfig() { sal_uInt8 nRed = 0; sal_Int32 idx = 0; - sal_Int32 temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sProgressTextColor, 0, ',', idx )); if ( idx != -1 ) { nRed = static_cast< sal_uInt8 >( temp ); - temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32(); + temp = o3tl::toInt32(o3tl::getToken(sProgressTextColor, 0, ',', idx )); } if ( idx != -1 ) { sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp ); - sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressTextColor.getToken( 0, ',', idx ).toInt32() ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( o3tl::toInt32(o3tl::getToken(sProgressTextColor, 0, ',', idx )) ); _cProgressTextColor = Color( nRed, nGreen, nBlue ); } } @@ -431,11 +432,11 @@ void SplashScreen::loadConfig() if ( !sSize.isEmpty() ) { sal_Int32 idx = 0; - sal_Int32 temp = sSize.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sSize, 0, ',', idx )); if ( idx != -1 ) { _barwidth = temp; - _barheight = sSize.getToken( 0, ',', idx ).toInt32(); + _barheight = o3tl::toInt32(o3tl::getToken(sSize, 0, ',', idx )); } } @@ -445,11 +446,11 @@ void SplashScreen::loadConfig() if ( !sPosition.isEmpty() ) { sal_Int32 idx = 0; - sal_Int32 temp = sPosition.getToken( 0, ',', idx ).toInt32(); + sal_Int32 temp = o3tl::toInt32(o3tl::getToken(sPosition, 0, ',', idx )); if ( idx != -1 ) { _tlx = temp; - _tly = sPosition.getToken( 0, ',', idx ).toInt32(); + _tly = o3tl::toInt32(o3tl::getToken(sPosition, 0, ',', idx )); } } } diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index a6e6b20beeed..3f972af18ddc 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/uri/UriReferenceFactory.hpp> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <sal/log.hxx> #include <cppuhelper/implbase.hxx> #include <vcl/event.hxx> @@ -72,7 +73,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/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx index ee30f710419c..e2f0a10eba58 100644 --- a/forms/source/xforms/xpathlib/xpathlib.cxx +++ b/forms/source/xforms/xpathlib/xpathlib.cxx @@ -297,12 +297,12 @@ static bool parseDateTime(std::u16string_view aString, DateTime& aDateTime) return false; sal_Int32 nIndex = 0; - sal_Int32 nYear = aDateTimeString.getToken(0, '-', nIndex).toInt32(); - sal_Int32 nMonth = aDateTimeString.getToken(0, '-', nIndex).toInt32(); - sal_Int32 nDay = aDateTimeString.getToken(0, 'T', nIndex).toInt32(); - sal_Int32 nHour = aDateTimeString.getToken(0, ':', nIndex).toInt32(); - sal_Int32 nMinute = aDateTimeString.getToken(0, ':', nIndex).toInt32(); - sal_Int32 nSecond = aDateTimeString.getToken(0, 'Z', nIndex).toInt32(); + sal_Int32 nYear = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, '-', nIndex)); + sal_Int32 nMonth = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, '-', nIndex)); + sal_Int32 nDay = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, 'T', nIndex)); + sal_Int32 nHour = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, ':', nIndex)); + sal_Int32 nMinute = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, ':', nIndex)); + sal_Int32 nSecond = o3tl::toInt32(o3tl::getToken(aDateTimeString, 0, 'Z', nIndex)); Date tmpDate(static_cast<sal_uInt16>(nDay), static_cast<sal_uInt16>(nMonth), static_cast<sal_uInt16>(nYear)); tools::Time tmpTime(nHour, nMinute, nSecond); diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index d417488e4a55..21fc6a28d8d1 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -248,7 +248,7 @@ void RemoteFilesDialog::InitSize() sal_Int32 nPos2{ sCfgStr.indexOf('|', nPos1+1 ) }; if (nPos2<0) return; - m_xFileView->SetConfigString( sCfgStr.copy(nPos2+1) ); + m_xFileView->SetConfigString( sCfgStr.subView(nPos2+1) ); } } diff --git a/fpicker/source/office/fileview.cxx b/fpicker/source/office/fileview.cxx index a0597203ee63..a9270e52fdb1 100644 --- a/fpicker/source/office/fileview.cxx +++ b/fpicker/source/office/fileview.cxx @@ -47,6 +47,7 @@ #include <rtl/math.hxx> #include <o3tl/safeint.hxx> #include <o3tl/typed_flags_set.hxx> +#include <o3tl/string_view.hxx> #include <osl/mutex.hxx> #include <osl/conditn.hxx> #include <salhelper/timer.hxx> @@ -1098,19 +1099,19 @@ OUString SvtFileView::GetConfigString() const return aContent; } -void SvtFileView::SetConfigString(const OUString& rCfgStr) +void SvtFileView::SetConfigString(std::u16string_view rCfgStr) { sal_Int32 nIdx = 0; - sal_uInt16 nSortColumn = static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); - bool bAscending = static_cast<bool>(static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32())); + sal_uInt16 nSortColumn = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx ))); + bool bAscending = static_cast<bool>(static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx )))); std::vector<int> aWidths(mpImpl->mxView->TypeColumnVisible() ? 4 : 3, -1); while ( nIdx != -1 ) { - sal_uInt16 nItemId = static_cast<sal_uInt16>(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); + sal_uInt16 nItemId = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx ))); - int nWidth = rCfgStr.getToken( 0, ';', nIdx ).toInt32(); + int nWidth = o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx )); // skip "TYPE" if (!mpImpl->mxView->TypeColumnVisible() && nItemId != COLUMN_TITLE) diff --git a/fpicker/source/office/fileview.hxx b/fpicker/source/office/fileview.hxx index d86ee93900e1..19ddd60e1e15 100644 --- a/fpicker/source/office/fileview.hxx +++ b/fpicker/source/office/fileview.hxx @@ -162,7 +162,7 @@ public: // save and load column size and sort order OUString GetConfigString() const; - void SetConfigString( const OUString& rCfgStr ); + void SetConfigString( std::u16string_view rCfgStr ); void EndInplaceEditing(); diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx index acb0ae059ff9..62c19b2e1c44 100644 --- a/framework/source/uiconfiguration/windowstateconfiguration.cxx +++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx @@ -42,6 +42,7 @@ #include <comphelper/propertysequence.hxx> #include <comphelper/sequence.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <string_view> #include <unordered_map> @@ -640,7 +641,7 @@ Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const OU { css::awt::Point aPos; aPos.X = aXStr.toInt32(); - aPos.Y = aString.getToken( 0, ',', nToken ).toInt32(); + aPos.Y = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken )); if ( i == PROPERTY_POS ) { @@ -672,7 +673,7 @@ Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const OU { css::awt::Size aSize; aSize.Width = aStr.toInt32(); - aSize.Height = aString.getToken( 0, ',', nToken ).toInt32(); + aSize.Height = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken )); if ( i == PROPERTY_SIZE ) { aWindowStateInfo.aSize = aSize; @@ -833,7 +834,7 @@ ConfigurationAccess_WindowState::WindowStateInfo& ConfigurationAccess_WindowStat { css::awt::Point aPos; aPos.X = aXStr.toInt32(); - aPos.Y = aString.getToken( 0, ',', nToken ).toInt32(); + aPos.Y = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken )); if ( i == PROPERTY_POS ) { @@ -862,7 +863,7 @@ ConfigurationAccess_WindowState::WindowStateInfo& ConfigurationAccess_WindowStat { css::awt::Size aSize; aSize.Width = aStr.toInt32(); - aSize.Height = aString.getToken( 0, ',', nToken ).toInt32(); + aSize.Height = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nToken )); if ( i == PROPERTY_SIZE ) { aWindowStateInfo.aSize = aSize; diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 0a2b9a4bf751..ff1246b452b3 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -33,6 +33,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <sal/macros.h> +#include <o3tl/string_view.hxx> namespace com::sun::star::uno { class XComponentContext; } @@ -1079,7 +1080,7 @@ LocaleDataImpl::getUnicodeScripts( const Locale& rLocale ) Sequence< UnicodeScript > seq(scriptCount); auto seqRange = asNonConstRange(seq); for(sal_Int16 i = 0; i < scriptCount; i++) { - seqRange[i] = UnicodeScript( OUString(scriptArray[i]).toInt32() ); + seqRange[i] = UnicodeScript( o3tl::toInt32(std::u16string_view(scriptArray[i], 1)) ); } return seq; } diff --git a/include/connectivity/dbconversion.hxx b/include/connectivity/dbconversion.hxx index 775201496e65..c73444a99515 100644 --- a/include/connectivity/dbconversion.hxx +++ b/include/connectivity/dbconversion.hxx @@ -89,7 +89,7 @@ namespace dbtools::DBTypeConversion sal_Int16 nKeyType); OOO_DLLPUBLIC_DBTOOLS css::util::Date toDate(double dVal, const css::util::Date& _rNullDate = getStandardDate()); - OOO_DLLPUBLIC_DBTOOLS css::util::Date toDate(const OUString& _sSQLDate); + OOO_DLLPUBLIC_DBTOOLS css::util::Date toDate(std::u16string_view _sSQLDate); OOO_DLLPUBLIC_DBTOOLS css::util::Time toTime(double dVal, short nDigits = 9); OOO_DLLPUBLIC_DBTOOLS css::util::Time toTime(const OUString& _sSQLDate); OOO_DLLPUBLIC_DBTOOLS css::util::DateTime toDateTime(double dVal, const css::util::Date& _rNullDate = getStandardDate()); diff --git a/include/connectivity/sqlnode.hxx b/include/connectivity/sqlnode.hxx index 0e9ca82bec4a..203679d25dcf 100644 --- a/include/connectivity/sqlnode.hxx +++ b/include/connectivity/sqlnode.hxx @@ -425,7 +425,7 @@ namespace connectivity bool addDateValue(OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const; static OUString convertDateTimeString(const SQLParseNodeParameter& rParam, const OUString& rString); - static OUString convertDateString(const SQLParseNodeParameter& rParam, const OUString& rString); + static OUString convertDateString(const SQLParseNodeParameter& rParam, std::u16string_view rString); static OUString convertTimeString(const SQLParseNodeParameter& rParam, const OUString& rString); void parseLeaf(OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const; }; diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx index 6a93b46d84be..ccfb32235e77 100644 --- a/include/sfx2/childwin.hxx +++ b/include/sfx2/childwin.hxx @@ -226,7 +226,7 @@ const int nCloseResponseToJustHide = -42; static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \ return aInfo; } -bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize ); +bool GetPosSizeFromString( std::u16string_view rStr, Point& rPos, Size& rSize ); bool GetSplitSizeFromString( const OUString& rStr, Size& rSize ); diff --git a/include/unotools/VersionConfig.hxx b/include/unotools/VersionConfig.hxx index f3ed8315640f..6142f5548fa5 100644 --- a/include/unotools/VersionConfig.hxx +++ b/include/unotools/VersionConfig.hxx @@ -11,6 +11,7 @@ #include <officecfg/Setup.hxx> #include <unotools/configmgr.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -25,11 +26,11 @@ namespace utl static bool isProductVersionUpgraded(bool aUpdateVersion) { OUString sSetupVersion = utl::ConfigManager::getProductVersion(); - sal_Int32 iCurrent - = sSetupVersion.getToken(0, '.').toInt32() * 10 + sSetupVersion.getToken(1, '.').toInt32(); + sal_Int32 iCurrent = o3tl::toInt32(o3tl::getToken(sSetupVersion, 0, '.')) * 10 + + o3tl::toInt32(o3tl::getToken(sSetupVersion, 1, '.')); OUString sLastVersion = officecfg::Setup::Product::ooSetupLastVersion::get().value_or("0.0"); - sal_Int32 iLast - = sLastVersion.getToken(0, '.').toInt32() * 10 + sLastVersion.getToken(1, '.').toInt32(); + sal_Int32 iLast = o3tl::toInt32(o3tl::getToken(sLastVersion, 0, '.')) * 10 + + o3tl::toInt32(o3tl::getToken(sLastVersion, 1, '.')); if (iCurrent > iLast) { if (aUpdateVersion) diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx index 45f6b21a903d..c7e68a88165a 100644 --- a/oox/source/drawingml/customshapepresetdata.cxx +++ b/oox/source/drawingml/customshapepresetdata.cxx @@ -85,91 +85,96 @@ void lcl_parseAdjustmentValues( } drawing::EnhancedCustomShapeParameterPair -lcl_parseEnhancedCustomShapeParameterPair(const OString& rValue) +lcl_parseEnhancedCustomShapeParameterPair(std::string_view rValue) { drawing::EnhancedCustomShapeParameterPair aPair; // We expect the following here: First.Value, First.Type, Second.Value, Second.Type static const char aExpectedFVPrefix[] = "First = (com.sun.star.drawing.EnhancedCustomShapeParameter) { Value = (any) { (long) "; - assert(rValue.startsWith(aExpectedFVPrefix)); + assert(o3tl::starts_with(rValue, aExpectedFVPrefix)); sal_Int32 nIndex = strlen(aExpectedFVPrefix); - aPair.First.Value <<= static_cast<sal_uInt32>(rValue.getToken(0, '}', nIndex).toInt32()); + aPair.First.Value + <<= static_cast<sal_uInt32>(o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex))); static const char aExpectedFTPrefix[] = ", Type = (short) "; - assert(nIndex >= 0 && rValue.match(aExpectedFTPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedFTPrefix)); nIndex += strlen(aExpectedFTPrefix); - aPair.First.Type = static_cast<sal_uInt16>(rValue.getToken(0, '}', nIndex).toInt32()); + aPair.First.Type + = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex))); static const char aExpectedSVPrefix[] = ", Second = " "(com.sun.star.drawing.EnhancedCustomShapeParameter) { " "Value = (any) { (long) "; - assert(nIndex >= 0 && rValue.match(aExpectedSVPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedSVPrefix)); nIndex += strlen(aExpectedSVPrefix); - aPair.Second.Value <<= static_cast<sal_uInt32>(rValue.getToken(0, '}', nIndex).toInt32()); + aPair.Second.Value + <<= static_cast<sal_uInt32>(o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex))); static const char aExpectedSTPrefix[] = ", Type = (short) "; - assert(nIndex >= 0 && rValue.match(aExpectedSTPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedSTPrefix)); nIndex += strlen(aExpectedSTPrefix); - aPair.Second.Type = static_cast<sal_uInt16>(rValue.getToken(0, '}', nIndex).toInt32()); + aPair.Second.Type + = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex))); return aPair; } -drawing::EnhancedCustomShapeSegment lcl_parseEnhancedCustomShapeSegment(const OString& rValue) +drawing::EnhancedCustomShapeSegment lcl_parseEnhancedCustomShapeSegment(std::string_view rValue) { drawing::EnhancedCustomShapeSegment aSegment; // We expect the following here: Command, Count static const char aExpectedCommandPrefix[] = "Command = (short) "; - assert(rValue.startsWith(aExpectedCommandPrefix)); + assert(o3tl::starts_with(rValue, aExpectedCommandPrefix)); sal_Int32 nIndex = strlen(aExpectedCommandPrefix); - aSegment.Command = static_cast<sal_Int16>(rValue.getToken(0, ',', nIndex).toInt32()); + aSegment.Command + = static_cast<sal_Int16>(o3tl::toInt32(o3tl::getToken(rValue, 0, ',', nIndex))); static const char aExpectedCountPrefix[] = " Count = (short) "; - assert(nIndex >= 0 && rValue.match(aExpectedCountPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedCountPrefix)); nIndex += strlen(aExpectedCountPrefix); - aSegment.Count = static_cast<sal_Int16>(rValue.getToken(0, '}', nIndex).toInt32()); + aSegment.Count = static_cast<sal_Int16>(o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex))); return aSegment; } -awt::Rectangle lcl_parseRectangle(const OString& rValue) +awt::Rectangle lcl_parseRectangle(std::string_view rValue) { awt::Rectangle aRectangle; // We expect the following here: X, Y, Width, Height static const char aExpectedXPrefix[] = "X = (long) "; - assert(rValue.startsWith(aExpectedXPrefix)); + assert(o3tl::starts_with(rValue, aExpectedXPrefix)); sal_Int32 nIndex = strlen(aExpectedXPrefix); - aRectangle.X = rValue.getToken(0, ',', nIndex).toInt32(); + aRectangle.X = o3tl::toInt32(o3tl::getToken(rValue, 0, ',', nIndex)); static const char aExpectedYPrefix[] = " Y = (long) "; - assert(nIndex >= 0 && rValue.match(aExpectedYPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedYPrefix)); nIndex += strlen(aExpectedYPrefix); - aRectangle.Y = rValue.getToken(0, ',', nIndex).toInt32(); + aRectangle.Y = o3tl::toInt32(o3tl::getToken(rValue, 0, ',', nIndex)); static const char aExpectedWidthPrefix[] = " Width = (long) "; - assert(nIndex >= 0 && rValue.match(aExpectedWidthPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedWidthPrefix)); nIndex += strlen(aExpectedWidthPrefix); - aRectangle.Width = rValue.getToken(0, ',', nIndex).toInt32(); + aRectangle.Width = o3tl::toInt32(o3tl::getToken(rValue, 0, ',', nIndex)); static const char aExpectedHeightPrefix[] = " Height = (long) "; - assert(nIndex >= 0 && rValue.match(aExpectedHeightPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedHeightPrefix)); nIndex += strlen(aExpectedHeightPrefix); - aRectangle.Height = o3tl::toInt32(rValue.subView(nIndex)); + aRectangle.Height = o3tl::toInt32(rValue.substr(nIndex)); return aRectangle; } -awt::Size lcl_parseSize(const OString& rValue) +awt::Size lcl_parseSize(std::string_view rValue) { awt::Size aSize; // We expect the following here: Width, Height static const char aExpectedWidthPrefix[] = "Width = (long) "; - assert(rValue.startsWith(aExpectedWidthPrefix)); + assert(o3tl::starts_with(rValue, aExpectedWidthPrefix)); sal_Int32 nIndex = strlen(aExpectedWidthPrefix); - aSize.Width = rValue.getToken(0, ',', nIndex).toInt32(); + aSize.Width = o3tl::toInt32(o3tl::getToken(rValue, 0, ',', nIndex)); static const char aExpectedHeightPrefix[] = " Height = (long) "; - assert(nIndex >= 0 && rValue.match(aExpectedHeightPrefix, nIndex)); + assert(nIndex >= 0 && o3tl::starts_with(rValue.substr(nIndex), aExpectedHeightPrefix)); nIndex += strlen(aExpectedHeightPrefix); - aSize.Height = o3tl::toInt32(rValue.subView(nIndex)); + aSize.Height = o3tl::toInt32(rValue.substr(nIndex)); return aSize; } @@ -305,12 +310,13 @@ void lcl_parseHandleRange(std::vector<beans::PropertyValue>& rHandle, const OStr static const char aExpectedVPrefix[] = "Value = (any) { (long) "; assert(rValue.match(aExpectedVPrefix, nIndex)); nIndex += strlen(aExpectedVPrefix); - aParameter.Value <<= rValue.getToken(0, '}', nIndex).toInt32(); + aParameter.Value <<= o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex)); static const char aExpectedTPrefix[] = ", Type = (short) "; assert(nIndex >= 0 && rValue.match(aExpectedTPrefix, nIndex)); nIndex += strlen(aExpectedTPrefix); - aParameter.Type = static_cast<sal_Int16>(rValue.getToken(0, '}', nIndex).toInt32()); + aParameter.Type + = static_cast<sal_Int16>(o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex))); beans::PropertyValue aPropertyValue; aPropertyValue.Name = rName; @@ -339,7 +345,7 @@ void lcl_parseHandleRef(std::vector<beans::PropertyValue>& rHandle, const OStrin beans::PropertyValue aPropertyValue; aPropertyValue.Name = rName; // We only expect a Value here - aPropertyValue.Value <<= rValue.getToken(0, '}', nIndex).toInt32(); + aPropertyValue.Value <<= o3tl::toInt32(o3tl::getToken(rValue, 0, '}', nIndex)); rHandle.push_back(aPropertyValue); } else @@ -459,7 +465,7 @@ void lcl_parsePathCoordinateValues(std::vector<beans::PropertyValue>& rPath, con nLevel--; if (!nLevel) aPairs.push_back(lcl_parseEnhancedCustomShapeParameterPair( - rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },")))); + rValue.subView(nStart + strlen("{ "), i - nStart - strlen(" },")))); } } @@ -526,7 +532,7 @@ void lcl_parsePathGluePointsValues(std::vector<beans::PropertyValue>& rPath, con nLevel--; if (!nLevel) aPairs.push_back(lcl_parseEnhancedCustomShapeParameterPair( - rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },")))); + rValue.subView(nStart + strlen("{ "), i - nStart - strlen(" },")))); } } @@ -591,7 +597,7 @@ void lcl_parsePathSegmentValues(std::vector<beans::PropertyValue>& rPath, const nLevel--; if (!nLevel) aSegments.push_back(lcl_parseEnhancedCustomShapeSegment( - rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },")))); + rValue.subView(nStart + strlen("{ "), i - nStart - strlen(" },")))); } } @@ -724,8 +730,8 @@ void lcl_parsePathSubViewSizeValues(std::vector<beans::PropertyValue>& rPath, co { nLevel--; if (!nLevel) - aSizes.push_back( - lcl_parseSize(rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },")))); + aSizes.push_back(lcl_parseSize( + rValue.subView(nStart + strlen("{ "), i - nStart - strlen(" },")))); } } diff --git a/oox/source/ppt/comments.cxx b/oox/source/ppt/comments.cxx index 8034a3978b45..a255dd010950 100644 --- a/oox/source/ppt/comments.cxx +++ b/oox/source/ppt/comments.cxx @@ -11,6 +11,7 @@ #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <rtl/math.h> #include <rtl/math.hxx> +#include <o3tl/string_view.hxx> namespace oox::ppt { @@ -33,7 +34,7 @@ void CommentAuthorList::setValues(const CommentAuthorList& list) void Comment::setDateTime(const OUString& sDateTime) { sal_Int32 nIdx{ 0 }; - aDateTime.Year = sDateTime.getToken(0, '-', nIdx).toInt32(); + aDateTime.Year = o3tl::toInt32(o3tl::getToken(sDateTime, 0, '-', nIdx)); aDateTime.Month = sDateTime.getToken(0, '-', nIdx).toUInt32(); aDateTime.Day = sDateTime.getToken(0, 'T', nIdx).toUInt32(); aDateTime.Hours = sDateTime.getToken(0, ':', nIdx).toUInt32(); diff --git a/oox/source/ppt/pptfilterhelpers.cxx b/oox/source/ppt/pptfilterhelpers.cxx index 23aae31c2212..fff1d3ddd3b5 100644 --- a/oox/source/ppt/pptfilterhelpers.cxx +++ b/oox/source/ppt/pptfilterhelpers.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <oox/ppt/pptfilterhelpers.hxx> #include <tools/color.hxx> +#include <o3tl/string_view.hxx> namespace { int lcl_gethex(int nChar) @@ -288,20 +289,20 @@ namespace oox::ppt { Color aColor; sal_Int32 index = 0; aColor.SetRed( - static_cast<sal_uInt8>(aString.getToken(0, ',', index).toInt32())); + static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)))); aColor.SetGreen( - static_cast<sal_uInt8>(aString.getToken(0, ',', index).toInt32())); + static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)))); aColor.SetRed( - static_cast<sal_uInt8>(aString.getToken(0, ',', index).toInt32())); + static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)))); rValue <<= aColor; bRet = true; } else if (aString.startsWith("hsl(")) { sal_Int32 index = 0; - sal_Int32 nA = aString.getToken(0, ',', index).toInt32(); - sal_Int32 nB = aString.getToken(0, ',', index).toInt32(); - sal_Int32 nC = aString.getToken(0, ',', index).toInt32(); + sal_Int32 nA = o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)); + sal_Int32 nB = o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)); + sal_Int32 nC = o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)); css::uno::Sequence<double> aHSL { nA * 360.0 / 255.0, diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 5967e7be0f34..2143647edec1 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -581,7 +581,7 @@ void lclGetDmlLineDash( OptValue< sal_Int32 >& oroPresetDash, LineProperties::Da ::std::vector< sal_Int32 > aValues; sal_Int32 nIndex = 0; while( nIndex >= 0 ) - aValues.push_back( rDashStyle.getToken( 0, ' ', nIndex ).toInt32() ); + aValues.push_back( o3tl::toInt32(o3tl::getToken(rDashStyle, 0, ' ', nIndex )) ); size_t nPairs = aValues.size() / 2; // ignore last value if size is odd for( size_t nPairIdx = 0; nPairIdx < nPairs; ++nPairIdx ) orCustomDash.emplace_back( aValues[ 2 * nPairIdx ], aValues[ 2 * nPairIdx + 1 ] ); diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index c5ccb9346289..188e3303449c 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -1020,7 +1020,7 @@ Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>& if ( !sArcsize.isEmpty( ) ) { sal_Unicode cLastChar = sArcsize[sArcsize.getLength() - 1]; - sal_Int32 nValue = sArcsize.copy( 0, sArcsize.getLength() - 1 ).toInt32( ); + sal_Int32 nValue = o3tl::toInt32(sArcsize.subView( 0, sArcsize.getLength() - 1 )); // Get the smallest half-side double size = std::min( rShapeRect.Height, rShapeRect.Width ) / 2.0; sal_Int32 nRadius = 0; @@ -1156,11 +1156,11 @@ awt::Rectangle LineShape::getRelRectangle() const awt::Rectangle aShapeRect; sal_Int32 nIndex = 0; - aShapeRect.X = maShapeModel.maFrom.getToken(0, ',', nIndex).toInt32(); - aShapeRect.Y = maShapeModel.maFrom.getToken(0, ',', nIndex).toInt32(); + aShapeRect.X = o3tl::toInt32(o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex)); + aShapeRect.Y = o3tl::toInt32(o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex)); nIndex = 0; - aShapeRect.Width = maShapeModel.maTo.getToken(0, ',', nIndex).toInt32() - aShapeRect.X; - aShapeRect.Height = maShapeModel.maTo.getToken(0, ',', nIndex).toInt32() - aShapeRect.Y; + aShapeRect.Width = o3tl::toInt32(o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex)) - aShapeRect.X; + aShapeRect.Height = o3tl::toInt32(o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex)) - aShapeRect.Y; return aShapeRect; } diff --git a/opencl/source/openclconfig.cxx b/opencl/source/openclconfig.cxx index 525ef84ced6f..0c3597620d8e 100644 --- a/opencl/source/openclconfig.cxx +++ b/opencl/source/openclconfig.cxx @@ -19,6 +19,7 @@ #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> #include <sal/types.h> +#include <o3tl/string_view.hxx> OpenCLConfig::OpenCLConfig() : mbUseOpenCL(true) @@ -80,7 +81,7 @@ OUString getToken(const OUString& string, sal_Int32& index) result.append(token.subView(i, p - i)); if (p < token.getLength() - 2) { - result.append(sal_Unicode(token.copy(p+1, 2).toInt32(16))); + result.append(sal_Unicode(o3tl::toInt32(token.subView(p+1, 2), 16))); i = p + 3; } else diff --git a/sc/source/filter/inc/drawingbase.hxx b/sc/source/filter/inc/drawingbase.hxx index f42700959f94..7ced93b73a99 100644 --- a/sc/source/filter/inc/drawingbase.hxx +++ b/sc/source/filter/inc/drawingbase.hxx @@ -90,7 +90,7 @@ public: /** Sets an attribute of the cell-dependent anchor position from xdr:from and xdr:to elements. */ void setCellPos( sal_Int32 nElement, sal_Int32 nParentContext, const OUString& rValue ); /** Imports the client anchor settings from a VML element. */ - void importVmlAnchor( const OUString& rAnchor ); + void importVmlAnchor( std::u16string_view rAnchor ); /** Checks whether the shape is visible based on the anchor diff --git a/sc/source/filter/oox/drawingbase.cxx b/sc/source/filter/oox/drawingbase.cxx index f946e4cc5950..dbde579be303 100644 --- a/sc/source/filter/oox/drawingbase.cxx +++ b/sc/source/filter/oox/drawingbase.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/awt/Rectangle.hpp> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <oox/helper/attributelist.hxx> #include <unitconverter.hxx> #include <oox/token/namespaces.hxx> @@ -148,7 +149,7 @@ void ShapeAnchor::setCellPos( sal_Int32 nElement, sal_Int32 nParentContext, cons } } -void ShapeAnchor::importVmlAnchor( const OUString& rAnchor ) +void ShapeAnchor::importVmlAnchor( std::u16string_view rAnchor ) { meAnchorType = ANCHOR_VML; meCellAnchorType = CellAnchorType::Pixel; @@ -158,7 +159,7 @@ void ShapeAnchor::importVmlAnchor( const OUString& rAnchor ) for(sal_Int32 nIndex{ 0 }; nIndex>=0;) { - nValues[nI] = rAnchor.getToken( 0, ',', nIndex ).toInt32(); + nValues[nI] = o3tl::toInt32(o3tl::getToken(rAnchor, 0, ',', nIndex )); if (++nI==8) { maFrom.mnCol = nValues[0]; 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); diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 55a6bbd16bdd..2b1b7bad57bb 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -511,7 +511,7 @@ void lcl_GetColumnTypes( } if ( bTypeDefined && !nFieldLen && nIdx>0 ) { - nFieldLen = aString.getToken( 0, ',', nIdx ).toInt32(); + nFieldLen = o3tl::toInt32(o3tl::getToken(aString, 0, ',', nIdx )); if ( !bPrecDefined && nIdx>0 ) { OUString aTmp( aString.getToken( 0, ',', nIdx ) ); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index bbc4f014eb18..422b1b0884e9 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -2086,7 +2086,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) case 'X': { bInvalidCol = false; - bool bFail = o3tl::checked_add<SCCOL>(OUString(p).toInt32(), nStartCol - 1, nCol); + bool bFail = o3tl::checked_add<SCCOL>(o3tl::toInt32(std::u16string_view(p)), nStartCol - 1, nCol); if (bFail || nCol < 0 || rDoc.MaxCol() < nCol) { SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol); @@ -2098,7 +2098,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) case 'Y': { bInvalidRow = false; - bool bFail = o3tl::checked_add(OUString(p).toInt32(), nStartRow - 1, nRow); + bool bFail = o3tl::checked_add(o3tl::toInt32(std::u16string_view(p)), nStartRow - 1, nRow); if (bFail || nRow < 0 || nMaxImportRow < nRow) { SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow); @@ -2110,7 +2110,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) case 'C': { bInvalidRefCol = false; - bool bFail = o3tl::checked_add<SCCOL>(OUString(p).toInt32(), nStartCol - 1, nRefCol); + bool bFail = o3tl::checked_add<SCCOL>(o3tl::toInt32(std::u16string_view(p)), nStartCol - 1, nRefCol); if (bFail || nRefCol < 0 || rDoc.MaxCol() < nRefCol) { SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;C invalid nRefCol=" << nRefCol); @@ -2122,7 +2122,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) case 'R': { bInvalidRefRow = false; - bool bFail = o3tl::checked_add(OUString(p).toInt32(), nStartRow - 1, nRefRow); + bool bFail = o3tl::checked_add(o3tl::toInt32(std::u16string_view(p)), nStartRow - 1, nRefRow); if (bFail || nRefRow < 0 || nMaxImportRow < nRefRow) { SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;R invalid nRefRow=" << nRefRow); @@ -2247,7 +2247,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) case 'X': { bInvalidCol = false; - bool bFail = o3tl::checked_add<SCCOL>(OUString(p).toInt32(), nStartCol - 1, nCol); + bool bFail = o3tl::checked_add<SCCOL>(o3tl::toInt32(std::u16string_view(p)), nStartCol - 1, nCol); if (bFail || nCol < 0 || rDoc.MaxCol() < nCol) { SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol); @@ -2259,7 +2259,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) case 'Y': { bInvalidRow = false; - bool bFail = o3tl::checked_add(OUString(p).toInt32(), nStartRow - 1, nRow); + bool bFail = o3tl::checked_add(o3tl::toInt32(std::u16string_view(p)), nStartRow - 1, nRow); if (bFail || nRow < 0 || nMaxImportRow < nRow) { SAL_WARN("sc.ui","ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow); diff --git a/sc/source/ui/miscdlgs/sharedocdlg.cxx b/sc/source/ui/miscdlgs/sharedocdlg.cxx index ec019fb70655..4fd2137b519c 100644 --- a/sc/source/ui/miscdlgs/sharedocdlg.cxx +++ b/sc/source/ui/miscdlgs/sharedocdlg.cxx @@ -24,6 +24,7 @@ #include <svl/sharecontrolfile.hxx> #include <unotools/useroptions.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <docsh.hxx> @@ -141,12 +142,12 @@ void ScShareDocumentDlg::UpdateView() OUString aDateStr = aDateTimeStr.getToken( 0, ' ', nIndex ); OUString aTimeStr = aDateTimeStr.getToken( 0, ' ', nIndex ); nIndex = 0; - sal_uInt16 nDay = sal::static_int_cast< sal_uInt16 >( aDateStr.getToken( 0, '.', nIndex ).toInt32() ); - sal_uInt16 nMonth = sal::static_int_cast< sal_uInt16 >( aDateStr.getToken( 0, '.', nIndex ).toInt32() ); - sal_uInt16 nYear = sal::static_int_cast< sal_uInt16 >( aDateStr.getToken( 0, '.', nIndex ).toInt32() ); + sal_uInt16 nDay = sal::static_int_cast< sal_uInt16 >( o3tl::toInt32(o3tl::getToken(aDateStr, 0, '.', nIndex )) ); + sal_uInt16 nMonth = sal::static_int_cast< sal_uInt16 >( o3tl::toInt32(o3tl::getToken(aDateStr, 0, '.', nIndex )) ); + sal_uInt16 nYear = sal::static_int_cast< sal_uInt16 >( o3tl::toInt32(o3tl::getToken(aDateStr, 0, '.', nIndex )) ); nIndex = 0; - sal_uInt16 nHours = sal::static_int_cast< sal_uInt16 >( aTimeStr.getToken( 0, ':', nIndex ).toInt32() ); - sal_uInt16 nMinutes = sal::static_int_cast< sal_uInt16 >( aTimeStr.getToken( 0, ':', nIndex ).toInt32() ); + sal_uInt16 nHours = sal::static_int_cast< sal_uInt16 >( o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', nIndex )) ); + sal_uInt16 nMinutes = sal::static_int_cast< sal_uInt16 >( o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', nIndex )) ); Date aDate( nDay, nMonth, nYear ); tools::Time aTime( nHours, nMinutes ); DateTime aDateTime( aDate, aTime ); diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx index 85cf20d014f3..c9910cc1db82 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -23,6 +23,7 @@ #include <sfx2/dispatch.hxx> #include <svl/intitem.hxx> #include <svl/stritem.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> using namespace css; @@ -233,7 +234,7 @@ void NumberFormatPropertyPanel::NotifyItemUpdate( sal_Int32 aFormat[4] = {0}; for (sal_Int32 & rn : aFormat) { - rn = aCode.getToken(0, ',', nIndex).toInt32(); + rn = o3tl::toInt32(o3tl::getToken(aCode, 0, ',', nIndex)); if (nIndex<0) break; } diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 7604fadb0882..18cae40634d7 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -41,6 +41,7 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/viewfac.hxx> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> #include <drwlayer.hxx> #include <prevwsh.hxx> @@ -921,8 +922,8 @@ void ScPreviewShell::ReadUserData(const OUString& rData, bool /* bBrowse */) if (!rData.isEmpty()) { sal_Int32 nIndex = 0; - pPreview->SetZoom(static_cast<sal_uInt16>(rData.getToken(0, SC_USERDATA_SEP, nIndex).toInt32())); - pPreview->SetPageNo(rData.getToken(0, SC_USERDATA_SEP, nIndex).toInt32()); + pPreview->SetZoom(static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rData, 0, SC_USERDATA_SEP, nIndex)))); + pPreview->SetPageNo(o3tl::toInt32(o3tl::getToken(rData, 0, SC_USERDATA_SEP, nIndex))); eZoom = SvxZoomType::PERCENT; } } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 841f2f6ea4d3..7a9df94d7678 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -3367,12 +3367,12 @@ void ScViewData::ReadUserData(const OUString& rData) if (cTabSep) { nIdx = 0; - maTabData[nPos]->nCurX = mrDoc.SanitizeCol(static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32())); - maTabData[nPos]->nCurY = mrDoc.SanitizeRow(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()); - maTabData[nPos]->eHSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()); - maTabData[nPos]->eVSplitMode = static_cast<ScSplitMode>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()); + maTabData[nPos]->nCurX = mrDoc.SanitizeCol(static_cast<SCCOL>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)))); + maTabData[nPos]->nCurY = mrDoc.SanitizeRow(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))); + maTabData[nPos]->eHSplitMode = static_cast<ScSplitMode>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))); + maTabData[nPos]->eVSplitMode = static_cast<ScSplitMode>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))); - sal_Int32 nTmp{ aTabOpt.getToken(0, cTabSep, nIdx).toInt32() }; + sal_Int32 nTmp = o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)); if ( maTabData[nPos]->eHSplitMode == SC_SPLIT_FIX ) { maTabData[nPos]->nFixPosX = mrDoc.SanitizeCol(static_cast<SCCOL>(nTmp)); @@ -3381,7 +3381,7 @@ void ScViewData::ReadUserData(const OUString& rData) else maTabData[nPos]->nHSplitPos = nTmp; - nTmp = aTabOpt.getToken(0, cTabSep, nIdx).toInt32(); + nTmp = o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)); if ( maTabData[nPos]->eVSplitMode == SC_SPLIT_FIX ) { maTabData[nPos]->nFixPosY = mrDoc.SanitizeRow(nTmp); @@ -3390,11 +3390,11 @@ void ScViewData::ReadUserData(const OUString& rData) else maTabData[nPos]->nVSplitPos = nTmp; - maTabData[nPos]->eWhichActive = static_cast<ScSplitPos>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()); - maTabData[nPos]->nPosX[0] = mrDoc.SanitizeCol(static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32())); - maTabData[nPos]->nPosX[1] = mrDoc.SanitizeCol(static_cast<SCCOL>(aTabOpt.getToken(0, cTabSep, nIdx).toInt32())); - maTabData[nPos]->nPosY[0] = mrDoc.SanitizeRow(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()); - maTabData[nPos]->nPosY[1] = mrDoc.SanitizeRow(aTabOpt.getToken(0, cTabSep, nIdx).toInt32()); + maTabData[nPos]->eWhichActive = static_cast<ScSplitPos>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))); + maTabData[nPos]->nPosX[0] = mrDoc.SanitizeCol(static_cast<SCCOL>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)))); + maTabData[nPos]->nPosX[1] = mrDoc.SanitizeCol(static_cast<SCCOL>(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx)))); + maTabData[nPos]->nPosY[0] = mrDoc.SanitizeRow(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))); + maTabData[nPos]->nPosY[1] = mrDoc.SanitizeRow(o3tl::toInt32(o3tl::getToken(aTabOpt, 0, cTabSep, nIdx))); maTabData[nPos]->eWhichActive = maTabData[nPos]->SanitizeWhichActive(); } diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx index eedae722a5a4..66a13be8ed74 100644 --- a/sd/source/ui/dlg/copydlg.cxx +++ b/sd/source/ui/dlg/copydlg.cxx @@ -27,6 +27,7 @@ #include <unotools/viewoptions.hxx> #include <svtools/unitconv.hxx> +#include <o3tl/string_view.hxx> #include <sdattr.hrc> #include <View.hxx> @@ -162,12 +163,12 @@ void CopyDlg::Reset() else { sal_Int32 nIdx {0}; - m_xNumFldCopies->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64()); - m_xMtrFldMoveX->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE); - m_xMtrFldMoveY->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE); - m_xMtrFldAngle->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE); - m_xMtrFldWidth->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE); - m_xMtrFldHeight->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE); + m_xNumFldCopies->set_value(o3tl::toInt64(o3tl::getToken(aStr, 0, TOKEN, nIdx))); + m_xMtrFldMoveX->set_value(o3tl::toInt64(o3tl::getToken(aStr, 0, TOKEN, nIdx)), FieldUnit::NONE); + m_xMtrFldMoveY->set_value(o3tl::toInt64(o3tl::getToken(aStr, 0, TOKEN, nIdx)), FieldUnit::NONE); + m_xMtrFldAngle->set_value(o3tl::toInt64(o3tl::getToken(aStr, 0, TOKEN, nIdx)), FieldUnit::NONE); + m_xMtrFldWidth->set_value(o3tl::toInt64(o3tl::getToken(aStr, 0, TOKEN, nIdx)), FieldUnit::NONE); + m_xMtrFldHeight->set_value(o3tl::toInt64(o3tl::getToken(aStr, 0, TOKEN, nIdx)), FieldUnit::NONE); m_xLbStartColor->SelectEntry( Color( ColorTransparency, aStr.getToken(0, TOKEN, nIdx).toUInt32() ) ); m_xLbEndColor->SelectEntry( Color( ColorTransparency, aStr.getToken(0, TOKEN, nIdx).toUInt32() ) ); } diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx index 8b98f2a5faaf..92ecf16e09e1 100644 --- a/sdext/source/minimizer/optimizerdialogcontrols.cxx +++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/frame/XStorable.hpp> #include <rtl/ustrbuf.hxx> #include <sal/macros.h> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star::awt; using namespace ::com::sun::star::uno; @@ -480,7 +481,7 @@ namespace bool lcl_getResolutionText(OUString& rResolutionText, const OUString& rImageResolution, sal_Int32 nTargetRes) { sal_Int32 nIdx{ 0 }; - if (rImageResolution.getToken(0, ';', nIdx).toInt32()!=nTargetRes) + if (o3tl::toInt32(o3tl::getToken(rImageResolution, 0, ';', nIdx))!=nTargetRes) return false; rResolutionText = rImageResolution.getToken(0, ';', nIdx); return true; diff --git a/sdext/source/pdfimport/test/pdfunzip.cxx b/sdext/source/pdfimport/test/pdfunzip.cxx index 3e2e614a9327..86797056e841 100644 --- a/sdext/source/pdfimport/test/pdfunzip.cxx +++ b/sdext/source/pdfimport/test/pdfunzip.cxx @@ -27,6 +27,7 @@ #include <rtl/alloc.h> #include <rtl/ustring.hxx> #include <rtl/strbuf.hxx> +#include <o3tl/string_view.hxx> #include <pdfparse.hxx> @@ -478,9 +479,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) sal_Int32 nObject = 0; sal_Int32 nGeneration = 0; sal_Int32 nGenIndex = 0; - nObject = aToken.getToken( 0, ':', nGenIndex ).toInt32(); + nObject = o3tl::toInt32( o3tl::getToken( aToken, 0, ':', nGenIndex ) ); if( nGenIndex != -1 ) - nGeneration = aToken.getToken( 0, ':', nGenIndex ).toInt32(); + nGeneration = o3tl::toInt32( o3tl::getToken(aToken, 0, ':', nGenIndex )); s_aEmitObjects.push_back( std::pair<sal_Int32,sal_Int32>(nObject,nGeneration) ); } } diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index 097ab1a5aee7..5cc448b2ccc3 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -106,16 +106,16 @@ class DisposeListener : public ::cppu::WeakImplHelper< css::lang::XEventListener } -bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize ) +bool GetPosSizeFromString( std::u16string_view rStr, Point& rPos, Size& rSize ) { if ( comphelper::string::getTokenCount(rStr, '/') != 4 ) return false; sal_Int32 nIdx = 0; - rPos.setX( rStr.getToken(0, '/', nIdx).toInt32() ); - rPos.setY( rStr.getToken(0, '/', nIdx).toInt32() ); - rSize.setWidth( rStr.getToken(0, '/', nIdx).toInt32() ); - rSize.setHeight( rStr.getToken(0, '/', nIdx).toInt32() ); + rPos.setX( o3tl::toInt32(o3tl::getToken(rStr, 0, '/', nIdx)) ); + rPos.setY( o3tl::toInt32(o3tl::getToken(rStr, 0, '/', nIdx)) ); + rSize.setWidth( o3tl::toInt32(o3tl::getToken(rStr, 0, '/', nIdx)) ); + rSize.setHeight( o3tl::toInt32(o3tl::getToken(rStr, 0, '/', nIdx)) ); // negative sizes are invalid return rSize.Width() >= 0 && rSize.Height() >= 0; @@ -133,8 +133,8 @@ bool GetSplitSizeFromString( const OUString& rStr, Size& rSize ) return false; sal_Int32 nIdx{ 0 }; - rSize.setWidth( aStr.getToken(0, ';', nIdx ).toInt32() ); - rSize.setHeight( aStr.getToken(0, ';', nIdx ).toInt32() ); + rSize.setWidth( o3tl::toInt32(o3tl::getToken(aStr, 0, ';', nIdx )) ); + rSize.setHeight( o3tl::toInt32(o3tl::getToken(aStr, 0, ';', nIdx )) ); // negative sizes are invalid return rSize.Width() >= 0 && rSize.Height() >= 0; diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index e175b7458726..58818c3a248d 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -933,9 +933,9 @@ SearchTabPage_Impl::SearchTabPage_Impl(weld::Widget* pParent, SfxHelpIndexWindow if ( aUserItem >>= aUserData ) { sal_Int32 nIdx {0}; - bool bChecked = aUserData.getToken(0, ';', nIdx).toInt32() == 1; + bool bChecked = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) == 1; m_xFullWordsCB->set_active(bChecked); - bChecked = aUserData.getToken(0, ';', nIdx).toInt32() == 1; + bChecked = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) == 1; m_xScopeCB->set_active(bChecked); while ( nIdx > 0 ) @@ -2257,13 +2257,13 @@ void SfxHelpWindow_Impl::LoadConfig() { DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" ); sal_Int32 nIdx = 0; - nIndexSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); + nIndexSize = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx )); aUserData.getToken(0, ';', nIdx); // ignore nTextSize - sal_Int32 nOldWidth = aUserData.getToken( 0, ';', nIdx ).toInt32(); - sal_Int32 nOldHeight = aUserData.getToken( 0, ';', nIdx ).toInt32(); + sal_Int32 nOldWidth = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx )); + sal_Int32 nOldHeight = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx )); aWinSize = Size(nOldWidth, nOldHeight); - aWinPos.setX( aUserData.getToken( 0, ';', nIdx ).toInt32() ); - aWinPos.setY( aUserData.getToken( 0, ';', nIdx ).toInt32() ); + aWinPos.setX( o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx )) ); + aWinPos.setY( o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx )) ); } pTextWin->ToggleIndex( bIndex ); diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx index 9805fed0aa0f..9116ae8efa32 100644 --- a/sfx2/source/bastyp/sfxhtml.cxx +++ b/sfx2/source/bastyp/sfxhtml.cxx @@ -38,6 +38,7 @@ #include <sfx2/sfxhtml.hxx> #include <comphelper/string.hxx> +#include <o3tl/string_view.hxx> #include <vector> @@ -323,7 +324,7 @@ double SfxHTMLParser::GetTableDataOptionsValNum( sal_uInt32& nNumForm, if ( comphelper::string::getTokenCount(aNumStr, ';') > 2 ) { sal_Int32 nIdx {0}; - eNumLang = LanguageType(aNumStr.getToken( 1, ';', nIdx ).toInt32()); + eNumLang = LanguageType(o3tl::toInt32(o3tl::getToken(aNumStr, 1, ';', nIdx ))); OUString aFormat( aNumStr.copy( nIdx ) ); sal_Int32 nCheckPos; SvNumFormatType nType; diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 5b0ee7e97b9d..364943f832b3 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -91,6 +91,7 @@ #include <sal/log.hxx> #include <comphelper/sequence.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <officecfg/Office/Common.hxx> #ifdef UNX @@ -2201,12 +2202,12 @@ void FileDialogHelper_Impl::loadConfig() try { // respect the last "insert as link" state - bool bLink = aUserData.getToken( 0, ' ' ).toInt32(); + bool bLink = o3tl::toInt32(o3tl::getToken(aUserData, 0, ' ' )); aValue <<= bLink; xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aValue ); // respect the last "show preview" state - bool bShowPreview = aUserData.getToken( 1, ' ' ).toInt32(); + bool bShowPreview = o3tl::toInt32(o3tl::getToken(aUserData, 1, ' ' )); aValue <<= bShowPreview; xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, aValue ); @@ -2250,7 +2251,7 @@ void FileDialogHelper_Impl::loadConfig() if ( mbHasAutoExt ) { - sal_Int32 nFlag = aUserData.getToken( 0, ' ' ).toInt32(); + sal_Int32 nFlag = o3tl::toInt32(o3tl::getToken(aUserData, 0, ' ' )); aValue <<= static_cast<bool>(nFlag); try { @@ -2261,7 +2262,7 @@ void FileDialogHelper_Impl::loadConfig() if( mbHasSelectionBox ) { - sal_Int32 nFlag = aUserData.getToken( 2, ' ' ).toInt32(); + sal_Int32 nFlag = o3tl::toInt32(o3tl::getToken(aUserData, 2, ' ' )); aValue <<= static_cast<bool>(nFlag); try { diff --git a/sfx2/source/dialog/splitwin.cxx b/sfx2/source/dialog/splitwin.cxx index 0255c8c8a7d0..f1afa3b08664 100644 --- a/sfx2/source/dialog/splitwin.cxx +++ b/sfx2/source/dialog/splitwin.cxx @@ -34,6 +34,7 @@ #include <splitwin.hxx> #include <workwin.hxx> #include <sfx2/dockwin.hxx> +#include <o3tl/string_view.hxx> #include <memory> #include <vector> @@ -233,23 +234,23 @@ SfxSplitWindow::SfxSplitWindow( vcl::Window* pParent, SfxChildAlignment eAl, if ( aWinData.startsWith("V") ) { sal_Int32 nIdx{ 0 }; - pEmptyWin->nState = static_cast<sal_uInt16>(aWinData.getToken( 1, ',', nIdx ).toInt32()); + pEmptyWin->nState = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(aWinData, 1, ',', nIdx ))); if ( pEmptyWin->nState & 2 ) pEmptyWin->bFadeIn = true; bPinned = true; // always assume pinned - floating mode not used anymore - const sal_Int32 nCount{ aWinData.getToken(0, ',', nIdx).toInt32() }; + const sal_Int32 nCount{ o3tl::toInt32(o3tl::getToken(aWinData, 0, ',', nIdx)) }; for ( sal_Int32 n=0; n<nCount; ++n ) { std::unique_ptr<SfxDock_Impl> pDock(new SfxDock_Impl); pDock->pWin = nullptr; pDock->bNewLine = false; pDock->bHide = true; - pDock->nType = static_cast<sal_uInt16>(aWinData.getToken(0, ',', nIdx).toInt32()); + pDock->nType = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(aWinData, 0, ',', nIdx))); if ( !pDock->nType ) { // could mean NewLine - pDock->nType = static_cast<sal_uInt16>(aWinData.getToken(0, ',', nIdx).toInt32()); + pDock->nType = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(aWinData, 0, ',', nIdx))); if ( !pDock->nType ) { // Read error diff --git a/sfx2/source/dialog/srchdlg.cxx b/sfx2/source/dialog/srchdlg.cxx index de5bde88d3c6..ea9f8c7766c6 100644 --- a/sfx2/source/dialog/srchdlg.cxx +++ b/sfx2/source/dialog/srchdlg.cxx @@ -23,6 +23,7 @@ #include <tools/debug.hxx> #include <unotools/viewoptions.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star::uno; @@ -70,10 +71,10 @@ void SearchDialog::LoadConfig() DBG_ASSERT( comphelper::string::getTokenCount(sUserData, ';') == 5, "invalid config data" ); sal_Int32 nIdx = 0; OUString sSearchText = sUserData.getToken( 0, ';', nIdx ); - m_xWholeWordsBox->set_active( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); - m_xMatchCaseBox->set_active( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); - m_xWrapAroundBox->set_active( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); - m_xBackwardsBox->set_active( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); + m_xWholeWordsBox->set_active( o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx )) == 1 ); + m_xMatchCaseBox->set_active( o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx )) == 1 ); + m_xWrapAroundBox->set_active( o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx )) == 1 ); + m_xBackwardsBox->set_active( o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx )) == 1 ); nIdx = 0; while ( nIdx != -1 ) diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx index c789538dd4fd..2d94cd3b6621 100644 --- a/sfx2/source/doc/autoredactdialog.cxx +++ b/sfx2/source/doc/autoredactdialog.cxx @@ -152,7 +152,7 @@ OUString TargetsTable::GetNameProposal() const sal_Int32 nIndex = 0; if (o3tl::getToken(sName, 0, ' ', nIndex) == sDefaultTargetName) { - sal_Int32 nCurrTargetId = sName.getToken(0, ' ', nIndex).toInt32(); + sal_Int32 nCurrTargetId = o3tl::toInt32(o3tl::getToken(sName, 0, ' ', nIndex)); nHighestTargetId = std::max<sal_Int32>(nHighestTargetId, nCurrTargetId); } } @@ -729,7 +729,7 @@ SfxAddTargetDialog::SfxAddTargetDialog(weld::Window* pParent, const OUString& sN if (eTargetType == RedactionTargetType::REDACTION_TARGET_PREDEFINED) { SelectTypeHdl(*m_xPredefContent); - m_xPredefContent->set_active(sContent.getToken(0, ';').toInt32()); + m_xPredefContent->set_active(o3tl::toInt32(o3tl::getToken(sContent, 0, ';'))); } else { diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 7d3e2cb8262b..9acfe6d1651b 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1469,7 +1469,7 @@ void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue& rKV ) if( rKV.GetKey().equalsIgnoreAsciiCase("refresh") && !rKV.GetValue().isEmpty() ) { sal_Int32 nIdx{ 0 }; - const sal_Int32 nTime{ aValue.getToken( 0, ';', nIdx ).toInt32() }; + const sal_Int32 nTime{ o3tl::toInt32(o3tl::getToken(aValue, 0, ';', nIdx )) }; const OUString aURL{ comphelper::string::strip(o3tl::getToken(aValue, 0, ';', nIdx ), ' ') }; uno::Reference<document::XDocumentProperties> xDocProps( pDoc->getDocProperties()); diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx index 7ac01619162e..e4e933128485 100644 --- a/svtools/source/misc/imagemgr.cxx +++ b/svtools/source/misc/imagemgr.cxx @@ -36,6 +36,7 @@ #include <ucbhelper/content.hxx> #include <svtools/strings.hrc> #include <svtools/svtresid.hxx> +#include <o3tl/string_view.hxx> #include <bitmaps.hlst> #include <strings.hxx> @@ -388,7 +389,7 @@ static SvImageId GetImageId_Impl( return nImage; } else if ( aType == "image" ) - nImage = static_cast<SvImageId>(aURLPath.getToken( 1, '/' ).toInt32()); + nImage = static_cast<SvImageId>(o3tl::toInt32(o3tl::getToken(aURLPath, 1, '/' ))); } else { diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index 7e589642d0f2..0c6e38ee9295 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -2021,8 +2021,8 @@ bool HTMLParser::ParseMetaOptionsImpl( if (comphelper::string::getTokenCount(aContent, ';') == 2) { sal_Int32 nIdx{ 0 }; - Date aDate(aContent.getToken(0, ';', nIdx).toInt32()); - auto nTime = aContent.getToken(0, ';', nIdx).toInt64(); + Date aDate(o3tl::toInt32(o3tl::getToken(aContent, 0, ';', nIdx))); + auto nTime = o3tl::toInt64(o3tl::getToken(aContent, 0, ';', nIdx)); if (nTime < 0) nTime = o3tl::saturating_toggle_sign(nTime); tools::Time aTime(nTime); diff --git a/svx/source/fmcomp/dbaexchange.cxx b/svx/source/fmcomp/dbaexchange.cxx index 26eaf9ad4894..65b5fb1006a8 100644 --- a/svx/source/fmcomp/dbaexchange.cxx +++ b/svx/source/fmcomp/dbaexchange.cxx @@ -27,6 +27,7 @@ #include <comphelper/extract.hxx> #include <sot/formats.hxx> #include <sot/exchange.hxx> +#include <o3tl/string_view.hxx> namespace svx @@ -329,7 +330,7 @@ namespace svx sal_Int32 nIdx{ 0 }; _rDatasource = sFieldDescription.getToken(0, cSeparator, nIdx); _rCommand = sFieldDescription.getToken(0, cSeparator, nIdx); - _nCommandType = sFieldDescription.getToken(0, cSeparator, nIdx).toInt32(); + _nCommandType = o3tl::toInt32(o3tl::getToken(sFieldDescription, 0, cSeparator, nIdx)); _rFieldName = sFieldDescription.getToken(0, cSeparator, nIdx); return true; diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index 3d59d6f635d6..0463f2e6044b 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -51,6 +51,7 @@ #include <svx/svxids.hrc> #include <vcl/i18nhelp.hxx> #include <vcl/window.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -387,7 +388,7 @@ SdrObjectUniquePtr FmFormView::CreateFieldControl(const OUString& rFieldDesc) co sal_Int32 nIdx{ 0 }; OUString sDataSource = rFieldDesc.getToken(0, u'\x000B', nIdx); OUString sObjectName = rFieldDesc.getToken(0, u'\x000B', nIdx); - sal_uInt16 nObjectType = static_cast<sal_uInt16>(rFieldDesc.getToken(0, u'\x000B', nIdx).toInt32()); + sal_uInt16 nObjectType = static_cast<sal_uInt16>(o3tl::toInt32(o3tl::getToken(rFieldDesc, 0, u'\x000B', nIdx))); OUString sFieldName = rFieldDesc.getToken(0, u'\x000B', nIdx); if (sFieldName.isEmpty() || sObjectName.isEmpty() || sDataSource.isEmpty()) diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 49248a03cf57..d94d51a398a8 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -235,7 +235,7 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u if( pNameOrIndex->GetName().startsWith( aUser ) ) { - sal_Int32 nThisIndex = pNameOrIndex->GetName().copy( aUser.getLength() ).toInt32(); + sal_Int32 nThisIndex = o3tl::toInt32(pNameOrIndex->GetName().subView( aUser.getLength() )); if( nThisIndex >= nUserIndex ) nUserIndex = nThisIndex + 1; } @@ -1236,7 +1236,7 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM if (pItem->GetName().startsWith(aUser)) { - sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength())); if (nThisIndex >= nUserIndex) nUserIndex = nThisIndex + 1; } @@ -1258,7 +1258,7 @@ std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pM if (pItem->GetName().startsWith(aUser)) { - sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength())); if (nThisIndex >= nUserIndex) nUserIndex = nThisIndex + 1; } @@ -1475,7 +1475,7 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel if (pItem->GetName().startsWith(aUser)) { - sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength())); if (nThisIndex >= nUserIndex) nUserIndex = nThisIndex + 1; } @@ -1497,7 +1497,7 @@ std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel if (pItem->GetName().startsWith(aUser)) { - sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + sal_Int32 nThisIndex = o3tl::toInt32(pItem->GetName().subView(aUser.getLength())); if (nThisIndex >= nUserIndex) nUserIndex = nThisIndex + 1; } diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index a31646704cbd..61a8614b4ac2 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -13,6 +13,7 @@ #include <vcl/gdimtf.hxx> #include <svx/svdpage.hxx> +#include <o3tl/string_view.hxx> #include <wrtsh.hxx> #include <docsh.hxx> @@ -446,7 +447,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testVerticallyMergedCellBorder) { xmlNodePtr pXmlNode = pXmlNodes->nodeTab[i]; xmlChar* pValue = xmlGetProp(pXmlNode, BAD_CAST("y")); - sal_Int32 nValue = OString(reinterpret_cast<char const*>(pValue)).toInt32(); + sal_Int32 nValue = o3tl::toInt32(reinterpret_cast<char const*>(pValue)); aBorderPositions.push_back(nValue); } xmlXPathFreeObject(pXmlObj); @@ -461,11 +462,11 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testVerticallyMergedCellBorder) if (i == 0) { xmlChar* pValue = xmlGetProp(pXmlNode, BAD_CAST("top")); - sal_Int32 nValue = OString(reinterpret_cast<char const*>(pValue)).toInt32(); + sal_Int32 nValue = o3tl::toInt32(reinterpret_cast<char const*>(pValue)); aLayoutPositions.push_back(nValue); } xmlChar* pValue = xmlGetProp(pXmlNode, BAD_CAST("bottom")); - sal_Int32 nValue = OString(reinterpret_cast<char const*>(pValue)).toInt32(); + sal_Int32 nValue = o3tl::toInt32(reinterpret_cast<char const*>(pValue)); aLayoutPositions.push_back(nValue); } xmlXPathFreeObject(pXmlObj); @@ -548,8 +549,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testInnerCellBorderIntersect) xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); - sal_Int32 nStartY = OString(reinterpret_cast<char const*>(pStartY)).toInt32(); - sal_Int32 nEndY = OString(reinterpret_cast<char const*>(pEndY)).toInt32(); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast<char const*>(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast<char const*>(pEndY)); if (nStartY != nEndY) { // Vertical border. @@ -557,8 +558,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testInnerCellBorderIntersect) } xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x")); xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x")); - sal_Int32 nStartX = OString(reinterpret_cast<char const*>(pStartX)).toInt32(); - sal_Int32 nEndX = OString(reinterpret_cast<char const*>(pEndX)).toInt32(); + sal_Int32 nStartX = o3tl::toInt32(reinterpret_cast<char const*>(pStartX)); + sal_Int32 nEndX = o3tl::toInt32(reinterpret_cast<char const*>(pEndX)); aBorderStartEnds.emplace_back(nStartX, nEndX); } xmlXPathFreeObject(pXmlObj); @@ -602,15 +603,15 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testDoubleBorderVertical) xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x")); xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x")); - sal_Int32 nStartX = OString(reinterpret_cast<char const*>(pStartX)).toInt32(); - sal_Int32 nEndX = OString(reinterpret_cast<char const*>(pEndX)).toInt32(); + sal_Int32 nStartX = o3tl::toInt32(reinterpret_cast<char const*>(pStartX)); + sal_Int32 nEndX = o3tl::toInt32(reinterpret_cast<char const*>(pEndX)); if (nStartX != nEndX) { // Horizontal border. continue; } xmlChar* pWidth = xmlGetProp(pStart->parent, BAD_CAST("width")); - sal_Int32 nWidth = OString(reinterpret_cast<char const*>(pWidth)).toInt32(); + sal_Int32 nWidth = o3tl::toInt32(reinterpret_cast<char const*>(pWidth)); aBorderWidths[nStartX] = nWidth; } xmlXPathFreeObject(pXmlObj); @@ -650,15 +651,15 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testDoubleBorderHorizontal) xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); - sal_Int32 nStartY = OString(reinterpret_cast<char const*>(pStartY)).toInt32(); - sal_Int32 nEndY = OString(reinterpret_cast<char const*>(pEndY)).toInt32(); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast<char const*>(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast<char const*>(pEndY)); if (nStartY != nEndY) { // Vertical border. continue; } xmlChar* pWidth = xmlGetProp(pStart->parent, BAD_CAST("width")); - sal_Int32 nWidth = OString(reinterpret_cast<char const*>(pWidth)).toInt32(); + sal_Int32 nWidth = o3tl::toInt32(reinterpret_cast<char const*>(pWidth)); aBorderWidths[nStartY] = nWidth; } xmlXPathFreeObject(pXmlObj); @@ -718,15 +719,15 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testDoublePageBorder) xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); - sal_Int32 nStartY = OString(reinterpret_cast<char const*>(pStartY)).toInt32(); - sal_Int32 nEndY = OString(reinterpret_cast<char const*>(pEndY)).toInt32(); + sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast<char const*>(pStartY)); + sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast<char const*>(pEndY)); if (nStartY != nEndY) { // Vertical border. continue; } xmlChar* pWidth = xmlGetProp(pStart->parent, BAD_CAST("width")); - sal_Int32 nWidth = OString(reinterpret_cast<char const*>(pWidth)).toInt32(); + sal_Int32 nWidth = o3tl::toInt32(reinterpret_cast<char const*>(pWidth)); aBorderWidths[nStartY] = nWidth; } xmlXPathFreeObject(pXmlObj); diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 61199249604c..6c059f0f57c4 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -17,6 +17,7 @@ #include <comphelper/sequence.hxx> #include <unotools/syslocaleoptions.hxx> #include <editeng/unolingu.hxx> +#include <o3tl/string_view.hxx> #include <unotxdoc.hxx> #include <rootfrm.hxx> @@ -966,15 +967,11 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf69648) const auto nComaPos2 = sDrawRect.indexOf(',', nComaPos1 + 1); const auto nComaPos3 = sDrawRect.indexOf(',', nComaPos2 + 1); - const auto nDraw1 = OUString(sDrawRect.subView(0, nComaPos1).data()).toInt64(); - const auto nDraw2 - = OUString(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1).data()).toInt64(); - const auto nDraw3 - = OUString(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2).data()).toInt64(); - const auto nDraw4 - = OUString( - sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1).data()) - .toInt64(); + const auto nDraw1 = o3tl::toInt64(sDrawRect.subView(0, nComaPos1)); + const auto nDraw2 = o3tl::toInt64(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1)); + const auto nDraw3 = o3tl::toInt64(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2)); + const auto nDraw4 = o3tl::toInt64( + sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1)); const auto aChildShape = SwRect(nDraw1, nDraw2, nDraw3, nDraw4); const auto nFlyLeft = getXPath(pXmlDoc, sFrameXPath[i], "left").toInt64(); diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index b4819567138e..30264306668f 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -28,6 +28,7 @@ #include <tools/json_writer.hxx> #include <unotools/streamwrap.hxx> #include <sfx2/linkmgr.hxx> +#include <o3tl/string_view.hxx> #include <view.hxx> #include <wrtsh.hxx> @@ -274,15 +275,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147126) const auto nComaPos2 = sDrawRect.indexOf(',', nComaPos1 + 1); const auto nComaPos3 = sDrawRect.indexOf(',', nComaPos2 + 1); - const auto nDraw1 = OUString(sDrawRect.subView(0, nComaPos1).data()).toInt64(); - const auto nDraw2 - = OUString(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1).data()).toInt64(); - const auto nDraw3 - = OUString(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2).data()).toInt64(); - const auto nDraw4 - = OUString( - sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1).data()) - .toInt64(); + const auto nDraw1 = o3tl::toInt64(sDrawRect.subView(0, nComaPos1)); + const auto nDraw2 = o3tl::toInt64(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1)); + const auto nDraw3 = o3tl::toInt64(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2)); + const auto nDraw4 = o3tl::toInt64( + sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1)); CPPUNIT_ASSERT_GREATER(nDraw1, nFlyLeft); CPPUNIT_ASSERT_GREATER(nDraw2, nFlyTop); @@ -342,15 +339,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147126) const auto nComaPos2 = sDrawRect.indexOf(',', nComaPos1 + 1); const auto nComaPos3 = sDrawRect.indexOf(',', nComaPos2 + 1); - const auto nDraw1 = OUString(sDrawRect.subView(0, nComaPos1).data()).toInt64(); - const auto nDraw2 - = OUString(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1).data()).toInt64(); - const auto nDraw3 - = OUString(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2).data()).toInt64(); - const auto nDraw4 - = OUString( - sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1).data()) - .toInt64(); + const auto nDraw1 = o3tl::toInt64(sDrawRect.subView(0, nComaPos1)); + const auto nDraw2 = o3tl::toInt64(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1)); + const auto nDraw3 = o3tl::toInt64(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2)); + const auto nDraw4 = o3tl::toInt64( + sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1)); CPPUNIT_ASSERT_GREATER(nDraw1, nFlyLeft); CPPUNIT_ASSERT_GREATER(nDraw2, nFlyTop); 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 ) diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx index c7d80bf43633..0f4c6aa5f947 100644 --- a/toolkit/source/awt/vclxprinter.cxx +++ b/toolkit/source/awt/vclxprinter.cxx @@ -29,6 +29,7 @@ #include <tools/debug.hxx> #include <tools/stream.hxx> +#include <o3tl/string_view.hxx> #include <toolkit/awt/vclxdevice.hxx> @@ -200,7 +201,7 @@ void VCLXPrinterPropertySet::selectForm( const OUString& rFormDescription ) ::osl::MutexGuard aGuard( Mutex ); sal_uInt16 nPaperBin = sal::static_int_cast< sal_uInt16 >( - rFormDescription.getToken( 3, ';' ).toInt32()); + o3tl::toInt32(o3tl::getToken(rFormDescription, 3, ';' ))); GetPrinter()->SetPaperBin( nPaperBin ); } diff --git a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx index a236957c096e..41f9a8232748 100644 --- a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx +++ b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx @@ -36,6 +36,7 @@ #include <rtl/ref.hxx> #include <rtl/uri.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> using namespace com::sun::star; using namespace http_dav_ucp; @@ -684,7 +685,7 @@ namespace if (sTimeout == "Infinite") maLock.Timeout = -1; else if (sTimeout.startsWith("Second-")) - maLock.Timeout = sTimeout.copy(7).toInt64(); + maLock.Timeout = o3tl::toInt64(sTimeout.subView(7)); break; } case WebDAVName_locktoken: diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 7fe9e482936b..b3f132014a71 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -2393,17 +2393,17 @@ bool TimeFormatter::TextToTime(std::u16string_view rStr, tools::Time& rTime, return false; if ( !aStr.isEmpty() && aStr[0] == '-' ) bNegative = true; - nNanoSec = aStr.toString().toInt64(); + nNanoSec = o3tl::toInt64(aStr); } else - nSecond = static_cast<short>(aStr.toString().toInt32()); + nSecond = static_cast<short>(o3tl::toInt32(aStr)); } else - nMinute = static_cast<short>(aStr.toString().toInt32()); + nMinute = static_cast<short>(o3tl::toInt32(aStr)); } else if ( nSepPos < 0 ) { - nSecond = static_cast<short>(aStr.toString().toInt32()); + nSecond = static_cast<short>(o3tl::toInt32(aStr)); nMinute += nSecond / 60; nSecond %= 60; nHour += nMinute / 60; @@ -2446,7 +2446,7 @@ bool TimeFormatter::TextToTime(std::u16string_view rStr, tools::Time& rTime, nHour += nMinute / 60; nMinute %= 60; } - nNanoSec = aStr.toString().toInt64(); + nNanoSec = o3tl::toInt64(aStr); } if ( nNanoSec ) diff --git a/vcl/source/filter/idxf/dxfgrprd.cxx b/vcl/source/filter/idxf/dxfgrprd.cxx index d951967d7fcb..48cdb3660a6b 100644 --- a/vcl/source/filter/idxf/dxfgrprd.cxx +++ b/vcl/source/filter/idxf/dxfgrprd.cxx @@ -20,6 +20,7 @@ #include <stdlib.h> #include <rtl/strbuf.hxx> #include <tools/stream.hxx> +#include <o3tl/string_view.hxx> #include "dxfgrprd.hxx" // we use an own ReadLine function, because Stream::ReadLine stops if @@ -182,7 +183,7 @@ tools::Long DXFGroupReader::ReadI() return 0; } - return aNumber.toString().toInt32(); + return o3tl::toInt32(aNumber); } double DXFGroupReader::ReadF() diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index 6d5b08c89f23..112aa411a67d 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -19,6 +19,7 @@ #include <vcl/filter/PDFiumLibrary.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> using namespace com::sun::star; @@ -47,8 +48,8 @@ bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize) || aFirstBytes[3] != 'F' || aFirstBytes[4] != '-') return false; - sal_Int32 nMajor = OString(char(aFirstBytes[5])).toInt32(); - sal_Int32 nMinor = OString(char(aFirstBytes[7])).toInt32(); + sal_Int32 nMajor = o3tl::toInt32(std::string_view(reinterpret_cast<char*>(&aFirstBytes[5]), 1)); + sal_Int32 nMinor = o3tl::toInt32(std::string_view(reinterpret_cast<char*>(&aFirstBytes[7]), 1)); return !(nMajor > 1 || (nMajor == 1 && nMinor > 6)); } diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index 466a8d4c8760..540433d63460 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -82,7 +82,7 @@ protected: private: - static css::uno::Reference< css::graphic::XGraphic > implLoadMemory( const OUString& rResourceURL ); + static css::uno::Reference< css::graphic::XGraphic > implLoadMemory( std::u16string_view rResourceURL ); static css::uno::Reference< css::graphic::XGraphic > implLoadRepositoryImage( std::u16string_view rResourceURL ); static css::uno::Reference< css::graphic::XGraphic > implLoadBitmap( const css::uno::Reference< css::awt::XBitmap >& rBitmap ); static css::uno::Reference< css::graphic::XGraphic > implLoadStandardImage( std::u16string_view rResourceURL ); @@ -122,14 +122,14 @@ uno::Sequence< sal_Int8 > SAL_CALL GraphicProvider::getImplementationId() return css::uno::Sequence<sal_Int8>(); } -uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadMemory( const OUString& rResourceURL ) +uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadMemory( std::u16string_view rResourceURL ) { uno::Reference< ::graphic::XGraphic > xRet; sal_Int32 nIndex = 0; if( o3tl::getToken(rResourceURL, 0, '/', nIndex ) == u"private:memorygraphic" ) { - sal_Int64 nGraphicAddress = rResourceURL.getToken( 0, '/', nIndex ).toInt64(); + sal_Int64 nGraphicAddress = o3tl::toInt64(o3tl::getToken(rResourceURL, 0, '/', nIndex )); if( nGraphicAddress ) { diff --git a/vcl/source/treelist/inetimg.cxx b/vcl/source/treelist/inetimg.cxx index 87ca6fef5f27..35c795cb0843 100644 --- a/vcl/source/treelist/inetimg.cxx +++ b/vcl/source/treelist/inetimg.cxx @@ -22,6 +22,7 @@ #include <tools/stream.hxx> #include <vcl/inetimg.hxx> +#include <o3tl/string_view.hxx> const sal_Unicode TOKEN_SEPARATOR = '\001'; @@ -68,10 +69,10 @@ bool INetImage::Read( SvStream& rIStm, SotClipboardFormatId nFormat ) aTargetURL = sINetImg.getToken( 0, TOKEN_SEPARATOR, nStart ); aTargetFrame = sINetImg.getToken( 0, TOKEN_SEPARATOR, nStart ); /*aAlternateText =*/ sINetImg.getToken( 0, TOKEN_SEPARATOR, nStart ); - aSizePixel.setWidth( sINetImg.getToken( 0, TOKEN_SEPARATOR, - nStart ).toInt32() ); - aSizePixel.setHeight( sINetImg.getToken( 0, TOKEN_SEPARATOR, - nStart ).toInt32() ); + aSizePixel.setWidth( o3tl::toInt32(o3tl::getToken(sINetImg, 0, TOKEN_SEPARATOR, + nStart )) ); + aSizePixel.setHeight(o3tl::toInt32(o3tl::getToken( sINetImg, 0, TOKEN_SEPARATOR, + nStart )) ); bRet = !sINetImg.isEmpty(); } break; diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx index c81272434136..ccdb8bed0f52 100644 --- a/vcl/unx/generic/app/wmadaptor.cxx +++ b/vcl/unx/generic/app/wmadaptor.cxx @@ -30,6 +30,7 @@ #include <sal/macros.h> #include <sal/log.hxx> #include <configsettings.hxx> +#include <o3tl/string_view.hxx> #include <unx/wmadaptor.hxx> #include <unx/saldisp.hxx> @@ -827,8 +828,8 @@ bool WMAdaptor::getNetWmName() { OUString aMetaVersion( reinterpret_cast<char*>(pProperty), nItems, RTL_TEXTENCODING_UTF8 ); sal_Int32 nIdx {0}; - nVersionMajor = aMetaVersion.getToken(0, '.', nIdx).toInt32(); - nVersionMinor = aMetaVersion.getToken(0, '.', nIdx).toInt32(); + nVersionMajor = o3tl::toInt32(o3tl::getToken(aMetaVersion, 0, '.', nIdx)); + nVersionMinor = o3tl::toInt32(o3tl::getToken(aMetaVersion, 0, '.', nIdx)); } if( pProperty ) { diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx index a1f17f46eec5..7ed5b677ec64 100644 --- a/vcl/unx/generic/printer/jobdata.cxx +++ b/vcl/unx/generic/printer/jobdata.cxx @@ -242,10 +242,10 @@ bool JobData::constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, Jo { bMargin = true; sal_Int32 nIdx {RTL_CONSTASCII_LENGTH(marginadjustmentEquals)}; - rJobData.m_nLeftMarginAdjust = aLine.getToken(0, ',', nIdx).toInt32(); - rJobData.m_nRightMarginAdjust = aLine.getToken(0, ',', nIdx).toInt32(); - rJobData.m_nTopMarginAdjust = aLine.getToken(0, ',', nIdx).toInt32(); - rJobData.m_nBottomMarginAdjust = aLine.getToken(0, ',', nIdx).toInt32(); + rJobData.m_nLeftMarginAdjust = o3tl::toInt32(o3tl::getToken(aLine, 0, ',', nIdx)); + rJobData.m_nRightMarginAdjust = o3tl::toInt32(o3tl::getToken(aLine, 0, ',', nIdx)); + rJobData.m_nTopMarginAdjust = o3tl::toInt32(o3tl::getToken(aLine, 0, ',', nIdx)); + rJobData.m_nBottomMarginAdjust = o3tl::toInt32(o3tl::getToken(aLine, 0, ',', nIdx)); } else if (aLine.startsWith(colordepthEquals)) { diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index f5af9b0b0c8c..ae87f6adf0f7 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -32,6 +32,7 @@ #include <osl/file.hxx> #include <osl/thread.hxx> #include <osl/mutex.hxx> +#include <o3tl/string_view.hxx> // filename of configuration files constexpr OUStringLiteral PRINT_FILENAME = u"psprint.conf"; @@ -225,10 +226,10 @@ void PrinterInfoManager::initialize() if (!aValue.isEmpty()) { sal_Int32 nIdx {0}; - m_aGlobalDefaults.m_nLeftMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); - m_aGlobalDefaults.m_nRightMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); - m_aGlobalDefaults.m_nTopMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); - m_aGlobalDefaults.m_nBottomMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); + m_aGlobalDefaults.m_nLeftMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); + m_aGlobalDefaults.m_nRightMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); + m_aGlobalDefaults.m_nTopMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); + m_aGlobalDefaults.m_nBottomMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); } aValue = aConfig.ReadKey( "ColorDepth", "24" ); @@ -409,10 +410,10 @@ void PrinterInfoManager::initialize() if (!aValue.isEmpty()) { sal_Int32 nIdx {0}; - aPrinter.m_aInfo.m_nLeftMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); - aPrinter.m_aInfo.m_nRightMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); - aPrinter.m_aInfo.m_nTopMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); - aPrinter.m_aInfo.m_nBottomMarginAdjust = aValue.getToken(0, ',', nIdx).toInt32(); + aPrinter.m_aInfo.m_nLeftMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); + aPrinter.m_aInfo.m_nRightMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); + aPrinter.m_aInfo.m_nTopMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); + aPrinter.m_aInfo.m_nBottomMarginAdjust = o3tl::toInt32(o3tl::getToken(aValue, 0, ',', nIdx)); } aValue = aConfig.ReadKey( "ColorDepth" ); diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx index 98657263a4bc..afc8acf72d00 100644 --- a/writerfilter/source/dmapper/ConversionHelper.cxx +++ b/writerfilter/source/dmapper/ConversionHelper.cxx @@ -671,14 +671,14 @@ util::DateTime ConvertDateStringToDateTime( const OUString& rDateTime ) // and writes it as Z (=UTC+0) OUString sTime = rDateTime.getToken( 0, 'Z', nIndex ); nIndex = 0; - aDateTime.Year = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() ); - aDateTime.Month = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() ); + aDateTime.Year = sal_uInt16( o3tl::toInt32(o3tl::getToken(sDate, 0, '-', nIndex )) ); + aDateTime.Month = sal_uInt16( o3tl::toInt32(o3tl::getToken(sDate, 0, '-', nIndex )) ); if (nIndex != -1) aDateTime.Day = sal_uInt16( o3tl::toInt32(sDate.subView( nIndex )) ); nIndex = 0; - aDateTime.Hours = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() ); - aDateTime.Minutes = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() ); + aDateTime.Hours = sal_uInt16( o3tl::toInt32(o3tl::getToken(sTime, 0, ':', nIndex )) ); + aDateTime.Minutes = sal_uInt16( o3tl::toInt32(o3tl::getToken(sTime, 0, ':', nIndex )) ); if (nIndex != -1) aDateTime.Seconds = sal_uInt16( o3tl::toInt32(sTime.subView( nIndex )) ); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 311a0ffd4384..58258a386c83 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -5354,7 +5354,7 @@ void DomainMapper_Impl::handleRubyEQField( const FieldContextPtr& pContext) if (nIndex != -1) { nIndex += 5; - sal_uInt32 nJc = rCommand.getToken(0, ' ',nIndex).toInt32(); + sal_uInt32 nJc = o3tl::toInt32(o3tl::getToken(rCommand, 0, ' ',nIndex)); const sal_Int32 aRubyAlignValues[] = { NS_ooxml::LN_Value_ST_RubyAlign_center, @@ -5373,7 +5373,7 @@ void DomainMapper_Impl::handleRubyEQField( const FieldContextPtr& pContext) if (nIndex != -1) { nIndex += 6; - aInfo.nHps = rCommand.getToken(0, ' ',nIndex).toInt32(); + aInfo.nHps = o3tl::toInt32(o3tl::getToken(rCommand, 0, ' ',nIndex)); } nIndex = rCommand.indexOf("\\o"); @@ -5863,7 +5863,7 @@ void DomainMapper_Impl::handleToc //empty tokens should be skipped while( sStyleName.isEmpty() && nPosition > 0 ) sStyleName = sTemplate.getToken( 0, ',', nPosition ); - nLevel = sTemplate.getToken( 0, ',', nPosition ).toInt32(); + nLevel = o3tl::toInt32(o3tl::getToken(sTemplate, 0, ',', nPosition )); if( !nLevel ) nLevel = 1; if( !sStyleName.isEmpty() ) diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 3426c9213f4f..6d03ac396664 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -47,6 +47,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <svx/svdobj.hxx> #include <tools/UnitConversion.hxx> +#include <o3tl/string_view.hxx> #include <dmapper/GraphicZOrderHelper.hxx> #include "rtfdocumentimpl.hxx" @@ -497,8 +498,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap // The coordinates are in an (x,y) form. aToken = aToken.copy(1, aToken.getLength() - 2); sal_Int32 nI = 0; - sal_Int32 nX = aToken.getToken(0, ',', nI).toInt32(); - sal_Int32 nY = (nI >= 0) ? aToken.getToken(0, ',', nI).toInt32() : 0; + sal_Int32 nX = o3tl::toInt32(o3tl::getToken(aToken, 0, ',', nI)); + sal_Int32 nY + = (nI >= 0) ? o3tl::toInt32(o3tl::getToken(aToken, 0, ',', nI)) : 0; drawing::EnhancedCustomShapeParameterPair aPair; aPair.First.Value <<= nX; aPair.Second.Value <<= nY; @@ -517,7 +519,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap sal_Int32 nCharIndex = 0; do { - sal_Int32 nSeg = rProperty.second.getToken(0, ';', nCharIndex).toInt32(); + sal_Int32 nSeg + = o3tl::toInt32(o3tl::getToken(rProperty.second, 0, ';', nCharIndex)); if (!nSize) nSize = nSeg; else if (!nCount) @@ -842,8 +845,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap // The coordinates are in an (x,y) form. aToken = aToken.copy(1, aToken.getLength() - 2); sal_Int32 nI = 0; - sal_Int32 nX = aToken.getToken(0, ',', nI).toInt32(); - sal_Int32 nY = (nI >= 0) ? aToken.getToken(0, ',', nI).toInt32() : 0; + sal_Int32 nX = o3tl::toInt32(o3tl::getToken(aToken, 0, ',', nI)); + sal_Int32 nY + = (nI >= 0) ? o3tl::toInt32(o3tl::getToken(aToken, 0, ',', nI)) : 0; RTFSprms aPathAttributes; aPathAttributes.set(NS_ooxml::LN_CT_Point2D_x, new RTFValue(nX)); aPathAttributes.set(NS_ooxml::LN_CT_Point2D_y, new RTFValue(nY)); diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 8bc776e5e421..992989665952 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -45,6 +45,7 @@ #include <xmloff/SchXMLSeriesHelper.hxx> #include <rtl/math.hxx> #include <o3tl/sorted_vector.hxx> +#include <o3tl/string_view.hxx> #include <limits> #include <vector> @@ -772,7 +773,7 @@ struct lcl_SequenceToMapElement nIndex = aRangeRep.toInt32(); } else if( rContent.first.is()) //has labels - nIndex = rContent.first->getSourceRangeRepresentation().copy( sizeof("label ")).toInt32(); + nIndex = o3tl::toInt32(rContent.first->getSourceRangeRepresentation().subView( sizeof("label "))); return std::make_pair(nIndex, rContent); } }; diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index a59a28b2546b..9ee4016087fe 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -27,6 +27,7 @@ #include "transporttypes.hxx" #include <XMLStringBufferImportContext.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <sal/log.hxx> #include <xmloff/xmlnamespace.hxx> #include <xmloff/xmltoken.hxx> @@ -946,7 +947,7 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( if( xLabel.is() ) { aRange = xLabel->getSourceRangeRepresentation(); - const sal_Int32 nId {aRange.getToken(1, ' ').toInt32()}; + const sal_Int32 nId = o3tl::toInt32(o3tl::getToken(aRange, 1, ' ')); if( ::std::find( rTable.aHiddenColumns.begin(), rTable.aHiddenColumns.end(), nId ) == rTable.aHiddenColumns.end() ) bHasUnhiddenColumns = true; } diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx index 2b332e2afe9d..47acf7737be6 100644 --- a/xmloff/source/meta/xmlversion.cxx +++ b/xmloff/source/meta/xmlversion.cxx @@ -23,6 +23,7 @@ #include <xmloff/xmlmetae.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <xmloff/xmltoken.hxx> #include <comphelper/processfactory.hxx> @@ -236,17 +237,17 @@ bool XMLVersionContext::ParseISODateTimeString( else { sal_Int32 n = 0; - nYear = aDateStr.getToken( 0, '-', n ).toInt32(); + nYear = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nYear > 9999 ) bSuccess = false; else if ( nDateTokens >= 2 ) { - nMonth = aDateStr.getToken( 0, '-', n ).toInt32(); + nMonth = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nMonth > 12 ) bSuccess = false; else if ( nDateTokens >= 3 ) { - nDay = aDateStr.getToken( 0, '-', n ).toInt32(); + nDay = o3tl::toInt32(o3tl::getToken(aDateStr, 0, '-', n )); if ( nDay > 31 ) bSuccess = false; } @@ -268,17 +269,17 @@ bool XMLVersionContext::ParseISODateTimeString( else { sal_Int32 n = 0; - nHour = aTimeStr.getToken( 0, ':', n ).toInt32(); + nHour = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nHour > 23 ) bSuccess = false; else if ( nTimeTokens >= 2 ) { - nMin = aTimeStr.getToken( 0, ':', n ).toInt32(); + nMin = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nMin > 59 ) bSuccess = false; else if ( nTimeTokens >= 3 ) { - nSec = aTimeStr.getToken( 0, ':', n ).toInt32(); + nSec = o3tl::toInt32(o3tl::getToken(aTimeStr, 0, ':', n )); if ( nSec > 59 ) bSuccess = false; } |