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

Mihai Varga mihai.varga at collabora.com
Mon Nov 16 05:03:45 PST 2015


 android/Bootstrap/src/org/libreoffice/kit/Document.java                     |    2 +
 android/source/src/java/org/libreoffice/LOKitThread.java                    |   13 +++---
 android/source/src/java/org/libreoffice/LOKitTileProvider.java              |   11 +++--
 android/source/src/java/org/libreoffice/TileProvider.java                   |    4 +-
 android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java |    4 ++
 desktop/source/lib/init.cxx                                                 |   20 +++++++++-
 desktop/source/lib/lokandroid.cxx                                           |    8 ++++
 include/LibreOfficeKit/LibreOfficeKit.h                                     |    7 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx                                   |   17 ++++++++
 include/LibreOfficeKit/LibreOfficeKitEnums.h                                |    7 +++
 include/vcl/ITiledRenderable.hxx                                            |   18 +++++++++
 sc/inc/docuno.hxx                                                           |    3 +
 sc/source/ui/app/inputhdl.cxx                                               |    8 ++++
 sc/source/ui/unoobj/docuno.cxx                                              |   18 ++++++++-
 14 files changed, 124 insertions(+), 16 deletions(-)

New commits:
commit 8a5cf61b7b0dc6668c283fe9476b3474736d33bc
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Nov 13 09:48:14 2015 +0200

    LOK: calc formula callback + formula bar implementation in gtk
    
    We need the callback to be able implement the formula bar
    
    Change-Id: I1c78ab0b9ed9304c0465a9993a7101f8efb91052
    
    Conflicts:
    	include/LibreOfficeKit/LibreOfficeKitEnums.h
    	libreofficekit/source/gtk/lokdocview.cxx
    
    Conflicts:
    	libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
    	libreofficekit/source/gtk/lokdocview.cxx

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 37837ea..7b23fcb 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -209,7 +209,12 @@ typedef enum
      *
      * Payload is a css mouse pointer style.
      */
-    LOK_CALLBACK_MOUSE_POINTER
+    LOK_CALLBACK_MOUSE_POINTER,
+
+    /**
+     * The text content of the formula bar in Calc.
+     */
+    LOK_CALLBACK_CELL_FORMULA
 }
 LibreOfficeKitCallbackType;
 
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index fe9ef00..fa2225e 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -52,6 +52,7 @@
 #include <tools/urlobj.hxx>
 #include <comphelper/string.hxx>
 #include <formula/formulahelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include "inputwin.hxx"
 #include "tabvwsh.hxx"
@@ -2138,6 +2139,11 @@ void ScInputHandler::DataChanged( bool bFromTopNotify, bool bSetModified )
 
         if ( pInputWin )
             pInputWin->SetTextString( aText );
+
+        ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell();
+        ScDocument& rDoc = pDocSh->GetDocument();
+        if ( rDoc.GetDrawLayer()->isTiledRendering() )
+            rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_CELL_FORMULA, aText.toUtf8().getStr());
     }
 
     // If the cursor is before the end of a paragraph, parts are being pushed to
@@ -3474,6 +3480,8 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
 
                         if ( pInputWin )
                             pInputWin->SetTextString(aString);
+                        else if ( rDoc.GetDrawLayer()->isTiledRendering() )
+                            rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_CELL_FORMULA, aString.toUtf8().getStr());
                     }
 
                     if ( pInputWin )                        // Named range input
commit c4d5cbfa85dba8a695ccdc98a57685bd48bbbee8
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Nov 6 14:34:28 2015 +0200

    LOK: setClientZoom() - sets the client zoom level
    
    We need to know the client's view level to correctly handle the mouse
    events in calc. PaintTile() set a zoom level that corresponds to the
    requested tiles and previously postMouseEvent would call SetZoom(1,1).
    Now we can make use of knowing the client's view level and call
    SetZoom() with the correct parameters
    
    Change-Id: I34b5afcdcc06a671a8ac92c03e87404e42adf4cd
    
    Conflicts:
    	sc/source/ui/unoobj/docuno.cxx
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    	libreofficekit/source/gtk/tilebuffer.hxx

diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 669ca94..38a024f 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -143,6 +143,8 @@ public class Document {
 
     private native int getDocumentTypeNative();
 
+    public native void setClientZoom(int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight);
+
     private native void saveAs(String url, String format, String options);
 
     private native void paintTileNative(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 5a784c7..c37f1d5 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -299,17 +299,18 @@ public class LOKitThread extends Thread {
 
         // to handle hyperlinks, enable single tap even in the Viewer
         boolean editing = LOKitShell.isEditingEnabled();
+        float zoomFactor = mViewportMetrics.getZoomFactor();
 
         if (touchType.equals("LongPress") && editing) {
             mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.TRANSITION);
-            mTileProvider.mouseButtonDown(documentCoordinate, 1);
-            mTileProvider.mouseButtonUp(documentCoordinate, 1);
-            mTileProvider.mouseButtonDown(documentCoordinate, 2);
-            mTileProvider.mouseButtonUp(documentCoordinate, 2);
+            mTileProvider.mouseButtonDown(documentCoordinate, 1, zoomFactor);
+            mTileProvider.mouseButtonUp(documentCoordinate, 1, zoomFactor);
+            mTileProvider.mouseButtonDown(documentCoordinate, 2, zoomFactor);
+            mTileProvider.mouseButtonUp(documentCoordinate, 2, zoomFactor);
         } else if (touchType.equals("SingleTap")) {
             mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.TRANSITION);
-            mTileProvider.mouseButtonDown(documentCoordinate, 1);
-            mTileProvider.mouseButtonUp(documentCoordinate, 1);
+            mTileProvider.mouseButtonDown(documentCoordinate, 1, zoomFactor);
+            mTileProvider.mouseButtonUp(documentCoordinate, 1, zoomFactor);
         } else if (touchType.equals("GraphicSelectionStart") && editing) {
             mTileProvider.setGraphicSelectionStart(documentCoordinate);
         } else if (touchType.equals("GraphicSelectionEnd") && editing) {
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index 4efbc5b..b638e5a 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -408,10 +408,11 @@ public class LOKitTileProvider implements TileProvider {
         }
     }
 
-    private void mouseButton(int type, PointF inDocument, int numberOfClicks) {
+    private void mouseButton(int type, PointF inDocument, int numberOfClicks, float zoomFactor) {
         int x = (int) pixelToTwip(inDocument.x, mDPI);
         int y = (int) pixelToTwip(inDocument.y, mDPI);
 
+        mDocument.setClientZoom(TILE_SIZE, TILE_SIZE, (int) (mTileWidth / zoomFactor), (int) (mTileHeight / zoomFactor));
         mDocument.postMouseEvent(type, x, y, numberOfClicks, Document.MOUSE_BUTTON_LEFT, Document.KEYBOARD_MODIFIER_NONE);
     }
 
@@ -419,16 +420,16 @@ public class LOKitTileProvider implements TileProvider {
      * @see TileProvider#mouseButtonDown(android.graphics.PointF, int)
      */
     @Override
-    public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks) {
-        mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks);
+    public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks, float zoomFactor) {
+        mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks, zoomFactor);
     }
 
     /**
      * @see TileProvider#mouseButtonUp(android.graphics.PointF, int)
      */
     @Override
-    public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks) {
-        mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks);
+    public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks, float zoomFactor) {
+        mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks, zoomFactor);
     }
 
     @Override
diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java
index 3104172..0ab5a1f 100644
--- a/android/source/src/java/org/libreoffice/TileProvider.java
+++ b/android/source/src/java/org/libreoffice/TileProvider.java
@@ -88,7 +88,7 @@ public interface TileProvider {
      * @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
      * @param numberOfClicks     - number of clicks (1 - single click, 2 - double click)
      */
-    void mouseButtonDown(PointF documentCoordinate, int numberOfClicks);
+    void mouseButtonDown(PointF documentCoordinate, int numberOfClicks, float zoomFactor);
 
 
     /**
@@ -107,7 +107,7 @@ public interface TileProvider {
      * @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
      * @param numberOfClicks     - number of clicks (1 - single click, 2 - double click)
      */
-    void mouseButtonUp(PointF documentCoordinate, int numberOfClicks);
+    void mouseButtonUp(PointF documentCoordinate, int numberOfClicks, float zoomFactor);
 
     /**
      * Post a UNO command to LOK.
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java b/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
index 35b4175..f90580f 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
@@ -106,6 +106,10 @@ public class ImmutableViewportMetrics {
         return new RectF(cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom);
     }
 
+    public float getZoomFactor() {
+        return zoomFactor;
+    }
+
     /*
      * Returns the viewport metrics that represent a linear transition between "this" and "to" at
      * time "t", which is on the scale [0, 1). This function interpolates all values stored in
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 13312e0..f62fcde 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -327,7 +327,11 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
                                   int nY);
 static void doc_resetSelection (LibreOfficeKitDocument* pThis);
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
-
+static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
+                                    int nTilePixelWidth,
+                                    int nTilePixelHeight,
+                                    int nTileTwipWidth,
+                                    int nTileTwipHeight);
 static int doc_createView(LibreOfficeKitDocument* pThis);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
@@ -367,6 +371,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection;
         m_pDocumentClass->resetSelection = doc_resetSelection;
         m_pDocumentClass->getCommandValues = doc_getCommandValues;
+        m_pDocumentClass->setClientZoom = doc_setClientZoom;
 
         m_pDocumentClass->createView = doc_createView;
         m_pDocumentClass->destroyView = doc_destroyView;
@@ -1479,6 +1484,19 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
     }
 }
 
+static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTilePixelWidth, int nTilePixelHeight,
+        int nTileTwipWidth, int nTileTwipHeight)
+{
+    ITiledRenderable* pDoc = getTiledRenderable(pThis);
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return;
+    }
+
+    pDoc->setClientZoom(nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
+}
+
 static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
 {
     SolarMutexGuard aGuard;
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 017ab8a..0c360d3 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -358,4 +358,12 @@ extern "C" SAL_JNI_EXPORT jstring JNICALL Java_org_libreoffice_kit_Document_getC
 
     return pEnv->NewStringUTF(pValue);
 }
+
+extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setClientZoom
+    (JNIEnv* pEnv, jobject aObject, jint nTilePixelWidth, jint nTilePixelHeight, jint nTileTwipWidth, jint nTileTwipHeight)
+{
+    LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+    pDocument->pClass->setClientZoom(pDocument, nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
+
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c887f5f..0321037 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -181,6 +181,13 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::getCommandValues().
     char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
 
+    /// @see lok::Document::setClientZoom().
+    void (*setClientZoom) (LibreOfficeKitDocument* pThis,
+            int nTilePixelWidth,
+            int nTilePixelHeight,
+            int nTileTwipWidth,
+            int nTileTwipHeight);
+
     /// @see lok::Document::createView().
     int (*createView) (LibreOfficeKitDocument* pThis);
     /// @see lok::Document::destroyView().
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 3268216..93e8772 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -291,6 +291,23 @@ public:
     }
 
     /**
+     * Save the client's view so that we can compute the right zoom level
+     * for the mouse events. This only affects CALC.
+     * @param nTilePixelWidth - tile width in pixels
+     * @param nTilePixelHeight - tile height in pixels
+     * @param nTileTwipWidth - tile width in twips
+     * @param nTileTwipHeight - tile height in twips
+     */
+    inline void setClientZoom(
+            int nTilePixelWidth,
+            int nTilePixelHeight,
+            int nTileTwipWidth,
+            int nTileTwipHeight)
+    {
+        mpDoc->pClass->setClientZoom(mpDoc, nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
+    }
+
+    /**
      * Create a new view for an existing document.
      * By default a loaded document has 1 view.
      * @return the ID of the new view.
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 7f9bed1..108e089 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -22,6 +22,9 @@ namespace vcl
 
 class VCL_DLLPUBLIC ITiledRenderable
 {
+protected:
+    int nTilePixelWidth, nTilePixelHeight;
+    int nTileTwipWidth, nTileTwipHeight;
 public:
     virtual ~ITiledRenderable();
 
@@ -179,6 +182,21 @@ public:
 
     /// If the current contents of the clipboard is something we can paste.
     virtual bool isMimeTypeSupported() = 0;
+
+    /**
+     * Save the client's view so that we can compute the right zoom level
+     * for the mouse events.
+     * @param nTilePixelWidth - tile width in pixels
+     * @param nTilePixelHeight - tile height in pixels
+     * @param nTileTwipWidth - tile width in twips
+     * @param nTileTwipHeight - tile height in twips
+     */
+    virtual void setClientZoom(int /*nTilePixelWidth*/,
+                               int /*nTilePixelHeight*/,
+                               int /*nTileTwipWidth*/,
+                               int /*nTileTwipHeight*/)
+    {
+    }
 };
 
 } // namespace vcl
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 62400df..32209b8 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -422,6 +422,9 @@ public:
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
 
+    /// @see vcl::ITiledRenderable::setClientZoom().
+    virtual void setClientZoom(int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight) override;
+
     /// @see vcl::ITiledRenderable::getRowColumnHeaders().
     virtual OUString getRowColumnHeaders(const Rectangle& rRectangle) SAL_OVERRIDE;
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 75e035e..5b0caaa 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -589,7 +589,8 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt
         return;
 
     // update the aLogicMode in ScViewData to something predictable
-    pViewData->SetZoom(Fraction(1, 1), Fraction(1, 1), true);
+    pViewData->SetZoom(Fraction(nTilePixelWidth * TWIPS_PER_PIXEL, nTileTwipWidth),
+                       Fraction(nTilePixelHeight * TWIPS_PER_PIXEL, nTileTwipHeight), true);
 
     // Calc operates in pixels...
     MouseEvent aEvent(Point(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()), nCount,
@@ -855,6 +856,14 @@ bool ScModelObj::isMimeTypeSupported()
     return EditEngine::HasValidData(aDataHelper.GetTransferable());
 }
 
+void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int nTileTwipWidth_, int nTileTwipHeight_)
+{
+    nTilePixelWidth = nTilePixelWidth_;
+    nTilePixelHeight = nTilePixelHeight_;
+    nTileTwipWidth = nTileTwipWidth_;
+    nTileTwipHeight = nTileTwipHeight_;
+}
+
 OUString ScModelObj::getRowColumnHeaders(const Rectangle& rRectangle)
 {
     ScViewData* pViewData = ScDocShell::GetViewData();
@@ -913,6 +922,13 @@ void ScModelObj::initializeForTiledRendering()
     // tdf#93154: in tiled rendering LO doesn't always detect changes
     SvtMiscOptions aMiscOpt;
     aMiscOpt.SetSaveAlwaysAllowed(true);
+
+    // default tile size in pixels
+    nTilePixelWidth = 256;
+    nTilePixelHeight = 256;
+    // the default zoom level will be 1
+    nTileTwipWidth = nTilePixelWidth * TWIPS_PER_PIXEL;
+    nTileTwipHeight = nTilePixelHeight * TWIPS_PER_PIXEL;
 }
 
 uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )


More information about the Libreoffice-commits mailing list