Kaydet (Commit) 97c0f88a authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Store cell text attribute pointers during initialization.

This will be used later when re-ordering rows.

Change-Id: I47504b49be11174b0002b1af1cbce9b8b7f2531c
üst 1dad03a8
......@@ -178,8 +178,12 @@ public:
const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
ScRefCellValue GetCellValue( SCROW nRow ) const;
ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const;
const sc::CellTextAttr* GetCellTextAttr( SCROW nRow ) const;
const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
void Delete( SCROW nRow );
void FreeAll();
void SwapRow( SCROW nRow1, SCROW nRow2 );
......
......@@ -384,6 +384,8 @@ public:
CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
const sc::CellTextAttr* GetCellTextAttr( SCCOL nCol, SCROW nRow ) const;
void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
......
......@@ -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)
......
......@@ -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;
......
......@@ -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;
}
}
......
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