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