[Libreoffice-commits] core.git: 6 commits - chart2/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Oct 10 12:43:17 PDT 2014
chart2/source/view/axes/VCoordinateSystem.cxx | 40 ++--
chart2/source/view/inc/VCoordinateSystem.hxx | 9
chart2/source/view/main/ChartView.cxx | 255 +++++++++++++-------------
3 files changed, 166 insertions(+), 138 deletions(-)
New commits:
commit ecf648b3a5881a5f24f5b26d51fb4823b225aed4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 10 14:12:04 2014 -0400
Make the variable name shorter and sweeter...
Change-Id: Ibea26f3c99b50f2011050960794d9736566ee7ce
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 1f1fe68..7e88097 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -77,7 +77,7 @@ VCoordinateSystem::VCoordinateSystem( const Reference< XCoordinateSystem >& xCoo
, m_eLeftWallPos(CuboidPlanePosition_Left)
, m_eBackWallPos(CuboidPlanePosition_Back)
, m_eBottomPos(CuboidPlanePosition_Bottom)
- , m_aMergedMinimumAndMaximumSupplier()
+ , m_aMergedMinMaxSupplier()
, m_aExplicitScales(3)
, m_aExplicitIncrements(3)
, m_apExplicitCategoriesProvider(NULL)
@@ -360,13 +360,14 @@ void VCoordinateSystem::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAuto
{
if( rScaleAutomatism.getScale().AxisType==AxisType::DATE && nDimIndex==0 )
{
+ // This is a date X dimension. Determine proper time resolution.
sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::MONTH;
if( !(rScaleAutomatism.getScale().TimeIncrement.TimeResolution >>= nTimeResolution) )
{
- nTimeResolution = m_aMergedMinimumAndMaximumSupplier.calculateTimeResolutionOnXAxis();
+ nTimeResolution = m_aMergedMinMaxSupplier.calculateTimeResolutionOnXAxis();
rScaleAutomatism.setAutomaticTimeResolution( nTimeResolution );
}
- m_aMergedMinimumAndMaximumSupplier.setTimeResolutionOnXAxis( nTimeResolution, rScaleAutomatism.getNullDate() );
+ m_aMergedMinMaxSupplier.setTimeResolutionOnXAxis( nTimeResolution, rScaleAutomatism.getNullDate() );
}
double fMin = 0.0;
@@ -375,31 +376,34 @@ void VCoordinateSystem::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAuto
::rtl::math::setInf(&fMax, true);
if( 0 == nDimIndex )
{
- fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumX();
- fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumX();
+ // x dimension
+ fMin = m_aMergedMinMaxSupplier.getMinimumX();
+ fMax = m_aMergedMinMaxSupplier.getMaximumX();
}
else if( 1 == nDimIndex )
{
+ // y dimension
ExplicitScaleData aScale = getExplicitScale( 0, 0 );
- fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
- fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
+ fMin = m_aMergedMinMaxSupplier.getMinimumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
+ fMax = m_aMergedMinMaxSupplier.getMaximumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
}
else if( 2 == nDimIndex )
{
- fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumZ();
- fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumZ();
+ // z dimension
+ fMin = m_aMergedMinMaxSupplier.getMinimumZ();
+ fMax = m_aMergedMinMaxSupplier.getMaximumZ();
}
//merge our values with those already contained in rScaleAutomatism
rScaleAutomatism.expandValueRange( fMin, fMax );
rScaleAutomatism.setAutoScalingOptions(
- m_aMergedMinimumAndMaximumSupplier.isExpandBorderToIncrementRhythm( nDimIndex ),
- m_aMergedMinimumAndMaximumSupplier.isExpandIfValuesCloseToBorder( nDimIndex ),
- m_aMergedMinimumAndMaximumSupplier.isExpandWideValuesToZero( nDimIndex ),
- m_aMergedMinimumAndMaximumSupplier.isExpandNarrowValuesTowardZero( nDimIndex ) );
+ m_aMergedMinMaxSupplier.isExpandBorderToIncrementRhythm( nDimIndex ),
+ m_aMergedMinMaxSupplier.isExpandIfValuesCloseToBorder( nDimIndex ),
+ m_aMergedMinMaxSupplier.isExpandWideValuesToZero( nDimIndex ),
+ m_aMergedMinMaxSupplier.isExpandNarrowValuesTowardZero( nDimIndex ) );
- VAxisBase* pVAxis( this->getVAxis( nDimIndex, nAxisIndex ) );
+ VAxisBase* pVAxis = getVAxis(nDimIndex, nAxisIndex);
if( pVAxis )
rScaleAutomatism.setMaximumAutoMainIncrementCount( pVAxis->estimateMaximumAutoMainIncrementCount() );
}
@@ -530,17 +534,17 @@ void VCoordinateSystem::createGridShapes()
}
void VCoordinateSystem::addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
{
- m_aMergedMinimumAndMaximumSupplier.addMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
+ m_aMergedMinMaxSupplier.addMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
}
bool VCoordinateSystem::hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
{
- return m_aMergedMinimumAndMaximumSupplier.hasMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
+ return m_aMergedMinMaxSupplier.hasMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
}
void VCoordinateSystem::clearMinimumAndMaximumSupplierList()
{
- m_aMergedMinimumAndMaximumSupplier.clearMinimumAndMaximumSupplierList();
+ m_aMergedMinMaxSupplier.clearMinimumAndMaximumSupplierList();
}
bool VCoordinateSystem::getPropertySwapXAndYAxis() const
diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx
index 7439535..cde8c1b 100644
--- a/chart2/source/view/inc/VCoordinateSystem.hxx
+++ b/chart2/source/view/inc/VCoordinateSystem.hxx
@@ -172,7 +172,12 @@ protected: //member
CuboidPlanePosition m_eBackWallPos;
CuboidPlanePosition m_eBottomPos;
- MergedMinimumAndMaximumSupplier m_aMergedMinimumAndMaximumSupplier; //this is used only for autoscaling purpose
+ /**
+ * Collection of min-max suppliers which are basically different chart
+ * types present in the same coordinate system. This is used only for
+ * auto-scaling purposes.
+ */
+ MergedMinimumAndMaximumSupplier m_aMergedMinMaxSupplier;
::com::sun::star::uno::Sequence< OUString > m_aSeriesNamesForZAxis;
commit acfabbf06d37b5bcd18dc27fcbf75a3943f498f8
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 10 11:40:55 2014 -0400
prepareScaleAutomatismForDimensionAndIndex -> prepareAutomaticAxisScaling.
Change-Id: Ic66d2fcf78603bdd4fa1e08933900f49c66384b7
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 457ff82..1f1fe68 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -356,7 +356,7 @@ void VCoordinateSystem::updateScalesAndIncrementsOnAxes()
{
}
-void VCoordinateSystem::prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex )
+void VCoordinateSystem::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex )
{
if( rScaleAutomatism.getScale().AxisType==AxisType::DATE && nDimIndex==0 )
{
diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx
index 54df0b3..7439535 100644
--- a/chart2/source/view/inc/VCoordinateSystem.hxx
+++ b/chart2/source/view/inc/VCoordinateSystem.hxx
@@ -86,7 +86,7 @@ public:
bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier );
void clearMinimumAndMaximumSupplierList();
- void prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex );
+ void prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex );
void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex
, const ExplicitScaleData& rExplicitScale
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index f3f14a4..1ecbe06 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -227,7 +227,7 @@ void AxisUsage::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism,
{
std::vector<VCoordinateSystem*> aVCooSysList = getCoordinateSystems(nDimIndex, nAxisIndex);
for (size_t i = 0, n = aVCooSysList.size(); i < n; ++i)
- aVCooSysList[i]->prepareScaleAutomatismForDimensionAndIndex(rScaleAutomatism, nDimIndex, nAxisIndex);
+ aVCooSysList[i]->prepareAutomaticAxisScaling(rScaleAutomatism, nDimIndex, nAxisIndex);
}
void AxisUsage::setExplicitScaleAndIncrement(
@@ -793,7 +793,7 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel&
{
for( size_t nC = 0; nC < aVCooSysList_Y.size(); ++nC )
{
- aVCooSysList_Y[nC]->prepareScaleAutomatismForDimensionAndIndex( rAxisUsage.aAutoScaling, 1, nAttachedAxisIndex );
+ aVCooSysList_Y[nC]->prepareAutomaticAxisScaling( rAxisUsage.aAutoScaling, 1, nAttachedAxisIndex );
ExplicitScaleData aExplicitScaleSource = aVCooSysList_Y[nC]->getExplicitScale( 1,nAttachedAxisIndex );
ExplicitIncrementData aExplicitIncrementSource = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAttachedAxisIndex );
commit 2ba6c00d37606595244ea2e67ddc14e129805b48
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 10 11:15:17 2014 -0400
Hide the 3rd nested looping for clarity.
Also aScaleAutomatism -> aAutoScaling. The word 'automatism' is a bit
awkward.
Change-Id: I9856f904d5693e79e19176ba5fff881267d5c7e7
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 9764494..f3f14a4 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -141,7 +141,10 @@ struct AxisUsage
::std::vector< VCoordinateSystem* > getCoordinateSystems( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
sal_Int32 getMaxAxisIndexForDimension( sal_Int32 nDimensionIndex );
- ScaleAutomatism aScaleAutomatism;
+ void prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex );
+ void setExplicitScaleAndIncrement( sal_Int32 nDimIndex, sal_Int32 nAxisIndex, const ExplicitScaleData& rScale, const ExplicitIncrementData& rInc );
+
+ ScaleAutomatism aAutoScaling;
private:
tCoordinateSystemMap aCoordinateSystems;
@@ -149,7 +152,7 @@ private:
};
AxisUsage::AxisUsage()
- : aScaleAutomatism(AxisHelper::createDefaultScale(),Date( Date::SYSTEM ))
+ : aAutoScaling(AxisHelper::createDefaultScale(), Date(Date::SYSTEM))
{
}
@@ -220,6 +223,21 @@ sal_Int32 AxisUsage::getMaxAxisIndexForDimension( sal_Int32 nDimensionIndex )
return nRet;
}
+void AxisUsage::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex )
+{
+ std::vector<VCoordinateSystem*> aVCooSysList = getCoordinateSystems(nDimIndex, nAxisIndex);
+ for (size_t i = 0, n = aVCooSysList.size(); i < n; ++i)
+ aVCooSysList[i]->prepareScaleAutomatismForDimensionAndIndex(rScaleAutomatism, nDimIndex, nAxisIndex);
+}
+
+void AxisUsage::setExplicitScaleAndIncrement(
+ sal_Int32 nDimIndex, sal_Int32 nAxisIndex, const ExplicitScaleData& rScale, const ExplicitIncrementData& rInc )
+{
+ std::vector<VCoordinateSystem*> aVCooSysList = getCoordinateSystems(nDimIndex, nAxisIndex);
+ for (size_t i = 0, n = aVCooSysList.size(); i < n; ++i)
+ aVCooSysList[i]->setExplicitScaleAndIncrement(nDimIndex, nAxisIndex, rScale, rInc);
+}
+
typedef boost::ptr_vector<VSeriesPlotter> SeriesPlottersType;
class SeriesPlotterContainer
@@ -584,7 +602,7 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate)
bool bHasComplexCat = pCatProvider && pCatProvider->hasComplexCategories();
aSourceScale.ShiftedCategoryPosition = isCategoryPositionShifted(aSourceScale, bHasComplexCat);
- m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(aSourceScale, rNullDate);
+ m_aAxisUsageList[xAxis].aAutoScaling = ScaleAutomatism(aSourceScale, rNullDate);
}
AxisUsage& rAxisUsage = m_aAxisUsageList[xAxis];
@@ -697,57 +715,38 @@ void SeriesPlotterContainer::doAutoScaling( ChartModel& rChartModel )
const ::std::map< uno::Reference< XAxis >, AxisUsage >::const_iterator aAxisEndIter = m_aAxisUsageList.end();
//iterate over the main scales first than secondary axis
- size_t nC;
- sal_Int32 nAxisIndex=0;
- for( nAxisIndex=0; nAxisIndex<=m_nMaxAxisIndex; nAxisIndex++ )
+ for (sal_Int32 nAxisIndex = 0; nAxisIndex <= m_nMaxAxisIndex; ++nAxisIndex)
{
-
// - first do autoscale for all x and z scales (because they are treated independent)
for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
{
AxisUsage& rAxisUsage = (*aAxisIter).second;
- ::std::vector< VCoordinateSystem* > aVCooSysList_X = rAxisUsage.getCoordinateSystems(0,nAxisIndex);
- ::std::vector< VCoordinateSystem* > aVCooSysList_Z = rAxisUsage.getCoordinateSystems(2,nAxisIndex);
- for( nC=0; nC < aVCooSysList_X.size(); nC++)
- aVCooSysList_X[nC]->prepareScaleAutomatismForDimensionAndIndex(rAxisUsage.aScaleAutomatism,0,nAxisIndex);
- for( nC=0; nC < aVCooSysList_Z.size(); nC++)
- aVCooSysList_Z[nC]->prepareScaleAutomatismForDimensionAndIndex(rAxisUsage.aScaleAutomatism,2,nAxisIndex);
+ rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 0, nAxisIndex);
+ rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 2, nAxisIndex);
ExplicitScaleData aExplicitScale;
ExplicitIncrementData aExplicitIncrement;
- rAxisUsage.aScaleAutomatism.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement );
+ rAxisUsage.aAutoScaling.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement );
- for( nC=0; nC < aVCooSysList_X.size(); nC++)
- aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement );
- for( nC=0; nC < aVCooSysList_Z.size(); nC++)
- aVCooSysList_Z[nC]->setExplicitScaleAndIncrement( 2, nAxisIndex, aExplicitScale, aExplicitIncrement );
+ rAxisUsage.setExplicitScaleAndIncrement(0, nAxisIndex, aExplicitScale, aExplicitIncrement);
+ rAxisUsage.setExplicitScaleAndIncrement(2, nAxisIndex, aExplicitScale, aExplicitIncrement);
}
// - second do autoscale for the dependent y scales (the coordinate systems are prepared with x and z scales already )
for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
{
AxisUsage& rAxisUsage = (*aAxisIter).second;
- ::std::vector< VCoordinateSystem* > aVCooSysList_X = rAxisUsage.getCoordinateSystems(0,nAxisIndex);
- ::std::vector< VCoordinateSystem* > aVCooSysList_Y = rAxisUsage.getCoordinateSystems(1,nAxisIndex);
- ::std::vector< VCoordinateSystem* > aVCooSysList_Z = rAxisUsage.getCoordinateSystems(2,nAxisIndex);
- if(!aVCooSysList_Y.size())
- continue;
-
- for( nC=0; nC < aVCooSysList_Y.size(); nC++)
- aVCooSysList_Y[nC]->prepareScaleAutomatismForDimensionAndIndex(rAxisUsage.aScaleAutomatism,1,nAxisIndex);
+ rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 1, nAxisIndex);
ExplicitScaleData aExplicitScale;
ExplicitIncrementData aExplicitIncrement;
- rAxisUsage.aScaleAutomatism.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement );
-
- for( nC=0; nC < aVCooSysList_X.size(); nC++)
- aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement );
- for( nC=0; nC < aVCooSysList_Y.size(); nC++)
- aVCooSysList_Y[nC]->setExplicitScaleAndIncrement( 1, nAxisIndex, aExplicitScale, aExplicitIncrement );
- for( nC=0; nC < aVCooSysList_Z.size(); nC++)
- aVCooSysList_Z[nC]->setExplicitScaleAndIncrement( 2, nAxisIndex, aExplicitScale, aExplicitIncrement );
+ rAxisUsage.aAutoScaling.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement );
+
+ rAxisUsage.setExplicitScaleAndIncrement(0, nAxisIndex, aExplicitScale, aExplicitIncrement);
+ rAxisUsage.setExplicitScaleAndIncrement(1, nAxisIndex, aExplicitScale, aExplicitIncrement);
+ rAxisUsage.setExplicitScaleAndIncrement(2, nAxisIndex, aExplicitScale, aExplicitIncrement);
}
}
AdaptScaleOfYAxisWithoutAttachedSeries( rChartModel );
@@ -794,7 +793,7 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel&
{
for( size_t nC = 0; nC < aVCooSysList_Y.size(); ++nC )
{
- aVCooSysList_Y[nC]->prepareScaleAutomatismForDimensionAndIndex( rAxisUsage.aScaleAutomatism, 1, nAttachedAxisIndex );
+ aVCooSysList_Y[nC]->prepareScaleAutomatismForDimensionAndIndex( rAxisUsage.aAutoScaling, 1, nAttachedAxisIndex );
ExplicitScaleData aExplicitScaleSource = aVCooSysList_Y[nC]->getExplicitScale( 1,nAttachedAxisIndex );
ExplicitIncrementData aExplicitIncrementSource = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAttachedAxisIndex );
@@ -808,7 +807,7 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel&
aExplicitIncrementDest.BaseValue = aExplicitIncrementSource.BaseValue;
- ScaleData aScale( rAxisUsage.aScaleAutomatism.getScale() );
+ ScaleData aScale( rAxisUsage.aAutoScaling.getScale() );
if( !aScale.Minimum.hasValue() )
{
bool bNewMinOK = true;
commit 5ce6a22a3bd048267af6b301ae54248a11a38def
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 10 09:53:26 2014 -0400
Make this loop a bit easier to follow...
Change-Id: Ib978f47925e1f7d77e02586bff50d24fa5b27f2c
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index e693deeb..9764494 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -242,6 +242,9 @@ public:
void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel );
+ bool isCategoryPositionShifted(
+ const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) const;
+
private:
SeriesPlottersType m_aSeriesPlotterList;
std::vector< VCoordinateSystem* >& m_rVCooSysList;
@@ -525,61 +528,89 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
}
}
+bool SeriesPlotterContainer::isCategoryPositionShifted(
+ const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) const
+{
+ if (rSourceScale.AxisType == AxisType::CATEGORY && m_bChartTypeUsesShiftedCategoryPositionPerDefault)
+ return true;
+
+ if (rSourceScale.AxisType==AxisType::CATEGORY && bHasComplexCategories)
+ return true;
+
+ if (rSourceScale.AxisType == AxisType::DATE)
+ return true;
+
+ if (rSourceScale.AxisType == AxisType::SERIES)
+ return true;
+
+ return false;
+}
+
void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate)
{
m_aAxisUsageList.clear();
- size_t nC;
- for( nC=0; nC < m_rVCooSysList.size(); nC++)
+
+ // Loop through coordinate systems in the diagram (though for now
+ // there should only be one coordinate system per diagram).
+ for (size_t i = 0, n = m_rVCooSysList.size(); i < n; ++i)
{
- VCoordinateSystem* pVCooSys = m_rVCooSysList[nC];
- for(sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
+ VCoordinateSystem* pVCooSys = m_rVCooSysList[i];
+ uno::Reference<XCoordinateSystem> xCooSys = pVCooSys->getModel();
+ sal_Int32 nDimCount = xCooSys->getDimension();
+
+ for (sal_Int32 nDimIndex = 0; nDimIndex < nDimCount; ++nDimIndex)
{
- uno::Reference< XCoordinateSystem > xCooSys = pVCooSys->getModel();
- sal_Int32 nDimensionCount = xCooSys->getDimension();
- if( nDimensionIndex >= nDimensionCount )
- continue;
- bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), nDimensionCount, nDimensionIndex );
- const sal_Int32 nMaximumAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
- for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex)
+ bool bDateAxisAllowed = ChartTypeHelper::isSupportingDateAxis(
+ AxisHelper::getChartTypeByIndex(xCooSys, 0), nDimCount, nDimIndex);
+
+ // Each dimension may have primary and secondary axes.
+ const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
+ for (sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; ++nAxisIndex)
{
- uno::Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
- OSL_ASSERT( xAxis.is());
- if( xAxis.is())
+ uno::Reference<XAxis> xAxis = xCooSys->getAxisByDimension(nDimIndex, nAxisIndex);
+
+ if (!xAxis.is())
+ continue;
+
+ if (m_aAxisUsageList.find(xAxis) == m_aAxisUsageList.end())
{
- if(m_aAxisUsageList.find(xAxis)==m_aAxisUsageList.end())
- {
- chart2::ScaleData aSourceScale = xAxis->getScaleData();
- ExplicitCategoriesProvider* pExplicitCategoriesProvider = pVCooSys->getExplicitCategoriesProvider();
- if( nDimensionIndex==0 )
- AxisHelper::checkDateAxis( aSourceScale, pExplicitCategoriesProvider, bChartTypeAllowsDateAxis );
- if( (aSourceScale.AxisType == AxisType::CATEGORY && m_bChartTypeUsesShiftedCategoryPositionPerDefault)
- || (aSourceScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() )
- || aSourceScale.AxisType == AxisType::DATE
- || aSourceScale.AxisType == AxisType::SERIES )
- aSourceScale.ShiftedCategoryPosition = true;
- else
- aSourceScale.ShiftedCategoryPosition = false;
- m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(aSourceScale,rNullDate);
- }
- AxisUsage& rAxisUsage = m_aAxisUsageList[xAxis];
- rAxisUsage.addCoordinateSystem(pVCooSys,nDimensionIndex,nAxisIndex);
+ // Create axis usage object for this axis.
+
+ chart2::ScaleData aSourceScale = xAxis->getScaleData();
+ ExplicitCategoriesProvider* pCatProvider = pVCooSys->getExplicitCategoriesProvider();
+ if (nDimIndex == 0)
+ AxisHelper::checkDateAxis( aSourceScale, pCatProvider, bDateAxisAllowed );
+
+ bool bHasComplexCat = pCatProvider && pCatProvider->hasComplexCategories();
+ aSourceScale.ShiftedCategoryPosition = isCategoryPositionShifted(aSourceScale, bHasComplexCat);
+
+ m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(aSourceScale, rNullDate);
}
+
+ AxisUsage& rAxisUsage = m_aAxisUsageList[xAxis];
+ rAxisUsage.addCoordinateSystem(pVCooSys, nDimIndex, nAxisIndex);
}
}
}
+ // Determine the highest axis index of all dimensions.
::std::map< uno::Reference< XAxis >, AxisUsage >::iterator aAxisIter = m_aAxisUsageList.begin();
const ::std::map< uno::Reference< XAxis >, AxisUsage >::const_iterator aAxisEndIter = m_aAxisUsageList.end();
-
- //init m_nMaxAxisIndex
m_nMaxAxisIndex = 0;
- for(sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
+ for (size_t i = 0, n = m_rVCooSysList.size(); i < n; ++i)
{
- for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
+ VCoordinateSystem* pVCooSys = m_rVCooSysList[i];
+ uno::Reference<XCoordinateSystem> xCooSys = pVCooSys->getModel();
+ sal_Int32 nDimCount = xCooSys->getDimension();
+
+ for (sal_Int32 nDimIndex = 0; nDimIndex < nDimCount; ++nDimIndex)
{
- sal_Int32 nLocalMax = aAxisIter->second.getMaxAxisIndexForDimension( nDimensionIndex );
- if( m_nMaxAxisIndex < nLocalMax )
- m_nMaxAxisIndex = nLocalMax;
+ for (aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter)
+ {
+ sal_Int32 nLocalMax = aAxisIter->second.getMaxAxisIndexForDimension(nDimIndex);
+ if (m_nMaxAxisIndex < nLocalMax)
+ m_nMaxAxisIndex = nLocalMax;
+ }
}
}
}
commit 424fb26da3603a5ec702b96fc0dcc2458706e84d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 10 09:33:33 2014 -0400
Make this a hard prerequisite.
Change-Id: Ib1c859b6033b2cf148e1ed74a437dda85872dffe
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 01d3cf8..e693deeb 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -658,8 +658,9 @@ void SeriesPlotterContainer::updateScalesAndIncrementsOnAxes()
void SeriesPlotterContainer::doAutoScaling( ChartModel& rChartModel )
{
- //precondition: need a initialized m_aSeriesPlotterList
- //precondition: need a initialized m_aAxisUsageList
+ if (m_aSeriesPlotterList.empty() || m_aAxisUsageList.empty())
+ // We need these two containers populated to do auto-scaling. Bail out.
+ return;
::std::map< uno::Reference< XAxis >, AxisUsage >::iterator aAxisIter = m_aAxisUsageList.begin();
const ::std::map< uno::Reference< XAxis >, AxisUsage >::const_iterator aAxisEndIter = m_aAxisUsageList.end();
commit eb2c2f1a3c1a6c829d75418ec1578d15f7895485
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Oct 10 09:30:04 2014 -0400
Use boost::ptr_vector for this...
which also exposed few cases of mis-used const-ness here and there...
Change-Id: Ie4374459643fc050ded646762d72ad622cf3f843
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 9d3b54c..01d3cf8 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -115,6 +115,7 @@
#include <osl/time.h>
#include <boost/shared_ptr.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
namespace chart {
@@ -219,6 +220,8 @@ sal_Int32 AxisUsage::getMaxAxisIndexForDimension( sal_Int32 nDimensionIndex )
return nRet;
}
+typedef boost::ptr_vector<VSeriesPlotter> SeriesPlottersType;
+
class SeriesPlotterContainer
{
public:
@@ -233,14 +236,14 @@ public:
void setNumberFormatsFromAxes();
drawing::Direction3D getPreferredAspectRatio();
- std::vector< VSeriesPlotter* >& getSeriesPlotterList() { return m_aSeriesPlotterList; }
+ SeriesPlottersType& getSeriesPlotterList() { return m_aSeriesPlotterList; }
std::vector< VCoordinateSystem* >& getCooSysList() { return m_rVCooSysList; }
std::vector< LegendEntryProvider* > getLegendEntryProviderList();
void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel );
private:
- std::vector< VSeriesPlotter* > m_aSeriesPlotterList;
+ SeriesPlottersType m_aSeriesPlotterList;
std::vector< VCoordinateSystem* >& m_rVCooSysList;
::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList;
sal_Int32 m_nMaxAxisIndex;
@@ -261,22 +264,16 @@ SeriesPlotterContainer::~SeriesPlotterContainer()
// - remove plotter from coordinatesystems
for( size_t nC=0; nC < m_rVCooSysList.size(); nC++)
m_rVCooSysList[nC]->clearMinimumAndMaximumSupplierList();
- // - delete all plotter
- ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
- const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
- for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
- delete *aPlotterIter;
- m_aSeriesPlotterList.clear();
}
std::vector< LegendEntryProvider* > SeriesPlotterContainer::getLegendEntryProviderList()
{
std::vector< LegendEntryProvider* > aRet( m_aSeriesPlotterList.size() );
- ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
- const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
+ 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;
+ aRet[nN] = &(*aPlotterIter);
return aRet;
}
@@ -517,7 +514,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
{
if(!bSeriesNamesInitialized)
{
- VSeriesPlotter* pSeriesPlotter = m_aSeriesPlotterList[0];
+ VSeriesPlotter* pSeriesPlotter = &m_aSeriesPlotterList[0];
if( pSeriesPlotter )
aSeriesNames = pSeriesPlotter->getSeriesNames();
bSeriesNamesInitialized = true;
@@ -590,11 +587,11 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate)
void SeriesPlotterContainer::setScalesFromCooSysToPlotter()
{
//set scales to plotter to enable them to provide the preferred scene AspectRatio
- ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
- const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
+ SeriesPlottersType::iterator aPlotterIter = m_aSeriesPlotterList.begin();
+ const SeriesPlottersType::iterator aPlotterEnd = m_aSeriesPlotterList.end();
for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
{
- VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
+ VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter);
VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( m_rVCooSysList, pSeriesPlotter );
if(pVCooSys)
{
@@ -609,11 +606,11 @@ void SeriesPlotterContainer::setScalesFromCooSysToPlotter()
void SeriesPlotterContainer::setNumberFormatsFromAxes()
{
//set numberformats to plotter to enable them to display the data labels in the numberformat of the axis
- ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
- const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
+ SeriesPlottersType::iterator aPlotterIter = m_aSeriesPlotterList.begin();
+ const SeriesPlottersType::iterator aPlotterEnd = m_aSeriesPlotterList.end();
for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
{
- VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
+ VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter);
VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( m_rVCooSysList, pSeriesPlotter );
if(pVCooSys)
{
@@ -876,12 +873,12 @@ drawing::Direction3D SeriesPlotterContainer::getPreferredAspectRatio()
//first with special demands wins (less or equal zero <-> arbitrary)
double fx, fy, fz;
fx = fy = fz = -1.0;
- ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
- const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
+ 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 )
{
- drawing::Direction3D aSingleRatio( (*aPlotterIter)->getPreferredDiagramAspectRatio() );
+ drawing::Direction3D aSingleRatio( aPlotterIter->getPreferredDiagramAspectRatio() );
if( fx<0 && aSingleRatio.DirectionX>0 )
fx = aSingleRatio.DirectionX;
@@ -1455,7 +1452,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
basegfx::B2IRectangle aAvailableOuterRect = BaseGFXHelper::makeRectangle(rParam.maRemainingSpace);
const std::vector< VCoordinateSystem* >& rVCooSysList( rParam.mpSeriesPlotterContainer->getCooSysList() );
- const std::vector< VSeriesPlotter* >& rSeriesPlotterList( rParam.mpSeriesPlotterContainer->getSeriesPlotterList() );
+ SeriesPlottersType& rSeriesPlotterList = rParam.mpSeriesPlotterContainer->getSeriesPlotterList();
//create VAxis, so they can give necessary information for automatic scaling
uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( static_cast< ::cppu::OWeakObject* >( &mrChartModel ), uno::UNO_QUERY );
@@ -1581,11 +1578,11 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
// - create data series for all charttypes
m_bPointsWereSkipped = false;
- ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = rSeriesPlotterList.begin();
- const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = rSeriesPlotterList.end();
+ SeriesPlottersType::iterator aPlotterIter = rSeriesPlotterList.begin();
+ const SeriesPlottersType::iterator aPlotterEnd = rSeriesPlotterList.end();
for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
{
- VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
+ VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter);
OUString aCID; //III
uno::Reference< drawing::XShapes > xSeriesTarget(0);
if( pSeriesPlotter->WantToPlotInFrontOfAxisLine() )
@@ -1624,7 +1621,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
{
- VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
+ VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter);
pSeriesPlotter->releaseShapes();
}
@@ -1644,7 +1641,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
// - create data series for all charttypes
for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
{
- VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
+ VSeriesPlotter* pSeriesPlotter = &(*aPlotterIter);
VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( rVCooSysList, pSeriesPlotter );
if(2==nDimensionCount)
pSeriesPlotter->setTransformationSceneToScreen( pVCooSys->getTransformationSceneToScreen() );
@@ -1653,10 +1650,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
}
for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
- {
- VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
- pSeriesPlotter->rearrangeLabelToAvoidOverlapIfRequested( rPageSize );
- }
+ aPlotterIter->rearrangeLabelToAvoidOverlapIfRequested(rPageSize);
}
if (rParam.mbUseFixedInnerSize)
@@ -1669,8 +1663,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
bool bSnapRectToUsedArea = false;
for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
{
- VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
- bSnapRectToUsedArea = pSeriesPlotter->shouldSnapRectToUsedArea();
+ bSnapRectToUsedArea = aPlotterIter->shouldSnapRectToUsedArea();
if(bSnapRectToUsedArea)
break;
}
@@ -3064,13 +3057,11 @@ void ChartView::createShapes2D( const awt::Size& rPageSize )
aParam.mpSeriesPlotterContainer->initializeCooSysAndSeriesPlotter( mrChartModel );
if(maTimeBased.bTimeBased && maTimeBased.nFrame != 0)
{
- std::vector<VSeriesPlotter*>& rSeriesPlotter =
- aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
+ SeriesPlottersType& rSeriesPlotter = aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
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());
@@ -3127,17 +3118,14 @@ void ChartView::createShapes2D( const awt::Size& rPageSize )
if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
{
// create copy of the data for next frame
- std::vector<VSeriesPlotter*>& rSeriesPlotter =
- aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
+ SeriesPlottersType& rSeriesPlotter = aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
size_t n = rSeriesPlotter.size();
maTimeBased.m_aDataSeriesList.clear();
maTimeBased.m_aDataSeriesList.resize(n);
for(size_t i = 0; i < n; ++i)
{
- std::vector< VDataSeries* > aAllNewDataSeries =
- rSeriesPlotter[i]->getAllSeries();
- std::vector< VDataSeries* >& rAllOldDataSeries =
- maTimeBased.m_aDataSeriesList[i];
+ 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)
{
More information about the Libreoffice-commits
mailing list