diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-29 16:12:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 09:59:39 +0200 |
commit | 75f398b22ae14dcf442abf6b1c92a50509565ae5 (patch) | |
tree | 3532d576d4cea3cdf420c8dfa662c876b57e1428 /sc/source/core/data/conditio.cxx | |
parent | 0c311bfbf67441823f8b3916db963e2680e9eb43 (diff) |
loplugin:flatten in sc/core/data
Change-Id: I9ffe58d68172c6fe9c76000c01c0c67a03967146
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99699
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core/data/conditio.cxx')
-rw-r--r-- | sc/source/core/data/conditio.cxx | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index b18b68e1fc68..94a8dd4be086 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -311,24 +311,24 @@ void ScConditionEntry::SimplifyCompiledFormula( std::unique_ptr<ScTokenArray>& r bool& rIsStr, OUString& rStrVal ) { - if ( rFormula->GetLen() == 1 ) + if ( rFormula->GetLen() != 1 ) + return; + + // Single (constant number)? + FormulaToken* pToken = rFormula->FirstToken(); + if ( pToken->GetOpCode() != ocPush ) + return; + + if ( pToken->GetType() == svDouble ) { - // Single (constant number)? - FormulaToken* pToken = rFormula->FirstToken(); - if ( pToken->GetOpCode() == ocPush ) - { - if ( pToken->GetType() == svDouble ) - { - rVal = pToken->GetDouble(); - rFormula.reset(); // Do not remember as formula - } - else if ( pToken->GetType() == svString ) - { - rIsStr = true; - rStrVal = pToken->GetString().getString(); - rFormula.reset(); // Do not remember as formula - } - } + rVal = pToken->GetDouble(); + rFormula.reset(); // Do not remember as formula + } + else if ( pToken->GetType() == svString ) + { + rIsStr = true; + rStrVal = pToken->GetString().getString(); + rFormula.reset(); // Do not remember as formula } } @@ -392,23 +392,23 @@ void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2, */ void ScConditionEntry::MakeCells( const ScAddress& rPos ) { - if ( !mpDoc->IsClipOrUndo() ) // Never calculate in the Clipboard! + if ( mpDoc->IsClipOrUndo() ) // Never calculate in the Clipboard! + return; + + if ( pFormula1 && !pFCell1 && !bRelRef1 ) { - if ( pFormula1 && !pFCell1 && !bRelRef1 ) - { - // pFCell1 will hold a flat-copied ScTokenArray sharing ref-counted - // code tokens with pFormula1 - pFCell1.reset( new ScFormulaCell(mpDoc, rPos, *pFormula1) ); - pFCell1->StartListeningTo( mpDoc ); - } + // pFCell1 will hold a flat-copied ScTokenArray sharing ref-counted + // code tokens with pFormula1 + pFCell1.reset( new ScFormulaCell(mpDoc, rPos, *pFormula1) ); + pFCell1->StartListeningTo( mpDoc ); + } - if ( pFormula2 && !pFCell2 && !bRelRef2 ) - { - // pFCell2 will hold a flat-copied ScTokenArray sharing ref-counted - // code tokens with pFormula2 - pFCell2.reset( new ScFormulaCell(mpDoc, rPos, *pFormula2) ); - pFCell2->StartListeningTo( mpDoc ); - } + if ( pFormula2 && !pFCell2 && !bRelRef2 ) + { + // pFCell2 will hold a flat-copied ScTokenArray sharing ref-counted + // code tokens with pFormula2 + pFCell2.reset( new ScFormulaCell(mpDoc, rPos, *pFormula2) ); + pFCell2->StartListeningTo( mpDoc ); } } @@ -755,58 +755,58 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr void ScConditionEntry::FillCache() const { - if(!mpCache) - { - const ScRangeList& rRanges = pCondFormat->GetRange(); - mpCache.reset(new ScConditionEntryCache); - size_t nListCount = rRanges.size(); - for( size_t i = 0; i < nListCount; i++ ) + if(mpCache) + return; + + const ScRangeList& rRanges = pCondFormat->GetRange(); + mpCache.reset(new ScConditionEntryCache); + size_t nListCount = rRanges.size(); + for( size_t i = 0; i < nListCount; i++ ) + { + const ScRange & rRange = rRanges[i]; + SCROW nRow = rRange.aEnd.Row(); + SCCOL nCol = rRange.aEnd.Col(); + SCCOL nColStart = rRange.aStart.Col(); + SCROW nRowStart = rRange.aStart.Row(); + SCTAB nTab = rRange.aStart.Tab(); + + // temporary fix to workaround slow duplicate entry + // conditions, prevent to use a whole row + if(nRow == MAXROW) { - const ScRange & rRange = rRanges[i]; - SCROW nRow = rRange.aEnd.Row(); - SCCOL nCol = rRange.aEnd.Col(); - SCCOL nColStart = rRange.aStart.Col(); - SCROW nRowStart = rRange.aStart.Row(); - SCTAB nTab = rRange.aStart.Tab(); - - // temporary fix to workaround slow duplicate entry - // conditions, prevent to use a whole row - if(nRow == MAXROW) + bool bShrunk = false; + mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart, + nCol, nRow, false); + } + + for( SCROW r = nRowStart; r <= nRow; r++ ) + for( SCCOL c = nColStart; c <= nCol; c++ ) { - bool bShrunk = false; - mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart, - nCol, nRow, false); - } + ScRefCellValue aCell(*mpDoc, ScAddress(c, r, nTab)); + if (aCell.isEmpty()) + continue; - for( SCROW r = nRowStart; r <= nRow; r++ ) - for( SCCOL c = nColStart; c <= nCol; c++ ) + double nVal = 0.0; + OUString aStr; + if (!lcl_GetCellContent(aCell, false, nVal, aStr, mpDoc)) { - ScRefCellValue aCell(*mpDoc, ScAddress(c, r, nTab)); - if (aCell.isEmpty()) - continue; + std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult = + mpCache->maStrings.emplace(aStr, 1); - double nVal = 0.0; - OUString aStr; - if (!lcl_GetCellContent(aCell, false, nVal, aStr, mpDoc)) - { - std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult = - mpCache->maStrings.emplace(aStr, 1); - - if(!aResult.second) - aResult.first->second++; - } - else - { - std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult = - mpCache->maValues.emplace(nVal, 1); + if(!aResult.second) + aResult.first->second++; + } + else + { + std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult = + mpCache->maValues.emplace(nVal, 1); - if(!aResult.second) - aResult.first->second++; + if(!aResult.second) + aResult.first->second++; - ++(mpCache->nValueItems); - } + ++(mpCache->nValueItems); } - } + } } } |