1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <ChartController.hxx>
23 #include <dlg_InsertAxis_Grid.hxx>
24 #include <dlg_InsertDataLabel.hxx>
25 #include <dlg_InsertLegend.hxx>
26 #include <dlg_InsertErrorBars.hxx>
27 #include <dlg_InsertTitle.hxx>
28 #include <dlg_ObjectProperties.hxx>
30 #include <ChartWindow.hxx>
31 #include <ChartModelHelper.hxx>
32 #include <AxisHelper.hxx>
33 #include <TitleHelper.hxx>
34 #include <DiagramHelper.hxx>
35 #include <chartview/DrawModelWrapper.hxx>
36 #include <NumberFormatterWrapper.hxx>
37 #include <ViewElementListProvider.hxx>
38 #include <MultipleChartConverters.hxx>
39 #include <ControllerLockGuard.hxx>
40 #include "UndoGuard.hxx"
42 #include <strings.hrc>
43 #include <ReferenceSizeProvider.hxx>
44 #include <ObjectIdentifier.hxx>
45 #include <RegressionCurveHelper.hxx>
46 #include <RegressionCurveItemConverter.hxx>
47 #include <StatisticsHelper.hxx>
48 #include <ErrorBarItemConverter.hxx>
49 #include <MultipleItemConverter.hxx>
50 #include <DataSeriesHelper.hxx>
51 #include <ObjectNameProvider.hxx>
52 #include <LegendHelper.hxx>
54 #include <com/sun/star/chart2/XRegressionCurve.hpp>
55 #include <com/sun/star/chart/ErrorBarStyle.hpp>
56 #include <svx/ActionDescriptionProvider.hxx>
58 #include <rtl/ustrbuf.hxx>
59 #include <vcl/svapp.hxx>
61 using namespace ::com::sun::star
;
62 using namespace ::com::sun::star::chart2
;
63 using ::com::sun::star::uno::Reference
;
64 using ::com::sun::star::uno::Sequence
;
69 void lcl_InsertMeanValueLine( const uno::Reference
< chart2::XDataSeries
> & xSeries
)
71 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
72 xSeries
, uno::UNO_QUERY
);
73 if( xRegCurveCnt
.is())
75 ::chart::RegressionCurveHelper::addMeanValueLine(
76 xRegCurveCnt
, uno::Reference
< beans::XPropertySet
>( xSeries
, uno::UNO_QUERY
));
80 } // anonymous namespace
85 void ChartController::executeDispatch_InsertAxes()
88 ActionDescriptionProvider::createDescription(
89 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_AXES
)),
94 InsertAxisOrGridDialogData aDialogInput
;
95 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram(getModel());
96 AxisHelper::getAxisOrGridExcistence( aDialogInput
.aExistenceList
, xDiagram
);
97 AxisHelper::getAxisOrGridPossibilities( aDialogInput
.aPossibilityList
, xDiagram
);
99 SolarMutexGuard aGuard
;
100 SchAxisDlg
aDlg(GetChartFrame(), aDialogInput
);
101 if (aDlg
.run() == RET_OK
)
103 // lock controllers till end of block
104 ControllerLockGuardUNO
aCLGuard( getModel() );
106 InsertAxisOrGridDialogData aDialogOutput
;
107 aDlg
.getResult(aDialogOutput
);
108 std::unique_ptr
< ReferenceSizeProvider
> pRefSizeProvider(
109 impl_createReferenceSizeProvider());
110 bool bChanged
= AxisHelper::changeVisibilityOfAxes( xDiagram
111 , aDialogInput
.aExistenceList
, aDialogOutput
.aExistenceList
, m_xCC
112 , pRefSizeProvider
.get() );
117 catch(const uno::RuntimeException
& e
)
119 SAL_WARN("chart2", "Exception caught. " << e
);
123 void ChartController::executeDispatch_InsertGrid()
125 UndoGuard
aUndoGuard(
126 ActionDescriptionProvider::createDescription(
127 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_GRIDS
)),
132 InsertAxisOrGridDialogData aDialogInput
;
133 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram(getModel());
134 AxisHelper::getAxisOrGridExcistence( aDialogInput
.aExistenceList
, xDiagram
, false );
135 AxisHelper::getAxisOrGridPossibilities( aDialogInput
.aPossibilityList
, xDiagram
, false );
137 SolarMutexGuard aGuard
;
138 SchGridDlg
aDlg(GetChartFrame(), aDialogInput
);//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY );
139 if (aDlg
.run() == RET_OK
)
141 // lock controllers till end of block
142 ControllerLockGuardUNO
aCLGuard( getModel() );
143 InsertAxisOrGridDialogData aDialogOutput
;
144 aDlg
.getResult( aDialogOutput
);
145 bool bChanged
= AxisHelper::changeVisibilityOfGrids( xDiagram
146 , aDialogInput
.aExistenceList
, aDialogOutput
.aExistenceList
);
151 catch(const uno::RuntimeException
& e
)
153 SAL_WARN("chart2", "Exception caught. " << e
);
157 void ChartController::executeDispatch_InsertTitles()
159 UndoGuard
aUndoGuard(
160 ActionDescriptionProvider::createDescription(
161 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_TITLES
)),
166 TitleDialogData aDialogInput
;
167 aDialogInput
.readFromModel( getModel() );
169 SolarMutexGuard aGuard
;
170 ScopedVclPtrInstance
< SchTitleDlg
> aDlg( GetChartWindow(), aDialogInput
);
171 if( aDlg
->Execute() == RET_OK
)
173 // lock controllers till end of block
174 ControllerLockGuardUNO
aCLGuard( getModel() );
175 TitleDialogData
aDialogOutput(impl_createReferenceSizeProvider());
176 aDlg
->getResult( aDialogOutput
);
177 bool bChanged
= aDialogOutput
.writeDifferenceToModel( getModel(), m_xCC
, &aDialogInput
);
182 catch(const uno::RuntimeException
& e
)
184 SAL_WARN("chart2", "Exception caught. " << e
);
188 void ChartController::executeDispatch_DeleteLegend()
190 UndoGuard
aUndoGuard(
191 ActionDescriptionProvider::createDescription(
192 ActionDescriptionProvider::ActionType::Delete
, SchResId( STR_OBJECT_LEGEND
)),
195 ChartModel
& rModel
= dynamic_cast<ChartModel
&>(*getModel().get());
196 LegendHelper::hideLegend(rModel
);
200 void ChartController::executeDispatch_InsertLegend()
202 UndoGuard
aUndoGuard(
203 ActionDescriptionProvider::createDescription(
204 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_LEGEND
)),
207 ChartModel
& rModel
= dynamic_cast<ChartModel
&>(*getModel().get());
208 Reference
< chart2::XLegend
> xLegend
= LegendHelper::showLegend(rModel
, m_xCC
);
212 void ChartController::executeDispatch_OpenLegendDialog()
214 UndoGuard
aUndoGuard(
215 ActionDescriptionProvider::createDescription(
216 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_LEGEND
)),
221 //prepare and open dialog
222 SolarMutexGuard aGuard
;
223 ScopedVclPtrInstance
< SchLegendDlg
> aDlg( GetChartWindow(), m_xCC
);
224 aDlg
->init( getModel() );
225 if( aDlg
->Execute() == RET_OK
)
227 // lock controllers till end of block
228 ControllerLockGuardUNO
aCLGuard( getModel() );
229 bool bChanged
= aDlg
->writeToModel( getModel() );
234 catch(const uno::RuntimeException
& e
)
236 SAL_WARN("chart2", "Exception caught. " << e
);
240 void ChartController::executeDispatch_InsertMenu_DataLabels()
242 UndoGuard
aUndoGuard(
243 ActionDescriptionProvider::createDescription(
244 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_DATALABELS
)),
247 //if a series is selected insert labels for that series only:
248 uno::Reference
< chart2::XDataSeries
> xSeries(
249 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel()), uno::UNO_QUERY
);
253 DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries
);
255 OUString
aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS
) + "=" );
256 OUString aObjectCID
= ObjectIdentifier::createClassifiedIdentifierForParticles(
257 ObjectIdentifier::getSeriesParticleFromCID(m_aSelection
.getSelectedCID()), aChildParticle
);
259 bool bSuccess
= ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID
, true );
267 wrapper::AllDataLabelItemConverter
aItemConverter(
269 m_pDrawModelWrapper
->GetItemPool(),
270 m_pDrawModelWrapper
->getSdrModel(),
271 uno::Reference
< lang::XMultiServiceFactory
>( getModel(), uno::UNO_QUERY
));
272 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
273 aItemConverter
.FillItemSet( aItemSet
);
275 //prepare and open dialog
276 SolarMutexGuard aGuard
;
278 //get number formatter
279 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( getModel(), uno::UNO_QUERY
);
280 NumberFormatterWrapper
aNumberFormatterWrapper( xNumberFormatsSupplier
);
281 SvNumberFormatter
* pNumberFormatter
= aNumberFormatterWrapper
.getSvNumberFormatter();
283 ScopedVclPtrInstance
< DataLabelsDialog
> aDlg( GetChartWindow(), aItemSet
, pNumberFormatter
);
285 if( aDlg
->Execute() == RET_OK
)
287 SfxItemSet aOutItemSet
= aItemConverter
.CreateEmptyItemSet();
288 aDlg
->FillItemSet( aOutItemSet
);
289 // lock controllers till end of block
290 ControllerLockGuardUNO
aCLGuard( getModel() );
291 bool bChanged
= aItemConverter
.ApplyItemSet( aOutItemSet
);//model should be changed now
296 catch(const uno::RuntimeException
& e
)
298 SAL_WARN("chart2", "Exception caught. " << e
);
302 void ChartController::executeDispatch_InsertMeanValue()
304 UndoGuard
aUndoGuard(
305 ActionDescriptionProvider::createDescription(
306 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_AVERAGE_LINE
)),
308 lcl_InsertMeanValueLine( ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(),
313 void ChartController::executeDispatch_InsertMenu_MeanValues()
315 UndoGuard
aUndoGuard(
316 ActionDescriptionProvider::createDescription(
317 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_AVERAGE_LINE
)),
320 uno::Reference
< chart2::XDataSeries
> xSeries(
321 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
324 //if a series is selected insert mean value only for that series:
325 lcl_InsertMeanValueLine( xSeries
);
329 std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeries(
330 DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() )));
332 for( const auto& xSrs
: aSeries
)
333 lcl_InsertMeanValueLine( xSrs
);
338 void ChartController::executeDispatch_InsertMenu_Trendlines()
340 OUString aCID
= m_aSelection
.getSelectedCID();
342 uno::Reference
< chart2::XDataSeries
> xSeries(
343 ObjectIdentifier::getDataSeriesForCID( aCID
, getModel() ), uno::UNO_QUERY
);
348 executeDispatch_InsertTrendline();
351 void ChartController::executeDispatch_InsertTrendline()
353 uno::Reference
< chart2::XRegressionCurveContainer
> xRegressionCurveContainer(
354 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel()), uno::UNO_QUERY
);
356 if( !xRegressionCurveContainer
.is() )
359 UndoLiveUpdateGuard
aUndoGuard(
360 ActionDescriptionProvider::createDescription(
361 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_CURVE
)),
364 uno::Reference
< chart2::XRegressionCurve
> xCurve
=
365 RegressionCurveHelper::addRegressionCurve(
366 SvxChartRegress::Linear
,
367 xRegressionCurveContainer
);
369 uno::Reference
< beans::XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
371 if( !xProperties
.is())
374 wrapper::RegressionCurveItemConverter
aItemConverter(
375 xProperties
, xRegressionCurveContainer
, m_pDrawModelWrapper
->getSdrModel().GetItemPool(),
376 m_pDrawModelWrapper
->getSdrModel(),
377 uno::Reference
< lang::XMultiServiceFactory
>( getModel(), uno::UNO_QUERY
));
380 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
381 aItemConverter
.FillItemSet( aItemSet
);
382 ObjectPropertiesDialogParameter aDialogParameter
= ObjectPropertiesDialogParameter(
383 ObjectIdentifier::createDataCurveCID(
384 ObjectIdentifier::getSeriesParticleFromCID( m_aSelection
.getSelectedCID()),
385 RegressionCurveHelper::getRegressionCurveIndex( xRegressionCurveContainer
, xCurve
), false ));
386 aDialogParameter
.init( getModel() );
387 ViewElementListProvider
aViewElementListProvider( m_pDrawModelWrapper
.get());
388 SolarMutexGuard aGuard
;
389 ScopedVclPtrInstance
<SchAttribTabDlg
> aDialog(
390 GetChartWindow(), &aItemSet
, &aDialogParameter
,
391 &aViewElementListProvider
,
392 uno::Reference
< util::XNumberFormatsSupplier
>(
393 getModel(), uno::UNO_QUERY
) );
395 // note: when a user pressed "OK" but didn't change any settings in the
396 // dialog, the SfxTabDialog returns "Cancel"
397 if( aDialog
->Execute() == RET_OK
|| aDialog
->DialogWasClosedWithOK())
399 const SfxItemSet
* pOutItemSet
= aDialog
->GetOutputItemSet();
402 ControllerLockGuardUNO
aCLGuard( getModel() );
403 aItemConverter
.ApplyItemSet( *pOutItemSet
);
409 void ChartController::executeDispatch_InsertErrorBars( bool bYError
)
411 ObjectType objType
= bYError
? OBJECTTYPE_DATA_ERRORS_Y
: OBJECTTYPE_DATA_ERRORS_X
;
413 //if a series is selected insert error bars for that series only:
414 uno::Reference
< chart2::XDataSeries
> xSeries(
415 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
419 UndoLiveUpdateGuard
aUndoGuard(
420 ActionDescriptionProvider::createDescription(
421 ActionDescriptionProvider::ActionType::Insert
,
422 SchResId( bYError
? STR_OBJECT_ERROR_BARS_Y
: STR_OBJECT_ERROR_BARS_X
)),
425 // add error bars with standard deviation
426 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
427 StatisticsHelper::addErrorBars( xSeries
,
428 css::chart::ErrorBarStyle::STANDARD_DEVIATION
,
431 // get an appropriate item converter
432 wrapper::ErrorBarItemConverter
aItemConverter(
433 getModel(), xErrorBarProp
, m_pDrawModelWrapper
->getSdrModel().GetItemPool(),
434 m_pDrawModelWrapper
->getSdrModel(),
435 uno::Reference
< lang::XMultiServiceFactory
>( getModel(), uno::UNO_QUERY
));
438 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
439 aItemSet
.Put(SfxBoolItem(SCHATTR_STAT_ERRORBAR_TYPE
,bYError
));
440 aItemConverter
.FillItemSet( aItemSet
);
441 ObjectPropertiesDialogParameter aDialogParameter
= ObjectPropertiesDialogParameter(
442 ObjectIdentifier::createClassifiedIdentifierWithParent(
443 objType
, OUString(), m_aSelection
.getSelectedCID()));
444 aDialogParameter
.init( getModel() );
445 ViewElementListProvider
aViewElementListProvider( m_pDrawModelWrapper
.get());
446 SolarMutexGuard aGuard
;
447 ScopedVclPtrInstance
<SchAttribTabDlg
> aDlg(
448 GetChartWindow(), &aItemSet
, &aDialogParameter
,
449 &aViewElementListProvider
,
450 uno::Reference
< util::XNumberFormatsSupplier
>(
451 getModel(), uno::UNO_QUERY
) );
452 aDlg
->SetAxisMinorStepWidthForErrorBarDecimals(
453 InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(),
454 m_xChartView
, m_aSelection
.getSelectedCID()));
456 // note: when a user pressed "OK" but didn't change any settings in the
457 // dialog, the SfxTabDialog returns "Cancel"
458 if( aDlg
->Execute() == RET_OK
|| aDlg
->DialogWasClosedWithOK())
460 const SfxItemSet
* pOutItemSet
= aDlg
->GetOutputItemSet();
463 ControllerLockGuardUNO
aCLGuard( getModel() );
464 aItemConverter
.ApplyItemSet( *pOutItemSet
);
471 //if no series is selected insert error bars for all series
472 UndoGuard
aUndoGuard(
473 ActionDescriptionProvider::createDescription(
474 ActionDescriptionProvider::ActionType::Insert
,
475 ObjectNameProvider::getName_ObjectForAllSeries( objType
) ),
480 wrapper::AllSeriesStatisticsConverter
aItemConverter(
481 getModel(), m_pDrawModelWrapper
->GetItemPool() );
482 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
483 aItemConverter
.FillItemSet( aItemSet
);
485 //prepare and open dialog
486 SolarMutexGuard aGuard
;
487 ScopedVclPtrInstance
<InsertErrorBarsDialog
> aDlg(
488 GetChartWindow(), aItemSet
,
489 uno::Reference
< chart2::XChartDocument
>( getModel(), uno::UNO_QUERY
),
490 bYError
? ErrorBarResources::ERROR_BAR_Y
: ErrorBarResources::ERROR_BAR_X
);
492 aDlg
->SetAxisMinorStepWidthForErrorBarDecimals(
493 InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView
, OUString() ) );
495 if( aDlg
->Execute() == RET_OK
)
497 SfxItemSet aOutItemSet
= aItemConverter
.CreateEmptyItemSet();
498 aDlg
->FillItemSet( aOutItemSet
);
500 // lock controllers till end of block
501 ControllerLockGuardUNO
aCLGuard( getModel() );
502 bool bChanged
= aItemConverter
.ApplyItemSet( aOutItemSet
);//model should be changed now
507 catch(const uno::RuntimeException
& e
)
509 SAL_WARN("chart2", "Exception caught. " << e
);
514 void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2
)
516 uno::Reference
< chart2::XRegressionCurve
> xRegCurve(
517 ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
518 if( !xRegCurve
.is() )
520 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
521 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
522 xRegCurve
.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt
) );
526 uno::Reference
< beans::XPropertySet
> xEqProp( xRegCurve
->getEquationProperties());
529 UndoGuard
aUndoGuard(
530 ActionDescriptionProvider::createDescription(
531 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_CURVE_EQUATION
)),
533 xEqProp
->setPropertyValue( "ShowEquation", uno::Any( true ));
534 xEqProp
->setPropertyValue( "XName", uno::Any( OUString("x") ));
535 xEqProp
->setPropertyValue( "YName", uno::Any( OUString("f(x)") ));
536 xEqProp
->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( bInsertR2
));
542 void ChartController::executeDispatch_InsertR2Value()
544 uno::Reference
< beans::XPropertySet
> xEqProp(
545 ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
548 UndoGuard
aUndoGuard(
549 ActionDescriptionProvider::createDescription(
550 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_CURVE_EQUATION
)),
552 xEqProp
->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( true ));
557 void ChartController::executeDispatch_DeleteR2Value()
559 uno::Reference
< beans::XPropertySet
> xEqProp(
560 ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
563 UndoGuard
aUndoGuard(
564 ActionDescriptionProvider::createDescription(
565 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_CURVE_EQUATION
)),
567 xEqProp
->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( false ));
572 void ChartController::executeDispatch_DeleteMeanValue()
574 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
575 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
576 if( xRegCurveCnt
.is())
578 UndoGuard
aUndoGuard(
579 ActionDescriptionProvider::createDescription(
580 ActionDescriptionProvider::ActionType::Delete
, SchResId( STR_OBJECT_AVERAGE_LINE
)),
582 RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt
);
587 void ChartController::executeDispatch_DeleteTrendline()
589 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
590 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
591 if( xRegCurveCnt
.is())
593 UndoGuard
aUndoGuard(
594 ActionDescriptionProvider::createDescription(
595 ActionDescriptionProvider::ActionType::Delete
, SchResId( STR_OBJECT_CURVE
)),
597 RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt
);
602 void ChartController::executeDispatch_DeleteTrendlineEquation()
604 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
605 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
606 if( xRegCurveCnt
.is())
608 UndoGuard
aUndoGuard(
609 ActionDescriptionProvider::createDescription(
610 ActionDescriptionProvider::ActionType::Delete
, SchResId( STR_OBJECT_CURVE_EQUATION
)),
612 RegressionCurveHelper::removeEquations( xRegCurveCnt
);
617 void ChartController::executeDispatch_DeleteErrorBars( bool bYError
)
619 uno::Reference
< chart2::XDataSeries
> xDataSeries(
620 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ));
621 if( xDataSeries
.is())
623 UndoGuard
aUndoGuard(
624 ActionDescriptionProvider::createDescription(
625 ActionDescriptionProvider::ActionType::Delete
, SchResId( STR_OBJECT_CURVE
)),
627 StatisticsHelper::removeErrorBars( xDataSeries
, bYError
);
632 void ChartController::executeDispatch_InsertDataLabels()
634 uno::Reference
< chart2::XDataSeries
> xSeries(
635 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
638 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert
,
639 SchResId( STR_OBJECT_DATALABELS
)),
641 DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries
);
646 void ChartController::executeDispatch_InsertDataLabel()
648 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert
,
649 SchResId( STR_OBJECT_LABEL
)),
651 DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ) );
655 void ChartController::executeDispatch_DeleteDataLabels()
657 uno::Reference
< chart2::XDataSeries
> xSeries(
658 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
661 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete
,
662 SchResId( STR_OBJECT_DATALABELS
)),
664 DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries
);
669 void ChartController::executeDispatch_DeleteDataLabel()
671 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete
,
672 SchResId( STR_OBJECT_LABEL
)),
674 DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ) );
678 void ChartController::executeDispatch_ResetAllDataPoints()
680 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format
,
681 SchResId( STR_OBJECT_DATAPOINTS
)),
683 uno::Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
685 xSeries
->resetAllDataPoints();
688 void ChartController::executeDispatch_ResetDataPoint()
690 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format
,
691 SchResId( STR_OBJECT_DATAPOINT
)),
693 uno::Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
696 sal_Int32 nPointIndex
= ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection
.getSelectedCID() );
697 xSeries
->resetDataPoint( nPointIndex
);
702 void ChartController::executeDispatch_InsertAxisTitle()
706 uno::Reference
< XTitle
> xTitle
;
708 UndoGuard
aUndoGuard(
709 ActionDescriptionProvider::createDescription(
710 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_TITLE
)),
713 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
714 sal_Int32 nDimensionIndex
= -1;
715 sal_Int32 nCooSysIndex
= -1;
716 sal_Int32 nAxisIndex
= -1;
717 AxisHelper::getIndicesForAxis( xAxis
, ChartModelHelper::findDiagram(getModel()), nCooSysIndex
, nDimensionIndex
, nAxisIndex
);
719 TitleHelper::eTitleType eTitleType
= TitleHelper::X_AXIS_TITLE
;
720 if( nDimensionIndex
==0 )
721 eTitleType
= nAxisIndex
==0 ? TitleHelper::X_AXIS_TITLE
: TitleHelper::SECONDARY_X_AXIS_TITLE
;
722 else if( nDimensionIndex
==1 )
723 eTitleType
= nAxisIndex
==0 ? TitleHelper::Y_AXIS_TITLE
: TitleHelper::SECONDARY_Y_AXIS_TITLE
;
725 eTitleType
= TitleHelper::Z_AXIS_TITLE
;
727 std::unique_ptr
< ReferenceSizeProvider
> apRefSizeProvider( impl_createReferenceSizeProvider());
728 xTitle
= TitleHelper::createTitle( eTitleType
, ObjectNameProvider::getTitleNameByType(eTitleType
), getModel(), m_xCC
, apRefSizeProvider
.get() );
732 catch(const uno::RuntimeException
& e
)
734 SAL_WARN("chart2", "Exception caught. " << e
);
738 void ChartController::executeDispatch_InsertAxis()
740 UndoGuard
aUndoGuard(
741 ActionDescriptionProvider::createDescription(
742 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_AXIS
)),
747 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
750 AxisHelper::makeAxisVisible( xAxis
);
754 catch(const uno::RuntimeException
& e
)
756 SAL_WARN("chart2", "Exception caught. " << e
);
760 void ChartController::executeDispatch_DeleteAxis()
762 UndoGuard
aUndoGuard(
763 ActionDescriptionProvider::createDescription(
764 ActionDescriptionProvider::ActionType::Delete
, SchResId( STR_OBJECT_AXIS
)),
769 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
772 AxisHelper::makeAxisInvisible( xAxis
);
776 catch(const uno::RuntimeException
& e
)
778 SAL_WARN("chart2", "Exception caught. " << e
);
782 void ChartController::executeDispatch_InsertMajorGrid()
784 UndoGuard
aUndoGuard(
785 ActionDescriptionProvider::createDescription(
786 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_GRID
)),
791 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
794 AxisHelper::makeGridVisible( xAxis
->getGridProperties() );
798 catch(const uno::RuntimeException
& e
)
800 SAL_WARN("chart2", "Exception caught. " << e
);
804 void ChartController::executeDispatch_DeleteMajorGrid()
806 UndoGuard
aUndoGuard(
807 ActionDescriptionProvider::createDescription(
808 ActionDescriptionProvider::ActionType::Delete
, SchResId( STR_OBJECT_GRID
)),
813 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
816 AxisHelper::makeGridInvisible( xAxis
->getGridProperties() );
820 catch(const uno::RuntimeException
& e
)
822 SAL_WARN("chart2", "Exception caught. " << e
);
826 void ChartController::executeDispatch_InsertMinorGrid()
828 UndoGuard
aUndoGuard(
829 ActionDescriptionProvider::createDescription(
830 ActionDescriptionProvider::ActionType::Insert
, SchResId( STR_OBJECT_GRID
)),
835 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
838 Sequence
< Reference
< beans::XPropertySet
> > aSubGrids( xAxis
->getSubGridProperties() );
839 for( sal_Int32 nN
=0; nN
<aSubGrids
.getLength(); nN
++)
840 AxisHelper::makeGridVisible( aSubGrids
[nN
] );
844 catch(const uno::RuntimeException
& e
)
846 SAL_WARN("chart2", "Exception caught. " << e
);
850 void ChartController::executeDispatch_DeleteMinorGrid()
852 UndoGuard
aUndoGuard(
853 ActionDescriptionProvider::createDescription(
854 ActionDescriptionProvider::ActionType::Delete
, SchResId(STR_OBJECT_GRID
)),
859 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
862 Sequence
< Reference
< beans::XPropertySet
> > aSubGrids( xAxis
->getSubGridProperties() );
863 for( sal_Int32 nN
=0; nN
<aSubGrids
.getLength(); nN
++)
864 AxisHelper::makeGridInvisible( aSubGrids
[nN
] );
868 catch(const uno::RuntimeException
& e
)
870 SAL_WARN("chart2", "Exception caught. " << e
);
876 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */