diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-12-15 15:31:49 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-03-08 11:50:51 +0100 |
commit | c883303400158573cfd3dc2bc0ad59fa8f64ce48 (patch) | |
tree | e6dcd901d8f0fa6427ff4ebbb34894af29a3d025 | |
parent | c056b630ef97aab139625d0a7c085825c8a9eb7f (diff) |
pivot table: make subdialogs of pivot table dialog async
Change-Id: I2c1b26ebe661a2f66bc7bf94e4f3ede2fc5e18b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107775
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112095
Tested-by: Jenkins
-rw-r--r-- | sc/qa/uitest/calc_tests9/pivotTable.py | 6 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.hxx | 10 | ||||
-rw-r--r-- | sc/source/ui/dbgui/PivotLayoutTreeList.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/dbgui/PivotLayoutTreeListData.cxx | 34 | ||||
-rw-r--r-- | sc/source/ui/dbgui/pvfundlg.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/inc/PivotLayoutTreeList.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/pvfundlg.hxx | 4 |
8 files changed, 67 insertions, 37 deletions
diff --git a/sc/qa/uitest/calc_tests9/pivotTable.py b/sc/qa/uitest/calc_tests9/pivotTable.py index d85894bf9af6..2da282bb19d3 100644 --- a/sc/qa/uitest/calc_tests9/pivotTable.py +++ b/sc/qa/uitest/calc_tests9/pivotTable.py @@ -53,7 +53,7 @@ class pivotTable(UITestCase): self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) xOKBtn = dialog2.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn.executeAction("CLICK", tuple()) def handle_options_dialog_second_time(dialog2): xEmptyLine = dialog2.getChild("emptyline") @@ -62,7 +62,7 @@ class pivotTable(UITestCase): self.assertEqual('false', get_state_as_dict(xEmptyLine)['Selected']) xCancelBtn = dialog2.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + xCancelBtn.executeAction("CLICK", tuple()) def handle_options_dialog_third_time(dialog2): xEmptyLine = dialog2.getChild("emptyline") @@ -70,7 +70,7 @@ class pivotTable(UITestCase): self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) xOKBtn = dialog2.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn.executeAction("CLICK", tuple()) self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ()), dialog_handler=handle_options_dialog_first_time) diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index b77f603540de..bc22a3fb443a 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -230,11 +230,21 @@ short AbstractScDPFunctionDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractScDPFunctionDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScDPSubtotalDlg_Impl::Execute() { return m_xDlg->run(); } +bool AbstractScDPSubtotalDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScDPNumGroupDlg_Impl::Execute() { return m_xDlg->run(); @@ -1123,7 +1133,7 @@ VclPtr<AbstractScDPFunctionDlg> ScAbstractDialogFactory_Impl::CreateScDPFunction const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData) { - return VclPtr<AbstractScDPFunctionDlg_Impl>::Create(std::make_unique<ScDPFunctionDlg>(pParent, rLabelVec, rLabelData, rFuncData)); + return VclPtr<AbstractScDPFunctionDlg_Impl>::Create(std::make_shared<ScDPFunctionDlg>(pParent, rLabelVec, rLabelData, rFuncData)); } VclPtr<AbstractScDPSubtotalDlg> ScAbstractDialogFactory_Impl::CreateScDPSubtotalDlg(weld::Widget* pParent, @@ -1132,7 +1142,7 @@ VclPtr<AbstractScDPSubtotalDlg> ScAbstractDialogFactory_Impl::CreateScDPSubtotal const ScPivotFuncData& rFuncData, const ScDPNameVec& rDataFields) { - return VclPtr<AbstractScDPSubtotalDlg_Impl>::Create(std::make_unique<ScDPSubtotalDlg>(pParent, rDPObj, rLabelData, rFuncData, rDataFields, true/*bEnableLayout*/)); + return VclPtr<AbstractScDPSubtotalDlg_Impl>::Create(std::make_shared<ScDPSubtotalDlg>(pParent, rDPObj, rLabelData, rFuncData, rDataFields, true/*bEnableLayout*/)); } VclPtr<AbstractScDPNumGroupDlg> ScAbstractDialogFactory_Impl::CreateScDPNumGroupDlg(weld::Window* pParent, const ScDPNumGroupInfo& rInfo) diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index be01347f495f..f48e2b4f2cfd 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -465,26 +465,28 @@ public: class AbstractScDPFunctionDlg_Impl : public AbstractScDPFunctionDlg { - std::unique_ptr<ScDPFunctionDlg> m_xDlg; + std::shared_ptr<ScDPFunctionDlg> m_xDlg; public: - explicit AbstractScDPFunctionDlg_Impl(std::unique_ptr<ScDPFunctionDlg> p) + explicit AbstractScDPFunctionDlg_Impl(std::shared_ptr<ScDPFunctionDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; virtual PivotFunc GetFuncMask() const override; virtual css::sheet::DataPilotFieldReference GetFieldRef() const override; }; class AbstractScDPSubtotalDlg_Impl : public AbstractScDPSubtotalDlg { - std::unique_ptr<ScDPSubtotalDlg> m_xDlg; + std::shared_ptr<ScDPSubtotalDlg> m_xDlg; public: - explicit AbstractScDPSubtotalDlg_Impl(std::unique_ptr<ScDPSubtotalDlg> p) + explicit AbstractScDPSubtotalDlg_Impl(std::shared_ptr<ScDPSubtotalDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; virtual PivotFunc GetFuncMask() const override; virtual void FillLabelData( ScDPLabelData& rLabelData ) const override; }; diff --git a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx index b193acf9a251..65e055477276 100644 --- a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx +++ b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx @@ -41,27 +41,31 @@ IMPL_LINK_NOARG(ScPivotLayoutTreeList, DoubleClickHdl, weld::TreeView&, bool) ScItemValue* pCurrentItemValue = reinterpret_cast<ScItemValue*>(mxControl->get_id(nEntry).toInt64()); ScPivotFuncData& rCurrentFunctionData = pCurrentItemValue->maFunctionData; + SCCOL nCurrentColumn = rCurrentFunctionData.mnCol; - if (mpParent->IsDataElement(rCurrentFunctionData.mnCol)) + if (mpParent->IsDataElement(nCurrentColumn)) return true; - SCCOL nCurrentColumn = rCurrentFunctionData.mnCol; ScDPLabelData& rCurrentLabelData = mpParent->GetLabelData(nCurrentColumn); ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create(); - std::vector<ScDPName> aDataFieldNames; - mpParent->PushDataFieldNames(aDataFieldNames); + maDataFieldNames.clear(); + mpParent->PushDataFieldNames(maDataFieldNames); - ScopedVclPtr<AbstractScDPSubtotalDlg> pDialog( + VclPtr<AbstractScDPSubtotalDlg> pDialog( pFactory->CreateScDPSubtotalDlg(mxControl.get(), mpParent->maPivotTableObject, - rCurrentLabelData, rCurrentFunctionData, aDataFieldNames)); + rCurrentLabelData, rCurrentFunctionData, maDataFieldNames)); - if (pDialog->Execute() == RET_OK) - { - pDialog->FillLabelData(rCurrentLabelData); - rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask(); - } + pDialog->StartExecuteAsync([this, pDialog, pCurrentItemValue, nCurrentColumn](int nResult) { + if (nResult == RET_OK) + { + pDialog->FillLabelData(mpParent->GetLabelData(nCurrentColumn)); + pCurrentItemValue->maFunctionData.mnFuncMask = pDialog->GetFuncMask(); + } + + pDialog->disposeOnce(); + }); return true; } diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx index 0dad394bda80..6924a72a6773 100644 --- a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx +++ b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx @@ -87,27 +87,33 @@ IMPL_LINK_NOARG(ScPivotLayoutTreeListData, DoubleClickHdl, weld::TreeView&, bool ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractScDPFunctionDlg> pDialog( + VclPtr<AbstractScDPFunctionDlg> pDialog( pFactory->CreateScDPFunctionDlg(mxControl.get(), mpParent->GetLabelDataVector(), rCurrentLabelData, rCurrentFunctionData)); - if (pDialog->Execute() == RET_OK) - { - rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask(); - rCurrentLabelData.mnFuncMask = pDialog->GetFuncMask(); + pDialog->StartExecuteAsync([this, pDialog, pCurrentItemValue, + rCurrentLabelData, nEntry](int nResult) mutable { + if (nResult == RET_OK) + { + ScPivotFuncData& rFunctionData = pCurrentItemValue->maFunctionData; + rFunctionData.mnFuncMask = pDialog->GetFuncMask(); + rCurrentLabelData.mnFuncMask = pDialog->GetFuncMask(); - rCurrentFunctionData.maFieldRef = pDialog->GetFieldRef(); + rFunctionData.maFieldRef = pDialog->GetFieldRef(); - ScDPLabelData& rDFData = mpParent->GetLabelData(rCurrentFunctionData.mnCol); + ScDPLabelData& rDFData = mpParent->GetLabelData(rFunctionData.mnCol); - AdjustDuplicateCount(pCurrentItemValue); + AdjustDuplicateCount(pCurrentItemValue); - OUString sDataItemName = lclCreateDataItemName( - rCurrentFunctionData.mnFuncMask, - rDFData.maName, - rCurrentFunctionData.mnDupCount); + OUString sDataItemName = lclCreateDataItemName( + rFunctionData.mnFuncMask, + rDFData.maName, + rFunctionData.mnDupCount); - mxControl->set_text(nEntry, sDataItemName); - } + mxControl->set_text(nEntry, sDataItemName); + } + + pDialog->disposeOnce(); + }); return true; } diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index 431ef89407de..481c1b738f92 100644 --- a/sc/source/ui/dbgui/pvfundlg.cxx +++ b/sc/source/ui/dbgui/pvfundlg.cxx @@ -565,9 +565,12 @@ IMPL_LINK(ScDPSubtotalDlg, ClickHdl, weld::Button&, rBtn, void) { if (&rBtn == mxBtnOptions.get()) { - ScDPSubtotalOptDlg aDlg(m_xDialog.get(), mrDPObj, maLabelData, mrDataFields, mbEnableLayout); - if (aDlg.run() == RET_OK) - aDlg.FillLabelData(maLabelData); + mxOptionsDlg = std::make_shared<ScDPSubtotalOptDlg>(m_xDialog.get(), mrDPObj, maLabelData, mrDataFields, mbEnableLayout); + + weld::DialogController::runAsync(mxOptionsDlg, [this](int nResult) { + if (nResult == RET_OK) + mxOptionsDlg->FillLabelData(maLabelData); + }); } } diff --git a/sc/source/ui/inc/PivotLayoutTreeList.hxx b/sc/source/ui/inc/PivotLayoutTreeList.hxx index 4d15053c0e31..1682b929eb4c 100644 --- a/sc/source/ui/inc/PivotLayoutTreeList.hxx +++ b/sc/source/ui/inc/PivotLayoutTreeList.hxx @@ -18,6 +18,7 @@ class ScPivotLayoutTreeList : public ScPivotLayoutTreeListBase { private: std::vector<std::unique_ptr<ScItemValue>> maItemValues; + std::vector<ScDPName> maDataFieldNames; DECL_LINK(KeyInputHdl, const KeyEvent&, bool); DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx index 4a60ec93e18a..6f093809660c 100644 --- a/sc/source/ui/inc/pvfundlg.hxx +++ b/sc/source/ui/inc/pvfundlg.hxx @@ -92,6 +92,8 @@ private: bool mbEmptyItem; /// true = Empty base item in listbox. }; +class ScDPSubtotalOptDlg; + class ScDPSubtotalDlg : public weld::GenericDialogController { public: @@ -127,6 +129,8 @@ private: std::unique_ptr<weld::Button> mxBtnOk; std::unique_ptr<weld::Button> mxBtnCancel; std::unique_ptr<weld::Button> mxBtnOptions; + + std::shared_ptr<ScDPSubtotalOptDlg> mxOptionsDlg; }; class ScDPSubtotalOptDlg : public weld::GenericDialogController |