[Libreoffice-commits] core.git: 66 commits - android/Bootstrap android/experimental android/README editeng/source include/LibreOfficeKit include/svx include/vcl libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/qa libreofficekit/source sc/inc sc/source sd/source svx/source sw/inc vcl/source

Jan Holesovsky kendy at collabora.com
Mon Mar 30 00:24:40 PDT 2015


 android/Bootstrap/Makefile.shared                                                                        |    2 
 android/Bootstrap/project.properties                                                                     |    2 
 android/README                                                                                           |  128 +
 android/experimental/DocumentLoader/project.properties                                                   |    2 
 android/experimental/LOAndroid3/AndroidManifest.xml.in                                                   |    1 
 android/experimental/LOAndroid3/res/layout/activity_document_browser.xml                                 |   36 
 android/experimental/LOAndroid3/res/layout/file_grid.xml                                                 |   20 
 android/experimental/LOAndroid3/res/layout/file_list.xml                                                 |   20 
 android/experimental/LOAndroid3/res/layout/text_selection_handles.xml                                    |   46 
 android/experimental/LOAndroid3/res/menu/view_menu.xml                                                   |    9 
 android/experimental/LOAndroid3/res/values-v21/themes.xml                                                |   10 
 android/experimental/LOAndroid3/res/values/themes.xml                                                    |    2 
 android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java                    |    9 
 android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java                       |   32 
 android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java                    |  256 +++
 android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java       |   75 
 android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java              |  141 +
 android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java |   67 
 android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java                     |  173 --
 android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java                   |   30 
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/TextSelection.java                            |    5 
 android/experimental/desktop/project.properties                                                          |    2 
 editeng/source/editeng/editview.cxx                                                                      |    1 
 editeng/source/editeng/impedit.cxx                                                                       |    9 
 include/LibreOfficeKit/LibreOfficeKitEnums.h                                                             |   22 
 include/LibreOfficeKit/LibreOfficeKitGtk.h                                                               |    3 
 include/svx/sdr/table/tablecontroller.hxx                                                                |    4 
 include/svx/selectioncontroller.hxx                                                                      |    5 
 include/svx/svdmodel.hxx                                                                                 |    3 
 include/vcl/ITiledRenderable.hxx                                                                         |   14 
 libreofficekit/Executable_gtktiledviewer.mk                                                              |    2 
 libreofficekit/Library_libreofficekitgtk.mk                                                              |    1 
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx                                                      |   69 
 libreofficekit/source/gtk/lokdocview.cxx                                                                 |  828 +++++-----
 sc/inc/docuno.hxx                                                                                        |   13 
 sc/source/ui/app/inputhdl.cxx                                                                            |   13 
 sc/source/ui/inc/gridwin.hxx                                                                             |    9 
 sc/source/ui/unoobj/docuno.cxx                                                                           |  134 +
 sc/source/ui/view/gridwin.cxx                                                                            |   87 -
 sc/source/ui/view/gridwin4.cxx                                                                           |   70 
 sd/source/ui/func/fusel.cxx                                                                              |    7 
 sd/source/ui/inc/ViewShell.hxx                                                                           |    4 
 sd/source/ui/inc/fupoor.hxx                                                                              |    2 
 sd/source/ui/inc/unomodel.hxx                                                                            |    6 
 sd/source/ui/unoidl/unomodel.cxx                                                                         |   72 
 sd/source/ui/view/viewshel.cxx                                                                           |   38 
 svx/source/sdr/overlay/overlayobjectlist.cxx                                                             |    6 
 svx/source/svdraw/selectioncontroller.cxx                                                                |    9 
 svx/source/svdraw/svdmrkv.cxx                                                                            |   44 
 svx/source/svdraw/svdobj.cxx                                                                             |    1 
 svx/source/table/tablecontroller.cxx                                                                     |   94 +
 sw/inc/viewsh.hxx                                                                                        |    3 
 vcl/source/window/paint.cxx                                                                              |    2 
 53 files changed, 1732 insertions(+), 911 deletions(-)

New commits:
commit 7fbfd04c2e348dbebd7d97ceecfcbea547de5b52
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Mar 27 22:25:28 2015 +0100

    sc tiled editing: Hide the cell selection when we select graphic.
    
    Change-Id: I50f68cc292e971af8bb59782e0495d6142007d67

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0856107..5c301f0 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5913,9 +5913,11 @@ void ScGridWindow::UpdateCursorOverlay()
             mpOOCursors->append(*pOverlay);
 
             // notify the LibreOfficeKit too, but only if there's no
-            // selection yet, to avoid setting the LOK selection twice
+            // selection yet (either cell selection, or graphic object),
+            // to avoid setting the LOK selection twice
             // (once for the cell only, and then for the selection)
-            if (!pViewData->GetMarkData().IsMarked() && !pViewData->GetMarkData().IsMultiMarked())
+            if (!pViewData->GetMarkData().IsMarked() && !pViewData->GetMarkData().IsMultiMarked() &&
+                !pViewData->GetViewShell()->GetScDrawView()->IsMarking())
             {
                 updateLibreOfficeKitSelection(pViewData, pDoc->GetDrawLayer(), aPixelRects);
             }
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 28629e5..52194e4 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -737,6 +737,9 @@ void SdrMarkView::SetMarkHandles()
                 }
 
                 sSelection = aSelection.toString();
+
+                // hide the text selection too
+                GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "");
             }
             GetModel()->libreOfficeKitCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelection.getStr());
         }
commit 9987747c47dba52a5c83956f370941aa25bf5d6a
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Mar 27 22:23:33 2015 +0100

    sc tiled editing: Improve the deselection.
    
    Change-Id: Ia7e320bbb8b61497f33e20b9b80aabfed4f75234

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 5bf0c05..35566dc 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -567,7 +567,8 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
     SolarMutexGuard aGuard;
 
     ScViewData* pViewData = ScDocShell::GetViewData();
-    ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewData->GetViewShell());
+    ScTabViewShell* pViewShell = pViewData->GetViewShell();
+    ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewShell);
 
     if (pInputHandler && pInputHandler->IsInputMode())
     {
@@ -594,8 +595,6 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
     }
     else
     {
-        // moving the cell selection handles
-
         // There seems to be no clear way of getting the grid window for this
         // particular document, hence we need to hope we get the right window.
         ScGridWindow* pGridWindow = pViewData->GetActiveWin();
@@ -603,6 +602,7 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
         if (!pGridWindow)
             return;
 
+        // move the cell selection handles
         pGridWindow->SetCellSelectionPixel(nType, nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY());
     }
 }
@@ -648,10 +648,17 @@ void ScModelObj::resetSelection()
     SolarMutexGuard aGuard;
 
     ScViewData* pViewData = ScDocShell::GetViewData();
-    ScTabView* pTabView  = pViewData->GetView();
+    ScTabViewShell* pViewShell = pViewData->GetViewShell();
 
-    // deselect the shapes
-    pTabView->DrawDeselectAll();
+    // deselect the shapes & texts
+    ScDrawView* pDrawView = pViewShell->GetScDrawView();
+    if (pDrawView)
+    {
+        pDrawView->ScEndTextEdit();
+        pDrawView->UnmarkAll();
+    }
+    else
+        pViewShell->Unmark();
 
     // and hide the cell and text selection
     pDocShell->GetDocument().GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "");
commit 99394c8e09631280f9d76a790832133f5ef7b873
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 27 19:49:02 2015 +0100

    Add SvxTableController::setCursorLogicPosition()
    
    With this, it's possible to drag the start or end handle of an Impress
    table selection and let it grow/shrink.
    
    Change-Id: Icdee1207c1c3a6b1c4fb15d00008db6327d6e2de

diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index b6d610c..6145dc4 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -93,6 +93,8 @@ public:
     SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) SAL_OVERRIDE;
 
     SVX_DLLPRIVATE virtual bool hasSelectedCells() const SAL_OVERRIDE { return mbCellSelectionMode || mpView->IsTextEdit(); }
+    /// @see sdr::SelectionController::setCursorLogicPosition().
+    SVX_DLLPRIVATE virtual void setCursorLogicPosition(const Point& rPosition, bool bPoint) SAL_OVERRIDE;
 
     void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
     void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
diff --git a/include/svx/selectioncontroller.hxx b/include/svx/selectioncontroller.hxx
index f629b20..214ccd9 100644
--- a/include/svx/selectioncontroller.hxx
+++ b/include/svx/selectioncontroller.hxx
@@ -32,6 +32,7 @@ class SfxRequest;
 class SfxStyleSheet;
 class SdrPage;
 class SdrModel;
+class Point;
 
 namespace sdr
 {
@@ -70,6 +71,8 @@ public:
     virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
     /// This is a table object, and one or more of its cells are selected.
     virtual bool hasSelectedCells() const;
+    /// Allows adjusting the point or mark of the selection to a document coordinate.
+    virtual void setCursorLogicPosition(const Point& rPosition, bool bPoint);
 };
 
 }
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index a0ab3f0..4845178 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -541,6 +541,13 @@ void ViewShell::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool
             EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
             rEditView.SetCursorLogicPosition(rPosition, bPoint, bClearMark);
         }
+        else
+        {
+            // No text edit object, then try to adjust table selection.
+            rtl::Reference<sdr::SelectionController> xSelectionController(GetView()->getSelectionController());
+            if (xSelectionController.is())
+                xSelectionController->setCursorLogicPosition(rPosition, bPoint);
+        }
     }
 }
 
diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx
index a2ff875..6d84934 100644
--- a/svx/source/svdraw/selectioncontroller.cxx
+++ b/svx/source/svdraw/selectioncontroller.cxx
@@ -105,6 +105,10 @@ bool SelectionController::hasSelectedCells() const
     return false;
 }
 
+void SelectionController::setCursorLogicPosition(const Point& /*rPosition*/, bool /*bPoint*/)
+{
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index fdd8481..e487b06 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -3148,6 +3148,24 @@ bool SvxTableController::isColumnHeader()
 
     return aSettings.mbUseFirstColumn;
 }
+
+void SvxTableController::setCursorLogicPosition(const Point& rPosition, bool bPoint)
+{
+    if (mxTableObj->GetObjIdentifier() != OBJ_TABLE)
+        return;
+
+    SdrTableObj* pTableObj = static_cast<SdrTableObj*>(mxTableObj.get());
+    CellPos aCellPos;
+    if (pTableObj->CheckTableHit(rPosition, aCellPos.mnCol, aCellPos.mnRow, 0) != SDRTABLEHIT_NONE)
+    {
+        if (bPoint)
+            maCursorLastPos = aCellPos;
+        else
+            maCursorFirstPos = aCellPos;
+        mpView->MarkListHasChanged();
+    }
+}
+
 } }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit dc755a3f7581b915f1f278e87af04d164514061d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 27 16:11:40 2015 +0100

    lokdocview: move handle rendering to LOKDocView_Impl
    
    Change-Id: I52537a96af596db076c38dc607abe857d0771257

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index ebcf11f..f73b0d7 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -132,6 +132,15 @@ struct LOKDocView_Impl
     static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, LOKDocView* pDocView);
     /// Implementation of expose event handler (renders cursor and selection overlay), invoked by renderOverlay().
     gboolean renderOverlayImpl(GtkWidget* pEventBox);
+    /// Is rRectangle empty?
+    static bool isEmptyRectangle(const GdkRectangle& rRectangle);
+    /**
+     * Renders pHandle below an rCursor rectangle on pCairo.
+     * @param rRectangle output parameter, the rectangle that contains the rendered handle.
+     */
+    void renderHandle(cairo_t* pCairo, const GdkRectangle& rCursor, cairo_surface_t* pHandle, GdkRectangle& rRectangle);
+    /// Renders pHandle around an rSelection rectangle on pCairo.
+    void renderGraphicHandle(cairo_t* pCairo, const GdkRectangle& rSelection, cairo_surface_t* pHandle);
 };
 
 LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
