summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-03-20 21:18:04 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-03-22 14:20:43 +0100
commit7d0bd54bad1782f74c156aa667e875c33efee0c1 (patch)
tree929357474beb322c71dc13fec316bef940d67308 /sfx2
parentf8efe7d63279900c7fd737cff5030dede870fac6 (diff)
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@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/childwin.cxx9
-rw-r--r--sfx2/source/appl/workwin.cxx4
-rw-r--r--sfx2/source/dialog/basedlgs.cxx56
-rw-r--r--sfx2/source/inc/workwin.hxx8
4 files changed, 46 insertions, 31 deletions
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();