chart2/source/controller/dialogs/ChartResourceGroups.cxx |   90 +++++++++------
 chart2/source/inc/ChartResourceGroups.hxx                |    8 -
 vcl/jsdialog/enabled.cxx                                 |    2 
 3 files changed, 62 insertions(+), 38 deletions(-)

New commits:
commit 437b45e14343488b143cbd341f386077d6ae69ff
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri Mar 24 10:52:13 2023 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Mon Apr 3 08:12:13 2023 +0200

    jsdialog: enable and make async chart line prop dialog
    
    Change-Id: I21817b21fe6d2ce0a6f6bd784c0e24fe35b17fec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149502
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/chart2/source/controller/dialogs/ChartResourceGroups.cxx 
b/chart2/source/controller/dialogs/ChartResourceGroups.cxx
index 19534aa1e0b0..3cf5996ed300 100644
--- a/chart2/source/controller/dialogs/ChartResourceGroups.cxx
+++ b/chart2/source/controller/dialogs/ChartResourceGroups.cxx
@@ -205,22 +205,22 @@ SplineResourceGroup::SplineResourceGroup(weld::Builder* 
pBuilder, weld::Window*
     m_xLB_LineType->connect_changed(LINK(this, SplineResourceGroup, 
LineTypeChangeHdl));
 }
 
-SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog()
+std::shared_ptr<SplinePropertiesDialog> 
SplineResourceGroup::getSplinePropertiesDialog()
 {
     if (!m_xSplinePropertiesDialog)
     {
         m_xSplinePropertiesDialog.reset(new SplinePropertiesDialog(m_pParent));
     }
-    return *m_xSplinePropertiesDialog;
+    return m_xSplinePropertiesDialog;
 }
 
-SteppedPropertiesDialog& SplineResourceGroup::getSteppedPropertiesDialog()
+std::shared_ptr<SteppedPropertiesDialog> 
SplineResourceGroup::getSteppedPropertiesDialog()
 {
     if (!m_xSteppedPropertiesDialog)
     {
         m_xSteppedPropertiesDialog.reset(new 
SteppedPropertiesDialog(m_pParent));
     }
-    return *m_xSteppedPropertiesDialog;
+    return m_xSteppedPropertiesDialog;
 }
 
 void SplineResourceGroup::showControls(bool bShow)
@@ -245,7 +245,7 @@ void SplineResourceGroup::fillControls(const 
ChartTypeParameter& rParameter)
             m_xPB_DetailsDialog->connect_clicked(
                 LINK(this, SplineResourceGroup, SplineDetailsDialogHdl));
             
m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES));
-            getSplinePropertiesDialog().fillControls(rParameter);
+            getSplinePropertiesDialog()->fillControls(rParameter);
             break;
         case CurveStyle_STEP_START:
         case CurveStyle_STEP_END:
@@ -256,7 +256,7 @@ void SplineResourceGroup::fillControls(const 
ChartTypeParameter& rParameter)
             m_xPB_DetailsDialog->connect_clicked(
                 LINK(this, SplineResourceGroup, SteppedDetailsDialogHdl));
             
m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES));
-            getSteppedPropertiesDialog().fillControls(rParameter);
+            getSteppedPropertiesDialog()->fillControls(rParameter);
             break;
         default:
             m_xLB_LineType->set_active(-1);
@@ -268,10 +268,10 @@ void 
SplineResourceGroup::fillParameter(ChartTypeParameter& rParameter)
     switch (m_xLB_LineType->get_active())
     {
         case POS_LINETYPE_SMOOTH:
-            getSplinePropertiesDialog().fillParameter(rParameter, true);
+            getSplinePropertiesDialog()->fillParameter(rParameter, true);
             break;
         case POS_LINETYPE_STEPPED:
-            getSteppedPropertiesDialog().fillParameter(rParameter, true);
+            getSteppedPropertiesDialog()->fillParameter(rParameter, true);
             break;
         default: // includes POS_LINETYPE_STRAIGHT
             rParameter.eCurveStyle = CurveStyle_LINES;
@@ -288,43 +288,65 @@ IMPL_LINK_NOARG(SplineResourceGroup, LineTypeChangeHdl, 
weld::ComboBox&, void)
 IMPL_LINK_NOARG(SplineResourceGroup, SplineDetailsDialogHdl, weld::Button&, 
void)
 {
     ChartTypeParameter aOldParameter;
-    getSplinePropertiesDialog().fillParameter(aOldParameter,
-                                              m_xLB_LineType->get_active() == 
POS_LINETYPE_SMOOTH);
+    std::shared_ptr<SplinePropertiesDialog> xDlg = getSplinePropertiesDialog();
+    xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == 
POS_LINETYPE_SMOOTH);
 
     const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active();
     m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH);
