135360
From d9ec8bc53bdd81ba9ef71fdd3783522f9fd6c8f8 Mon Sep 17 00:00:00 2001
135360
From: Andrzej Hunt <andrzej@ahunt.org>
135360
Date: Wed, 11 Nov 2015 10:05:25 +0100
135360
Subject: [PATCH 302/398] Implement LOK_CALLBACK_MOUSE_POINTER
135360
135360
Change-Id: I8d1f63208baf277b0a9d15908f3ea7ff3b56bf10
135360
Reviewed-on: https://gerrit.libreoffice.org/19883
135360
Reviewed-by: Andrzej Hunt <andrzej@ahunt.org>
135360
Tested-by: Andrzej Hunt <andrzej@ahunt.org>
135360
(cherry picked from commit 81b8ca683d44ba9c37f2dc8c74470a86ce70513f)
135360
---
135360
 desktop/source/lib/init.cxx                  | 69 ++++++++++++++++++++++++++++
135360
 include/LibreOfficeKit/LibreOfficeKitEnums.h |  9 +++-
135360
 include/vcl/ITiledRenderable.hxx             |  3 ++
135360
 sc/inc/docuno.hxx                            |  3 ++
135360
 sc/source/ui/unoobj/docuno.cxx               | 15 ++++++
135360
 sd/source/ui/inc/unomodel.hxx                |  2 +
135360
 sd/source/ui/unoidl/unomodel.cxx             | 14 ++++++
135360
 sw/inc/unotxdoc.hxx                          |  2 +
135360
 sw/source/uibase/uno/unotxdoc.cxx            | 11 +++++
135360
 9 files changed, 127 insertions(+), 1 deletion(-)
135360
135360
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
135360
index 2e6e7e73df1a..ddd7859426e7 100644
135360
--- a/desktop/source/lib/init.cxx
135360
+++ b/desktop/source/lib/init.cxx
135360
@@ -65,6 +65,7 @@
135360
 #include <tools/fract.hxx>
135360
 #include <svtools/ctrltool.hxx>
135360
 #include <vcl/graphicfilter.hxx>
135360
+#include <vcl/ptrstyle.hxx>
135360
 #include <vcl/sysdata.hxx>
135360
 #include <vcl/virdev.hxx>
135360
 #include <vcl/ITiledRenderable.hxx>
135360
@@ -173,6 +174,58 @@ static const ExtensionMap aDrawExtensionMap[] =
135360
     { NULL, NULL }
135360
 };
135360
 
135360
+/*
135360
+ * Map directly to css cursor styles to avoid further mapping in the client.
135360
+ * Gtk (via gdk_cursor_new_from_name) also supports the same css cursor styles.
135360
+ *
135360
+ * This was created partially with help of the mappings in gtkdata.cxx.
135360
+ * The list is incomplete as some cursor style simply aren't supported
135360
+ * by css, it might turn out to be worth mapping some of these missing cursors
135360
+ * to available cursors?
135360
+ */
135360
+static const std::map <PointerStyle, OString> aPointerMap {
135360
+    { PointerStyle::Arrow, "default" },
135360
+    // PointerStyle::Null ?
135360
+    { PointerStyle::Wait, "wait" },
135360
+    { PointerStyle::Text, "text" },
135360
+    { PointerStyle::Help, "help" },
135360
+    { PointerStyle::Cross, "crosshair" },
135360
+    { PointerStyle::Move, "move" },
135360
+    { PointerStyle::NSize, "n-resize" },
135360
+    { PointerStyle::SSize, "s-resize" },
135360
+    { PointerStyle::WSize, "w-resize" },
135360
+    { PointerStyle::ESize, "e-resize" },
135360
+    { PointerStyle::NWSize, "ne-resize" },
135360
+    { PointerStyle::NESize, "ne-resize" },
135360
+    { PointerStyle::SWSize, "sw-resize" },
135360
+    { PointerStyle::SESize, "se-resize" },
135360
+    // WindowNSize through WindowSESize
135360
+    { PointerStyle::HSplit, "col-resize" },
135360
+    { PointerStyle::VSplit, "row-resize" },
135360
+    { PointerStyle::HSizeBar, "col-resize" },
135360
+    { PointerStyle::VSizeBar, "row-resize" },
135360
+    { PointerStyle::Hand, "grab" },
135360
+    { PointerStyle::RefHand, "grabbing" },
135360
+    // Pen, Magnify, Fill, Rotate
135360
+    // HShear, VShear
135360
+    // Mirror, Crook, Crop, MovePoint, MoveBezierWeight
135360
+    // MoveData
135360
+    { PointerStyle::CopyData, "copy" },
135360
+    { PointerStyle::LinkData, "alias" },
135360
+    // MoveDataLink, CopyDataLink
135360
+    //MoveFile, CopyFile, LinkFile
135360
+    // MoveFileLink, CopyFileLink, MoveFiless, CopyFiles
135360
+    { PointerStyle::NotAllowed, "not-allowed" },
135360
+    // DrawLine through DrawCaption
135360
+    // Chart, Detective, PivotCol, PivotRow, PivotField, Chain, ChainNotAllowed
135360
+    // TimeEventMove, TimeEventSize
135360
+    // AutoScrollN through AutoScrollNSWE
135360
+    // Airbrush
135360
+    { PointerStyle::TextVertical, "vertical-text" }
135360
+    // Pivot Delete, TabSelectS through TabSelectSW
135360
+    // PaintBrush, HideWhiteSpace, ShowWhiteSpace
135360
+};
135360
+
135360
 static OUString getUString(const char* pString)
