summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2018-10-24 15:38:17 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-11-28 00:43:02 +0100
commitc93558c7919efc4840ed1adfe7b20f3d1deeba36 (patch)
treefaa0cb57863e05330a2fd8d0ab19305aea99f3fe
parentsc: speed-up: avoid usage of svl::SharedString where it is possible (diff)
downloadcore-c93558c7919efc4840ed1adfe7b20f3d1deeba36.tar.gz
core-c93558c7919efc4840ed1adfe7b20f3d1deeba36.zip
sc: fix: range/step calculation for progress bar
Change-Id: I733e4003b65b410d44d9a1132be4e9e10ac24c3e Reviewed-on: https://gerrit.libreoffice.org/62305 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Conflicts: sc/source/core/data/table1.cxx
-rw-r--r--sc/inc/column.hxx3
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/source/core/data/column2.cxx61
-rw-r--r--sc/source/core/data/dociter.cxx14
-rw-r--r--sc/source/core/data/table1.cxx21
-rw-r--r--sc/source/core/data/table3.cxx13
6 files changed, 88 insertions, 25 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 5076e70b0eb8..e5a596e7c26b 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -369,7 +369,8 @@ public:
ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow, size_t& rBlockSize ) const;
CellType GetCellType( SCROW nRow ) const;
SCSIZE GetCellCount() const;
- sal_uInt32 GetWeightedCount() const;
+ sal_uLong GetWeightedCount() const;
+ sal_uLong GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
FormulaError GetErrCode( SCROW nRow ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index dae1f6f36eaf..61a6cff077d4 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -294,6 +294,7 @@ public:
}
sal_uLong GetCellCount() const;
sal_uLong GetWeightedCount() const;
+ sal_uLong GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
sal_uLong GetCodeCount() const; // RPN code in formula
sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 912428f688e1..89ac4e47fe53 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -3460,48 +3460,91 @@ namespace {
class WeightedCounter
{
- size_t mnCount;
+ sal_uLong mnCount;
public:
WeightedCounter() : mnCount(0) {}
void operator() (const sc::CellStoreType::value_type& node)
{
+ mnCount += getWeight(node);
+ }
+
+ static sal_uLong getWeight(const sc::CellStoreType::value_type& node)
+ {
switch (node.type)
{
case sc::element_type_numeric:
case sc::element_type_string:
- mnCount += node.size;
+ return node.size;
break;
case sc::element_type_formula:
{
+ size_t nCount = 0;
// Each formula cell is worth its code length plus 5.
sc::formula_block::const_iterator it = sc::formula_block::begin(*node.data);
sc::formula_block::const_iterator itEnd = sc::formula_block::end(*node.data);
for (; it != itEnd; ++it)
{
const ScFormulaCell* p = *it;
- mnCount += 5 + p->GetCode()->GetCodeLen();
+ nCount += 5 + p->GetCode()->GetCodeLen();
}
+
+ return nCount;
}
break;
case sc::element_type_edittext:
// each edit-text cell is worth 50.
- mnCount += node.size * 50;
+ return node.size * 50;
break;
default:
- ;
+ return 0;
}
}
- size_t getCount() const { return mnCount; }
+ sal_uLong getCount() const { return mnCount; }
};
+class WeightedCounterWithRows
+{
+ const SCROW mnStartRow;
+ const SCROW mnEndRow;
+ sal_uLong mnCount;
+
+public:
+ WeightedCounterWithRows(SCROW nStartRow, SCROW nEndRow)
+ : mnStartRow(nStartRow)
+ , mnEndRow(nEndRow)
+ , mnCount(0)
+ {
+ }
+
+ void operator() (const sc::CellStoreType::value_type& node)
+ {
+ const SCROW nRow1 = node.position;
+ const SCROW nRow2 = nRow1 + 1;
+
+ if (! ((nRow2 < mnStartRow) || (nRow1 > mnEndRow)))
+ {
+ mnCount += WeightedCounter::getWeight(node);
+ }
+ }
+
+ sal_uLong getCount() const { return mnCount; }
+};
+
+}
+
+sal_uLong ScColumn::GetWeightedCount() const
+{
+ const WeightedCounter aFunc = std::for_each(maCells.begin(), maCells.end(),
+ WeightedCounter());
+ return aFunc.getCount();
}
-sal_uInt32 ScColumn::GetWeightedCount() const
+sal_uLong ScColumn::GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const
{
- WeightedCounter aFunc;
- std::for_each(maCells.begin(), maCells.end(), aFunc);
+ const WeightedCounterWithRows aFunc = std::for_each(maCells.begin(), maCells.end(),
+ WeightedCounterWithRows(nStartRow, nEndRow));
return aFunc.getCount();
}
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 3f76513cb8d1..43b2ed89506c 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -2556,10 +2556,14 @@ void ScDocRowHeightUpdater::update()
return;
}
- sal_uInt32 nCellCount = 0;
+ sal_uLong nCellCount = 0;
vector<TabRanges>::const_iterator itr = mpTabRangesArray->begin(), itrEnd = mpTabRangesArray->end();
for (; itr != itrEnd; ++itr)
{
+ const SCTAB nTab = itr->mnTab;
+ if (!ValidTab(nTab) || nTab >= mrDoc.GetTableCount() || !mrDoc.maTabs[nTab])
+ continue;
+
ScFlatBoolRowSegments::RangeData aData;
ScFlatBoolRowSegments::RangeIterator aRangeItr(*itr->mpRanges);
for (bool bFound = aRangeItr.getFirst(aData); bFound; bFound = aRangeItr.getNext(aData))
@@ -2567,7 +2571,7 @@ void ScDocRowHeightUpdater::update()
if (!aData.mbValue)
continue;
- nCellCount += aData.mnRow2 - aData.mnRow1 + 1;
+ nCellCount += mrDoc.maTabs[nTab]->GetWeightedCount(aData.mnRow1, aData.mnRow2);
}
}
@@ -2575,10 +2579,10 @@ void ScDocRowHeightUpdater::update()
Fraction aZoom(1, 1);
itr = mpTabRangesArray->begin();
- sal_uInt32 nProgressStart = 0;
+ sal_uLong nProgressStart = 0;
for (; itr != itrEnd; ++itr)
{
- SCTAB nTab = itr->mnTab;
+ const SCTAB nTab = itr->mnTab;
if (!ValidTab(nTab) || nTab >= mrDoc.GetTableCount() || !mrDoc.maTabs[nTab])
continue;
@@ -2593,7 +2597,7 @@ void ScDocRowHeightUpdater::update()
mrDoc.maTabs[nTab]->SetOptimalHeight(
aCxt, aData.mnRow1, aData.mnRow2, &aProgress, nProgressStart);
- nProgressStart += aData.mnRow2 - aData.mnRow1 + 1;
+ nProgressStart += mrDoc.maTabs[nTab]->GetWeightedCount(aData.mnRow1, aData.mnRow2);
}
}
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index a4ff71ee3036..3062de5a3dca 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -50,6 +50,7 @@
#include <scmatrix.hxx>
#include <refupdatecontext.hxx>
#include <rowheightcontext.hxx>
+#include <vcl/svapp.hxx>
#include <formula/vectortoken.hxx>
#include <token.hxx>
@@ -84,7 +85,7 @@ ScProgress* GetProgressBar(
void GetOptimalHeightsInColumn(
sc::RowHeightContext& rCxt, ScColContainer& rCol, SCROW nStartRow, SCROW nEndRow,
- ScProgress* pProgress, sal_uInt32 nProgressStart )
+ ScProgress* pProgress, sal_uLong nProgressStart )
{
assert(nStartRow <= nEndRow);
@@ -109,20 +110,24 @@ void GetOptimalHeightsInColumn(
break;
}
- SCROW nMinStart = nPos;
+ const SCROW nMinStart = nPos;
- sal_uLong nWeightedCount = 0;
- for (SCCOL nCol=0; nCol<(rCol.size()-1); nCol++) // last col done already above
+ sal_uLong nWeightedCount = nProgressStart + rCol.back().GetWeightedCount(nStartRow, nEndRow);
+ const SCCOL maxCol = (rCol.size() - 1); // last col done already above
+ const SCCOL progressUpdateStep = rCol.size() / 10;
+ for (SCCOL nCol=0; nCol<maxCol; nCol++)
{
rCol[nCol].GetOptimalHeight(rCxt, nStartRow, nEndRow, nMinHeight, nMinStart);
if (pProgress)
{
- sal_uLong nWeight = rCol[nCol].GetWeightedCount();
- if (nWeight) // does not have to be the same Status
+ nWeightedCount += rCol[nCol].GetWeightedCount(nStartRow, nEndRow);
+ pProgress->SetState( nWeightedCount );
+
+ if ((nCol % progressUpdateStep) == 0)
{
- nWeightedCount += nWeight;
- pProgress->SetState( nWeightedCount + nProgressStart );
+ // try to make sure the progress dialog is painted before continuing
+ Application::Reschedule(true);
}
}
}
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index e59475ff3514..776ca2e3c51a 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -3546,8 +3546,17 @@ sal_uLong ScTable::GetWeightedCount() const
sal_uLong nCellCount = 0;
for ( SCCOL nCol=0; nCol < aCol.size(); nCol++ )
- if ( aCol[nCol].GetCellCount() )
- nCellCount += aCol[nCol].GetWeightedCount();
+ nCellCount += aCol[nCol].GetWeightedCount();
+
+ return nCellCount;
+}
+
+sal_uLong ScTable::GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const
+{
+ sal_uLong nCellCount = 0;
+
+ for ( SCCOL nCol=0; nCol < aCol.size(); nCol++ )
+ nCellCount += aCol[nCol].GetWeightedCount(nStartRow, nEndRow);
return nCellCount;
}