From 072e3ce1cfea5bb61cc5f3001c288df6deb45613 Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Thu, 11 Jan 2018 13:31:36 -0400 Subject: [PATCH] lok dialog: enable MessageDialog tunneling Change-Id: I05b270a19e29c5ed3a2482fd8163e61e66bfdf74 Reviewed-on: https://gerrit.libreoffice.org/47772 Reviewed-by: pranavk Tested-by: pranavk --- include/sfx2/basedlgs.hxx | 1 - include/vcl/dialog.hxx | 1 + include/vcl/window.hxx | 2 +- sfx2/source/dialog/basedlgs.cxx | 24 ------------------------ sfx2/source/dialog/tabdlg.cxx | 21 --------------------- sfx2/source/view/viewfrm.cxx | 5 +++++ sfx2/source/view/viewsh.cxx | 9 +++++++++ translations | 2 +- vcl/source/window/dialog.cxx | 37 +++++++++++++++++++++++++++++++++++++ vcl/source/window/window.cxx | 19 ++++++++++--------- 10 files changed, 64 insertions(+), 57 deletions(-) diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx index db885c7173a2..670fc10f7238 100644 --- a/include/sfx2/basedlgs.hxx +++ b/include/sfx2/basedlgs.hxx @@ -72,7 +72,6 @@ public: virtual ~SfxModalDialog() override; virtual void dispose() override; - virtual short Execute() override; const SfxItemSet* GetOutputItemSet() const { return pOutputSet; } const SfxItemSet* GetInputItemSet() const { return pInputSet; } void StateChanged( StateChangedType nStateChange ) override; diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 7fe00ba1c8c3..eaf9bbe99960 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -60,6 +60,7 @@ private: SAL_DLLPRIVATE void RemoveFromDlgList(); SAL_DLLPRIVATE void ImplInitDialogData(); SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE inline void ImplLOKNotifier(vcl::Window* pParent); SAL_DLLPRIVATE VclPtr AddBorderWindow(vcl::Window* pParent, WinBits nBits); virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 528ba110bd04..3fe40355bab3 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1209,7 +1209,7 @@ public: void SetComponentInterface( css::uno::Reference< css::awt::XWindowPeer > const & xIFace ); /// Interface to register for dialog / window tunneling. - void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier); + void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier, bool bParent = false); const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const; vcl::LOKWindowId GetLOKWindowId() const; diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 5379702e7d0a..9ed41424e133 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -161,33 +161,9 @@ void SfxModalDialog::dispose() SetDialogData_Impl(); delete pOutputSet; - if (comphelper::LibreOfficeKit::isActive() && GetLOKNotifier()) - { - SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "close"); - ReleaseLOKNotifier(); - } - ModalDialog::dispose(); } -short SfxModalDialog::Execute() -{ - SfxViewShell* pViewShell = SfxViewShell::Current(); - if (comphelper::LibreOfficeKit::isActive() && pViewShell && !GetLOKNotifier()) - { - SetLOKNotifier(pViewShell); - const Size aSize = GetOptimalSize(); - std::vector aItems; - aItems.emplace_back("type", "dialog"); - aItems.emplace_back("size", aSize.toString()); - if (!GetText().isEmpty()) - aItems.emplace_back("title", GetText().toUtf8()); - pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems); - } - - return ModalDialog::Execute(); -} - void SfxModalDialog::CreateOutputItemSet( SfxItemPool& rPool ) { DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" ); diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index dea1658092fe..4eb7a29d1c49 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -403,13 +403,6 @@ void SfxTabDialog::dispose() m_pBaseFmtBtn.clear(); m_pActionArea.clear(); - SfxViewShell* pViewShell = SfxViewShell::Current(); - if (comphelper::LibreOfficeKit::isActive() && pViewShell) - { - pViewShell->notifyWindow(GetLOKWindowId(), "close"); - ReleaseLOKNotifier(); - } - TabDialog::dispose(); } @@ -587,20 +580,6 @@ void SfxTabDialog::Start_Impl() m_pTabCtrl->SetCurPageId( nActPage ); ActivatePageHdl( m_pTabCtrl ); - - SfxViewShell* pViewShell = SfxViewShell::Current(); - - if (comphelper::LibreOfficeKit::isActive() && pViewShell && !GetLOKNotifier()) - { - SetLOKNotifier(pViewShell); - const Size aSize = GetOptimalSize(); - std::vector aItems; - aItems.emplace_back("type", "dialog"); - aItems.emplace_back("size", aSize.toString()); - if (!GetText().isEmpty()) - aItems.emplace_back("title", GetText().toUtf8()); - pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems); - } } void SfxTabDialog::AddTabPage( sal_uInt16 nId, const OUString &rRiderText ) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 149b24b89826..de705dc9ff61 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1261,8 +1261,13 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } case SfxHintId::Deinitializing: + { + if (GetWindow().GetLOKNotifier()) + GetWindow().ReleaseLOKNotifier(); + GetFrame().DoClose(); break; + } case SfxHintId::Dying: // when the Object is being deleted, destroy the view too if ( m_xObjSh.is() ) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 0f05946039f2..c64a50031119 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1072,6 +1072,9 @@ SfxViewShell::SfxViewShell // Insert into list SfxViewShellArr_Impl &rViewArr = SfxGetpApp()->GetViewShells_Impl(); rViewArr.push_back(this); + + if (comphelper::LibreOfficeKit::isActive()) + pViewFrame->GetWindow().SetLOKNotifier(this, true); } @@ -1095,6 +1098,9 @@ SfxViewShell::~SfxViewShell() pImpl->m_pController->ReleaseShell_Impl(); pImpl->m_pController.clear(); } + + if (GetViewFrame()->GetWindow().GetLOKNotifier()) + GetViewFrame()->GetWindow().ReleaseLOKNotifier(); } bool SfxViewShell::PrepareClose @@ -1102,6 +1108,9 @@ bool SfxViewShell::PrepareClose bool bUI // TRUE: Allow Dialog and so on, FALSE: silent-mode ) { + if (GetViewFrame()->GetWindow().GetLOKNotifier()) + GetViewFrame()->GetWindow().ReleaseLOKNotifier(); + SfxPrinter *pPrinter = GetPrinter(); if ( pPrinter && pPrinter->IsPrinting() ) { diff --git a/translations b/translations index 4c9058997dff..4e3651a5d0e1 160000 --- a/translations +++ b/translations @@ -1 +1 @@ -Subproject commit 4c9058997dff2f568d90ead5d9b50fc92b1281cc +Subproject commit 4e3651a5d0e16bd39067227b9279f5cc98fbc127 diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 972b6671f0ed..c61a41be32f1 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -489,6 +489,17 @@ void Dialog::ImplInitSettings() SetBackground(GetSettings().GetStyleSettings().GetDialogColor()); } +void Dialog::ImplLOKNotifier(vcl::Window* pParent) +{ + if (comphelper::LibreOfficeKit::isActive() && pParent) + { + if (VclPtr pWin = pParent->GetParentWithLOKNotifier()) + { + SetLOKNotifier(pWin->GetLOKNotifier()); + } + } +} + Dialog::Dialog( WindowType nType ) : SystemWindow( nType ) , mbForceBorderWindow(false) @@ -525,6 +536,7 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML , mbForceBorderWindow(false) , mnInitFlag(InitFlag::Default) { + ImplLOKNotifier(pParent); ImplInitDialogData(); loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription); } @@ -534,6 +546,7 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML , mbForceBorderWindow(bBorder) , mnInitFlag(eFlag) { + ImplLOKNotifier(pParent); ImplInitDialogData(); loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription); } @@ -543,6 +556,7 @@ Dialog::Dialog(vcl::Window* pParent, WinBits nStyle, InitFlag eFlag) , mbForceBorderWindow(false) , mnInitFlag(eFlag) { + ImplLOKNotifier(pParent); ImplInitDialogData(); ImplInit( pParent, nStyle, eFlag ); } @@ -593,6 +607,15 @@ void Dialog::dispose() xEventBroadcaster->documentEventOccured(aObject); UITestLogger::getInstance().log("DialogClosed"); + if (comphelper::LibreOfficeKit::isActive()) + { + if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + { + pNotifier->notifyWindow(GetLOKWindowId(), "close"); + ReleaseLOKNotifier(); + } + } + SystemWindow::dispose(); } @@ -859,6 +882,20 @@ bool Dialog::ImplStartExecuteModal() xEventBroadcaster->documentEventOccured(aObject); UITestLogger::getInstance().log("DialogExecute"); + if (comphelper::LibreOfficeKit::isActive()) + { + if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + { + const Size aSize = GetOptimalSize(); + std::vector aItems; + aItems.emplace_back("type", "dialog"); + aItems.emplace_back("size", aSize.toString()); + if (!GetText().isEmpty()) + aItems.emplace_back("title", GetText().toUtf8()); + pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems); + } + } + return true; } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index f1ee1d744baa..aedd405f1c04 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -3177,19 +3177,22 @@ LOKWindowsMap& GetLOKWindowsMap() } -void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier) +void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier, bool bParent) { // don't allow setting this twice assert(mpWindowImpl->mpLOKNotifier == nullptr); assert(pNotifier); - // Counter to be able to have unique id's for each window. - static vcl::LOKWindowId sLastLOKWindowId = 1; + if (!bParent) + { + // Counter to be able to have unique id's for each window. + static vcl::LOKWindowId sLastLOKWindowId = 1; - // assign the LOK window id - assert(mpWindowImpl->mnLOKWindowId == 0); - mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++; - GetLOKWindowsMap().insert(std::map>::value_type(mpWindowImpl->mnLOKWindowId, this)); + // assign the LOK window id + assert(mpWindowImpl->mnLOKWindowId == 0); + mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++; + GetLOKWindowsMap().insert(std::map>::value_type(mpWindowImpl->mnLOKWindowId, this)); + } mpWindowImpl->mpLOKNotifier = pNotifier; } @@ -3220,8 +3223,6 @@ const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const vcl::LOKWindowId Window::GetLOKWindowId() const { - assert(mpWindowImpl->mnLOKWindowId > 0); - return mpWindowImpl->mnLOKWindowId; } -- 2.11.4.GIT