135360
 {
135360
     if (pString == NULL)
135360
@@ -1039,6 +1092,22 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
135360
     }
135360
 
135360
     pDoc->postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier);
135360
+
135360
+    Pointer aPointer = pDoc->getPointer();
135360
+
135360
+    // We don't map all possible pointers hence we need a default
135360
+    OString aPointerString = "default";
135360
+    auto aIt = aPointerMap.find(aPointer.GetStyle());
135360
+    if (aIt != aPointerMap.end())
135360
+    {
135360
+        aPointerString = aIt->second;
135360
+    }
135360
+
135360
+    LibLODocument_Impl* pLib = static_cast<LibLODocument_Impl*>(pThis);
135360
+    if (pLib->mpCallback && pLib->mpCallbackData)
135360
+    {
135360
+        pLib->mpCallback(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr(), pLib->mpCallbackData);
135360
+    }
135360
 }
135360
 
135360
 static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
135360
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
135360
index bf6267585a0a..37837ea49b86 100644
135360
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
135360
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
135360
@@ -202,7 +202,14 @@ typedef enum
135360
      *
135360
      * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
135360
      */
135360
-    LOK_CALLBACK_CELL_CURSOR
135360
+    LOK_CALLBACK_CELL_CURSOR,
135360
+
135360
+    /**
135360
+     * The current mouse pointer style.
135360
+     *
135360
+     * Payload is a css mouse pointer style.
135360
+     */
135360
+    LOK_CALLBACK_MOUSE_POINTER
135360
 }
135360
 LibreOfficeKitCallbackType;
135360
 
135360
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
135360
index 963f1fc7054a..bf0aa55e32a6 100644
135360
--- a/include/vcl/ITiledRenderable.hxx
135360
+++ b/include/vcl/ITiledRenderable.hxx
135360
@@ -14,6 +14,7 @@
135360
 #define LOK_USE_UNSTABLE_API
135360
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
135360
 #include <tools/gen.hxx>
135360
+#include <vcl/pointr.hxx>
135360
 #include <vcl/virdev.hxx>
135360
 
135360
 namespace vcl
135360
@@ -171,6 +172,8 @@ public:
135360
         return OString();
135360
     }
135360
 
135360
+    virtual Pointer getPointer() = 0;
135360
+
135360
     /// Sets the clipboard of the component.
135360
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
135360
 
135360
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
135360
index 70f61ca03548..b73eb12704be 100644
135360
--- a/sc/inc/docuno.hxx
135360
+++ b/sc/inc/docuno.hxx
135360
@@ -430,6 +430,9 @@ public:
135360
                                    int nOutputHeight,
135360
                                    long nTileWidth,
135360
                                    long nTileHeight ) override;
135360
+
135360
+    /// @see vcl::ITiledRenderable::getPointer().
135360
+    virtual Pointer getPointer() override;
135360
 };
135360
 
135360
 class ScDrawPagesObj : public cppu::WeakImplHelper2<
