[Libreoffice-commits] core.git: include/sfx2 include/vcl sfx2/source sw/inc sw/source vcl/source

Pranav Kant pranavk at collabora.co.uk
Wed Nov 15 12:47:09 UTC 2017


 include/sfx2/lokhelper.hxx        |    5 +++
 include/vcl/IDialogRenderable.hxx |    6 +++-
 include/vcl/dialog.hxx            |    2 -
 sfx2/source/view/lokhelper.cxx    |   14 ++++++++--
 sw/inc/unotxdoc.hxx               |    4 ++-
 sw/source/uibase/uno/unotxdoc.cxx |    6 +++-
 vcl/source/control/edit.cxx       |   49 +++++++++++++++++++++++++++++---------
 vcl/source/window/dialog.cxx      |   14 ++++++----
 8 files changed, 75 insertions(+), 25 deletions(-)

New commits:
commit 43540adb76f764522344c5d66ebc63f7cb0f9c1c
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 14 18:45:02 2017 +0530

    lokdialog: Expose cursor visible status
    
    Change the notifyDialog API a bit. Use a std::vector to keep track of
    each payload item that needs to be fed to the resulting JSON.
    
    Change-Id: If3229a88d2df5368e14290a0e80ebe6206780639
    Reviewed-on: https://gerrit.libreoffice.org/44722
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index b14c35fa3956..e22017c8eccc 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -10,6 +10,7 @@
 #ifndef INCLUDED_SFX2_LOKHELPER_HXX
 #define INCLUDED_SFX2_LOKHELPER_HXX
 
+#include <vcl/IDialogRenderable.hxx>
 #include <sfx2/dllapi.h>
 #include <sfx2/viewsh.hxx>
 #include <cstddef>
@@ -41,7 +42,9 @@ 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_DIALOG
-    static void notifyDialog(const OUString& rPayload, const OUString& rAction, const tools::Rectangle* rRect);
+    static void notifyDialog(const OUString& rDialogId,
+                             const OUString& rAction,
+                             const std::vector<vcl::LOKPayloadItem>& rPayload);
     /// Emits a LOK_CALLBACK_DIALOG_CHILD
     static void notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 87630d5c2f1d..4137e960edb9 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -21,6 +21,8 @@
 namespace vcl
 {
 
+typedef std::pair<const OString, const OString> LOKPayloadItem;
+
 typedef OUString DialogID;
 
 class VCL_DLLPUBLIC IDialogRenderable
@@ -45,7 +47,9 @@ public:
                                            int nCount, int nButtons, int nModifier) = 0;
 
     // Callbacks
-    virtual void notifyDialog(const DialogID& rDialogID, const OUString& rAction, const tools::Rectangle* rRect) = 0;
+    virtual void notifyDialog(const DialogID& rDialogID,
+                              const OUString& rAction,
+                              const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) = 0;
 
     virtual void notifyDialogChild(const DialogID& rDialogID, const OUString& rAction, const Point& rPos) = 0;
 };
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 48ae4fec43fd..8d84aab17606 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -97,7 +97,7 @@ public:
 
     void LOKKeyInput(const KeyEvent& rKeyEvent);
     void LOKKeyUp(const KeyEvent& rKeyEvent);
-    void LOKCursorInvalidate(const tools::Rectangle& rRect);
+    void LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload);
 
 protected:
     explicit        Dialog( WindowType nType );
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 633e221e4f86..33464711852f 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -144,7 +144,9 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
     }
 }
 
-void SfxLokHelper::notifyDialog(const OUString& rDialogID, const OUString& rAction, const tools::Rectangle* rRect)
+void SfxLokHelper::notifyDialog(const OUString& rDialogID,
+                                const OUString& rAction,
+                                const std::vector<vcl::LOKPayloadItem>& rPayload)
 {
     if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty())
         return;
@@ -152,9 +154,15 @@ void SfxLokHelper::notifyDialog(const OUString& rDialogID, const OUString& rActi
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
     aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
-    if (!rAction.isEmpty() && rRect && !rRect->IsEmpty())
-        aPayload += OString(", \"rectangle\": \"") + rRect->toString() + OString("\"");
 
+    for (const auto& rItem: rPayload)
+    {
+        if (!rItem.first.isEmpty() && !rItem.second.isEmpty())
+        {
+            aPayload += OString(", \"") + rItem.first + OString("\": \"") +
+                rItem.second + OString("\"");
+        }
+    }
     aPayload += "}";
 
     while (pViewShell)
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index b9fb29d3aa16..e8a995ee3142 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -443,7 +443,9 @@ public:
     void postDialogChildMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY,
                                    int nCount, int nButtons, int nModifier) override;
 
-    void notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction, const tools::Rectangle* rRect) override;
+    void notifyDialog(const vcl::DialogID& rDialogID,
+                      const OUString& rAction,
+                      const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) override;
 
     void notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos) override;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 2ede2e2b69eb..6187022a9ed3 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3801,9 +3801,11 @@ void SwXTextDocument::postDialogChildMouseEvent(const vcl::DialogID& rDialogID,
     }
 }
 
