chart2/source/controller/inc/ChartController.hxx | 2 chart2/source/controller/main/ChartController_Insert.cxx | 9 - chart2/source/controller/main/ChartController_Properties.cxx | 58 +++++------ 3 files changed, 32 insertions(+), 37 deletions(-)
New commits: commit 69a5a5ce7fb452b8a1ed1c1edf3571b1df5d7439 Author: codewithvk <[email protected]> AuthorDate: Thu Jan 25 18:39:18 2024 +0530 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Mar 3 14:53:24 2024 +0100 Make Chart Object Properties Dialogs Async How to reproduce it: When double-clicking on a chart, it will now open the Chart Object Properties dialog box. Previously synchronous, this commit updates it to be asynchronous. Signed-off-by: codewithvk <[email protected]> Change-Id: I54c24e0cd30d6ec8b2bfa93567e830405d2fd30c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162576 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> (cherry picked from commit 748a5a01165d40e9bcaa7bfc75b0e6f74fc5a07d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164194 Reviewed-by: Caolán McNamara <[email protected]> diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 9e72e09ddbd9..752e551828c2 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -429,7 +429,7 @@ private: void executeDispatch_ObjectProperties(); void executeDispatch_FormatObject( std::u16string_view rDispatchCommand ); void executeDlg_ObjectProperties( const OUString& rObjectCID ); - bool executeDlg_ObjectProperties_withoutUndoGuard( const OUString& rObjectCID, bool bSuccessOnUnchanged ); + void executeDlg_ObjectProperties_withUndoGuard( std::shared_ptr<UndoGuard> aUndoGuard, const OUString& rObjectCID, bool bSuccessOnUnchanged ); void executeDispatch_ChartType(); diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 5c069235f7b4..db296081f652 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -359,7 +359,7 @@ 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 ); @@ -376,12 +376,9 @@ 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( @@ -409,7 +406,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&) diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 5f9e9a7d9570..82ddf5047eda 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -703,24 +703,22 @@ void ChartController::executeDlg_ObjectProperties( const OUString& rSelectedObje { OUString aObjectCID = lcl_getFormatCIDforSelectedCID( rSelectedObjectCID ); - UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::ActionType::Format, - ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), - m_xUndoManager ); + auto aUndoGuard = std::make_shared<UndoGuard>( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::ActionType::Format, + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), + m_xUndoManager ); - bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); - if( bSuccess ) - aUndoGuard.commit(); + ChartController::executeDlg_ObjectProperties_withUndoGuard( aUndoGuard, aObjectCID, false ); } -bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( - const OUString& rObjectCID, bool bSuccessOnUnchanged ) +void ChartController::executeDlg_ObjectProperties_withUndoGuard( + std::shared_ptr<UndoGuard> aUndoGuard,const OUString& rObjectCID, bool bSuccessOnUnchanged ) { //return true if the properties were changed successfully - bool bRet = false; if( rObjectCID.isEmpty() ) { - return bRet; + return; } try { @@ -728,12 +726,12 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID ); if( eObjectType==OBJECTTYPE_UNKNOWN ) { - return bRet; + return; } if( eObjectType==OBJECTTYPE_DIAGRAM_WALL || eObjectType==OBJECTTYPE_DIAGRAM_FLOOR ) { if( !getFirstDiagram()->isSupportingFloorAndWall() ) - return bRet; + return; } //convert properties to ItemSet @@ -742,14 +740,14 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( rtl::Reference<::chart::ChartModel> xChartDoc(getChartModel()); - std::unique_ptr<wrapper::ItemConverter> pItemConverter( + std::shared_ptr<wrapper::ItemConverter> pItemConverter( createItemConverter( rObjectCID, xChartDoc, m_xCC, m_pDrawModelWrapper->getSdrModel(), m_xChartView.get(), pRefSizeProv.get())); if (!pItemConverter) - return bRet; + return; SfxItemSet aItemSet = pItemConverter->CreateEmptyItemSet(); @@ -764,10 +762,10 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get() ); SolarMutexGuard aGuard; - SchAttribTabDlg aDlg( - GetChartFrame(), &aItemSet, &aDialogParameter, - &aViewElementListProvider, - xChartDoc ); + std::shared_ptr<SchAttribTabDlg> aDlgPtr = std::make_shared<SchAttribTabDlg>( + GetChartFrame(), &aItemSet, &aDialogParameter, + &aViewElementListProvider, + xChartDoc); if(aDialogParameter.HasSymbolProperties()) { @@ -786,25 +784,26 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( sal_Int32 const nStandardSymbol=0;//@todo get from somewhere std::optional<Graphic> oAutoSymbolGraphic(std::in_place, aViewElementListProvider.GetSymbolGraphic( nStandardSymbol, &aSymbolShapeProperties ) ); // note: the dialog takes the ownership of pSymbolShapeProperties and pAutoSymbolGraphic - aDlg.setSymbolInformation( std::move(aSymbolShapeProperties), std::move(oAutoSymbolGraphic) ); + aDlgPtr->setSymbolInformation( std::move(aSymbolShapeProperties), std::move(oAutoSymbolGraphic) ); } if( aDialogParameter.HasStatisticProperties() ) { - aDlg.SetAxisMinorStepWidthForErrorBarDecimals( + aDlgPtr->SetAxisMinorStepWidthForErrorBarDecimals( InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( xChartDoc, m_xChartView, rObjectCID ) ); } //open the dialog - if (aDlg.run() == RET_OK || (bSuccessOnUnchanged && aDlg.DialogWasClosedWithOK())) + SfxTabDialogController::runAsync(aDlgPtr, [aDlgPtr, xChartDoc, pItemConverter, bSuccessOnUnchanged, aUndoGuard] (int nResult) { - const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); - if(pOutItemSet) - { - ControllerLockGuardUNO aCLGuard(xChartDoc); - (void)pItemConverter->ApplyItemSet(*pOutItemSet); //model should be changed now - bRet = true; + if (nResult == RET_OK || (bSuccessOnUnchanged && aDlgPtr->DialogWasClosedWithOK())) { + const SfxItemSet* pOutItemSet = aDlgPtr->GetOutputItemSet(); + if(pOutItemSet) { + ControllerLockGuardUNO aCLGuard(xChartDoc); + (void)pItemConverter->ApplyItemSet(*pOutItemSet); //model should be changed now + aUndoGuard->commit(); + } } - } + }); } catch( const util::CloseVetoException& ) { @@ -812,7 +811,6 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( catch( const uno::RuntimeException& ) { } - return bRet; } void ChartController::executeDispatch_View3D()
