diff options
author | Noel Grandin <noel@peralex.com> | 2015-11-10 09:18:04 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-11-10 09:41:53 +0200 |
commit | 73baabfffc34461068df57d1a1851351b17cb8e8 (patch) | |
tree | 309bdbdc6103b5ae5616cd5d334cc4faaf6909f9 /chart2 | |
parent | e0dec4c73b6ada7733726f756e4506a7e3114048 (diff) |
chart2: replace boost::ptr_vector with std::vector<unique_ptr>
Change-Id: I5c374afcfa2760ebf21e461f38fe392692054dfe
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/inc/pch/precompiled_chartcore.hxx | 1 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 69 |
2 files changed, 27 insertions, 43 deletions
diff --git a/chart2/inc/pch/precompiled_chartcore.hxx b/chart2/inc/pch/precompiled_chartcore.hxx index fde1f3c90250..5860f8f03c90 100644 --- a/chart2/inc/pch/precompiled_chartcore.hxx +++ b/chart2/inc/pch/precompiled_chartcore.hxx @@ -33,7 +33,6 @@ #include <boost/bind.hpp> #include <boost/checked_delete.hpp> #include <boost/ptr_container/ptr_map.hpp> -#include <boost/ptr_container/ptr_vector.hpp> #include <memory> #include <cmath> #include <com/sun/star/awt/CharSet.hpp> diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 34a54da10537..722a93ff9f09 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -116,7 +116,6 @@ #include <osl/time.h> #include <memory> -#include <boost/ptr_container/ptr_vector.hpp> namespace chart { @@ -248,7 +247,7 @@ void AxisUsage::setExplicitScaleAndIncrement( aVCooSysList[i]->setExplicitScaleAndIncrement(nDimIndex, nAxisIndex, rScale, rInc); } -typedef boost::ptr_vector<VSeriesPlotter> SeriesPlottersType; +typedef std::vector<std::unique_ptr<VSeriesPlotter> > SeriesPlottersType; /** This class is a container of `SeriesPlotter` objects (such as `PieChart` * instances). It is used for initializing coordinate systems, axes and scales @@ -385,11 +384,9 @@ SeriesPlotterContainer::~SeriesPlotterContainer() std::vector< LegendEntryProvider* > SeriesPlotterContainer::getLegendEntryProviderList() { std::vector< LegendEntryProvider* > aRet( m_aSeriesPlotterList.size() ); - SeriesPlottersType::iterator aPlotterIter = m_aSeriesPlotterList.begin(); - const SeriesPlottersType::iterator aPlotterEnd = m_aSeriesPlotterList.end(); sal_Int32 nN = 0; - for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter, nN++ ) - aRet[nN] = &(*aPlotterIter); + for( std::unique_ptr<VSeriesPlotter>& aPlotter : m_aSeriesPlotterList) + aRet[nN++] = aPlotter.get(); return aRet; } @@ -535,7 +532,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( if( !pPlotter ) continue; - m_aSeriesPlotterList.push_back( pPlotter ); + m_aSeriesPlotterList.push_back( std::unique_ptr<VSeriesPlotter>(pPlotter) ); pPlotter->setNumberFormatsSupplier( xNumberFormatsSupplier ); pPlotter->setColorScheme( xColorScheme ); if(pVCooSys) @@ -630,9 +627,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( { if(!bSeriesNamesInitialized) { - VSeriesPlotter* pSeriesPlotter = &m_aSeriesPlotterList[0]; - if( pSeriesPlotter ) - aSeriesNames = pSeriesPlotter->getSeriesNames(); + aSeriesNames = m_aSeriesPlotterList[0]->getSeriesNames(); bSeriesNamesInitialized = true; } pVCooSys->setSeriesNamesForAxis( aSeriesNames ); @@ -731,11 +726,9 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate) void SeriesPlotterContainer::setScalesFromCooSysToPlotter() { //set scales to plotter to enable them to provide the preferred scene AspectRatio - SeriesPlottersType::iterator aPlotterIter = m_aSeriesPlotterList.begin(); - const SeriesPlottersType::iterator aPlotterEnd = m_aSeriesPlotterList.end(); - for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter ) + for( std::unique_ptr<VSeriesPlotter>& aPlotter : m_aSeriesPlotterList ) { - VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter); + VSeriesPlotter* pSeriesPlotter = aPlotter.get(); VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( m_rVCooSysList, pSeriesPlotter ); if(pVCooSys) { @@ -750,11 +743,9 @@ void SeriesPlotterContainer::setScalesFromCooSysToPlotter() void SeriesPlotterContainer::setNumberFormatsFromAxes() { //set numberformats to plotter to enable them to display the data labels in the numberformat of the axis - SeriesPlottersType::iterator aPlotterIter = m_aSeriesPlotterList.begin(); - const SeriesPlottersType::iterator aPlotterEnd = m_aSeriesPlotterList.end(); - for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter ) + for( std::unique_ptr<VSeriesPlotter>& aPlotter : m_aSeriesPlotterList ) { - VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter); + VSeriesPlotter* pSeriesPlotter = aPlotter.get(); VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( m_rVCooSysList, pSeriesPlotter ); if(pVCooSys) { @@ -999,12 +990,9 @@ drawing::Direction3D SeriesPlotterContainer::getPreferredAspectRatio() //first with special demands wins (less or equal zero <-> arbitrary) double fx, fy, fz; fx = fy = fz = -1.0; - SeriesPlottersType::const_iterator aPlotterIter = m_aSeriesPlotterList.begin(); - const SeriesPlottersType::const_iterator aPlotterEnd = m_aSeriesPlotterList.end(); - for( aPlotterIter = m_aSeriesPlotterList.begin(), nPlotterCount=0 - ; aPlotterIter != aPlotterEnd; ++aPlotterIter, ++nPlotterCount ) + for( std::unique_ptr<VSeriesPlotter>& aPlotter : m_aSeriesPlotterList ) { - drawing::Direction3D aSingleRatio( aPlotterIter->getPreferredDiagramAspectRatio() ); + drawing::Direction3D aSingleRatio( aPlotter->getPreferredDiagramAspectRatio() ); if( fx<0 && aSingleRatio.DirectionX>0 ) fx = aSingleRatio.DirectionX; @@ -1030,6 +1018,7 @@ drawing::Direction3D SeriesPlotterContainer::getPreferredAspectRatio() if( fx>0 && fy>0 && fz>0 ) break; + ++nPlotterCount; } aPreferredAspectRatio = drawing::Direction3D(fx, fy, fz); return aPreferredAspectRatio; @@ -1728,11 +1717,9 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D // - create data series for all charttypes m_bPointsWereSkipped = false; - SeriesPlottersType::iterator aPlotterIter = rSeriesPlotterList.begin(); - const SeriesPlottersType::iterator aPlotterEnd = rSeriesPlotterList.end(); - for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter ) + for( std::unique_ptr<VSeriesPlotter>& aPlotter : rSeriesPlotterList ) { - VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter); + VSeriesPlotter* pSeriesPlotter = aPlotter.get(); OUString aCID; //III uno::Reference< drawing::XShapes > xSeriesTarget(0); if( pSeriesPlotter->WantToPlotInFrontOfAxisLine() ) @@ -1769,10 +1756,9 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D if (!rParam.mbUseFixedInnerSize) aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect ); - for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter ) + for( std::unique_ptr<VSeriesPlotter>& aPlotter : rSeriesPlotterList ) { - VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter); - pSeriesPlotter->releaseShapes(); + aPlotter->releaseShapes(); } //clear and recreate @@ -1789,18 +1775,17 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D } // - create data series for all charttypes - for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter ) + for( std::unique_ptr<VSeriesPlotter>& aPlotter : rSeriesPlotterList ) { - VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter); - VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( rVCooSysList, pSeriesPlotter ); + VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( rVCooSysList, aPlotter.get() ); if(2==nDimensionCount) - pSeriesPlotter->setTransformationSceneToScreen( pVCooSys->getTransformationSceneToScreen() ); - pSeriesPlotter->createShapes(); - m_bPointsWereSkipped = m_bPointsWereSkipped || pSeriesPlotter->PointsWereSkipped(); + aPlotter->setTransformationSceneToScreen( pVCooSys->getTransformationSceneToScreen() ); + aPlotter->createShapes(); + m_bPointsWereSkipped = m_bPointsWereSkipped || aPlotter->PointsWereSkipped(); } - for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter ) - aPlotterIter->rearrangeLabelToAvoidOverlapIfRequested(rPageSize); + for( std::unique_ptr<VSeriesPlotter>& aPlotter : rSeriesPlotterList ) + aPlotter->rearrangeLabelToAvoidOverlapIfRequested(rPageSize); } if (rParam.mbUseFixedInnerSize) @@ -1811,9 +1796,9 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D aUsedOuterRect = rParam.maRemainingSpace; bool bSnapRectToUsedArea = false; - for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter ) + for( std::unique_ptr<VSeriesPlotter>& aPlotter : rSeriesPlotterList ) { - bSnapRectToUsedArea = aPlotterIter->shouldSnapRectToUsedArea(); + bSnapRectToUsedArea = aPlotter->shouldSnapRectToUsedArea(); if(bSnapRectToUsedArea) break; } @@ -3213,7 +3198,7 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) size_t n = rSeriesPlotter.size(); for(size_t i = 0; i < n; ++i) { - std::vector<VDataSeries*> aAllNewDataSeries = rSeriesPlotter[i].getAllSeries(); + std::vector<VDataSeries*> aAllNewDataSeries = rSeriesPlotter[i]->getAllSeries(); std::vector< VDataSeries* >& rAllOldDataSeries = maTimeBased.m_aDataSeriesList[i]; size_t m = std::min(aAllNewDataSeries.size(), rAllOldDataSeries.size()); @@ -3276,7 +3261,7 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) maTimeBased.m_aDataSeriesList.resize(n); for(size_t i = 0; i < n; ++i) { - std::vector<VDataSeries*> aAllNewDataSeries = rSeriesPlotter[i].getAllSeries(); + std::vector<VDataSeries*> aAllNewDataSeries = rSeriesPlotter[i]->getAllSeries(); std::vector<VDataSeries*>& rAllOldDataSeries = maTimeBased.m_aDataSeriesList[i]; size_t m = aAllNewDataSeries.size(); for(size_t j = 0; j < m; ++j) |