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