[Libreoffice-commits] core.git: 4 commits - chart2/inc chart2/source

Noel Grandin noel at peralex.com
Mon Nov 9 23:42:17 PST 2015


 chart2/inc/pch/precompiled_chartcore.hxx       |    1 
 chart2/source/view/charttypes/GL3DBarChart.cxx |   88 +++++++++++--------------
 chart2/source/view/inc/GL3DBarChart.hxx        |    7 -
 chart2/source/view/inc/GL3DPlotterBase.hxx     |    5 -
 chart2/source/view/main/ChartView.cxx          |   73 ++++++++------------
 5 files changed, 76 insertions(+), 98 deletions(-)

New commits:
commit 73baabfffc34461068df57d1a1851351b17cb8e8
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Nov 10 09:18:04 2015 +0200

    chart2: replace boost::ptr_vector with std::vector<unique_ptr>
    
    Change-Id: I5c374afcfa2760ebf21e461f38fe392692054dfe

diff --git a/chart2/inc/pch/precompiled_chartcore.hxx b/chart2/inc/pch/precompiled_chartcore.hxx
index fde1f3c..5860f8f 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 34a54da..722a93f 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)
commit e0dec4c73b6ada7733726f756e4506a7e3114048
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Nov 10 08:54:33 2015 +0200

    chart2: replace boost::ptr_vector with std::vector<unique_ptr>
    
    Change-Id: Ia5c35cbd54045a79e896832adf2dbe68c5facf1f

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 5f70233..c806534 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -63,17 +63,15 @@ float calculateTextWidth(const OUString& rText)
     return rText.getLength() * 10;
 }
 
-double findMaxValue(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer)
+double findMaxValue(const std::vector<std::unique_ptr<VDataSeries> >& rDataSeriesContainer)
 {
     double nMax = 0.0;
-    for (boost::ptr_vector<VDataSeries>::const_iterator itr = rDataSeriesContainer.begin(),
-            itrEnd = rDataSeriesContainer.end(); itr != itrEnd; ++itr)
+    for (const std::unique_ptr<VDataSeries>& rDataSeries : rDataSeriesContainer)
     {
-        const VDataSeries& rDataSeries = *itr;
-        sal_Int32 nPointCount = rDataSeries.getTotalPointCount();
+        sal_Int32 nPointCount = rDataSeries->getTotalPointCount();
         for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
         {
-            double nVal = rDataSeries.getYValue(nIndex);
+            double nVal = rDataSeries->getYValue(nIndex);
             nMax = std::max(nMax, nVal);
         }
     }
@@ -599,7 +597,7 @@ GL3DBarChart::~GL3DBarChart()
         mpWindow->setRenderer(NULL);
 }
 
-void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer,
+void GL3DBarChart::create3DShapes(const std::vector<std::unique_ptr<VDataSeries> >& rDataSeriesContainer,
         ExplicitCategoriesProvider& rCatProvider)
 {
     SharedResourceAccess aResGuard(maCond1, maCond2);
@@ -654,24 +652,22 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     }
     else
     {
-        const VDataSeries& rFirstRow = *(rDataSeriesContainer.begin());
+        const VDataSeries& rFirstRow = *rDataSeriesContainer.begin()->get();
         mnBarsInRow = rFirstRow.getTotalPointCount();
     }
-    for (boost::ptr_vector<VDataSeries>::const_iterator itr = rDataSeriesContainer.begin(),
-            itrEnd = rDataSeriesContainer.end(); itr != itrEnd; ++itr)
+    for (const std::unique_ptr<VDataSeries>& rDataSeries : rDataSeriesContainer)
     {
         nYPos = nSeriesIndex * (BAR_SIZE_Y + BAR_DISTANCE_Y) + BAR_DISTANCE_Y;
 
-        const VDataSeries& rDataSeries = *itr;
-        sal_Int32 nPointCount = rDataSeries.getTotalPointCount();
+        sal_Int32 nPointCount = rDataSeries->getTotalPointCount();
         nMaxPointCount = std::max(nMaxPointCount, nPointCount);
 
-        bool bMappedFillProperty = rDataSeries.hasPropertyMapping("FillColor");
+        bool bMappedFillProperty = rDataSeries->hasPropertyMapping("FillColor");
 
         // Create series name text object.
         OUString aSeriesName =
             DataSeriesHelper::getDataSeriesLabel(
-                rDataSeries.getModel(), mxChartType->getRoleOfSequenceForSeriesLabel());
+                rDataSeries->getModel(), mxChartType->getRoleOfSequenceForSeriesLabel());
 
         maSeriesNames.push_back(aSeriesName);
 
