comphelper/source/misc/sequenceashashmap.cxx | 19 +- compilerplugins/clang/stringview.cxx | 50 +++--- compilerplugins/clang/test/stringview.cxx | 5 connectivity/source/commontools/dbconversion.cxx | 9 - connectivity/source/drivers/hsqldb/HDriver.cxx | 7 connectivity/source/parse/sqlnode.cxx | 2 cui/source/options/dbregister.cxx | 5 cui/source/tabpages/chardlg.cxx | 9 - dbaccess/source/core/misc/dsntypes.cxx | 2 dbaccess/source/ui/dlg/TextConnectionHelper.cxx | 7 dbaccess/source/ui/dlg/TextConnectionHelper.hxx | 2 desktop/qa/desktop_lib/test_desktop_lib.cxx | 7 desktop/source/splash/splash.cxx | 27 +-- extensions/source/bibliography/general.cxx | 3 forms/source/xforms/xpathlib/xpathlib.cxx | 12 - fpicker/source/office/RemoteFilesDialog.cxx | 2 fpicker/source/office/fileview.cxx | 11 - fpicker/source/office/fileview.hxx | 2 framework/source/uiconfiguration/windowstateconfiguration.cxx | 9 - i18npool/source/localedata/localedata.cxx | 3 include/connectivity/dbconversion.hxx | 2 include/connectivity/sqlnode.hxx | 2 include/sfx2/childwin.hxx | 2 include/unotools/VersionConfig.hxx | 9 - oox/source/drawingml/customshapepresetdata.cxx | 78 +++++----- oox/source/ppt/comments.cxx | 3 oox/source/ppt/pptfilterhelpers.cxx | 13 - oox/source/vml/vmlformatting.cxx | 2 oox/source/vml/vmlshape.cxx | 10 - opencl/source/openclconfig.cxx | 3 sc/source/filter/inc/drawingbase.hxx | 2 sc/source/filter/oox/drawingbase.cxx | 5 sc/source/ui/dbgui/asciiopt.cxx | 10 - sc/source/ui/dbgui/csvruler.cxx | 3 sc/source/ui/dbgui/imoptdlg.cxx | 4 sc/source/ui/dbgui/scuiasciiopt.cxx | 5 sc/source/ui/dbgui/scuiimoptdlg.cxx | 4 sc/source/ui/docshell/docsh8.cxx | 2 sc/source/ui/docshell/impex.cxx | 12 - sc/source/ui/miscdlgs/sharedocdlg.cxx | 11 - sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx | 3 sc/source/ui/view/prevwsh.cxx | 5 sc/source/ui/view/viewdata.cxx | 22 +- sd/source/ui/dlg/copydlg.cxx | 13 - sdext/source/minimizer/optimizerdialogcontrols.cxx | 3 sdext/source/pdfimport/test/pdfunzip.cxx | 5 sfx2/source/appl/childwin.cxx | 14 - sfx2/source/appl/newhelp.cxx | 14 - sfx2/source/bastyp/sfxhtml.cxx | 3 sfx2/source/dialog/filedlghelper.cxx | 9 - sfx2/source/dialog/splitwin.cxx | 9 - sfx2/source/dialog/srchdlg.cxx | 9 - sfx2/source/doc/autoredactdialog.cxx | 4 sfx2/source/doc/objmisc.cxx | 2 svtools/source/misc/imagemgr.cxx | 3 svtools/source/svhtml/parhtml.cxx | 4 svx/source/fmcomp/dbaexchange.cxx | 3 svx/source/form/fmview.cxx | 3 svx/source/xoutdev/xattr.cxx | 10 - sw/qa/core/layout/layout.cxx | 33 ++-- sw/qa/extras/layout/layout2.cxx | 15 - sw/qa/extras/uiwriter/uiwriter3.cxx | 29 +-- sw/source/core/doc/docfld.cxx | 2 sw/source/core/docnode/ndtbl.cxx | 3 sw/source/core/edit/autofmt.cxx | 5 sw/source/filter/ww8/ww8par5.cxx | 4 sw/source/ui/fldui/flddb.cxx | 3 sw/source/ui/fldui/flddinf.cxx | 3 sw/source/ui/fldui/flddok.cxx | 3 sw/source/ui/fldui/fldfunc.cxx | 3 sw/source/ui/fldui/fldpage.cxx | 7 sw/source/ui/fldui/fldref.cxx | 5 sw/source/ui/index/swuiidxmrk.cxx | 3 sw/source/ui/misc/bookmark.cxx | 2 sw/source/ui/misc/glosbib.cxx | 2 sw/source/ui/misc/glossary.cxx | 4 sw/source/uibase/app/apphdl.cxx | 3 sw/source/uibase/fldui/fldmgr.cxx | 2 sw/source/uibase/misc/glosdoc.cxx | 8 - sw/source/uibase/uiview/view.cxx | 23 +- sw/source/uibase/uiview/view2.cxx | 2 sw/source/uibase/utlui/content.cxx | 5 sw/source/uibase/utlui/gloslst.cxx | 4 toolkit/source/awt/vclxprinter.cxx | 3 ucb/source/ucp/webdav-curl/webdavresponseparser.cxx | 3 vcl/source/control/field2.cxx | 10 - vcl/source/filter/idxf/dxfgrprd.cxx | 3 vcl/source/filter/ipdf/pdfread.cxx | 5 vcl/source/graphic/UnoGraphicProvider.cxx | 6 vcl/source/treelist/inetimg.cxx | 9 - vcl/unx/generic/app/wmadaptor.cxx | 5 vcl/unx/generic/printer/jobdata.cxx | 8 - vcl/unx/generic/printer/printerinfomanager.cxx | 17 +- writerfilter/source/dmapper/ConversionHelper.cxx | 8 - writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 writerfilter/source/rtftok/rtfsdrimport.cxx | 14 + xmloff/source/chart/SchXMLExport.cxx | 3 xmloff/source/chart/SchXMLTableContext.cxx | 3 xmloff/source/meta/xmlversion.cxx | 13 - 99 files changed, 437 insertions(+), 365 deletions(-)
New commits: commit 85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 Author: Noel Grandin <[email protected]> AuthorDate: Sun Apr 10 20:17:54 2022 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon Apr 11 14:45:38 2022 +0200 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 <[email protected]> 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")); ... etc. - the rest is truncated
