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 | 3 +++ sfx2/source/view/viewsh.cxx | 9 +++++++++ vcl/source/window/dialog.cxx | 37 +++++++++++++++++++++++++++++++++++++ vcl/source/window/window.cxx | 19 ++++++++++--------- 9 files changed, 61 insertions(+), 56 deletions(-)
New commits: commit 20459ed3996781788ca7581d21d8c25b0c2b85d0 Author: Henry Castro <[email protected]> Date: Thu Jan 11 13:31:36 2018 -0400 lok dialog: enable MessageDialog tunneling (cherry picked from commit 18dcf1dca74123659a9fe786921915f7307da147) Change-Id: I344530471c650b3b70c5c9900d86df735c09a09d Reviewed-on: https://gerrit.libreoffice.org/48122 Reviewed-by: pranavk <[email protected]> Tested-by: pranavk <[email protected]> Reviewed-by: Jan Holesovsky <[email protected]> Tested-by: Jan Holesovsky <[email protected]> diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx index 88b20c6d87a1..2cf08407d3be 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 7a69b6c48618..92bf603400f6 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -53,6 +53,7 @@ private: SAL_DLLPRIVATE void RemoveFromDlgList(); SAL_DLLPRIVATE void ImplInitDialogData(); SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE inline void ImplLOKNotifier(vcl::Window* pParent); virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index a46e7569e74f..7f15b5dac267 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1205,7 +1205,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 41db15950eb4..729e1fbbdb97 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -167,33 +167,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<vcl::LOKPayloadItem> 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 c2228856465b..28dff535463c 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -405,13 +405,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(); } @@ -589,20 +582,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<vcl::LOKPayloadItem> 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 977efc4566d9..f789a2f74931 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1320,6 +1320,9 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } case SFX_HINT_DEINITIALIZING: + if (GetWindow().GetLOKNotifier()) + GetWindow().ReleaseLOKNotifier(); + GetFrame().DoClose(); break; case SFX_HINT_DYING: diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 4b50b2d8cafc..c018aa6ce001 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1117,6 +1117,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); } @@ -1140,6 +1143,9 @@ SfxViewShell::~SfxViewShell() pImpl->m_pController->ReleaseShell_Impl(); pImpl->m_pController.clear(); } + + if (GetViewFrame()->GetWindow().GetLOKNotifier()) + GetViewFrame()->GetWindow().ReleaseLOKNotifier(); } bool SfxViewShell::PrepareClose @@ -1147,6 +1153,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/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 1fe977961d74..d2d20d1ef7cd 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -482,6 +482,17 @@ void Dialog::ImplInitSettings() SetBackground(GetSettings().GetStyleSettings().GetDialogColor()); } +void Dialog::ImplLOKNotifier(vcl::Window* pParent) +{ + if (comphelper::LibreOfficeKit::isActive() && pParent) + { + if (VclPtr<vcl::Window> pWin = pParent->GetParentWithLOKNotifier()) + { + SetLOKNotifier(pWin->GetLOKNotifier()); + } + } +} + Dialog::Dialog( WindowType nType ) : SystemWindow( nType ) , mnInitFlag(InitFlag::Default) @@ -531,6 +542,7 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML : SystemWindow(WINDOW_DIALOG) , mnInitFlag(InitFlag::Default) { + ImplLOKNotifier(pParent); ImplInitDialogData(); loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription); } @@ -539,6 +551,7 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML : SystemWindow(nType) , mnInitFlag(eFlag) { + ImplLOKNotifier(pParent); ImplInitDialogData(); loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription); } @@ -547,6 +560,7 @@ Dialog::Dialog(vcl::Window* pParent, WinBits nStyle, InitFlag eFlag) : SystemWindow(WINDOW_DIALOG) , mnInitFlag(eFlag) { + ImplLOKNotifier(pParent); ImplInitDialogData(); ImplInit( pParent, nStyle, eFlag ); } @@ -599,6 +613,15 @@ void Dialog::dispose() aObject.EventName = "DialogClosed"; xEventBroadcaster->documentEventOccured(aObject); + if (comphelper::LibreOfficeKit::isActive()) + { + if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + { + pNotifier->notifyWindow(GetLOKWindowId(), "close"); + ReleaseLOKNotifier(); + } + } + SystemWindow::dispose(); } @@ -868,6 +891,20 @@ bool Dialog::ImplStartExecuteModal() aObject.EventName = "DialogExecute"; xEventBroadcaster->documentEventOccured(aObject); + if (comphelper::LibreOfficeKit::isActive()) + { + if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + { + const Size aSize = GetOptimalSize(); + std::vector<vcl::LOKPayloadItem> 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 f0ab681f421f..4b3384f02756 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -3214,19 +3214,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<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this)); + // assign the LOK window id + assert(mpWindowImpl->mnLOKWindowId == 0); + mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++; + GetLOKWindowsMap().insert(std::map<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this)); + } mpWindowImpl->mpLOKNotifier = pNotifier; } @@ -3257,8 +3260,6 @@ const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const vcl::LOKWindowId Window::GetLOKWindowId() const { - assert(mpWindowImpl->mnLOKWindowId > 0); - return mpWindowImpl->mnLOKWindowId; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
