Kaydet (Commit) 94c63b86 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Prefer using back() to access the last element.

üst bd161794
...@@ -256,7 +256,7 @@ public: ...@@ -256,7 +256,7 @@ public:
double GetValue( SCROW nRow ) const; double GetValue( SCROW nRow ) const;
void GetFormula( SCROW nRow, rtl::OUString& rFormula ) const; void GetFormula( SCROW nRow, rtl::OUString& rFormula ) const;
CellType GetCellType( SCROW nRow ) const; CellType GetCellType( SCROW nRow ) const;
SCSIZE GetCellCount() const { return maItems.size(); } SCSIZE GetCellCount() const;
sal_uInt32 GetWeightedCount() const; sal_uInt32 GetWeightedCount() const;
sal_uInt32 GetCodeCount() const; // RPN-Code in formulas sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
sal_uInt16 GetErrCode( SCROW nRow ) const; sal_uInt16 GetErrCode( SCROW nRow ) const;
......
...@@ -705,7 +705,7 @@ bool ScColumn::Search( SCROW nRow, SCSIZE& nIndex ) const ...@@ -705,7 +705,7 @@ bool ScColumn::Search( SCROW nRow, SCSIZE& nIndex ) const
nIndex = 0; nIndex = 0;
return nRow == nMinRow; return nRow == nMinRow;
} }
SCROW nMaxRow = maItems[maItems.size()-1].nRow; SCROW nMaxRow = maItems.back().nRow;
if ( nRow >= nMaxRow ) if ( nRow >= nMaxRow )
{ {
if ( nRow == nMaxRow ) if ( nRow == nMaxRow )
...@@ -1103,7 +1103,7 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) ...@@ -1103,7 +1103,7 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL) ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL)
ScAddress& rAddress = aHint.GetAddress(); ScAddress& rAddress = aHint.GetAddress();
// for sparse occupation use single broadcasts, not ranges // for sparse occupation use single broadcasts, not ranges
bool bSingleBroadcasts = (((maItems[maItems.size()-1].nRow - maItems[i].nRow) / bool bSingleBroadcasts = (((maItems.back().nRow - maItems[i].nRow) /
(maItems.size() - i)) > 1); (maItems.size() - i)) > 1);
if ( bSingleBroadcasts ) if ( bSingleBroadcasts )
{ {
...@@ -1150,7 +1150,7 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) ...@@ -1150,7 +1150,7 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
} }
} }
if ( !bCountChanged ) if ( !bCountChanged )
aRange.aEnd.SetRow( maItems[maItems.size()-1].nRow ); aRange.aEnd.SetRow( maItems.back().nRow );
pDocument->AreaBroadcastInRange( aRange, aHint ); pDocument->AreaBroadcastInRange( aRange, aHint );
} }
......
...@@ -1296,7 +1296,7 @@ SCROW ScColumn::GetFirstDataPos() const ...@@ -1296,7 +1296,7 @@ SCROW ScColumn::GetFirstDataPos() const
SCROW ScColumn::GetLastDataPos() const SCROW ScColumn::GetLastDataPos() const
{ {
if ( !maItems.empty() ) if ( !maItems.empty() )
return maItems[maItems.size()-1].nRow; return maItems.back().nRow;
else else
return 0; return 0;
} }
......
...@@ -74,7 +74,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) ...@@ -74,7 +74,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
sal_Bool bIsAppended = false; sal_Bool bIsAppended = false;
if ( !maItems.empty() ) if ( !maItems.empty() )
{ {
if (maItems[maItems.size()-1].nRow < nRow) if (maItems.back().nRow < nRow)
{ {
Append(nRow, pNewCell ); Append(nRow, pNewCell );
bIsAppended = sal_True; bIsAppended = sal_True;
...@@ -149,8 +149,8 @@ void ScColumn::Insert( SCROW nRow, sal_uInt32 nNumberFormat, ScBaseCell* pCell ) ...@@ -149,8 +149,8 @@ void ScColumn::Insert( SCROW nRow, sal_uInt32 nNumberFormat, ScBaseCell* pCell )
void ScColumn::Append( SCROW nRow, ScBaseCell* pCell ) void ScColumn::Append( SCROW nRow, ScBaseCell* pCell )
{ {
maItems.push_back(ColEntry()); maItems.push_back(ColEntry());
maItems[maItems.size() - 1].pCell = pCell; maItems.back().pCell = pCell;
maItems[maItems.size() - 1].nRow = nRow; maItems.back().nRow = nRow;
} }
...@@ -260,7 +260,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) ...@@ -260,7 +260,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL) ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL)
ScAddress& rAddress = aHint.GetAddress(); ScAddress& rAddress = aHint.GetAddress();
// for sparse occupation use single broadcasts, not ranges // for sparse occupation use single broadcasts, not ranges
sal_Bool bSingleBroadcasts = (((maItems[maItems.size()-1].nRow - maItems[i].nRow) / bool bSingleBroadcasts = (((maItems.back().nRow - maItems[i].nRow) /
(maItems.size() - i)) > 1); (maItems.size() - i)) > 1);
if ( bSingleBroadcasts ) if ( bSingleBroadcasts )
{ {
...@@ -288,7 +288,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) ...@@ -288,7 +288,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
{ {
rAddress.SetRow( maItems[i].nRow ); rAddress.SetRow( maItems[i].nRow );
ScRange aRange( rAddress ); ScRange aRange( rAddress );
aRange.aEnd.SetRow( maItems[maItems.size()-1].nRow ); aRange.aEnd.SetRow( maItems.back().nRow );
for ( ; i < maItems.size(); i++ ) for ( ; i < maItems.size(); i++ )
{ {
SCROW nNewRow = (maItems[i].nRow -= nSize); SCROW nNewRow = (maItems[i].nRow -= nSize);
...@@ -1439,7 +1439,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, ...@@ -1439,7 +1439,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
} }
} }
if ( bIsLoading && (maItems.empty() || nRow > maItems[maItems.size()-1].nRow) ) if ( bIsLoading && (maItems.empty() || nRow > maItems.back().nRow) )
{ // Search einsparen und ohne Umweg ueber Insert, Listener aufbauen { // Search einsparen und ohne Umweg ueber Insert, Listener aufbauen
// und Broadcast kommt eh erst nach dem Laden // und Broadcast kommt eh erst nach dem Laden
if ( pNewCell ) if ( pNewCell )
...@@ -1820,6 +1820,10 @@ CellType ScColumn::GetCellType( SCROW nRow ) const ...@@ -1820,6 +1820,10 @@ CellType ScColumn::GetCellType( SCROW nRow ) const
return CELLTYPE_NONE; return CELLTYPE_NONE;
} }
SCSIZE ScColumn::GetCellCount() const
{
return maItems.size();
}
sal_uInt16 ScColumn::GetErrCode( SCROW nRow ) const sal_uInt16 ScColumn::GetErrCode( SCROW nRow ) const
{ {
......
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