Kaydet (Commit) 9a568c41 authored tarafından Eike Rathke's avatar Eike Rathke

Ctrl+A and Data Sort took ages to broadcast ALL cells

... now that also empty cells are to be broadcasted.

Set dirty and broadcast only the effective data range as determined by Sort.

This is more a workaround, a cleaner solution would be to refactor the
SetDirty() algorithm to iterate only through broadcasters and use
AreaBroadcast() to notify area listeners.

However, this can also be easily backported to 4-3.

Change-Id: I6d68ca0088cec6a8328a3e93364ac928ef69babe
üst 80a1b88e
......@@ -1683,8 +1683,12 @@ public:
SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
SC_DLLPUBLIC SvNumberFormatter* CreateFormatTable() const;
/** Sort a range of data.
@param rSortParam may get adjusted to the actual range used if it did
encompass leading or trailing empty blocks
*/
void Sort(
SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
SCTAB nTab, ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
ScProgress* pProgress, sc::ReorderParam* pUndo );
void Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress );
......
......@@ -834,8 +834,12 @@ public:
void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
/** Sort a range of data.
@param rSortParam may get adjusted to the actual range used if it did
encompass leading or trailing empty blocks
*/
void Sort(
const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
ScProgress* pProgress, sc::ReorderParam* pUndo );
void Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress );
......
......@@ -1342,7 +1342,7 @@ bool ScDocument::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, b
}
void ScDocument::Sort(
SCTAB nTab, const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
SCTAB nTab, ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
ScProgress* pProgress, sc::ReorderParam* pUndo )
{
if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
......
......@@ -1525,10 +1525,9 @@ void ScTable::DecoladeRow( ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2 )
}
void ScTable::Sort(
const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
ScProgress* pProgress, sc::ReorderParam* pUndo )
{
aSortParam = rSortParam;
InitSortCollator( rSortParam );
bGlobalKeepQuery = bKeepQuery;
......@@ -1542,19 +1541,20 @@ void ScTable::Sort(
}
// Trim empty leading and trailing column ranges.
while (aSortParam.nCol1 < aSortParam.nCol2 && aCol[aSortParam.nCol1].IsEmptyBlock(aSortParam.nRow1, aSortParam.nRow2))
++aSortParam.nCol1;
while (aSortParam.nCol1 < aSortParam.nCol2 && aCol[aSortParam.nCol2].IsEmptyBlock(aSortParam.nRow1, aSortParam.nRow2))
--aSortParam.nCol2;
while (rSortParam.nCol1 < rSortParam.nCol2 && aCol[rSortParam.nCol1].IsEmptyBlock(rSortParam.nRow1, rSortParam.nRow2))
++rSortParam.nCol1;
while (rSortParam.nCol1 < rSortParam.nCol2 && aCol[rSortParam.nCol2].IsEmptyBlock(rSortParam.nRow1, rSortParam.nRow2))
--rSortParam.nCol2;
if (rSortParam.bByRow)
{
SCROW nLastRow = 0;
for (SCCOL nCol = aSortParam.nCol1; nCol <= aSortParam.nCol2; nCol++)
for (SCCOL nCol = rSortParam.nCol1; nCol <= rSortParam.nCol2; nCol++)
nLastRow = std::max(nLastRow, aCol[nCol].GetLastDataPos());
nLastRow = std::min(nLastRow, aSortParam.nRow2);
rSortParam.nRow2 = nLastRow = std::min(nLastRow, rSortParam.nRow2);
SCROW nRow1 = (rSortParam.bHasHeader ?
aSortParam.nRow1 + 1 : aSortParam.nRow1);
rSortParam.nRow1 + 1 : rSortParam.nRow1);
aSortParam = rSortParam; // must be assigned before calling IsSorted()
if (!IsSorted(nRow1, nLastRow))
{
if(pProgress)
......@@ -1580,9 +1580,10 @@ void ScTable::Sort(
}
else
{
SCCOL nLastCol = aSortParam.nCol2;
SCCOL nLastCol = rSortParam.nCol2;
SCCOL nCol1 = (rSortParam.bHasHeader ?
aSortParam.nCol1 + 1 : aSortParam.nCol1);
rSortParam.nCol1 + 1 : rSortParam.nCol1);
aSortParam = rSortParam; // must be assigned before calling IsSorted()
if (!IsSorted(nCol1, nLastCol))
{
if(pProgress)
......
......@@ -556,6 +556,7 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
ScInputOptions aInputOption = SC_MOD()->GetInputOptions();
bool bUpdateRefs = aInputOption.GetSortRefUpdate();
ScProgress aProgress(&rDocShell, ScGlobal::GetRscString(STR_PROGRESS_SORTING), 0);
// aLocalParam range now may get adapted to exclude empty edges
rDoc.Sort(nTab, aLocalParam, bRepeatQuery, bUpdateRefs, &aProgress, &aUndoParam);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment