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 .
20 #include "ChartController.hxx"
22 #include "dlg_InsertAxis_Grid.hxx"
23 #include "dlg_InsertDataLabel.hxx"
24 #include "dlg_InsertLegend.hxx"
25 #include "dlg_InsertErrorBars.hxx"
26 #include "dlg_InsertTitle.hxx"
27 #include "dlg_ObjectProperties.hxx"
29 #include "ChartWindow.hxx"
30 #include "ChartModelHelper.hxx"
31 #include "AxisHelper.hxx"
32 #include "TitleHelper.hxx"
33 #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 <vcl/msgbox.hxx>
59 #include <rtl/ustrbuf.hxx>
60 #include <vcl/svapp.hxx>
61 #include <osl/mutex.hxx>
63 using namespace ::com::sun::star
;
64 using namespace ::com::sun::star::chart2
;
65 using ::com::sun::star::uno::Reference
;
66 using ::com::sun::star::uno::Sequence
;
70 struct lcl_InsertMeanValueLine
73 lcl_InsertMeanValueLine( const uno::Reference
< uno::XComponentContext
> & xContext
) :
74 m_xContext( xContext
)
77 void operator()( const uno::Reference
< chart2::XDataSeries
> & xSeries
)
79 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
80 xSeries
, uno::UNO_QUERY
);
81 if( xRegCurveCnt
.is())
83 ::chart::RegressionCurveHelper::addMeanValueLine(
84 xRegCurveCnt
, m_xContext
, uno::Reference
< beans::XPropertySet
>( xSeries
, uno::UNO_QUERY
));
89 uno::Reference
< uno::XComponentContext
> m_xContext
;
92 } // anonymous namespace
97 void ChartController::executeDispatch_InsertAxes()
100 ActionDescriptionProvider::createDescription(
101 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_AXES
)),
106 InsertAxisOrGridDialogData aDialogInput
;
107 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram(getModel());
108 AxisHelper::getAxisOrGridExcistence( aDialogInput
.aExistenceList
, xDiagram
, true );
109 AxisHelper::getAxisOrGridPossibilities( aDialogInput
.aPossibilityList
, xDiagram
, true );
111 SolarMutexGuard aGuard
;
112 ScopedVclPtrInstance
<SchAxisDlg
> aDlg( m_pChartWindow
, aDialogInput
);
113 if( aDlg
->Execute() == RET_OK
)
115 // lock controllers till end of block
116 ControllerLockGuardUNO
aCLGuard( getModel() );
118 InsertAxisOrGridDialogData aDialogOutput
;
119 aDlg
->getResult( aDialogOutput
);
120 boost::scoped_ptr
< ReferenceSizeProvider
> mpRefSizeProvider(
121 impl_createReferenceSizeProvider());
122 bool bChanged
= AxisHelper::changeVisibilityOfAxes( xDiagram
123 , aDialogInput
.aExistenceList
, aDialogOutput
.aExistenceList
, m_xCC
124 , mpRefSizeProvider
.get() );
129 catch(const uno::RuntimeException
& e
)
131 ASSERT_EXCEPTION( e
);
135 void ChartController::executeDispatch_InsertGrid()
137 UndoGuard
aUndoGuard(
138 ActionDescriptionProvider::createDescription(
139 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_GRIDS
)),
144 InsertAxisOrGridDialogData aDialogInput
;
145 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram(getModel());
146 AxisHelper::getAxisOrGridExcistence( aDialogInput
.aExistenceList
, xDiagram
, false );
147 AxisHelper::getAxisOrGridPossibilities( aDialogInput
.aPossibilityList
, xDiagram
, false );
149 SolarMutexGuard aGuard
;
150 ScopedVclPtrInstance
<SchGridDlg
> aDlg(m_pChartWindow
, aDialogInput
);//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY );
151 if( aDlg
->Execute() == RET_OK
)
153 // lock controllers till end of block
154 ControllerLockGuardUNO
aCLGuard( getModel() );
155 InsertAxisOrGridDialogData aDialogOutput
;
156 aDlg
->getResult( aDialogOutput
);
157 bool bChanged
= AxisHelper::changeVisibilityOfGrids( xDiagram
158 , aDialogInput
.aExistenceList
, aDialogOutput
.aExistenceList
, m_xCC
);
163 catch(const uno::RuntimeException
& e
)
165 ASSERT_EXCEPTION( e
);
169 void ChartController::executeDispatch_InsertTitles()
171 UndoGuard
aUndoGuard(
172 ActionDescriptionProvider::createDescription(
173 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_TITLES
)),
178 TitleDialogData aDialogInput
;
179 aDialogInput
.readFromModel( getModel() );
181 SolarMutexGuard aGuard
;
182 ScopedVclPtrInstance
< SchTitleDlg
> aDlg( m_pChartWindow
, aDialogInput
);
183 if( aDlg
->Execute() == RET_OK
)
185 // lock controllers till end of block
186 ControllerLockGuardUNO
aCLGuard( getModel() );
187 TitleDialogData
aDialogOutput(impl_createReferenceSizeProvider());
188 aDlg
->getResult( aDialogOutput
);
189 bool bChanged
= aDialogOutput
.writeDifferenceToModel( getModel(), m_xCC
, &aDialogInput
);
194 catch(const uno::RuntimeException
& e
)
196 ASSERT_EXCEPTION( e
);
200 void ChartController::executeDispatch_DeleteLegend()
202 UndoGuard
aUndoGuard(
203 ActionDescriptionProvider::createDescription(
204 ActionDescriptionProvider::DELETE
, SCH_RESSTR( STR_OBJECT_LEGEND
)),
207 ChartModel
& rModel
= dynamic_cast<ChartModel
&>(*getModel().get());
208 LegendHelper::hideLegend(rModel
);
212 void ChartController::executeDispatch_InsertLegend()
214 UndoGuard
aUndoGuard(
215 ActionDescriptionProvider::createDescription(
216 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_LEGEND
)),
219 ChartModel
& rModel
= dynamic_cast<ChartModel
&>(*getModel().get());
220 Reference
< chart2::XLegend
> xLegend
= LegendHelper::showLegend(rModel
, m_xCC
);
224 void ChartController::executeDispatch_OpenLegendDialog()
226 UndoGuard
aUndoGuard(
227 ActionDescriptionProvider::createDescription(
228 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_LEGEND
)),
233 //prepare and open dialog
234 SolarMutexGuard aGuard
;
235 ScopedVclPtrInstance
< SchLegendDlg
> aDlg( m_pChartWindow
, m_xCC
);
236 aDlg
->init( getModel() );
237 if( aDlg
->Execute() == RET_OK
)
239 // lock controllers till end of block
240 ControllerLockGuardUNO
aCLGuard( getModel() );
241 bool bChanged
= aDlg
->writeToModel( getModel() );
246 catch(const uno::RuntimeException
& e
)
248 ASSERT_EXCEPTION( e
);
252 void ChartController::executeDispatch_InsertMenu_DataLabels()
254 UndoGuard
aUndoGuard(
255 ActionDescriptionProvider::createDescription(
256 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_DATALABELS
)),
259 //if a series is selected insert labels for that series only:
260 uno::Reference
< chart2::XDataSeries
> xSeries(
261 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel()), uno::UNO_QUERY
);
265 DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries
);
267 OUString
aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS
) + "=" );
268 OUString aObjectCID
= ObjectIdentifier::createClassifiedIdentifierForParticles(
269 ObjectIdentifier::getSeriesParticleFromCID(m_aSelection
.getSelectedCID()), aChildParticle
);
271 bool bSuccess
= ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID
, true );
279 wrapper::AllDataLabelItemConverter
aItemConverter(
281 m_pDrawModelWrapper
->GetItemPool(),
282 m_pDrawModelWrapper
->getSdrModel(),
283 uno::Reference
< lang::XMultiServiceFactory
>( getModel(), uno::UNO_QUERY
));
284 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
285 aItemConverter
.FillItemSet( aItemSet
);
287 //prepare and open dialog
288 SolarMutexGuard aGuard
;
290 //get number formatter
291 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( getModel(), uno::UNO_QUERY
);
292 NumberFormatterWrapper
aNumberFormatterWrapper( xNumberFormatsSupplier
);
293 SvNumberFormatter
* pNumberFormatter
= aNumberFormatterWrapper
.getSvNumberFormatter();
295 ScopedVclPtrInstance
< DataLabelsDialog
> aDlg( m_pChartWindow
, aItemSet
, pNumberFormatter
);
297 if( aDlg
->Execute() == RET_OK
)
299 SfxItemSet aOutItemSet
= aItemConverter
.CreateEmptyItemSet();
300 aDlg
->FillItemSet( aOutItemSet
);
301 // lock controllers till end of block
302 ControllerLockGuardUNO
aCLGuard( getModel() );
303 bool bChanged
= aItemConverter
.ApplyItemSet( aOutItemSet
);//model should be changed now
308 catch(const uno::RuntimeException
& e
)
310 ASSERT_EXCEPTION( e
);
314 void ChartController::executeDispatch_InsertMeanValue()
316 UndoGuard
aUndoGuard(
317 ActionDescriptionProvider::createDescription(
318 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_AVERAGE_LINE
)),
320 lcl_InsertMeanValueLine( m_xCC
).operator()(
321 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ));
325 void ChartController::executeDispatch_InsertMenu_MeanValues()
327 UndoGuard
aUndoGuard(
328 ActionDescriptionProvider::createDescription(
329 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_AVERAGE_LINE
)),
332 uno::Reference
< chart2::XDataSeries
> xSeries(
333 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
336 //if a series is selected insert mean value only for that series:
337 lcl_InsertMeanValueLine( m_xCC
).operator()(xSeries
);
341 ::std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeries(
342 DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() )));
343 ::std::for_each( aSeries
.begin(), aSeries
.end(), lcl_InsertMeanValueLine( m_xCC
));
348 void ChartController::executeDispatch_InsertMenu_Trendlines()
350 OUString aCID
= m_aSelection
.getSelectedCID();
352 uno::Reference
< chart2::XDataSeries
> xSeries(
353 ObjectIdentifier::getDataSeriesForCID( aCID
, getModel() ), uno::UNO_QUERY
);
358 executeDispatch_InsertTrendline();
361 void ChartController::executeDispatch_InsertTrendline()
363 uno::Reference
< chart2::XRegressionCurveContainer
> xRegressionCurveContainer(
364 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel()), uno::UNO_QUERY
);
366 if( !xRegressionCurveContainer
.is() )
369 UndoLiveUpdateGuard
aUndoGuard(
370 ActionDescriptionProvider::createDescription(
371 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_CURVE
)),
374 uno::Reference
< chart2::XRegressionCurve
> xCurve
=
375 RegressionCurveHelper::addRegressionCurve(
377 xRegressionCurveContainer
,
380 uno::Reference
< beans::XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
382 if( !xProperties
.is())
385 wrapper::RegressionCurveItemConverter
aItemConverter(
386 xProperties
, xRegressionCurveContainer
, m_pDrawModelWrapper
->getSdrModel().GetItemPool(),
387 m_pDrawModelWrapper
->getSdrModel(),
388 uno::Reference
< lang::XMultiServiceFactory
>( getModel(), uno::UNO_QUERY
));
391 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
392 aItemConverter
.FillItemSet( aItemSet
);
393 ObjectPropertiesDialogParameter aDialogParameter
= ObjectPropertiesDialogParameter(
394 ObjectIdentifier::createDataCurveCID(
395 ObjectIdentifier::getSeriesParticleFromCID( m_aSelection
.getSelectedCID()),
396 RegressionCurveHelper::getRegressionCurveIndex( xRegressionCurveContainer
, xCurve
), false ));
397 aDialogParameter
.init( getModel() );
398 ViewElementListProvider
aViewElementListProvider( m_pDrawModelWrapper
.get());
399 SolarMutexGuard aGuard
;
400 ScopedVclPtrInstance
<SchAttribTabDlg
> aDialog(
401 m_pChartWindow
, &aItemSet
, &aDialogParameter
,
402 &aViewElementListProvider
,
403 uno::Reference
< util::XNumberFormatsSupplier
>(
404 getModel(), uno::UNO_QUERY
) );
406 // note: when a user pressed "OK" but didn't change any settings in the
407 // dialog, the SfxTabDialog returns "Cancel"
408 if( aDialog
->Execute() == RET_OK
|| aDialog
->DialogWasClosedWithOK())
410 const SfxItemSet
* pOutItemSet
= aDialog
->GetOutputItemSet();
413 ControllerLockGuardUNO
aCLGuard( getModel() );
414 aItemConverter
.ApplyItemSet( *pOutItemSet
);
420 void ChartController::executeDispatch_InsertErrorBars( bool bYError
)
422 ObjectType objType
= bYError
? OBJECTTYPE_DATA_ERRORS_Y
: OBJECTTYPE_DATA_ERRORS_X
;
424 //if a series is selected insert error bars for that series only:
425 uno::Reference
< chart2::XDataSeries
> xSeries(
426 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
430 UndoLiveUpdateGuard
aUndoGuard(
431 ActionDescriptionProvider::createDescription(
432 ActionDescriptionProvider::INSERT
,
433 SCH_RESSTR( bYError
? STR_OBJECT_ERROR_BARS_Y
: STR_OBJECT_ERROR_BARS_X
)),
436 // add error bars with standard deviation
437 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
438 StatisticsHelper::addErrorBars( xSeries
, m_xCC
,
439 ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION
,
442 // get an appropriate item converter
443 wrapper::ErrorBarItemConverter
aItemConverter(
444 getModel(), xErrorBarProp
, m_pDrawModelWrapper
->getSdrModel().GetItemPool(),
445 m_pDrawModelWrapper
->getSdrModel(),
446 uno::Reference
< lang::XMultiServiceFactory
>( getModel(), uno::UNO_QUERY
));
449 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
450 aItemSet
.Put(SfxBoolItem(SCHATTR_STAT_ERRORBAR_TYPE
,bYError
));
451 aItemConverter
.FillItemSet( aItemSet
);
452 ObjectPropertiesDialogParameter aDialogParameter
= ObjectPropertiesDialogParameter(
453 ObjectIdentifier::createClassifiedIdentifierWithParent(
454 objType
, OUString(), m_aSelection
.getSelectedCID()));
455 aDialogParameter
.init( getModel() );
456 ViewElementListProvider
aViewElementListProvider( m_pDrawModelWrapper
.get());
457 SolarMutexGuard aGuard
;
458 ScopedVclPtrInstance
<SchAttribTabDlg
> aDlg(
459 m_pChartWindow
, &aItemSet
, &aDialogParameter
,
460 &aViewElementListProvider
,
461 uno::Reference
< util::XNumberFormatsSupplier
>(
462 getModel(), uno::UNO_QUERY
) );
463 aDlg
->SetAxisMinorStepWidthForErrorBarDecimals(
464 InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(),
465 m_xChartView
, m_aSelection
.getSelectedCID()));
467 // note: when a user pressed "OK" but didn't change any settings in the
468 // dialog, the SfxTabDialog returns "Cancel"
469 if( aDlg
->Execute() == RET_OK
|| aDlg
->DialogWasClosedWithOK())
471 const SfxItemSet
* pOutItemSet
= aDlg
->GetOutputItemSet();
474 ControllerLockGuardUNO
aCLGuard( getModel() );
475 aItemConverter
.ApplyItemSet( *pOutItemSet
);
482 //if no series is selected insert error bars for all series
483 UndoGuard
aUndoGuard(
484 ActionDescriptionProvider::createDescription(
485 ActionDescriptionProvider::INSERT
,
486 ObjectNameProvider::getName_ObjectForAllSeries( objType
) ),
491 wrapper::AllSeriesStatisticsConverter
aItemConverter(
492 getModel(), m_pDrawModelWrapper
->GetItemPool() );
493 SfxItemSet aItemSet
= aItemConverter
.CreateEmptyItemSet();
494 aItemConverter
.FillItemSet( aItemSet
);
496 //prepare and open dialog
497 SolarMutexGuard aGuard
;
498 ScopedVclPtrInstance
<InsertErrorBarsDialog
> aDlg(
499 m_pChartWindow
, aItemSet
,
500 uno::Reference
< chart2::XChartDocument
>( getModel(), uno::UNO_QUERY
),
501 bYError
? ErrorBarResources::ERROR_BAR_Y
: ErrorBarResources::ERROR_BAR_X
);
503 aDlg
->SetAxisMinorStepWidthForErrorBarDecimals(
504 InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView
, OUString() ) );
506 if( aDlg
->Execute() == RET_OK
)
508 SfxItemSet aOutItemSet
= aItemConverter
.CreateEmptyItemSet();
509 aDlg
->FillItemSet( aOutItemSet
);
511 // lock controllers till end of block
512 ControllerLockGuardUNO
aCLGuard( getModel() );
513 bool bChanged
= aItemConverter
.ApplyItemSet( aOutItemSet
);//model should be changed now
518 catch(const uno::RuntimeException
& e
)
520 ASSERT_EXCEPTION( e
);
525 void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2
)
527 uno::Reference
< chart2::XRegressionCurve
> xRegCurve(
528 ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
529 if( !xRegCurve
.is() )
531 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
532 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
533 xRegCurve
.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt
) );
537 uno::Reference
< beans::XPropertySet
> xEqProp( xRegCurve
->getEquationProperties());
540 // using assignment for broken gcc 3.3
541 UndoGuard aUndoGuard
= UndoGuard(
542 ActionDescriptionProvider::createDescription(
543 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_CURVE_EQUATION
)),
545 xEqProp
->setPropertyValue( "ShowEquation", uno::makeAny( true ));
546 xEqProp
->setPropertyValue( "ShowCorrelationCoefficient", uno::makeAny( bInsertR2
));
552 void ChartController::executeDispatch_InsertR2Value()
554 uno::Reference
< beans::XPropertySet
> xEqProp(
555 ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
558 UndoGuard aUndoGuard
= UndoGuard(
559 ActionDescriptionProvider::createDescription(
560 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_CURVE_EQUATION
)),
562 xEqProp
->setPropertyValue( "ShowCorrelationCoefficient", uno::makeAny( true ));
567 void ChartController::executeDispatch_DeleteR2Value()
569 uno::Reference
< beans::XPropertySet
> xEqProp(
570 ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
573 UndoGuard aUndoGuard
= UndoGuard(
574 ActionDescriptionProvider::createDescription(
575 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_CURVE_EQUATION
)),
577 xEqProp
->setPropertyValue( "ShowCorrelationCoefficient", uno::makeAny( false ));
582 void ChartController::executeDispatch_DeleteMeanValue()
584 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
585 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
586 if( xRegCurveCnt
.is())
588 UndoGuard
aUndoGuard(
589 ActionDescriptionProvider::createDescription(
590 ActionDescriptionProvider::DELETE
, SCH_RESSTR( STR_OBJECT_AVERAGE_LINE
)),
592 RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt
);
597 void ChartController::executeDispatch_DeleteTrendline()
599 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
600 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
601 if( xRegCurveCnt
.is())
603 UndoGuard
aUndoGuard(
604 ActionDescriptionProvider::createDescription(
605 ActionDescriptionProvider::DELETE
, SCH_RESSTR( STR_OBJECT_CURVE
)),
607 RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt
);
612 void ChartController::executeDispatch_DeleteTrendlineEquation()
614 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCurveCnt(
615 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
616 if( xRegCurveCnt
.is())
618 UndoGuard
aUndoGuard(
619 ActionDescriptionProvider::createDescription(
620 ActionDescriptionProvider::DELETE
, SCH_RESSTR( STR_OBJECT_CURVE_EQUATION
)),
622 RegressionCurveHelper::removeEquations( xRegCurveCnt
);
627 void ChartController::executeDispatch_DeleteErrorBars( bool bYError
)
629 uno::Reference
< chart2::XDataSeries
> xDataSeries(
630 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ));
631 if( xDataSeries
.is())
633 UndoGuard
aUndoGuard(
634 ActionDescriptionProvider::createDescription(
635 ActionDescriptionProvider::DELETE
, SCH_RESSTR( STR_OBJECT_CURVE
)),
637 StatisticsHelper::removeErrorBars( xDataSeries
, bYError
);
642 void ChartController::executeDispatch_InsertDataLabels()
644 uno::Reference
< chart2::XDataSeries
> xSeries(
645 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
648 UndoGuard aUndoGuard
= UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT
,
649 SCH_RESSTR( STR_OBJECT_DATALABELS
)),
651 DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries
);
656 void ChartController::executeDispatch_InsertDataLabel()
658 UndoGuard aUndoGuard
= UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT
,
659 SCH_RESSTR( STR_OBJECT_LABEL
)),
661 DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ) );
665 void ChartController::executeDispatch_DeleteDataLabels()
667 uno::Reference
< chart2::XDataSeries
> xSeries(
668 ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
671 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE
,
672 SCH_RESSTR( STR_OBJECT_DATALABELS
)),
674 DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries
);
679 void ChartController::executeDispatch_DeleteDataLabel()
681 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE
,
682 SCH_RESSTR( STR_OBJECT_LABEL
)),
684 DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection
.getSelectedCID(), getModel() ) );
688 void ChartController::executeDispatch_ResetAllDataPoints()
690 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT
,
691 SCH_RESSTR( STR_OBJECT_DATAPOINTS
)),
693 uno::Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
695 xSeries
->resetAllDataPoints();
698 void ChartController::executeDispatch_ResetDataPoint()
700 UndoGuard
aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT
,
701 SCH_RESSTR( STR_OBJECT_DATAPOINT
)),
703 uno::Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection
.getSelectedCID(), getModel() ), uno::UNO_QUERY
);
706 sal_Int32 nPointIndex
= ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection
.getSelectedCID() );
707 xSeries
->resetDataPoint( nPointIndex
);
712 void ChartController::executeDispatch_InsertAxisTitle()
716 uno::Reference
< XTitle
> xTitle
;
718 UndoGuard
aUndoGuard(
719 ActionDescriptionProvider::createDescription(
720 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_TITLE
)),
723 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
724 sal_Int32 nDimensionIndex
= -1;
725 sal_Int32 nCooSysIndex
= -1;
726 sal_Int32 nAxisIndex
= -1;
727 AxisHelper::getIndicesForAxis( xAxis
, ChartModelHelper::findDiagram(getModel()), nCooSysIndex
, nDimensionIndex
, nAxisIndex
);
729 TitleHelper::eTitleType eTitleType
= TitleHelper::X_AXIS_TITLE
;
730 if( nDimensionIndex
==0 )
731 eTitleType
= nAxisIndex
==0 ? TitleHelper::X_AXIS_TITLE
: TitleHelper::SECONDARY_X_AXIS_TITLE
;
732 else if( nDimensionIndex
==1 )
733 eTitleType
= nAxisIndex
==0 ? TitleHelper::Y_AXIS_TITLE
: TitleHelper::SECONDARY_Y_AXIS_TITLE
;
735 eTitleType
= TitleHelper::Z_AXIS_TITLE
;
737 boost::scoped_ptr
< ReferenceSizeProvider
> apRefSizeProvider( impl_createReferenceSizeProvider());
738 xTitle
= TitleHelper::createTitle( eTitleType
, ObjectNameProvider::getTitleNameByType(eTitleType
), getModel(), m_xCC
, apRefSizeProvider
.get() );
742 catch(const uno::RuntimeException
& e
)
744 ASSERT_EXCEPTION( e
);
748 void ChartController::executeDispatch_InsertAxis()
750 UndoGuard
aUndoGuard(
751 ActionDescriptionProvider::createDescription(
752 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_AXIS
)),
757 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
760 AxisHelper::makeAxisVisible( xAxis
);
764 catch(const uno::RuntimeException
& e
)
766 ASSERT_EXCEPTION( e
);
770 void ChartController::executeDispatch_DeleteAxis()
772 UndoGuard
aUndoGuard(
773 ActionDescriptionProvider::createDescription(
774 ActionDescriptionProvider::DELETE
, SCH_RESSTR( STR_OBJECT_AXIS
)),
779 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
782 AxisHelper::makeAxisInvisible( xAxis
);
786 catch(const uno::RuntimeException
& e
)
788 ASSERT_EXCEPTION( e
);
792 void ChartController::executeDispatch_InsertMajorGrid()
794 UndoGuard
aUndoGuard(
795 ActionDescriptionProvider::createDescription(
796 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_GRID
)),
801 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
804 AxisHelper::makeGridVisible( xAxis
->getGridProperties() );
808 catch(const uno::RuntimeException
& e
)
810 ASSERT_EXCEPTION( e
);
814 void ChartController::executeDispatch_DeleteMajorGrid()
816 UndoGuard
aUndoGuard(
817 ActionDescriptionProvider::createDescription(
818 ActionDescriptionProvider::DELETE
, SCH_RESSTR( STR_OBJECT_GRID
)),
823 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
826 AxisHelper::makeGridInvisible( xAxis
->getGridProperties() );
830 catch(const uno::RuntimeException
& e
)
832 ASSERT_EXCEPTION( e
);
836 void ChartController::executeDispatch_InsertMinorGrid()
838 UndoGuard
aUndoGuard(
839 ActionDescriptionProvider::createDescription(
840 ActionDescriptionProvider::INSERT
, SCH_RESSTR( STR_OBJECT_GRID
)),
845 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
848 Sequence
< Reference
< beans::XPropertySet
> > aSubGrids( xAxis
->getSubGridProperties() );
849 for( sal_Int32 nN
=0; nN
<aSubGrids
.getLength(); nN
++)
850 AxisHelper::makeGridVisible( aSubGrids
[nN
] );
854 catch(const uno::RuntimeException
& e
)
856 ASSERT_EXCEPTION( e
);
860 void ChartController::executeDispatch_DeleteMinorGrid()
862 UndoGuard
aUndoGuard(
863 ActionDescriptionProvider::createDescription(
864 ActionDescriptionProvider::DELETE
, SCH_RESSTR(STR_OBJECT_GRID
)),
869 Reference
< XAxis
> xAxis
= ObjectIdentifier::getAxisForCID( m_aSelection
.getSelectedCID(), getModel() );
872 Sequence
< Reference
< beans::XPropertySet
> > aSubGrids( xAxis
->getSubGridProperties() );
873 for( sal_Int32 nN
=0; nN
<aSubGrids
.getLength(); nN
++)
874 AxisHelper::makeGridInvisible( aSubGrids
[nN
] );
878 catch(const uno::RuntimeException
& e
)
880 ASSERT_EXCEPTION( e
);
886 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */