Kaydet (Commit) 727c2303 authored tarafından Pranav Kant's avatar Pranav Kant

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
üst b1bcc70d
...@@ -42,7 +42,8 @@ public: ...@@ -42,7 +42,8 @@ public:
/// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them. /// 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); static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
/// Emits a LOK_CALLBACK_WINDOW /// Emits a LOK_CALLBACK_WINDOW
static void notifyWindow(vcl::LOKWindowId nWindowId, static void notifyWindow(const SfxViewShell* pThisView,
vcl::LOKWindowId nWindowId,
const OUString& rAction, const OUString& rAction,
const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()); const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed. /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
......
...@@ -315,7 +315,7 @@ static void setupDocView(GtvApplicationWindow* window) ...@@ -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, "formula-changed", G_CALLBACK(LOKDocViewSigHandlers::formulaChanged), nullptr);
g_signal_connect(window->lokdocview, "password-required", G_CALLBACK(LOKDocViewSigHandlers::passwordRequired), 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, "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); g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr);
} }
...@@ -402,6 +402,9 @@ gtv_application_window_get_part_broadcast(GtvApplicationWindow* window) ...@@ -402,6 +402,9 @@ gtv_application_window_get_part_broadcast(GtvApplicationWindow* window)
void void
gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) 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); GtvApplicationWindowPrivate* priv = getPrivate(window);
if (pChildWin) if (pChildWin)
priv->m_pChildWindows = g_list_append(priv->m_pChildWindows, pChildWin); priv->m_pChildWindows = g_list_append(priv->m_pChildWindows, pChildWin);
...@@ -410,6 +413,9 @@ gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWi ...@@ -410,6 +413,9 @@ gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWi
void void
gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) 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); GtvApplicationWindowPrivate* priv = getPrivate(window);
if (pChildWin) if (pChildWin)
{ {
...@@ -432,7 +438,6 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin ...@@ -432,7 +438,6 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin
{ {
guint dialogId = 0; guint dialogId = 0;
g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr); g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr);
if (dialogId == nWinId) if (dialogId == nWinId)
{ {
ret = GTK_WINDOW(pIt->data); ret = GTK_WINDOW(pIt->data);
...@@ -443,7 +448,8 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin ...@@ -443,7 +448,8 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin
return ret; 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); GtvApplicationWindowPrivate* priv = getPrivate(window);
GList* pIt = nullptr; GList* pIt = nullptr;
...@@ -455,17 +461,6 @@ GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint ...@@ -455,17 +461,6 @@ GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint
return nullptr; 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* GtvApplicationWindow*
gtv_application_window_new(GtkApplication* app) gtv_application_window_new(GtkApplication* app)
{ {
......
...@@ -105,8 +105,6 @@ void gtv_application_window_unregister_child_window(GtvApplicationWindow* window ...@@ -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); 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); GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId);
G_END_DECLS G_END_DECLS
......
...@@ -301,9 +301,9 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin ...@@ -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); std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot; boost::property_tree::ptree aRoot;
...@@ -350,9 +350,8 @@ void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpoint ...@@ -350,9 +350,8 @@ void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpoint
else if (aAction == "close") else if (aAction == "close")
gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pParent)); gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pParent));
} }
else // it's the dialog window itself else if (GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nWinId))
{ { // it's the dialog window itself
GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nWinId);
if (aAction == "close") if (aAction == "close")
gtk_widget_destroy(GTK_WIDGET(pDialog)); gtk_widget_destroy(GTK_WIDGET(pDialog));
else if (aAction == "size_changed") else if (aAction == "size_changed")
......
...@@ -249,12 +249,9 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange ) ...@@ -249,12 +249,9 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
if (comphelper::LibreOfficeKit::isActive() && pViewShell) if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{ {
SetLOKNotifier(pViewShell); SetLOKNotifier(pViewShell);
// Below method doesn't really give the exact dimensions,
// Check GetSizePixel() ?
const Size aOptimalSize = GetOptimalSize();
std::vector<vcl::LOKPayloadItem> aItems; std::vector<vcl::LOKPayloadItem> aItems;
aItems.emplace_back(std::make_pair("type", "dialog")); 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); pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
} }
......
...@@ -144,10 +144,13 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS ...@@ -144,10 +144,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 OUString& rAction,
const std::vector<vcl::LOKPayloadItem>& rPayload) const std::vector<vcl::LOKPayloadItem>& rPayload)
{ {
assert(pThisView);
if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0) if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
return; return;
...@@ -164,8 +167,7 @@ void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId, ...@@ -164,8 +167,7 @@ void SfxLokHelper::notifyWindow(vcl::LOKWindowId nLOKWindowId,
} }
aPayload += "}"; aPayload += "}";
if (SfxViewShell* pViewShell = SfxViewShell::Current()) pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, aPayload.getStr());
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, aPayload.getStr());
} }
void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload) void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
......
...@@ -1950,7 +1950,7 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable() ...@@ -1950,7 +1950,7 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable()
void SfxViewShell::notifyWindow(vcl::LOKWindowId nDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) const 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() uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment