[Libreoffice-commits] core.git: cui/source include/sfx2 sfx2/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Mar 12 19:42:51 UTC 2019
cui/source/tabpages/numfmt.cxx | 16 ++++------------
include/sfx2/basedlgs.hxx | 19 +++++++++++++++++--
include/sfx2/tabdlg.hxx | 18 +++++++-----------
sfx2/source/dialog/basedlgs.cxx | 2 +-
sfx2/source/dialog/tabdlg.cxx | 25 ++++++++++---------------
5 files changed, 39 insertions(+), 41 deletions(-)
New commits:
commit 47cf97743e1c648d74e7759b1e5ed57acec2f5a2
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Mar 12 16:16:02 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 12 20:42:23 2019 +0100
insert an intermediate class to inherit from
Change-Id: I77cc250197658fed57175b775976a3194050c0da
Reviewed-on: https://gerrit.libreoffice.org/69117
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index 94309d7b9dfb..964ca5d62111 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -1138,18 +1138,10 @@ IMPL_LINK(SvxNumberFormatTabPage, DoubleClickHdl_Impl, weld::TreeView&, rLb, voi
{
SelFormatHdl_Impl(&rLb);
- if (SfxTabDialogController* pController = GetDialogController())
- {
- weld::Button& rOkButton = pController->GetOKButton();
- rOkButton.clicked();
- }
- else
- {
- SfxSingleTabDialog* pParent = dynamic_cast<SfxSingleTabDialog*>(GetParentDialog());
- OKButton* pOKButton = pParent ? pParent->GetOKButton() : nullptr;
- if ( pOKButton )
- pOKButton->Click();
- }
+ SfxOkDialogController* pController = GetDialogController();
+ assert(pController);
+ weld::Button& rOkButton = pController->GetOKButton();
+ rOkButton.clicked();
}
diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index fc0a436301c3..0b3d526888b5 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -223,7 +223,20 @@ private:
std::unique_ptr<SingleTabDlgImpl> pImpl;
};
-class SFX2_DLLPUBLIC SfxSingleTabDialogController : public SfxDialogController
+class SFX2_DLLPUBLIC SfxOkDialogController : public SfxDialogController
+{
+public:
+ SfxOkDialogController(weld::Widget* pParent, const OUString& rUIXMLDescription,
+ const OString& rID)
+ : SfxDialogController(pParent, rUIXMLDescription, rID)
+ {
+ }
+
+ virtual weld::Button& GetOKButton() const = 0;
+ virtual const SfxItemSet* GetExampleSet() const = 0;
+};
+
+class SFX2_DLLPUBLIC SfxSingleTabDialogController : public SfxOkDialogController
{
private:
std::unique_ptr<SfxItemSet> m_xOutputSet;
@@ -239,7 +252,9 @@ public:
virtual ~SfxSingleTabDialogController() override;
void SetTabPage(SfxTabPage* pTabPage);
- weld::Button& GetOKButton() const { return *m_xOKBtn; }
+
+ virtual weld::Button& GetOKButton() const override { return *m_xOKBtn; }
+ virtual const SfxItemSet* GetExampleSet() const override { return nullptr; }
const SfxItemSet* GetOutputItemSet() const { return m_xOutputSet.get(); }
const SfxItemSet* GetInputItemSet() const { return m_pInputSet; }
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 33ff5175769e..e2395fd4fe1f 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -188,7 +188,7 @@ public:
virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override;
};
-class SFX2_DLLPUBLIC SfxTabDialogController : public SfxDialogController
+class SFX2_DLLPUBLIC SfxTabDialogController : public SfxOkDialogController
{
protected:
std::unique_ptr<weld::Notebook> m_xTabCtrl;
@@ -269,13 +269,9 @@ public:
void SetInputSet( const SfxItemSet* pInSet );
const SfxItemSet* GetOutputItemSet() const { return m_pOutSet.get(); }
- const weld::Button& GetOKButton() const { return *m_xOKBtn; }
- weld::Button& GetOKButton() { return *m_xOKBtn; }
- const weld::Button& GetCancelButton() const { return *m_xCancelBtn; }
- weld::Button& GetCancelButton() { return *m_xCancelBtn; }
-
- const weld::Button* GetUserButton() const { return m_xUserBtn.get(); }
- weld::Button* GetUserButton() { return m_xUserBtn.get(); }
+ virtual weld::Button& GetOKButton() const override { return *m_xOKBtn; }
+ weld::Button& GetCancelButton() const { return *m_xCancelBtn; }
+ weld::Button* GetUserButton() const { return m_xUserBtn.get(); }
void RemoveResetButton();
void RemoveStandardButton();
@@ -283,7 +279,7 @@ public:
static bool runAsync(const std::shared_ptr<SfxTabDialogController>& rController,
const std::function<void(sal_Int32)>&);
- const SfxItemSet* GetExampleSet() const { return m_xExampleSet.get(); }
+ virtual const SfxItemSet* GetExampleSet() const override { return m_xExampleSet.get(); }
void SetApplyHandler(const Link<weld::Button&,void>& _rHdl);
@@ -333,10 +329,10 @@ protected:
}
SfxTabDialog* GetTabDialog() const;
- SfxTabDialogController* GetDialogController() const;
+ SfxOkDialogController* GetDialogController() const;
public:
void SetTabDialog(SfxTabDialog* pDialog);
- void SetDialogController(SfxTabDialogController* pDialog);
+ void SetDialogController(SfxOkDialogController* pDialog);
public:
virtual ~SfxTabPage() override;
virtual void dispose() override;
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 74e7e3a00844..07af730ace62 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -846,7 +846,7 @@ IMPL_STATIC_LINK_NOARG(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::I
SfxSingleTabDialogController::SfxSingleTabDialogController(weld::Widget *pParent, const SfxItemSet& rSet,
const OUString& rUIXMLDescription, const OString& rID)
- : SfxDialogController(pParent, rUIXMLDescription, rID)
+ : SfxOkDialogController(pParent, rUIXMLDescription, rID)
, m_pInputSet(&rSet)
, m_xContainer(m_xDialog->weld_content_area())
, m_xOKBtn(m_xBuilder->weld_button("ok"))
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 5338b6e924d0..3ccc31662287 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -51,11 +51,10 @@ struct TabPageImpl
{
bool mbStandard;
VclPtr<SfxTabDialog> mxDialog;
- weld::DialogController* mpDialogController;
- SfxTabDialogController* mpTabDialogController;
+ SfxOkDialogController* mpDialogController;
css::uno::Reference< css::frame::XFrame > mxFrame;
- TabPageImpl() : mbStandard(false), mpDialogController(nullptr), mpTabDialogController(nullptr) {}
+ TabPageImpl() : mbStandard(false), mpDialogController(nullptr) {}
};
struct Data_Impl
@@ -191,7 +190,7 @@ SfxTabPage::SfxTabPage(TabPageParent pParent, const OUString& rUIXMLDescription,
: Application::CreateInterimBuilder(this, rUIXMLDescription))
, m_xContainer(m_xBuilder->weld_container(rID))
{
- pImpl->mpDialogController = pParent.pController;
+ pImpl->mpDialogController = dynamic_cast<SfxOkDialogController*>(pParent.pController);
}
SfxTabPage::~SfxTabPage()
@@ -335,15 +334,14 @@ SfxTabDialog* SfxTabPage::GetTabDialog() const
return pImpl->mxDialog;
}
-void SfxTabPage::SetDialogController(SfxTabDialogController* pDialog)
+void SfxTabPage::SetDialogController(SfxOkDialogController* pDialog)
{
- pImpl->mpTabDialogController = pDialog;
- pImpl->mpDialogController = pImpl->mpTabDialogController;
+ pImpl->mpDialogController = pDialog;
}
-SfxTabDialogController* SfxTabPage::GetDialogController() const
+SfxOkDialogController* SfxTabPage::GetDialogController() const
{
- return pImpl->mpTabDialogController;
+ return pImpl->mpDialogController;
}
OString SfxTabPage::GetConfigId() const
@@ -359,17 +357,14 @@ OString SfxTabPage::GetConfigId() const
weld::Window* SfxTabPage::GetDialogFrameWeld() const
{
if (pImpl->mpDialogController)
- {
- assert(pImpl->mpTabDialogController == pImpl->mpDialogController || !pImpl->mpTabDialogController);
return pImpl->mpDialogController->getDialog();
- }
return GetFrameWeld();
}
const SfxItemSet* SfxTabPage::GetDialogExampleSet() const
{
- if (pImpl->mpTabDialogController)
- return pImpl->mpTabDialogController->GetExampleSet();
+ if (pImpl->mpDialogController)
+ return pImpl->mpDialogController->GetExampleSet();
if (pImpl->mxDialog)
return pImpl->mxDialog->GetExampleSet();
return nullptr;
@@ -1371,7 +1366,7 @@ SfxTabDialogController::SfxTabDialogController
// can be NULL, when Pages are onDemand
bool bEditFmt // when yes -> additional Button for standard
)
- : SfxDialogController(pParent, rUIXMLDescription, rID)
+ : SfxOkDialogController(pParent, rUIXMLDescription, rID)
, m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
, m_xOKBtn(m_xBuilder->weld_button("ok"))
, m_xApplyBtn(m_xBuilder->weld_button("apply"))
More information about the Libreoffice-commits
mailing list