summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-17 13:24:51 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-23 21:08:19 -0400
commit97c0f88afc47b01fd5bf5a47ae92c9674e518fe1 (patch)
tree4c219f90f95bd4c183ec3982af14b4f3f826266c /sc/source
parent1dad03a80a1236aa643974ab49a3f4cc75ceec1f (diff)
Store cell text attribute pointers during initialization.
This will be used later when re-ordering rows. Change-Id: I47504b49be11174b0002b1af1cbce9b8b7f2531c
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/column.cxx36
-rw-r--r--sc/source/core/data/table2.cxx8
-rw-r--r--sc/source/core/data/table3.cxx7
3 files changed, 50 insertions, 1 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 2d2c44e5e5ce..192aa5bcb4be 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -771,6 +771,16 @@ ScRefCellValue ScColumn::GetCellValue( SCROW nRow ) const
return GetCellValue(aPos.first, aPos.second);
}
+ScRefCellValue ScColumn::GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const
+{
+ std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(rBlockPos.miCellPos, nRow);
+ if (aPos.first == maCells.end())
+ return ScRefCellValue();
+
+ rBlockPos.miCellPos = aPos.first; // Store this for next call.
+ return GetCellValue(aPos.first, aPos.second);
+}
+
ScRefCellValue ScColumn::GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const
{
ScRefCellValue aVal; // Defaults to empty cell.
@@ -803,6 +813,32 @@ ScRefCellValue ScColumn::GetCellValue( const sc::CellStoreType::const_iterator&
return aVal;
}
+const sc::CellTextAttr* ScColumn::GetCellTextAttr( SCROW nRow ) const
+{
+ sc::CellTextAttrStoreType::const_position_type aPos = maCellTextAttrs.position(nRow);
+ if (aPos.first == maCellTextAttrs.end())
+ return NULL;
+
+ if (aPos.first->type != sc::element_type_celltextattr)
+ return NULL;
+
+ return &sc::celltextattr_block::at(*aPos.first->data, aPos.second);
+}
+
+const sc::CellTextAttr* ScColumn::GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const
+{
+ sc::CellTextAttrStoreType::const_position_type aPos = maCellTextAttrs.position(rBlockPos.miCellTextAttrPos, nRow);
+ if (aPos.first == maCellTextAttrs.end())
+ return NULL;
+
+ rBlockPos.miCellTextAttrPos = aPos.first;
+
+ if (aPos.first->type != sc::element_type_celltextattr)
+ return NULL;
+
+ return &sc::celltextattr_block::at(*aPos.first->data, aPos.second);
+}
+
namespace {
ScFormulaCell* cloneFormulaCell(ScDocument* pDoc, const ScAddress& rNewPos, ScFormulaCell& rOldCell)
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index d72a43617a73..af2492ea4e11 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1596,6 +1596,14 @@ ScRefCellValue ScTable::GetCellValue( SCCOL nCol, SCROW nRow ) const
return aCol[nCol].GetCellValue(nRow);
}
+const sc::CellTextAttr* ScTable::GetCellTextAttr( SCCOL nCol, SCROW nRow ) const
+{
+ if (!ValidColRow(nCol, nRow))
+ return NULL;
+
+ return aCol[nCol].GetCellTextAttr(nRow);
+}
+
void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const
{
rCol = 0;
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index a9dcd0311c9e..4b7bde22aece 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -206,6 +206,7 @@ short Compare( const OUString &sInput1, const OUString &sInput2,
struct ScSortInfo
{
ScRefCellValue maCell;
+ const sc::CellTextAttr* mpTextAttr;
SCCOLROW nOrg;
DECL_FIXEDMEMPOOL_NEWDEL( ScSortInfo );
};
@@ -279,10 +280,13 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 )
{
SCCOL nCol = static_cast<SCCOL>(aSortParam.maKeyState[nSort].nField);
ScColumn* pCol = &aCol[nCol];
+ sc::ColumnBlockConstPosition aBlockPos;
+ pCol->InitBlockPosition(aBlockPos);
for ( SCROW nRow = nInd1; nRow <= nInd2; nRow++ )
{
ScSortInfo* pInfo = pArray->Get( nSort, nRow );
- pInfo->maCell = pCol->GetCellValue(nRow);
+ pInfo->maCell = pCol->GetCellValue(aBlockPos, nRow);
+ pInfo->mpTextAttr = pCol->GetCellTextAttr(aBlockPos, nRow);
pInfo->nOrg = nRow;
}
}
@@ -297,6 +301,7 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 )
{
ScSortInfo* pInfo = pArray->Get( nSort, nCol );
pInfo->maCell = GetCellValue(nCol, nRow);
+ pInfo->mpTextAttr = GetCellTextAttr(nCol, nRow);
pInfo->nOrg = nCol;
}
}