diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-24 21:05:41 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-24 21:07:43 -0400 |
commit | 3f9275bd262dd8a7cfc199ad858208b8e400f6d9 (patch) | |
tree | ee2d70ce9c32e2797ad40fc311350d01086c5d9c /chart2/source/controller/dialogs/DialogModel.cxx | |
parent | 1e0c38bb54563788d08336dabe8178a60e4f83e7 (diff) |
Annotate the code a little more, to make it easier to follow.
Change-Id: Iefc61fdc132a18e73b0136f0248d69ab9e07a5e8
Diffstat (limited to 'chart2/source/controller/dialogs/DialogModel.cxx')
-rw-r--r-- | chart2/source/controller/dialogs/DialogModel.cxx | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index e18c7d333216..5f6de8c4dc30 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -479,6 +479,37 @@ void addMissingRoles(DialogModel::tRolesWithRanges& rResult, const uno::Sequence } } +/** + * Insert a new data series to chart type at position after specified series + * position. + * + * @param xChartType chart type that contains data series. + * @param xSeries insertion position. The new series will be inserted after + * this one. + * @param xNewSeries new data series to insert. + */ +void addNewSeriesToContainer( + const Reference<XChartType>& xChartType, + const Reference<XDataSeries>& xSeries, + const Reference<XDataSeries>& xNewSeries ) +{ + Reference<XDataSeriesContainer> xSeriesCnt(xChartType, uno::UNO_QUERY_THROW); + std::vector<Reference<XDataSeries> > aSeries = SequenceToVector(xSeriesCnt->getDataSeries()); + + std::vector<Reference<XDataSeries> >::iterator aIt = + std::find( aSeries.begin(), aSeries.end(), xSeries); + + if( aIt == aSeries.end()) + // if we have no series we insert at the first position. + aIt = aSeries.begin(); + else + // vector::insert inserts before, so we have to advance + ++aIt; + + aSeries.insert(aIt, xNewSeries); + xSeriesCnt->setDataSeries(ContainerToSequence(aSeries)); +} + } DialogModel::tRolesWithRanges DialogModel::getRolesWithRanges( @@ -561,21 +592,7 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( // add new series to container if( xNewSeries.is()) - { - Reference< XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY_THROW ); - ::std::vector< Reference< XDataSeries > > aSeries( - SequenceToVector( xSeriesCnt->getDataSeries())); - ::std::vector< Reference< XDataSeries > >::iterator aIt = - ::std::find( aSeries.begin(), aSeries.end(), xSeries ); - if( aIt == aSeries.end()) - // if we have no series we insert at the first position. - aIt = aSeries.begin(); - else - // vector::insert inserts before, so we have to advance - ++aIt; - aSeries.insert( aIt, xNewSeries ); - xSeriesCnt->setDataSeries( ContainerToSequence( aSeries )); - } + addNewSeriesToContainer(xChartType, xSeries, xNewSeries); ThreeDHelper::setScheme( xDiagram, e3DScheme ); } |