From 1a1ee7803d8f17532fb2149fcc386cc70720eef0 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Thu, 26 Oct 2017 13:39:06 -0700 Subject: 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 Reviewed-by: pranavk --- include/vcl/dialog.hxx | 5 ++-- .../gtv-lokdocview-signal-handlers.cxx | 32 ++++++++++++++-------- sfx2/source/view/lokhelper.cxx | 4 +-- sw/source/uibase/uno/unotxdoc.cxx | 2 +- vcl/source/window/dialog.cxx | 5 ++-- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 9130ee2e46cd..4ae5e040103a 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -76,7 +76,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; } @@ -87,7 +88,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 95a462a79593..415c3d6526c4 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("dialogId"); + std::string aDialogId = aRoot.get("dialogId"); std::string aAction = aRoot.get("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("dialogId"); + std::string aDialogId = aRoot.get("dialogId"); std::string aAction = aRoot.get("action"); std::string aPos = aRoot.get("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 702e88d09cf0..eccb3b1bf1f0 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -146,7 +146,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(); @@ -163,7 +163,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 1b91fc434970..818a47ff5a83 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3663,7 +3663,7 @@ void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& Dialog* pDlg = static_cast(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 de6f1d71f48f..eb196997c4b6 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -525,7 +525,6 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML : SystemWindow(WindowType::DIALOG) , mbForceBorderWindow(false) , mnInitFlag(InitFlag::Default) - , maID(rID) { ImplInitDialogData(); loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription); @@ -535,7 +534,6 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML : SystemWindow(nType) , mbForceBorderWindow(bBorder) , mnInitFlag(eFlag) - , maID(rID) { ImplInitDialogData(); loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription); @@ -876,11 +874,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; } } -- cgit