@@ -455,17 +464,12 @@ gboolean LOKDocView_Impl::renderOverlay(GtkWidget* pEventBox, GdkEventExpose* /*
     return pDocView->m_pImpl->renderOverlayImpl(pEventBox);
 }
 
-static gboolean lcl_isEmptyRectangle(GdkRectangle* pRectangle);
-static void lcl_renderHandle(cairo_t* pCairo, GdkRectangle* pCursor, cairo_surface_t* pHandle,
-                             GdkRectangle* pRectangle, LOKDocView* pDocView);
-static void lcl_renderGraphicHandle(cairo_t* pCairo, GdkRectangle* pSelection, cairo_surface_t* pHandle, GdkRectangle* pGraphicHandleRects, LOKDocView* pDocView);
-
 gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
 {
 #if GTK_CHECK_VERSION(2,14,0) // we need gtk_widget_get_window()
     cairo_t* pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
 
-    if (m_bEdit && m_bCursorVisible && m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&m_aVisibleCursor))
+    if (m_bEdit && m_bCursorVisible && m_bCursorOverlayVisible && !isEmptyRectangle(m_aVisibleCursor))
     {
         if (m_aVisibleCursor.width < 30)
             // Set a minimal width if it would be 0.
@@ -480,12 +484,12 @@ gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
         cairo_fill(pCairo);
     }
 
-    if (m_bEdit && m_bCursorVisible && !lcl_isEmptyRectangle(&m_aVisibleCursor) && !m_pTextSelectionRectangles)
+    if (m_bEdit && m_bCursorVisible && !isEmptyRectangle(m_aVisibleCursor) && !m_pTextSelectionRectangles)
     {
         // Have a cursor, but no selection: we need the middle handle.
         if (!m_pHandleMiddle)
             m_pHandleMiddle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_middle.png");
-        lcl_renderHandle(pCairo, &m_aVisibleCursor, m_pHandleMiddle, &m_aHandleMiddleRect, m_pDocView);
+        renderHandle(pCairo, m_aVisibleCursor, m_pHandleMiddle, m_aHandleMiddleRect);
     }
 
     if (m_pTextSelectionRectangles)
@@ -504,31 +508,27 @@ gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
         }
 
         // Handles
-        if (!lcl_isEmptyRectangle(&m_aTextSelectionStart))
+        if (!isEmptyRectangle(m_aTextSelectionStart))
         {
             // Have a start position: we need a start handle.
             if (!m_pHandleStart)
                 m_pHandleStart = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_start.png");
-            lcl_renderHandle(pCairo, &m_aTextSelectionStart,
-                             m_pHandleStart, &m_aHandleStartRect,
-                             m_pDocView);
+            renderHandle(pCairo, m_aTextSelectionStart, m_pHandleStart, m_aHandleStartRect);
         }
-        if (!lcl_isEmptyRectangle(&m_aTextSelectionEnd))
+        if (!isEmptyRectangle(m_aTextSelectionEnd))
         {
             // Have a start position: we need an end handle.
             if (!m_pHandleEnd)
                 m_pHandleEnd = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_end.png");
-            lcl_renderHandle(pCairo, &m_aTextSelectionEnd,
-                             m_pHandleEnd, &m_aHandleEndRect,
-                             m_pDocView);
+            renderHandle(pCairo, m_aTextSelectionEnd, m_pHandleEnd, m_aHandleEndRect);
         }
     }
 
-    if (!lcl_isEmptyRectangle(&m_aGraphicSelection))
+    if (!isEmptyRectangle(m_aGraphicSelection))
     {
         if (!m_pGraphicHandle)
             m_pGraphicHandle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_graphic.png");
-        lcl_renderGraphicHandle(pCairo, &m_aGraphicSelection, m_pGraphicHandle, m_aGraphicHandleRects, m_pDocView);
+        renderGraphicHandle(pCairo, m_aGraphicSelection, m_pGraphicHandle);
     }
 
     cairo_destroy(pCairo);
@@ -536,6 +536,101 @@ gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
     return FALSE;
 }
 
+bool LOKDocView_Impl::isEmptyRectangle(const GdkRectangle& rRectangle)
+{
+    return rRectangle.x == 0 && rRectangle.y == 0 && rRectangle.width == 0 && rRectangle.height == 0;
+}
+
+void LOKDocView_Impl::renderHandle(cairo_t* pCairo, const GdkRectangle& rCursor, cairo_surface_t* pHandle, GdkRectangle& rRectangle)
+{
+    GdkPoint aCursorBottom;
+    int nHandleWidth, nHandleHeight;
+    double fHandleScale;
+
+    nHandleWidth = cairo_image_surface_get_width(pHandle);
+    nHandleHeight = cairo_image_surface_get_height(pHandle);
+    // We want to scale down the handle, so that its height is the same as the cursor caret.
+    fHandleScale = twipToPixel(rCursor.height) / nHandleHeight;
+    // We want the top center of the handle bitmap to be at the bottom center of the cursor rectangle.
+    aCursorBottom.x = twipToPixel(rCursor.x) + twipToPixel(rCursor.width) / 2 - (nHandleWidth * fHandleScale) / 2;
+    aCursorBottom.y = twipToPixel(rCursor.y) + twipToPixel(rCursor.height);
+    cairo_save(pCairo);
+    cairo_translate(pCairo, aCursorBottom.x, aCursorBottom.y);
+    cairo_scale(pCairo, fHandleScale, fHandleScale);
+    cairo_set_source_surface(pCairo, pHandle, 0, 0);
+    cairo_paint(pCairo);
+    cairo_restore(pCairo);
+
+    rRectangle.x = aCursorBottom.x;
+    rRectangle.y = aCursorBottom.y;
+    rRectangle.width = nHandleWidth * fHandleScale;
+    rRectangle.height = nHandleHeight * fHandleScale;
+}
+
+/// Renders pHandle around an rSelection rectangle on pCairo.
+void LOKDocView_Impl::renderGraphicHandle(cairo_t* pCairo, const GdkRectangle& rSelection, cairo_surface_t* pHandle)
+{
+    int nHandleWidth, nHandleHeight;
+    GdkRectangle aSelection;
+
+    nHandleWidth = cairo_image_surface_get_width(pHandle);
+    nHandleHeight = cairo_image_surface_get_height(pHandle);
+
+    aSelection.x = twipToPixel(rSelection.x);
+    aSelection.y = twipToPixel(rSelection.y);
+    aSelection.width = twipToPixel(rSelection.width);
+    aSelection.height = twipToPixel(rSelection.height);
+
+    for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
+    {
+        int x = aSelection.x, y = aSelection.y;
+        cairo_save(pCairo);
+
+        switch (i)
+        {
+        case 0: // top-left
+            break;
+        case 1: // top-middle
+            x += aSelection.width / 2;
+            break;
+        case 2: // top-right
+            x += aSelection.width;
+            break;
+        case 3: // middle-left
+            y += aSelection.height / 2;
+            break;
+        case 4: // middle-right
+            x += aSelection.width;
+            y += aSelection.height / 2;
+            break;
+        case 5: // bottom-left
+            y += aSelection.height;
+            break;
+        case 6: // bottom-middle
+            x += aSelection.width / 2;
+            y += aSelection.height;
+            break;
+        case 7: // bottom-right
+            x += aSelection.width;
+            y += aSelection.height;
+            break;
+        }
+
+        // Center the handle.
+        x -= nHandleWidth / 2;
+        y -= nHandleHeight / 2;
+
+        m_aGraphicHandleRects[i].x = x;
+        m_aGraphicHandleRects[i].y = y;
+        m_aGraphicHandleRects[i].width = nHandleWidth;
+        m_aGraphicHandleRects[i].height = nHandleHeight;
+
+        cairo_translate(pCairo, x, y);
+        cairo_set_source_surface(pCairo, pHandle, 0, 0);
+        cairo_paint(pCairo);
+        cairo_restore(pCairo);
+    }
+}
 
 static void lok_docview_class_init( gpointer );
 static void lok_docview_init( GTypeInstance *, gpointer );
@@ -619,11 +714,6 @@ SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
     return GTK_WIDGET( pDocView );
 }
 
-static gboolean lcl_isEmptyRectangle(GdkRectangle* pRectangle)
-{
-    return pRectangle->x == 0 && pRectangle->y == 0 && pRectangle->width == 0 && pRectangle->height == 0;
-}
-
 /// Takes care of the blinking cursor.
 static gboolean lcl_handleTimeout(gpointer pData)
 {
@@ -641,103 +731,6 @@ static gboolean lcl_handleTimeout(gpointer pData)
     return G_SOURCE_CONTINUE;
 }
 
-/// Renders pHandle below a pCursor rectangle on pCairo.
-static void lcl_renderHandle(cairo_t* pCairo, GdkRectangle* pCursor, cairo_surface_t* pHandle,
-                             GdkRectangle* pRectangle, LOKDocView* pDocView)
-{
-    GdkPoint aCursorBottom;
-    int nHandleWidth, nHandleHeight;
-    double fHandleScale;
-
-    nHandleWidth = cairo_image_surface_get_width(pHandle);
-    nHandleHeight = cairo_image_surface_get_height(pHandle);
-    // We want to scale down the handle, so that its height is the same as the cursor caret.
-    fHandleScale = pDocView->m_pImpl->twipToPixel(pCursor->height) / nHandleHeight;
-    // We want the top center of the handle bitmap to be at the bottom center of the cursor rectangle.
-    aCursorBottom.x = pDocView->m_pImpl->twipToPixel(pCursor->x) + pDocView->m_pImpl->twipToPixel(pCursor->width) / 2 - (nHandleWidth * fHandleScale) / 2;
-    aCursorBottom.y = pDocView->m_pImpl->twipToPixel(pCursor->y) + pDocView->m_pImpl->twipToPixel(pCursor->height);
-    cairo_save(pCairo);
-    cairo_translate(pCairo, aCursorBottom.x, aCursorBottom.y);
-    cairo_scale(pCairo, fHandleScale, fHandleScale);
-    cairo_set_source_surface(pCairo, pHandle, 0, 0);
-    cairo_paint(pCairo);
-    cairo_restore(pCairo);
-
-    if (pRectangle)
-    {
-        // Return the rectangle that contains the rendered handle.
-        pRectangle->x = aCursorBottom.x;
-        pRectangle->y = aCursorBottom.y;
-        pRectangle->width = nHandleWidth * fHandleScale;
-        pRectangle->height = nHandleHeight * fHandleScale;
-    }
-}
-
-/// Renders pHandle around a pSelection rectangle on pCairo.
-static void lcl_renderGraphicHandle(cairo_t* pCairo, GdkRectangle* pSelection, cairo_surface_t* pHandle, GdkRectangle* pGraphicHandleRects, LOKDocView* pDocView)
-{
-    int nHandleWidth, nHandleHeight;
-    GdkRectangle aSelection;
-
-    nHandleWidth = cairo_image_surface_get_width(pHandle);
-    nHandleHeight = cairo_image_surface_get_height(pHandle);
-
-    aSelection.x = pDocView->m_pImpl->twipToPixel(pSelection->x);
-    aSelection.y = pDocView->m_pImpl->twipToPixel(pSelection->y);
-    aSelection.width = pDocView->m_pImpl->twipToPixel(pSelection->width);
-    aSelection.height = pDocView->m_pImpl->twipToPixel(pSelection->height);
-
-    for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
-    {
-        int x = aSelection.x, y = aSelection.y;
-        cairo_save(pCairo);
-
-        switch (i)
-        {
-        case 0: // top-left
-            break;
-        case 1: // top-middle
-            x += aSelection.width / 2;
-            break;
-        case 2: // top-right
-            x += aSelection.width;
-            break;
-        case 3: // middle-left
-            y += aSelection.height / 2;
-            break;
-        case 4: // middle-right
-            x += aSelection.width;
-            y += aSelection.height / 2;
-            break;
-        case 5: // bottom-left
-            y += aSelection.height;
-            break;
-        case 6: // bottom-middle
-            x += aSelection.width / 2;
-            y += aSelection.height;
-            break;
-        case 7: // bottom-right
-            x += aSelection.width;
-            y += aSelection.height;
-            break;
-        }
-
-        // Center the handle.
-        x -= nHandleWidth / 2;
-        y -= nHandleHeight / 2;
-
-        pGraphicHandleRects[i].x = x;
-        pGraphicHandleRects[i].y = y;
-        pGraphicHandleRects[i].width = nHandleWidth;
-        pGraphicHandleRects[i].height = nHandleHeight;
-
-        cairo_translate(pCairo, x, y);
-        cairo_set_source_surface(pCairo, pHandle, 0, 0);
-        cairo_paint(pCairo);
-        cairo_restore(pCairo);
-    }
-}
-
 void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
 {
     const int nTileSizePixels = 256;
commit eba73d9ef683e347edd97b50eed1063f2d41d1ad
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Mar 27 22:13:50 2015 +0900

    android: comment selection related code, rearrange and clean-up
    
    Change-Id: I18c8c4864d074662f85fc5b0e43eb84cc0638fd8

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
index 4439bad..1a237a9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
@@ -34,12 +34,17 @@ public class GraphicSelection implements CanvasElement {
     private GraphicSelectionHandle mHandles[] = new GraphicSelectionHandle[8];
     private GraphicSelectionHandle mDragHandle = null;
 
+    /**
+     * Construct the graphic selection.
+     */
     public GraphicSelection() {
+        // Create the paint, which is needed at drawing
         mPaint = new Paint();
         mPaint.setStyle(Paint.Style.STROKE);
         mPaint.setColor(Color.BLACK);
         mPaint.setStrokeWidth(2);
 
+        // Create the handles of the selection
         mHandles[0] = new GraphicSelectionHandle(HandlePosition.TOP_LEFT);
         mHandles[1] = new GraphicSelectionHandle(HandlePosition.TOP);
         mHandles[2] = new GraphicSelectionHandle(HandlePosition.TOP_RIGHT);
@@ -50,10 +55,15 @@ public class GraphicSelection implements CanvasElement {
         mHandles[7] = new GraphicSelectionHandle(HandlePosition.BOTTOM_RIGHT);
     }
 
+    /**
+     * Viewport has changed, reposition the selection to the new rectangle.
+     * @param scaledRectangle - rectangle of selection position on the document
+     */
     public void reposition(RectF scaledRectangle) {
         mScaledRectangle = scaledRectangle;
-        mDrawRectangle = scaledRectangle;
+        mDrawRectangle = scaledRectangle; // rectangle that will be draw
 
+        // reposition the handles too
         mHandles[0].reposition(scaledRectangle.left, scaledRectangle.top);
         mHandles[1].reposition(scaledRectangle.centerX(), scaledRectangle.top);
         mHandles[2].reposition(scaledRectangle.right, scaledRectangle.top);
@@ -64,6 +74,10 @@ public class GraphicSelection implements CanvasElement {
         mHandles[7].reposition(scaledRectangle.right, scaledRectangle.bottom);
     }
 
+    /**
+     * Hit test for the selection.
+     * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
+     */
     @Override
     public boolean contains(float x, float y) {
         // Check if handle was hit
@@ -76,6 +90,7 @@ public class GraphicSelection implements CanvasElement {
     }
 
     /**
+     * Draw the selection on the canvas.
      * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
      */
     @Override
@@ -86,6 +101,10 @@ public class GraphicSelection implements CanvasElement {
         }
     }
 
+    /**
+     * Dragging on the screen has started.
+     * @param position - position where the dragging started
+     */
     public void dragStart(PointF position) {
         mDragHandle = null;
         mType = DragType.NONE;
@@ -105,6 +124,10 @@ public class GraphicSelection implements CanvasElement {
         mStartDragPosition = position;
     }
 
+    /**
+     * Dragging is in process.
+     * @param position - position of the drag
+     */
     public void dragging(PointF position) {
         if (mType == DragType.MOVE) {
             float deltaX = position.x - mStartDragPosition.x;
@@ -117,6 +140,34 @@ public class GraphicSelection implements CanvasElement {
         }
     }
 
+    /**
+     * Dragging has ended.
+     * @param position - last position of the drag
+     */
+    public void dragEnd(PointF position) {
+        PointF point = new PointF();
+        if (mDragHandle != null) {
+            point.x = mDragHandle.mPosition.x;
+            point.y = mDragHandle.mPosition.y;
+            mDragHandle.reset();
+            mDragHandle = null;
+        } else {
+            point.x = mStartDragPosition.x;
+            point.y = mStartDragPosition.y;
+        }
+        float deltaX = position.x - mStartDragPosition.x;
+        float deltaY = position.y - mStartDragPosition.y;
+        point.offset(deltaX, deltaY);
+
+        sendGraphicSelectionEnd(point);
+
+        mDrawRectangle = mScaledRectangle;
+        mType = DragType.NONE;
+    }
+
+    /**
+     * Adapt the selection depending on which handle was dragged.
+     */
     private void adaptDrawRectangle(float x, float y) {
         mDrawRectangle = new RectF(mScaledRectangle);
         switch(mDragHandle.getHandlePosition()) {
@@ -151,43 +202,41 @@ public class GraphicSelection implements CanvasElement {
         }
     }
 
-    public void dragEnd(PointF position) {
-        PointF point = new PointF();
-        if (mDragHandle != null) {
-            point.x = mDragHandle.mPosition.x;
-            point.y = mDragHandle.mPosition.y;
-            mDragHandle.reset();
-            mDragHandle = null;
-        } else {
-            point.x = mStartDragPosition.x;
-            point.y = mStartDragPosition.y;
-        }
-        float deltaX = position.x - mStartDragPosition.x;
-        float deltaY = position.y - mStartDragPosition.y;
-        point.offset(deltaX, deltaY);
-
-        sendGraphicSelectionEnd(point);
-
-        mDrawRectangle = mScaledRectangle;
-        mType = DragType.NONE;
-    }
-
+    /**
+     * Send graphic selection start event to LOKitTread
+     * @param screenPosition - screen position of the selection
+     */
     private void sendGraphicSelectionStart(PointF screenPosition) {
-        LayerView layerView = LOKitShell.getLayerView();
-        if (layerView != null) {
-            PointF documentPoint = layerView.getLayerClient().convertViewPointToLayerPoint(screenPosition);
-            LOKitShell.sendTouchEvent("GraphicSelectionStart", documentPoint);
-        }
+        sendGraphicSelection("GraphicSelectionStart", screenPosition);
     }
 
+    /**
+     * Send graphic selection end event to LOKitTread
+     * @param screenPosition - screen position of the selection
+     */
     private void sendGraphicSelectionEnd(PointF screenPosition) {
+        sendGraphicSelection("GraphicSelectionEnd", screenPosition);
+    }
+
+    /**
+     * Send graphic selection event to LOKitTread
+     * @param type - type of the graphic selection
+     * @param screenPosition - screen position of the selection
+     */
+    private void sendGraphicSelection(String type, PointF screenPosition)
+    {
         LayerView layerView = LOKitShell.getLayerView();
         if (layerView != null) {
+            // Position is in screen coordinates. We need to convert them to
+            // document coordinates.
             PointF documentPoint = layerView.getLayerClient().convertViewPointToLayerPoint(screenPosition);
             LOKitShell.sendTouchEvent("GraphicSelectionEnd", documentPoint);
         }
     }
 
+    /**
+     * Reset the selection.
+     */
     public void reset() {
         mDragHandle = null;
         for (GraphicSelectionHandle handle : mHandles) {
@@ -195,6 +244,9 @@ public class GraphicSelection implements CanvasElement {
         }
     }
 
+    /**
+     * Type of the selection dragging.
+     */
     public enum DragType {
         NONE,
         MOVE,
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
index a33589f..52b662e 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
@@ -20,6 +20,11 @@ import android.graphics.RectF;
  * touched.
  */
 public class GraphicSelectionHandle implements CanvasElement {
+    /**
+     * The factor used to inflate the hit area.
+     */
+    private final float HIT_AREA_INFLATE_FACTOR = 1.75f;
+
     private final HandlePosition mHandlePosition;
     public PointF mPosition = new PointF();
     private float mRadius = 20.0f;
@@ -29,6 +34,10 @@ public class GraphicSelectionHandle implements CanvasElement {
     private RectF mHitRect = new RectF();
     private boolean mSelected = false;
 
+    /**
+     * Construct the handle - set the handle position on the selection.
+     * @param position - the handle position on the selection
+     */
     public GraphicSelectionHandle(HandlePosition position) {
         mHandlePosition = position;
 
@@ -43,11 +52,17 @@ public class GraphicSelectionHandle implements CanvasElement {
         mSelectedFillPaint.setColor(Color.BLUE);
     }
 
+    /**
+     * The position of the handle
+     * @return
+     */
     public HandlePosition getHandlePosition() {
         return mHandlePosition;
     }
 
     /**
+     * Draws the handle to the canvas.
+     *
      * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
      */
     @Override
@@ -59,33 +74,58 @@ public class GraphicSelectionHandle implements CanvasElement {
         }
     }
 
+    /**
+     * Draw a filled and stroked circle to the canvas
+     */
     private void drawFilledCircle(Canvas canvas, float x, float y, float radius, Paint strokePaint, Paint fillPaint) {
         canvas.drawCircle(x, y, radius, fillPaint);
         canvas.drawCircle(x, y, radius, strokePaint);
     }
 
+    /**
+     * Viewport has changed, reposition the handle to the input coordinates.
+     */
     public void reposition(float x, float y) {
         mPosition.x = x;
         mPosition.y = y;
-        mHitRect.left = mPosition.x - mRadius * 1.75f;
-        mHitRect.right = mPosition.x + mRadius * 1.75f;
-        mHitRect.top = mPosition.y - mRadius * 1.75f;
-        mHitRect.bottom = mPosition.y + mRadius * 1.75f;
+
+        // inflate the radius by HIT_AREA_INFLATE_FACTOR
+        float inflatedRadius = mRadius * HIT_AREA_INFLATE_FACTOR;
+
+        // reposition the hit area rectangle
+        mHitRect.left = mPosition.x - inflatedRadius;
+        mHitRect.right = mPosition.x + inflatedRadius;
+        mHitRect.top = mPosition.y - inflatedRadius;
+        mHitRect.bottom = mPosition.y + inflatedRadius;
     }
 
+    /**
+     * Hit test for the handle.
+     * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
+     */
     @Override
     public boolean contains(float x, float y) {
         return mHitRect.contains(x, y);
     }
 
+    /**
+     * Mark the handle as selected.
+     */
     public void select() {
         mSelected = true;
     }
 
+    /**
+     * Reset the selection for the handle.
+     */
     public void reset() {
         mSelected = false;
     }
 
+    /**
+     * All posible handle positions. The selection rectangle has 8 possible
+     * handles.
+     */
     public enum HandlePosition {
         TOP_LEFT,
         TOP,
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
index 818dbc4..af3237e 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
@@ -95,6 +95,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
         }
     }
 
+    /**
+     * Change the cursor position.
+     * @param position - new position of the cursor
+     */
     public void changeCursorPosition(RectF position) {
         LayerView layerView = LOKitShell.getLayerView();
         if (layerView == null) {
@@ -108,6 +112,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
         repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
     }
 
+    /**
+     * Change the text selection rectangles.
+     * @param selectionRects - list of text selection rectangles
+     */
     public void changeSelections(List<RectF> selectionRects) {
         LayerView layerView = LOKitShell.getLayerView();
         if (layerView == null) {
@@ -121,6 +129,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
         repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
     }
 
+    /**
+     * Change the graphic selection rectangle.
+     * @param rectangle - new graphic selection rectangle
+     */
     public void changeGraphicSelection(RectF rectangle) {
         LayerView layerView = LOKitShell.getLayerView();
         if (layerView == null) {
@@ -156,6 +168,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
         return cursor;
     }
 
+    /**
+     * Drawing on canvas.
+     */
     @Override
     protected void onDraw(Canvas canvas) {
         super.onDraw(canvas);
@@ -172,6 +187,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
         }
     }
 
+    /**
+     * Cursor animation function. Switch the alpha between opaque and fully transparent.
+     */
     private Runnable cursorAnimation = new Runnable() {
         public void run() {
             if (mCursorVisible) {
@@ -182,26 +200,41 @@ public class TextCursorView extends View implements View.OnTouchListener {
         }
     };
 
+    /**
+     * Show the cursor on the view.
+     */
     public void showCursor() {
         mCursorVisible = true;
         invalidate();
     }
 
+    /**
+     * Hide the cursor.
+     */
     public void hideCursor() {
         mCursorVisible = false;
         invalidate();
     }
 
+    /**
+     * Show text selection rectangles.
+     */
     public void showSelections() {
         mSelectionsVisible = true;
         invalidate();
     }
 
+    /**
+     * Hide text selection rectangles.
+     */
     public void hideSelections() {
         mSelectionsVisible = false;
         invalidate();
     }
 
+    /**
+     * Show the graphic selection on the view.
+     */
     public void showGraphicSelection() {
         mGraphicSelectionVisible = true;
         mGraphicSelectionMove = false;
@@ -209,11 +242,17 @@ public class TextCursorView extends View implements View.OnTouchListener {
         invalidate();
     }
 
+    /**
+     * Hide the graphic selection.
+     */
     public void hideGraphicSelection() {
         mGraphicSelectionVisible = false;
         invalidate();
     }
 
+    /**
+     * Handle the triggered touch event.
+     */
     @Override
     public boolean onTouch(View view, MotionEvent event) {
         switch (event.getActionMasked()) {
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/TextSelection.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/TextSelection.java
index 52aa555..7a07742 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/TextSelection.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/TextSelection.java
@@ -33,6 +33,11 @@ public class TextSelection extends Layer {
     private float mViewTop;
     private float mViewZoom;
 
+    /**
+     * Construct the TextSelection. Context is needed to get the needed
+     * resources (views) to display all the handles and selections.
+     * @param context - the activity context
+     */
     public TextSelection(Activity context) {
         mStartHandle = (TextSelectionHandle) context.findViewById(R.id.start_handle);
         mMiddleHandle = (TextSelectionHandle) context.findViewById(R.id.middle_handle);
commit a518d5a4a7de70426ddb4dbcfdb5c7859aa2f225
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 27 15:18:06 2015 +0100

    android: open csv files in Calc
    
    Change-Id: I17b9c4f9d40db46fe6f1be8f1a3ecaee4946454c

diff --git a/android/experimental/LOAndroid3/AndroidManifest.xml.in b/android/experimental/LOAndroid3/AndroidManifest.xml.in
index e151172..040246da 100644
--- a/android/experimental/LOAndroid3/AndroidManifest.xml.in
+++ b/android/experimental/LOAndroid3/AndroidManifest.xml.in
@@ -77,6 +77,7 @@
 
                 <!-- OTHER -->
                 <data android:mimeType="text/csv"/>
+                <data android:mimeType="text/comma-separated-values"/>
                 <data android:mimeType="application/vnd.ms-works" />
                 <data android:mimeType="application/vnd.apple.keynote" />
                 <data android:mimeType="application/x-abiword" />
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index c054143..c169d8e 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -171,7 +171,14 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
         InputStream inputStream = null;
         try {
             inputStream = contentResolver.openInputStream(getIntent().getData());
-            mTempFile = File.createTempFile("LibreOffice", null, this.getCacheDir());
+
+            // CSV files need a .csv suffix to be opened in Calc.
+            String suffix = null;
+            String intentType = getIntent().getType();
+            // K-9 mail uses the first, GMail uses the second variant.
+            if ("text/comma-separated-values".equals(intentType) || "text/csv".equals(intentType))
+                suffix = ".csv";
+            mTempFile = File.createTempFile("LibreOffice", suffix, this.getCacheDir());
 
             OutputStream outputStream = new FileOutputStream(mTempFile);
             byte[] buffer = new byte[4096];
commit 54510b3b65141bebb342fea9ffe9f59e7b2d9bbf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 27 09:19:25 2015 +0100

    svx tiled rendering: double-click in empty table cell selects it
    
    This brings Impress tables in sync with Writer, where long push on
    Android selects the empty cell.
    
    Change-Id: If8403ec43daeea6ca79b488a54253cb8b71794d9

diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 27d6a7d..fdd8481 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -248,6 +248,16 @@ bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWindow
 
 bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWindow )
 {
+    if (mxTableObj->GetModel()->isTiledRendering() && !pWindow)
+    {
+        // Tiled rendering: get the window that has the disabled map mode.
+        if (OutputDevice* pOutputDevice = mpView->GetFirstOutputDevice())
+        {
+            if (pOutputDevice->GetOutDevType() == OUTDEV_WINDOW)
+                pWindow = static_cast<vcl::Window*>(pOutputDevice);
+        }
+    }
+
     if( !pWindow || !checkTableObject() )
         return false;
 
@@ -294,6 +304,28 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
         }
     }
 
+    if (mxTableObj->GetModel()->isTiledRendering() && rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && eHit == SDRTABLEHIT_CELLTEXTAREA)
+    {
+        bool bEmptyOutliner = false;
+        if (Outliner* pOutliner = mpView->GetTextEditOutliner())
+        {
+            if (pOutliner->GetParagraphCount() == 1)
+            {
+                if (Paragraph* pParagraph = pOutliner->GetParagraph(0))
+                    bEmptyOutliner = pOutliner->GetText(pParagraph).isEmpty();
+            }
+        }
+        if (bEmptyOutliner)
+        {
+            // Tiled rendering: a left double-click in an empty cell: select it.
+            StartSelection(maMouseDownPos);
+            setSelectedCells(maMouseDownPos, maMouseDownPos);
+            // Update graphic selection, should be hidden now.
+            mpView->AdjustMarkHdl();
+            return true;
+        }
+    }
+
     return false;
 }
 
commit ffc571462b99b9b0976099d24f5647feb7371631
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Mar 27 09:17:26 2015 +0100

    lokdocview: move cursor / selection overlay to LOKDocView_Impl
    
    Change-Id: I48a6906382fd41906a06704855d2f054467c1716

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 90fa014..ebcf11f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -128,6 +128,10 @@ struct LOKDocView_Impl
     static gboolean signalMotion(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView* pDocView);
     /// Implementation of motion event handler, invoked by signalMotion().
     gboolean signalMotionImpl(GdkEventButton* pEvent);
+    /// Receives an expose event.
+    static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, LOKDocView* pDocView);
+    /// Implementation of expose event handler (renders cursor and selection overlay), invoked by renderOverlay().
+    gboolean renderOverlayImpl(GtkWidget* pEventBox);
 };
 
 LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
@@ -446,9 +450,95 @@ gboolean LOKDocView_Impl::signalMotionImpl(GdkEventButton* pEvent)
     return FALSE;
 }
 
+gboolean LOKDocView_Impl::renderOverlay(GtkWidget* pEventBox, GdkEventExpose* /*pEvent*/, LOKDocView* pDocView)
+{
+    return pDocView->m_pImpl->renderOverlayImpl(pEventBox);
+}
+
+static gboolean lcl_isEmptyRectangle(GdkRectangle* pRectangle);
+static void lcl_renderHandle(cairo_t* pCairo, GdkRectangle* pCursor, cairo_surface_t* pHandle,
+                             GdkRectangle* pRectangle, LOKDocView* pDocView);
+static void lcl_renderGraphicHandle(cairo_t* pCairo, GdkRectangle* pSelection, cairo_surface_t* pHandle, GdkRectangle* pGraphicHandleRects, LOKDocView* pDocView);
+
+gboolean LOKDocView_Impl::renderOverlayImpl(GtkWidget* pWidget)
+{
+#if GTK_CHECK_VERSION(2,14,0) // we need gtk_widget_get_window()
+    cairo_t* pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
+
+    if (m_bEdit && m_bCursorVisible && m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&m_aVisibleCursor))
+    {
+        if (m_aVisibleCursor.width < 30)
+            // Set a minimal width if it would be 0.
+            m_aVisibleCursor.width = 30;
+
+        cairo_set_source_rgb(pCairo, 0, 0, 0);
+        cairo_rectangle(pCairo,
+                        twipToPixel(m_aVisibleCursor.x),
+                        twipToPixel(m_aVisibleCursor.y),
+                        twipToPixel(m_aVisibleCursor.width),
+                        twipToPixel(m_aVisibleCursor.height));
+        cairo_fill(pCairo);
+    }
+
+    if (m_bEdit && m_bCursorVisible && !lcl_isEmptyRectangle(&m_aVisibleCursor) && !m_pTextSelectionRectangles)
+    {
+        // Have a cursor, but no selection: we need the middle handle.
+        if (!m_pHandleMiddle)
+            m_pHandleMiddle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_middle.png");
+        lcl_renderHandle(pCairo, &m_aVisibleCursor, m_pHandleMiddle, &m_aHandleMiddleRect, m_pDocView);
+    }
+
+    if (m_pTextSelectionRectangles)
+    {
+        for (GList* i = m_pTextSelectionRectangles; i != NULL; i = i->next)
+        {
+            GdkRectangle* pRectangle = static_cast<GdkRectangle*>(i->data);
+            // Blue with 75% transparency.
+            cairo_set_source_rgba(pCairo, ((double)0x43)/255, ((double)0xac)/255, ((double)0xe8)/255, 0.25);
+            cairo_rectangle(pCairo,
+                            twipToPixel(pRectangle->x),
+                            twipToPixel(pRectangle->y),
+                            twipToPixel(pRectangle->width),
+                            twipToPixel(pRectangle->height));
+            cairo_fill(pCairo);
+        }
+
+        // Handles
+        if (!lcl_isEmptyRectangle(&m_aTextSelectionStart))
+        {
+            // Have a start position: we need a start handle.
+            if (!m_pHandleStart)
+                m_pHandleStart = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_start.png");
+            lcl_renderHandle(pCairo, &m_aTextSelectionStart,
+                             m_pHandleStart, &m_aHandleStartRect,
+                             m_pDocView);
+        }
+        if (!lcl_isEmptyRectangle(&m_aTextSelectionEnd))
+        {
+            // Have a start position: we need an end handle.
+            if (!m_pHandleEnd)
+                m_pHandleEnd = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_end.png");
+            lcl_renderHandle(pCairo, &m_aTextSelectionEnd,
+                             m_pHandleEnd, &m_aHandleEndRect,
+                             m_pDocView);
+        }
+    }
+
+    if (!lcl_isEmptyRectangle(&m_aGraphicSelection))
+    {
+        if (!m_pGraphicHandle)
+            m_pGraphicHandle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_graphic.png");
+        lcl_renderGraphicHandle(pCairo, &m_aGraphicSelection, m_pGraphicHandle, m_aGraphicHandleRects, m_pDocView);
+    }
+
+    cairo_destroy(pCairo);
+#endif
+    return FALSE;
+}
+
+
 static void lok_docview_class_init( gpointer );
 static void lok_docview_init( GTypeInstance *, gpointer );
-static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpointer pData);
 
 SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
 {
@@ -519,8 +609,7 @@ static void lok_docview_init( GTypeInstance* pInstance, gpointer )
     gtk_widget_show( pDocView->m_pImpl->m_pEventBox );
 
     gtk_signal_connect(GTK_OBJECT(pDocView), "destroy", GTK_SIGNAL_FUNC(LOKDocView_Impl::destroy), 0);
-    g_signal_connect_after(pDocView->m_pImpl->m_pEventBox, "expose-event",
-                           G_CALLBACK(renderOverlay), pDocView);
+    g_signal_connect_after(pDocView->m_pImpl->m_pEventBox, "expose-event", G_CALLBACK(LOKDocView_Impl::renderOverlay), pDocView);
 }
 
 SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
@@ -649,85 +738,6 @@ static void lcl_renderGraphicHandle(cairo_t* pCairo, GdkRectangle* pSelection, c
     }
 }
 
-static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* /*pEvent*/, gpointer pData)
-{
-#if GTK_CHECK_VERSION(2,14,0) // we need gtk_widget_get_window()
-    LOKDocView* pDocView = LOK_DOCVIEW(pData);
-    cairo_t* pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
-
-    if (pDocView->m_pImpl->m_bEdit && pDocView->m_pImpl->m_bCursorVisible && pDocView->m_pImpl->m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aVisibleCursor))
-    {
-        if (pDocView->m_pImpl->m_aVisibleCursor.width < 30)
-            // Set a minimal width if it would be 0.
-            pDocView->m_pImpl->m_aVisibleCursor.width = 30;
-
-        cairo_set_source_rgb(pCairo, 0, 0, 0);
-        cairo_rectangle(pCairo,
-                        pDocView->m_pImpl->twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.x),
-                        pDocView->m_pImpl->twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.y),
-                        pDocView->m_pImpl->twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.width),
-                        pDocView->m_pImpl->twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.height));
-        cairo_fill(pCairo);
-    }
-
-    if (pDocView->m_pImpl->m_bEdit && pDocView->m_pImpl->m_bCursorVisible && !lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aVisibleCursor) && !pDocView->m_pImpl->m_pTextSelectionRectangles)
-    {
-        // Have a cursor, but no selection: we need the middle handle.
-        if (!pDocView->m_pImpl->m_pHandleMiddle)
-            pDocView->m_pImpl->m_pHandleMiddle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_middle.png");
-        lcl_renderHandle(pCairo, &pDocView->m_pImpl->m_aVisibleCursor,
-                         pDocView->m_pImpl->m_pHandleMiddle, &pDocView->m_pImpl->m_aHandleMiddleRect,
-                         pDocView);
-    }
-
-    if (pDocView->m_pImpl->m_pTextSelectionRectangles)
-    {
-        for (GList* i = pDocView->m_pImpl->m_pTextSelectionRectangles; i != NULL; i = i->next)
-        {
-            GdkRectangle* pRectangle = static_cast<GdkRectangle*>(i->data);
-            // Blue with 75% transparency.
-            cairo_set_source_rgba(pCairo, ((double)0x43)/255, ((double)0xac)/255, ((double)0xe8)/255, 0.25);
-            cairo_rectangle(pCairo,
-                            pDocView->m_pImpl->twipToPixel(pRectangle->x),
-                            pDocView->m_pImpl->twipToPixel(pRectangle->y),
-                            pDocView->m_pImpl->twipToPixel(pRectangle->width),
-                            pDocView->m_pImpl->twipToPixel(pRectangle->height));
-            cairo_fill(pCairo);
-        }
-
-        // Handles
-        if (!lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aTextSelectionStart))
-        {
-            // Have a start position: we need a start handle.
-            if (!pDocView->m_pImpl->m_pHandleStart)
-                pDocView->m_pImpl->m_pHandleStart = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_start.png");
-            lcl_renderHandle(pCairo, &pDocView->m_pImpl->m_aTextSelectionStart,
-                             pDocView->m_pImpl->m_pHandleStart, &pDocView->m_pImpl->m_aHandleStartRect,
-                             pDocView);
-        }
-        if (!lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aTextSelectionEnd))
-        {
-            // Have a start position: we need an end handle.
-            if (!pDocView->m_pImpl->m_pHandleEnd)
-                pDocView->m_pImpl->m_pHandleEnd = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_end.png");
-            lcl_renderHandle(pCairo, &pDocView->m_pImpl->m_aTextSelectionEnd,
-                             pDocView->m_pImpl->m_pHandleEnd, &pDocView->m_pImpl->m_aHandleEndRect,
-                             pDocView);
-        }
-    }
-
-    if (!lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aGraphicSelection))
-    {
-        if (!pDocView->m_pImpl->m_pGraphicHandle)
-            pDocView->m_pImpl->m_pGraphicHandle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_graphic.png");
-        lcl_renderGraphicHandle(pCairo, &pDocView->m_pImpl->m_aGraphicSelection, pDocView->m_pImpl->m_pGraphicHandle, pDocView->m_pImpl->m_aGraphicHandleRects, pDocView);
-    }
-
-    cairo_destroy(pCairo);
-#endif
-    return FALSE;
-}
-
 void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
 {
     const int nTileSizePixels = 256;
commit 84793d11152fc0eb308cf29475ae2c2a86d40967
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 26 15:37:45 2015 +0100

    SdXImpressDocument: implement resetSelection()
    
    With this, when editing is finished, no text edit is active, also both
    editeng and sdr selections are reset.
    
    Change-Id: If953e1d8683171c1f1ed8c7d97ae34a163d14765

diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 0717635..a10e448 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -124,7 +124,7 @@ public:
     /**
      * @see lok::Document::resetSelection().
      */
-    virtual void resetSelection() { }
+    virtual void resetSelection() = 0;
 };
 
 } // namespace vcl
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index fe5679b..409b620 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -250,6 +250,8 @@ public:
     virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::setGraphicSelection().
     virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
