summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-07-01 22:16:15 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-07-03 21:46:47 +0200
commitb0fbaa6fa28df570e8179f166fe0547892b2dbc7 (patch)
tree5022046f89fb5487814de963d710086c44acaf67 /chart2
parent0a21c4faea3a444a3b6c5a7561754c73310fb77c (diff)
Adding multiple trendlines with menu item Insert>Trend Lines..
Menu item "Insert>Trend Lines.." allowed adding trendlines for all data series at the same time. As we can now have more trendlines per one data series this becomes cumbersome so only allow to add a trend line when data series is selected or known. Change-Id: I676876f389d00d3fbe668d429f0f98bd8c8d4d3d
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/ChartController_Insert.cxx47
-rw-r--r--chart2/source/controller/main/ControllerCommandDispatch.cxx10
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;