-    if (getSplinePropertiesDialog().run() == RET_OK)
-    {
-        if (m_pChangeListener)
-            m_pChangeListener->stateChanged();
-    }
-    else
-    {
-        //restore old state:
-        m_xLB_LineType->set_active(iOldLineTypePos);
-        getSplinePropertiesDialog().fillControls(aOldParameter);
-    }
+    weld::GenericDialogController::runAsync(xDlg, [this, xDlg, aOldParameter,
+                                                   iOldLineTypePos](sal_Int32 
nResult) {
+        m_xSplinePropertiesDialog = nullptr;
+        auto xNewDlg = getSplinePropertiesDialog();
+
+        if (nResult == RET_OK)
+        {
+            ChartTypeParameter aNewParameter;
+            xDlg->fillParameter(aNewParameter, m_xLB_LineType->get_active() == 
POS_LINETYPE_SMOOTH);
+            xNewDlg->fillControls(aNewParameter);
+
+            if (m_pChangeListener)
+                m_pChangeListener->stateChanged();
+        }
+        else
+        {
+            //restore old state:
+            m_xLB_LineType->set_active(iOldLineTypePos);
+            xNewDlg->fillControls(aOldParameter);
+        }
+    });
 }
 
 IMPL_LINK_NOARG(SplineResourceGroup, SteppedDetailsDialogHdl, weld::Button&, 
void)
 {
     ChartTypeParameter aOldParameter;
-    getSteppedPropertiesDialog().fillParameter(aOldParameter, 
m_xLB_LineType->get_active()
-                                                                  == 
POS_LINETYPE_STEPPED);
+    std::shared_ptr<SteppedPropertiesDialog> xDlg = 
getSteppedPropertiesDialog();
+    xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == 
POS_LINETYPE_STEPPED);
 
     const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active();
     m_xLB_LineType->set_active(POS_LINETYPE_STEPPED);
-    if (getSteppedPropertiesDialog().run() == RET_OK)
-    {
-        if (m_pChangeListener)
-            m_pChangeListener->stateChanged();
-    }
-    else
-    {
-        //restore old state:
-        m_xLB_LineType->set_active(iOldLineTypePos);
-        getSteppedPropertiesDialog().fillControls(aOldParameter);
-    }
+
+    weld::GenericDialogController::runAsync(
+        xDlg, [this, xDlg, aOldParameter, iOldLineTypePos](sal_Int32 nResult) {
+            m_xSteppedPropertiesDialog = nullptr;
+            auto xNewDlg = getSplinePropertiesDialog();
+
+            if (nResult == RET_OK)
+            {
+                ChartTypeParameter aNewParameter;
+                xDlg->fillParameter(aNewParameter,
+                                    m_xLB_LineType->get_active() == 
POS_LINETYPE_STEPPED);
+                xNewDlg->fillControls(aNewParameter);
+
+                if (m_pChangeListener)
+                    m_pChangeListener->stateChanged();
+            }
+            else
+            {
+                //restore old state:
+                m_xLB_LineType->set_active(iOldLineTypePos);
+                xDlg->fillControls(aOldParameter);
+            }
+        });
 }
 
 GeometryResourceGroup::GeometryResourceGroup(weld::Builder* pBuilder)
diff --git a/chart2/source/inc/ChartResourceGroups.hxx 
b/chart2/source/inc/ChartResourceGroups.hxx
index 8c263a7a6a75..9ae397d84f2f 100644
--- a/chart2/source/inc/ChartResourceGroups.hxx
+++ b/chart2/source/inc/ChartResourceGroups.hxx
@@ -113,16 +113,16 @@ private:
     DECL_LINK(LineTypeChangeHdl, weld::ComboBox&, void);
     DECL_LINK(SplineDetailsDialogHdl, weld::Button&, void);
     DECL_LINK(SteppedDetailsDialogHdl, weld::Button&, void);
-    SplinePropertiesDialog& getSplinePropertiesDialog();
-    SteppedPropertiesDialog& getSteppedPropertiesDialog();
+    std::shared_ptr<SplinePropertiesDialog> getSplinePropertiesDialog();
+    std::shared_ptr<SteppedPropertiesDialog> getSteppedPropertiesDialog();
 
 private:
     weld::Window* m_pParent;
     std::unique_ptr<weld::Label> m_xFT_LineType;
     std::unique_ptr<weld::ComboBox> m_xLB_LineType;
     std::unique_ptr<weld::Button> m_xPB_DetailsDialog;
-    std::unique_ptr<SplinePropertiesDialog> m_xSplinePropertiesDialog;
-    std::unique_ptr<SteppedPropertiesDialog> m_xSteppedPropertiesDialog;
+    std::shared_ptr<SplinePropertiesDialog> m_xSplinePropertiesDialog;
+    std::shared_ptr<SteppedPropertiesDialog> m_xSteppedPropertiesDialog;
 };
 
 class GeometryResourceGroup final : public ChangingResource
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 5efd2a15d921..5249e2e1ffdb 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -136,6 +136,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
         || rUIFile == u"modules/schart/ui/datarangedialog.ui"
         || rUIFile == u"modules/schart/ui/insertaxisdlg.ui"
         || rUIFile == u"modules/schart/ui/inserttitledlg.ui"
+        || rUIFile == u"modules/schart/ui/smoothlinesdlg.ui"
+        || rUIFile == u"modules/schart/ui/steppedlinesdlg.ui"
         || rUIFile == u"modules/schart/ui/tp_ChartType.ui"
         || rUIFile == u"modules/schart/ui/tp_RangeChooser.ui"
         || rUIFile == u"modules/schart/ui/tp_DataSource.ui"

Reply via email to