diff options
author | Jan Holesovsky <kendy@collabora.com> | 2017-11-24 10:20:47 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-11-29 10:16:56 +0100 |
commit | ba8154d857aa815ba3c5b52987dc17be6eba7f48 (patch) | |
tree | b1fe470f5123b1a15a4fb128cc706ff197ee3e2a | |
parent | f2b6bffdedb12983d4ca2bab21fb68eeb3c3d08d (diff) |
lokdialog: Move the Notifier down to vcl::Window.
We need to tunnel more than just dialogs, so this is the 1st step to get the
Autofilter popup rendered.
Change-Id: I6523a39ddc7a6eb2a204e48ab364130a5822f548
-rw-r--r-- | include/sfx2/lokhelper.hxx | 4 | ||||
-rw-r--r-- | include/sfx2/viewsh.hxx | 16 | ||||
-rw-r--r-- | include/vcl/IDialogRenderable.hxx | 24 | ||||
-rw-r--r-- | include/vcl/dialog.hxx | 8 | ||||
-rw-r--r-- | include/vcl/window.hxx | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/basedlgs.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 14 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 24 | ||||
-rw-r--r-- | vcl/inc/window.h | 4 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 50 | ||||
-rw-r--r-- | vcl/source/window/floatwin.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 20 | ||||
-rw-r--r-- | vcl/source/window/winproc.cxx | 4 |
16 files changed, 122 insertions, 110 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 24e59d097393..170d65a794d0 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -42,11 +42,11 @@ public: /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them. static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload); /// Emits a LOK_CALLBACK_DIALOG - static void notifyDialog(vcl::DialogID nDialogId, + static void notifyDialog(vcl::LOKWindowId nDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()); /// Emits a LOK_CALLBACK_DIALOG_CHILD - static void notifyDialogChild(vcl::DialogID nDialogId, const OUString& rAction, const Point& rPos); + static void notifyDialogChild(vcl::LOKWindowId nDialogId, const OUString& rAction, const Point& rPos); /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed. static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload); /// A special value to signify 'infinity'. diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index e6687ff7d5a7..2fcf7283399a 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -142,7 +142,7 @@ template<class T> bool checkSfxViewShell(const SfxViewShell* pShell) return dynamic_cast<const T*>(pShell) != nullptr; } -class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell, public vcl::IDialogNotifier +class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener, public OutlinerViewShell, public vcl::ILibreOfficeKitNotifier { friend class SfxViewFrame; friend class SfxBaseController; @@ -153,7 +153,7 @@ friend class SfxPrinterController; VclPtr<vcl::Window> pWindow; bool bNoNewWindow; bool mbPrinterSettingsModified; - std::vector<std::pair<vcl::DialogID, VclPtr<Dialog> > > maOpenedDialogs; + std::vector<std::pair<vcl::LOKWindowId, VclPtr<Dialog> > > maOpenedDialogs; protected: virtual void Activate(bool IsMDIActivate) override; @@ -222,13 +222,13 @@ public: virtual SfxShell* GetFormShell() { return nullptr; }; virtual const SfxShell* GetFormShell() const { return nullptr; }; - void RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg); - VclPtr<Dialog> GetOpenedDlg(vcl::DialogID nDialogId); - void UnregisterDlg(vcl::DialogID nDialogId); + void RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg); + VclPtr<Dialog> GetOpenedDlg(vcl::LOKWindowId nDialogId); + void UnregisterDlg(vcl::LOKWindowId nDialogId); - // IDialogNotifier - virtual void notifyDialog(const vcl::DialogID& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) override; - virtual void notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos) override; + // ILibreOfficeKitNotifier + virtual void notifyDialog(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override; + virtual void notifyDialogChild(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const Point& rPos) const override; // Focus, KeyInput, Cursor virtual void ShowCursor( bool bOn = true ); diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx index f606782692e3..20515c86d2a6 100644 --- a/include/vcl/IDialogRenderable.hxx +++ b/include/vcl/IDialogRenderable.hxx @@ -23,41 +23,39 @@ namespace vcl typedef std::pair<const OString, const OString> LOKPayloadItem; -typedef sal_uInt32 DialogID; - class VCL_DLLPUBLIC IDialogRenderable { public: virtual ~IDialogRenderable(); - virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice) = 0; + virtual void paintDialog(const LOKWindowId& rLOKWindowId, VirtualDevice &rDevice) = 0; - virtual void getDialogInfo(const DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight) = 0; + virtual void getDialogInfo(const LOKWindowId& rLOKWindowId, OUString& rDialogTitle, int& rWidth, int& rHeight) = 0; - virtual void paintActiveFloatingWindow(const DialogID& rDialogID, VirtualDevice &rDevice, + virtual void paintActiveFloatingWindow(const LOKWindowId& rLOKWindowId, VirtualDevice &rDevice, int& nOutputWidth, int& nOutputHeight) = 0; - virtual void postDialogKeyEvent(const DialogID& rDialogID, int nType, + virtual void postDialogKeyEvent(const LOKWindowId& rLOKWindowId, int nType, int nCharCode, int nKeyCode) = 0; - virtual void postDialogMouseEvent(const DialogID& rDialogID, int nType, int nX, int nY, + virtual void postDialogMouseEvent(const LOKWindowId& rLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier) = 0; - virtual void postDialogChildMouseEvent(const DialogID& rDialogID, int nType, int nX, int nY, + virtual void postDialogChildMouseEvent(const LOKWindowId& rLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier) = 0; }; -class VCL_DLLPUBLIC IDialogNotifier +class VCL_DLLPUBLIC ILibreOfficeKitNotifier { public: - virtual ~IDialogNotifier() {} + virtual ~ILibreOfficeKitNotifier() {} // Callbacks - virtual void notifyDialog(const DialogID& rDialogID, + virtual void notifyDialog(const LOKWindowId& rLOKWindowId, const OUString& rAction, - const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) = 0; + const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) const = 0; - virtual void notifyDialogChild(const DialogID& rDialogID, const OUString& rAction, const Point& rPos) = 0; + virtual void notifyDialogChild(const LOKWindowId& rLOKWindowId, const OUString& rAction, const Point& rPos) const = 0; }; } // namespace vcl diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index e4d9f88f6d83..4347917b7675 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -57,10 +57,6 @@ private: VclPtr<VclButtonBox> mpActionArea; VclPtr<VclBox> mpContentArea; - vcl::IDialogNotifier* mpDialogNotifier; // to emit LOK callbacks - - static vcl::DialogID mnLastDialogId; - SAL_DLLPRIVATE void ImplInitDialogData(); SAL_DLLPRIVATE void ImplInitSettings(); SAL_DLLPRIVATE VclPtr<vcl::Window> AddBorderWindow(vcl::Window* pParent, WinBits nBits); @@ -75,10 +71,6 @@ private: protected: using Window::ImplInit; SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default ); - /// Dialog ID (used for LOK) - vcl::DialogID maID; - /// Necessary to register dialog notifier instance to emit LOK callbacks - void registerDialogNotifier(vcl::IDialogNotifier* pDialogNotifier); public: SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; } diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 42cbfcc79df9..be9d88d48adc 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -430,6 +430,7 @@ const char* ImplDbgCheckWindow( const void* pObj ); namespace vcl { class Window; } namespace vcl { class Cursor; } +namespace vcl { class ILibreOfficeKitNotifier; } class Dialog; class WindowImpl; class PaintHelper; @@ -488,6 +489,8 @@ public: Color const * pPaintColor = nullptr); }; +typedef sal_uInt32 LOKWindowId; + class VCL_DLLPUBLIC Window : public ::OutputDevice { friend class ::vcl::Cursor; @@ -1200,6 +1203,11 @@ public: void SetComponentInterface( css::uno::Reference< css::awt::XWindowPeer > const & xIFace ); + /// Interface to register for dialog tunneling. + void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier); + const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const; + vcl::LOKWindowId GetLOKWindowId() const; + /** @name Accessibility */ ///@{ diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 73a110038d95..9d30c8596e33 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -164,8 +164,8 @@ void SfxModalDialog::dispose() SfxViewShell* pViewShell = SfxViewShell::Current(); if (comphelper::LibreOfficeKit::isActive() && pViewShell) { - pViewShell->notifyDialog(maID, "close"); - pViewShell->UnregisterDlg(maID); + pViewShell->notifyDialog(GetLOKWindowId(), "close"); + pViewShell->UnregisterDlg(GetLOKWindowId()); } ModalDialog::dispose(); @@ -176,12 +176,12 @@ short SfxModalDialog::Execute() SfxViewShell* pViewShell = SfxViewShell::Current(); if (comphelper::LibreOfficeKit::isActive() && pViewShell) { - pViewShell->RegisterDlg(maID, this); - registerDialogNotifier(static_cast<vcl::IDialogNotifier*>(pViewShell)); + pViewShell->RegisterDlg(GetLOKWindowId(), this); + SetLOKNotifier(pViewShell); const Size aSize = GetOptimalSize(); std::vector<vcl::LOKPayloadItem> aItems; aItems.emplace_back(std::make_pair("size", aSize.toString())); - pViewShell->notifyDialog(maID, "created", aItems); + pViewShell->notifyDialog(GetLOKWindowId(), "created", aItems); } return ModalDialog::Execute(); @@ -248,14 +248,14 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange ) SfxViewShell* pViewShell = SfxViewShell::Current(); if (comphelper::LibreOfficeKit::isActive() && pViewShell) { - pViewShell->RegisterDlg(maID, this); - registerDialogNotifier(static_cast<vcl::IDialogNotifier*>(pViewShell)); + pViewShell->RegisterDlg(GetLOKWindowId(), this); + SetLOKNotifier(pViewShell); // Below method doesn't really give the exact dimensions, // Check GetSizePixel() ? const Size aOptimalSize = GetOptimalSize(); std::vector<vcl::LOKPayloadItem> aItems; aItems.emplace_back(std::make_pair("size", aOptimalSize.toString())); - pViewShell->notifyDialog(maID, "created", aItems); + pViewShell->notifyDialog(GetLOKWindowId(), "created", aItems); } pImpl->bConstructed = true; @@ -393,8 +393,8 @@ void SfxModelessDialog::dispose() SfxViewShell* pViewShell = SfxViewShell::Current(); if (comphelper::LibreOfficeKit::isActive() && pViewShell) { - pViewShell->notifyDialog(maID, "close"); - pViewShell->UnregisterDlg(maID); + pViewShell->notifyDialog(GetLOKWindowId(), "close"); + pViewShell->UnregisterDlg(GetLOKWindowId()); } ModelessDialog::dispose(); diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 17f64d51a063..a12d76a14ae1 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -406,8 +406,8 @@ void SfxTabDialog::dispose() SfxViewShell* pViewShell = SfxViewShell::Current(); if (comphelper::LibreOfficeKit::isActive() && pViewShell) { - pViewShell->notifyDialog(maID, "close"); - pViewShell->UnregisterDlg(maID); + pViewShell->notifyDialog(GetLOKWindowId(), "close"); + pViewShell->UnregisterDlg(GetLOKWindowId()); } TabDialog::dispose(); @@ -521,12 +521,12 @@ short SfxTabDialog::Execute() SfxViewShell* pViewShell = SfxViewShell::Current(); if (comphelper::LibreOfficeKit::isActive() && pViewShell) { - pViewShell->RegisterDlg(maID, this); - registerDialogNotifier(static_cast<vcl::IDialogNotifier*>(pViewShell)); + pViewShell->RegisterDlg(GetLOKWindowId(), this); + SetLOKNotifier(pViewShell); const Size aSize = GetOptimalSize(); std::vector<vcl::LOKPayloadItem> aItems; aItems.emplace_back(std::make_pair("size", aSize.toString())); - pViewShell->notifyDialog(maID, "created", aItems); + pViewShell->notifyDialog(GetLOKWindowId(), "created", aItems); } return TabDialog::Execute(); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 9af028916b69..cfd9041ab421 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -144,15 +144,15 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS } } -void SfxLokHelper::notifyDialog(vcl::DialogID nDialogID, +void SfxLokHelper::notifyDialog(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) { - if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0) + if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0) return; SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) + OString("\""); + OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nLOKWindowId) + OString("\""); aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\""); for (const auto& rItem: rPayload) @@ -172,13 +172,13 @@ void SfxLokHelper::notifyDialog(vcl::DialogID nDialogID, } } -void SfxLokHelper::notifyDialogChild(vcl::DialogID nDialogID, const OUString& rAction, const Point& rPos) +void SfxLokHelper::notifyDialogChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos) { - if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0) + if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0) return; SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - const OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) + + const OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nLOKWindowId) + OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\", \"position\": \"") + OString::number(rPos.getX()) + OString(", ") + OString::number(rPos.getY()) + + "\" }"; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 986a640d1625..778a9d9f68b7 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1948,27 +1948,27 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable() return xRender; } -void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) +void SfxViewShell::notifyDialog(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) const { SfxLokHelper::notifyDialog(rDialogId, rAction, rPayload); } -void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos) +void SfxViewShell::notifyDialogChild(const vcl::LOKWindowId& rDialogId, const OUString& rAction, const Point& rPos) const { SfxLokHelper::notifyDialogChild(rDialogId, rAction, rPos); } -void SfxViewShell::RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg) +void SfxViewShell::RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg) { if (pDlg) maOpenedDialogs.push_back(std::make_pair(nDialogId, pDlg)); } -VclPtr<Dialog> SfxViewShell::GetOpenedDlg(vcl::DialogID nDialogId) +VclPtr<Dialog> SfxViewShell::GetOpenedDlg(vcl::LOKWindowId nDialogId) { const auto it = std::find_if(maOpenedDialogs.begin(), maOpenedDialogs.end(), - [&nDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) { + [&nDialogId](const std::pair<vcl::LOKWindowId, VclPtr<Dialog>> aItem) { return nDialogId == aItem.first; }); @@ -1980,11 +1980,11 @@ VclPtr<Dialog> SfxViewShell::GetOpenedDlg(vcl::DialogID nDialogId) return ret; } -void SfxViewShell::UnregisterDlg(vcl::DialogID nDialogId) +void SfxViewShell::UnregisterDlg(vcl::LOKWindowId nDialogId) { maOpenedDialogs.erase(std::remove_if(maOpenedDialogs.begin(), maOpenedDialogs.end(), - [&nDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) { + [&nDialogId](const std::pair<vcl::LOKWindowId, VclPtr<Dialog>> aItem) { return aItem.first == nDialogId; })); } diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 81b9165cfa15..85c1d4a4ead6 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -431,16 +431,16 @@ public: /// @see vcl::ITiledRenderable::getPostIts(). OUString getPostIts() override; - void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice) override; - void getDialogInfo(const vcl::DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight) override; - void paintActiveFloatingWindow(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) override; - void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, + void paintDialog(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice) override; + void getDialogInfo(const vcl::LOKWindowId& rLOKWindowId, OUString& rDialogTitle, int& rWidth, int& rHeight) override; + void paintActiveFloatingWindow(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice, int& nWidth, int& nHeight) override; + void postDialogKeyEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nCharCode, int nKeyCode) override; - void postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, + void postDialogMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; - void postDialogChildMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, + void postDialogChildMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; // css::tiledrendering::XTiledRenderable diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 9e13851fb415..fc7c7a6a2b59 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3639,18 +3639,18 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I #endif } -void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice) +void SwXTextDocument::paintDialog(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice) { SfxViewShell* pViewShell = SfxViewShell::Current(); - VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rDialogID); + VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rLOKWindowId); if (pDlg) pDlg->paintDialog(rDevice); } -void SwXTextDocument::getDialogInfo(const vcl::DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight) +void SwXTextDocument::getDialogInfo(const vcl::LOKWindowId& rLOKWindowId, OUString& rDialogTitle, int& rWidth, int& rHeight) { SfxViewShell* pViewShell = SfxViewShell::Current(); - VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rDialogID); + VclPtr<Dialog> pDlg = pViewShell->GetOpenedDlg(rLOKWindowId); if (pDlg) { rDialogTitle = pDlg->GetText(); @@ -3660,12 +3660,12 @@ void SwXTextDocument::getDialogInfo(const vcl::DialogID& rDialogID, OUString& rD } } -void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, int nCharCode, int nKeyCode) +void SwXTextDocument::postDialogKeyEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nCharCode, int nKeyCode) { SolarMutexGuard aGuard; SfxViewShell* pViewShell = SfxViewShell::Current(); - VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID); + VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId); if (pDialog) { KeyEvent aEvent(nCharCode, nKeyCode, 0); @@ -3685,13 +3685,13 @@ void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& rDialogID, int nTy } } -void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, +void SwXTextDocument::postDialogMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier) { SolarMutexGuard aGuard; SfxViewShell* pViewShell = SfxViewShell::Current(); - VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID); + VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId); if (pDialog) { Point aPos(nX , nY); @@ -3716,13 +3716,13 @@ void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& rDialogID, int n } -void SwXTextDocument::postDialogChildMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, +void SwXTextDocument::postDialogChildMouseEvent(const vcl::LOKWindowId& rLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier) { SolarMutexGuard aGuard; SfxViewShell* pViewShell = SfxViewShell::Current(); - VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID); + VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId); if (pDialog) { Point aPos(nX , nY); @@ -3746,10 +3746,10 @@ void SwXTextDocument::postDialogChildMouseEvent(const vcl::DialogID& rDialogID, } } -void SwXTextDocument::paintActiveFloatingWindow(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) +void SwXTextDocument::paintActiveFloatingWindow(const vcl::LOKWindowId& rLOKWindowId, VirtualDevice& rDevice, int& nWidth, int& nHeight) { SfxViewShell* pViewShell = SfxViewShell::Current(); - VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rDialogID); + VclPtr<Dialog> pDialog = pViewShell->GetOpenedDlg(rLOKWindowId); if (pDialog) { const Size aSize = pDialog->PaintActiveFloatingWindow(rDevice); diff --git a/vcl/inc/window.h b/vcl/inc/window.h index d9108e71cf1f..7b2222b3718b 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -376,6 +376,10 @@ public: mbDoubleBufferingRequested:1; css::uno::Reference< css::uno::XInterface > mxDNDListenerContainer; + + const vcl::ILibreOfficeKitNotifier* mpLOKNotifier; ///< To emit the LOK callbacks eg. for dialog tunneling. + static vcl::LOKWindowId mnLastWindowId; ///< To be able to have an unique ID for each dealog / window we tunnel. + vcl::LOKWindowId mnLOKWindowId; ///< ID of this specific window. }; /// Sets up the buffer to have settings matching the window, and restores the original state in the dtor. diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index f5d3bdc59aba..68232e872e5d 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -53,6 +53,7 @@ #include <vcl/uitest/uiobject.hxx> #include <vcl/uitest/logger.hxx> #include <vcl/virdev.hxx> +#include <vcl/IDialogRenderable.hxx> #include <salframe.hxx> #include <iostream> @@ -346,8 +347,6 @@ struct DialogImpl void Dialog::ImplInitDialogData() { - maID = mnLastDialogId++; - mpDialogNotifier = nullptr; mpWindowImpl->mbDialog = true; mpPrevExecuteDlg = nullptr; mbInExecute = false; @@ -491,8 +490,6 @@ void Dialog::ImplInitSettings() SetBackground(GetSettings().GetStyleSettings().GetDialogColor()); } -vcl::DialogID Dialog::mnLastDialogId = 1; - Dialog::Dialog( WindowType nType ) : SystemWindow( nType ) , mbForceBorderWindow(false) @@ -875,14 +872,6 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/) return true; } -void Dialog::registerDialogNotifier(vcl::IDialogNotifier* pDialogNotifier) -{ - if (pDialogNotifier && !mpDialogNotifier) - { - mpDialogNotifier = pDialogNotifier; - } -} - void Dialog::paintDialog(VirtualDevice& rDevice) { setDeferredProperties(); @@ -955,29 +944,28 @@ void Dialog::LogicMouseMoveChild(const MouseEvent& rMouseEvent) void Dialog::InvalidateFloatingWindow(const Point& rPos) { - if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && maID != 0) - { - mpDialogNotifier->notifyDialogChild(maID, "invalidate", rPos); - } + if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + pNotifier->notifyDialogChild(GetLOKWindowId(), "invalidate", rPos); } void Dialog::CloseFloatingWindow() { - if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && maID != 0) - { - mpDialogNotifier->notifyDialogChild(maID, "close", Point(0, 0)); - } + if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + pNotifier->notifyDialogChild(GetLOKWindowId(), "close", Point(0, 0)); } void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle) { - if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0) + if (comphelper::LibreOfficeKit::isDialogPainting()) + return; + + if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) { std::vector<vcl::LOKPayloadItem> aPayload; if (pRectangle) aPayload.push_back(std::make_pair(OString("rectangle"), pRectangle->toString())); - mpDialogNotifier->notifyDialog(maID, "invalidate", aPayload); + pNotifier->notifyDialog(GetLOKWindowId(), "invalidate", aPayload); } } @@ -1023,10 +1011,11 @@ void Dialog::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloa { assert(comphelper::LibreOfficeKit::isActive()); - if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0) - { - mpDialogNotifier->notifyDialog(maID, rAction, rPayload); - } + if (comphelper::LibreOfficeKit::isDialogPainting()) + return; + + if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + pNotifier->notifyDialog(GetLOKWindowId(), rAction, rPayload); } void Dialog::ensureRepaint() @@ -1345,11 +1334,12 @@ void Dialog::Resize() { SystemWindow::Resize(); + if (comphelper::LibreOfficeKit::isDialogPainting()) + return; + // inform LOK clients - if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0) - { - mpDialogNotifier->notifyDialog(maID, "invalidate"); - } + if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + pNotifier->notifyDialog(GetLOKWindowId(), "invalidate"); } bool Dialog::set_property(const OString &rKey, const OUString &rValue) diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx index 57c5f7ec26a8..936f55d401e3 100644 --- a/vcl/source/window/floatwin.cxx +++ b/vcl/source/window/floatwin.cxx @@ -29,7 +29,7 @@ #include <vcl/toolbox.hxx> #include <vcl/floatwin.hxx> #include <vcl/settings.hxx> - +#include <vcl/IDialogRenderable.hxx> class FloatingWindow::ImplData { diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index c68601165057..3604276839b8 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -42,6 +42,7 @@ #include <vcl/virdev.hxx> #include <vcl/settings.hxx> #include <vcl/sysdata.hxx> +#include <vcl/IDialogRenderable.hxx> #include <vcl/uitest/uiobject.hxx> #include <vcl/uitest/uitest.hxx> @@ -590,6 +591,8 @@ Window::~Window() } /* namespace vcl */ +vcl::LOKWindowId WindowImpl::mnLastWindowId = 1; + WindowImpl::WindowImpl( WindowType nType ) { maZoom = Fraction( 1, 1 ); @@ -736,6 +739,8 @@ WindowImpl::WindowImpl( WindowType nType ) mbNonHomogeneous = false; static bool bDoubleBuffer = getenv("VCL_DOUBLEBUFFERING_FORCE_ENABLE"); mbDoubleBufferingRequested = bDoubleBuffer; // when we are not sure, assume it cannot do double-buffering via RenderContext + mpLOKNotifier = nullptr; + mnLOKWindowId = mnLastWindowId++; } WindowImpl::~WindowImpl() @@ -3148,6 +3153,21 @@ void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > const & x pWrapper->SetWindowInterface( this, xIFace ); } +void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier) +{ + mpWindowImpl->mpLOKNotifier = pNotifier; +} + +const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const +{ + return mpWindowImpl->mpLOKNotifier; +} + +vcl::LOKWindowId Window::GetLOKWindowId() const +{ + return mpWindowImpl->mnLOKWindowId; +} + void Window::ImplCallDeactivateListeners( vcl::Window *pNew ) { // no deactivation if the newly activated window is my child diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index bf64ef132cc7..ad4c6920a738 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -2493,8 +2493,8 @@ bool ImplWindowFrameProc( vcl::Window* _pWindow, SalEvent nEvent, const void* pE break; case SalEvent::ShowDialog: { - ShowDialogId nDialogID = static_cast<ShowDialogId>(reinterpret_cast<sal_IntPtr>(pEvent)); - bRet = ImplHandleShowDialog( pWindow, nDialogID ); + ShowDialogId nLOKWindowId = static_cast<ShowDialogId>(reinterpret_cast<sal_IntPtr>(pEvent)); + bRet = ImplHandleShowDialog( pWindow, nLOKWindowId ); } break; case SalEvent::SurroundingTextRequest: |