@@ -696,12 +692,12 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
         {
             if(bMappedFillProperty)
             {
-                double nPropVal = rDataSeries.getValueByProperty(nIndex, "FillColor");
+                double nPropVal = rDataSeries->getValueByProperty(nIndex, "FillColor");
                 if(!rtl::math::isNan(nPropVal))
                     nColor = static_cast<sal_uInt32>(nPropVal);
             }
 
-            float nVal = rDataSeries.getYValue(nIndex);
+            float nVal = rDataSeries->getYValue(nIndex);
             if (rtl::math::isNan(nVal))
                 continue;
 
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 5f68b27..419c679 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -13,7 +13,6 @@
 #include <GL3DPlotterBase.hxx>
 
 #include <vector>
-#include <boost/ptr_container/ptr_vector.hpp>
 #include "VDataSeries.hxx"
 
 #include <glm/glm.hpp>
@@ -71,7 +70,7 @@ public:
 
     virtual ~GL3DBarChart();
 
-    virtual void create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeries,
+    virtual void create3DShapes(const std::vector<std::unique_ptr<VDataSeries>>& rDataSeries,
         ExplicitCategoriesProvider& rCatProvider) override;
 
     virtual void render() override;
diff --git a/chart2/source/view/inc/GL3DPlotterBase.hxx b/chart2/source/view/inc/GL3DPlotterBase.hxx
index ceea643..c403389 100644
--- a/chart2/source/view/inc/GL3DPlotterBase.hxx
+++ b/chart2/source/view/inc/GL3DPlotterBase.hxx
@@ -10,8 +10,9 @@
 #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_GL3DPLOTTERBASE_HXX
 #define INCLUDED_CHART2_SOURCE_VIEW_INC_GL3DPLOTTERBASE_HXX
 
-#include <boost/ptr_container/ptr_vector.hpp>
 #include "VDataSeries.hxx"
+#include <vector>
+#include <memory>
 
 namespace chart {
 
@@ -22,7 +23,7 @@ class GL3DPlotterBase
 public:
     virtual ~GL3DPlotterBase();
 
-    virtual void create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeries,
+    virtual void create3DShapes(const std::vector<std::unique_ptr<VDataSeries> >& rDataSeries,
         ExplicitCategoriesProvider& rCatProvider) = 0;
     virtual void render() = 0;
 };
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 975f3cf..34a54da 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -3403,7 +3403,7 @@ void ChartView::createShapes3D()
     if( !xDataSeriesContainer.is() )
         return;
 
-    boost::ptr_vector<VDataSeries> aDataSeries;
+    std::vector<std::unique_ptr<VDataSeries> > aDataSeries;
     uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
     for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS )
     {
@@ -3411,7 +3411,7 @@ void ChartView::createShapes3D()
         if(!xDataSeries.is())
             continue;
 
-        aDataSeries.push_back(new VDataSeries(xDataSeries));
+        aDataSeries.push_back(std::make_unique<VDataSeries>(xDataSeries));
     }
 
     std::unique_ptr<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel));
commit 126103cd2ad057f3d6adf907114239820ead8df4
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Nov 10 08:43:04 2015 +0200

    chart2: replace boost::ptr_vector with std::vector<unique_ptr>
    
    Change-Id: I8bc458c2bcbcb72791ba93a6fe15c83e05d8fae1

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index dfded76..5f70233 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -467,10 +467,9 @@ void RenderBenchMarkThread::UpdateScreenText()
     {
         mpChart->mpWindow->getContext().makeCurrent();
         mpChart->mpRenderer->ReleaseScreenTextTexture();
-        for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = mpChart->maScreenTextShapes.begin(),
-                itrEnd = mpChart->maScreenTextShapes.end(); itr != itrEnd; ++itr)
+        for(std::unique_ptr<opengl3D::Renderable3DObject>& aObj : mpChart->maScreenTextShapes)
         {
-            itr->render();
+            aObj->render();
         }
         mpChart->mbScreenTextNewRender = false;
         mpChart->mpWindow->getContext().resetCurrent();
@@ -1135,10 +1134,10 @@ void GL3DBarChart::contextDestroyed()
 float GL3DBarChart::addScreenTextShape(OUString &nStr, const glm::vec2& rLeftOrRightTop, float nTextHeight, bool bLeftTopFlag,
                                             const glm::vec4& rColor, const glm::vec3& rPos, sal_uInt32 nEvent)
 {
-    maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, nStr, rColor, nEvent));
+    maScreenTextShapes.push_back(std::make_unique<opengl3D::ScreenText>(mpRenderer.get(), *mpTextCache, nStr, rColor, nEvent));
     const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(nStr);
     float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * nTextHeight / 2.0f;
-    opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
+    opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(maScreenTextShapes.back().get());
     if (bLeftTopFlag)
         pScreenText->setPosition(rLeftOrRightTop, glm::vec2(rLeftOrRightTop.x + nRectWidth, rLeftOrRightTop.y - nTextHeight), rPos);
     else
@@ -1245,10 +1244,10 @@ void GL3DBarChart::addMovementScreenText(sal_uInt32 nBarId)
                                   rBarInfo.maPos.y + BAR_SIZE_Y / 2.0f,
                                   rBarInfo.maPos.z);
     OUString aBarValue = "Value: " + OUString::number(rBarInfo.mnVal);
-    maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), CALC_POS_EVENT_ID, true));
+    maScreenTextShapes.push_back(std::make_unique<opengl3D::ScreenText>(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), CALC_POS_EVENT_ID, true));
     const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue);
     float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.024;
-    opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
+    opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(maScreenTextShapes.back().get());
     pScreenText->setPosition(glm::vec2(-nRectWidth / 2, 0.03f), glm::vec2(nRectWidth / 2, -0.03f), aTextPos);
 }
 
@@ -1316,8 +1315,8 @@ void GL3DBarChart::updateClickEvent()
         }
         //add translucent back ground
         aTitle = " ";
-        maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aTitle, glm::vec4(0.0f, 0.0f, 0.0f, 0.5f), 0));
-        opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
+        maScreenTextShapes.push_back(std::make_unique<opengl3D::ScreenText>(mpRenderer.get(), *mpTextCache, aTitle, glm::vec4(0.0f, 0.0f, 0.0f, 0.5f), 0));
+        opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(maScreenTextShapes.back().get());
         pScreenText->setPosition(glm::vec2(nMinXCoord, 0.99f), glm::vec2(nMaxXCoord, 0.99f - nMaxHight));
     }
 }
@@ -1442,13 +1441,13 @@ void GL3DBarChart::updateScroll()
             for(size_t i = 0; i < aBarInfoList.size(); i++)
             {
                 OUString aBarValue = "Value: " + OUString::number(aBarInfoList[i].mnVal);
-                maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), CALC_POS_EVENT_ID, true));
+                maScreenTextShapes.push_back(std::make_unique<opengl3D::ScreenText>(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), CALC_POS_EVENT_ID, true));
                 const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue);
                 float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.024;
                 glm::vec3 aTextPos = glm::vec3(aBarInfoList[i].maPos.x + BAR_SIZE_X / 2.0f,
                                       aBarInfoList[i].maPos.y + BAR_SIZE_Y / 2.0f,
                                       aBarInfoList[i].maPos.z);
