summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-18 15:40:24 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-23 21:08:22 -0400
commit1920d3e7a5272263ab70903ba5388c867fda77f4 (patch)
tree2ce7c41a332d8bc22b173e63f4507528922afea2
parentcd83e2f1674c04c8a489cf5a15ef35c25491ee6e (diff)
Use the mdds storage types directly rather than using CellValues.
Change-Id: I415b3cddc4b764668564affd573ae9cc00601278
-rw-r--r--sc/inc/cellvalues.hxx1
-rw-r--r--sc/source/core/data/cellvalues.cxx54
-rw-r--r--sc/source/core/data/column4.cxx4
-rw-r--r--sc/source/core/data/table3.cxx78
4 files changed, 65 insertions, 72 deletions
diff --git a/sc/inc/cellvalues.hxx b/sc/inc/cellvalues.hxx
index f68ce5a0f69a..3bc378228435 100644
--- a/sc/inc/cellvalues.hxx
+++ b/sc/inc/cellvalues.hxx
@@ -49,7 +49,6 @@ public:
void copyTo( ScColumn& rCol, SCROW nRow ) const;
void assign( const std::vector<double>& rVals );
- void append( ScRefCellValue& rVal, const CellTextAttr* pAttr, const ScAddress& rPos );
size_t size() const;
diff --git a/sc/source/core/data/cellvalues.cxx b/sc/source/core/data/cellvalues.cxx
index 0740ab5e384c..083b4d1ac7a8 100644
--- a/sc/source/core/data/cellvalues.cxx
+++ b/sc/source/core/data/cellvalues.cxx
@@ -10,7 +10,6 @@
#include <cellvalues.hxx>
#include <column.hxx>
#include <cellvalue.hxx>
-#include <sharedformula.hxx>
#include <cassert>
#include <boost/noncopyable.hpp>
@@ -65,59 +64,6 @@ void CellValues::assign( const std::vector<double>& rVals )
mpImpl->maCellTextAttrs.set(0, aDefaults.begin(), aDefaults.end());
}
-void CellValues::append( ScRefCellValue& rVal, const CellTextAttr* pAttr, const ScAddress& rPos )
-{
- assert(mpImpl->maCells.size() == mpImpl->maCellTextAttrs.size());
-
- size_t n = mpImpl->maCells.size();
-
- bool bAppendAttr = true;
-
- switch (rVal.meType)
- {
- case CELLTYPE_STRING:
- {
- mpImpl->maCells.resize(n+1);
- mpImpl->maCells.set(n, *rVal.mpString);
- }
- break;
- case CELLTYPE_VALUE:
- {
- mpImpl->maCells.resize(n+1);
- mpImpl->maCells.set(n, rVal.mfValue);
- }
- break;
- case CELLTYPE_EDIT:
- {
- mpImpl->maCells.resize(n+1);
- mpImpl->maCells.set(n, rVal.mpEditText->Clone());
- }
- break;
- case CELLTYPE_FORMULA:
- {
- mpImpl->maCells.resize(n+1);
- CellStoreType::iterator itBlk = mpImpl->maCells.set(n, rVal.mpFormula->Clone(rPos));
-
- size_t nOffset = n - itBlk->position;
- CellStoreType::position_type aPos(itBlk, nOffset);
- SharedFormulaUtil::joinFormulaCellAbove(aPos);
- }
- break;
- default:
- bAppendAttr = false;
- }
-
- if (bAppendAttr)
- {
- mpImpl->maCellTextAttrs.resize(n+1);
-
- if (pAttr)
- mpImpl->maCellTextAttrs.set(n, *pAttr);
- else
- mpImpl->maCellTextAttrs.set(n, CellTextAttr());
- }
-}
-
size_t CellValues::size() const
{
assert(mpImpl->maCells.size() == mpImpl->maCellTextAttrs.size());
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 2bef7ba9f8cc..2698f0b5f647 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -300,7 +300,7 @@ void ScColumn::TransferCellValuesFrom( SCROW nRow, sc::CellValues& rSrc )
return;
sc::CellStoreType::position_type aPos = maCells.position(nRow);
-// DetachFormulaCells(aPos, rSrc.size());
+ DetachFormulaCells(aPos, rSrc.size());
rSrc.transferTo(*this, nRow);
@@ -311,7 +311,7 @@ void ScColumn::TransferCellValuesFrom( SCROW nRow, sc::CellValues& rSrc )
for (SCROW i = nRow; i <= nLastRow; ++i)
aRows.push_back(i);
-// BroadcastCells(aRows, SC_HINT_DATACHANGED);
+ BroadcastCells(aRows, SC_HINT_DATACHANGED);
}
void ScColumn::CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index b8db3c614404..5bdc653c20eb 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -57,8 +57,8 @@
#include "mtvcellfunc.hxx"
#include "columnspanset.hxx"
#include <stlalgorithm.hxx>
-#include <cellvalues.hxx>
#include <listenercontext.hxx>
+#include <sharedformula.hxx>
#include "svl/sharedstringpool.hxx"
@@ -380,7 +380,8 @@ namespace {
struct SortedColumn : boost::noncopyable
{
- sc::CellValues maCells; /// Stores cells and cell text attributes.
+ sc::CellStoreType maCells;
+ sc::CellTextAttrStoreType maCellTextAttrs;
sc::BroadcasterStoreType maBroadcasters;
};
@@ -453,15 +454,47 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
{
ScSortInfoArray::Cell& rCell = (*pRow)[nCol];
- sc::CellValues& rStore = aSortedCols.at(nCol).maCells;
- ScAddress aCellPos(aSortParam.nCol1 + nCol, aSortParam.nRow1 + i, nTab);
- rStore.append(rCell.maCell, rCell.mpAttr, aCellPos);
+ sc::CellStoreType& rCellStore = aSortedCols.at(nCol).maCells;
+ size_t n = rCellStore.size();
+ rCellStore.resize(n+1);
+ switch (rCell.maCell.meType)
+ {
+ case CELLTYPE_STRING:
+ assert(rCell.mpAttr);
+ rCellStore.set(n, *rCell.maCell.mpString);
+ break;
+ case CELLTYPE_VALUE:
+ assert(rCell.mpAttr);
+ rCellStore.set(n, rCell.maCell.mfValue);
+ break;
+ case CELLTYPE_EDIT:
+ assert(rCell.mpAttr);
+ rCellStore.set(n, rCell.maCell.mpEditText->Clone());
+ break;
+ case CELLTYPE_FORMULA:
+ {
+ assert(rCell.mpAttr);
+ ScAddress aCellPos(aSortParam.nCol1 + nCol, aSortParam.nRow1 + i, nTab);
+ sc::CellStoreType::iterator itBlk = rCellStore.set(n, rCell.maCell.mpFormula->Clone(aCellPos));
+
+ size_t nOffset = n - itBlk->position;
+ sc::CellStoreType::position_type aPos(itBlk, nOffset);
+ sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
+ }
+ break;
+ default:
+ assert(!rCell.mpAttr);
+ }
+
+ sc::CellTextAttrStoreType& rAttrStore = aSortedCols.at(nCol).maCellTextAttrs;
+ rAttrStore.resize(n+1);
+ if (rCell.mpAttr)
+ rAttrStore.set(n, *rCell.mpAttr);
// At this point each broadcaster instance is managed by 2
// containers. We will release those in the original storage
// below before transferring them to the document.
sc::BroadcasterStoreType& rBCStore = aSortedCols.at(nCol).maBroadcasters;
- size_t n = rBCStore.size();
rBCStore.resize(n+1);
if (rCell.mpBroadcaster)
// A const pointer would be implicitly converted to a bool type.
@@ -475,18 +508,33 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
for (size_t i = 0, n = aSortedCols.size(); i < n; ++i)
{
SCCOL nThisCol = i + aSortParam.nCol1;
- TransferCellValuesFrom(nThisCol, aSortParam.nRow1, aSortedCols[i].maCells);
- sc::BroadcasterStoreType& rBCDest = aCol[nThisCol].maBroadcasters;
+ {
+ sc::CellStoreType& rDest = aCol[nThisCol].maCells;
+ sc::CellStoreType& rSrc = aSortedCols[i].maCells;
+ rSrc.transfer(0, rSrc.size()-1, rDest, aSortParam.nRow1);
+ }
- // Release current broadcasters first, to prevent them from getting deleted.
- SvtBroadcaster* pBC = NULL;
- for (SCROW nRow = aSortParam.nRow1; nRow <= aSortParam.nRow2; ++nRow)
- rBCDest.release(nRow, pBC);
+ {
+ sc::CellTextAttrStoreType& rDest = aCol[nThisCol].maCellTextAttrs;
+ sc::CellTextAttrStoreType& rSrc = aSortedCols[i].maCellTextAttrs;
+ rSrc.transfer(0, rSrc.size()-1, rDest, aSortParam.nRow1);
+ }
+
+ {
+ sc::BroadcasterStoreType& rBCDest = aCol[nThisCol].maBroadcasters;
+
+ // Release current broadcasters first, to prevent them from getting deleted.
+ SvtBroadcaster* pBC = NULL;
+ for (SCROW nRow = aSortParam.nRow1; nRow <= aSortParam.nRow2; ++nRow)
+ rBCDest.release(nRow, pBC);
+
+ // Transfer sorted broadcaster segment to the document.
+ sc::BroadcasterStoreType& rBCSrc = aSortedCols[i].maBroadcasters;
+ rBCSrc.transfer(0, rBCSrc.size()-1, rBCDest, aSortParam.nRow1);
+ }
- // Transfer sorted broadcaster segment to the document.
- sc::BroadcasterStoreType& rBCSrc = aSortedCols[i].maBroadcasters;
- rBCSrc.transfer(0, rBCSrc.size()-1, rBCDest, aSortParam.nRow1);
+ aCol[nThisCol].CellStorageModified();
}
// Attach all formula cells within sorted range, to have them start listening again.