summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-12-02 02:47:38 +0530
committerJan Holesovsky <kendy@collabora.com>2017-12-04 13:04:47 +0100
commitde5bef13019ca95429865d4a9794fbc2a6f81a1b (patch)
tree58b351ae58a771969d14a7c9722b104844bc9361
parent9d2b7628d901bed92fc2a490084b0ac51aa6691b (diff)
lokdialog: multiview: Do not mix one view with other
In GTV, use correct application window object to fetch the dialog object. Use correct view shell to notify window (dialogs, etc.) callbacks. Change-Id: I7d82b39d4522a4b4904e156757a032c342c71efb
-rw-r--r--include/sfx2/lokhelper.hxx3
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx23
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx2
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx9
-rw-r--r--sfx2/source/dialog/basedlgs.cxx5
-rw-r--r--sfx2/source/view/lokhelper.cxx8
-rw-r--r--sfx2/source/view/viewsh.cxx2
7 files changed, 22 insertions, 30 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index eff40dd2f4ee..b7600f015163 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,7 +42,8 @@ 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_WINDOW
- static void notifyWindow(vcl::LOKWindowId nWindowId,
+ static void notifyWindow(const SfxViewShell* pThisView,
+ vcl::LOKWindowId nWindowId,
const OUString& rAction,
const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
index efe9b3da7061..d67b6afd61d3 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
@@ -315,7 +315,7 @@ static void setupDocView(GtvApplicationWindow* window)
g_signal_connect(window->lokdocview, "formula-changed", G_CALLBACK(LOKDocViewSigHandlers::formulaChanged), nullptr);
g_signal_connect(window->lokdocview, "password-required", G_CALLBACK(LOKDocViewSigHandlers::passwordRequired), nullptr);
g_signal_connect(window->lokdocview, "comment", G_CALLBACK(LOKDocViewSigHandlers::comment), nullptr);
- g_signal_connect(window->lokdocview, "window", G_CALLBACK(LOKDocViewSigHandlers::window), nullptr);
+ g_signal_connect(window->lokdocview, "window", G_CALLBACK(LOKDocViewSigHandlers::window), window);
g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr);
}
@@ -402,6 +402,9 @@ gtv_application_window_get_part_broadcast(GtvApplicationWindow* window)
void
gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin)
{
+ guint dialogid = 0;
+ g_object_get(G_OBJECT(pChildWin), "dialogid", &dialogid, nullptr);
+ g_debug("Register child window: dialogid [%d] in window[%p]", dialogid, window);
GtvApplicationWindowPrivate* priv = getPrivate(window);
if (pChildWin)
priv->m_pChildWindows = g_list_append(priv->m_pChildWindows, pChildWin);
@@ -410,6 +413,9 @@ gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWi
void
gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin)
{
+ guint dialogid = 0;
+ g_object_get(G_OBJECT(pChildWin), "dialogid", &dialogid, nullptr);
+ g_debug("Unregister child window: dialogid [%d] in window[%p]", dialogid, window);
GtvApplicationWindowPrivate* priv = getPrivate(window);
if (pChildWin)
{
@@ -432,7 +438,6 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin
{
guint dialogId = 0;
g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr);
-
if (dialogId == nWinId)
{
ret = GTK_WINDOW(pIt->data);
@@ -443,7 +448,8 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin
return ret;
}
-GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId)
+GtkWidget*
+gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId)
{
GtvApplicationWindowPrivate* priv = getPrivate(window);
GList* pIt = nullptr;
@@ -455,17 +461,6 @@ GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint
return nullptr;
}
-
-// temporary function to invalidate all opened dialogs
-// because currently the dialog id returned in dialog invalidation payload
-// doesn't match our hard-coded list of dialog ids (uno commands) for some dialogs
-GList*
-gtv_application_window_get_all_child_windows(GtvApplicationWindow* window)
-{
- GtvApplicationWindowPrivate* priv = getPrivate(window);
- return priv->m_pChildWindows;
-}
-
GtvApplicationWindow*
gtv_application_window_new(GtkApplication* app)
{
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
index b6aac5466133..01fd01837dd7 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx
@@ -105,8 +105,6 @@ void gtv_application_window_unregister_child_window(GtvApplicationWindow* window
GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guint nWinId);
-GList* gtv_application_window_get_all_child_windows(GtvApplicationWindow* window);
-
GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId);
G_END_DECLS
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 8d3a116df97e..75d511c53f94 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -301,9 +301,9 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin
}
}
-void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpointer)
+void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpointer pData)
{
- GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
+ GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(pData);
std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot;
@@ -350,9 +350,8 @@ void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpoint
else if (aAction == "close")
gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pParent));
}
- else // it's the dialog window itself
- {
- GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nWinId);
+ else if (GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nWinId))
+ { // it's the dialog window itself
if (aAction == "close")
gtk_widget_destroy(GTK_WIDGET(pDialog));
else if (aAction == "size_changed")
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 0fd2abc9ba8e..c7755d3b8ff1 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -276,12 +276,9 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
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("type", "dialog"));
- aItems.emplace_back(std::make_pair("size", aOptimalSize.toString()));
+ aItems.emplace_back(std::make_pair("size", GetOptimalSize().toString()));
pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index d28e5a835dd6..73e7a170412c 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -132,10 +132,13 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
}
}
-void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
+void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
+ vcl::LOKWindowId nLOKWindowId,
const OUString& rAction,
const std::vector<vcl::LOKPayloadItem>& rPayload)
{
+ assert(pThisView);
+
if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
return;
@@ -152,8 +155,7 @@ void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
}
aPayload += "}";
- if (SfxViewShell* pViewShell = SfxViewShell::Current())
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, aPayload.getStr());
+ pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, aPayload.getStr());
}
void SfxLokHelper::notifyInvalidation(SfxViewShell* pThisView, const OString& rPayload)
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 23b3237e4c83..1dcc439f291c 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2038,7 +2038,7 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable()
void SfxViewShell::notifyWindow(vcl::LOKWindowId nDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) const
{
- SfxLokHelper::notifyWindow(nDialogId, rAction, rPayload);
+ SfxLokHelper::notifyWindow(this, nDialogId, rAction, rPayload);
}
uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier()