diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-10 12:42:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-10 15:53:13 +0200 |
commit | 43a6b59539ad573436f43303e9fbe17c12dc9c84 (patch) | |
tree | 24cbf3a9fc84ad38e17ed92ed0a50db48f20f2c5 | |
parent | f2a1298ea409141a9190c7789b39546644084980 (diff) |
simplify some OUString compareTo calls
to either startsWith or == or !=
Change-Id: Ie4b4662f5b8e4532cbc1ab36910389e0b3d41ef0
Reviewed-on: https://gerrit.libreoffice.org/39750
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
24 files changed, 106 insertions, 126 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index 7d03c2364b7c..8d64ee3a3ca9 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -452,14 +452,14 @@ namespace bool isSameExtension(const ExtensionInfoEntry& rComp) const { - return (maRepository == rComp.maRepository && 0 == maName.compareTo(rComp.maName)); + return (maRepository == rComp.maRepository && maName == rComp.maName); } bool operator<(const ExtensionInfoEntry& rComp) const { if (maRepository == rComp.maRepository) { - if (0 == maName.compareTo(rComp.maName)) + if (maName == rComp.maName) { return mbEnabled < rComp.mbEnabled; } diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index 91374b1712a8..7a1498891511 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -446,16 +446,13 @@ bool OStorageHelper::PathHasSegment( const OUString& aPath, const OUString& aSeg if ( !aSegment.isEmpty() && nPathLen >= nSegLen ) { - OUString aEndSegment = "/" - + aSegment; - - OUString aInternalSegment = aEndSegment - + "/"; + OUString aEndSegment = "/" + aSegment; + OUString aInternalSegment = aEndSegment + "/"; if ( aPath.indexOf( aInternalSegment ) >= 0 ) bResult = true; - if ( !bResult && !aPath.compareTo( aSegment, nSegLen ) ) + if ( !bResult && aPath.startsWith( aSegment ) ) { if ( nPathLen == nSegLen || aPath[nSegLen] == '/' ) bResult = true; diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx index db6609f722ee..802316fa84dc 100644 --- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx @@ -1513,9 +1513,9 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( // deferrability is currently not supported, but may be supported in the future. /* - aCurrentRow[14] = (xRow->getString(5).compareTo(OUString("NO") == 0 ? + aCurrentRow[14] = (xRow->getString(5) == "NO" ? new ORowSetValueDecorator(Deferrability::NONE) - : (xRow->getString(6).compareTo(OUString("NO") == 0 ? + : (xRow->getString(6) == "NO" ? new ORowSetValueDecorator(Deferrability::INITIALLY_IMMEDIATE) : new ORowSetValueDecorator(Deferrability::INITIALLY_DEFERRED)); */ diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx index d29e6995f7a4..412ee78fd2ae 100644 --- a/cui/source/dialogs/screenshotannotationdlg.cxx +++ b/cui/source/dialogs/screenshotannotationdlg.cxx @@ -364,7 +364,7 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, Button*, void) INetURLObject aConfirmedURL(aConfirmedName); OUString aCurrentExtension(aConfirmedURL.getExtension()); - if (!aCurrentExtension.isEmpty() && 0 != aCurrentExtension.compareTo("png")) + if (!aCurrentExtension.isEmpty() && aCurrentExtension != "png") { aConfirmedURL.removeExtension(); aCurrentExtension.clear(); diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index b5795870d8ad..6caf231ad57e 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -1146,7 +1146,7 @@ bool SVGTextWriter::nextTextPortion() sFieldName = pNames->copy( sServicePrefix.getLength() ); break; } - else if( 0 == pNames->compareTo( sPresentationServicePrefix, sPresentationServicePrefix.getLength() ) ) + else if( pNames->startsWith( sPresentationServicePrefix ) ) { // TextField found => postfix is field type! sFieldName = pNames->copy( sPresentationServicePrefix.getLength() ); diff --git a/framework/source/uielement/notebookbarmenucontroller.cxx b/framework/source/uielement/notebookbarmenucontroller.cxx index f469628d4bd8..70d7827dd7e2 100644 --- a/framework/source/uielement/notebookbarmenucontroller.cxx +++ b/framework/source/uielement/notebookbarmenucontroller.cxx @@ -272,11 +272,11 @@ void SAL_CALL NotebookbarMenuController::itemActivated( const css::awt::MenuEven return; // Entries are enabled only when Notebookbar mode is active - bool bActive = ( comphelper::getString( aModesNode.getNodeValue( "Active" ) ).compareTo("Notebookbar") == 0 ); + bool bActive = comphelper::getString( aModesNode.getNodeValue( "Active" ) ) == "Notebookbar"; for ( int i = 0; i < m_xPopupMenu->getItemCount(); ++i ) { - m_xPopupMenu->checkItem( i+1, ( aActive.compareTo( m_xPopupMenu->getCommand( i+1 ) ) == 0 ) ); + m_xPopupMenu->checkItem( i+1, aActive == m_xPopupMenu->getCommand( i+1 ) ); m_xPopupMenu->enableItem( i+1, bActive ); } } diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx index 698f826a4012..2ac7f4671df8 100644 --- a/framework/source/uielement/toolbarmodemenucontroller.cxx +++ b/framework/source/uielement/toolbarmodemenucontroller.cxx @@ -283,7 +283,7 @@ void SAL_CALL ToolbarModeMenuController::itemActivated( const css::awt::MenuEven OUString aMode = comphelper::getString( aModesNode.getNodeValue( "Active" ) ); for ( int i = 0; i < m_xPopupMenu->getItemCount(); ++i ) - m_xPopupMenu->checkItem( i+1, (aMode.compareTo( m_xPopupMenu->getCommand( i+1 ) ) == 0) ); + m_xPopupMenu->checkItem( i+1, aMode == m_xPopupMenu->getCommand( i+1 ) ); } // XPopupMenuController diff --git a/sal/qa/rtl/process/child_process.cxx b/sal/qa/rtl/process/child_process.cxx index c6b44cc50c19..a51cdde51631 100644 --- a/sal/qa/rtl/process/child_process.cxx +++ b/sal/qa/rtl/process/child_process.cxx @@ -47,10 +47,10 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(, argv) aString.getStr()); } - if ( suArg[0].compareTo( suParam0) != 0 || - suArg[1].compareTo( suParam1) != 0 || - suArg[2].compareTo( suParam2) != 0 || - suArg[3].compareTo( suParam3) != 0 ) + if ( suArg[0] != suParam0 || + suArg[1] != suParam1 || + suArg[2] != suParam2 || + suArg[3] != suParam3 ) { return 0; } diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 057f804a03b1..653e73da36ac 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3419,202 +3419,200 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config, ft->Children[i], new OpIf, nResultSize)); break; case ocExternal: - if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getEffect"))) + if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getEffect") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpEffective, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCumipmt"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCumipmt") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCumipmt, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getNominal"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getNominal") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpNominal, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCumprinc"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCumprinc") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCumprinc, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getXnpv"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getXnpv") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpXNPV, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getPricemat"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getPricemat") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpPriceMat, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getReceived"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getReceived") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpReceived, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getTbilleq"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getTbilleq") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpTbilleq, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getTbillprice"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getTbillprice") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpTbillprice, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getTbillyield"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getTbillyield") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpTbillyield, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getFvschedule"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getFvschedule") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpFvschedule, nResultSize)); } - /*else if ( !(pChild->GetExternal().compareTo(OUString( - "com.sun.star.sheet.addin.Analysis.getYield")))) + /*else if ( pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getYield") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpYield)); }*/ - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getYielddisc"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getYielddisc") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpYielddisc, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getYieldmat"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getYieldmat") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpYieldmat, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getAccrintm"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getAccrintm") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpAccrintm, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCoupdaybs"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCoupdaybs") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCoupdaybs, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getDollarde"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getDollarde") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpDollarde, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getDollarfr"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getDollarfr") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpDollarfr, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCoupdays"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCoupdays") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCoupdays, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCoupdaysnc"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCoupdaysnc") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCoupdaysnc, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getDisc"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getDisc") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpDISC, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getIntrate"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getIntrate") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpINTRATE, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getPrice"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getPrice") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpPrice, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCoupnum"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCoupnum") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCoupnum, nResultSize)); } - /*else if ( !(pChild->GetExternal().compareTo(OUString( - "com.sun.star.sheet.addin.Analysis.getDuration")))) + /*else if pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getDuration")) { mvSubArguments.push_back( SoPHelper(mCalcConfig, ts, ft->Children[i], new OpDuration_ADD)); }*/ - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getAmordegrc"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getAmordegrc") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpAmordegrc, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getAmorlinc"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getAmorlinc") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpAmorlinc, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getMduration"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getMduration") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpMDuration, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getXirr"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getXirr") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpXirr, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getOddlprice"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getOddlprice") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpOddlprice, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getOddlyield"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getOddlyield") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpOddlyield, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getPricedisc"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getPricedisc") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpPriceDisc, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCouppcd"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCouppcd") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCouppcd, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getCoupncd"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getCoupncd") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpCoupncd, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getAccrint"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getAccrint") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpAccrint, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getSqrtpi"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getSqrtpi") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpSqrtPi, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getConvert"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getConvert") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpConvert, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getIseven"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getIseven") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpIsEven, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getIsodd"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getIsodd") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpIsOdd, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getMround"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getMround") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpMROUND, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getQuotient"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getQuotient") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpQuotient, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getSeriessum"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getSeriessum") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpSeriesSum, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getBesselj"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getBesselj") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpBesselj, nResultSize)); } - else if (!(pChild->GetExternal().compareTo("com.sun.star.sheet.addin.Analysis.getGestep"))) + else if (pChild->GetExternal() == "com.sun.star.sheet.addin.Analysis.getGestep") { mvSubArguments.push_back(SoPHelper(mCalcConfig, ts, ft->Children[i], new OpGestep, nResultSize)); diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index f76cb2214a31..2aead2a4d511 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -171,11 +171,9 @@ ScXMLChangeTrackingImportHelper::ScXMLChangeTrackingImportHelper() : pDoc(nullptr), pTrack(nullptr), pCurrentAction(nullptr), - sIDPrefix(SC_CHANGE_ID_PREFIX), nMultiSpanned(0), nMultiSpannedSlaveCount(0) { - nPrefixLength = sIDPrefix.getLength(); } ScXMLChangeTrackingImportHelper::~ScXMLChangeTrackingImportHelper() @@ -226,12 +224,11 @@ void ScXMLChangeTrackingImportHelper::StartChangeAction(const ScChangeActionType sal_uInt32 ScXMLChangeTrackingImportHelper::GetIDFromString(const OUString& sID) { sal_uInt32 nResult(0); - sal_uInt32 nLength(sID.getLength()); - if (nLength) + if (!sID.isEmpty()) { - if (sID.compareTo(sIDPrefix, nPrefixLength) == 0) + if (sID.startsWith(SC_CHANGE_ID_PREFIX)) { - OUString sValue(sID.copy(nPrefixLength, nLength - nPrefixLength)); + OUString sValue(sID.copy(strlen(SC_CHANGE_ID_PREFIX))); sal_Int32 nValue; ::sax::Converter::convertNumber(nValue, sValue); OSL_ENSURE(nValue > 0, "wrong change action ID"); diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx index 0f1d18f5cf5e..1fdeaec90903 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx @@ -180,8 +180,6 @@ class ScXMLChangeTrackingImportHelper ScDocument* pDoc; ScChangeTrack* pTrack; ScMyBaseAction* pCurrentAction; - OUString sIDPrefix; - sal_uInt32 nPrefixLength; sal_Int16 nMultiSpanned; sal_Int16 nMultiSpannedSlaveCount; @@ -202,7 +200,7 @@ public: void SetProtection(const css::uno::Sequence<sal_Int8>& rProtect) { aProtect = rProtect; } void StartChangeAction(const ScChangeActionType nActionType); - sal_uInt32 GetIDFromString(const OUString& sID); + static sal_uInt32 GetIDFromString(const OUString& sID); void SetActionNumber(const sal_uInt32 nActionNumber) { pCurrentAction->nActionNumber = nActionNumber; } void SetActionState(const ScChangeActionState nActionState) { pCurrentAction->nActionState = nActionState; } diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx index ab95b71bc461..e680128eb643 100644 --- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx +++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx @@ -630,7 +630,7 @@ ScXMLCellContentDeletionContext::ScXMLCellContentDeletionContext( ScXMLImport& if (nPrefix == XML_NAMESPACE_TABLE) { if (IsXMLToken(aLocalName, XML_ID)) - nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } } } @@ -692,7 +692,7 @@ ScXMLDependenceContext::ScXMLDependenceContext( ScXMLImport& rImport, if (nPrefix == XML_NAMESPACE_TABLE) { if (IsXMLToken(aLocalName, XML_ID)) - nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } } pChangeTrackingImportHelper->AddDependence(nID); @@ -764,7 +764,7 @@ ScXMLChangeDeletionContext::ScXMLChangeDeletionContext( ScXMLImport& rImport, if (nPrefix == XML_NAMESPACE_TABLE) { if (IsXMLToken(aLocalName, XML_ID)) - nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } } pChangeTrackingImportHelper->AddDeleted(nID); @@ -1124,7 +1124,7 @@ ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport& rImport, if (nPrefix == XML_NAMESPACE_TABLE) { if (IsXMLToken(aLocalName, XML_ID)) - nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } } } @@ -1176,7 +1176,7 @@ ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport& rImport, { if (IsXMLToken(aLocalName, XML_ID)) { - nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) { @@ -1187,7 +1187,7 @@ ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport& rImport, } else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) { - nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } } } @@ -1267,7 +1267,7 @@ ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport& rImport, { if (IsXMLToken(aLocalName, XML_ID)) { - nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) { @@ -1278,7 +1278,7 @@ ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport& rImport, } else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) { - nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_TYPE)) { @@ -1361,7 +1361,7 @@ ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport& rImport, { if (IsXMLToken(aLocalName, XML_ID)) { - nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_POSITION)) { @@ -1409,7 +1409,7 @@ ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport& rImport, { if (IsXMLToken(aLocalName, XML_ID)) { - nID = pChangeTrackingImportHelper->GetIDFromString(sValue); + nID = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_POSITION)) { @@ -1506,7 +1506,7 @@ ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport, { if (IsXMLToken(aLocalName, XML_ID)) { - nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) { @@ -1517,7 +1517,7 @@ ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport, } else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) { - nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_TYPE)) { @@ -1613,7 +1613,7 @@ ScXMLMovementContext::ScXMLMovementContext( ScXMLImport& rImport, { if (IsXMLToken(aLocalName, XML_ID)) { - nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) { @@ -1624,7 +1624,7 @@ ScXMLMovementContext::ScXMLMovementContext( ScXMLImport& rImport, } else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) { - nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } } } @@ -1694,7 +1694,7 @@ ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport& rImport, { if (IsXMLToken(aLocalName, XML_ID)) { - nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nActionNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE)) { @@ -1705,7 +1705,7 @@ ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport& rImport, } else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID)) { - nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue); + nRejectingNumber = ScXMLChangeTrackingImportHelper::GetIDFromString(sValue); } } } diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 363ab7f60ef8..450e74931393 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -744,7 +744,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) aCurrentMode = comphelper::getString( aAppNode.getNodeValue( "Active" ) ); - if ( aCurrentMode.compareTo( aNewName ) == 0 ) + if ( aCurrentMode == aNewName ) { bDone = true; break; @@ -821,7 +821,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); - if ( aCommandArg.compareTo( aNewName ) == 0 ) + if ( aCommandArg == aNewName ) { aMandatoryToolbars = aModeNode.getNodeValue( "Toolbars" ).get< uno::Sequence<OUString> >(); aUserToolbars = aModeNode.getNodeValue( "UserToolbars" ).get< uno::Sequence<OUString> >(); @@ -881,17 +881,17 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) sfx2::sidebar::SidebarController::GetSidebarControllerForFrame( xFrame ); if ( pSidebar ) { - if ( aSidebarMode.compareTo( "Arrow" ) == 0 ) + if ( aSidebarMode == "Arrow" ) { pSidebar->FadeOut(); } - else if ( aSidebarMode.compareTo( "Tabs" ) == 0 ) + else if ( aSidebarMode == "Tabs" ) { pSidebar->FadeIn(); pSidebar->RequestOpenDeck(); pSidebar->RequestCloseDeck(); } - else if ( aSidebarMode.compareTo( "Opened" ) == 0 ) + else if ( aSidebarMode == "Opened" ) { pSidebar->FadeIn(); pSidebar->RequestOpenDeck(); @@ -917,7 +917,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); - if ( aCommandArg.compareTo( aCurrentMode ) == 0 ) + if ( aCommandArg == aCurrentMode ) { aModeNode.setNodeValue( "UserToolbars", makeAny( aBackup ) ); break; diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index ca5f95c347d5..023dce7a4e22 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -145,7 +145,7 @@ static const utl::OConfigurationNode lcl_getCurrentImplConfigNode(const Referenc OUString aCommandArg = comphelper::getString( aImplNode.getNodeValue( "File" ) ); - if ( aCommandArg.compareTo( aActive ) == 0 ) + if ( aCommandArg == aActive ) { return aImplNode; } @@ -222,7 +222,7 @@ bool SfxNotebookBar::IsActive() OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) ); - if ( aCommandArg.compareTo( aActive ) == 0 ) + if ( aCommandArg == aActive ) { return comphelper::getBOOL( aModeNode.getNodeValue( "HasNotebookbar" ) ); } @@ -288,7 +288,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, // delete ".ui" sNewFile = sNewFile.copy( 0, sNewFile.getLength() - 3 ); - bChangedFile = ( sNewFile.compareTo( sCurrentFile ) != 0 ); + bChangedFile = sNewFile != sCurrentFile; } if ( ( !sFile.isEmpty() && bChangedFile ) || !pNotebookBar || !pNotebookBar->IsVisible() ) diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx index 8305ea557b94..031edde3755a 100644 --- a/svtools/source/dialogs/PlaceEditDialog.cxx +++ b/svtools/source/dialogs/PlaceEditDialog.cxx @@ -226,13 +226,10 @@ IMPL_LINK( PlaceEditDialog, OKHdl, Button*, /*pBtn*/, void) if ( m_xCurrentDetails.get() ) { OUString sUrl = m_xCurrentDetails->getUrl().GetHost( INetURLObject::DecodeMechanism::WithCharset ); - OUString sGDriveHost( GDRIVE_BASE_URL ); - OUString sAlfrescoHost( ALFRESCO_CLOUD_BASE_URL ); - OUString sOneDriveHost( ONEDRIVE_BASE_URL ); - if ( sUrl.compareTo( sGDriveHost, sGDriveHost.getLength() ) == 0 - || sUrl.compareTo( sAlfrescoHost, sAlfrescoHost.getLength() ) == 0 - || sUrl.compareTo( sOneDriveHost, sOneDriveHost.getLength() ) == 0 ) + if ( sUrl.startsWith( GDRIVE_BASE_URL ) + || sUrl.startsWith( ALFRESCO_CLOUD_BASE_URL ) + || sUrl.startsWith( ONEDRIVE_BASE_URL ) ) { m_pBTRepoRefresh->Click(); diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index f35d174df05c..6262bcdee23b 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -853,7 +853,7 @@ void AssignmentPersistentData::ImplCommit() for (;pTableNames != pEnd; ++pTableNames) { m_pTable->InsertEntry(*pTableNames); - if (0 == pTableNames->compareTo(sOldTable)) + if (*pTableNames == sOldTable) bKnowOldTable = true; } diff --git a/svtools/source/svhtml/htmlkywd.cxx b/svtools/source/svhtml/htmlkywd.cxx index b345a48e5cfc..de34418d37ce 100644 --- a/svtools/source/svhtml/htmlkywd.cxx +++ b/svtools/source/svhtml/htmlkywd.cxx @@ -200,7 +200,7 @@ HtmlTokenId GetHTMLToken( const OUString& rName ) HtmlTokenId nRet = HtmlTokenId::NONE; - if( !rName.compareTo( OOO_STRING_SVTOOLS_HTML_comment, 3 ) ) + if( rName.startsWith( OOO_STRING_SVTOOLS_HTML_comment )) return HtmlTokenId::COMMENT; void* pFound; diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx index c52207e10f32..f3993cba8dbe 100644 --- a/svtools/source/svhtml/htmlout.cxx +++ b/svtools/source/svhtml/htmlout.cxx @@ -980,10 +980,9 @@ OString HTMLOutFuncs::CreateTableDataOptionsValNum( bool HTMLOutFuncs::PrivateURLToInternalImg( OUString& rURL ) { - if( rURL.getLength() > 14 && - rURL.compareTo( OOO_STRING_SVTOOLS_HTML_private_image, 14 ) == 0 ) + if( rURL.startsWith(OOO_STRING_SVTOOLS_HTML_private_image) ) { - rURL = rURL.copy( 14 ); + rURL = rURL.copy( strlen(OOO_STRING_SVTOOLS_HTML_private_image) ); return true; } diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 513f6c57a478..544ec38cbf0b 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -3694,7 +3694,7 @@ bool INetURLObject::operator ==(INetURLObject const & rObject) const default: return false; } - return aPath1.compareTo(aPath2, nLength) == 0; + return aPath2.startsWith(aPath1); } default: diff --git a/ucbhelper/source/provider/providerhelper.cxx b/ucbhelper/source/provider/providerhelper.cxx index 9547ece9a982..f5e3163b5658 100644 --- a/ucbhelper/source/provider/providerhelper.cxx +++ b/ucbhelper/source/provider/providerhelper.cxx @@ -313,9 +313,7 @@ bool ContentProviderImplHelper::renameAdditionalPropertySet( for ( sal_Int32 n = 0; n < nCount; ++n ) { const OUString& rKey = pKeys[ n ]; - if ( rKey.compareTo( - aOldKeyWithSlash, - aOldKeyWithSlash.getLength() ) == 0 + if ( rKey.startsWith( aOldKeyWithSlash ) || rKey.equals( aOldKeyWithoutSlash ) ) { OUString aNewKey @@ -397,9 +395,7 @@ bool ContentProviderImplHelper::copyAdditionalPropertySet( for ( sal_Int32 n = 0; n < nCount; ++n ) { const OUString& rKey = pKeys[ n ]; - if ( rKey.compareTo( - aSrcKeyWithSlash, - aSrcKeyWithSlash.getLength() ) == 0 + if ( rKey.startsWith(aSrcKeyWithSlash ) || rKey.equals( aSrcKeyWithoutSlash ) ) { OUString aNewKey @@ -533,9 +529,7 @@ bool ContentProviderImplHelper::removeAdditionalPropertySet( for ( sal_Int32 n = 0; n < nCount; ++n ) { const OUString& rCurrKey = pKeys[ n ]; - if ( rCurrKey.compareTo( - aKeyWithSlash, - aKeyWithSlash.getLength() ) == 0 + if ( rCurrKey.startsWith(aKeyWithSlash ) || rCurrKey.equals( aKeyWithoutSlash ) ) { if ( !removeAdditionalPropertySet( diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index a9cbc922ec0d..5ec90505c443 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -1261,7 +1261,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc if( nPrefLen ) { sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( '-' ) + 1; - if( (nPrefLen != nStylePrefLen) || (aStyleName.compareTo( rPrefix, nPrefLen ) != 0) ) + if( (nPrefLen != nStylePrefLen) || !aStyleName.startsWith(rPrefix) ) continue; aStyleName = aStyleName.copy( nPrefLen ); @@ -1357,7 +1357,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc if( nPrefLen ) { sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( '-' ) + 1; - if( (nPrefLen != nStylePrefLen) || (aStyleName.compareTo( rPrefix, nPrefLen ) != 0) ) + if( (nPrefLen != nStylePrefLen) || !aStyleName.startsWith( rPrefix ) ) continue; aStyleName = aStyleName.copy( nPrefLen ); @@ -1371,7 +1371,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc if( nPrefLen ) { sal_Int32 nStylePrefLen = sParentStyleDisplayName.lastIndexOf( '-' ) + 1; - if( (nPrefLen != nStylePrefLen) || (sParentStyleDisplayName.compareTo( rPrefix, nPrefLen ) != 0) ) + if( (nPrefLen != nStylePrefLen) || !sParentStyleDisplayName.startsWith( rPrefix ) ) continue; sParentStyleDisplayName = sParentStyleDisplayName.copy( nPrefLen ); diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index c11222ff1c9b..4f332d25ab1c 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -988,7 +988,7 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( const sal_Int32 nRotateLen(aRotate.getLength()); sal_Int32 nLen = sValue.getLength(); if( nLen >= nRotateLen+3 && - 0 == sValue.compareTo( aRotate, nRotateLen ) && + sValue.startsWith(aRotate) && '(' == sValue[nRotateLen] && ')' == sValue[nLen-1] ) { diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index 713b2621a9bc..e6cf61577327 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -390,7 +390,7 @@ enum FieldIdEnum XMLTextFieldExport::GetFieldID( // search for TextField service name while( nCount2-- ) { - if( 0 == pNames2->compareTo(sPresentationServicePrefix, sPresentationServicePrefix.getLength())) + if( pNames2->startsWith(sPresentationServicePrefix) ) { // TextField found => postfix is field type! sFieldName = pNames2->copy(sPresentationServicePrefix.getLength()); diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index b2653f152871..0bc0c9617473 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2597,7 +2597,7 @@ bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange( o_rpRDFaAttributes = std::get<2>(rEntry); m_xImpl->m_BookmarkStartRanges.erase(sName); auto it(m_xImpl->m_BookmarkVector.begin()); - while (it != m_xImpl->m_BookmarkVector.end() && it->compareTo(sName)!=0) + while (it != m_xImpl->m_BookmarkVector.end() && *it != sName) { ++it; } |