-void SwXTextDocument::notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction, const tools::Rectangle* rRect)
+void SwXTextDocument::notifyDialog(const vcl::DialogID& rDialogID,
+                                   const OUString& rAction,
+                                   const std::vector<vcl::LOKPayloadItem>& rPayload)
 {
-    SfxLokHelper::notifyDialog(rDialogID, rAction, rRect);
+    SfxLokHelper::notifyDialog(rDialogID, rAction, rPayload);
 }
 
 void SwXTextDocument::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos)
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index cf8a153ee256..add78c2f49b3 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -19,6 +19,7 @@
 
 #include <comphelper/lok.hxx>
 
+#include <vcl/IDialogRenderable.hxx>
 #include <vcl/decoview.hxx>
 #include <vcl/event.hxx>
 #include <vcl/cursor.hxx>
@@ -1144,18 +1145,23 @@ void Edit::ImplShowCursor( bool bOnlyIfVisible )
         pCursor->SetPos( Point( nCursorPosX, nCursorPosY ) );
         pCursor->SetSize( Size( nCursorWidth, nTextHeight ) );
         pCursor->Show();
-    }
 
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        const long X = GetOutOffXPixel() + pCursor->GetPos().X();
-        const long Y = GetOutOffYPixel() + pCursor->GetPos().Y();
-        if (nCursorWidth == 0)
-            nCursorWidth = 2;
-        const tools::Rectangle aRect(Point(X, Y), Size(nCursorWidth, pCursor->GetHeight()));
-        Dialog* pParentDlg = GetParentDialog();
-        if (pParentDlg)
-            pParentDlg->LOKCursorInvalidate(aRect);
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            const long X = GetOutOffXPixel() + pCursor->GetPos().X();
+            const long Y = GetOutOffYPixel() + pCursor->GetPos().Y();
+
+            if (nCursorWidth == 0)
+                nCursorWidth = 2;
+            const tools::Rectangle aRect(Point(X, Y), Size(nCursorWidth, pCursor->GetHeight()));
+
+            std::vector<vcl::LOKPayloadItem> aPayload;
+            aPayload.push_back(std::make_pair("rectangle", aRect.toString()));
+
+            Dialog* pParentDlg = GetParentDialog();
+            if (pParentDlg)
+                pParentDlg->LOKCursor("cursor_invalidate", aPayload);
+        }
     }
 }
 
@@ -1902,6 +1908,16 @@ void Edit::GetFocus()
         SetInputContext( InputContext( GetFont(), !IsReadOnly() ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE ) );
     }
 
+    // notify dialog's cursor visible status
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        std::vector<vcl::LOKPayloadItem> aPayload;
+        aPayload.push_back(std::make_pair(OString("visible"), OString("true")));
+        Dialog* pParentDlg = GetParentDialog();
+        if (pParentDlg)
+            pParentDlg->LOKCursor("cursor_visible", aPayload);
+    }
+
     Control::GetFocus();
 }
 
@@ -1929,6 +1945,17 @@ void Edit::LoseFocus()
             ImplInvalidateOrRepaint();    // paint the selection
     }
 
+
+    // notify dialog's cursor visible status
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        std::vector<vcl::LOKPayloadItem> aPayload;
+        aPayload.push_back(std::make_pair(OString("visible"), OString("false")));
+        Dialog* pParentDlg = GetParentDialog();
+        if (pParentDlg)
+            pParentDlg->LOKCursor("cursor_visible", aPayload);
+    }
+
     Control::LoseFocus();
 }
 
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 8e6d5f101012..4db7c9674a83 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -596,7 +596,7 @@ void Dialog::dispose()
 
     if (comphelper::LibreOfficeKit::isActive() && mpDialogRenderable)
     {
-        mpDialogRenderable->notifyDialog(maID, "close", nullptr);
+        mpDialogRenderable->notifyDialog(maID, "close");
     }
 
     SystemWindow::dispose();
@@ -973,7 +973,11 @@ void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle)
 {
     if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogRenderable && !maID.isEmpty())
     {
-        mpDialogRenderable->notifyDialog(maID, "invalidate", pRectangle);
+        std::vector<vcl::LOKPayloadItem> aPayload;
+        if (pRectangle)
+            aPayload.push_back(std::make_pair(OString("rectangle"), pRectangle->toString()));
+
+        mpDialogRenderable->notifyDialog(maID, "invalidate", aPayload);
     }
 }
 
@@ -1015,13 +1019,13 @@ void Dialog::LOKKeyUp(const KeyEvent& rKeyEvent)
     ImplWindowFrameProc(this, SalEvent::ExternalKeyUp, &rKeyEvent);
 }
 
-void Dialog::LOKCursorInvalidate(const tools::Rectangle& aRect)
+void Dialog::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
 {
     assert(comphelper::LibreOfficeKit::isActive());
 
     if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogRenderable && !maID.isEmpty())
     {
-        mpDialogRenderable->notifyDialog(maID, "cursor_invalidate", &aRect);
+        mpDialogRenderable->notifyDialog(maID, rAction, rPayload);
     }
 }
 
@@ -1342,7 +1346,7 @@ void Dialog::Resize()
     // inform LOK clients
     if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogRenderable && !maID.isEmpty())
     {
-        mpDialogRenderable->notifyDialog(maID, "invalidate", nullptr);
+        mpDialogRenderable->notifyDialog(maID, "invalidate");
     }
 }
 


More information about the Libreoffice-commits mailing list