135360
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
135360
index 66794f3c6f27..0e5396e5910e 100644
135360
--- a/sc/source/ui/unoobj/docuno.cxx
135360
+++ b/sc/source/ui/unoobj/docuno.cxx
135360
@@ -903,6 +903,21 @@ OString ScModelObj::getCellCursor( int nOutputWidth, int nOutputHeight,
135360
     return "{ \"commandName\": \".uno:CellCursor\", \"commandValues\": \"" + pGridWindow->getCellCursor( nOutputWidth, nOutputHeight, nTileWidth, nTileHeight ) + "\" }";
135360
 }
135360
 
135360
+Pointer ScModelObj::getPointer()
135360
+{
135360
+    SolarMutexGuard aGuard;
135360
+
135360
+    ScViewData* pViewData = ScDocShell::GetViewData();
135360
+    if (!pViewData)
135360
+        return Pointer();
135360
+
135360
+    ScGridWindow* pGridWindow = pViewData->GetActiveWin();
135360
+    if (!pGridWindow)
135360
+        return Pointer();
135360
+
135360
+    return pGridWindow->GetPointer();
135360
+}
135360
+
135360
 void ScModelObj::initializeForTiledRendering()
135360
 {
135360
     SolarMutexGuard aGuard;
135360
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
135360
index 8178aab1f1fa..1c444dd478bf 100644
135360
--- a/sd/source/ui/inc/unomodel.hxx
135360
+++ b/sd/source/ui/inc/unomodel.hxx
135360
@@ -262,6 +262,8 @@ public:
135360
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
135360
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
135360
     virtual bool isMimeTypeSupported() override;
135360
+    /// @see vcl::ITiledRenderable::getPointer().
135360
+    virtual Pointer getPointer() override;
135360
 
135360
     // XComponent
135360
 
135360
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
135360
index 9475ff56c505..28ca11878044 100644
135360
--- a/sd/source/ui/unoidl/unomodel.cxx
135360
+++ b/sd/source/ui/unoidl/unomodel.cxx
135360
@@ -2568,6 +2568,20 @@ bool SdXImpressDocument::isMimeTypeSupported()
135360
     return EditEngine::HasValidData(aDataHelper.GetTransferable());
135360
 }
135360
 
135360
+Pointer SdXImpressDocument::getPointer()
135360
+{
135360
+    SolarMutexGuard aGuard;
135360
+    DrawViewShell* pViewShell = GetViewShell();
135360
+    if (!pViewShell)
135360
+        return Pointer();
135360
+
135360
+    Window* pWindow = pViewShell->GetActiveWindow();
135360
+    if (!pWindow)
135360
+        return Pointer();
135360
+
135360
+    return pWindow->GetPointer();
135360
+}
135360
+
135360
 uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
135360
 {
135360
     uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
135360
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
135360
index 85605d56c60f..e8cb116bb671 100644
135360
--- a/sw/inc/unotxdoc.hxx
135360
+++ b/sw/inc/unotxdoc.hxx
135360
@@ -438,6 +438,8 @@ public:
135360
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
135360
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
135360
     virtual bool isMimeTypeSupported() override;
135360
+    /// @see vcl::ITiledRenderable::getPointer().
135360
+    virtual Pointer getPointer() override;
135360
 
135360
     // ::com::sun::star::tiledrendering::XTiledRenderable
135360
     virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
135360
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
135360
index 4de023d1275c..53bb2506928b 100644
135360
--- a/sw/source/uibase/uno/unotxdoc.cxx
135360
+++ b/sw/source/uibase/uno/unotxdoc.cxx
135360
@@ -3214,6 +3214,17 @@ bool SwXTextDocument::isMimeTypeSupported()
135360
     return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
135360
 }
135360
 
135360
+Pointer SwXTextDocument::getPointer()
135360
+{
135360
+    SolarMutexGuard aGuard;
135360
+
135360
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
135360
+    if (!pWrtShell)
135360
+        return Pointer();
135360
+
135360
+    return pWrtShell->GetView().GetEditWin().GetPointer();
135360
+}
135360
+
135360
 int SwXTextDocument::getPart()
135360
 {
135360
     SolarMutexGuard aGuard;
135360
-- 
135360
2.12.0
135360