+    /// @see lok::Document::resetSelection().
+    virtual void resetSelection() SAL_OVERRIDE;
 
     // XComponent
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 4305b9b..0a1a955 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2451,6 +2451,29 @@ void SdXImpressDocument::setGraphicSelection(int nType, int nX, int nY)
     }
 }
 
+void SdXImpressDocument::resetSelection()
+{
+    SolarMutexGuard aGuard;
+
+    DrawViewShell* pViewShell = GetViewShell();
+    if (!pViewShell)
+        return;
+
+    SdrView* pSdrView = pViewShell->GetView();
+    if (!pSdrView)
+        return;
+
+    if (pSdrView->IsTextEdit())
+    {
+        // Reset the editeng selection.
+        pSdrView->UnmarkAll();
+        // Finish editing.
+        pSdrView->SdrEndTextEdit();
+    }
+    // Reset graphic selection.
+    pSdrView->UnmarkAll();
+}
+
 uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
 {
     uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
commit 62d03f6c6109755375a93681ffcc7196827cfd0c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 26 11:53:57 2015 +0100

    SdrTableObj tiled rendering: implement selection callbacks
    
    This makes selections of Impress tables visible. Double-click in an
    empty cell doesn't select the cell yet, neither extending cell text
    selections into table ones work, but it's a start.
    
    Change-Id: Idb8921d980ac9d7ab363c68c91c1a9e6cf0918e3

diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 181adf9..27d6a7d 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -66,6 +66,7 @@
 #include "tableundo.hxx"
 #include "tablelayouter.hxx"
 #include <vcl/msgbox.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <memory>
 
 using ::editeng::SvxBorderLine;
@@ -2077,18 +2078,18 @@ void SvxTableController::updateSelectionOverlay()
         {
             sdr::overlay::OverlayObjectCell::RangeVector aRanges;
 
-            Rectangle aRect;
+            Rectangle aStartRect, aEndRect;
             CellPos aStart,aEnd;
             getSelectedCells( aStart, aEnd );
-            pTableObj->getCellBounds( aStart, aRect );
+            pTableObj->getCellBounds( aStart, aStartRect );
 
-            basegfx::B2DRange a2DRange( basegfx::B2DPoint(aRect.Left(), aRect.Top()) );
-            a2DRange.expand( basegfx::B2DPoint(aRect.Right(), aRect.Bottom()) );
+            basegfx::B2DRange a2DRange( basegfx::B2DPoint(aStartRect.Left(), aStartRect.Top()) );
+            a2DRange.expand( basegfx::B2DPoint(aStartRect.Right(), aStartRect.Bottom()) );
 
             findMergeOrigin( aEnd );
-            pTableObj->getCellBounds( aEnd, aRect );
-            a2DRange.expand( basegfx::B2DPoint(aRect.Left(), aRect.Top()) );
-            a2DRange.expand( basegfx::B2DPoint(aRect.Right(), aRect.Bottom()) );
+            pTableObj->getCellBounds( aEnd, aEndRect );
+            a2DRange.expand( basegfx::B2DPoint(aEndRect.Left(), aEndRect.Top()) );
+            a2DRange.expand( basegfx::B2DPoint(aEndRect.Right(), aEndRect.Bottom()) );
             aRanges.push_back( a2DRange );
 
             ::Color aHighlight( COL_BLUE );
@@ -2116,6 +2117,27 @@ void SvxTableController::updateSelectionOverlay()
                     }
                 }
             }
