summaryrefslogtreecommitdiffstats
path: root/chart2/source/controller/main/ChartController_Insert.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/main/ChartController_Insert.cxx')
-rw-r--r--chart2/source/controller/main/ChartController_Insert.cxx423
1 files changed, 267 insertions, 156 deletions
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx
index b14a788f2140..b3455ad49e04 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -25,14 +25,15 @@
#include <dlg_InsertLegend.hxx>
#include <dlg_InsertErrorBars.hxx>
#include <dlg_InsertTitle.hxx>
+#include <dlg_InsertDataTable.hxx>
#include <dlg_ObjectProperties.hxx>
-#include <ChartModel.hxx>
-#include <ChartModelHelper.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <TitleHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <DataSeries.hxx>
#include <Diagram.hxx>
+#include <GridProperties.hxx>
#include <chartview/DrawModelWrapper.hxx>
#include <chartview/ChartSfxItemIds.hxx>
#include <NumberFormatterWrapper.hxx>
@@ -50,15 +51,17 @@
#include <ErrorBarItemConverter.hxx>
#include <DataSeriesHelper.hxx>
#include <ObjectNameProvider.hxx>
+#include <Legend.hxx>
#include <LegendHelper.hxx>
+#include <DataTable.hxx>
+#include <RegressionCurveModel.hxx>
#include <com/sun/star/chart2/XRegressionCurve.hpp>
-#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <svx/ActionDescriptionProvider.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/svapp.hxx>
using namespace ::com::sun::star;
@@ -69,14 +72,12 @@ using ::com::sun::star::uno::Sequence;
namespace
{
-void lcl_InsertMeanValueLine( const uno::Reference< chart2::XDataSeries > & xSeries )
+void lcl_InsertMeanValueLine( const rtl::Reference< ::chart::DataSeries > & xSeries )
{
- uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
- xSeries, uno::UNO_QUERY );
- if( xRegCurveCnt.is())
+ if( xSeries.is())
{
::chart::RegressionCurveHelper::addMeanValueLine(
- xRegCurveCnt, uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
+ xSeries, xSeries);
}
}
@@ -87,35 +88,36 @@ namespace chart
void ChartController::executeDispatch_InsertAxes()
{
- UndoGuard aUndoGuard(
+ auto xUndoGuard = std::make_shared<UndoGuard>(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_AXES )),
m_xUndoManager );
try
{
- InsertAxisOrGridDialogData aDialogInput;
+ auto aDialogInput = std::make_shared<InsertAxisOrGridDialogData>();
rtl::Reference< Diagram > xDiagram = getFirstDiagram();
- AxisHelper::getAxisOrGridExistence( aDialogInput.aExistenceList, xDiagram );
- AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram );
+ AxisHelper::getAxisOrGridExistence( aDialogInput->aExistenceList, xDiagram );
+ AxisHelper::getAxisOrGridPossibilities( aDialogInput->aPossibilityList, xDiagram );
SolarMutexGuard aGuard;
- SchAxisDlg aDlg(GetChartFrame(), aDialogInput);
- if (aDlg.run() == RET_OK)
- {
- // lock controllers till end of block
- ControllerLockGuardUNO aCLGuard( getChartModel() );
+ auto aDlg = std::make_shared<SchAxisDlg>(GetChartFrame(), *aDialogInput);
+ weld::DialogController::runAsync(aDlg, [this, aDlg, aDialogInput, xUndoGuard=std::move(xUndoGuard)](int nResult) {
+ if ( nResult == RET_OK )
+ {
+ // lock controllers till end of block
+ ControllerLockGuardUNO aCLGuard( getChartModel() );
- InsertAxisOrGridDialogData aDialogOutput;
- aDlg.getResult(aDialogOutput);
- std::unique_ptr< ReferenceSizeProvider > pRefSizeProvider(
- impl_createReferenceSizeProvider());
- bool bChanged = AxisHelper::changeVisibilityOfAxes( xDiagram
- , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC
- , pRefSizeProvider.get() );
- if( bChanged )
- aUndoGuard.commit();
- }
+ InsertAxisOrGridDialogData aDialogOutput;
+ aDlg->getResult(aDialogOutput);
+ ReferenceSizeProvider aRefSizeProvider(impl_createReferenceSizeProvider());
+ bool bChanged = AxisHelper::changeVisibilityOfAxes( getFirstDiagram()
+ , aDialogInput->aExistenceList, aDialogOutput.aExistenceList, m_xCC
+ , &aRefSizeProvider );
+ if( bChanged )
+ xUndoGuard->commit();
+ }
+ });
}
catch(const uno::RuntimeException&)
{
@@ -157,30 +159,145 @@ void ChartController::executeDispatch_InsertGrid()
}
}
+void ChartController::executeDispatch_OpenInsertDataTableDialog()
+{
+ SolarMutexGuard aGuard;
+
+ auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Insert, SchResId(STR_DATA_TABLE));
+ UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager);
+
+ rtl::Reference<Diagram> xDiagram = getFirstDiagram();
+
+ InsertDataTableDialog aDialog(GetChartFrame());
+ {
+ // init values
+ DataTableDialogData aData;
+ auto xDataTable = xDiagram->getDataTable();
+ aData.mbShow = xDataTable.is();
+ if (xDataTable.is())
+ {
+ uno::Reference<beans::XPropertySet> xProperties(xDataTable, uno::UNO_QUERY);
+
+ uno::Any aAny = xProperties->getPropertyValue("HBorder");
+ if (aAny.has<bool>())
+ aData.mbHorizontalBorders = aAny.get<bool>();
+
+ aAny = xProperties->getPropertyValue("VBorder");
+ if (aAny.has<bool>())
+ aData.mbVerticalBorders = aAny.get<bool>();
+
+ aAny = xProperties->getPropertyValue("Outline");
+ if (aAny.has<bool>())
+ aData.mbOutline = aAny.get<bool>();
+
+ aAny = xProperties->getPropertyValue("Keys");
+ if (aAny.has<bool>())
+ aData.mbKeys = aAny.get<bool>();
+ }
+ aDialog.init(aData);
+ }
+
+ // show the dialog
+ if (aDialog.run() == RET_OK)
+ {
+ bool bChanged = false;
+
+ auto& rDialogData = aDialog.getDataTableDialogData();
+ auto xDataTable = xDiagram->getDataTable();
+ if (!rDialogData.mbShow && xDataTable.is())
+ {
+ xDiagram->setDataTable(uno::Reference<chart2::XDataTable>());
+ bChanged = true;
+ }
+ else if (rDialogData.mbShow && !xDataTable.is())
+ {
+ uno::Reference<chart2::XDataTable> xNewDataTable(new DataTable);
+ if (xNewDataTable.is())
+ {
+ xDiagram->setDataTable(xNewDataTable);
+ bChanged = true;
+ }
+ }
+
+ // Set the properties
+ xDataTable = xDiagram->getDataTable();
+ if (rDialogData.mbShow && xDataTable.is())
+ {
+ uno::Reference<beans::XPropertySet> xProperties(xDataTable, uno::UNO_QUERY);
+ xProperties->setPropertyValue("HBorder" , uno::Any(rDialogData.mbHorizontalBorders));
+ xProperties->setPropertyValue("VBorder" , uno::Any(rDialogData.mbVerticalBorders));
+ xProperties->setPropertyValue("Outline" , uno::Any(rDialogData.mbOutline));
+ xProperties->setPropertyValue("Keys" , uno::Any(rDialogData.mbKeys));
+ bChanged = true;
+ }
+
+ if (bChanged)
+ aUndoGuard.commit();
+ }
+}
+
+/** Create and insert a data table to the chart */
+void ChartController::executeDispatch_InsertDataTable()
+{
+ auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Insert, SchResId(STR_DATA_TABLE));
+ UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager);
+
+
+ rtl::Reference<Diagram> xDiagram = getFirstDiagram();
+ auto xDataTable = xDiagram->getDataTable();
+ if (!xDataTable.is())
+ {
+ uno::Reference<chart2::XDataTable> xNewDataTable(new DataTable);
+ if (xNewDataTable.is())
+ {
+ xDiagram->setDataTable(xNewDataTable);
+ aUndoGuard.commit();
+ }
+ }
+}
+
+/** Delete a data table from the chart */
+void ChartController::executeDispatch_DeleteDataTable()
+{
+ auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Delete, SchResId(STR_DATA_TABLE));
+ UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager);
+
+ rtl::Reference<Diagram> xDiagram = getFirstDiagram();
+ auto xDataTable = xDiagram->getDataTable();
+ if (xDataTable.is())
+ {
+ // insert a empty data table reference
+ xDiagram->setDataTable(uno::Reference<chart2::XDataTable>());
+ aUndoGuard.commit();
+ }
+}
+
void ChartController::executeDispatch_InsertTitles()
{
- UndoGuard aUndoGuard(
+ auto xUndoGuard = std::make_shared<UndoGuard>(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_TITLES )),
m_xUndoManager );
try
{
- TitleDialogData aDialogInput;
- aDialogInput.readFromModel( getChartModel() );
+ auto aDialogInput = std::make_shared<TitleDialogData>();
+ aDialogInput->readFromModel( getChartModel() );
SolarMutexGuard aGuard;
- SchTitleDlg aDlg(GetChartFrame(), aDialogInput);
- if (aDlg.run() == RET_OK)
- {
- // lock controllers till end of block
- ControllerLockGuardUNO aCLGuard( getChartModel() );
- TitleDialogData aDialogOutput(impl_createReferenceSizeProvider());
- aDlg.getResult(aDialogOutput);
- bool bChanged = aDialogOutput.writeDifferenceToModel( getChartModel(), m_xCC, &aDialogInput );
- if( bChanged )
- aUndoGuard.commit();
- }
+ auto aDlg = std::make_shared<SchTitleDlg>(GetChartFrame(), *aDialogInput);
+ weld::DialogController::runAsync(aDlg, [this, aDlg, aDialogInput, xUndoGuard=std::move(xUndoGuard)](int nResult){
+ if ( nResult == RET_OK )
+ {
+ // lock controllers till end of block
+ ControllerLockGuardUNO aCLGuard( getChartModel() );
+ TitleDialogData aDialogOutput( impl_createReferenceSizeProvider() );
+ aDlg->getResult( aDialogOutput );
+ bool bChanged = aDialogOutput.writeDifferenceToModel( getChartModel(), m_xCC, aDialogInput.get() );
+ if( bChanged )
+ xUndoGuard->commit();
+ }
+ });
}
catch(const uno::RuntimeException&)
{
@@ -195,8 +312,7 @@ void ChartController::executeDispatch_DeleteLegend()
ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_LEGEND )),
m_xUndoManager );
- ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel());
- LegendHelper::hideLegend(rModel);
+ LegendHelper::hideLegend(*getChartModel());
aUndoGuard.commit();
}
@@ -207,8 +323,7 @@ void ChartController::executeDispatch_InsertLegend()
ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_LEGEND )),
m_xUndoManager );
- ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel());
- LegendHelper::showLegend(rModel, m_xCC);
+ LegendHelper::showLegend(*getChartModel(), m_xCC);
aUndoGuard.commit();
}
@@ -241,13 +356,13 @@ void ChartController::executeDispatch_OpenLegendDialog()
void ChartController::executeDispatch_InsertMenu_DataLabels()
{
- UndoGuard aUndoGuard(
+ std::shared_ptr<UndoGuard> aUndoGuard = std::make_shared<UndoGuard>(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_DATALABELS )),
m_xUndoManager );
//if a series is selected insert labels for that series only:
- uno::Reference< chart2::XDataSeries > xSeries =
+ rtl::Reference< DataSeries > xSeries =
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel());
if( xSeries.is() )
{
@@ -258,19 +373,16 @@ void ChartController::executeDispatch_InsertMenu_DataLabels()
OUString aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticles(
ObjectIdentifier::getSeriesParticleFromCID(m_aSelection.getSelectedCID()), aChildParticle );
- bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true );
- if( bSuccess )
- aUndoGuard.commit();
+ ChartController::executeDlg_ObjectProperties_withUndoGuard( aUndoGuard, aObjectCID, true );
return;
}
-
try
{
wrapper::AllDataLabelItemConverter aItemConverter(
getChartModel(),
m_pDrawModelWrapper->GetItemPool(),
m_pDrawModelWrapper->getSdrModel(),
- uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ));
+ getChartModel() );
SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
aItemConverter.FillItemSet( aItemSet );
@@ -278,8 +390,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels()
SolarMutexGuard aGuard;
//get number formatter
- uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( getModel(), uno::UNO_QUERY );
- NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
+ NumberFormatterWrapper aNumberFormatterWrapper( getChartModel() );
SvNumberFormatter* pNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter();
DataLabelsDialog aDlg(GetChartFrame(), aItemSet, pNumberFormatter);
@@ -292,7 +403,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels()
ControllerLockGuardUNO aCLGuard( getChartModel() );
bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
if( bChanged )
- aUndoGuard.commit();
+ aUndoGuard->commit();
}
}
catch(const uno::RuntimeException&)
@@ -319,17 +430,17 @@ void ChartController::executeDispatch_InsertMenu_MeanValues()
ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_AVERAGE_LINE )),
m_xUndoManager );
- uno::Reference< chart2::XDataSeries > xSeries =
+ rtl::Reference< DataSeries > xSeries =
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xSeries.is() )
{
//if a series is selected insert mean value only for that series:
lcl_InsertMeanValueLine( xSeries );
}
- else
+ else if (rtl::Reference<Diagram> xDiagram = getFirstDiagram())
{
- std::vector< uno::Reference< chart2::XDataSeries > > aSeries(
- DiagramHelper::getDataSeriesFromDiagram( getFirstDiagram()));
+ std::vector< rtl::Reference< DataSeries > > aSeries =
+ xDiagram->getDataSeries();
for( const auto& xSrs : aSeries )
lcl_InsertMeanValueLine( xSrs );
@@ -341,7 +452,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines()
{
OUString aCID = m_aSelection.getSelectedCID();
- uno::Reference< chart2::XDataSeries > xSeries =
+ rtl::Reference< DataSeries > xSeries =
ObjectIdentifier::getDataSeriesForCID( aCID, getChartModel() );
if( !xSeries.is() )
@@ -352,35 +463,33 @@ void ChartController::executeDispatch_InsertMenu_Trendlines()
void ChartController::executeDispatch_InsertTrendline()
{
- uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer(
- ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel()), uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xRegressionCurveContainer =
+ ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel());
if( !xRegressionCurveContainer.is() )
return;
- UndoLiveUpdateGuard aUndoGuard(
+ auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_CURVE )),
m_xUndoManager );
- uno::Reference< chart2::XRegressionCurve > xCurve =
+ rtl::Reference< RegressionCurveModel > xCurve =
RegressionCurveHelper::addRegressionCurve(
SvxChartRegress::Linear,
xRegressionCurveContainer );
- uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
-
- if( !xProperties.is())
+ if( !xCurve.is())
return;
- wrapper::RegressionCurveItemConverter aItemConverter(
- xProperties, xRegressionCurveContainer, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
+ auto aItemConverter = std::make_shared<wrapper::RegressionCurveItemConverter>(
+ xCurve, xRegressionCurveContainer, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
m_pDrawModelWrapper->getSdrModel(),
- uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ));
+ getChartModel() );
// open dialog
- SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
- aItemConverter.FillItemSet( aItemSet );
+ SfxItemSet aItemSet = aItemConverter->CreateEmptyItemSet();
+ aItemConverter->FillItemSet( aItemSet );
ObjectPropertiesDialogParameter aDialogParameter(
ObjectIdentifier::createDataCurveCID(
ObjectIdentifier::getSeriesParticleFromCID( m_aSelection.getSelectedCID()),
@@ -388,24 +497,23 @@ void ChartController::executeDispatch_InsertTrendline()
aDialogParameter.init( getChartModel() );
ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get());
SolarMutexGuard aGuard;
- SchAttribTabDlg aDialog(
- GetChartFrame(), &aItemSet, &aDialogParameter,
- &aViewElementListProvider,
- uno::Reference< util::XNumberFormatsSupplier >(
- getModel(), uno::UNO_QUERY ) );
+ auto aDialog = std::make_shared<SchAttribTabDlg>(GetChartFrame(), &aItemSet, &aDialogParameter,
+ &aViewElementListProvider, getChartModel());
// note: when a user pressed "OK" but didn't change any settings in the
// dialog, the SfxTabDialog returns "Cancel"
- if( aDialog.run() == RET_OK || aDialog.DialogWasClosedWithOK())
- {
- const SfxItemSet* pOutItemSet = aDialog.GetOutputItemSet();
- if( pOutItemSet )
+ SfxTabDialogController::runAsync(aDialog, [this, aDialog, aItemConverter, xUndoGuard=std::move(xUndoGuard)](int nResult) {
+ if ( nResult == RET_OK || aDialog->DialogWasClosedWithOK() )
{
- ControllerLockGuardUNO aCLGuard( getChartModel() );
- aItemConverter.ApplyItemSet( *pOutItemSet );
+ const SfxItemSet* pOutItemSet = aDialog->GetOutputItemSet();
+ if( pOutItemSet )
+ {
+ ControllerLockGuardUNO aCLGuard( getChartModel() );
+ aItemConverter->ApplyItemSet( *pOutItemSet );
+ }
+ xUndoGuard->commit();
}
- aUndoGuard.commit();
- }
+ });
}
void ChartController::executeDispatch_InsertErrorBars( bool bYError )
@@ -413,12 +521,12 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError )
ObjectType objType = bYError ? OBJECTTYPE_DATA_ERRORS_Y : OBJECTTYPE_DATA_ERRORS_X;
//if a series is selected insert error bars for that series only:
- uno::Reference< chart2::XDataSeries > xSeries =
+ rtl::Reference< DataSeries > xSeries =
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xSeries.is())
{
- UndoLiveUpdateGuard aUndoGuard(
+ auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::ActionType::Insert,
SchResId( bYError ? STR_OBJECT_ERROR_BARS_Y : STR_OBJECT_ERROR_BARS_X )),
@@ -431,47 +539,48 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError )
bYError));
// get an appropriate item converter
- wrapper::ErrorBarItemConverter aItemConverter(
- getModel(), xErrorBarProp, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
+ auto aItemConverter = std::make_shared<wrapper::ErrorBarItemConverter> (
+ getChartModel(), xErrorBarProp, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
m_pDrawModelWrapper->getSdrModel(),
- uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ));
+ getChartModel() );
// open dialog
- SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
+ SfxItemSet aItemSet = aItemConverter->CreateEmptyItemSet();
aItemSet.Put(SfxBoolItem(SCHATTR_STAT_ERRORBAR_TYPE,bYError));
- aItemConverter.FillItemSet( aItemSet );
+ aItemConverter->FillItemSet( aItemSet );
ObjectPropertiesDialogParameter aDialogParameter(
ObjectIdentifier::createClassifiedIdentifierWithParent(
objType, u"", m_aSelection.getSelectedCID()));
aDialogParameter.init( getChartModel() );
ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get());
SolarMutexGuard aGuard;
- SchAttribTabDlg aDlg(
+ auto aDlg = std::make_shared<SchAttribTabDlg>(
GetChartFrame(), &aItemSet, &aDialogParameter,
&aViewElementListProvider,
- uno::Reference< util::XNumberFormatsSupplier >(
- getModel(), uno::UNO_QUERY ) );
- aDlg.SetAxisMinorStepWidthForErrorBarDecimals(
+ getChartModel() );
+ aDlg->SetAxisMinorStepWidthForErrorBarDecimals(
InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(),
m_xChartView, m_aSelection.getSelectedCID()));
// note: when a user pressed "OK" but didn't change any settings in the
// dialog, the SfxTabDialog returns "Cancel"
- if (aDlg.run() == RET_OK || aDlg.DialogWasClosedWithOK())
- {
- const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet();
- if( pOutItemSet )
+ SfxTabDialogController::runAsync(aDlg, [this, aDlg, aItemConverter, xUndoGuard=std::move(xUndoGuard)](int nResult) {
+ if ( nResult == RET_OK || aDlg->DialogWasClosedWithOK() )
{
- ControllerLockGuardUNO aCLGuard( getChartModel() );
- aItemConverter.ApplyItemSet( *pOutItemSet );
+ const SfxItemSet* pOutItemSet = aDlg->GetOutputItemSet();
+ if( pOutItemSet )
+ {
+ ControllerLockGuardUNO aCLGuard( getChartModel() );
+ aItemConverter->ApplyItemSet( *pOutItemSet );
+ }
+ xUndoGuard->commit();
}
- aUndoGuard.commit();
- }
+ });
}
else
{
//if no series is selected insert error bars for all series
- UndoGuard aUndoGuard(
+ auto xUndoGuard = std::make_shared<UndoGuard>(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::ActionType::Insert,
ObjectNameProvider::getName_ObjectForAllSeries( objType ) ),
@@ -479,32 +588,34 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError )
try
{
- wrapper::AllSeriesStatisticsConverter aItemConverter(
+ auto aItemConverter = std::make_shared<wrapper::AllSeriesStatisticsConverter>(
getChartModel(), m_pDrawModelWrapper->GetItemPool() );
- SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
- aItemConverter.FillItemSet( aItemSet );
+ SfxItemSet aItemSet = aItemConverter->CreateEmptyItemSet();
+ aItemConverter->FillItemSet( aItemSet );
//prepare and open dialog
SolarMutexGuard aGuard;
- InsertErrorBarsDialog aDlg(
+ auto aDlg = std::make_shared<InsertErrorBarsDialog>(
GetChartFrame(), aItemSet,
getChartModel(),
bYError ? ErrorBarResources::ERROR_BAR_Y : ErrorBarResources::ERROR_BAR_X);
- aDlg.SetAxisMinorStepWidthForErrorBarDecimals(
- InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(), m_xChartView, OUString() ) );
-
- if (aDlg.run() == RET_OK)
- {
- SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet();
- aDlg.FillItemSet( aOutItemSet );
-
- // lock controllers till end of block
- ControllerLockGuardUNO aCLGuard( getChartModel() );
- bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
- if( bChanged )
- aUndoGuard.commit();
- }
+ aDlg->SetAxisMinorStepWidthForErrorBarDecimals(
+ InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(), m_xChartView, u"" ) );
+
+ weld::DialogController::runAsync(aDlg, [this, aDlg, aItemConverter, xUndoGuard=std::move(xUndoGuard)](int nResult) {
+ if ( nResult == RET_OK )
+ {
+ SfxItemSet aOutItemSet = aItemConverter->CreateEmptyItemSet();
+ aDlg->FillItemSet( aOutItemSet );
+
+ // lock controllers till end of block
+ ControllerLockGuardUNO aCLGuard( getChartModel() );
+ bool bChanged = aItemConverter->ApplyItemSet( aOutItemSet );//model should be changed now
+ if( bChanged )
+ xUndoGuard->commit();
+ }
+ });
}
catch(const uno::RuntimeException&)
{
@@ -519,8 +630,8 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 )
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY );
if( !xRegCurve.is() )
{
- uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
- ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xRegCurveCnt =
+ ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) );
}
if( !xRegCurve.is())
@@ -573,8 +684,8 @@ void ChartController::executeDispatch_DeleteR2Value()
void ChartController::executeDispatch_DeleteMeanValue()
{
- uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
- ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xRegCurveCnt =
+ ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xRegCurveCnt.is())
{
UndoGuard aUndoGuard(
@@ -588,8 +699,8 @@ void ChartController::executeDispatch_DeleteMeanValue()
void ChartController::executeDispatch_DeleteTrendline()
{
- uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
- ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xRegCurveCnt =
+ ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xRegCurveCnt.is())
{
UndoGuard aUndoGuard(
@@ -603,8 +714,8 @@ void ChartController::executeDispatch_DeleteTrendline()
void ChartController::executeDispatch_DeleteTrendlineEquation()
{
- uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
- ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY );
+ rtl::Reference< DataSeries > xRegCurveCnt =
+ ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xRegCurveCnt.is())
{
UndoGuard aUndoGuard(
@@ -618,8 +729,8 @@ void ChartController::executeDispatch_DeleteTrendlineEquation()
void ChartController::executeDispatch_DeleteErrorBars( bool bYError )
{
- uno::Reference< chart2::XDataSeries > xDataSeries(
- ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ));
+ rtl::Reference< DataSeries > xDataSeries =
+ ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xDataSeries.is())
{
UndoGuard aUndoGuard(
@@ -633,7 +744,7 @@ void ChartController::executeDispatch_DeleteErrorBars( bool bYError )
void ChartController::executeDispatch_InsertDataLabels()
{
- uno::Reference< chart2::XDataSeries > xSeries =
+ rtl::Reference< DataSeries > xSeries =
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xSeries.is() )
{
@@ -656,7 +767,7 @@ void ChartController::executeDispatch_InsertDataLabel()
void ChartController::executeDispatch_DeleteDataLabels()
{
- uno::Reference< chart2::XDataSeries > xSeries =
+ rtl::Reference< DataSeries > xSeries =
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xSeries.is() )
{
@@ -682,7 +793,7 @@ void ChartController::executeDispatch_ResetAllDataPoints()
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format,
SchResId( STR_OBJECT_DATAPOINTS )),
m_xUndoManager );
- uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xSeries.is() )
xSeries->resetAllDataPoints();
aUndoGuard.commit();
@@ -692,7 +803,7 @@ void ChartController::executeDispatch_ResetDataPoint()
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format,
SchResId( STR_OBJECT_DATAPOINT )),
m_xUndoManager );
- uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xSeries.is() )
{
sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
@@ -705,14 +816,14 @@ void ChartController::executeDispatch_InsertAxisTitle()
{
try
{
- uno::Reference< XTitle > xTitle;
+ rtl::Reference< Title > xTitle;
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_TITLE )),
m_xUndoManager );
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
sal_Int32 nDimensionIndex = -1;
sal_Int32 nCooSysIndex = -1;
sal_Int32 nAxisIndex = -1;
@@ -726,8 +837,8 @@ void ChartController::executeDispatch_InsertAxisTitle()
else
eTitleType = TitleHelper::Z_AXIS_TITLE;
- std::unique_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider());
- xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getChartModel(), m_xCC, apRefSizeProvider.get() );
+ ReferenceSizeProvider aRefSizeProvider( impl_createReferenceSizeProvider());
+ xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getChartModel(), m_xCC, &aRefSizeProvider );
aUndoGuard.commit();
}
}
@@ -746,7 +857,7 @@ void ChartController::executeDispatch_InsertAxis()
try
{
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xAxis.is() )
{
AxisHelper::makeAxisVisible( xAxis );
@@ -768,7 +879,7 @@ void ChartController::executeDispatch_DeleteAxis()
try
{
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xAxis.is() )
{
AxisHelper::makeAxisInvisible( xAxis );
@@ -790,10 +901,10 @@ void ChartController::executeDispatch_InsertMajorGrid()
try
{
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xAxis.is() )
{
- AxisHelper::makeGridVisible( xAxis->getGridProperties() );
+ AxisHelper::makeGridVisible( xAxis->getGridProperties2() );
aUndoGuard.commit();
}
}
@@ -812,10 +923,10 @@ void ChartController::executeDispatch_DeleteMajorGrid()
try
{
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xAxis.is() )
{
- AxisHelper::makeGridInvisible( xAxis->getGridProperties() );
+ AxisHelper::makeGridInvisible( xAxis->getGridProperties2() );
aUndoGuard.commit();
}
}
@@ -834,11 +945,11 @@ void ChartController::executeDispatch_InsertMinorGrid()
try
{
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xAxis.is() )
{
- const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
- for( Reference< beans::XPropertySet > const & props : aSubGrids)
+ std::vector< rtl::Reference< ::chart::GridProperties > > aSubGrids( xAxis->getSubGridProperties2() );
+ for( rtl::Reference< GridProperties > const & props : aSubGrids)
AxisHelper::makeGridVisible( props );
aUndoGuard.commit();
}
@@ -858,11 +969,11 @@ void ChartController::executeDispatch_DeleteMinorGrid()
try
{
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
+ rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() );
if( xAxis.is() )
{
- const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
- for( Reference< beans::XPropertySet > const & props : aSubGrids)
+ std::vector< rtl::Reference< ::chart::GridProperties > > aSubGrids( xAxis->getSubGridProperties2() );
+ for( rtl::Reference< ::chart::GridProperties > const & props : aSubGrids)
AxisHelper::makeGridInvisible( props );
aUndoGuard.commit();
}