summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-12-16 15:59:00 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2020-12-16 17:36:39 +0100
commitb99e2cd598a2a3a9e540f0145c385de044e93bb1 (patch)
tree4772fbb22f2d2218ec2ec9b2deeb3d969215150c /sc
parent9fb7c25e78d68d346e60e0a6e15f90851140a6bc (diff)
pivot table: properly close all subdialogs
Change-Id: Ieda601ce25d822394d6ddd12da861128b9270aa2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107843 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/scabstdlg.hxx2
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx10
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx2
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeList.cxx18
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeListData.cxx22
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx13
-rw-r--r--sc/source/ui/inc/PivotLayoutTreeList.hxx3
-rw-r--r--sc/source/ui/inc/PivotLayoutTreeListData.hxx3
-rw-r--r--sc/source/ui/inc/pvfundlg.hxx1
9 files changed, 58 insertions, 16 deletions
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index a72573c808b9..670abcaaf70e 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -298,6 +298,7 @@ protected:
public:
virtual PivotFunc GetFuncMask() const = 0;
virtual css::sheet::DataPilotFieldReference GetFieldRef() const = 0;
+ virtual void Response(int nResponse) = 0;
};
class AbstractScDPSubtotalDlg : public VclAbstractDialog
@@ -307,6 +308,7 @@ protected:
public:
virtual PivotFunc GetFuncMask() const = 0;
virtual void FillLabelData( ScDPLabelData& rLabelData ) const = 0;
+ virtual void Response(int nResponse) = 0;
};
class AbstractScDPNumGroupDlg : public VclAbstractDialog
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index b3171514f191..ec8e9491862f 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -763,6 +763,11 @@ PivotFunc AbstractScDPFunctionDlg_Impl::GetFuncMask() const
return m_xDlg->GetFuncMask();
}
+void AbstractScDPFunctionDlg_Impl::Response(int nResponse)
+{
+ m_xDlg->response(nResponse);
+}
+
css::sheet::DataPilotFieldReference AbstractScDPFunctionDlg_Impl::GetFieldRef() const
{
return m_xDlg->GetFieldRef();
@@ -778,6 +783,11 @@ void AbstractScDPSubtotalDlg_Impl::FillLabelData( ScDPLabelData& rLabelData ) co
m_xDlg->FillLabelData( rLabelData );
}
+void AbstractScDPSubtotalDlg_Impl::Response(int nResponse)
+{
+ m_xDlg->response(nResponse);
+}
+
ScDPNumGroupInfo AbstractScDPNumGroupDlg_Impl::GetGroupInfo() const
{
return m_xDlg->GetGroupInfo();
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 5665bb6f5b22..72982aa56d1a 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -475,6 +475,7 @@ public:
virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override;
virtual PivotFunc GetFuncMask() const override;
virtual css::sheet::DataPilotFieldReference GetFieldRef() const override;
+ virtual void Response(int nResponse) override;
};
class AbstractScDPSubtotalDlg_Impl : public AbstractScDPSubtotalDlg
@@ -489,6 +490,7 @@ public:
virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override;
virtual PivotFunc GetFuncMask() const override;
virtual void FillLabelData( ScDPLabelData& rLabelData ) const override;
+ virtual void Response(int nResponse) override;
};
class AbstractScDPNumGroupDlg_Impl : public AbstractScDPNumGroupDlg
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
index a5279bc14c57..13aa1e9f8dc0 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
@@ -15,7 +15,6 @@
#include <vcl/event.hxx>
#include <pivot.hxx>
-#include <scabstdlg.hxx>
ScPivotLayoutTreeList::ScPivotLayoutTreeList(std::unique_ptr<weld::TreeView> xControl)
: ScPivotLayoutTreeListBase(std::move(xControl))
@@ -26,6 +25,11 @@ ScPivotLayoutTreeList::ScPivotLayoutTreeList(std::unique_ptr<weld::TreeView> xCo
ScPivotLayoutTreeList::~ScPivotLayoutTreeList()
{
+ if (mpSubtotalDlg)
+ {
+ mpSubtotalDlg->Response(RET_CANCEL);
+ mpSubtotalDlg.clear();
+ }
}
void ScPivotLayoutTreeList::Setup(ScPivotLayoutDialog* pParent, SvPivotTreeListType eType)
@@ -54,17 +58,17 @@ IMPL_LINK_NOARG(ScPivotLayoutTreeList, DoubleClickHdl, weld::TreeView&, bool)
maDataFieldNames.clear();
mpParent->PushDataFieldNames(maDataFieldNames);
- VclPtr<AbstractScDPSubtotalDlg> pDialog(
- pFactory->CreateScDPSubtotalDlg(mxControl.get(), mpParent->maPivotTableObject, rCurrentLabelData, rCurrentFunctionData, maDataFieldNames));
+ mpSubtotalDlg = pFactory->CreateScDPSubtotalDlg(mxControl.get(), mpParent->maPivotTableObject,
+ rCurrentLabelData, rCurrentFunctionData, maDataFieldNames);
- pDialog->StartExecuteAsync([this, pDialog, pCurrentItemValue, nCurrentColumn](int nResult) {
+ mpSubtotalDlg->StartExecuteAsync([this, pCurrentItemValue, nCurrentColumn](int nResult) {
if (nResult == RET_OK)
{
- pDialog->FillLabelData(mpParent->GetLabelData(nCurrentColumn));
- pCurrentItemValue->maFunctionData.mnFuncMask = pDialog->GetFuncMask();
+ mpSubtotalDlg->FillLabelData(mpParent->GetLabelData(nCurrentColumn));
+ pCurrentItemValue->maFunctionData.mnFuncMask = mpSubtotalDlg->GetFuncMask();
}
- pDialog->disposeOnce();
+ mpSubtotalDlg.disposeAndClear();
});
return true;
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
index 905a56857fa7..6b10fd8b953f 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
@@ -15,7 +15,6 @@
#include <vcl/event.hxx>
#include <pivot.hxx>
-#include <scabstdlg.hxx>
#include <globstr.hrc>
#include <scresid.hxx>
@@ -69,7 +68,13 @@ ScPivotLayoutTreeListData::ScPivotLayoutTreeListData(std::unique_ptr<weld::TreeV
}
ScPivotLayoutTreeListData::~ScPivotLayoutTreeListData()
-{}
+{
+ if (mpFunctionDlg)
+ {
+ mpFunctionDlg->Response(RET_CANCEL);
+ mpFunctionDlg.clear();
+ }
+}
IMPL_LINK_NOARG(ScPivotLayoutTreeListData, DoubleClickHdl, weld::TreeView&, bool)
{
@@ -85,17 +90,16 @@ IMPL_LINK_NOARG(ScPivotLayoutTreeListData, DoubleClickHdl, weld::TreeView&, bool
ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create();
- VclPtr<AbstractScDPFunctionDlg> pDialog(
- pFactory->CreateScDPFunctionDlg(mxControl.get(), mpParent->GetLabelDataVector(), rCurrentLabelData, rCurrentFunctionData));
+ mpFunctionDlg = pFactory->CreateScDPFunctionDlg(mxControl.get(), mpParent->GetLabelDataVector(), rCurrentLabelData, rCurrentFunctionData);
- pDialog->StartExecuteAsync([this, pDialog, pCurrentItemValue, rCurrentFunctionData,
+ mpFunctionDlg->StartExecuteAsync([this, pCurrentItemValue, rCurrentFunctionData,
rCurrentLabelData, nEntry](int nResult) mutable {
if (nResult == RET_OK)
{
- rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask();
- rCurrentLabelData.mnFuncMask = pDialog->GetFuncMask();
+ rCurrentFunctionData.mnFuncMask = mpFunctionDlg->GetFuncMask();
+ rCurrentLabelData.mnFuncMask = mpFunctionDlg->GetFuncMask();
- rCurrentFunctionData.maFieldRef = pDialog->GetFieldRef();
+ rCurrentFunctionData.maFieldRef = mpFunctionDlg->GetFieldRef();
ScDPLabelData& rDFData = mpParent->GetLabelData(rCurrentFunctionData.mnCol);
@@ -109,7 +113,7 @@ IMPL_LINK_NOARG(ScPivotLayoutTreeListData, DoubleClickHdl, weld::TreeView&, bool
mxControl->set_text(nEntry, sDataItemName);
}
- pDialog->disposeOnce();
+ mpFunctionDlg->disposeOnce();
});
return true;
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 4c03fd0ba7be..af4ecb1e0b5d 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -482,6 +482,16 @@ ScDPSubtotalDlg::ScDPSubtotalDlg(weld::Widget* pParent, ScDPObject& rDPObj,
ScDPSubtotalDlg::~ScDPSubtotalDlg()
{
+ CloseSubdialog();
+}
+
+void ScDPSubtotalDlg::CloseSubdialog()
+{
+ if (mxOptionsDlg && mxOptionsDlg->getDialog())
+ {
+ mxOptionsDlg->getDialog()->response(RET_CANCEL);
+ mxOptionsDlg = nullptr;
+ }
}
PivotFunc ScDPSubtotalDlg::GetFuncMask() const
@@ -544,6 +554,8 @@ void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScPivotFuncDa
IMPL_LINK(ScDPSubtotalDlg, ButtonClicked, weld::Button&, rButton, void)
{
+ CloseSubdialog();
+
if (&rButton == mxBtnOk.get())
response(RET_OK);
else
@@ -570,6 +582,7 @@ IMPL_LINK(ScDPSubtotalDlg, ClickHdl, weld::Button&, rBtn, void)
weld::DialogController::runAsync(mxOptionsDlg, [this](int nResult) {
if (nResult == RET_OK)
mxOptionsDlg->FillLabelData(maLabelData);
+ mxOptionsDlg = nullptr;
});
}
}
diff --git a/sc/source/ui/inc/PivotLayoutTreeList.hxx b/sc/source/ui/inc/PivotLayoutTreeList.hxx
index 9ae1695e2e8f..5b57b8910489 100644
--- a/sc/source/ui/inc/PivotLayoutTreeList.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeList.hxx
@@ -14,6 +14,7 @@
#include <memory>
#include <tools/solar.h>
#include "PivotLayoutTreeListBase.hxx"
+#include <scabstdlg.hxx>
class ScPivotLayoutTreeList : public ScPivotLayoutTreeListBase
{
@@ -21,6 +22,8 @@ private:
std::vector<std::unique_ptr<ScItemValue> > maItemValues;
std::vector<ScDPName> maDataFieldNames;
+ VclPtr<AbstractScDPSubtotalDlg> mpSubtotalDlg;
+
DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
DECL_LINK(DoubleClickHdl, weld::TreeView&, bool);
diff --git a/sc/source/ui/inc/PivotLayoutTreeListData.hxx b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
index c5a3fb07ce44..688175273529 100644
--- a/sc/source/ui/inc/PivotLayoutTreeListData.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
@@ -15,6 +15,7 @@
#include <tools/solar.h>
#include <vector>
#include <memory>
+#include <scabstdlg.hxx>
class ScPivotLayoutTreeListData final : public ScPivotLayoutTreeListBase
{
@@ -36,6 +37,8 @@ private:
void AdjustDuplicateCount(ScItemValue* pInputItemValue);
std::vector<std::unique_ptr<ScItemValue> > maDataItemValues;
+
+ VclPtr<AbstractScDPFunctionDlg> mpFunctionDlg;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
index f6e8cc0c5ed6..85442f172ce2 100644
--- a/sc/source/ui/inc/pvfundlg.hxx
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -107,6 +107,7 @@ public:
private:
void Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData );
+ void CloseSubdialog();
DECL_LINK( DblClickHdl, weld::TreeView&, bool );
DECL_LINK( RadioClickHdl, weld::Button&, void );