[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 2 commits - desktop/source include/LibreOfficeKit include/vcl sc/inc sc/source sd/source sw/inc sw/source

Andrzej Hunt andrzej at ahunt.org
Wed Nov 11 04:27:59 PST 2015


 desktop/source/lib/init.cxx                  |   69 +++++++++++++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKitEnums.h |    9 +++
 include/vcl/ITiledRenderable.hxx             |    3 +
 sc/inc/docuno.hxx                            |    3 +
 sc/source/ui/inc/gridwin.hxx                 |    8 ---
 sc/source/ui/unoobj/docuno.cxx               |   15 +++++
 sc/source/ui/view/gridwin.cxx                |    4 +
 sc/source/ui/view/gridwin4.cxx               |    6 +-
 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 ++++
 12 files changed, 133 insertions(+), 13 deletions(-)

New commits:
commit c34df1dadcec05c9a45ede4bab8e2fea9d3c0720
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Wed Nov 11 10:05:25 2015 +0100

    Implement LOK_CALLBACK_MOUSE_POINTER
    
    Reviewed-on: https://gerrit.libreoffice.org/19883
    Reviewed-by: Andrzej Hunt <andrzej at ahunt.org>
    Tested-by: Andrzej Hunt <andrzej at ahunt.org>
    (cherry picked from commit 81b8ca683d44ba9c37f2dc8c74470a86ce70513f)
    
    Conflicts:
    	sc/inc/docuno.hxx
    	sd/source/ui/inc/unomodel.hxx
    	sw/inc/unotxdoc.hxx
    
    Change-Id: I8d1f63208baf277b0a9d15908f3ea7ff3b56bf10

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index dfb37b9..b672525 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -73,6 +73,7 @@
 #include <tools/fract.hxx>
 #include <svtools/ctrltool.hxx>
 #include <vcl/graphicfilter.hxx>
+#include <vcl/ptrstyle.hxx>
 #include <vcl/sysdata.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/ITiledRenderable.hxx>
@@ -183,6 +184,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 <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)
 {
     if (pString == NULL)
@@ -1048,6 +1101,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<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)
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index bf62675..37837ea 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 e3ad01b..7f9bed1 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -14,6 +14,7 @@
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
 #include <tools/gen.hxx>
+#include <vcl/pointr.hxx>
 #include <vcl/virdev.hxx>
 
 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<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
 
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index b384ede..62400df 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -430,6 +430,9 @@ public:
                                    int nOutputHeight,
                                    long nTileWidth,
                                    long nTileHeight ) SAL_OVERRIDE;
+
+    /// @see vcl::ITiledRenderable::getPointer().
+    virtual Pointer getPointer() SAL_OVERRIDE;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index c216b36..75e035e 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -885,6 +885,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 14162e3..e56549b 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<css::datatransfer::clipboard::XClipboard>& xClipboard) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::getPointer().
+    virtual Pointer getPointer() SAL_OVERRIDE;
 
     // XComponent
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 9475ff5..28ca118 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 4a3307b..63695f0 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -438,6 +438,8 @@ public:
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::getPointer().
+    virtual Pointer getPointer() SAL_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 58a61e8..db61ce3 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;
commit d3ddd695fbde04d3f283b6e2c8cfeed113cf52e1
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Fri Nov 6 17:36:18 2015 +0100

    Revert "sc lok: Cache viewdata zoom and reuse for cursor callback"
    
    This reverts fab3c48a0cd5a0517025993502a04358308fe5ef for now.
    The correct solution is to have the client "hint" at the current
    resolution, which is still being developed
    (gerrit-id: I34b5afcdcc06a671a8ac92c03e87404e42adf4cd).
    For now the cursor will be wrongly positioned when moved as the result
    of a mouse click.
    
    Reviewed-on: https://gerrit.libreoffice.org/19827
    Tested-by: Andrzej Hunt <andrzej at ahunt.org>
    Reviewed-by: Andrzej Hunt <andrzej at ahunt.org>
    (cherry picked from commit 064fb1f73abbc103226a8fce8a46b7e8b8347dac)
    
    Conflicts:
    	sc/source/ui/inc/gridwin.hxx
    
    Change-Id: I68d56eac958e607e8e2e3ad16aff4e1a7dd0b6dd

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index b040e92..dc1cec7 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -202,14 +202,6 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
 
     DECL_LINK( PopupModeEndHdl, void* );
     DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* );
-    // We cache the tiled rendering zoom level in order to be able to
-    // calculate the correct cell cursor position (which is dependent
-    // on the zoom level). The caching is necessary since
-    // ScModelObj::postMouseEvent resets the zoom level to the default,
-    // which means we have the default zoom level set during the
-    // cell cursor position calculations in updateLibreOfficeKitCellCursor().
-    Fraction                mTiledZoomX;
-    Fraction                mTiledZoomY;
 
     bool            TestMouse( const MouseEvent& rMEvt, bool bAction );
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 079653b..2531bc7 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5834,7 +5834,9 @@ void ScGridWindow::updateLibreOfficeKitCellCursor()
 {
     ScDocument* pDoc = pViewData->GetDocument();
     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
-    OString aCursor = getCellCursor(mTiledZoomX, mTiledZoomY);
+    // TODO: the zoom levels here should be replaced by the setClientZoom values
+    // in a patch currently in gerrit (https://gerrit.libreoffice.org/#/c/19822/)
+    OString aCursor = getCellCursor(pViewData->GetZoomX(), pViewData->GetZoomY());
     pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
 }
 
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index cfdde43..ceaf3d8 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -955,11 +955,11 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     // Similarly to Writer, we should set the mapmode once on the rDevice, and
     // not care about any zoom settings.
 
-    mTiledZoomX = Fraction(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
-    mTiledZoomY = Fraction(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
+    Fraction aFracX(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
+    Fraction aFracY(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
 
     // page break zoom, and aLogicMode in ScViewData
-    pViewData->SetZoom(mTiledZoomX, mTiledZoomY, true);
+    pViewData->SetZoom(aFracX, aFracY, true);
 
     double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / nTileWidth;
     double fTilePosYPixel = static_cast<double>(nTilePosY) * nOutputHeight / nTileHeight;


More information about the Libreoffice-commits mailing list