-                opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
+                opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(maScreenTextShapes.back().get());
                 pScreenText->setPosition(glm::vec2(-nRectWidth / 2, 0.03f), glm::vec2(nRectWidth / 2, -0.03f), aTextPos);
             }
         }
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index d887c5d..5f68b27 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -176,7 +176,7 @@ private:
     bool mbScrollFlg;
     Idle maIdle;
     bool mbScreenTextNewRender;
-    boost::ptr_vector<opengl3D::Renderable3DObject> maScreenTextShapes;
+    std::vector<std::unique_ptr<opengl3D::Renderable3DObject>> maScreenTextShapes;
     OUString maFPS;
     OUString maDataUpdateFPS;
     sal_uInt32 miFrameCount;
commit c3e642c0b6a136dad8b5c30e120575e4f61d6ccd
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Nov 10 08:24:43 2015 +0200

    chart2: replace boost::ptr_vector with std::vector<unique_ptr>
    
    Change-Id: I706b730ebbe6a7637a3f1a9cea80a1604f005a53

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index c1ee3c2..dfded76 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -643,8 +643,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     {
         mnColorRate = 0;
     }
-    maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));
-    mpCamera = static_cast<opengl3D::Camera*>(&maShapes.back());
+    maShapes.push_back(std::make_unique<opengl3D::Camera>(mpRenderer.get()));
+    mpCamera = static_cast<opengl3D::Camera*>(maShapes.back().get());
 
     sal_Int32 nSeriesIndex = 0;
     sal_Int32 nMaxPointCount = 0;
@@ -678,10 +678,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
 
         if(!aSeriesName.isEmpty())
         {
-            maShapes.push_back(new opengl3D::Text(mpRenderer.get(),
+            maShapes.push_back(std::make_unique<opengl3D::Text>(mpRenderer.get(),
                         *mpTextCache, aSeriesName, nId));
             nId += ID_STEP;
-            opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
+            opengl3D::Text* p = static_cast<opengl3D::Text*>(maShapes.back().get());
             glm::vec3 aTopLeft, aTopRight, aBottomRight;
             aTopRight.x = -BAR_DISTANCE_Y;
             aTopRight.y = nYPos + BAR_DISTANCE_Y;
@@ -729,7 +729,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
                         processAutoFly(nId, nColor);
                 }
             }
-            maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId));
+            maShapes.push_back(std::make_unique<opengl3D::Bar>(mpRenderer.get(), aBarPosition, nColor, nId));
             nId += ID_STEP;
         }
 
@@ -743,9 +743,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     nYPos += BAR_SIZE_Y + BAR_DISTANCE_Y;
 
     // X axis
-    maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId));
+    maShapes.push_back(std::make_unique<opengl3D::Line>(mpRenderer.get(), nId));
     nId += ID_STEP;
-    opengl3D::Line* pAxis = static_cast<opengl3D::Line*>(&maShapes.back());
+    opengl3D::Line* pAxis = static_cast<opengl3D::Line*>(maShapes.back().get());
     glm::vec3 aBegin;
     aBegin.y = nYPos;
     glm::vec3 aEnd = aBegin;
@@ -754,9 +754,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     pAxis->setLineColor(COL_BLUE);
 
     // Y axis
-    maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId));
+    maShapes.push_back(std::make_unique<opengl3D::Line>(mpRenderer.get(), nId));
     nId += ID_STEP;
-    pAxis = static_cast<opengl3D::Line*>(&maShapes.back());
+    pAxis = static_cast<opengl3D::Line*>(maShapes.back().get());
     aBegin.x = aBegin.y = 0;
     aEnd = aBegin;
     aEnd.y = nYPos;
@@ -764,9 +764,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
     pAxis->setLineColor(COL_BLUE);
 
     // Chart background.
