diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-23 12:43:30 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-04 12:30:37 -0500 |
commit | 6e7539a49e61c17eb058dcb7bb395ea1d5f78961 (patch) | |
tree | 2f60daa65b3c6c674db500bfbe3f3b65cc3224e2 /chart2/source/view/axes/VCartesianAxis.cxx | |
parent | 374d581a84d13ef0c48ee7de81c69b50b5d2d1b4 (diff) |
Let's use size_t for the index.
This removes unnecessary static_cast's and check for negative values
which, from what I've read from the code, never happens.
Change-Id: I9d9e1de5b091df335dd3b7eeb34e4e8f98de0fbd
Diffstat (limited to 'chart2/source/view/axes/VCartesianAxis.cxx')
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index fbc533593e0c..7ff0f997703e 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -414,8 +414,7 @@ void getAxisLabelProperties( class MaxLabelTickIter : public TickIter { public: - MaxLabelTickIter( TickInfoArrayType& rTickInfoVector - , sal_Int32 nLongestLabelIndex ); + MaxLabelTickIter( TickInfoArrayType& rTickInfoVector, size_t nLongestLabelIndex ); virtual ~MaxLabelTickIter(); virtual TickInfo* firstInfo() SAL_OVERRIDE; @@ -423,21 +422,21 @@ public: private: TickInfoArrayType& m_rTickInfoVector; - ::std::vector< sal_Int32 > m_aValidIndices; - sal_Int32 m_nCurrentIndex; + std::vector<size_t> m_aValidIndices; + size_t m_nCurrentIndex; }; -MaxLabelTickIter::MaxLabelTickIter( TickInfoArrayType& rTickInfoVector - , sal_Int32 nLongestLabelIndex ) - : m_rTickInfoVector(rTickInfoVector) - , m_nCurrentIndex(0) +MaxLabelTickIter::MaxLabelTickIter( + TickInfoArrayType& rTickInfoVector, size_t nLongestLabelIndex ) : + m_rTickInfoVector(rTickInfoVector), m_nCurrentIndex(0) { - sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; - if( nLongestLabelIndex<0 || nLongestLabelIndex>=nMaxIndex-1 ) + assert(!rTickInfoVector.empty()); // should be checked by the caller. + + size_t nMaxIndex = m_rTickInfoVector.size()-1; + if (nLongestLabelIndex >= nMaxIndex-1) nLongestLabelIndex = 0; - if( nMaxIndex>=0 ) - m_aValidIndices.push_back(0); + m_aValidIndices.push_back(0); if( nMaxIndex>=1 ) m_aValidIndices.push_back(1); if( nLongestLabelIndex>1 ) @@ -454,7 +453,7 @@ MaxLabelTickIter::~MaxLabelTickIter() TickInfo* MaxLabelTickIter::firstInfo() { m_nCurrentIndex = 0; - if( m_nCurrentIndex < static_cast<sal_Int32>(m_aValidIndices.size()) ) + if (m_nCurrentIndex < m_aValidIndices.size()) return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]]; return 0; } @@ -462,7 +461,7 @@ TickInfo* MaxLabelTickIter::firstInfo() TickInfo* MaxLabelTickIter::nextInfo() { m_nCurrentIndex++; - if( m_nCurrentIndex>=0 && m_nCurrentIndex<static_cast<sal_Int32>(m_aValidIndices.size()) ) + if (m_nCurrentIndex < m_aValidIndices.size()) return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]]; return 0; } @@ -624,7 +623,7 @@ TickIter* VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel ) { if( !m_aAllTickInfos.empty() ) { - sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0; + size_t nLongestLabelIndex = m_bUseTextLabels ? getIndexOfLongestLabel(m_aTextLabels) : 0; return new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex ); } } |