summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorIngrid Halama <iha@openoffice.org>2010-03-09 17:58:27 +0100
committerIngrid Halama <iha@openoffice.org>2010-03-09 17:58:27 +0100
commit6616bad4c5f200c3e3db340682e33ae239a5964c (patch)
treeb5549fdd022e4ba26866088eec3ecdc849296b39 /chart2/source
parentd664555501c1464073c44991724cec578a435a70 (diff)
chart43: #i99562# delete secondary axis automatically if last series is deleted that was attached to it
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx2
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx8
-rw-r--r--chart2/source/inc/AxisHelper.hxx3
-rw-r--r--chart2/source/inc/DiagramHelper.hxx3
-rw-r--r--chart2/source/tools/AxisHelper.cxx20
-rw-r--r--chart2/source/tools/DiagramHelper.cxx8
6 files changed, 41 insertions, 3 deletions
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
index 99ce6b59b113..d69212512ebe 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -285,7 +285,7 @@ void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, cons
{
Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
if( xDiagram.is() )
- ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext );
+ ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext, false );
}
}
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 94a6a24a9a1e..382d85ac0c10 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -48,6 +48,7 @@
#include "LegendHelper.hxx"
#include "AxisHelper.hxx"
#include "RegressionCurveHelper.hxx"
+#include "DiagramHelper.hxx"
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
@@ -107,7 +108,14 @@ bool lcl_deleteDataSeries(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_DATASERIES )))),
xUndoManager, xModel );
+
+ Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) );
+ uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) );
+
::chart::DataSeriesHelper::deleteSeries( xSeries, xChartType );
+
+ ::chart::AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram );
+
bResult = true;
aUndoGuard.commitAction();
}
diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx
index be2a60bb63f7..75e69436a784 100644
--- a/chart2/source/inc/AxisHelper.hxx
+++ b/chart2/source/inc/AxisHelper.hxx
@@ -101,6 +101,9 @@ public:
static void makeAxisInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
static void makeGridInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
+ static void hideAxisIfNoDataIsAttached( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram);
+
SAL_DLLPRIVATE static sal_Bool areAxisLabelsVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProperties );
static sal_Bool isAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
static sal_Bool isGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx
index fe412366606b..43b8f29ab296 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -172,7 +172,8 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext );
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ bool bAdaptAxes=true );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XAxis > getAttachedAxis(
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index b2f7fb24e6f2..8cdd24e4dc05 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -284,6 +284,26 @@ void AxisHelper::makeAxisInvisible( const Reference< XAxis >& xAxis )
}
}
+//static
+void AxisHelper::hideAxisIfNoDataIsAttached( const Reference< XAxis >& xAxis, const Reference< XDiagram >& xDiagram )
+{
+ //axis is hidden if no data is attached anymore but data is available
+ bool bOtherSeriesAttachedToThisAxis = false;
+ ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aIt = aSeriesVector.begin();
+ for( ; aIt != aSeriesVector.end(); ++aIt)
+ {
+ uno::Reference< chart2::XAxis > xCurrentAxis( DiagramHelper::getAttachedAxis( *aIt, xDiagram ), uno::UNO_QUERY );
+ if( xCurrentAxis==xAxis )
+ {
+ bOtherSeriesAttachedToThisAxis = true;
+ break;
+ }
+ }
+ if(!bOtherSeriesAttachedToThisAxis && !aSeriesVector.empty() )
+ AxisHelper::makeAxisInvisible( xAxis );
+}
+
void AxisHelper::hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
, const Reference< XDiagram >& xDiagram )
{
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 31ac5f1ae4ec..a0863a288005 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -597,7 +597,7 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
, const uno::Reference< chart2::XDataSeries >& xDataSeries
, const uno::Reference< chart2::XDiagram >& xDiagram
, const uno::Reference< uno::XComponentContext > & xContext
- )
+ , bool bAdaptAxes )
{
bool bChanged = false;
@@ -608,6 +608,7 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
sal_Int32 nOldAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
+ uno::Reference< chart2::XAxis > xOldAxis( DiagramHelper::getAttachedAxis( xDataSeries, xDiagram ) );
if( nOldAxisIndex != nNewAxisIndex )
{
@@ -627,6 +628,11 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
uno::Reference< XAxis > xAxis( AxisHelper::getAxis( 1, bAttachToMainAxis, xDiagram ) );
if(!xAxis.is()) //create an axis if necessary
xAxis = AxisHelper::createAxis( 1, bAttachToMainAxis, xDiagram, xContext );
+ if( bAdaptAxes )
+ {
+ AxisHelper::makeAxisVisible( xAxis );
+ AxisHelper::hideAxisIfNoDataIsAttached( xOldAxis, xDiagram );
+ }
}
return bChanged;