[Libreoffice-commits] core.git: sc/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 15 19:00:20 UTC 2020
sc/source/core/data/column.cxx | 12 +-
sc/source/core/data/column3.cxx | 13 +-
sc/source/core/data/dociter.cxx | 5
sc/source/core/data/documen4.cxx | 13 +-
sc/source/core/data/formulacell.cxx | 53 +++++---
sc/source/core/data/global2.cxx | 4
sc/source/core/data/table6.cxx | 207 ++++++++++++++++++-----------------
sc/source/core/data/validat.cxx | 41 +++---
sc/source/core/tool/chartpos.cxx | 24 ++--
sc/source/core/tool/chgtrack.cxx | 31 +++--
sc/source/core/tool/compiler.cxx | 20 ++-
sc/source/core/tool/interpr1.cxx | 4
sc/source/core/tool/interpr4.cxx | 64 ++++++----
sc/source/core/tool/token.cxx | 63 +++++-----
sc/source/filter/excel/xeformula.cxx | 67 ++++++++---
sc/source/filter/excel/xetable.cxx | 4
sc/source/filter/html/htmlpars.cxx | 17 ++
sc/source/filter/oox/formulabase.cxx | 2
sc/source/ui/app/drwtrans.cxx | 19 +--
sc/source/ui/app/inputhdl.cxx | 11 +
sc/source/ui/app/seltrans.cxx | 19 +--
sc/source/ui/dbgui/csvgrid.cxx | 8 +
sc/source/ui/dbgui/validate.cxx | 3
sc/source/ui/docshell/docsh8.cxx | 6 -
sc/source/ui/miscdlgs/anyrefdg.cxx | 3
sc/source/ui/view/dbfunc3.cxx | 21 ++-
sc/source/ui/view/gridwin.cxx | 52 ++++----
sc/source/ui/view/viewfun2.cxx | 24 ++--
28 files changed, 480 insertions(+), 330 deletions(-)
New commits:
commit 61d8db6b1a2026a29f61eaa691beb3c6cf05de5c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Apr 15 09:25:22 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Apr 15 20:59:31 2020 +0200
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 at collabora.co.uk>
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 9388e01ee1f0..a223352b8dd3 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -627,9 +627,11 @@ const ScStyleSheet* ScColumn::GetSelectionStyle( const ScMarkData& rMark, bool&
ScAttrIterator aAttrIter( pAttrArray.get(), nTop, nBottom, pDocument->GetDefPattern() );
SCROW nRow;
SCROW nDummy;
- const ScPatternAttr* pPattern;
- while (bEqual && ( pPattern = aAttrIter.Next( nRow, nDummy ) ) != nullptr)
+ while (bEqual)
{
+ const ScPatternAttr* pPattern = aAttrIter.Next( nRow, nDummy );
+ if (!pPattern)
+ break;
pNewStyle = pPattern->GetStyleSheet();
rFound = true;
if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) )
@@ -653,9 +655,11 @@ const ScStyleSheet* ScColumn::GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRo
ScAttrIterator aAttrIter( pAttrArray.get(), nRow1, nRow2, GetDoc()->GetDefPattern() );
SCROW nRow;
SCROW nDummy;
- const ScPatternAttr* pPattern;
- while (bEqual && ( pPattern = aAttrIter.Next( nRow, nDummy ) ) != nullptr)
+ while (bEqual)
{
+ const ScPatternAttr* pPattern = aAttrIter.Next( nRow, nDummy );
+ if (!pPattern)
+ break;
pNewStyle = pPattern->GetStyleSheet();
rFound = true;
if ( !pNewStyle || ( pStyle && pNewStyle != pStyle ) )
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 2f3869db93c0..88ed96df0f3c 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1965,16 +1965,17 @@ bool ScColumn::ParseString(
sal_uInt32 nIndex = 0;
sal_uInt32 nOldIndex = 0;
SvNumFormatType eNumFormatType = SvNumFormatType::ALL;
- sal_Unicode cFirstChar;
if (!aParam.mpNumFormatter)
aParam.mpNumFormatter = GetDoc()->GetFormatTable();
+ sal_Unicode cFirstChar = 0; // Text
nIndex = nOldIndex = GetNumberFormat( GetDoc()->GetNonThreadedContext(), nRow );
- if ( rString.getLength() > 1
- && (eNumFormatType = aParam.mpNumFormatter->GetType(nIndex)) != SvNumFormatType::TEXT )
- cFirstChar = rString[0];
- else
- cFirstChar = 0; // Text
+ if ( rString.getLength() > 1 )
+ {
+ eNumFormatType = aParam.mpNumFormatter->GetType(nIndex);
+ if ( eNumFormatType != SvNumFormatType::TEXT )
+ cFirstChar = rString[0];
+ }
svl::SharedStringPool& rPool = GetDoc()->GetSharedStringPool();
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 604cbbf361b0..85be65c5c17d 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1312,8 +1312,11 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
nFoundCol = GetCol();
nFoundRow = GetRow();
aPosSave = maCurPos;
+ if (IsEqualConditionFulfilled())
+ break;
+ bNext = GetNext();
}
- while ( !IsEqualConditionFulfilled() && (bNext = GetNext()));
+ while (bNext);
// There may be no pNext but equal condition fulfilled if regular
// expressions are involved. Keep the found entry and proceed.
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 871d0cba34cc..bbed307d5cc6 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -489,10 +489,12 @@ bool ScDocument::MarkUsedExternalReferences( const ScTokenArray& rArr, const ScA
ScExternalRefManager* pRefMgr = nullptr;
formula::FormulaTokenArrayPlainIterator aIter( rArr );
- formula::FormulaToken* t = nullptr;
bool bAllMarked = false;
- while (!bAllMarked && (t = aIter.GetNextReferenceOrName()) != nullptr)
+ while (!bAllMarked)
{
+ formula::FormulaToken* t = aIter.GetNextReferenceOrName();
+ if (!t)
+ break;
if (t->IsExternalRef())
{
if (!pRefMgr)
@@ -632,9 +634,10 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScI
{
const SvNumberFormatter* pFormatter = pContext ? pContext->GetFormatTable() : GetFormatTable();
const SvNumberformat* pFormat = pFormatter->GetEntry( nFormat );
- SvNumFormatType nType;
- if (pFormat && (nType = pFormat->GetMaskedType()) != SvNumFormatType::DATE
- && nType != SvNumFormatType::TIME && nType != SvNumFormatType::DATETIME )
+ if (!pFormat)
+ return fVal;
+ SvNumFormatType nType = pFormat->GetMaskedType();
+ if (nType != SvNumFormatType::DATE && nType != SvNumFormatType::TIME && nType != SvNumFormatType::DATETIME )
{
short nPrecision;
if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 90f7c70b01e7..328b881b516c 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -881,9 +881,11 @@ ScFormulaCell::ScFormulaCell(const ScFormulaCell& rCell, ScDocument& rDoc, const
if( !bCompile )
{ // Name references with references and ColRowNames
formula::FormulaTokenArrayPlainIterator aIter(*pCode);
- formula::FormulaToken* t;
- while ( ( t = aIter.GetNextReferenceOrName() ) != nullptr && !bCompile )
+ for (;;)
{
+ formula::FormulaToken* t = aIter.GetNextReferenceOrName();
+ if (!t || bCompile)
+ break;
if ( t->IsExternalRef() )
{
// External name, cell, and area references.
@@ -1094,15 +1096,17 @@ void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows )
{
MaybeInterpret();
- const ScMatrix* pMat = nullptr;
- if (pCode->GetCodeError() == FormulaError::NONE && aResult.GetType() == svMatrixCell &&
- ((pMat = aResult.GetToken()->GetMatrix()) != nullptr))
- pMat->GetDimensions( rCols, rRows );
- else
+ if (pCode->GetCodeError() == FormulaError::NONE && aResult.GetType() == svMatrixCell)
{
- rCols = 0;
- rRows = 0;
+ const ScMatrix* pMat = aResult.GetToken()->GetMatrix();
+ if (pMat)
+ {
+ pMat->GetDimensions( rCols, rRows );
+ return;
+ }
}
+ rCols = 0;
+ rRows = 0;
}
void ScFormulaCell::ResetDirty() { bDirty = bTableOpDirty = mbPostponedDirty = false; }
@@ -1699,14 +1703,17 @@ bool ScFormulaCell::Interpret(SCROW nStartOffset, SCROW nEndOffset)
* added above with rRecursionHelper.Insert() should always
* be 'this', shouldn't it? */
ScFormulaCell* pLastCell = nullptr;
- if (rRecursionHelper.GetList().size() > 1 &&
- ((pLastCell = rRecursionHelper.GetList().back().pCell) != this))
+ if (rRecursionHelper.GetList().size() > 1)
{
- pDocument->IncInterpretLevel();
- ScInterpreterContextGetterGuard aContextGetterGuard(*pDocument, pDocument->GetFormatTable());
- pLastCell->InterpretTail(
- *aContextGetterGuard.GetInterpreterContext(), SCITP_CLOSE_ITERATION_CIRCLE);
- pDocument->DecInterpretLevel();
+ pLastCell = rRecursionHelper.GetList().back().pCell;
+ if (pLastCell != this)
+ {
+ pDocument->IncInterpretLevel();
+ ScInterpreterContextGetterGuard aContextGetterGuard(*pDocument, pDocument->GetFormatTable());
+ pLastCell->InterpretTail(
+ *aContextGetterGuard.GetInterpreterContext(), SCITP_CLOSE_ITERATION_CIRCLE);
+ pDocument->DecInterpretLevel();
+ }
}
// Start at 1, init things.
rRecursionHelper.StartIteration();
@@ -2039,8 +2046,8 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa
const SvNumFormatType nRetType = pInterpreter->GetRetFormatType();
if (nRetType == SvNumFormatType::LOGICAL)
{
- double fVal;
- if ((fVal = aNewResult.GetDouble()) != 1.0 && fVal != 0.0)
+ double fVal = aNewResult.GetDouble();
+ if (fVal != 1.0 && fVal != 0.0)
bForceNumberFormat = false;
else
{
@@ -2112,10 +2119,14 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa
bSetFormat = false;
nFormatType = nOldFormatType; // that? or number?
}
- else if ((fVal = aNewResult.GetDouble()) != 1.0 && fVal != 0.0)
+ else
{
- bSetFormat = false;
- nFormatType = SvNumFormatType::NUMBER;
+ fVal = aNewResult.GetDouble();
+ if (fVal != 1.0 && fVal != 0.0)
+ {
+ bSetFormat = false;
+ nFormatType = SvNumFormatType::NUMBER;
+ }
}
}
}
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 95c6f81dffbc..0f10debc2aa1 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -421,8 +421,8 @@ Label_fallback_to_unambiguous:
// Decimal and group separator 0 => only integer and possibly exponent,
// stops at first non-digit non-sign.
fValue = ::rtl::math::stringToDouble( rStr, 0, 0, &eStatus, &nParseEnd);
- sal_Int32 nLen;
- if (eStatus == rtl_math_ConversionStatus_Ok && nParseEnd < (nLen = rStr.getLength()))
+ sal_Int32 nLen = rStr.getLength();
+ if (eStatus == rtl_math_ConversionStatus_Ok && nParseEnd < nLen)
{
// Not at string end, check for trailing blanks or switch to date or
// time parsing or bail out.
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 63eab0850af8..4769a78b2a77 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -151,119 +151,130 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::Colum
return bFound;
}
+ if (!bFound)
+ return false;
+ if ( rSearchItem.GetCommand() != SvxSearchCmd::REPLACE
+ && rSearchItem.GetCommand() != SvxSearchCmd::REPLACE_ALL )
+ return bFound;
+
+ if (!IsBlockEditable(nCol, nRow, nCol, nRow))
+ return bFound;
+
ScMatrixMode cMatrixFlag = ScMatrixMode::NONE;
- if ( bFound &&
- ( (rSearchItem.GetCommand() == SvxSearchCmd::REPLACE)
- ||(rSearchItem.GetCommand() == SvxSearchCmd::REPLACE_ALL) ) &&
- // Don't split the matrix, only replace Matrix formulas
- !( (eCellType == CELLTYPE_FORMULA &&
- ((cMatrixFlag = aCell.mpFormula->GetMatrixFlag()) == ScMatrixMode::Reference))
- // No UndoDoc => Matrix not restorable => don't replace
- || (cMatrixFlag != ScMatrixMode::NONE && !pUndoDoc) ) &&
- IsBlockEditable(nCol, nRow, nCol, nRow)
- )
+
+ // Don't split the matrix, only replace Matrix formulas
+ if (eCellType == CELLTYPE_FORMULA)
+ {
+ cMatrixFlag = aCell.mpFormula->GetMatrixFlag();
+ if(cMatrixFlag == ScMatrixMode::Reference)
+ return bFound;
+ }
+ // No UndoDoc => Matrix not restorable => don't replace
+ if (cMatrixFlag != ScMatrixMode::NONE && !pUndoDoc)
+ return bFound;
+
+ if ( cMatrixFlag == ScMatrixMode::NONE && rSearchItem.GetCommand() == SvxSearchCmd::REPLACE )
+ rUndoStr = aString;
+ else if (pUndoDoc)
+ {
+ ScAddress aAdr( nCol, nRow, nTab );
+ aCell.commit(*pUndoDoc, aAdr);
+ }
+
+ bool bRepeat = !rSearchItem.GetWordOnly();
+ do
{
- if ( cMatrixFlag == ScMatrixMode::NONE && rSearchItem.GetCommand() == SvxSearchCmd::REPLACE )
- rUndoStr = aString;
- else if (pUndoDoc)
+ // don't continue search if the found text is empty,
+ // otherwise it would never stop (#35410#)
+ if ( nEnd < nStart )
+ bRepeat = false;
+
+ OUString sReplStr = rSearchItem.GetReplaceString();
+ if (rSearchItem.GetRegExp())
{
- ScAddress aAdr( nCol, nRow, nTab );
- aCell.commit(*pUndoDoc, aAdr);
+ pSearchText->ReplaceBackReferences( sReplStr, aString, aSearchResult );
+ OUStringBuffer aStrBuffer(aString);
+ aStrBuffer.remove(nStart, nEnd-nStart+1);
+ aStrBuffer.insert(nStart, sReplStr);
+ aString = aStrBuffer.makeStringAndClear();
}
- bool bRepeat = !rSearchItem.GetWordOnly();
- do
+ else
{
- // don't continue search if the found text is empty,
- // otherwise it would never stop (#35410#)
- if ( nEnd < nStart )
- bRepeat = false;
+ OUStringBuffer aStrBuffer(aString);
+ aStrBuffer.remove(nStart, nEnd-nStart+1);
+ aStrBuffer.insert(nStart, rSearchItem.GetReplaceString());
+ aString = aStrBuffer.makeStringAndClear();
+ }
- OUString sReplStr = rSearchItem.GetReplaceString();
- if (rSearchItem.GetRegExp())
- {
- pSearchText->ReplaceBackReferences( sReplStr, aString, aSearchResult );
- OUStringBuffer aStrBuffer(aString);
- aStrBuffer.remove(nStart, nEnd-nStart+1);
- aStrBuffer.insert(nStart, sReplStr);
- aString = aStrBuffer.makeStringAndClear();
- }
- else
- {
- OUStringBuffer aStrBuffer(aString);
- aStrBuffer.remove(nStart, nEnd-nStart+1);
- aStrBuffer.insert(nStart, rSearchItem.GetReplaceString());
- aString = aStrBuffer.makeStringAndClear();
- }
+ // Adjust index
+ if (bDoBack)
+ {
+ nEnd = nStart;
+ nStart = 0;
+ }
+ else
+ {
+ nStart = nStart + sReplStr.getLength();
+ nEnd = aString.getLength();
+ }
- // Adjust index
- if (bDoBack)
+ // continue search ?
+ if (bRepeat)
+ {
+ if ( rSearchItem.GetCommand() != SvxSearchCmd::REPLACE_ALL || nStart >= nEnd )
+ bRepeat = false;
+ else if (bDoBack)
{
- nEnd = nStart;
- nStart = 0;
+ sal_Int32 nTemp=nStart; nStart=nEnd; nEnd=nTemp;
+ bRepeat = pSearchText->SearchBackward(aString, &nStart, &nEnd, &aSearchResult);
+ // change results to definition before 614:
+ --nEnd;
}
else
{
- nStart = nStart + sReplStr.getLength();
- nEnd = aString.getLength();
- }
-
- // continue search ?
- if (bRepeat)
- {
- if ( rSearchItem.GetCommand() != SvxSearchCmd::REPLACE_ALL || nStart >= nEnd )
- bRepeat = false;
- else if (bDoBack)
- {
- sal_Int32 nTemp=nStart; nStart=nEnd; nEnd=nTemp;
- bRepeat = pSearchText->SearchBackward(aString, &nStart, &nEnd, &aSearchResult);
- // change results to definition before 614:
- --nEnd;
- }
- else
- {
- bRepeat = pSearchText->SearchForward(aString, &nStart, &nEnd, &aSearchResult);
- // change results to definition before 614:
- --nEnd;
- }
+ bRepeat = pSearchText->SearchForward(aString, &nStart, &nEnd, &aSearchResult);
+ // change results to definition before 614:
+ --nEnd;
}
}
- while (bRepeat);
- if (rSearchItem.GetCellType() == SvxSearchCellType::NOTE)
- {
- // NB: rich text format is lost.
- // This is also true of Cells.
- if (pNote)
- pNote->SetText( ScAddress( nCol, nRow, nTab ), aString );
- }
- else if ( cMatrixFlag != ScMatrixMode::NONE )
- { // don't split Matrix
- if ( aString.getLength() > 2 )
- { // remove {} here so that "{=" can be replaced by "{=..."
- if ( aString[ aString.getLength()-1 ] == '}' )
- aString = aString.copy( 0, aString.getLength()-1 );
- if ( aString[0] == '{' )
- aString = aString.copy( 1 );
- }
- ScAddress aAdr( nCol, nRow, nTab );
- ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr,
- aString, pDocument->GetGrammar(), cMatrixFlag );
- SCCOL nMatCols;
- SCROW nMatRows;
- aCell.mpFormula->GetMatColsRows(nMatCols, nMatRows);
- pFCell->SetMatColsRows( nMatCols, nMatRows );
- aCol[nCol].SetFormulaCell(nRow, pFCell);
- }
- else if ( bMultiLine && aString.indexOf('\n') != -1 )
- {
- ScFieldEditEngine& rEngine = pDocument->GetEditEngine();
- rEngine.SetTextCurrentDefaults(aString);
- SetEditText(nCol, nRow, rEngine.CreateTextObject());
+ }
+ while (bRepeat);
+ if (rSearchItem.GetCellType() == SvxSearchCellType::NOTE)
+ {
+ // NB: rich text format is lost.
+ // This is also true of Cells.
+ if (pNote)
+ pNote->SetText( ScAddress( nCol, nRow, nTab ), aString );
+ }
+ else if ( cMatrixFlag != ScMatrixMode::NONE )
+ { // don't split Matrix
+ if ( aString.getLength() > 2 )
+ { // remove {} here so that "{=" can be replaced by "{=..."
+ if ( aString[ aString.getLength()-1 ] == '}' )
+ aString = aString.copy( 0, aString.getLength()-1 );
+ if ( aString[0] == '{' )
+ aString = aString.copy( 1 );
}
- else
- aCol[nCol].SetString(nRow, nTab, aString, pDocument->GetAddressConvention());
- // pCell is invalid now (deleted)
- aCol[nCol].InitBlockPosition( rBlockPos ); // invalidate also the cached position
+ ScAddress aAdr( nCol, nRow, nTab );
+ ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr,
+ aString, pDocument->GetGrammar(), cMatrixFlag );
+ SCCOL nMatCols;
+ SCROW nMatRows;
+ aCell.mpFormula->GetMatColsRows(nMatCols, nMatRows);
+ pFCell->SetMatColsRows( nMatCols, nMatRows );
+ aCol[nCol].SetFormulaCell(nRow, pFCell);
+ }
+ else if ( bMultiLine && aString.indexOf('\n') != -1 )
+ {
+ ScFieldEditEngine& rEngine = pDocument->GetEditEngine();
+ rEngine.SetTextCurrentDefaults(aString);
+ SetEditText(nCol, nRow, rEngine.CreateTextObject());
}
+ else
+ aCol[nCol].SetString(nRow, nTab, aString, pDocument->GetAddressConvention());
+ // pCell is invalid now (deleted)
+ aCol[nCol].InitBlockPosition( rBlockPos ); // invalidate also the cached position
+
return bFound;
}
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 056fd3eb6547..e2921aaf7368 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -732,32 +732,35 @@ bool ScValidationData::GetSelectionFromFormula(
ScRange aRange;
ScTokenArray* pArr = const_cast<ScTokenArray*>(&rTokArr);
- formula::FormulaTokenArrayPlainIterator aIter(*pArr);
- formula::FormulaToken* t = nullptr;
- if (pArr->GetLen() == 1 && (t = aIter.GetNextReferenceOrName()) != nullptr)
+ if (pArr->GetLen() == 1)
{
- OpCode eOpCode = t->GetOpCode();
- if (eOpCode == ocDBArea || eOpCode == ocTableRef)
+ formula::FormulaTokenArrayPlainIterator aIter(*pArr);
+ formula::FormulaToken* t = aIter.GetNextReferenceOrName();
+ if (t)
{
- if (const ScDBData* pDBData = pDocument->GetDBCollection()->getNamedDBs().findByIndex(t->GetIndex()))
+ OpCode eOpCode = t->GetOpCode();
+ if (eOpCode == ocDBArea || eOpCode == ocTableRef)
{
- pDBData->GetArea(aRange);
- bRef = true;
+ if (const ScDBData* pDBData = pDocument->GetDBCollection()->getNamedDBs().findByIndex(t->GetIndex()))
+ {
+ pDBData->GetArea(aRange);
+ bRef = true;
+ }
}
- }
- else if (eOpCode == ocName)
- {
- const ScRangeData* pName = pDocument->FindRangeNameBySheetAndIndex( t->GetSheet(), t->GetIndex());
- if (pName && pName->IsReference(aRange))
+ else if (eOpCode == ocName)
{
- bRef = true;
+ const ScRangeData* pName = pDocument->FindRangeNameBySheetAndIndex( t->GetSheet(), t->GetIndex());
+ if (pName && pName->IsReference(aRange))
+ {
+ bRef = true;
+ }
}
- }
- else if (t->GetType() != svIndex)
- {
- if (pArr->IsValidReference(aRange, rPos))
+ else if (t->GetType() != svIndex)
{
- bRef = true;
+ if (pArr->IsValidReference(aRange, rPos))
+ {
+ bRef = true;
+ }
}
}
}
diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx
index 6448fa3d8d91..89326661f319 100644
--- a/sc/source/core/tool/chartpos.cxx
+++ b/sc/source/core/tool/chartpos.cxx
@@ -204,10 +204,14 @@ void ScChartPositioner::GlueState()
else
*p = CellState::Free;
}
- if ( bGlue && *(p = (pA.get() + (((static_cast<sal_uLong>(nCol)+1) * nR) - 1))) == CellState::Free )
- { // mark column as totally unused
- *p = CellState::Glue;
- bGlueCols = true; // one unused column at least
+ if ( bGlue )
+ {
+ p = pA.get() + (((static_cast<sal_uLong>(nCol)+1) * nR) - 1);
+ if (*p == CellState::Free)
+ { // mark column as totally unused
+ *p = CellState::Glue;
+ bGlueCols = true; // one unused column at least
+ }
}
}
@@ -227,10 +231,14 @@ void ScChartPositioner::GlueState()
else
*p = CellState::Free;
}
- if ( bGlue && *(p = (pA.get() + (((static_cast<sal_uLong>(nC)-1) * nR) + nRow))) == CellState::Free )
- { // mark row as totally unused
- *p = CellState::Glue;
- bGlueRows = true; // one unused row at least
+ if ( bGlue )
+ {
+ p = pA.get() + (((static_cast<sal_uLong>(nC)-1) * nR) + nRow);
+ if (*p == CellState::Free )
+ { // mark row as totally unused
+ *p = CellState::Glue;
+ bGlueRows = true; // one unused row at least
+ }
}
}
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index a29e21d244c0..a6524f95da7d 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -370,9 +370,8 @@ bool ScChangeAction::IsDeletedInDelType( ScChangeActionType eDelType ) const
}
while ( pL )
{
- ScChangeAction* p;
- if ( (p = pL->GetAction()) != nullptr &&
- (p->GetType() == eDelType || p->GetType() == eInsType) )
+ ScChangeAction* p = pL->GetAction();
+ if ( p != nullptr && (p->GetType() == eDelType || p->GetType() == eInsType) )
return true;
pL = pL->GetNext();
}
@@ -3654,9 +3653,13 @@ void ScChangeTrack::UpdateReference( ScChangeAction** ppFirstAction,
// Split up the ContentChain
ScChangeActionContent *pHere, *pTmp;
pHere = static_cast<ScChangeActionContent*>(p);
- while ( (pTmp = pHere->GetPrevContent()) != nullptr &&
- pTmp->GetActionNumber() > nEndLastCut )
+ for (;;)
+ {
+ pTmp = pHere->GetPrevContent();
+ if (!pTmp || pTmp->GetActionNumber() <= nEndLastCut)
+ break;
pHere = pTmp;
+ }
if ( pTmp )
{ // Becomes TopContent of the Move
pTmp->SetNextContent( nullptr );
@@ -3888,9 +3891,14 @@ void ScChangeTrack::GetDependents( ScChangeAction* pAct,
// if this Delete is at the top of a Row
ScChangeActionType eType = pDel->GetType();
ScChangeAction* p = pDel;
- while ( (p = p->GetPrev()) != nullptr && p->GetType() == eType &&
- !static_cast<ScChangeActionDel*>(p)->IsTopDelete() )
+ for (;;)
+ {
+ p = p->GetPrev();
+ if (!p || p->GetType() != eType ||
+ static_cast<ScChangeActionDel*>(p)->IsTopDelete() )
+ break;
rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
+ }
// delete this in the map too
rMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
}
@@ -4030,10 +4038,13 @@ bool ScChangeTrack::SelectContent( ScChangeAction* pAct, bool bOldest )
if ( bOldest )
{
pContent = pContent->GetTopContent();
- ScChangeActionContent* pPrevContent;
- while ( (pPrevContent = pContent->GetPrevContent()) != nullptr &&
- pPrevContent->IsVirgin() )
+ for (;;)
+ {
+ ScChangeActionContent* pPrevContent = pContent->GetPrevContent();
+ if ( !pPrevContent || !pPrevContent->IsVirgin() )
+ break;
pContent = pPrevContent;
+ }
}
if ( !pContent->IsClickable() )
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 0c1e9e5d07bb..8217c6a411e8 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2954,8 +2954,10 @@ bool ScCompiler::IsOpCode( const OUString& rName, bool bInArray )
bFound = true;
}
}
- OpCode eOp;
- if (bFound && ((eOp = maRawToken.GetOpCode()) == ocSub || eOp == ocNegSub))
+ if (!bFound)
+ return false;
+ OpCode eOp = maRawToken.GetOpCode();
+ if (eOp == ocSub || eOp == ocNegSub)
{
bool bShouldBeNegSub =
(eLastOp == ocOpen || eLastOp == ocSep || eLastOp == ocNegSub ||
@@ -4026,12 +4028,14 @@ void ScCompiler::AutoCorrectParsedSymbol()
{
OUString aSymbol( aCorrectedSymbol );
OUString aDoc;
- sal_Int32 nPosition;
- if ( aSymbol[0] == '\''
- && ((nPosition = aSymbol.indexOf( "'#" )) != -1) )
- { // Split off 'Doc'#, may be d:\... or whatever
- aDoc = aSymbol.copy(0, nPosition + 2);
- aSymbol = aSymbol.copy(nPosition + 2);
+ if ( aSymbol[0] == '\'' )
+ {
+ sal_Int32 nPosition = aSymbol.indexOf( "'#" );
+ if (nPosition != -1)
+ { // Split off 'Doc'#, may be d:\... or whatever
+ aDoc = aSymbol.copy(0, nPosition + 2);
+ aSymbol = aSymbol.copy(nPosition + 2);
+ }
}
sal_Int32 nRefs = comphelper::string::getTokenCount(aSymbol, ':');
bool bColons;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 4daf1afaa169..8f54c25d258b 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8180,8 +8180,8 @@ void ScInterpreter::ScIndirect()
// Anything else that resolves to one reference could be added
// here, but we don't want to compile every arbitrary string. This
// is already nasty enough...
- sal_Int32 nIndex = 0;
- if ((nIndex = sRefStr.indexOf('[')) >= 0 && sRefStr.indexOf(']',nIndex+1) > nIndex)
+ sal_Int32 nIndex = sRefStr.indexOf('[');
+ if (nIndex >= 0 && sRefStr.indexOf(']',nIndex+1) > nIndex)
{
do
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index f1506f60adeb..2be1e335a40e 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3711,19 +3711,22 @@ void ScInterpreter::ScColRowNameAuto()
if (aAbs.aEnd.Row() > nRow2)
aAbs.aEnd.SetRow(nRow2);
SCROW nMyRow;
- if ( aPos.Col() == nStartCol
- && nStartRow <= (nMyRow = aPos.Row()) && nMyRow <= aAbs.aEnd.Row())
- { //Formula in the same column and within the range
- if ( nMyRow == nStartRow )
- { // take the rest under the name
- nStartRow++;
- if ( nStartRow > pDok->MaxRow() )
- nStartRow = pDok->MaxRow();
- aAbs.aStart.SetRow(nStartRow);
- }
- else
- { // below the name to the formula cell
- aAbs.aEnd.SetRow(nMyRow - 1);
+ if ( aPos.Col() == nStartCol )
+ {
+ nMyRow = aPos.Row();
+ if ( nStartRow <= nMyRow && nMyRow <= aAbs.aEnd.Row())
+ { //Formula in the same column and within the range
+ if ( nMyRow == nStartRow )
+ { // take the rest under the name
+ nStartRow++;
+ if ( nStartRow > pDok->MaxRow() )
+ nStartRow = pDok->MaxRow();
+ aAbs.aStart.SetRow(nStartRow);
+ }
+ else
+ { // below the name to the formula cell
+ aAbs.aEnd.SetRow(nMyRow - 1);
+ }
}
}
}
@@ -3734,19 +3737,22 @@ void ScInterpreter::ScColRowNameAuto()
if (aAbs.aEnd.Col() > nCol2)
aAbs.aEnd.SetCol(nCol2);
SCCOL nMyCol;
- if ( aPos.Row() == nStartRow
- && nStartCol <= (nMyCol = aPos.Col()) && nMyCol <= aAbs.aEnd.Col())
- { //Formula in the same column and within the range
- if ( nMyCol == nStartCol )
- { // take the rest under the name
- nStartCol++;
- if ( nStartCol > pDok->MaxCol() )
- nStartCol = pDok->MaxCol();
- aAbs.aStart.SetCol(nStartCol);
- }
- else
- { // below the name to the formula cell
- aAbs.aEnd.SetCol(nMyCol - 1);
+ if ( aPos.Row() == nStartRow )
+ {
+ nMyCol = aPos.Col();
+ if (nStartCol <= nMyCol && nMyCol <= aAbs.aEnd.Col())
+ { //Formula in the same column and within the range
+ if ( nMyCol == nStartCol )
+ { // take the rest under the name
+ nStartCol++;
+ if ( nStartCol > pDok->MaxCol() )
+ nStartCol = pDok->MaxCol();
+ aAbs.aStart.SetCol(nStartCol);
+ }
+ else
+ { // below the name to the formula cell
+ aAbs.aEnd.SetCol(nMyCol - 1);
+ }
}
}
}
@@ -3966,9 +3972,11 @@ StackVar ScInterpreter::Interpret()
OpCode eOp = ocNone;
aCode.Reset();
- while( ( pCur = aCode.Next() ) != nullptr
- && (nGlobalError == FormulaError::NONE || nErrorFunction <= nErrorFunctionCount) )
+ for (;;)
{
+ pCur = aCode.Next();
+ if (!pCur || (nGlobalError != FormulaError::NONE && nErrorFunction > nErrorFunctionCount) )
+ break;
eOp = pCur->GetOpCode();
cPar = pCur->GetByte();
if ( eOp == ocPush )
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index fc08062c965f..2e4977ced2ee 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -657,9 +657,10 @@ const ScRefList* ScRefListToken::GetRefList() const { return &aRefList;
bool ScRefListToken::IsArrayResult() const { return mbArrayResult; }
bool ScRefListToken::operator==( const FormulaToken& r ) const
{
- const ScRefListToken* p;
- return FormulaToken::operator==( r ) && &aRefList == r.GetRefList() &&
- ((p = dynamic_cast<const ScRefListToken*>(&r)) != nullptr) && mbArrayResult == p->IsArrayResult();
+ if (!FormulaToken::operator==( r ) || &aRefList != r.GetRefList())
+ return false;
+ const ScRefListToken* p = dynamic_cast<const ScRefListToken*>(&r);
+ return p && mbArrayResult == p->IsArrayResult();
}
ScMatrixToken::ScMatrixToken( const ScMatrixRef& p ) :
@@ -2168,22 +2169,26 @@ void ScTokenArray::MergeRangeReference( const ScAddress & rPos )
if (!pCode || !nLen)
return;
sal_uInt16 nIdx = nLen;
- FormulaToken *p1, *p2, *p3; // ref, ocRange, ref
+
// The actual types are checked in extendRangeReference().
- if (((p3 = PeekPrev(nIdx)) != nullptr) &&
- (((p2 = PeekPrev(nIdx)) != nullptr) && p2->GetOpCode() == ocRange) &&
- ((p1 = PeekPrev(nIdx)) != nullptr))
+ FormulaToken *p3 = PeekPrev(nIdx); // ref
+ if (!p3)
+ return;
+ FormulaToken *p2 = PeekPrev(nIdx); // ocRange
+ if (!p2 || p2->GetOpCode() != ocRange)
+ return;
+ FormulaToken *p1 = PeekPrev(nIdx); // ref
+ if (!p1)
+ return;
+ FormulaTokenRef p = extendRangeReference( *mxSheetLimits, *p1, *p3, rPos, true);
+ if (p)
{
- FormulaTokenRef p = extendRangeReference( *mxSheetLimits, *p1, *p3, rPos, true);
- if (p)
- {
- p->IncRef();
- p1->DecRef();
- p2->DecRef();
- p3->DecRef();
- nLen -= 2;
- pCode[ nLen-1 ] = p.get();
- }
+ p->IncRef();
+ p1->DecRef();
+ p2->DecRef();
+ p3->DecRef();
+ nLen -= 2;
+ pCode[ nLen-1 ] = p.get();
}
}
@@ -2267,28 +2272,28 @@ bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
switch ( eDir )
{
case DIR_BOTTOM :
- if ( rPos.Row() < mxSheetLimits->mnMaxRow )
- nRow = (nExtend = rPos.Row()) + 1;
- else
+ if ( rPos.Row() >= mxSheetLimits->mnMaxRow )
return false;
+ nExtend = rPos.Row();
+ nRow = nExtend + 1;
break;
case DIR_RIGHT :
- if ( rPos.Col() < mxSheetLimits->mnMaxCol )
- nCol = static_cast<SCCOL>(nExtend = rPos.Col()) + 1;
- else
+ if ( rPos.Col() >= mxSheetLimits->mnMaxCol )
return false;
+ nExtend = rPos.Col();
+ nCol = static_cast<SCCOL>(nExtend) + 1;
break;
case DIR_TOP :
- if ( rPos.Row() > 0 )
- nRow = (nExtend = rPos.Row()) - 1;
- else
+ if ( rPos.Row() <= 0 )
return false;
+ nExtend = rPos.Row();
+ nRow = nExtend - 1;
break;
case DIR_LEFT :
- if ( rPos.Col() > 0 )
- nCol = static_cast<SCCOL>(nExtend = rPos.Col()) - 1;
- else
+ if ( rPos.Col() <= 0 )
return false;
+ nExtend = rPos.Col();
+ nCol = static_cast<SCCOL>(nExtend) - 1;
break;
default:
OSL_FAIL( "unknown Direction" );
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, '$' );
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx
index 9b6529b18601..ac338fa2c115 100644
--- a/sc/source/ui/app/drwtrans.cxx
+++ b/sc/source/ui/app/drwtrans.cxx
@@ -142,17 +142,18 @@ ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDo
if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
{
OUString aUrl = sTmp;
- OUString aAbs;
- const SfxMedium* pMedium;
- if (pContainerShell && (pMedium = pContainerShell->GetMedium()) != nullptr)
+ OUString aAbs = aUrl;
+ if (pContainerShell)
{
- bool bWasAbs = true;
- aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ).
- GetMainURL(INetURLObject::DecodeMechanism::NONE);
- // full path as stored INetBookmark must be encoded
+ const SfxMedium* pMedium = pContainerShell->GetMedium();
+ if (pMedium)
+ {
+ bool bWasAbs = true;
+ aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ).
+ GetMainURL(INetURLObject::DecodeMechanism::NONE);
+ // full path as stored INetBookmark must be encoded
+ }
}
- else
- aAbs = aUrl;
// Label
OUString aLabel;
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index bea2cc244eb3..530ad88ab0b7 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3265,8 +3265,13 @@ void ScInputHandler::AddRefEntry()
OUString aText = GetEditText(mpEditEngine.get());
sal_Unicode cLastChar = 0;
sal_Int32 nPos = aText.getLength() - 1;
- while (nPos >= 0 && ((cLastChar = aText[nPos]) == ' ')) //checking space
+ while (nPos >= 0) //checking space
+ {
+ cLastChar = aText[nPos];
+ if (cLastChar != ' ')
+ break;
--nPos;
+ }
bool bAppendSeparator = (cLastChar != '(' && cLastChar != cSep && cLastChar != '=');
if (bAppendSeparator)
@@ -3285,7 +3290,9 @@ void ScInputHandler::SetReference( const ScRange& rRef, const ScDocument& rDoc )
HideTip();
const ScDocument* pThisDoc = nullptr;
- bool bOtherDoc = (pRefViewSh && ((pThisDoc = pRefViewSh->GetViewData().GetDocument()) != &rDoc));
+ if (pRefViewSh)
+ pThisDoc = pRefViewSh->GetViewData().GetDocument();
+ bool bOtherDoc = (pThisDoc != &rDoc);
if (bOtherDoc && !rDoc.GetDocumentShell()->HasName())
{
// References to unnamed document; that doesn't work
diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx
index a2f4b44c8c45..1757b64749bd 100644
--- a/sc/source/ui/app/seltrans.cxx
+++ b/sc/source/ui/app/seltrans.cxx
@@ -114,16 +114,17 @@ ScSelectionTransferObj* ScSelectionTransferObj::CreateFromView( ScTabView* pView
// allow MultiMarked because GetSimpleArea may be able to merge into a simple range
// (GetSimpleArea modifies a local copy of MarkData)
// Also allow simple filtered area.
- ScMarkType eMarkType;
- if ( ( rMark.IsMarked() || rMark.IsMultiMarked() ) &&
- (((eMarkType = rViewData.GetSimpleArea( aRange )) == SC_MARK_SIMPLE) ||
- (eMarkType == SC_MARK_SIMPLE_FILTERED)) )
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
{
- // only for "real" selection, cursor alone isn't used
- if ( aRange.aStart == aRange.aEnd )
- eMode = SC_SELTRANS_CELL;
- else
- eMode = SC_SELTRANS_CELLS;
+ ScMarkType eMarkType = rViewData.GetSimpleArea( aRange );
+ if (eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED)
+ {
+ // only for "real" selection, cursor alone isn't used
+ if ( aRange.aStart == aRange.aEnd )
+ eMode = SC_SELTRANS_CELL;
+ else
+ eMode = SC_SELTRANS_CELLS;
+ }
}
}
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index c69b35ac9a1e..dad4e9f2d299 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -156,7 +156,13 @@ void ScCsvGrid::UpdateOffsetX()
{
sal_Int32 nLastLine = GetLastVisLine() + 1;
sal_Int32 nDigits = 2;
- while( nLastLine /= 10 ) ++nDigits;
+ for (;;)
+ {
+ nLastLine /= 10;
+ if (!nLastLine)
+ break;
+ ++nDigits;
+ }
nDigits = std::max( nDigits, sal_Int32( 3 ) );
Execute(CSVCMD_SETHDRWIDTH, GetDrawingArea()->get_approximate_digit_width() * nDigits);
}
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
index 9e1e2693644d..0c1f63cabdfd 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -862,7 +862,8 @@ bool ScValidationDlg::SetupRefDlg()
if( EnterRefMode() )
{
SetModal( false );
- return m_bOwnRefHdlr = true && EnterRefStatus();
+ m_bOwnRefHdlr = true;
+ return EnterRefStatus();
}
return false;
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 0dc7570d6d54..d4bfa92931f3 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -999,10 +999,12 @@ ErrCode ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncoding
const sal_Int32* pColLengths = aColLengths.getConstArray();
ScHorizontalCellIterator aIter( &m_aDocument, nTab, nFirstCol,
nDocRow, nLastCol, nDocRow);
- ScRefCellValue* pCell = nullptr;
bool bTest = true;
- while (bTest && ((pCell = aIter.GetNext( nDocCol, nDocRow)) != nullptr))
+ while (bTest)
{
+ ScRefCellValue* pCell = aIter.GetNext( nDocCol, nDocRow);
+ if (!pCell)
+ break;
SCCOL nCol = nDocCol - nFirstCol;
switch (pColTypes[nCol])
{
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 0fa7bff3634d..a5149123db4f 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -612,7 +612,8 @@ bool ScRefHandler::EnterRefMode()
m_aHelper.SetDispatcherLock( true );
- return m_bInRefMode = true;
+ m_bInRefMode = true;
+ return m_bInRefMode;
}
ScRefHandler::~ScRefHandler() COVERITY_NOEXCEPT_FALSE
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 0093c96820f6..8b7782ed2e25 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -145,8 +145,11 @@ void ScDBFunc::TestRemoveOutline( bool& rCol, bool& rRow )
{
ScOutlineArray& rArray = pTable->GetColArray();
ScSubOutlineIterator aColIter( &rArray );
- while ((pEntry=aColIter.GetNext()) != nullptr && !bColFound)
+ while (bColFound)
{
+ pEntry=aColIter.GetNext();
+ if (!pEntry)
+ break;
nStart = pEntry->GetStart();
nEnd = pEntry->GetEnd();
if ( nStartCol<=static_cast<SCCOL>(nEnd) && nEndCol>=static_cast<SCCOL>(nStart) )
@@ -160,8 +163,11 @@ void ScDBFunc::TestRemoveOutline( bool& rCol, bool& rRow )
{
ScOutlineArray& rArray = pTable->GetRowArray();
ScSubOutlineIterator aRowIter( &rArray );
- while ((pEntry=aRowIter.GetNext()) != nullptr && !bRowFound)
+ while (!bRowFound)
{
+ pEntry=aRowIter.GetNext();
+ if (!pEntry)
+ break;
nStart = pEntry->GetStart();
nEnd = pEntry->GetEnd();
if ( nStartRow<=nEnd && nEndRow>=nStart )
@@ -284,7 +290,6 @@ bool ScDBFunc::OutlinePossible(bool bHide)
ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
if (pTable)
{
- ScOutlineEntry* pEntry;
SCCOLROW nStart;
SCCOLROW nEnd;
@@ -292,8 +297,11 @@ bool ScDBFunc::OutlinePossible(bool bHide)
ScOutlineArray& rColArray = pTable->GetColArray();
ScSubOutlineIterator aColIter( &rColArray );
- while ((pEntry=aColIter.GetNext()) != nullptr && !bEnable)
+ while (!bEnable)
{
+ ScOutlineEntry* pEntry = aColIter.GetNext();
+ if (!pEntry)
+ break;
nStart = pEntry->GetStart();
nEnd = pEntry->GetEnd();
if ( bHide )
@@ -314,8 +322,11 @@ bool ScDBFunc::OutlinePossible(bool bHide)
ScOutlineArray& rRowArray = pTable->GetRowArray();
ScSubOutlineIterator aRowIter( &rRowArray );
- while ((pEntry=aRowIter.GetNext()) != nullptr)
+ for (;;)
{
+ ScOutlineEntry* pEntry = aRowIter.GetNext();
+ if (!pEntry)
+ break;
nStart = pEntry->GetStart();
nEnd = pEntry->GetEnd();
if ( bHide )
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index f1d64e6d639c..0fde9121afc8 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2511,34 +2511,36 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt )
// Page-Break-Mode
- sal_uInt16 nBreakType;
- if ( !nButtonDown && pViewData->IsPagebreakMode() &&
- ( nBreakType = HitPageBreak( rMEvt.GetPosPixel(), nullptr, nullptr, nullptr ) ) != 0 )
+ if ( !nButtonDown && pViewData->IsPagebreakMode() )
{
- PointerStyle eNew = PointerStyle::Arrow;
- switch ( nBreakType )
+ sal_uInt16 nBreakType = HitPageBreak( rMEvt.GetPosPixel(), nullptr, nullptr, nullptr );
+ if (nBreakType != 0 )
{
- case SC_PD_RANGE_L:
- case SC_PD_RANGE_R:
- case SC_PD_BREAK_H:
- eNew = PointerStyle::ESize;
- break;
- case SC_PD_RANGE_T:
- case SC_PD_RANGE_B:
- case SC_PD_BREAK_V:
- eNew = PointerStyle::SSize;
- break;
- case SC_PD_RANGE_TL:
- case SC_PD_RANGE_BR:
- eNew = PointerStyle::SESize;
- break;
- case SC_PD_RANGE_TR:
- case SC_PD_RANGE_BL:
- eNew = PointerStyle::NESize;
- break;
+ PointerStyle eNew = PointerStyle::Arrow;
+ switch ( nBreakType )
+ {
+ case SC_PD_RANGE_L:
+ case SC_PD_RANGE_R:
+ case SC_PD_BREAK_H:
+ eNew = PointerStyle::ESize;
+ break;
+ case SC_PD_RANGE_T:
+ case SC_PD_RANGE_B:
+ case SC_PD_BREAK_V:
+ eNew = PointerStyle::SSize;
+ break;
+ case SC_PD_RANGE_TL:
+ case SC_PD_RANGE_BR:
+ eNew = PointerStyle::SESize;
+ break;
+ case SC_PD_RANGE_TR:
+ case SC_PD_RANGE_BL:
+ eNew = PointerStyle::NESize;
+ break;
+ }
+ SetPointer( eNew );
+ bCross = true;
}
- SetPointer( eNew );
- bCross = true;
}
// Show fill cursor?
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 697b8ae19736..09e5b87526cb 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -319,9 +319,11 @@ static bool lcl_FindNextSumEntryInColumn( ScDocument* pDoc, SCCOL nCol, SCROW& n
{
const SCROW nTmp = nRow;
ScAutoSum eSkip = ScAutoSumNone;
- while ( ( eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_TOP, nExtend ) ) == ScAutoSumData &&
- nRow > nMinRow )
+ for (;;)
{
+ eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_TOP, nExtend );
+ if (eSkip != ScAutoSumData || nRow <= nMinRow )
+ break;
--nRow;
}
return eSkip >= ScAutoSumSum && nRow < nTmp;
@@ -332,9 +334,11 @@ static bool lcl_FindNextSumEntryInRow( ScDocument* pDoc, SCCOL& nCol, SCROW nRow
{
const SCCOL nTmp = nCol;
ScAutoSum eSkip = ScAutoSumNone;
- while ( ( eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_LEFT, nExtend ) ) == ScAutoSumData &&
- nCol > nMinCol )
+ for (;;)
{
+ eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_LEFT, nExtend );
+ if (eSkip != ScAutoSumData || nCol <= nMinCol )
+ break;
--nCol;
}
return eSkip >= ScAutoSumSum && nCol < nTmp;
@@ -372,9 +376,11 @@ static ScAutoSum lcl_GetAutoSumForColumnRange( ScDocument* pDoc, ScRangeList& rR
}
else
{
- while ( nStartRow > aStart.Row() &&
- (eSum = lcl_IsAutoSumData( pDoc, nCol, nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ )) < ScAutoSumSum )
+ while ( nStartRow > aStart.Row() )
{
+ eSum = lcl_IsAutoSumData( pDoc, nCol, nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ );
+ if (eSum >= ScAutoSumSum )
+ break;
--nStartRow;
}
rRangeList.push_back( ScRange( nCol, nStartRow, nTab, nCol, nEndRow, nTab ) );
@@ -417,9 +423,11 @@ static ScAutoSum lcl_GetAutoSumForRowRange( ScDocument* pDoc, ScRangeList& rRang
}
else
{
- while ( nStartCol > aStart.Col() &&
- (eSum = lcl_IsAutoSumData( pDoc, nStartCol-1, nRow, nTab, DIR_LEFT, nExtend /*out*/ )) < ScAutoSumSum )
+ while ( nStartCol > aStart.Col() )
{
+ eSum = lcl_IsAutoSumData( pDoc, nStartCol-1, nRow, nTab, DIR_LEFT, nExtend /*out*/ );
+ if (eSum >= ScAutoSumSum )
+ break;
--nStartCol;
}
rRangeList.push_back( ScRange( nStartCol, nRow, nTab, nEndCol, nRow, nTab ) );
More information about the Libreoffice-commits
mailing list