summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-09-24 21:19:09 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-09-24 21:22:18 -0400
commitfad417fe49d9da0fdef7447521a4bcd962d5c9eb (patch)
treedde1fc47107726fab6611b291c3084e036e29660 /chart2
parent8baaff5c798984b0fa7fe7a764491ca27765623e (diff)
Prevent so many copying of vector instances.
Change-Id: I2d74fe70411fb1a12387458d170a4a6b603755a3
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/inc/ExplicitCategoriesProvider.hxx2
-rw-r--r--chart2/source/tools/ExplicitCategoriesProvider.cxx9
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx39
3 files changed, 30 insertions, 20 deletions
diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx
index b83052b51ed8..d96ef67253a1 100644
--- a/chart2/source/inc/ExplicitCategoriesProvider.hxx
+++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx
@@ -84,7 +84,7 @@ public:
::com::sun::star::chart2::data::XDataSequence > getOriginalCategories();
::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories();
- ::std::vector< ComplexCategory > getCategoriesByLevel( sal_Int32 nLevel );
+ const std::vector<ComplexCategory>* getCategoriesByLevel( sal_Int32 nLevel );
static ::rtl::OUString getCategoryByIndex(
const ::com::sun::star::uno::Reference<
diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx
index 9cc82b6f383a..e3d800f1b1f8 100644
--- a/chart2/source/tools/ExplicitCategoriesProvider.cxx
+++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx
@@ -556,14 +556,13 @@ Sequence< ::rtl::OUString > ExplicitCategoriesProvider::getSimpleCategories()
return m_aExplicitCategories;
}
-std::vector< ComplexCategory > ExplicitCategoriesProvider::getCategoriesByLevel( sal_Int32 nLevel )
+const std::vector<ComplexCategory>* ExplicitCategoriesProvider::getCategoriesByLevel( sal_Int32 nLevel )
{
- std::vector< ComplexCategory > aRet;
init();
sal_Int32 nMaxIndex = m_aComplexCats.size()-1;
- if( nLevel >= 0 && nLevel <= nMaxIndex )
- aRet = m_aComplexCats[nMaxIndex-nLevel];
- return aRet;
+ if (nLevel >= 0 && nLevel <= nMaxIndex)
+ return &m_aComplexCats[nMaxIndex-nLevel];
+ return NULL;
}
OUString ExplicitCategoriesProvider::getCategoryByIndex(
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 6c0dd0424090..f394ef828c24 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -463,10 +463,16 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s
for( ; nLevel<nLevelCount; nLevel++ )
{
::std::vector< TickInfo > aTickInfoVector;
- std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
+ const std::vector<ComplexCategory>* pComplexCategories =
+ m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel(nLevel);
+
+ if (!pComplexCategories)
+ continue;
+
sal_Int32 nCatIndex = 0;
- std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
- std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
+ std::vector<ComplexCategory>::const_iterator aIt = pComplexCategories->begin();
+ std::vector<ComplexCategory>::const_iterator aEnd = pComplexCategories->end();
+
for(;aIt!=aEnd;++aIt)
{
TickInfo aTickInfo(0);
@@ -497,20 +503,25 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s
for( ; nLevel<nLevelCount; nLevel++ )
{
::std::vector< TickInfo > aTickInfoVector;
- std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
+ const std::vector<ComplexCategory>* pComplexCategories =
+ m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel(nLevel);
sal_Int32 nCatIndex = 0;
- std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
- std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
- for(;aIt!=aEnd;++aIt)
+ if (pComplexCategories)
{
- TickInfo aTickInfo(0);
- ComplexCategory aCat(*aIt);
- aTickInfo.fScaledTickValue = nCatIndex + 1.0;
- aTickInfoVector.push_back(aTickInfo);
- nCatIndex += aCat.Count;
- if( nCatIndex + 1.0 > m_aScale.Maximum )
- break;
+ std::vector<ComplexCategory>::const_iterator aIt = pComplexCategories->begin();
+ std::vector<ComplexCategory>::const_iterator aEnd = pComplexCategories->end();
+ for(;aIt!=aEnd;++aIt)
+ {
+ TickInfo aTickInfo(0);
+ ComplexCategory aCat(*aIt);
+ aTickInfo.fScaledTickValue = nCatIndex + 1.0;
+ aTickInfoVector.push_back(aTickInfo);
+ nCatIndex += aCat.Count;
+ if( nCatIndex + 1.0 > m_aScale.Maximum )
+ break;
+ }
}
+
//fill up with single ticks until maximum scale
while( nCatIndex + 1.0 < m_aScale.Maximum )
{