Kaydet (Commit) 81b8ca68 authored tarafından Andrzej Hunt's avatar Andrzej Hunt

Implement LOK_CALLBACK_MOUSE_POINTER

Change-Id: I8d1f63208baf277b0a9d15908f3ea7ff3b56bf10
Reviewed-on: https://gerrit.libreoffice.org/19883Reviewed-by: 's avatarAndrzej Hunt <andrzej@ahunt.org>
Tested-by: 's avatarAndrzej Hunt <andrzej@ahunt.org>
üst ee74deca
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include <tools/fract.hxx> #include <tools/fract.hxx>
#include <svtools/ctrltool.hxx> #include <svtools/ctrltool.hxx>
#include <vcl/graphicfilter.hxx> #include <vcl/graphicfilter.hxx>
#include <vcl/ptrstyle.hxx>
#include <vcl/sysdata.hxx> #include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
#include <vcl/ITiledRenderable.hxx> #include <vcl/ITiledRenderable.hxx>
...@@ -174,6 +175,58 @@ static const ExtensionMap aDrawExtensionMap[] = ...@@ -174,6 +175,58 @@ static const ExtensionMap aDrawExtensionMap[] =
{ nullptr, nullptr } { nullptr, nullptr }
}; };
/*
* 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 <PointerStyle, OString> 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) static OUString getUString(const char* pString)
{ {
if (pString == nullptr) if (pString == nullptr)
...@@ -1040,6 +1093,22 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, ...@@ -1040,6 +1093,22 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
} }
pDoc->postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier); 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<LibLODocument_Impl*>(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) static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
......
...@@ -202,7 +202,14 @@ typedef enum ...@@ -202,7 +202,14 @@ typedef enum
* *
* Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES. * 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; LibreOfficeKitCallbackType;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define LOK_USE_UNSTABLE_API #define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKitTypes.h> #include <LibreOfficeKit/LibreOfficeKitTypes.h>
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <vcl/pointr.hxx>
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
...@@ -172,6 +173,8 @@ public: ...@@ -172,6 +173,8 @@ public:
return OString(); return OString();
} }
virtual Pointer getPointer() = 0;
/// Sets the clipboard of the component. /// Sets the clipboard of the component.
virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0; virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
......
...@@ -413,6 +413,9 @@ public: ...@@ -413,6 +413,9 @@ public:
int nOutputHeight, int nOutputHeight,
long nTileWidth, long nTileWidth,
long nTileHeight ) override; long nTileHeight ) override;
/// @see vcl::ITiledRenderable::getPointer().
virtual Pointer getPointer() override;
}; };
class ScDrawPagesObj : public cppu::WeakImplHelper< class ScDrawPagesObj : public cppu::WeakImplHelper<
......
...@@ -902,6 +902,21 @@ OString ScModelObj::getCellCursor( int nOutputWidth, int nOutputHeight, ...@@ -902,6 +902,21 @@ OString ScModelObj::getCellCursor( int nOutputWidth, int nOutputHeight,
return "{ \"commandName\": \".uno:CellCursor\", \"commandValues\": \"" + pGridWindow->getCellCursor( nOutputWidth, nOutputHeight, nTileWidth, nTileHeight ) + "\" }"; 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() void ScModelObj::initializeForTiledRendering()
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
......
...@@ -263,6 +263,8 @@ public: ...@@ -263,6 +263,8 @@ public:
virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override; virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
/// @see vcl::ITiledRenderable::isMimeTypeSupported(). /// @see vcl::ITiledRenderable::isMimeTypeSupported().
virtual bool isMimeTypeSupported() override; virtual bool isMimeTypeSupported() override;
/// @see vcl::ITiledRenderable::getPointer().
virtual Pointer getPointer() override;
// XComponent // XComponent
......
...@@ -2558,6 +2558,20 @@ bool SdXImpressDocument::isMimeTypeSupported() ...@@ -2558,6 +2558,20 @@ bool SdXImpressDocument::isMimeTypeSupported()
return EditEngine::HasValidData(aDataHelper.GetTransferable()); 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 > SdXImpressDocument::getForbiddenCharsTable()
{ {
uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters); uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
......
...@@ -435,6 +435,8 @@ public: ...@@ -435,6 +435,8 @@ public:
virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override; virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
/// @see vcl::ITiledRenderable::isMimeTypeSupported(). /// @see vcl::ITiledRenderable::isMimeTypeSupported().
virtual bool isMimeTypeSupported() override; virtual bool isMimeTypeSupported() override;
/// @see vcl::ITiledRenderable::getPointer().
virtual Pointer getPointer() override;
// css::tiledrendering::XTiledRenderable // css::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) override; 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) override;
......
...@@ -3165,6 +3165,17 @@ bool SwXTextDocument::isMimeTypeSupported() ...@@ -3165,6 +3165,17 @@ bool SwXTextDocument::isMimeTypeSupported()
return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper); 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() int SwXTextDocument::getPart()
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment