summaryrefslogtreecommitdiff
path: root/chart2/source/tools/AxisHelper.cxx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-10-20 14:56:32 +0200
committerMichael Stahl <mstahl@redhat.com>2014-10-20 17:14:26 +0200
commit908d1b6e632922a6fa59385c49828be3c3eeb969 (patch)
tree8748baf657b16dacc90c23696412dc9d4d274fe2 /chart2/source/tools/AxisHelper.cxx
parentae218f4895082ea9fca8f414a332bcf47045ba8c (diff)
chart2: fix memory leak due to cyclic reference in VAxisBase
The VAxisBase::m_xNumberFormatsSupplier refers to the ChartModel itself, and apparently that is a cyclic reference. Naively using the ChartModel's m_xNumberFormatsSupplier in ChartView::impl_createDiagramAndContent() because it will later be passed to AxisHelper::getExplicitNumberFormatKeyForAxis(), which expects to be able to convert it to a ChartModel. Since passing around the ChartModel as an XNumberFormattingSupplier is sort of un-intuitive anyway, refactor some methods to use XChartDocument instead, and only create the VPolarAxis / VCartesianAxis with the ChartModel's m_xNumberFormatsSupplier. The drawback is that if ChartModel::attachNumberFormatsSupplier() is called after ChartView::update() has created the axes, it may not have an effect on them; not sure if that is a real or hypothetical problem. Change-Id: Ib5f0d5882b85adaf44f80e086f19178b3e64882f
Diffstat (limited to 'chart2/source/tools/AxisHelper.cxx')
-rw-r--r--chart2/source/tools/AxisHelper.cxx6
1 files changed, 3 insertions, 3 deletions
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index acc757071ff6..d60b0311c07c 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -132,7 +132,7 @@ void AxisHelper::checkDateAxis( chart2::ScaleData& rScale, ExplicitCategoriesPro
sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
const Reference< chart2::XAxis >& xAxis
, const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem
- , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
+ , const Reference<chart2::XChartDocument>& xChartDoc
, bool bSearchForParallelAxisIfNothingIsFound )
{
sal_Int32 nNumberFormatKey(0);
@@ -140,7 +140,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
sal_Int32 nAxisIndex = 0;
sal_Int32 nDimensionIndex = 1;
AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex );
- Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY );
+ Reference<util::XNumberFormatsSupplier> const xNumberFormatsSupplier(xChartDoc, uno::UNO_QUERY);
Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
if (!xProp.is())
@@ -321,7 +321,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis(
{
sal_Int32 nParallelAxisIndex = (nAxisIndex==1) ?0 :1;
Reference< XAxis > xParallelAxis( AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem ) );
- nNumberFormatKey = AxisHelper::getExplicitNumberFormatKeyForAxis( xParallelAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier, false );
+ nNumberFormatKey = AxisHelper::getExplicitNumberFormatKeyForAxis(xParallelAxis, xCorrespondingCoordinateSystem, xChartDoc, false);
}
}
}