+
+            // If tiled rendering, emit callbacks for sdr table selection.
+            if (pOutDev && pTableObj->GetModel()->isTiledRendering())
+            {
+                // Left edge of aStartRect.
+                Rectangle aSelectionStart(aStartRect.Left(), aStartRect.Top(), aStartRect.Left(), aStartRect.Bottom());
+                // Right edge of aEndRect.
+                Rectangle aSelectionEnd(aEndRect.Right(), aEndRect.Top(), aEndRect.Right(), aEndRect.Bottom());
+                Rectangle aSelection(a2DRange.getMinX(), a2DRange.getMinY(), a2DRange.getMaxX(), a2DRange.getMaxY());
+
+                if (pOutDev->GetMapMode().GetMapUnit() == MAP_100TH_MM)
+                {
+                    aSelectionStart = OutputDevice::LogicToLogic(aSelectionStart, MAP_100TH_MM, MAP_TWIP);
+                    aSelectionEnd = OutputDevice::LogicToLogic(aSelectionEnd, MAP_100TH_MM, MAP_TWIP);
+                    aSelection = OutputDevice::LogicToLogic(aSelection, MAP_100TH_MM, MAP_TWIP);
+                }
+
+                pTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, aSelectionStart.toString().getStr());
+                pTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, aSelectionEnd.toString().getStr());
+                pTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.toString().getStr());
+            }
         }
     }
 }
@@ -2128,6 +2150,14 @@ void SvxTableController::destroySelectionOverlay()
     {
         delete mpSelectionOverlay;
         mpSelectionOverlay = 0;
+
+        if (mxTableObj->GetModel()->isTiledRendering())
+        {
+            // Clear the LOK text selection so far provided by this table.
+            mxTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, "EMPTY");
+            mxTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, "EMPTY");
+            mxTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "EMPTY");
+        }
     }
 }
 
commit 741599f3e56c2ae6656377cdac6bc19512513876
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 26 14:22:55 2015 +0100

    SdrMarkView tiled rendering: partially disable SdrTableObj graphic selection
    
    If one or more cells are selected in an Impress table, then the shape
    already provides its own text selection, don't overwrite it with the
    generic graphic selection in this case.
    
    Change-Id: I4f84a220df6cd9d225ed67d6f70ba2df6eff38af

diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index 92d893df..b6d610c 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -92,7 +92,7 @@ public:
     SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage ) SAL_OVERRIDE;
     SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) SAL_OVERRIDE;
 
-    SVX_DLLPRIVATE bool hasSelectedCells() const { return mbCellSelectionMode || mpView->IsTextEdit(); }
+    SVX_DLLPRIVATE virtual bool hasSelectedCells() const SAL_OVERRIDE { return mbCellSelectionMode || mpView->IsTextEdit(); }
 
     void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
     void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
