summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-10-26 13:39:06 -0700
committerJan Holesovsky <kendy@collabora.com>2017-11-15 17:07:16 +0100
commitdf8f50170b502a8ad4a528507740f4f15ce1bc6d (patch)
treed68537eda1b146fe7ce3a7e89a96592787e574a3
parent1418849287f07443603feefe11c0aa51fc312c06 (diff)
lokdialog: Use UNO name as dialog id when invoking lok callbacks
... not the frame id from the .ui file Remove temporary hacks introduced earlier in GTV also. Change-Id: I71290a5fac6547a5584094da21e2301ef8fbce0c Reviewed-on: https://gerrit.libreoffice.org/43957 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk>
-rw-r--r--include/vcl/dialog.hxx5
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx32
-rw-r--r--sfx2/source/view/lokhelper.cxx4
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx2
-rw-r--r--vcl/source/window/dialog.cxx5
5 files changed, 28 insertions, 20 deletions
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 6a92883fa8e7..0ad945815be5 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -63,7 +63,8 @@ private:
protected:
using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
- OUString maID; // identifier for this dialog
+ OUString maID; // Dialog ID (UNO name) for this dialog (set
+ // and used by LOK for now)
public:
SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
@@ -74,7 +75,7 @@ public:
Size PaintActiveFloatingWindow(VirtualDevice& rDevice);
/// Necessary to register dialog renderable instance to emit LOK callbacks
- void registerDialogRenderable(vcl::IDialogRenderable* pDialogRenderable);
+ void registerDialogRenderable(vcl::IDialogRenderable* pDialogRenderable, const OUString& aDialogId);
/// Paints the current dialog to the given virtual device
void paintDialog(VirtualDevice& rDevice);
void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 8ad25f42a98c..c177e6bf5e41 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -288,24 +288,27 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot;
boost::property_tree::read_json(aStream, aRoot);
- //std::string aDialogId = aRoot.get<std::string>("dialogId");
+ std::string aDialogId = aRoot.get<std::string>("dialogId");
std::string aAction = aRoot.get<std::string>("action");
// we only understand 'invalidate' and 'close' as of now
if (aAction != "invalidate" && aAction != "close")
return;
- // temporary hack to invalidate all open dialogs
GList* pChildWins = gtv_application_window_get_all_child_windows(window);
GList* pIt = nullptr;
for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
{
- if (aAction == "close")
+ gchar* pChildDialogId = nullptr;
+ g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr);
+ if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0)
{
- gtk_widget_destroy(GTK_WIDGET(pIt->data));
+ if (aAction == "close")
+ gtk_widget_destroy(GTK_WIDGET(pIt->data));
+ else if (aAction == "invalidate")
+ gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data));
}
- else if (aAction == "invalidate")
- gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data));
+ g_free(pChildDialogId);
}
}
@@ -316,7 +319,7 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g
std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot;
boost::property_tree::read_json(aStream, aRoot);
- //std::string aDialogId = aRoot.get<std::string>("dialogId");
+ std::string aDialogId = aRoot.get<std::string>("dialogId");
std::string aAction = aRoot.get<std::string>("action");
std::string aPos = aRoot.get<std::string>("position");
gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2);
@@ -332,15 +335,20 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g
g_strfreev(ppCoordinates);
- // temporary hack to invalidate/close floating window of all opened dialogs
GList* pChildWins = gtv_application_window_get_all_child_windows(window);
GList* pIt = nullptr;
for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
{
- if (aAction == "invalidate")
- gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY);
- else if (aAction == "close")
- gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data));
+ gchar* pChildDialogId = nullptr;
+ g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr);
+ if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0)
+ {
+ if (aAction == "invalidate")
+ gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY);
+ else if (aAction == "close")
+ gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data));
+ }
+ g_free(pChildDialogId);
}
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 7ae0e65459bd..8128f88fef10 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -134,7 +134,7 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
void SfxLokHelper::notifyDialog(const OUString& rDialogID, const OUString& rAction)
{
- if (SfxLokHelper::getViewsCount() <= 0)
+ if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty())
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
@@ -151,7 +151,7 @@ void SfxLokHelper::notifyDialog(const OUString& rDialogID, const OUString& rActi
void SfxLokHelper::notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos)
{
- if (SfxLokHelper::getViewsCount() <= 0)
+ if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty())
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index d29e9a593194..99921da44b47 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3735,7 +3735,7 @@ void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice&
Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow());
// register the instance so that vcl::Dialog can emit LOK callbacks
- pDlg->registerDialogRenderable(this);
+ pDlg->registerDialogRenderable(this, rDialogID);
pDlg->paintDialog(rDevice);
const Size aSize = pDlg->GetOptimalSize();
nWidth = aSize.getWidth();
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index a8b63bc59a72..4ff9d42896a1 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -527,7 +527,6 @@ void Dialog::doDeferredInit(WinBits nBits)
Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription)
: SystemWindow(WINDOW_DIALOG)
, mnInitFlag(InitFlag::Default)
- , maID(rID)
{
ImplInitDialogData();
loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);
@@ -536,7 +535,6 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML
Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag)
: SystemWindow(nType)
, mnInitFlag(eFlag)
- , maID(rID)
{
ImplInitDialogData();
loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);
@@ -877,11 +875,12 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/)
return true;
}
-void Dialog::registerDialogRenderable(vcl::IDialogRenderable* pDialogRenderable)
+void Dialog::registerDialogRenderable(vcl::IDialogRenderable* pDialogRenderable, const OUString& aDialogId)
{
if (pDialogRenderable && !mpDialogRenderable)
{
mpDialogRenderable = pDialogRenderable;
+ maID = aDialogId;
}
}