summaryrefslogtreecommitdiff
path: root/sc/source/filter
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 09:25:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 20:59:31 +0200
commit61d8db6b1a2026a29f61eaa691beb3c6cf05de5c (patch)
treefc81eda81cf811256290c3e564166ef217f8268e /sc/source/filter
parent7baa60a5e9a8c48829f47db8cd98d0f05a30e235 (diff)
loplugin:buriedassign in sc
Change-Id: I9b4146c4e8814a36c7bfcd4c31f913c8412320e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92244 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/filter')
-rw-r--r--sc/source/filter/excel/xeformula.cxx67
-rw-r--r--sc/source/filter/excel/xetable.cxx4
-rw-r--r--sc/source/filter/html/htmlpars.cxx17
-rw-r--r--sc/source/filter/oox/formulabase.cxx2
4 files changed, 64 insertions, 26 deletions
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 9990155ea2e0..72dcfa8124be 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -722,17 +722,26 @@ void XclExpFmlaCompImpl::RecalcTokenClass( const XclExpTokenConvInfo& rConvInfo,
their original token class.
Array and defined name formulas: convert VAL to ARR. */
if( (mxData->mrCfg.meClassType != EXC_CLASSTYPE_CELL) && (nTokClass == EXC_TOKCLASS_VAL) )
- ChangeTokenClass( rnTokenId, nTokClass = EXC_TOKCLASS_ARR );
+ {
+ nTokClass = EXC_TOKCLASS_ARR;
+ ChangeTokenClass( rnTokenId, nTokClass );
+ }
break;
case EXC_CLASSCONV_VAL:
// convert ARR to VAL
if( nTokClass == EXC_TOKCLASS_ARR )
- ChangeTokenClass( rnTokenId, nTokClass = EXC_TOKCLASS_VAL );
+ {
+ nTokClass = EXC_TOKCLASS_VAL;
+ ChangeTokenClass( rnTokenId, nTokClass );
+ }
break;
case EXC_CLASSCONV_ARR:
// convert VAL to ARR
if( nTokClass == EXC_TOKCLASS_VAL )
- ChangeTokenClass( rnTokenId, nTokClass = EXC_TOKCLASS_ARR );
+ {
+ nTokClass = EXC_TOKCLASS_ARR;
+ ChangeTokenClass( rnTokenId, nTokClass );
+ }
break;
}
@@ -989,9 +998,11 @@ XclExpScToken XclExpFmlaCompImpl::AndTerm( XclExpScToken aTokData, bool bInParen
XclExpScToken XclExpFmlaCompImpl::CompareTerm( XclExpScToken aTokData, bool bInParentheses )
{
aTokData = ConcatTerm( aTokData, bInParentheses );
- sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetCompareTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ sal_uInt8 nOpTokenId = lclGetConcatTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = ConcatTerm( GetNextToken(), bInParentheses );
AppendBinaryOperatorToken( nOpTokenId, true, nSpaces );
@@ -1002,9 +1013,11 @@ XclExpScToken XclExpFmlaCompImpl::CompareTerm( XclExpScToken aTokData, bool bInP
XclExpScToken XclExpFmlaCompImpl::ConcatTerm( XclExpScToken aTokData, bool bInParentheses )
{
aTokData = AddSubTerm( aTokData, bInParentheses );
- sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetConcatTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ sal_uInt8 nOpTokenId = lclGetCompareTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = AddSubTerm( GetNextToken(), bInParentheses );
AppendBinaryOperatorToken( nOpTokenId, true, nSpaces );
@@ -1015,9 +1028,11 @@ XclExpScToken XclExpFmlaCompImpl::ConcatTerm( XclExpScToken aTokData, bool bInPa
XclExpScToken XclExpFmlaCompImpl::AddSubTerm( XclExpScToken aTokData, bool bInParentheses )
{
aTokData = MulDivTerm( aTokData, bInParentheses );
- sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetAddSubTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ sal_uInt8 nOpTokenId = lclGetAddSubTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = MulDivTerm( GetNextToken(), bInParentheses );
AppendBinaryOperatorToken( nOpTokenId, true, nSpaces );
@@ -1028,9 +1043,11 @@ XclExpScToken XclExpFmlaCompImpl::AddSubTerm( XclExpScToken aTokData, bool bInPa
XclExpScToken XclExpFmlaCompImpl::MulDivTerm( XclExpScToken aTokData, bool bInParentheses )
{
aTokData = PowTerm( aTokData, bInParentheses );
- sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetMulDivTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ sal_uInt8 nOpTokenId = lclGetMulDivTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = PowTerm( GetNextToken(), bInParentheses );
AppendBinaryOperatorToken( nOpTokenId, true, nSpaces );
@@ -1042,8 +1059,11 @@ XclExpScToken XclExpFmlaCompImpl::PowTerm( XclExpScToken aTokData, bool bInParen
{
aTokData = UnaryPostTerm( aTokData, bInParentheses );
sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetPowTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ nOpTokenId = lclGetPowTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = UnaryPostTerm( GetNextToken(), bInParentheses );
AppendBinaryOperatorToken( nOpTokenId, true, nSpaces );
@@ -1055,8 +1075,11 @@ XclExpScToken XclExpFmlaCompImpl::UnaryPostTerm( XclExpScToken aTokData, bool bI
{
aTokData = UnaryPreTerm( aTokData, bInParentheses );
sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetUnaryPostTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ nOpTokenId = lclGetUnaryPostTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
AppendUnaryOperatorToken( nOpTokenId, aTokData.mnSpaces );
GetNextToken( aTokData );
}
@@ -1085,9 +1108,11 @@ XclExpScToken XclExpFmlaCompImpl::ListTerm( XclExpScToken aTokData, bool bInPare
bool bHasAnyRefOp = false;
bool bHasListOp = false;
aTokData = IntersectTerm( aTokData, bHasAnyRefOp );
- sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetListTokenId( aTokData.GetOpCode(), mxData->mbStopAtSep )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ sal_uInt8 nOpTokenId = lclGetListTokenId( aTokData.GetOpCode(), mxData->mbStopAtSep );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = IntersectTerm( GetNextToken(), bHasAnyRefOp );
AppendBinaryOperatorToken( nOpTokenId, false, nSpaces );
@@ -1114,9 +1139,11 @@ XclExpScToken XclExpFmlaCompImpl::ListTerm( XclExpScToken aTokData, bool bInPare
XclExpScToken XclExpFmlaCompImpl::IntersectTerm( XclExpScToken aTokData, bool& rbHasRefOp )
{
aTokData = RangeTerm( aTokData, rbHasRefOp );
- sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetIntersectTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ sal_uInt8 nOpTokenId = lclGetIntersectTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId ==EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = RangeTerm( GetNextToken(), rbHasRefOp );
AppendBinaryOperatorToken( nOpTokenId, false, nSpaces );
@@ -1128,9 +1155,11 @@ XclExpScToken XclExpFmlaCompImpl::IntersectTerm( XclExpScToken aTokData, bool& r
XclExpScToken XclExpFmlaCompImpl::RangeTerm( XclExpScToken aTokData, bool& rbHasRefOp )
{
aTokData = Factor( aTokData );
- sal_uInt8 nOpTokenId = EXC_TOKID_NONE;
- while( mxData->mbOk && ((nOpTokenId = lclGetRangeTokenId( aTokData.GetOpCode() )) != EXC_TOKID_NONE) )
+ while( mxData->mbOk )
{
+ sal_uInt8 nOpTokenId = lclGetRangeTokenId( aTokData.GetOpCode() );
+ if (nOpTokenId == EXC_TOKID_NONE)
+ break;
sal_uInt8 nSpaces = aTokData.mnSpaces;
aTokData = Factor( GetNextToken() );
AppendBinaryOperatorToken( nOpTokenId, false, nSpaces );
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index bf2b66808aee..d23cb5f083ad 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -170,7 +170,9 @@ XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr, cons
ScAddress aAbsPos = rRef.toAbs(&GetRoot().GetDoc(), rBasePos);
XclExpArrayMap::const_iterator it = maRecMap.find(aAbsPos);
- return (it == maRecMap.end()) ? xRec : xRec = it->second;
+ if (it != maRecMap.end())
+ xRec = it->second;
+ return xRec;
}
// Shared formulas ============================================================
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 8e4a1dd6d63d..02c60140b844 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1894,10 +1894,10 @@ const SfxItemSet& ScHTMLTable::GetCurrItemSet() const
ScHTMLSize ScHTMLTable::GetSpan( const ScHTMLPos& rCellPos ) const
{
ScHTMLSize aSpan( 1, 1 );
- const ScRange* pRange = nullptr;
- if( ( (pRange = maVMergedCells.Find( rCellPos.MakeAddr() ) ) != nullptr)
- || ( (pRange = maHMergedCells.Find( rCellPos.MakeAddr() ) ) != nullptr)
- )
+ const ScRange* pRange = maVMergedCells.Find( rCellPos.MakeAddr() );
+ if (!pRange)
+ pRange = maHMergedCells.Find( rCellPos.MakeAddr() );
+ if (pRange)
aSpan.Set( pRange->aEnd.Col() - pRange->aStart.Col() + 1, pRange->aEnd.Row() - pRange->aStart.Row() + 1 );
return aSpan;
}
@@ -2386,8 +2386,15 @@ void ScHTMLTable::InsertNewCell( const ScHTMLSize& rSpanSize )
/* Find an unused cell by skipping all merged ranges that cover the
current cell position stored in maCurrCell. */
- while( ((pRange = maVMergedCells.Find( maCurrCell.MakeAddr() )) != nullptr) || ((pRange = maHMergedCells.Find( maCurrCell.MakeAddr() )) != nullptr) )
+ for (;;)
+ {
+ pRange = maVMergedCells.Find( maCurrCell.MakeAddr() );
+ if (!pRange)
+ pRange = maHMergedCells.Find( maCurrCell.MakeAddr() );
+ if (!pRange)
+ break;
maCurrCell.mnCol = pRange->aEnd.Col() + 1;
+ }
mpCurrEntryVector = &maEntryMap[ maCurrCell ];
/* If the new cell is merged horizontally, try to find collisions with
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 6d8d884c767d..b2c074a1d277 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -1544,7 +1544,7 @@ OUString FormulaProcessorBase::generateAddress2dString( const BinAddress& rAddre
{
OUStringBuffer aBuffer;
// column
- for( sal_Int32 nTemp = rAddress.mnCol; nTemp >= 0; (nTemp /= 26) -= 1 )
+ for( sal_Int32 nTemp = rAddress.mnCol; nTemp >= 0; nTemp = (nTemp / 26) - 1 )
aBuffer.insert( 0, sal_Unicode( 'A' + (nTemp % 26) ) );
if( bAbsolute )
aBuffer.insert( 0, '$' );