summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-01-20 14:39:54 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-01-20 17:07:20 -0500
commit94c63b8699e822fe1344002b68c3b11e687a1153 (patch)
tree254fbbb4cea5e572d311d6efa961267353776b93 /sc
parentbd161794ac844891f18660c292387dd449cb4c71 (diff)
Prefer using back() to access the last element.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/column.hxx2
-rw-r--r--sc/source/core/data/column.cxx6
-rw-r--r--sc/source/core/data/column2.cxx2
-rw-r--r--sc/source/core/data/column3.cxx16
4 files changed, 15 insertions, 11 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index e00aa64275ef..2f58a92630d8 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -256,7 +256,7 @@ public:
double GetValue( SCROW nRow ) const;
void GetFormula( SCROW nRow, rtl::OUString& rFormula ) const;
CellType GetCellType( SCROW nRow ) const;
- SCSIZE GetCellCount() const { return maItems.size(); }
+ SCSIZE GetCellCount() const;
sal_uInt32 GetWeightedCount() const;
sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
sal_uInt16 GetErrCode( SCROW nRow ) const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index bc2a0405e305..6c1c8499d5de 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -705,7 +705,7 @@ bool ScColumn::Search( SCROW nRow, SCSIZE& nIndex ) const
nIndex = 0;
return nRow == nMinRow;
}
- SCROW nMaxRow = maItems[maItems.size()-1].nRow;
+ SCROW nMaxRow = maItems.back().nRow;
if ( nRow >= nMaxRow )
{
if ( nRow == nMaxRow )
@@ -1103,7 +1103,7 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL)
ScAddress& rAddress = aHint.GetAddress();
// 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);
if ( bSingleBroadcasts )
{
@@ -1150,7 +1150,7 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
}
}
if ( !bCountChanged )
- aRange.aEnd.SetRow( maItems[maItems.size()-1].nRow );
+ aRange.aEnd.SetRow( maItems.back().nRow );
pDocument->AreaBroadcastInRange( aRange, aHint );
}
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index f7c9dbb077d1..b97b0dea0cde 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1296,7 +1296,7 @@ SCROW ScColumn::GetFirstDataPos() const
SCROW ScColumn::GetLastDataPos() const
{
if ( !maItems.empty() )
- return maItems[maItems.size()-1].nRow;
+ return maItems.back().nRow;
else
return 0;
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e880110c48ce..687c62db5aa6 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -74,7 +74,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
sal_Bool bIsAppended = false;
if ( !maItems.empty() )
{
- if (maItems[maItems.size()-1].nRow < nRow)
+ if (maItems.back().nRow < nRow)
{
Append(nRow, pNewCell );
bIsAppended = sal_True;
@@ -149,8 +149,8 @@ void ScColumn::Insert( SCROW nRow, sal_uInt32 nNumberFormat, ScBaseCell* pCell )
void ScColumn::Append( SCROW nRow, ScBaseCell* pCell )
{
maItems.push_back(ColEntry());
- maItems[maItems.size() - 1].pCell = pCell;
- maItems[maItems.size() - 1].nRow = nRow;
+ maItems.back().pCell = pCell;
+ maItems.back().nRow = nRow;
}
@@ -260,7 +260,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL)
ScAddress& rAddress = aHint.GetAddress();
// 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);
if ( bSingleBroadcasts )
{
@@ -288,7 +288,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
{
rAddress.SetRow( maItems[i].nRow );
ScRange aRange( rAddress );
- aRange.aEnd.SetRow( maItems[maItems.size()-1].nRow );
+ aRange.aEnd.SetRow( maItems.back().nRow );
for ( ; i < maItems.size(); i++ )
{
SCROW nNewRow = (maItems[i].nRow -= nSize);
@@ -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
// und Broadcast kommt eh erst nach dem Laden
if ( pNewCell )
@@ -1820,6 +1820,10 @@ CellType ScColumn::GetCellType( SCROW nRow ) const
return CELLTYPE_NONE;
}
+SCSIZE ScColumn::GetCellCount() const
+{
+ return maItems.size();
+}
sal_uInt16 ScColumn::GetErrCode( SCROW nRow ) const
{