[Libreoffice-commits] core.git: include/sfx2 sfx2/source sw/inc sw/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Mar 22 13:21:13 UTC 2019
include/sfx2/basedlgs.hxx | 23 ++++++++++++---
include/sfx2/childwin.hxx | 6 ++--
sfx2/source/appl/childwin.cxx | 9 +++---
sfx2/source/appl/workwin.cxx | 4 +-
sfx2/source/dialog/basedlgs.cxx | 56 +++++++++++++++++++++++---------------
sfx2/source/inc/workwin.hxx | 8 ++---
sw/inc/swabstdlg.hxx | 4 +-
sw/source/ui/dialog/swdlgfact.cxx | 6 ++--
sw/source/ui/dialog/swdlgfact.hxx | 6 ++--
9 files changed, 75 insertions(+), 47 deletions(-)
New commits:
commit 7d0bd54bad1782f74c156aa667e875c33efee0c1
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Mar 20 21:18:04 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Mar 22 14:20:43 2019 +0100
refactor into a shareable base class
Change-Id: I5eb1f2b6b7b2dbc3bc675845730cb3aef1cab5f0
Reviewed-on: https://gerrit.libreoffice.org/69528
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index 6b86abed0b01..893481e2d4d5 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -111,8 +111,21 @@ class SFX2_DLLPUBLIC SfxDialogController : public weld::GenericDialogController
{
private:
DECL_DLLPRIVATE_STATIC_LINK(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*);
+
+ DECL_DLLPRIVATE_LINK(FocusInHdl, weld::Widget&, void);
+ DECL_DLLPRIVATE_LINK(FocusOutHdl, weld::Widget&, void);
+
public:
SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId);
+ // dialog gets focus
+ virtual void Activate() {}
+ // dialog loses focus
+ virtual void DeActivate() {}
+
+ // when the dialog has an associated SfxChildWin, typically for Modeless interaction
+ virtual void ChildWinDispose() {} // called from the associated SfxChildWin dtor
+ virtual void Close() {} // called by the SfxChildWin when the dialog is closed
+ virtual void EndDialog(); // called by the SfxChildWin to close the dialog
};
class SfxModelessDialog_Impl;
@@ -126,8 +139,6 @@ class SFX2_DLLPUBLIC SfxModelessDialogController : public SfxDialogController
void Init(SfxBindings *pBindinx, SfxChildWindow *pCW);
- DECL_DLLPRIVATE_LINK(FocusInHdl, weld::Widget&, void);
- DECL_DLLPRIVATE_LINK(FocusOutHdl, weld::Widget&, void);
protected:
SfxModelessDialogController(SfxBindings*, SfxChildWindow* pChildWin,
weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID);
@@ -135,11 +146,13 @@ protected:
public:
void FillInfo(SfxChildWinInfo&) const;
- virtual void Activate() {}
void Initialize (SfxChildWinInfo const * pInfo);
- void Close();
void DeInit();
- void EndDialog();
+ virtual void Close() override;
+ virtual void EndDialog() override;
+ virtual void Activate() override;
+ virtual void DeActivate() override;
+ virtual void ChildWinDispose() override;
SfxBindings& GetBindings() { return *m_pBindings; }
};
diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx
index b07c6d1cd983..8d99f20642de 100644
--- a/include/sfx2/childwin.hxx
+++ b/include/sfx2/childwin.hxx
@@ -146,7 +146,7 @@ class SFX2_DLLPUBLIC SfxChildWindow
VclPtr<vcl::Window> pParent; // parent window ( Topwindow )
sal_uInt16 const nType; // ChildWindow-Id
VclPtr<vcl::Window> pWindow; // actual contents
- std::shared_ptr<SfxModelessDialogController> xController; // actual contents
+ std::shared_ptr<SfxDialogController> xController; // actual contents
SfxChildAlignment eChildAlignment; // Current css::drawing::Alignment
std::unique_ptr< SfxChildWindow_Impl> pImpl; // Implementation data
std::unique_ptr<SfxChildWindowContext> pContext; // With context-sensitive ChildWindows:
@@ -162,9 +162,9 @@ public:
void Destroy();
vcl::Window* GetWindow() const
{ return pWindow; }
- void SetController(std::shared_ptr<SfxModelessDialogController> controller) { xController = controller; }
+ void SetController(std::shared_ptr<SfxDialogController> controller) { xController = controller; }
void ClearController() { xController.reset(); }
- std::shared_ptr<SfxModelessDialogController>& GetController() { return xController; }
+ std::shared_ptr<SfxDialogController>& GetController() { return xController; }
vcl::Window* GetParent() const
{ return pParent; }
SfxChildAlignment GetAlignment() const
diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index ca2919cf263e..6a02b5bacab6 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -196,12 +196,13 @@ SfxChildWindow::~SfxChildWindow()
pContext.reset();
ClearWorkwin();
if (xController)
- xController->DeInit();
- else
- pWindow.disposeAndClear();
+ {
+ xController->ChildWinDispose();
+ xController.reset();
+ }
+ pWindow.disposeAndClear();
}
-
std::unique_ptr<SfxChildWindow> SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
vcl::Window *pParent, SfxBindings* pBindings, SfxChildWinInfo const & rInfo)
{
diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx
index 529451920676..8e86d0300ba3 100644
--- a/sfx2/source/appl/workwin.cxx
+++ b/sfx2/source/appl/workwin.cxx
@@ -882,7 +882,7 @@ SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl( vcl::Window& rWindow,
return aChildren.back().get();
}
-SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl(std::shared_ptr<SfxModelessDialogController>& rController,
+SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl(std::shared_ptr<SfxDialogController>& rController,
SfxChildAlignment eAlign )
{
DBG_ASSERT( aChildren.size() < 255, "too many children" );
@@ -915,7 +915,7 @@ void SfxWorkWindow::ReleaseChild_Impl( vcl::Window& rWindow )
OSL_FAIL( "releasing unregistered child" );
}
-void SfxWorkWindow::ReleaseChild_Impl(SfxModelessDialogController& rController)
+void SfxWorkWindow::ReleaseChild_Impl(SfxDialogController& rController)
{
SfxChild_Impl *pChild = nullptr;
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index b5056df8b1a9..81ccb97b910e 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -408,8 +408,6 @@ SfxModelessDialogController::SfxModelessDialogController(SfxBindings* pBindinx,
: SfxDialogController(pParent, rUIXMLDescription, rID)
{
Init(pBindinx, pCW);
- m_xDialog->connect_focus_in(LINK(this, SfxModelessDialogController, FocusInHdl));
- m_xDialog->connect_focus_out(LINK(this, SfxModelessDialogController, FocusOutHdl));
}
void SfxModelessDialogController::Init(SfxBindings *pBindinx, SfxChildWindow *pCW)
@@ -423,35 +421,30 @@ void SfxModelessDialogController::Init(SfxBindings *pBindinx, SfxChildWindow *pC
m_xImpl->StartListening( *pBindinx );
}
-void SfxModelessDialogController::DeInit()
-{
- if (m_xImpl->pMgr)
- {
- WindowStateMask nMask = WindowStateMask::Pos | WindowStateMask::State;
- if (m_xDialog->get_resizable())
- nMask |= WindowStateMask::Width | WindowStateMask::Height;
- m_xImpl->aWinState = m_xDialog->get_window_state(nMask);
- GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SfxChildIdentifier::DOCKINGWINDOW, SfxDockingConfig::ALIGNDOCKINGWINDOW, m_xImpl->pMgr->GetType() );
- }
-
- m_xImpl->pMgr = nullptr;
-}
-
/* [Description]
If a ModelessDialog is enabled its ViewFrame will be activated.
This is necessary by PluginInFrames.
*/
-IMPL_LINK_NOARG(SfxModelessDialogController, FocusInHdl, weld::Widget&, void)
+IMPL_LINK_NOARG(SfxDialogController, FocusInHdl, weld::Widget&, void)
+{
+ Activate();
+}
+
+void SfxModelessDialogController::Activate()
{
if (!m_xImpl)
return;
m_pBindings->SetActiveFrame(m_xImpl->pMgr->GetFrame());
m_xImpl->pMgr->Activate_Impl();
- Activate();
}
-IMPL_LINK_NOARG(SfxModelessDialogController, FocusOutHdl, weld::Widget&, void)
+IMPL_LINK_NOARG(SfxDialogController, FocusOutHdl, weld::Widget&, void)
+{
+ DeActivate();
+}
+
+void SfxModelessDialogController::DeActivate()
{
if (!m_xImpl)
return;
@@ -469,15 +462,34 @@ SfxModelessDialogController::~SfxModelessDialogController()
m_pBindings->SetActiveFrame(nullptr);
}
-void SfxModelessDialogController::EndDialog()
+void SfxDialogController::EndDialog()
{
if (!m_xDialog->get_visible())
return;
- m_xImpl->bClosing = true;
response(RET_CLOSE);
+}
+
+void SfxModelessDialogController::EndDialog()
+{
+ m_xImpl->bClosing = true;
+ SfxDialogController::EndDialog();
m_xImpl->bClosing = false;
}
+void SfxModelessDialogController::ChildWinDispose()
+{
+ if (m_xImpl->pMgr)
+ {
+ WindowStateMask nMask = WindowStateMask::Pos | WindowStateMask::State;
+ if (m_xDialog->get_resizable())
+ nMask |= WindowStateMask::Width | WindowStateMask::Height;
+ m_xImpl->aWinState = m_xDialog->get_window_state(nMask);
+ GetBindings().GetWorkWindow_Impl()->ConfigChild_Impl( SfxChildIdentifier::DOCKINGWINDOW, SfxDockingConfig::ALIGNDOCKINGWINDOW, m_xImpl->pMgr->GetType() );
+ }
+
+ m_xImpl->pMgr = nullptr;
+}
+
/* [Description]
The window is closed when the ChildWindow is destroyed by running the
@@ -837,6 +849,8 @@ SfxDialogController::SfxDialogController(weld::Widget* pParent, const OUString&
: GenericDialogController(pParent, rUIFile, rDialogId)
{
m_xDialog->SetInstallLOKNotifierHdl(LINK(this, SfxDialogController, InstallLOKNotifierHdl));
+ m_xDialog->connect_focus_in(LINK(this, SfxDialogController, FocusInHdl));
+ m_xDialog->connect_focus_out(LINK(this, SfxDialogController, FocusOutHdl));
}
IMPL_STATIC_LINK_NOARG(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*)
diff --git a/sfx2/source/inc/workwin.hxx b/sfx2/source/inc/workwin.hxx
index 040065f62543..6b9894628e94 100644
--- a/sfx2/source/inc/workwin.hxx
+++ b/sfx2/source/inc/workwin.hxx
@@ -85,7 +85,7 @@ namespace o3tl
struct SfxChild_Impl
{
VclPtr<vcl::Window> pWin;
- std::shared_ptr<SfxModelessDialogController> xController;
+ std::shared_ptr<SfxDialogController> xController;
Size aSize;
SfxChildAlignment eAlign;
SfxChildVisibility nVisible;
@@ -100,7 +100,7 @@ struct SfxChild_Impl
nVisible = bIsVisible ? SfxChildVisibility::VISIBLE : SfxChildVisibility::NOT_VISIBLE;
}
- SfxChild_Impl(const std::shared_ptr<SfxModelessDialogController>& rChild,
+ SfxChild_Impl(const std::shared_ptr<SfxDialogController>& rChild,
SfxChildAlignment eAlignment):
pWin(nullptr), xController(rChild), eAlign(eAlignment), bResize(false),
bSetFocus( false )
@@ -249,9 +249,9 @@ public:
// Methods for all Child windows
void DataChanged_Impl();
void ReleaseChild_Impl( vcl::Window& rWindow );
- void ReleaseChild_Impl(SfxModelessDialogController&);
+ void ReleaseChild_Impl(SfxDialogController&);
SfxChild_Impl* RegisterChild_Impl( vcl::Window& rWindow, SfxChildAlignment eAlign );
- SfxChild_Impl* RegisterChild_Impl(std::shared_ptr<SfxModelessDialogController>& rController, SfxChildAlignment eAlign);
+ SfxChild_Impl* RegisterChild_Impl(std::shared_ptr<SfxDialogController>& rController, SfxChildAlignment eAlign);
void ShowChildren_Impl();
void HideChildren_Impl();
bool PrepareClose_Impl();
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 10d0fe9f882e..e6f3a5e714e3 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -203,7 +203,7 @@ protected:
public:
virtual void UpdateCounts() = 0;
virtual void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) = 0;
- virtual std::shared_ptr<SfxModelessDialogController> GetController() = 0;
+ virtual std::shared_ptr<SfxDialogController> GetController() = 0;
};
class AbstractSwInsertAbstractDlg : public VclAbstractDialog
@@ -338,7 +338,7 @@ protected:
virtual ~AbstractMarkFloatDlg() override = default;
public:
virtual void ReInitDlg(SwWrtShell& rWrtShell) = 0;
- virtual std::shared_ptr<SfxModelessDialogController> GetController() = 0;
+ virtual std::shared_ptr<SfxDialogController> GetController() = 0;
};
#define RET_LOAD_DOC 100
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 85cb3ad716b2..fb764f190916 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -674,7 +674,7 @@ void AbstractIndexMarkFloatDlg_Impl::ReInitDlg(SwWrtShell& rWrtShell)
m_xDlg->ReInitDlg( rWrtShell);
}
-std::shared_ptr<SfxModelessDialogController> AbstractIndexMarkFloatDlg_Impl::GetController()
+std::shared_ptr<SfxDialogController> AbstractIndexMarkFloatDlg_Impl::GetController()
{
return m_xDlg;
}
@@ -684,12 +684,12 @@ void AbstractAuthMarkFloatDlg_Impl::ReInitDlg(SwWrtShell& rWrtShell)
m_xDlg->ReInitDlg(rWrtShell);
}
-std::shared_ptr<SfxModelessDialogController> AbstractAuthMarkFloatDlg_Impl::GetController()
+std::shared_ptr<SfxDialogController> AbstractAuthMarkFloatDlg_Impl::GetController()
{
return m_xDlg;
}
-std::shared_ptr<SfxModelessDialogController> AbstractSwWordCountFloatDlg_Impl::GetController()
+std::shared_ptr<SfxDialogController> AbstractSwWordCountFloatDlg_Impl::GetController()
{
return m_xDlg;
}
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 3f51a2ca9eb8..d17ccab6a473 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -84,7 +84,7 @@ public:
virtual short Execute() override;
virtual void UpdateCounts() override;
virtual void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) override;
- virtual std::shared_ptr<SfxModelessDialogController> GetController() override;
+ virtual std::shared_ptr<SfxDialogController> GetController() override;
};
class AbstractSwInsertAbstractDlg_Impl : public AbstractSwInsertAbstractDlg
@@ -546,7 +546,7 @@ public:
}
virtual short Execute() override;
virtual void ReInitDlg(SwWrtShell& rWrtShell) override;
- virtual std::shared_ptr<SfxModelessDialogController> GetController() override;
+ virtual std::shared_ptr<SfxDialogController> GetController() override;
};
class SwAuthMarkFloatDlg;
@@ -560,7 +560,7 @@ public:
}
virtual short Execute() override;
virtual void ReInitDlg(SwWrtShell& rWrtShell) override;
- virtual std::shared_ptr<SfxModelessDialogController> GetController() override;
+ virtual std::shared_ptr<SfxDialogController> GetController() override;
};
class SwMailMergeWizard;
More information about the Libreoffice-commits
mailing list