-    maShapes.push_back(new opengl3D::Rectangle(mpRenderer.get(), nId));
+    maShapes.push_back(std::make_unique<opengl3D::Rectangle>(mpRenderer.get(), nId));
     nId += ID_STEP;
-    opengl3D::Rectangle* pRect = static_cast<opengl3D::Rectangle*>(&maShapes.back());
+    opengl3D::Rectangle* pRect = static_cast<opengl3D::Rectangle*>(maShapes.back().get());
     glm::vec3 aTopLeft;
     glm::vec3 aTopRight = aTopLeft;
     aTopRight.x = mbBenchMarkMode ? (mbScrollFlg ? nXEnd - BAR_SIZE_X : nXEnd + 2 * BAR_DISTANCE_X) : (nXEnd + 2 * BAR_DISTANCE_X);
@@ -791,10 +791,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
 
         float nXPos = i * (BAR_SIZE_X + BAR_DISTANCE_X);
 
-        maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
+        maShapes.push_back(std::make_unique<opengl3D::Text>(mpRenderer.get(), *mpTextCache,
                     aCats[i], nId));
         nId += ID_STEP;
-        opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
+        opengl3D::Text* p = static_cast<opengl3D::Text*>(maShapes.back().get());
         aTopLeft.x = nXPos + TEXT_HEIGHT + 0.5 * BAR_SIZE_X;
         aTopLeft.y = nYPos + calculateTextWidth(aCats[i]) + 0.5 * BAR_DISTANCE_Y;
         aTopRight = aTopLeft;
@@ -805,10 +805,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
 
         // create shapes on other side as well
 
-        maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
+        maShapes.push_back(std::make_unique<opengl3D::Text>(mpRenderer.get(), *mpTextCache,
                     aCats[i], nId));
         nId += ID_STEP;
-        p = static_cast<opengl3D::Text*>(&maShapes.back());
+        p = static_cast<opengl3D::Text*>(maShapes.back().get());
         aTopLeft.x = nXPos + TEXT_HEIGHT + 0.5 * BAR_SIZE_X;
         aTopLeft.y =  - 0.5 * BAR_DISTANCE_Y;
         aTopRight = aTopLeft;
@@ -975,9 +975,9 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
         glm::vec3 aTextPos = glm::vec3(rBarInfo.maPos.x + BAR_SIZE_X / 2.0f,
                 rBarInfo.maPos.y + BAR_SIZE_Y / 2.0f,
                 rBarInfo.maPos.z);
-        maShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache,
+        maShapes.push_back(std::make_unique<opengl3D::ScreenText>(mpRenderer.get(), *mpTextCache,
                     "Value: " + OUString::number(rBarInfo.mnVal), glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), CALC_POS_EVENT_ID));
-        opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maShapes.back());
+        opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(maShapes.back().get());
         pScreenText->setPosition(glm::vec2(-0.9f, 0.9f), glm::vec2(-0.6f, 0.8f), aTextPos);
         pScreenText->render();
         mpWindow->getContext().resetCurrent();
@@ -1015,10 +1015,9 @@ void GL3DBarChart::renderFrame()
     if(mbNeedsNewRender)
     {
         mpRenderer->ReleaseTextTexture();
-        for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
-                itrEnd = maShapes.end(); itr != itrEnd; ++itr)
+        for(std::unique_ptr<opengl3D::Renderable3DObject>& aObj : maShapes)
         {
-            itr->render();
+            aObj->render();
         }
     }
     else
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index d746167..d887c5d 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -120,7 +120,7 @@ private:
     void getNeighborBarID(sal_uInt32 nSelectBarId, sal_uInt32 *pNeighborBarId);
     void addMovementScreenText(sal_uInt32 nBarId);
     css::uno::Reference<css::chart2::XChartType> mxChartType;
-    boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
+    std::vector<std::unique_ptr<opengl3D::Renderable3DObject> > maShapes;
 
     std::unique_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
     VclPtr<OpenGLWindow> mpWindow;


More information about the Libreoffice-commits mailing list