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 8c3fa629f489fdd5ec73c9ec18010eeaf39955a4
Author:     codewithvk <vivek.jav...@collabora.com>
AuthorDate: Thu Jan 25 18:39:18 2024 +0530
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Mar 3 14:52:38 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 <vivek.jav...@collabora.com>
    Change-Id: I54c24e0cd30d6ec8b2bfa93567e830405d2fd30c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162576
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 748a5a01165d40e9bcaa7bfc75b0e6f74fc5a07d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164125
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/chart2/source/controller/inc/ChartController.hxx 
b/chart2/source/controller/inc/ChartController.hxx
index e6d42f139053..d1e95efafac3 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -430,7 +430,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 b80ef2bd5fd1..6461955cbc24 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -358,7 +358,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 );
@@ -375,12 +375,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(
@@ -408,7 +405,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 84f1fdcb9e33..79b6159d4a6e 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(),
                                  &aRefSizeProv));
 
         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()

Reply via email to