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: ...@@ -178,8 +178,12 @@ public:
const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; } const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
ScRefCellValue GetCellValue( SCROW nRow ) const; 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; 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 Delete( SCROW nRow );
void FreeAll(); void FreeAll();
void SwapRow( SCROW nRow1, SCROW nRow2 ); void SwapRow( SCROW nRow1, SCROW nRow2 );
......
...@@ -384,6 +384,8 @@ public: ...@@ -384,6 +384,8 @@ public:
CellType GetCellType( SCCOL nCol, SCROW nRow ) const; CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
ScRefCellValue GetCellValue( 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 GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const; void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
......
...@@ -771,6 +771,16 @@ ScRefCellValue ScColumn::GetCellValue( SCROW nRow ) const ...@@ -771,6 +771,16 @@ ScRefCellValue ScColumn::GetCellValue( SCROW nRow ) const
return GetCellValue(aPos.first, aPos.second); 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 ScColumn::GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const
{ {
ScRefCellValue aVal; // Defaults to empty cell. ScRefCellValue aVal; // Defaults to empty cell.
...@@ -803,6 +813,32 @@ ScRefCellValue ScColumn::GetCellValue( const sc::CellStoreType::const_iterator& ...@@ -803,6 +813,32 @@ ScRefCellValue ScColumn::GetCellValue( const sc::CellStoreType::const_iterator&
return aVal; 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 { namespace {
ScFormulaCell* cloneFormulaCell(ScDocument* pDoc, const ScAddress& rNewPos, ScFormulaCell& rOldCell) ScFormulaCell* cloneFormulaCell(ScDocument* pDoc, const ScAddress& rNewPos, ScFormulaCell& rOldCell)
......
...@@ -1596,6 +1596,14 @@ ScRefCellValue ScTable::GetCellValue( SCCOL nCol, SCROW nRow ) const ...@@ -1596,6 +1596,14 @@ ScRefCellValue ScTable::GetCellValue( SCCOL nCol, SCROW nRow ) const
return aCol[nCol].GetCellValue(nRow); 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 void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const
{ {
rCol = 0; rCol = 0;
......
...@@ -206,6 +206,7 @@ short Compare( const OUString &sInput1, const OUString &sInput2, ...@@ -206,6 +206,7 @@ short Compare( const OUString &sInput1, const OUString &sInput2,
struct ScSortInfo struct ScSortInfo
{ {
ScRefCellValue maCell; ScRefCellValue maCell;
const sc::CellTextAttr* mpTextAttr;
SCCOLROW nOrg; SCCOLROW nOrg;
DECL_FIXEDMEMPOOL_NEWDEL( ScSortInfo ); DECL_FIXEDMEMPOOL_NEWDEL( ScSortInfo );
}; };
...@@ -279,10 +280,13 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 ) ...@@ -279,10 +280,13 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 )
{ {
SCCOL nCol = static_cast<SCCOL>(aSortParam.maKeyState[nSort].nField); SCCOL nCol = static_cast<SCCOL>(aSortParam.maKeyState[nSort].nField);
ScColumn* pCol = &aCol[nCol]; ScColumn* pCol = &aCol[nCol];
sc::ColumnBlockConstPosition aBlockPos;
pCol->InitBlockPosition(aBlockPos);
for ( SCROW nRow = nInd1; nRow <= nInd2; nRow++ ) for ( SCROW nRow = nInd1; nRow <= nInd2; nRow++ )
{ {
ScSortInfo* pInfo = pArray->Get( nSort, 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; pInfo->nOrg = nRow;
} }
} }
...@@ -297,6 +301,7 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 ) ...@@ -297,6 +301,7 @@ ScSortInfoArray* ScTable::CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 )
{ {
ScSortInfo* pInfo = pArray->Get( nSort, nCol ); ScSortInfo* pInfo = pArray->Get( nSort, nCol );
pInfo->maCell = GetCellValue(nCol, nRow); pInfo->maCell = GetCellValue(nCol, nRow);
pInfo->mpTextAttr = GetCellTextAttr(nCol, nRow);
pInfo->nOrg = nCol; 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