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
This commit is contained in:
Pranav Kant
2017-12-02 02:47:38 +05:30
parent b1bcc70d2a
commit 727c2303cb
7 changed files with 22 additions and 30 deletions

View File

@@ -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 const* 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.

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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")

View File

@@ -249,12 +249,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);
}

View File

@@ -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 std::vector<vcl::LOKPayloadItem>& rPayload)
{
assert(pThisView);
if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
return;
@@ -164,8 +167,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 const* pThisView, const OString& rPayload)

View File

@@ -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
{
SfxLokHelper::notifyWindow(nDialogId, rAction, rPayload);
SfxLokHelper::notifyWindow(this, nDialogId, rAction, rPayload);
}
uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier()