summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-11-24 10:20:47 +0100
committerJan Holesovsky <kendy@collabora.com>2017-11-28 17:59:13 +0100
commit9df590be66324884e3e0e4eb9b255cd35103b06b (patch)
tree7b75e4d75eb11cd09b57cc8656129c22ddd430eb
parentf003eba0e30f41d036bed6fe417520fe66a3335f (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.hxx4
-rw-r--r--include/sfx2/viewsh.hxx16
-rw-r--r--include/vcl/IDialogRenderable.hxx24
-rw-r--r--include/vcl/dialog.hxx8
-rw-r--r--include/vcl/window.hxx8
-rw-r--r--sfx2/source/dialog/basedlgs.cxx20
-rw-r--r--sfx2/source/dialog/tabdlg.cxx10
-rw-r--r--sfx2/source/view/lokhelper.cxx12
-rw-r--r--sfx2/source/view/viewsh.cxx14
-rw-r--r--sw/inc/unotxdoc.hxx12
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx24
-rw-r--r--vcl/inc/window.h4
-rw-r--r--vcl/source/window/dialog.cxx50
-rw-r--r--vcl/source/window/floatwin.cxx1
-rw-r--r--vcl/source/window/window.cxx20
-rw-r--r--vcl/source/window/winproc.cxx4
16 files changed, 122 insertions, 109 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index ce0a69b75e6f..c199a5287b5c 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* 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* pThisView, const OString& rPayload);
/// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 0db8fb3aec82..7602da3f5d25 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -143,7 +143,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
{
#ifdef INCLUDED_SFX2_VIEWSH_HXX
friend class SfxViewFrame;
@@ -157,7 +157,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;
@@ -227,13 +227,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 ccb99cb0adb2..db3831ccd5c6 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -25,41 +25,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 3586c116b31d..76952b2f3cc5 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -48,10 +48,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();
@@ -65,10 +61,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 496a0743562c..08faef8e8519 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -435,6 +435,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;
@@ -484,6 +485,8 @@ public:
Color* pPaintColor = nullptr);
};
+typedef sal_uInt32 LOKWindowId;
+
class VCL_DLLPUBLIC Window : public ::OutputDevice, public Resource
{
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 1a20dcf2576e..8bd02f13ced5 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -170,8 +170,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();
@@ -182,12 +182,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();
@@ -254,14 +254,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;
@@ -397,8 +397,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 b072efbcbbc9..54a4088313c6 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -408,8 +408,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();
@@ -523,12 +523,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 eea6e2c1cefc..da6cd4ac16ee 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -132,15 +132,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)
@@ -160,13 +160,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 504439a11568..46412c9db379 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2036,27 +2036,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;
});
@@ -2068,11 +2068,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 5e9c13fa17d4..e16dc50f43f4 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -452,16 +452,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 51fd19fba506..be7df40f4619 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3711,18 +3711,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();
@@ -3732,12 +3732,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);
@@ -3757,13 +3757,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);
@@ -3788,13 +3788,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);
@@ -3818,10 +3818,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 8ba8be792eb6..4f247162bcef 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -352,6 +352,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 7a2f6f158d84..6eab80b0c2f6 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -55,6 +55,7 @@
#include <vcl/settings.hxx>
#include <vcl/uitest/uiobject.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/IDialogRenderable.hxx>
#include <salframe.hxx>
#include <iostream>
@@ -351,8 +352,6 @@ struct DialogImpl
void Dialog::ImplInitDialogData()
{
- maID = mnLastDialogId++;
- mpDialogNotifier = nullptr;
mpWindowImpl->mbDialog = true;
mpPrevExecuteDlg = nullptr;
mbInExecute = false;
@@ -480,8 +479,6 @@ void Dialog::ImplInitSettings()
SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
}
-vcl::DialogID Dialog::mnLastDialogId = 1;
-
Dialog::Dialog( WindowType nType )
: SystemWindow( nType )
, mnInitFlag(InitFlag::Default)
@@ -876,14 +873,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();
@@ -956,29 +945,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 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);
}
}
@@ -1024,10 +1012,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()
@@ -1356,11 +1345,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 OString &rValue)
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index fd936bcd6610..995183ebd5d0 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -32,6 +32,7 @@
#include <tools/rc.h>
#include <tools/debug.hxx>
+#include <vcl/IDialogRenderable.hxx>
class FloatingWindow::ImplData
{
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 72c2a5d832e5..d3ad60417d87 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -43,6 +43,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>
@@ -596,6 +597,8 @@ Window::~Window()
} /* namespace vcl */
+vcl::LOKWindowId WindowImpl::mnLastWindowId = 1;
+
WindowImpl::WindowImpl( WindowType nType )
{
maZoom = Fraction( 1, 1 );
@@ -745,6 +748,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()
@@ -3185,6 +3190,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 3133990e158f..82d81a6ecbd3 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -2526,8 +2526,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: