diff options
Diffstat (limited to 'chart2/source/controller/main')
-rw-r--r-- | chart2/source/controller/main/ChartController_Insert.cxx | 47 | ||||
-rw-r--r-- | chart2/source/controller/main/ControllerCommandDispatch.cxx | 10 |
2 files changed, 12 insertions, 45 deletions
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 86123f808fff..9b882dbacadd 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -363,48 +363,15 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() void ChartController::executeDispatch_InsertMenu_Trendlines() { - //if a series is selected insert only for that series: - uno::Reference< chart2::XDataSeries > xSeries( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); - if( xSeries.is()) - { - executeDispatch_InsertTrendline(); - return; - } - - UndoGuard aUndoGuard( - ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ), - m_xUndoManager ); - - try - { - wrapper::AllSeriesStatisticsConverter aItemConverter( - getModel(), m_pDrawModelWrapper->GetItemPool() ); - SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); - aItemConverter.FillItemSet( aItemSet ); + OUString aCID = m_aSelection.getSelectedCID(); - //prepare and open dialog - SolarMutexGuard aGuard; - InsertTrendlineDialog aDialog( m_pChartWindow, aItemSet ); - aDialog.adjustSize(); + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( aCID, getModel() ), uno::UNO_QUERY ); - if( aDialog.Execute() == RET_OK ) - { - SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); - aDialog.FillItemSet( aOutItemSet ); + if( !xSeries.is() ) + return; - // lock controllers till end of block - ControllerLockGuard aCLGuard( getModel() ); - bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now - if( bChanged ) - aUndoGuard.commit(); - } - } - catch(const uno::RuntimeException& e) - { - ASSERT_EXCEPTION( e ); - } + executeDispatch_InsertTrendline(); } void ChartController::executeDispatch_InsertTrendline() @@ -420,14 +387,12 @@ void ChartController::executeDispatch_InsertTrendline() ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))), m_xUndoManager ); - // add a linear curve uno::Reference< chart2::XRegressionCurve > xCurve = RegressionCurveHelper::addRegressionCurve( RegressionCurveHelper::REGRESSION_TYPE_LINEAR, xRegressionCurveContainer, m_xCC ); - // get an appropriate item converter uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); if( !xProperties.is()) diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 6731998599c2..abb74fc634af 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -117,6 +117,7 @@ struct ControllerState bool bMayMoveSeriesBackward; // trendlines + bool bMayAddMenuTrendline; bool bMayAddTrendline; bool bMayAddTrendlineEquation; bool bMayAddR2Value; @@ -147,6 +148,7 @@ ControllerState::ControllerState() : bIsFormateableObjectSelected(false), bMayMoveSeriesForward( false ), bMayMoveSeriesBackward( false ), + bMayAddMenuTrendline( false ), bMayAddTrendline( false ), bMayAddTrendlineEquation( false ), bMayAddR2Value( false ), @@ -208,6 +210,7 @@ void ControllerState::update( xGivenDataSeries, MOVE_SERIES_BACKWARD ); + bMayAddMenuTrendline = false; bMayAddTrendline = false; bMayAddTrendlineEquation = false; bMayAddR2Value = false; @@ -229,6 +232,7 @@ void ControllerState::update( { if( xGivenDataSeries.is()) { + bMayAddMenuTrendline = true; sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); uno::Reference< chart2::XChartType > xFirstChartType( DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram )); @@ -237,11 +241,9 @@ void ControllerState::update( if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType) && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount )) { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - xGivenDataSeries, uno::UNO_QUERY ); + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xGivenDataSeries, uno::UNO_QUERY ); if( xRegCurveCnt.is()) { - uno::Reference< chart2::XRegressionCurve > xRegCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); // Trendline bMayAddTrendline = true; @@ -578,7 +580,7 @@ void ControllerCommandDispatch::updateCommandAvailability() m_aCommandAvailability[ ".uno:InsertMenuDataLabels" ] = bIsWritable; m_aCommandAvailability[ ".uno:InsertRemoveAxes" ] = m_aCommandAvailability[ ".uno:InsertMenuAxes" ] = bIsWritable && m_apModelState->bSupportsAxes; m_aCommandAvailability[ ".uno:InsertMenuGrids" ] = bIsWritable && m_apModelState->bSupportsAxes; - m_aCommandAvailability[ ".uno:InsertMenuTrendlines" ] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ ".uno:InsertMenuTrendlines" ] = bIsWritable && m_apModelState->bSupportsStatistics && m_apControllerState->bMayAddMenuTrendline; m_aCommandAvailability[ ".uno:InsertMenuMeanValues" ] = bIsWritable && m_apModelState->bSupportsStatistics; m_aCommandAvailability[ ".uno:InsertMenuXErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics; m_aCommandAvailability[ ".uno:InsertMenuYErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics; |