[Libreoffice-commits] core.git: Branch 'private/kohei/calc-sort-fix' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Apr 22 13:29:41 PDT 2014
sc/inc/document.hxx | 2 ++
sc/inc/table.hxx | 2 ++
sc/source/core/data/document10.cxx | 9 +++++++++
sc/source/core/data/table7.cxx | 14 ++++++++++++++
sc/source/ui/docshell/dbdocfun.cxx | 20 ++++++++++++++------
5 files changed, 41 insertions(+), 6 deletions(-)
New commits:
commit 737806755dc57a1fa2b95a29a7a4ed49384fa016
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Apr 22 16:29:14 2014 -0400
Skip adjustment of row height when all rows have the same height.
Change-Id: I490ecade6b909bcf36b848c05e198d58adc90e0a
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index df8d0bb..06f3b54 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1574,6 +1574,8 @@ public:
SC_DLLPUBLIC bool IsManualRowHeight(SCROW nRow, SCTAB nTab) const;
+ bool HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const;
+
/**
* Write all column row flags to table's flag data, because not all column
* row attributes are stored in the flag data members. This is necessary
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 6715448..a521fa34 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -815,6 +815,8 @@ public:
bool IsManualRowHeight(SCROW nRow) const;
+ bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
+
void SyncColRowFlags();
void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index abf5297..9513dfb 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -279,4 +279,13 @@ void ScDocument::UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW
pTab->UpdateScriptTypes(rPos.Col(), rPos.Row(), rPos.Col()+nColSize-1, rPos.Row()+nRowSize-1);
}
+bool ScDocument::HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const
+{
+ const ScTable* pTab = FetchTable(nTab);
+ if (!pTab)
+ return false;
+
+ return pTab->HasUniformRowHeight(nRow1, nRow2);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index eeb4643..385bea1 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -12,6 +12,7 @@
#include <document.hxx>
#include <clipparam.hxx>
#include <bcaslot.hxx>
+#include <segmenttree.hxx>
bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const
{
@@ -110,4 +111,17 @@ void ScTable::UpdateScriptTypes( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nR
aCol[nCol].UpdateScriptTypes(nRow1, nRow2);
}
+bool ScTable::HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const
+{
+ if (!ValidRow(nRow1) || !ValidRow(nRow2) || nRow1 > nRow2)
+ return false;
+
+ ScFlatUInt16RowSegments::RangeData aData;
+ if (!mpRowHeights->getRangeData(nRow1, aData))
+ // Search failed.
+ return false;
+
+ return nRow2 <= aData.mnRow2;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 936f601..2be536e 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -490,13 +490,19 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
WaitObject aWait( rDocShell.GetActiveDialogParent() );
+ SCROW nStartRow = aLocalParam.nRow1 + (aLocalParam.bHasHeader ? 1 : 0);
+
// Calculate the script types for all cells in the sort range beforehand.
// This will speed up the row height adjustment that takes place after the
// sort.
pDoc->UpdateScriptTypes(
- ScAddress(rSortParam.nCol1,rSortParam.nRow1,nTab),
- rSortParam.nCol2-rSortParam.nCol1+1,
- rSortParam.nRow2-rSortParam.nRow1+1);
+ ScAddress(aLocalParam.nCol1,nStartRow,nTab),
+ aLocalParam.nCol2-aLocalParam.nCol1+1,
+ aLocalParam.nRow2-nStartRow+1);
+
+ // No point adjusting row heights after the sort when all rows have the same height.
+ bool bUniformRowHeight =
+ pDoc->HasUniformRowHeight(nTab, nStartRow, aLocalParam.nRow2);
sal_Bool bRepeatQuery = false; // bestehenden Filter wiederholen?
ScQueryParam aQueryParam;
@@ -632,8 +638,9 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
}
}
- ScRange aDirtyRange( aLocalParam.nCol1, aLocalParam.nRow1, nTab,
- aLocalParam.nCol2, aLocalParam.nRow2, nTab );
+ ScRange aDirtyRange(
+ aLocalParam.nCol1, nStartRow, nTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nTab);
pDoc->SetDirty( aDirtyRange );
if (bPaint)
@@ -659,7 +666,8 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
rDocShell.PostPaint(ScRange(nStartX, nStartY, nTab, nEndX, nEndY, nTab), nPaint);
}
- rDocShell.AdjustRowHeight( aLocalParam.nRow1, aLocalParam.nRow2, nTab );
+ if (!bUniformRowHeight)
+ rDocShell.AdjustRowHeight(nStartRow, aLocalParam.nRow2, nTab);
// #i59745# set collected drawing undo actions at sorting undo action
if( pUndoAction && pDrawLayer )
More information about the Libreoffice-commits
mailing list