diff --git a/include/svx/selectioncontroller.hxx b/include/svx/selectioncontroller.hxx
index 6c15e28..f629b20 100644
--- a/include/svx/selectioncontroller.hxx
+++ b/include/svx/selectioncontroller.hxx
@@ -68,6 +68,8 @@ public:
         if bNoParagraphFormats is true, no paragraph attributes are changed.
     */
     virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
+    /// This is a table object, and one or more of its cells are selected.
+    virtual bool hasSelectedCells() const;
 };
 
 }
diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx
index 800d694..a2ff875 100644
--- a/svx/source/svdraw/selectioncontroller.cxx
+++ b/svx/source/svdraw/selectioncontroller.cxx
@@ -100,6 +100,11 @@ bool SelectionController::ApplyFormatPaintBrush( SfxItemSet& /*rFormatSet*/, boo
     return false;
 }
 
+bool SelectionController::hasSelectedCells() const
+{
+    return false;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 66a2a32..28629e5 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -703,6 +703,17 @@ void SdrMarkView::SetMarkHandles()
             {
                 return;
             }
+
+            if (bTiledRendering && pMarkedObj->GetObjIdentifier() == OBJ_TABLE)
+            {
+                rtl::Reference<sdr::SelectionController> xController = static_cast<SdrView*>(this)->getSelectionController();
+                if (xController.is() && xController->hasSelectedCells())
+                {
+                    // The table shape has selected cells, which provide text selection already -> no graphic selection.
+                    GetModel()->libreOfficeKitCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
+                    return;
+                }
+            }
         }
 
         Rectangle aRect(GetMarkedObjRect());
commit 986c685e9f324abe8d0f722aa5310477686cde59
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 26 09:45:41 2015 +0100

    lokdocview: move motion handling to LOKDocView_Impl
    
    Change-Id: Ibace4a943fb61e2f897c9571cc2c8814935b6e75

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 5793d7a..90fa014 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -121,9 +121,13 @@ struct LOKDocView_Impl
      */
     static void getDragPoint(GdkRectangle* pHandle, GdkEventButton* pEvent, GdkPoint* pPoint);
     /// Receives a button press event.
-    static gboolean signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKDocView* pDocView);
+    static gboolean signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView* pDocView);
     /// Implementation of button press event handler, invoked by signalButton().
     gboolean signalButtonImpl(GdkEventButton* pEvent);
+    /// Receives a motion event.
+    static gboolean signalMotion(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView* pDocView);
+    /// Implementation of motion event handler, invoked by signalMotion().
+    gboolean signalMotionImpl(GdkEventButton* pEvent);
 };
 
 LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
@@ -251,7 +255,7 @@ gboolean LOKDocView_Impl::signalButton(GtkWidget* /*pEventBox*/, GdkEventButton*
 /// Receives a button press event.
 gboolean LOKDocView_Impl::signalButtonImpl(GdkEventButton* pEvent)
 {
-    g_info("LOKDocView_Impl::ssignalButton: %d, %d (in twips: %d, %d)", (int)pEvent->x, (int)pEvent->y, (int)pixelToTwip(pEvent->x), (int)pixelToTwip(pEvent->y));
+    g_info("LOKDocView_Impl::signalButton: %d, %d (in twips: %d, %d)", (int)pEvent->x, (int)pEvent->y, (int)pixelToTwip(pEvent->x), (int)pixelToTwip(pEvent->y));
 
     if (pEvent->type == GDK_BUTTON_RELEASE)
     {
@@ -382,74 +386,70 @@ void LOKDocView_Impl::getDragPoint(GdkRectangle* pHandle, GdkEventButton* pEvent
     pPoint->y = aCursor.y + (pEvent->y - aHandle.y);
 }
 
-static void lok_docview_class_init( gpointer );
-static void lok_docview_init( GTypeInstance *, gpointer );
-static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpointer pData);
+gboolean LOKDocView_Impl::signalMotion(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKDocView* pDocView)
+{
+    return pDocView->m_pImpl->signalMotionImpl(pEvent);
+}
 
-gboolean lcl_signalMotion(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKDocView* pDocView)
+gboolean LOKDocView_Impl::signalMotionImpl(GdkEventButton* pEvent)
 {
     GdkPoint aPoint;
 
-    if (pDocView->m_pImpl->m_bInDragMiddleHandle)
+    if (m_bInDragMiddleHandle)
     {
         g_info("lcl_signalMotion: dragging the middle handle");
-        LOKDocView_Impl::getDragPoint(&pDocView->m_pImpl->m_aHandleMiddleRect, pEvent, &aPoint);
-        pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
-                pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_RESET,
-                pDocView->m_pImpl->pixelToTwip(aPoint.x), pDocView->m_pImpl->pixelToTwip(aPoint.y));
+        LOKDocView_Impl::getDragPoint(&m_aHandleMiddleRect, pEvent, &aPoint);
+        m_pDocument->pClass->setTextSelection(m_pDocument, LOK_SETTEXTSELECTION_RESET, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
         return FALSE;
     }
-    if (pDocView->m_pImpl->m_bInDragStartHandle)
+    if (m_bInDragStartHandle)
     {
         g_info("lcl_signalMotion: dragging the start handle");
-        LOKDocView_Impl::getDragPoint(&pDocView->m_pImpl->m_aHandleStartRect, pEvent, &aPoint);
-        pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
-                pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_START,
-                pDocView->m_pImpl->pixelToTwip(aPoint.x), pDocView->m_pImpl->pixelToTwip(aPoint.y));
+        LOKDocView_Impl::getDragPoint(&m_aHandleStartRect, pEvent, &aPoint);
+        m_pDocument->pClass->setTextSelection(m_pDocument, LOK_SETTEXTSELECTION_START, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
         return FALSE;
     }
-    if (pDocView->m_pImpl->m_bInDragEndHandle)
+    if (m_bInDragEndHandle)
     {
         g_info("lcl_signalMotion: dragging the end handle");
-        LOKDocView_Impl::getDragPoint(&pDocView->m_pImpl->m_aHandleEndRect, pEvent, &aPoint);
-        pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
-                pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_END,
-                pDocView->m_pImpl->pixelToTwip(aPoint.x), pDocView->m_pImpl->pixelToTwip(aPoint.y));
+        LOKDocView_Impl::getDragPoint(&m_aHandleEndRect, pEvent, &aPoint);
+        m_pDocument->pClass->setTextSelection(m_pDocument, LOK_SETTEXTSELECTION_END, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
         return FALSE;
     }
     for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
     {
-        if (pDocView->m_pImpl->m_bInDragGraphicHandles[i])
+        if (m_bInDragGraphicHandles[i])
         {
             g_info("lcl_signalMotion: dragging the graphic handle #%d", i);
             return FALSE;
         }
     }
-    if (pDocView->m_pImpl->m_bInDragGraphicSelection)
+    if (m_bInDragGraphicSelection)
     {
         g_info("lcl_signalMotion: dragging the graphic selection");
         return FALSE;
     }
 
     GdkRectangle aMotionInTwipsInTwips;
-    aMotionInTwipsInTwips.x = pDocView->m_pImpl->pixelToTwip(pEvent->x);
-    aMotionInTwipsInTwips.y = pDocView->m_pImpl->pixelToTwip(pEvent->y);
+    aMotionInTwipsInTwips.x = pixelToTwip(pEvent->x);
+    aMotionInTwipsInTwips.y = pixelToTwip(pEvent->y);
     aMotionInTwipsInTwips.width = 1;
     aMotionInTwipsInTwips.height = 1;
-    if (gdk_rectangle_intersect(&aMotionInTwipsInTwips, &pDocView->m_pImpl->m_aGraphicSelection, 0))
+    if (gdk_rectangle_intersect(&aMotionInTwipsInTwips, &m_aGraphicSelection, 0))
     {
         g_info("lcl_signalMotion: start of drag graphic selection");
-        pDocView->m_pImpl->m_bInDragGraphicSelection = true;
-        pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
-            pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_START,
-            pDocView->m_pImpl->pixelToTwip(pEvent->x),
-            pDocView->m_pImpl->pixelToTwip(pEvent->y));
+        m_bInDragGraphicSelection = true;
+        m_pDocument->pClass->setGraphicSelection(m_pDocument, LOK_SETGRAPHICSELECTION_START, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
         return FALSE;
     }
 
     return FALSE;
 }
 
+static void lok_docview_class_init( gpointer );
+static void lok_docview_init( GTypeInstance *, gpointer );
+static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpointer pData);
+
 SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
 {
     static guint lok_docview_type = 0;
@@ -514,7 +514,7 @@ static void lok_docview_init( GTypeInstance* pInstance, gpointer )
     gtk_widget_set_events(pDocView->m_pImpl->m_pEventBox, GDK_BUTTON_PRESS_MASK); // So that drag doesn't try to move the whole window.
     gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "button-press-event", GTK_SIGNAL_FUNC(LOKDocView_Impl::signalButton), pDocView);
     gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "button-release-event", GTK_SIGNAL_FUNC(LOKDocView_Impl::signalButton), pDocView);
-    gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "motion-notify-event", GTK_SIGNAL_FUNC(lcl_signalMotion), pDocView);
+    gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "motion-notify-event", GTK_SIGNAL_FUNC(LOKDocView_Impl::signalMotion), pDocView);
 
     gtk_widget_show( pDocView->m_pImpl->m_pEventBox );
 
commit 00094f9dcde54e071c52c4d9422506b8f3ebee47
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Mar 26 14:34:41 2015 +0100

    sc tiled editing: Implement resetSelection().
    
    Change-Id: I3eb8d749119e0b219dee9252e8fe332dd9dbed48

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index e826eb7..5642569 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -388,6 +388,9 @@ public:
     /// @see vcl::ITiledRenderable::getParts().
     virtual int getParts() SAL_OVERRIDE;
 
+    /// @see vcl::ITiledRenderable::initializeForTiledRendering().
+    virtual void initializeForTiledRendering() SAL_OVERRIDE;
+
     /// @see vcl::ITiledRenderable::registerCallback().
     virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE;
 
@@ -400,8 +403,8 @@ public:
     /// @see vcl::ITiledRenderable::setGraphicSelection().
     virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
 
-    /// @see vcl::ITiledRenderable::initializeForTiledRendering().
-    virtual void initializeForTiledRendering() SAL_OVERRIDE;
+    /// @see lok::Document::resetSelection().
+    virtual void resetSelection() SAL_OVERRIDE;
 };
 
 class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 725c76e..5bf0c05 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -643,6 +643,20 @@ void ScModelObj::setGraphicSelection(int nType, int nX, int nY)
     }
 }
 
+void ScModelObj::resetSelection()
+{
+    SolarMutexGuard aGuard;
+
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    ScTabView* pTabView  = pViewData->GetView();
+
+    // deselect the shapes
+    pTabView->DrawDeselectAll();
+
+    // and hide the cell and text selection
+    pDocShell->GetDocument().GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "");
+}
+
 void ScModelObj::initializeForTiledRendering()
 {
     SolarMutexGuard aGuard;
commit 4415ecbfc605f5db8bdfadf282954f16385348e3
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Mar 26 22:26:44 2015 +0900

    android: properly merge README with new content
    
    Change-Id: I740c654f5844ef4cb7cbc5387c7b8a56e326e532

diff --git a/android/README b/android/README
index 5e8db7c..617e86b 100644
--- a/android/README
+++ b/android/README
@@ -1,4 +1,46 @@
+LibreOffice Android
+*******************
+
+Bootstrap
+*********
+
+Contains common code for all projects on Android to bootstrap LibreOffice. In
+addition it is a home to LibreOfficeKit (LOK - see libreofficekit/README) JNI
+classes.
+
+LOAndroid3 (in experimental)
+****************************
+
+LibreOffice Android application - the code is based on Fennec (Firefox for Android).
+It uses OpenGL ES 2 for rendering of the document tiles which are gathered from
+LibreOffice using LOK. The application contains the LibreOffice core in one shared
+library: liblo-native-code.so, which is bundled together with the application.
+
+TiledRendering
+**************
+
+Tiled rendering is a technique that splits the document to bitmaps of same size
+(typically 256x256) which are fetched on demand.
+
+Architecture and Threading
+**************************
+
+The application implements editing support using 4 threads:
+1. The Android UI thread, we can't perform anything here that would take a considerable
+   amount of time.
+2. An OpenGL thread which contains the OpenGL context and is responsible for drawing
+   all layers (including tiles) to the screen.
+3. A thread (LOKitThread), that performs LibreOfficeKit calls, which may take more time
+   to complete. In addition it also receives events from the soffice thread (see below)
+   when the callback emits an event. Events are stored in a blocking queue (thread
+   processes events in FCFS order, goes to sleep when no more event is available and
+   awakens when there are events in queue again).
+4. A native thread created by LibreOfficeKit (we call it the soffice thread), where
+   LibreOffice itself runs. It receives calls from LOKitThread, and may emit callback
+   events as necessary.
+
 Android-specific notes
+**********************
 
 Note that this document has not necessarily been updated to match
 reality...
@@ -7,67 +49,67 @@ For instructions on how to build for Android, see README.cross.
 
 * Getting something running on an emulated device
 
-	Create an AVD in the android UI, don't even try to get
+        Create an AVD in the android UI, don't even try to get
 the data partition size right in the GUI, that is doomed to producing
 an AVD that doesn't work. Instead start it from the console:
 
-	LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500
+        LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500
 
 In order to have proper acceleration, you need the 32-bit libGL.so:
 
         sudo zypper in Mesa-libGL-devel-32bit
 
-	Where <Name> is the literal name of the AVD that you entered.
+        Where <Name> is the literal name of the AVD that you entered.
 
-	Then:
+        Then:
 
-	cd android/experimental/LOAndroid3
-	ant debug install
-	adb logcat
+        cd android/experimental/LOAndroid3
+        ant debug install
+        adb logcat
 
-	And if all goes well - you should have some nice debug output to enjoy
+        And if all goes well - you should have some nice debug output to enjoy
 when you start the app. After a while of this loop you might find that you have
 lost a lot of space on your emulator's or device's /data volume. If using the
 emulator, you can do:
 
-	adb shell stop; adb shell start
+        adb shell stop; adb shell start
 
 but on a (non-rooted) device you probably just need to reboot it. On the other
 hand, this phenomenon might not happen on actual devices.
 
 * What about using a real device?
 
-	That works fine, too.
+        That works fine, too.
 
 * Debugging
 
-	First of all, you need to configure the build with --enable-debug or
+        First of all, you need to configure the build with --enable-debug or
 --enable-dbgutil.  You may want to provide --enable-selective-debuginfo too,
 like --enable-selective-debuginfo="sw/" or so, in order to fit into the memory
 during linking.
 
-	Building with all symbols is also possible but the linking is currently
+        Building with all symbols is also possible but the linking is currently
 slow (around 10 to 15 minutes) and you need lots of memory (around 16GB + some
 swap).
 
-	You also want to avoid --with-android-package-name (or when you use
+        You also want to avoid --with-android-package-name (or when you use
 that, you must set it to "org.libreoffice"), otherwise ndk-gdb will complain
 that
 
 ERROR: Could not extract package's data directory. Are you sure that
        your installed application is debuggable?
 
-	When you have all this, install the .apk to the device, and:
+        When you have all this, install the .apk to the device, and:
 
-	cd android/experimental/LOAndroid3
-	<android-ndk-r10d>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb --start
+        cd android/experimental/LOAndroid3
+        <android-ndk-r10d>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb --start
 
-	Pretty printers aren't loaded automatically due to the single shared
-	object, but you can still load them manually. E.g. to have a pretty-printer for
-	rtl::OString, you need:
+        Pretty printers aren't loaded automatically due to the single shared
+        object, but you can still load them manually. E.g. to have a pretty-printer for
+        rtl::OString, you need:
 
-	(gdb) python sys.path.insert(0, "/master/solenv/gdb")
-	(gdb) source /master/instdir/program/libuno_sal.so.3-gdb.py
+        (gdb) python sys.path.insert(0, "/master/solenv/gdb")
+        (gdb) source /master/instdir/program/libuno_sal.so.3-gdb.py
 
 * Debuggint the Java part
 
@@ -77,28 +119,27 @@ debugger. Steps to use it:
 
 1) Find out the JDWP ID of a debuggable application:
 
-	adb jdwp
+        adb jdwp
 
 From the list of currently active JDWP processes, the last number is the just
 started debuggable application.
 
 2) Forward the remote JDWP port/process ID to a local port:
 
-	adb forward tcp:7777 jdwp:31739
+        adb forward tcp:7777 jdwp:31739
 
 3) Connect to the running application:
 
-	jdb -sourcepath src/java/ -attach localhost:7777
+        jdb -sourcepath src/java/ -attach localhost:7777
 
 Assuming that you're already in the LOAndroid3 directory in your shell.
 
 * Common Errors / Gotchas
 
 lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
-	This (most likely) means that the install quietly failed, and that
+        This (most likely) means that the install quietly failed, and that
 the file is truncated; check it out with adb shell ls -l /data/data/....
 
-
 * Detailed explanation
 
 Note: the below talk about unit tests is obsolete; we no longer have
@@ -120,17 +161,17 @@ which real end-user apps with GUI etc run. We have no intent to
 require LibreOffice code to be used only on "rooted" devices etc.
 
 All Android apps are basically Java programs. They run "in" a Dalvik
-virtual machine. Yes, you can also have apps where all *your* code is
-native code, written in a compiled language like C or C++. But also
-also such apps are actually started by system-provided Java
-bootstrapping code (NativeActivity) running in a Dalvik VM.
+(or on Android 5 or newer - ART) virtual machine. Yes, you can also
+have apps where all *your* code is native code, written in a compiled
+language like C or C++. But also also such apps are actually started
+by system-provided Java bootstrapping code (NativeActivity) running
+in a Dalvik VM.
 
 Such a native app (or actually, "activity") is not built as a
 executable program, but as a shared object. The Java NativeActivity
 bootstrapper loads that shared object with dlopen.
 
-Anyway, our current "experimental" apps (DocumentLoader,
-LibreOffice4Android and LibreOfficeDesktop) are not based on
-NativeActivity any more. They have normal Java code for the activity,
-and just call out to a single, app-specific native library (called
-liblo-native-code.so) to do all the heavy lifting.
+Anyway, our current "experimental" apps are not based on NativeActivity.
+They have normal Java code for the activity, and just call out to a single,
+app-specific native library (called liblo-native-code.so) to do all the
+heavy lifting.
commit 498f578f97c6dc3dd32f7fe7086d3216f816305a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Mar 26 22:23:10 2015 +0900

    Revert "android: add README"
    
    This reverts commit 9ebd22c353ca2e2b3d37b0c6d266b6c582538edc.

diff --git a/android/README b/android/README
index d7fdf77..5e8db7c 100644
--- a/android/README
+++ b/android/README
@@ -1,40 +1,136 @@
-LibreOffice Android
-*******************
-
-Bootstrap
-*********
-
-Contains common code for all projects on Android to bootstrap LibreOffice. In
-addition it is a home to LibreOfficeKit (LOK - see libreofficekit/README) JNI 
-classes.
-
-LOAndroid3 (in experimental)
-****************************
-
-LibreOffice Android application - the code is based on Fennec (Firefox for Android). 
-It uses OpenGL ES 2 for rendering of the document tiles which are gathered from 
-LibreOffice using LOK. The application contains the LibreOffice core in one shared 
-library: liblo-native-code.so, which is bundled together with the application. 
-
-TiledRendering
-**************
-
-Tiled rendering is a technique that splits the document to bitmaps of same size 
-(typically 256x256) which are fetched on demand. 
-
-Architecture and Threading
-**************************
-
-The application implements editing support using 4 threads:
-1. The Android UI thread, we can't perform anything here that would take a considerable 
-   amount of time.
-2. An OpenGL thread which contains the OpenGL context and is responsible for drawing 
-   all layers (including tiles) to the screen.
-3. A thread (LOKitThread), that performs LibreOfficeKit calls, which may take more time
-   to complete. In addition it also receives events from the soffice thread (see below) 
-   when the callback emits an event. Events are stored in a blocking queue (thread 
-   processes events in FCFS order, goes to sleep when no more event is available and
-   awakens when there are events in queue again).
-4. A native thread created by LibreOfficeKit (we call it the soffice thread), where 
-   LibreOffice itself runs. It receives calls from LOKitThread, and may emit callback 
-   events as necessary.
+Android-specific notes
+
+Note that this document has not necessarily been updated to match
+reality...
+
+For instructions on how to build for Android, see README.cross.
+
+* Getting something running on an emulated device
+
+	Create an AVD in the android UI, don't even try to get
+the data partition size right in the GUI, that is doomed to producing
+an AVD that doesn't work. Instead start it from the console:
+
+	LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500
+
+In order to have proper acceleration, you need the 32-bit libGL.so:
+
+        sudo zypper in Mesa-libGL-devel-32bit
+
+	Where <Name> is the literal name of the AVD that you entered.
+
+	Then:
+
+	cd android/experimental/LOAndroid3
+	ant debug install
+	adb logcat
+
+	And if all goes well - you should have some nice debug output to enjoy
+when you start the app. After a while of this loop you might find that you have
+lost a lot of space on your emulator's or device's /data volume. If using the
+emulator, you can do:
+
+	adb shell stop; adb shell start
+
+but on a (non-rooted) device you probably just need to reboot it. On the other
+hand, this phenomenon might not happen on actual devices.
+
+* What about using a real device?
+
+	That works fine, too.
+
+* Debugging
+
+	First of all, you need to configure the build with --enable-debug or
+--enable-dbgutil.  You may want to provide --enable-selective-debuginfo too,
+like --enable-selective-debuginfo="sw/" or so, in order to fit into the memory
+during linking.
+
+	Building with all symbols is also possible but the linking is currently
+slow (around 10 to 15 minutes) and you need lots of memory (around 16GB + some
+swap).
+
+	You also want to avoid --with-android-package-name (or when you use
+that, you must set it to "org.libreoffice"), otherwise ndk-gdb will complain
+that
+
+ERROR: Could not extract package's data directory. Are you sure that
+       your installed application is debuggable?
+
+	When you have all this, install the .apk to the device, and:
+
+	cd android/experimental/LOAndroid3
+	<android-ndk-r10d>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb --start
+
+	Pretty printers aren't loaded automatically due to the single shared
+	object, but you can still load them manually. E.g. to have a pretty-printer for
+	rtl::OString, you need:
+
+	(gdb) python sys.path.insert(0, "/master/solenv/gdb")
+	(gdb) source /master/instdir/program/libuno_sal.so.3-gdb.py
+
+* Debuggint the Java part
+
+At the moment the code is not organized in a way that would make Eclipse or
+Android Studio happy as-is, so the quickest way is to use the jdb command-line
+debugger. Steps to use it:
+
+1) Find out the JDWP ID of a debuggable application:
+
+	adb jdwp
+
+From the list of currently active JDWP processes, the last number is the just
+started debuggable application.
+
+2) Forward the remote JDWP port/process ID to a local port:
+
+	adb forward tcp:7777 jdwp:31739
+
+3) Connect to the running application:
+
+	jdb -sourcepath src/java/ -attach localhost:7777
+
+Assuming that you're already in the LOAndroid3 directory in your shell.
+
+* Common Errors / Gotchas
+
+lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
+	This (most likely) means that the install quietly failed, and that
+the file is truncated; check it out with adb shell ls -l /data/data/....
+
+
+* Detailed explanation
+
+Note: the below talk about unit tests is obsolete; we no longer have
+any makefilery etc to build unit tests for Android.
+
+Unit tests are the first thing we want to run on Android, to get some
+idea how well, if at all, the basic LO libraries work. We want to
+build even unit tests as normal Android apps, i.e. packaged as .apk
+files, so that they run in a sandboxed environment like that of
+whatever eventual end-user Android apps there will be that use LO
+code.
+
+Sure, we could quite easily build unit tests as plain Linux
+executables (built against the Android libraries, of course, not
+GNU/Linux ones), push them to the device or emulator with adb and run
+them from adb shell, but that would not be a good test as the
+environment such processs run in is completely different from that in
+which real end-user apps with GUI etc run. We have no intent to
+require LibreOffice code to be used only on "rooted" devices etc.
+
+All Android apps are basically Java programs. They run "in" a Dalvik
+virtual machine. Yes, you can also have apps where all *your* code is
+native code, written in a compiled language like C or C++. But also
+also such apps are actually started by system-provided Java
+bootstrapping code (NativeActivity) running in a Dalvik VM.
+
+Such a native app (or actually, "activity") is not built as a
+executable program, but as a shared object. The Java NativeActivity
+bootstrapper loads that shared object with dlopen.
+
+Anyway, our current "experimental" apps (DocumentLoader,
+LibreOffice4Android and LibreOfficeDesktop) are not based on
+NativeActivity any more. They have normal Java code for the activity,
+and just call out to a single, app-specific native library (called
+liblo-native-code.so) to do all the heavy lifting.
commit 2675d681df13fe8e8399cc445465595be0d9a213
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Mar 26 21:48:02 2015 +0900

    android: add README
    
    Change-Id: I7a2b3cb487b4dfe290bff36e3766357fbbc84fba

diff --git a/android/README b/android/README
index 5e8db7c..d7fdf77 100644
--- a/android/README
+++ b/android/README
@@ -1,136 +1,40 @@
-Android-specific notes
-
-Note that this document has not necessarily been updated to match
-reality...
-
-For instructions on how to build for Android, see README.cross.
-
-* Getting something running on an emulated device
-
-	Create an AVD in the android UI, don't even try to get
-the data partition size right in the GUI, that is doomed to producing
-an AVD that doesn't work. Instead start it from the console:
-
-	LD_LIBRARY_PATH=$(pwd)/lib emulator-arm -avd <Name> -partition-size 500
-
-In order to have proper acceleration, you need the 32-bit libGL.so:
-
-        sudo zypper in Mesa-libGL-devel-32bit
-
-	Where <Name> is the literal name of the AVD that you entered.
-
-	Then:
-
-	cd android/experimental/LOAndroid3
-	ant debug install
-	adb logcat
-
-	And if all goes well - you should have some nice debug output to enjoy
-when you start the app. After a while of this loop you might find that you have
-lost a lot of space on your emulator's or device's /data volume. If using the
-emulator, you can do:
-
-	adb shell stop; adb shell start
-
-but on a (non-rooted) device you probably just need to reboot it. On the other
-hand, this phenomenon might not happen on actual devices.
-
-* What about using a real device?
-
-	That works fine, too.
-
-* Debugging
-
-	First of all, you need to configure the build with --enable-debug or
---enable-dbgutil.  You may want to provide --enable-selective-debuginfo too,
-like --enable-selective-debuginfo="sw/" or so, in order to fit into the memory
-during linking.
-
-	Building with all symbols is also possible but the linking is currently
-slow (around 10 to 15 minutes) and you need lots of memory (around 16GB + some
-swap).
-
-	You also want to avoid --with-android-package-name (or when you use
-that, you must set it to "org.libreoffice"), otherwise ndk-gdb will complain
-that
-
-ERROR: Could not extract package's data directory. Are you sure that
-       your installed application is debuggable?
-
-	When you have all this, install the .apk to the device, and:
-
-	cd android/experimental/LOAndroid3
-	<android-ndk-r10d>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb --start
-
-	Pretty printers aren't loaded automatically due to the single shared
-	object, but you can still load them manually. E.g. to have a pretty-printer for
-	rtl::OString, you need:
-
-	(gdb) python sys.path.insert(0, "/master/solenv/gdb")
-	(gdb) source /master/instdir/program/libuno_sal.so.3-gdb.py
-
-* Debuggint the Java part
-
-At the moment the code is not organized in a way that would make Eclipse or
-Android Studio happy as-is, so the quickest way is to use the jdb command-line
-debugger. Steps to use it:
-
-1) Find out the JDWP ID of a debuggable application:
-
-	adb jdwp
-
-From the list of currently active JDWP processes, the last number is the just
-started debuggable application.
-
-2) Forward the remote JDWP port/process ID to a local port:
-
-	adb forward tcp:7777 jdwp:31739
-
-3) Connect to the running application:
-
-	jdb -sourcepath src/java/ -attach localhost:7777
-
-Assuming that you're already in the LOAndroid3 directory in your shell.
-
-* Common Errors / Gotchas
-
-lo_dlneeds: Could not read ELF header of /data/data/org.libreoffice...libfoo.so
-	This (most likely) means that the install quietly failed, and that
-the file is truncated; check it out with adb shell ls -l /data/data/....
-
-
-* Detailed explanation
-
-Note: the below talk about unit tests is obsolete; we no longer have
-any makefilery etc to build unit tests for Android.
-
-Unit tests are the first thing we want to run on Android, to get some
-idea how well, if at all, the basic LO libraries work. We want to
-build even unit tests as normal Android apps, i.e. packaged as .apk
-files, so that they run in a sandboxed environment like that of
-whatever eventual end-user Android apps there will be that use LO
-code.
-
-Sure, we could quite easily build unit tests as plain Linux
-executables (built against the Android libraries, of course, not
-GNU/Linux ones), push them to the device or emulator with adb and run
-them from adb shell, but that would not be a good test as the
-environment such processs run in is completely different from that in
-which real end-user apps with GUI etc run. We have no intent to
-require LibreOffice code to be used only on "rooted" devices etc.
-
-All Android apps are basically Java programs. They run "in" a Dalvik
-virtual machine. Yes, you can also have apps where all *your* code is
-native code, written in a compiled language like C or C++. But also
-also such apps are actually started by system-provided Java
-bootstrapping code (NativeActivity) running in a Dalvik VM.
-
-Such a native app (or actually, "activity") is not built as a
-executable program, but as a shared object. The Java NativeActivity
-bootstrapper loads that shared object with dlopen.
-
-Anyway, our current "experimental" apps (DocumentLoader,
-LibreOffice4Android and LibreOfficeDesktop) are not based on
-NativeActivity any more. They have normal Java code for the activity,
-and just call out to a single, app-specific native library (called
-liblo-native-code.so) to do all the heavy lifting.
+LibreOffice Android
+*******************
+
+Bootstrap
+*********
+
+Contains common code for all projects on Android to bootstrap LibreOffice. In
+addition it is a home to LibreOfficeKit (LOK - see libreofficekit/README) JNI 
+classes.
+
+LOAndroid3 (in experimental)
+****************************
+
+LibreOffice Android application - the code is based on Fennec (Firefox for Android). 
+It uses OpenGL ES 2 for rendering of the document tiles which are gathered from 
+LibreOffice using LOK. The application contains the LibreOffice core in one shared 
+library: liblo-native-code.so, which is bundled together with the application. 
+
+TiledRendering
+**************
+
+Tiled rendering is a technique that splits the document to bitmaps of same size 
+(typically 256x256) which are fetched on demand. 
+
+Architecture and Threading
+**************************
+
+The application implements editing support using 4 threads:
+1. The Android UI thread, we can't perform anything here that would take a considerable 
+   amount of time.
+2. An OpenGL thread which contains the OpenGL context and is responsible for drawing 
+   all layers (including tiles) to the screen.
+3. A thread (LOKitThread), that performs LibreOfficeKit calls, which may take more time
+   to complete. In addition it also receives events from the soffice thread (see below) 
+   when the callback emits an event. Events are stored in a blocking queue (thread 
+   processes events in FCFS order, goes to sleep when no more event is available and
+   awakens when there are events in queue again).
+4. A native thread created by LibreOfficeKit (we call it the soffice thread), where 
+   LibreOffice itself runs. It receives calls from LOKitThread, and may emit callback 
+   events as necessary.
commit 25f0d5772bcaa28dda6441dfcbe0aea6b6202ba3
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Mar 26 20:33:08 2015 +0900

    android: add contains (hit test) to CanvasElement interface
    
    Change-Id: Ic0022790c9ee1a5be1352eba0815e0d63ae17025

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java
index 154d4ce..094894b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java
@@ -21,5 +21,12 @@ public interface CanvasElement {
      * @param canvas - the canvas
      */
     void draw(Canvas canvas);
+
+    /**
+     * Hit test - returns true if the object has been hit
+     * @param x - x coordinate of the
+     * @param y - y coordinate of the
+     */
+    boolean contains(float x, float y);
 }
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
index 8251495..4439bad 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
@@ -64,6 +64,7 @@ public class GraphicSelection implements CanvasElement {
         mHandles[7].reposition(scaledRectangle.right, scaledRectangle.bottom);
     }
 
+    @Override
     public boolean contains(float x, float y) {
         // Check if handle was hit
         for (GraphicSelectionHandle handle : mHandles) {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
index 109592e..a33589f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
@@ -73,6 +73,7 @@ public class GraphicSelectionHandle implements CanvasElement {
         mHitRect.bottom = mPosition.y + mRadius * 1.75f;
     }
 
+    @Override
     public boolean contains(float x, float y) {
         return mHitRect.contains(x, y);
     }
commit 24587ecbb77a15cf5d5ba58ee03c31a7071a98c6
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Mar 26 12:33:40 2015 +0100

    sc tiled editing: Implement scaling of drawings and bitmaps in Calc.
    
    Change-Id: I1faa4608047e5a7ce30c317c72babfa44cdd808d

diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index c8a9d93..0717635 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -119,7 +119,7 @@ public:
      *
      * @see lok::Document::setGraphicSelection().
      */
-    virtual void setGraphicSelection(int /*nType*/, int /*nX*/, int /*nY*/) { }
+    virtual void setGraphicSelection(int nType, int nX, int nY) = 0;
 
     /**
      * @see lok::Document::resetSelection().
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index a2af3b4..e826eb7 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -397,6 +397,9 @@ public:
     /// @see vcl::ITiledRenderable::setTextSelection().
     virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
 
+    /// @see vcl::ITiledRenderable::setGraphicSelection().
+    virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
+
     /// @see vcl::ITiledRenderable::initializeForTiledRendering().
     virtual void initializeForTiledRendering() SAL_OVERRIDE;
 };
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4ec5415..725c76e 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -598,7 +598,6 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
 
         // There seems to be no clear way of getting the grid window for this
         // particular document, hence we need to hope we get the right window.
-        ScViewData* pViewData = ScDocShell::GetViewData();
         ScGridWindow* pGridWindow = pViewData->GetActiveWin();
 
         if (!pGridWindow)
@@ -608,6 +607,42 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY)
     }
 }
 
+void ScModelObj::setGraphicSelection(int nType, int nX, int nY)
+{
+    SolarMutexGuard aGuard;
+
+    // There seems to be no clear way of getting the grid window for this
+    // particular document, hence we need to hope we get the right window.
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+
+    int nPixelX = nX * pViewData->GetPPTX();
+    int nPixelY = nY * pViewData->GetPPTY();
+
+    switch (nType)
+    {
+    case LOK_SETGRAPHICSELECTION_START:

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list