[Libreoffice-commits] core.git: Branch 'private/kohei/sort-ref-update' - 3 commits - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Sun Jul 13 13:11:29 PDT 2014
sc/inc/sortparam.hxx | 2 -
sc/source/core/data/sortparam.cxx | 6 ++--
sc/source/core/data/table3.cxx | 57 ++++++++++++++++++++++++--------------
3 files changed, 40 insertions(+), 25 deletions(-)
New commits:
commit cf6e1071795e61419f8d1a28e4ce5d9c04226cef
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Sun Jul 13 16:12:39 2014 -0400
Implement reorder by column. Now undo of column sorting is working too.
Change-Id: I2b98610f6b774400ecfaffe2905201c27fcab33f
diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx
index 7bf0664..ab26d10 100644
--- a/sc/inc/sortparam.hxx
+++ b/sc/inc/sortparam.hxx
@@ -92,7 +92,7 @@ struct SC_DLLPUBLIC ReorderParam
/**
* List of original column / row positions after reordering.
*/
- std::vector<SCCOLROW> maPosIndices;
+ std::vector<SCCOLROW> maOrderIndices;
bool mbByRow;
bool mbPattern;
bool mbHiddenFiltered;
diff --git a/sc/source/core/data/sortparam.cxx b/sc/source/core/data/sortparam.cxx
index ad7653f..1e265b3 100644
--- a/sc/source/core/data/sortparam.cxx
+++ b/sc/source/core/data/sortparam.cxx
@@ -265,13 +265,13 @@ void ReorderParam::reverse()
else
nStart = maSortRange.aStart.Col();
- size_t n = maPosIndices.size();
+ size_t n = maOrderIndices.size();
std::vector<ReorderIndex> aBucket;
aBucket.reserve(n);
for (size_t i = 0; i < n; ++i)
{
SCCOLROW nPos1 = i + nStart;
- SCCOLROW nPos2 = maPosIndices[i];
+ SCCOLROW nPos2 = maOrderIndices[i];
aBucket.push_back(ReorderIndex(nPos1, nPos2));
}
@@ -281,7 +281,7 @@ void ReorderParam::reverse()
for (size_t i = 0; i < n; ++i)
aNew.push_back(aBucket[i].mnPos1);
- maPosIndices.swap(aNew);
+ maOrderIndices.swap(aNew);
}
}
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 844db24..64f0ef5 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -350,6 +350,11 @@ public:
}
}
+ void SetOrderIndices( const std::vector<SCCOLROW>& rIndices )
+ {
+ maOrderIndices = rIndices;
+ }
+
/**
* @param rIndices indices are actual row positions on the sheet, not an
* offset from the top row.
@@ -471,6 +476,11 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( const sc::ReorderParam& rParam )
}
else
{
+ SCCOLROW nCol1 = rParam.maSortRange.aStart.Col();
+ SCCOLROW nCol2 = rParam.maSortRange.aEnd.Col();
+
+ pArray = new ScSortInfoArray(0, nCol1, nCol2);
+ pArray->SetKeepQuery(rParam.mbHiddenFiltered);
}
return pArray;
@@ -1228,7 +1238,7 @@ void ScTable::Sort(
if (pUndo)
{
pUndo->maSortRange = ScRange(rSortParam.nCol1, nRow1, nTab, rSortParam.nCol2, nLastRow, nTab);
- pUndo->maPosIndices = pArray->GetOrderIndices();
+ pUndo->maOrderIndices = pArray->GetOrderIndices();
}
}
}
@@ -1254,7 +1264,7 @@ void ScTable::Sort(
if (pUndo)
{
pUndo->maSortRange = ScRange(nCol1, aSortParam.nRow1, nTab, nLastCol, aSortParam.nRow2, nTab);
- pUndo->maPosIndices = pArray->GetOrderIndices();
+ pUndo->maOrderIndices = pArray->GetOrderIndices();
}
}
}
@@ -1263,7 +1273,7 @@ void ScTable::Sort(
void ScTable::Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress )
{
- if (rParam.maPosIndices.empty())
+ if (rParam.maOrderIndices.empty())
return;
boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(rParam));
@@ -1273,14 +1283,18 @@ void ScTable::Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress )
if (rParam.mbByRow)
{
// Re-play sorting from the known sort indices.
- pArray->ReorderByRow(rParam.maPosIndices);
+ pArray->ReorderByRow(rParam.maOrderIndices);
SortReorderByRow(
pArray.get(), rParam.maSortRange.aStart.Col(), rParam.maSortRange.aEnd.Col(), pProgress);
}
else
{
-
+ // Ordering by column is much simpler. Just set the order indices and we are done.
+ pArray->SetOrderIndices(rParam.maOrderIndices);
+ SortReorderByColumn(
+ pArray.get(), rParam.maSortRange.aStart.Row(), rParam.maSortRange.aEnd.Row(),
+ rParam.mbPattern, pProgress);
}
}
commit 6b2e9a84920da68e9965c613302a36bda39a780e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Sun Jul 13 16:01:58 2014 -0400
Some renaming. The name "old indices" is not very representative.
Change-Id: Idbb462e3b366d6fcc3fbbade6ee1310b9941423d
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 4e9dd6d..844db24 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -257,7 +257,7 @@ private:
SCCOLROW mnLastIndex; /// index of last non-empty cell position.
sal_uInt16 nUsedSorts;
- std::vector<SCCOLROW> maOldIndices;
+ std::vector<SCCOLROW> maOrderIndices;
bool mbKeepQuery;
public:
@@ -281,7 +281,7 @@ public:
}
for (size_t i = 0; i < nCount; ++i)
- maOldIndices.push_back(i+nStart);
+ maOrderIndices.push_back(i+nStart);
}
~ScSortInfoArray()
@@ -340,7 +340,7 @@ public:
ppInfo[n2] = pTmp;
}
- std::swap(maOldIndices[n1], maOldIndices[n2]);
+ std::swap(maOrderIndices[n1], maOrderIndices[n2]);
if (mpRows)
{
@@ -354,15 +354,15 @@ public:
* @param rIndices indices are actual row positions on the sheet, not an
* offset from the top row.
*/
- void ReorderDataRows( const std::vector<SCCOLROW>& rIndices )
+ void ReorderByRow( const std::vector<SCCOLROW>& rIndices )
{
if (!mpRows)
return;
RowsType& rRows = *mpRows;
- std::vector<SCCOLROW> aOldIndices2;
- aOldIndices2.reserve(rIndices.size());
+ std::vector<SCCOLROW> aOrderIndices2;
+ aOrderIndices2.reserve(rIndices.size());
RowsType aRows2;
aRows2.reserve(rRows.size());
@@ -372,11 +372,11 @@ public:
{
size_t nPos = *it - nStart; // switch to an offset to top row.
aRows2.push_back(rRows[nPos]);
- aOldIndices2.push_back(maOldIndices[nPos]);
+ aOrderIndices2.push_back(maOrderIndices[nPos]);
}
rRows.swap(aRows2);
- maOldIndices.swap(aOldIndices2);
+ maOrderIndices.swap(aOrderIndices2);
}
sal_uInt16 GetUsedSorts() const { return nUsedSorts; }
@@ -385,7 +385,7 @@ public:
SCCOLROW GetLast() const { return mnLastIndex; }
SCSIZE GetCount() const { return nCount; }
- const std::vector<SCCOLROW>& GetOldIndices() const { return maOldIndices; }
+ const std::vector<SCCOLROW>& GetOrderIndices() const { return maOrderIndices; }
RowsType& InitDataRows( size_t nRowSize, size_t nColSize )
{
@@ -661,7 +661,7 @@ void ScTable::SortReorderByColumn(
SCCOLROW nStart = pArray->GetStart();
SCCOLROW nLast = pArray->GetLast();
- std::vector<SCCOLROW> aIndices = pArray->GetOldIndices();
+ std::vector<SCCOLROW> aIndices = pArray->GetOrderIndices();
size_t nCount = aIndices.size();
// Cut formula grouping at row and reference boundaries before the reordering.
@@ -698,7 +698,7 @@ void ScTable::SortReorderByColumn(
// Set up column reorder map (for later broadcasting of reference updates).
sc::ColRowReorderMapType aColMap;
- const std::vector<SCCOLROW>& rOldIndices = pArray->GetOldIndices();
+ const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices();
for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
{
SCCOL nNew = i + nStart;
@@ -917,7 +917,7 @@ void ScTable::SortReorderByRow(
// Set up row reorder map (for later broadcasting of reference updates).
sc::ColRowReorderMapType aRowMap;
- const std::vector<SCCOLROW>& rOldIndices = pArray->GetOldIndices();
+ const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices();
for (size_t i = 0, n = rOldIndices.size(); i < n; ++i)
{
SCROW nNew = i + nRow1;
@@ -1228,7 +1228,7 @@ void ScTable::Sort(
if (pUndo)
{
pUndo->maSortRange = ScRange(rSortParam.nCol1, nRow1, nTab, rSortParam.nCol2, nLastRow, nTab);
- pUndo->maPosIndices = pArray->GetOldIndices();
+ pUndo->maPosIndices = pArray->GetOrderIndices();
}
}
}
@@ -1254,7 +1254,7 @@ void ScTable::Sort(
if (pUndo)
{
pUndo->maSortRange = ScRange(nCol1, aSortParam.nRow1, nTab, nLastCol, aSortParam.nRow2, nTab);
- pUndo->maPosIndices = pArray->GetOldIndices();
+ pUndo->maPosIndices = pArray->GetOrderIndices();
}
}
}
@@ -1266,19 +1266,21 @@ void ScTable::Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress )
if (rParam.maPosIndices.empty())
return;
+ boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(rParam));
+ if (!pArray)
+ return;
+
if (rParam.mbByRow)
{
- boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(rParam));
-
// Re-play sorting from the known sort indices.
- pArray->ReorderDataRows(rParam.maPosIndices);
+ pArray->ReorderByRow(rParam.maPosIndices);
SortReorderByRow(
pArray.get(), rParam.maSortRange.aStart.Col(), rParam.maSortRange.aEnd.Col(), pProgress);
}
else
{
- // TODO : Implement this.
+
}
}
commit 8bc9a54e435b0d843a226f4ac55818e6a2d8d0ef
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Sun Jul 13 15:52:02 2014 -0400
No need to copy it here anymore.
Change-Id: Ie636149e0ed71bbc5c6675c4e1481d62c66ab68e
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 008e883..4e9dd6d 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1268,14 +1268,13 @@ void ScTable::Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress )
if (rParam.mbByRow)
{
- sc::ReorderParam aParam = rParam; // copy
boost::scoped_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(rParam));
// Re-play sorting from the known sort indices.
- pArray->ReorderDataRows(aParam.maPosIndices);
+ pArray->ReorderDataRows(rParam.maPosIndices);
SortReorderByRow(
- pArray.get(), aParam.maSortRange.aStart.Col(), aParam.maSortRange.aEnd.Col(), pProgress);
+ pArray.get(), rParam.maSortRange.aStart.Col(), rParam.maSortRange.aEnd.Col(), pProgress);
}
else
{
More information about the Libreoffice-commits
mailing list