[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 539 commits - accessibility/source android/Bootstrap android/experimental android/mobile-config.py avmedia/Library_avmediavlc.mk avmedia/source basctl/source basebmp/Library_basebmp.mk basegfx/source basic/inc basic/source binaryurp/source bin/find-german-comments bin/find-unused-defines.awk bin/find-unused-defines.sh bin/gbuild-to-ide bridges/inc bridges/source canvas/Library_cairocanvas.mk canvas/source chart2/inc chart2/source comphelper/source compilerplugins/clang config_host/config_features.h.in config_host.mk.in configure.ac connectivity/Module_connectivity.mk connectivity/registry connectivity/source cppcanvas/qa cppcanvas/source cppuhelper/source cppu/source crashrep/CustomTarget_crashrep_res.mk crashrep/Executable_crashrep.mk crashrep/Makefile crashrep/Module_crashrep.mk crashrep/README crashrep/source crashrep/WinResTarget_crashrep.mk cui/source dbaccess/inc dbaccess/qa dbaccess/source dbaccess/uiconfig desktop/Executable _crashrep_com.mk desktop/Library_sofficeapp.mk desktop/Module_desktop.mk desktop/source desktop/win32 dictionaries distro-configs/OxygenOfficeLinux.conf download.lst drawinglayer/source dtrans/source editeng/source embeddedobj/source embeddedobj/test extensions/source external/beanshell external/boost external/coinmp external/graphite external/hunspell external/icu external/jpeg-turbo external/libebook external/libmspub external/libmwaw external/libvisio external/python3 external/redland extras/Module_extras.mk extras/Package_tplofficorr.mk extras/Package_tploffimisc.mk extras/Package_tplpersonal.mk extras/Package_tplpresnt.mk extras/source filter/Configuration_filter.mk filter/qa filter/source forms/qa forms/source formula/source fpicker/source framework/inc framework/qa framework/source g helpcompiler/source helpcontent2 hwpfilter/source i18npool/inc i18npool/source icon-themes/sifr idl/inc idl/source include/avmedia include/basebmp include/basegfx include/basic include/clew inclu de/comphelper include/connectivity include/cppuhelper include/dbaccess include/drawinglayer include/editeng include/filter include/formula include/LibreOfficeKit include/o3tl include/oox include/opencl include/osl include/postwin.h include/rtl include/sal include/sfx2 include/sot include/svl include/svtools include/svx include/toolkit include/tools include/uno include/unotools include/vcl include/xmloff javaunohelper/com javaunohelper/source jvmfwk/plugins l10ntools/inc libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/qa libreofficekit/README libreofficekit/source linguistic/qa lotuswordpro/source Makefile.in mysqlc/source odk/examples odk/source offapi/com officecfg/registry oox/source opencl/source package/inc package/source qadevOOo/runner qadevOOo/tests readlicense_oo/license reportdesign/inc reportdesign/qa reportdesign/source RepositoryExternal.mk RepositoryFixes.mk Repository.mk RepositoryModule_host.mk rsc/inc rsc/source sal/android sal/osl sal/qa sal/rtl sal/textenc scaddins/source sc/CppunitTest_sc_condformats.mk sc/CppunitTest_sc_opencl_test.mk sc/inc sc/Module_sc.mk scp2/AutoInstall.mk scp2/InstallModule_crashrep.mk scp2/InstallScript_setup_osl.mk scp2/Module_scp2.mk scp2/source sc/qa scripting/java sc/sdi sc/source sc/uiconfig sdext/source sd/inc sd/Library_sd.mk sd/source setup_native/scripts sfx2/qa sfx2/source sfx2/uiconfig shell/inc slideshow/source solenv/bin solenv/gbuild soltools/mkdepend sot/qa sot/source sot/workben starmath/CppunitTest_starmath_import.mk starmath/inc starmath/Library_sm.mk starmath/Module_starmath.mk starmath/qa starmath/source stoc/source svgio/qa svgio/source svl/source svtools/source svx/inc svx/Library_svxcore.mk svx/source svx/workben sw/inc sw/Library_sw.mk sw/qa sw/source sw/uiconfig sysui/desktop test/source toolkit/Library_tk.mk toolkit/qa toolkit/source tools/qa tools/source tubes/source ucb/qa ucb/source UnoControls/source unodevtools/source unotest/source unotools/source uui/source vcl/android vcl/generic vcl/headless vcl/inc vcl/ios vcl/Library_vcl.mk vcl/opengl vcl/osx vcl/qa vcl/source vcl/unx vcl/win vcl/WinResTarget_vcl.mk vcl/workben wizards/com wizards/source writerfilter/documentation writerfilter/qa writerfilter/source xmlhelp/source xmloff/Module_xmloff.mk xmloff/source xmlsecurity/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jan 19 02:44:52 PST 2015


Rebased ref, commits from common ancestor:
commit 016b7259dbb79dbe56d527a5147f04e821ad0cd7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jan 19 09:12:05 2015 +0100

    android: show vendor in LOAbout
    
    Change-Id: Iddcf953718083b218d41fcb895d28adb5808a8f4

diff --git a/android/Bootstrap/Makefile.shared b/android/Bootstrap/Makefile.shared
index ee50d1f..3332646 100644
--- a/android/Bootstrap/Makefile.shared
+++ b/android/Bootstrap/Makefile.shared
@@ -182,7 +182,7 @@ copy-stuff:
 	echo 'BuildVersion=' >> assets/program/versionrc
 	echo 'buildid=$(shell cd $(SRCDIR) && git log -1 --format=%H)' >> assets/program/versionrc
 	echo 'ReferenceOOoMajorMinor=4.1' >> assets/program/versionrc
-	sed -i 's|android:versionName=".*"|android:versionName="$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX)/$(shell cd $(SRCDIR) && git log -1 --format=%H)"|' AndroidManifest.xml
+	sed -i 's|android:versionName=".*"|android:versionName="$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX)/$(shell cd $(SRCDIR) && git log -1 --format=%H)/$(OOO_VENDOR)"|' AndroidManifest.xml
 #
 # .res files
 	mkdir -p assets/program/resource
diff --git a/android/experimental/LOAndroid3/res/layout/about.xml b/android/experimental/LOAndroid3/res/layout/about.xml
index c15f0cc..49f707a 100644
--- a/android/experimental/LOAndroid3/res/layout/about.xml
+++ b/android/experimental/LOAndroid3/res/layout/about.xml
@@ -34,4 +34,12 @@
         android:textColor="@android:color/secondary_text_light"
         android:textSize="18dip"/>
 
+    <TextView
+        android:id="@+id/about_vendor"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textIsSelectable="true"
+        android:text="@string/app_vendor"
+        android:textColor="@android:color/secondary_text_light"
+        android:textSize="18sp"/>
 </LinearLayout>
diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index 2d03388..47fee0c 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -7,6 +7,7 @@
     <string name="app_version">Version: $VERSION\nBuild ID: $BUILDID</string>
     <string name="app_description">LibreOffice Viewer is a document viewer based on LibreOffice.</string>
     <string name="app_credits">http://www.libreoffice.org</string>
+    <string name="app_vendor">This release was supplied by $VENDOR.</string>
 
     <string name="about_license">Show License</string>
     <string name="about_notice">Show Notice</string>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
index 1aca1c6..27bb50a 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
@@ -59,25 +59,30 @@ public abstract class LOAbout extends Activity {
         int defaultColor = textView.getTextColors().getDefaultColor();
         textView.setTextColor(defaultColor);
 
-        // Take care of placeholders in the version text view.
-        textView = (TextView)messageView.findViewById(R.id.about_version);
+        // Take care of placeholders in the version and vendor text views.
+        TextView versionView = (TextView)messageView.findViewById(R.id.about_version);
+        TextView vendorView = (TextView)messageView.findViewById(R.id.about_vendor);
         try
         {
             String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
             String[] tokens = versionName.split("/");
-            if (tokens.length == 2)
+            if (tokens.length == 3)
             {
-                String version = textView.getText().toString();
+                String version = versionView.getText().toString();
+                String vendor = vendorView.getText().toString();
                 version = version.replace("$VERSION", tokens[0]);
                 version = version.replace("$BUILDID", tokens[1]);
-                textView.setText(version);
+                vendor = vendor.replace("$VENDOR", tokens[2]);
+                versionView.setText(version);
+                vendorView.setText(vendor);
             }
             else
                 throw new NameNotFoundException();
         }
         catch (NameNotFoundException e)
         {
-            textView.setText("");
+            versionView.setText("");
+            vendorView.setText("");
         }
 
 
commit e17f0fb193dcc1e333b332019ddfa18b4f9f2734
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 16 18:53:45 2015 +0100

    libreofficekit: update README, deploy a couple of g_info() calls
    
    As we can't use SAL_INFO in C code (not to mention that the widget
    doesn't link to LO code, either).
    
    Change-Id: I71b925ab3c18c2e0afebe84cdaefd5c01fc91872

diff --git a/libreofficekit/README b/libreofficekit/README
index 8b18b36..eb29106 100644
--- a/libreofficekit/README
+++ b/libreofficekit/README
@@ -43,6 +43,5 @@ LibreOfficeKitGtk
 
 Currently consists of only a very basic GTK+ document viewer widget.
 
-Currently this simply renders the entire document as one large tile (for
-Writer) and/or entire sheet for Calc, which can be somewhat slow with
-larger documents.
+The widget uses g_info() instead of SAL_INFO(), use the 'G_MESSAGES_DEBUG=all'
+environment variable to display those messages.
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 2be201f..c24755b 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -134,7 +134,10 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD
     int nCode = 0;
 
     if (!pLOKDocView->m_bEdit)
+    {
+        g_info("signalKey: not in edit mode, ignore");
         return;
+    }
 
     switch (pEvent->keyval)
     {
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 519b9b3..b335d8b 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -191,6 +191,7 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
 
                 pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, aTileRectanglePixels.width, aTileRectanglePixels.height);
                 pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
+                g_info("renderDocument: paintTile(%d, %d)", nRow, nColumn);
                 pDocView->pDocument->pClass->paintTile(pDocView->pDocument,
                                                        // Buffer and its size, depends on the position only.
                                                        pBuffer,
@@ -287,6 +288,7 @@ static void lok_docview_callback_worker(int nType, const char* pPayload, void* p
     pCallback->m_nType = nType;
     pCallback->m_pPayload = g_strdup(pPayload);
     pCallback->m_pDocView = pDocView;
+    g_info("lok_docview_callback_worker: %d, '%s'", nType, pPayload);
 #if GTK_CHECK_VERSION(2,12,0)
     gdk_threads_add_idle(lok_docview_callback, pCallback);
 #else
@@ -368,7 +370,10 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_edit( LOKDocView* pDocView,
                                                 gboolean bEdit )
 {
     if (!pDocView->m_bEdit && bEdit)
+    {
+        g_info("lok_docview_set_edit: entering edit mode, registering callback");
         pDocView->pDocument->pClass->registerCallback(pDocView->pDocument, &lok_docview_callback_worker, pDocView);
+    }
     pDocView->m_bEdit = bEdit;
 }
 
commit 1ac719985e1339033664747a562b03f9ef87e97b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 16 18:42:31 2015 +0100

    lokdocview: reduce scope
    
    Change-Id: I246ef656f1211cf760d4fcf408b83f39a1c56b56

diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index ec61410..519b9b3 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -160,55 +160,56 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
     {
         for (nColumn = 0; nColumn < nColumns; ++nColumn)
         {
-            int nTileWidthPixels, nTileHeightPixels;
-            GdkPixbuf* pPixBuf;
-            unsigned char* pBuffer;
-            int nRowStride;
-            GdkRectangle aTileRectangle;
+            GdkRectangle aTileRectangleTwips, aTileRectanglePixels;
             gboolean bPaint = TRUE;
 
             // Determine size of the tile: the rightmost/bottommost tiles may be smaller and we need the size to decide if we need to repaint.
             if (nColumn == nColumns - 1)
-                nTileWidthPixels = nDocumentWidthPixels - nColumn * nTileSizePixels;
+                aTileRectanglePixels.width = nDocumentWidthPixels - nColumn * nTileSizePixels;
             else
-                nTileWidthPixels = nTileSizePixels;
+                aTileRectanglePixels.width = nTileSizePixels;
             if (nRow == nRows - 1)
-                nTileHeightPixels = nDocumentHeightPixels - nRow * nTileSizePixels;
+                aTileRectanglePixels.height = nDocumentHeightPixels - nRow * nTileSizePixels;
             else
-                nTileHeightPixels = nTileSizePixels;
+                aTileRectanglePixels.height = nTileSizePixels;
 
             // Determine size and position of the tile in document coordinates, so we can decide if we can skip painting for partial rendering.
-            aTileRectangle.x = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn;
-            aTileRectangle.y = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow;
-            aTileRectangle.width = pixelToTwip(nTileWidthPixels) / pDocView->fZoom;
-            aTileRectangle.height = pixelToTwip(nTileHeightPixels) / pDocView->fZoom;
-            if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangle, NULL))
+            aTileRectangleTwips.x = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn;
+            aTileRectangleTwips.y = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow;
+            aTileRectangleTwips.width = pixelToTwip(aTileRectanglePixels.width) / pDocView->fZoom;
+            aTileRectangleTwips.height = pixelToTwip(aTileRectanglePixels.height) / pDocView->fZoom;
+            if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangleTwips, NULL))
                     bPaint = FALSE;
 
             if (bPaint)
             {
-                pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, nTileWidthPixels, nTileHeightPixels);
+                // Index of the current tile.
+                guint nTile = nRow * nColumns + nColumn;
+                GdkPixbuf* pPixBuf;
+                unsigned char* pBuffer;
+                int nRowStride;
+
+                pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, aTileRectanglePixels.width, aTileRectanglePixels.height);
                 pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
                 pDocView->pDocument->pClass->paintTile(pDocView->pDocument,
                                                        // Buffer and its size, depends on the position only.
                                                        pBuffer,
-                                                       nTileWidthPixels, nTileHeightPixels,
+                                                       aTileRectanglePixels.width, aTileRectanglePixels.height,
                                                        &nRowStride,
                                                        // Position of the tile.
-                                                       aTileRectangle.x, aTileRectangle.y,
+                                                       aTileRectangleTwips.x, aTileRectangleTwips.y,
                                                        // Size of the tile, depends on the zoom factor and the tile position only.
-                                                       aTileRectangle.width, aTileRectangle.height);
+                                                       aTileRectangleTwips.width, aTileRectangleTwips.height);
                 (void) nRowStride;
 
-                if (pDocView->pCanvas[nRow * nColumns + nColumn])
-                    gtk_widget_destroy(GTK_WIDGET(pDocView->pCanvas[nRow * nColumns + nColumn]));
-                pDocView->pCanvas[nRow * nColumns + nColumn] = gtk_image_new();
-                gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->pCanvas[nRow * nColumns + nColumn]), pPixBuf);
+                if (pDocView->pCanvas[nTile])
+                    gtk_widget_destroy(GTK_WIDGET(pDocView->pCanvas[nTile]));
+                pDocView->pCanvas[nTile] = gtk_image_new();
+                gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->pCanvas[nTile]), pPixBuf);
                 g_object_unref(G_OBJECT(pPixBuf));
-                gtk_widget_show(pDocView->pCanvas[nRow * nColumns + nColumn]);
-                gtk_table_attach_defaults(GTK_TABLE(pDocView->pTable), pDocView->pCanvas[nRow * nColumns + nColumn], nColumn, nColumn + 1, nRow, nRow + 1);
+                gtk_widget_show(pDocView->pCanvas[nTile]);
                 gtk_table_attach(GTK_TABLE(pDocView->pTable),
-                                 pDocView->pCanvas[nRow * nColumns + nColumn],
+                                 pDocView->pCanvas[nTile],
                                  nColumn, nColumn + 1, nRow, nRow + 1,
                                  GTK_SHRINK, GTK_SHRINK, 0, 0);
             }
commit 80dc9a084b9037dca57db568160a1bfb9bba1c3c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 16 15:47:51 2015 +0100

    lokdocview: add support for partial rendering
    
    When typing a single letter to an empty document with an A4 paper size,
    this reduces the number of rendered tiles from 20 to 3.
    
    It also allows detecting when LOK_CALLBACK_INVALIDATE_TILES has a buggy
    parameter (e.g. empty rectangle -> no re-rendering).
    
    Change-Id: I8f509d1eb5c8f059663e544be8028503ed7a882e

diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index b0c1c64..ec61410 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -9,6 +9,7 @@
 
 #include <sal/types.h>
 #include <math.h>
+#include <string.h>
 
 #define LOK_USE_UNSTABLE_API
 #include <LibreOfficeKit/LibreOfficeKit.h>
@@ -113,11 +114,14 @@ static float pixelToTwip(float nInput)
     return (nInput / g_nDPI) * 1440.0f;
 }
 
-void renderDocument( LOKDocView* pDocView )
+void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
 {
     long nDocumentWidthTwips, nDocumentHeightTwips, nDocumentWidthPixels, nDocumentHeightPixels;
     const int nTileSizePixels = 256;
-    long nRow, nColumn, nRows, nColumns;
+    // Current row / column.
+    guint nRow, nColumn;
+    // Total number of rows / columns in this document.
+    guint nRows, nColumns;
 
     // Get document size and find out how many rows / columns we need.
     pDocView->pDocument->pClass->getDocumentSize(pDocView->pDocument, &nDocumentWidthTwips, &nDocumentHeightTwips);
@@ -127,14 +131,29 @@ void renderDocument( LOKDocView* pDocView )
     nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
 
     // Set up our table and the tile pointers.
-    if (pDocView->pTable)
-        gtk_container_remove(GTK_CONTAINER( pDocView->pEventBox ), pDocView->pTable);
-    pDocView->pTable = gtk_table_new(nRows, nColumns, FALSE);
-    gtk_container_add(GTK_CONTAINER(pDocView->pEventBox), pDocView->pTable);
-    gtk_widget_show(pDocView->pTable);
-    if (pDocView->pCanvas)
-        g_free(pDocView->pCanvas);
-    pDocView->pCanvas = g_malloc0(sizeof(GtkWidget*) * nRows * nColumns);
+    if (!pDocView->pTable)
+        pPartial = NULL;
+    if (pPartial)
+    {
+        // Same as nRows / nColumns, but from the previous renderDocument() call.
+        guint nOldRows, nOldColumns;
+
+        gtk_table_get_size(GTK_TABLE(pDocView->pTable), &nOldRows, &nOldColumns);
+        if (nOldRows != nRows || nOldColumns != nColumns)
+            // Can't do partial rendering, document size changed.
+            pPartial = NULL;
+    }
+    if (!pPartial)
+    {
+        if (pDocView->pTable)
+            gtk_container_remove(GTK_CONTAINER(pDocView->pEventBox), pDocView->pTable);
+        pDocView->pTable = gtk_table_new(nRows, nColumns, FALSE);
+        gtk_container_add(GTK_CONTAINER(pDocView->pEventBox), pDocView->pTable);
+        gtk_widget_show(pDocView->pTable);
+        if (pDocView->pCanvas)
+            g_free(pDocView->pCanvas);
+        pDocView->pCanvas = g_malloc0(sizeof(GtkWidget*) * nRows * nColumns);
+    }
 
     // Render the tiles.
     for (nRow = 0; nRow < nRows; ++nRow)
@@ -145,8 +164,10 @@ void renderDocument( LOKDocView* pDocView )
             GdkPixbuf* pPixBuf;
             unsigned char* pBuffer;
             int nRowStride;
+            GdkRectangle aTileRectangle;
+            gboolean bPaint = TRUE;
 
-            // The rightmost/bottommost tiles may be smaller.
+            // Determine size of the tile: the rightmost/bottommost tiles may be smaller and we need the size to decide if we need to repaint.
             if (nColumn == nColumns - 1)
                 nTileWidthPixels = nDocumentWidthPixels - nColumn * nTileSizePixels;
             else
@@ -156,27 +177,41 @@ void renderDocument( LOKDocView* pDocView )
             else
                 nTileHeightPixels = nTileSizePixels;
 
-            pPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, nTileWidthPixels, nTileHeightPixels);
-            pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
-            pDocView->pDocument->pClass->paintTile( pDocView->pDocument,
-                                                    // Buffer and its size, depends on the position only.
-                                                    pBuffer,
-                                                    nTileWidthPixels, nTileHeightPixels,
-                                                    &nRowStride,
-                                                    // Position of the tile.
-                                                    pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn, pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow,
-                                                    // Size of the tile, depends on the zoom factor and the tile position only.
-                                                    pixelToTwip(nTileWidthPixels) / pDocView->fZoom, pixelToTwip(nTileHeightPixels) / pDocView->fZoom );
-            (void) nRowStride;
-
-            pDocView->pCanvas[nRow * nColumns + nColumn] = gtk_image_new();
-            gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas[nRow * nColumns + nColumn] ), pPixBuf );
-            g_object_unref(G_OBJECT(pPixBuf));
-            gtk_table_attach(GTK_TABLE(pDocView->pTable),
-                             pDocView->pCanvas[nRow * nColumns + nColumn],
-                             nColumn, nColumn + 1, nRow, nRow + 1,
-                             GTK_SHRINK, GTK_SHRINK, 0, 0);
-            gtk_widget_show(pDocView->pCanvas[nRow * nColumns + nColumn]);
+            // Determine size and position of the tile in document coordinates, so we can decide if we can skip painting for partial rendering.
+            aTileRectangle.x = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn;
+            aTileRectangle.y = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow;
+            aTileRectangle.width = pixelToTwip(nTileWidthPixels) / pDocView->fZoom;
+            aTileRectangle.height = pixelToTwip(nTileHeightPixels) / pDocView->fZoom;
+            if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangle, NULL))
+                    bPaint = FALSE;
+
+            if (bPaint)
+            {
+                pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, nTileWidthPixels, nTileHeightPixels);
+                pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
+                pDocView->pDocument->pClass->paintTile(pDocView->pDocument,
+                                                       // Buffer and its size, depends on the position only.
+                                                       pBuffer,
+                                                       nTileWidthPixels, nTileHeightPixels,
+                                                       &nRowStride,
+                                                       // Position of the tile.
+                                                       aTileRectangle.x, aTileRectangle.y,
+                                                       // Size of the tile, depends on the zoom factor and the tile position only.
+                                                       aTileRectangle.width, aTileRectangle.height);
+                (void) nRowStride;
+
+                if (pDocView->pCanvas[nRow * nColumns + nColumn])
+                    gtk_widget_destroy(GTK_WIDGET(pDocView->pCanvas[nRow * nColumns + nColumn]));
+                pDocView->pCanvas[nRow * nColumns + nColumn] = gtk_image_new();
+                gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->pCanvas[nRow * nColumns + nColumn]), pPixBuf);
+                g_object_unref(G_OBJECT(pPixBuf));
+                gtk_widget_show(pDocView->pCanvas[nRow * nColumns + nColumn]);
+                gtk_table_attach_defaults(GTK_TABLE(pDocView->pTable), pDocView->pCanvas[nRow * nColumns + nColumn], nColumn, nColumn + 1, nRow, nRow + 1);
+                gtk_table_attach(GTK_TABLE(pDocView->pTable),
+                                 pDocView->pCanvas[nRow * nColumns + nColumn],
+                                 nColumn, nColumn + 1, nRow, nRow + 1,
+                                 GTK_SHRINK, GTK_SHRINK, 0, 0);
+            }
         }
     }
 }
@@ -185,11 +220,36 @@ void renderDocument( LOKDocView* pDocView )
 typedef struct
 {
     int m_nType;
-    const char* m_pPayload;
+    char* m_pPayload;
     LOKDocView* m_pDocView;
 }
 LOKDocViewCallbackData;
 
+/// Returns the GdkRectangle of a width,height,x,y string.
+static GdkRectangle lcl_payloadToRectangle(const char* pPayload)
+{
+    GdkRectangle aRet;
+    gchar** ppCoordinates;
+
+    ppCoordinates = g_strsplit(pPayload, ", ", 4);
+    if (!*ppCoordinates)
+        return aRet;
+    aRet.width = atoi(*ppCoordinates);
+    ++ppCoordinates;
+    if (!*ppCoordinates)
+        return aRet;
+    aRet.height = atoi(*ppCoordinates);
+    ++ppCoordinates;
+    if (!*ppCoordinates)
+        return aRet;
+    aRet.x = atoi(*ppCoordinates);
+    ++ppCoordinates;
+    if (!*ppCoordinates)
+        return aRet;
+    aRet.y = atoi(*ppCoordinates);
+    return aRet;
+}
+
 /// Invoked on the main thread if lok_docview_callback_worker() requests so.
 static gboolean lok_docview_callback(gpointer pData)
 {
@@ -198,12 +258,21 @@ static gboolean lok_docview_callback(gpointer pData)
     switch (pCallback->m_nType)
     {
     case LOK_CALLBACK_INVALIDATE_TILES:
-        renderDocument(pCallback->m_pDocView);
-        break;
+    {
+        if (strcmp(pCallback->m_pPayload, "EMPTY") != 0)
+        {
+            GdkRectangle aRectangle = lcl_payloadToRectangle(pCallback->m_pPayload);
+            renderDocument(pCallback->m_pDocView, &aRectangle);
+        }
+        else
+            renderDocument(pCallback->m_pDocView, NULL);
+    }
+    break;
     default:
         break;
     }
 
+    g_free(pCallback->m_pPayload);
     g_free(pCallback);
     return G_SOURCE_REMOVE;
 }
@@ -215,7 +284,7 @@ static void lok_docview_callback_worker(int nType, const char* pPayload, void* p
 
     LOKDocViewCallbackData* pCallback = g_new0(LOKDocViewCallbackData, 1);
     pCallback->m_nType = nType;
-    pCallback->m_pPayload = pPayload;
+    pCallback->m_pPayload = g_strdup(pPayload);
     pCallback->m_pDocView = pDocView;
 #if GTK_CHECK_VERSION(2,12,0)
     gdk_threads_add_idle(lok_docview_callback, pCallback);
@@ -244,7 +313,7 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
     else
     {
         pDocView->pDocument->pClass->initializeForRendering(pDocView->pDocument);
-        renderDocument( pDocView );
+        renderDocument(pDocView, NULL);
     }
 
     return TRUE;
@@ -256,7 +325,7 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZo
 
     if ( pDocView->pDocument )
     {
-        renderDocument( pDocView );
+        renderDocument(pDocView, NULL);
     }
     // TODO: maybe remember and reset positiong?
 }
@@ -279,7 +348,7 @@ SAL_DLLPUBLIC_EXPORT int lok_docview_get_part( LOKDocView* pDocView )
 SAL_DLLPUBLIC_EXPORT void lok_docview_set_part( LOKDocView* pDocView, int nPart)
 {
     pDocView->pDocument->pClass->setPart( pDocView->pDocument, nPart );
-    renderDocument( pDocView );
+    renderDocument(pDocView, NULL);
 }
 
 SAL_DLLPUBLIC_EXPORT char* lok_docview_get_part_name( LOKDocView* pDocView, int nPart )
@@ -291,7 +360,7 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_partmode( LOKDocView* pDocView,
                                                     LibreOfficeKitPartMode ePartMode )
 {
     pDocView->pDocument->pClass->setPartMode( pDocView->pDocument, ePartMode );
-    renderDocument( pDocView );
+    renderDocument(pDocView, NULL);
 }
 
 SAL_DLLPUBLIC_EXPORT void lok_docview_set_edit( LOKDocView* pDocView,
commit f43ba8db2552a1913bdd1fbbc510b70baa574ebd
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 23:21:07 2015 +0900

    android: fix invalidation rect calculation in ComposedTileLayer
    
    Change-Id: I5e0a59d6b966daea2a2033b0f52dc6983b837ca1

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index d0fe36a..e169056 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -134,9 +134,6 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
         float newZoom = getZoom(viewportMetrics);
 
         if (!currentViewport.equals(newCurrentViewPort) || currentZoom != newZoom) {
-            if (newZoom == 1.0f) {
-                Log.i(LOGTAG, "Suspisious zoom 1.0");
-            }
             currentViewport = newCurrentViewPort;
             currentZoom = newZoom;
             RectF pageRect = viewportMetrics.getPageRect();
@@ -216,10 +213,9 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
      * Invalidate tiles which intersect the input rect
      */
     public void invalidateTiles(RectF rect) {
-        RectF zoomedRect = RectUtils.inverseScale(rect, currentZoom);
-
+        RectF zoomedRect = RectUtils.scale(rect, currentZoom);
         for (SubTile tile : tiles.values()) {
-            if (RectF.intersects(rect, tile.id.getRect())) {
+            if (RectF.intersects(zoomedRect, tile.id.getRect())) {
                 LOKitShell.sendEvent(LOEventFactory.tileRerender(this, tile));
             }
         }
commit 22ef55e72ecd773b2a4a729bac9e38e3d33e86f0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 21:20:22 2015 +0900

    android: cleanup GeckoLayerClient
    
    Change-Id: If9a7c50249c9e44dce1a8e3c02a8b2f568dedfb1

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 3e70698..1006383 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -147,10 +147,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         return mView;
     }
 
-    public FloatSize getViewportSize() {
-        return mViewportMetrics.getSize();
-    }
-
     /**
      * The view calls this function to indicate that the viewport changed size. It must hold the
      * monitor while calling it.
@@ -220,7 +216,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         ImmutableViewportMetrics clampedMetrics = metrics.clamp();
 
         if (displayPort == null) {
-            displayPort = DisplayPortCalculator.calculate(metrics, getPanZoomController().getVelocityVector());
+            displayPort = DisplayPortCalculator.calculate(metrics, mPanZoomController.getVelocityVector());
         }
 
         mDisplayPort = displayPort;
@@ -280,7 +276,7 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         synchronized (this) {
             try {
                 mNewGeckoViewport = viewportMetrics;
-                updateViewport(true);
+                updateViewport();
                 mLowResLayer.invalidate();
                 mRootLayer.invalidate();
             } finally {
@@ -290,12 +286,12 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         }
     }
 
-    protected void updateViewport(boolean onlyUpdatePageSize) {
+    protected void updateViewport() {
         // save and restore the viewport size stored in java; never let the
         // JS-side viewport dimensions override the java-side ones because
         // java is the One True Source of this information, and allowing JS
         // to override can lead to race conditions where this data gets clobbered.
-        FloatSize viewportSize = getViewportSize();
+        FloatSize viewportSize = mViewportMetrics.getSize();
         mGeckoViewport = mNewGeckoViewport.setViewportSize(viewportSize.width, viewportSize.height);
 
         RectF position = mGeckoViewport.getViewport();
@@ -305,15 +301,10 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         mLowResLayer.setPosition(RectUtils.round(position));
         mLowResLayer.setResolution(mGeckoViewport.zoomFactor);
 
-        if (onlyUpdatePageSize) {
-            // Don't adjust page size when zooming unless zoom levels are
-            // approximately equal.
-            if (FloatUtils.fuzzyEquals(getViewportMetrics().zoomFactor, mGeckoViewport.zoomFactor)) {
-                setPageRect(mGeckoViewport.getPageRect(), mGeckoViewport.getCssPageRect());
-            }
-        } else {
-            setViewportMetrics(mGeckoViewport);
-            abortPanZoomAnimation();
+        // Don't adjust page size when zooming unless zoom levels are
+        // approximately equal.
+        if (FloatUtils.fuzzyEquals(getViewportMetrics().zoomFactor, mGeckoViewport.zoomFactor)) {
+            setPageRect(mGeckoViewport.getPageRect(), mGeckoViewport.getCssPageRect());
         }
     }
 
@@ -397,14 +388,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         }
     }
 
-    public void forceRender() {
-        post(new Runnable() {
-            public void run() {
-                mView.requestRender();
-            }
-        });
-    }
-
     /** Implementation of PanZoomTarget */
     public boolean post(Runnable action) {
         return mView.post(action);
@@ -446,10 +429,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         return layerPoint;
     }
 
-    public ImmutableViewportMetrics getGeckoViewportMetrics() {
-        return mGeckoViewport;
-    }
-
     public void destroy() {
         mPanZoomController.destroy();
     }
@@ -458,7 +437,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         return mContext;
     }
 
-
     public void zoomTo(RectF rect) {
         if (mPanZoomController instanceof JavaPanZoomController) {
             ((JavaPanZoomController) mPanZoomController).animatedZoomTo(rect);
@@ -469,6 +447,14 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         zoomTo(new RectF(0, 0, pageWidth, pageHeight));
     }
 
+    public void forceRender() {
+        post(new Runnable() {
+            public void run() {
+                mView.requestRender();
+            }
+        });
+    }
+
     private class AdjustRunnable implements Runnable {
         public void run() {
             mPendingViewportAdjust = false;
commit 775a22b75a41a971312bb7a4498f91521bcaec4a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 20:41:59 2015 +0900

    android: remove getDisplayMetrics as it exists in LOKitShell
    
    Change-Id: I5e7fa1b9c99707db382c555c5ffdfe601eb4622a

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 5efbc68..48c46ff 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -85,12 +85,6 @@ public class LibreOfficeMainActivity extends LOAbout {
         return super.onPrepareOptionsMenu(menu);
     }
 
-    public DisplayMetrics getDisplayMetrics() {
-        DisplayMetrics metrics = new DisplayMetrics();
-        getWindowManager().getDefaultDisplay().getMetrics(metrics);
-        return metrics;
-    }
-
     @Override
     public void onCreate(Bundle savedInstanceState) {
         Log.w(LOGTAG, "onCreate..");
commit 0ac8f1a390993f9becdbfd43b7e58c62319458fc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 20:39:58 2015 +0900

    android: move getMemoryClass to LOKitShell
    
    Change-Id: I2db92ec20c1999c0a4373fa25690680cacd79331

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 5206694..ac3e360 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -1,6 +1,8 @@
 package org.libreoffice;
 
 
+import android.app.ActivityManager;
+import android.content.Context;
 import android.os.Handler;
 import android.util.DisplayMetrics;
 import android.view.KeyEvent;
@@ -38,6 +40,11 @@ public class LOKitShell {
         });
     }
 
+    public static int getMemoryClass(Context context) {
+        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        return activityManager.getMemoryClass() * 1024 * 1024;
+    }
+
     public static DisplayMetrics getDisplayMetrics() {
         if (LibreOfficeMainActivity.mAppContext == null) {
             return null;
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index 862d2c8..d0fe36a 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -31,11 +31,6 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     protected RectF currentViewport = new RectF();
     protected float currentZoom;
 
-    private static int getMemoryClass(Context context) {
-        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
-        return activityManager.getMemoryClass() * 1024 * 1024;
-    }
-
     public ComposedTileLayer(Context context) {
         context.registerComponentCallbacks(this);
         this.tileSize = new IntSize(256, 256);
commit 31f76ad84ceb3c99af1d9db3f0a8e1f6932bbb94
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sat Jan 17 20:58:51 2015 +0900

    Leave a comment about the lesson learned
    
    from 234e45bf1d27484b72e73fe327b1e92fda1933f1
    
    Change-Id: Ic1bcab8a9662e2f302a24a6eaad2f813c12b28a8

diff --git a/include/sal/config.h b/include/sal/config.h
index c459365..e891a6b 100644
--- a/include/sal/config.h
+++ b/include/sal/config.h
@@ -86,6 +86,11 @@
 #define SAL_CONFIGFILE( name ) name "rc"
 #endif
 
+/* The following spell is for Solaris and its descendants.
+ * See the "Solaris" section of
+ * <http://sourceforge.net/p/predef/wiki/OperatingSystems/>, and
+ * <http://stackoverflow.com/questions/16618604/solaris-and-preprocessor-macros>.
+ */
 #ifdef sun
 #undef sun
 #define sun sun
commit 8d279e8081162927dfb58c230433230101a35f4c
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sat Jan 17 20:28:50 2015 +0900

    Drop unused inline functions
    
    Change-Id: Iba54fb717b4337ffe255d849a1c073f7baf7c921

diff --git a/starmath/inc/symbol.hxx b/starmath/inc/symbol.hxx
index dc1f0bb..2b6df4f 100644
--- a/starmath/inc/symbol.hxx
+++ b/starmath/inc/symbol.hxx
@@ -137,7 +137,6 @@ public:
     std::set< OUString >      GetSymbolSetNames() const;
     const SymbolPtrVec_t    GetSymbolSet(  const OUString& rSymbolSetName );
 
-    sal_uInt16                  GetSymbolCount() const  { return static_cast< sal_uInt16 >(m_aSymbols.size()); }
     const SymbolPtrVec_t    GetSymbols() const;
     bool                    AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false );
     void                    RemoveSymbol( const OUString & rSymbolName );
diff --git a/starmath/inc/types.hxx b/starmath/inc/types.hxx
index 7ab5b07..aeb1dcf 100644
--- a/starmath/inc/types.hxx
+++ b/starmath/inc/types.hxx
@@ -31,9 +31,6 @@ enum SmPrintSize { PRINT_SIZE_NORMAL, PRINT_SIZE_SCALED, PRINT_SIZE_ZOOMED };
 
 inline bool IsInPrivateUseArea( sal_Unicode cChar ) { return 0xE000 <= cChar  &&  cChar <= 0xF8FF; }
 
-// Greek char range as seen in svx/.../charmap.cxx RID_SUBSETSTR_BASIC_GREEK
-inline bool IsGreekChar( sal_Unicode cChar ) { return 0x0370 <= cChar  &&  cChar <= 0x03FF; }
-
 sal_Unicode ConvertMathToMathML( sal_Unicode cChar );
 
 
commit 5c99a17037b807f7728ed8c677559c3032b9500c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Jan 17 02:38:37 2015 +0100

    forgot the Win and OSX backend
    
    Change-Id: I1aa12c89cbddd83febac733f68904cda6b91f0a9

diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index f89917b..a531dbd 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -271,7 +271,7 @@ void SalYieldMutex::release()
     {
         if ( mnCount == 1 )
         {
-            OpenGLContext::resetAllContexts();
+            // TODO: add OpenGLContext::clearCurrent with vcl OpenGL support
             mnThreadId = 0;
         }
         mnCount--;
diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx
index 1154ac1..9610034 100644
--- a/vcl/win/source/app/salinst.cxx
+++ b/vcl/win/source/app/salinst.cxx
@@ -149,7 +149,7 @@ void SalYieldMutex::release()
         {
             if ( mnCount == 1 )
             {
-                OpenGLContext::resetAllContexts();
+                OpenGLContext::clearCurrent();
 
                 // If we don't call these message, the Output from the
                 // Java clients doesn't come in the right order
commit d20092259c7ea63885a539f911788715f8147ee9
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Jan 17 02:29:20 2015 +0100

    no need to do that for all contexts
    
    This fixes a crash as we would need to make each context current before
    calling ReleaseFramebuffers.
    
    However this is totally unnecessary as only the current context can have
    bound framebuffers.
    
    Change-Id: I8b1496bb890982742b3d2ebf60fdce47db642d70

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 67570c1..5ef30cd 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -200,9 +200,6 @@ public:
 
     bool isCurrent();
     static void clearCurrent();
-    /// reset all contexts dis-associating them with their underlying
-    /// resources before a potential thread switch.
-    static void resetAllContexts();
 
     /// make this GL context current - so it is implicit in subsequent GL calls
     void makeCurrent();
diff --git a/vcl/generic/app/geninst.cxx b/vcl/generic/app/geninst.cxx
index 5ac4936..0310435 100644
--- a/vcl/generic/app/geninst.cxx
+++ b/vcl/generic/app/geninst.cxx
@@ -55,7 +55,7 @@ void SalYieldMutex::release()
     {
         if ( mnCount == 1 )
         {
-            OpenGLContext::resetAllContexts();
+            OpenGLContext::clearCurrent();
             mnThreadId = 0;
         }
         mnCount--;
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 9d681ff..4317d56 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1292,22 +1292,6 @@ void OpenGLContext::clearCurrent()
         pCurrentCtx->ReleaseFramebuffers();
 }
 
-void OpenGLContext::resetAllContexts()
-{
-    ImplSVData* pSVData = ImplGetSVData();
-
-    // release all framebuffers from the old context so we can re-attach the
-    // texture in the new context
-    for (OpenGLContext* l = pSVData->maGDIData.mpLastContext; l;
-         l = l->mpPrevContext)
-    {
-        l->ReleaseFramebuffers();
-        if (l->isCurrent())
-            l->resetCurrent();
-        assert (!l->mpNextContext || l->mpNextContext->mpPrevContext == l);
-    }
-}
-
 void OpenGLContext::makeCurrent()
 {
     ImplSVData* pSVData = ImplGetSVData();
commit 5f6bdce0c0ac687f418821ce328f2987bf340cda
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jan 16 23:56:09 2015 +0100

    rhbz#1136013: svx: try to make the ExternalToolEdit not crash all the time
    
    This thing was starting a timer that re-starts itself forever, and when
    the file it was watching changed, it would just assume the drawing
    objects were still there (and the document, for that matter...)
    
    Change-Id: I35f187f0828097a05618dc1733dce819fc6bffc6

diff --git a/include/svx/extedit.hxx b/include/svx/extedit.hxx
index dc0c489..65e178d 100644
--- a/include/svx/extedit.hxx
+++ b/include/svx/extedit.hxx
@@ -10,30 +10,51 @@
 #ifndef INCLUDED_SVX_EXTEDIT_HXX
 #define INCLUDED_SVX_EXTEDIT_HXX
 
-#include <svtools/grfmgr.hxx>
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <vcl/graph.hxx>
-#include <vcl/timer.hxx>
 #include <svx/svxdllapi.h>
+#include <svl/lstner.hxx>
+#include <rtl/ustring.hxx>
+#include <memory>
+
+class Graphic;
+class GraphicObject;
+class FileChangedChecker;
 
 class SVX_DLLPUBLIC ExternalToolEdit
 {
-public:
-    GraphicObject* m_pGraphicObject;
+protected:
     OUString m_aFileName;
 
+    ::std::unique_ptr<FileChangedChecker> m_pChecker;
+
+public:
+
     ExternalToolEdit();
     virtual ~ExternalToolEdit();
 
     virtual void Update( Graphic& aGraphic ) = 0;
-    void Edit( GraphicObject *pGraphic );
+    void Edit(GraphicObject const*const pGraphic);
 
-    DECL_LINK( StartListeningEvent, void *pEvent );
+    void StartListeningEvent();
 
-    static void threadWorker( void *pThreadData );
     static void HandleCloseEvent( ExternalToolEdit* pData );
 };
 
+class FmFormView;
+class SdrObject;
+
+class SVX_DLLPUBLIC SdrExternalToolEdit
+    : public ExternalToolEdit
+    , public SfxListener
+{
+private:
+    FmFormView * m_pView;
+    SdrObject *  m_pObj;
+
+    SAL_DLLPRIVATE virtual void Update(Graphic&) SAL_OVERRIDE;
+    SAL_DLLPRIVATE virtual void Notify(SfxBroadcaster&, const SfxHint&) SAL_OVERRIDE;
+
+public:
+    SdrExternalToolEdit(FmFormView * pView, SdrObject * pObj);
+};
 
 #endif
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
index 5284efb..b98f92b 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -38,32 +38,6 @@
 #define ScGraphicShell
 #include "scslots.hxx"
 
-class ScExternalToolEdit : public ExternalToolEdit
-{
-    FmFormView* m_pView;
-    SdrObject*  m_pObj;
-
-public:
-    ScExternalToolEdit ( FmFormView* pView, SdrObject* pObj ) :
-        m_pView   (pView),
-        m_pObj (pObj)
-    {}
-
-    virtual void Update( Graphic& aGraphic ) SAL_OVERRIDE
-    {
-        SdrPageView* pPageView = m_pView->GetSdrPageView();
-        if( pPageView )
-        {
-            SdrGrafObj* pNewObj = static_cast<SdrGrafObj*>(m_pObj->Clone());
-            OUString    aStr = m_pView->GetDescriptionOfMarkedObjects() + " External Edit";
-            m_pView->BegUndo( aStr );
-            pNewObj->SetGraphicObject( aGraphic );
-            m_pView->ReplaceObjectAtView( m_pObj, *pPageView, pNewObj );
-            m_pView->EndUndo();
-        }
-    }
-};
-
 SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell)
 
 void ScGraphicShell::InitInterface_Impl()
@@ -188,8 +162,9 @@ void ScGraphicShell::ExecuteExternalEdit( SfxRequest& )
         if( pObj && pObj->ISA( SdrGrafObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP )
         {
             GraphicObject aGraphicObject( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() );
-            ScExternalToolEdit* aExternalToolEdit = new ScExternalToolEdit( pView, pObj );
-            aExternalToolEdit->Edit( &aGraphicObject );
+            m_ExternalEdits.push_back( std::unique_ptr<SdrExternalToolEdit>(
+                        new SdrExternalToolEdit(pView, pObj)));
+            m_ExternalEdits.back()->Edit( &aGraphicObject );
         }
     }
 
diff --git a/sc/source/ui/inc/graphsh.hxx b/sc/source/ui/inc/graphsh.hxx
index 866d527..59bd4a4 100644
--- a/sc/source/ui/inc/graphsh.hxx
+++ b/sc/source/ui/inc/graphsh.hxx
@@ -25,6 +25,7 @@
 #include <sfx2/module.hxx>
 #include <svx/svdmark.hxx>
 
+class SdrExternalToolEdit;
 class ScViewData;
 
 #include "drawsh.hxx"
@@ -36,6 +37,8 @@ public:
     SFX_DECL_INTERFACE(SCID_GRAPHIC_SHELL)
 
 private:
+    std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits;
+
     /// SfxInterface initializer.
     static void InitInterface_Impl();
 
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 4110907..8a92f42 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -33,6 +33,7 @@
 
 class Outliner;
 class SdPage;
+class SdrExternalToolEdit;
 class DrawDocShell;
 class TabBar;
 class SdrObject;
@@ -507,6 +508,8 @@ private:
 
     ::std::unique_ptr< AnnotationManager > mpAnnotationManager;
     ::std::unique_ptr< ViewOverlayManager > mpViewOverlayManager;
+
+    std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits;
 };
 
 } // end of namespace sd
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 5b4517e..f30b974 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -185,33 +185,6 @@ using namespace ::com::sun::star::uno;
 
 namespace sd {
 
-class SdExternalToolEdit : public ExternalToolEdit
-{
-    FmFormView* m_pView;
-    SdrObject*  m_pObj;
-
-public:
-    SdExternalToolEdit ( FmFormView* pView, SdrObject* pObj ) :
-        m_pView   (pView),
-        m_pObj (pObj)
-    {}
-
-    virtual void Update( Graphic& aGraphic ) SAL_OVERRIDE
-    {
-        SdrPageView* pPageView = m_pView->GetSdrPageView();
-        if( pPageView )
-        {
-            SdrGrafObj* pNewObj = static_cast<SdrGrafObj*>( m_pObj->Clone() );
-            OUString    aStr = m_pView->GetDescriptionOfMarkedObjects();
-            aStr += " External Edit";
-            m_pView->BegUndo( aStr );
-            pNewObj->SetGraphicObject( aGraphic );
-            m_pView->ReplaceObjectAtView( m_pObj, *pPageView, pNewObj );
-            m_pView->EndUndo();
-        }
-    }
-};
-
 /**
  * SfxRequests for temporary actions
  */
@@ -999,8 +972,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                 if( pObj && pObj->ISA( SdrGrafObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP )
                 {
                     GraphicObject aGraphicObject( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() );
-                    SdExternalToolEdit* aExternalToolEdit = new SdExternalToolEdit( mpDrawView, pObj );
-                    aExternalToolEdit->Edit( &aGraphicObject );
+                    m_ExternalEdits.push_back(
+                        std::unique_ptr<SdrExternalToolEdit>(
+                            new SdrExternalToolEdit(mpDrawView, pObj)));
+                    m_ExternalEdits.back()->Edit( &aGraphicObject );
                 }
             }
             Cancel();
diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx
index eb4a084..0ab56de 100644
--- a/sd/source/ui/view/drviewsa.cxx
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -43,6 +43,7 @@
 #include <svx/fmshell.hxx>
 #include <svtools/cliplistener.hxx>
 #include <svx/float3d.hxx>
+#include <svx/extedit.hxx>
 #include <svx/sidebar/SelectionAnalyzer.hxx>
 #include "helpids.h"
 
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
index 83cbbec..7cc8b5f 100644
--- a/svx/source/core/extedit.cxx
+++ b/svx/source/core/extedit.cxx
@@ -7,15 +7,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <svx/extedit.hxx>
+
 #include <vcl/svapp.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/cvtgrf.hxx>
 #include <vcl/graphicfilter.hxx>
 #include <svx/xoutbmp.hxx>
-#include <svx/extedit.hxx>
 #include <svx/graphichelper.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/fmview.hxx>
+#include <svtools/grfmgr.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/bindings.hxx>
+#include <salhelper/thread.hxx>
 #include <osl/file.hxx>
 #include <osl/thread.hxx>
 #include <osl/process.h>
@@ -33,7 +39,6 @@ using namespace css::uno;
 using namespace css::system;
 
 ExternalToolEdit::ExternalToolEdit()
-    : m_pGraphicObject(NULL)
 {
 }
 
@@ -56,35 +61,40 @@ void ExternalToolEdit::HandleCloseEvent(ExternalToolEdit* pData)
     }
 }
 
-IMPL_LINK (ExternalToolEdit, StartListeningEvent, void*, pEvent)
+void ExternalToolEdit::StartListeningEvent()
 {
     //Start an event listener implemented via VCL timeout
-    ExternalToolEdit* pData = ( ExternalToolEdit* )pEvent;
-
-    new FileChangedChecker(pData->m_aFileName, ::boost::bind(&HandleCloseEvent, pData));
-
-    return 0;
+    assert(!m_pChecker.get());
+    m_pChecker.reset(new FileChangedChecker(
+            m_aFileName, ::boost::bind(&HandleCloseEvent, this)));
 }
 
-void ExternalToolEdit::threadWorker(void* pThreadData)
+// self-destructing thread to make shell execute async
+class ExternalToolEditThread
+    : public ::salhelper::Thread
 {
-    osl_setThreadName("ExternalToolEdit");
+private:
+    OUString const m_aFileName;
 
-    ExternalToolEdit* pData = (ExternalToolEdit*) pThreadData;
+    virtual void execute() SAL_OVERRIDE;
 
-    // Make an asynchronous call to listen to the event of temporary image file
-    // getting changed
-    Application::PostUserEvent( LINK( NULL, ExternalToolEdit, StartListeningEvent ), pThreadData);
+public:
+    ExternalToolEditThread(OUString const& rFileName)
+        : ::salhelper::Thread("ExternalToolEdit")
+        , m_aFileName(rFileName)
+    {}
+};
 
+void ExternalToolEditThread::execute()
+{
     Reference<XSystemShellExecute> xSystemShellExecute(
         SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
-    xSystemShellExecute->execute( pData->m_aFileName, OUString(), SystemShellExecuteFlags::URIS_ONLY );
+    xSystemShellExecute->execute(m_aFileName, OUString(), SystemShellExecuteFlags::URIS_ONLY);
 }
 
-void ExternalToolEdit::Edit( GraphicObject* pGraphicObject )
+void ExternalToolEdit::Edit(GraphicObject const*const pGraphicObject)
 {
     //Get the graphic from the GraphicObject
-    m_pGraphicObject = pGraphicObject;
     const Graphic aGraphic = pGraphicObject->GetGraphic();
 
     //get the Preferred File Extension for this graphic
@@ -117,8 +127,57 @@ void ExternalToolEdit::Edit( GraphicObject* pGraphicObject )
 
     //Create a thread
 
-    // Create the data that is needed by the thread later
-    osl_createThread(ExternalToolEdit::threadWorker, this);
+    rtl::Reference<ExternalToolEditThread> const pThread(
+            new ExternalToolEditThread(m_aFileName));
+    pThread->launch();
+
+    StartListeningEvent();
+}
+
+SdrExternalToolEdit::SdrExternalToolEdit(
+        FmFormView *const pView, SdrObject *const pObj)
+    : m_pView(pView)
+    , m_pObj(pObj)
+{
+    assert(m_pObj && m_pView);
+    StartListening(*m_pObj->GetModel());
+}
+
+
+void SdrExternalToolEdit::Notify(SfxBroadcaster & rBC, SfxHint const& rHint)
+{
+    SdrHint const*const pSdrHint(dynamic_cast<SdrHint const*>(&rHint));
+    if (pSdrHint
+        && (HINT_MODELCLEARED == pSdrHint->GetKind()
+            || (pSdrHint->GetObject() == m_pObj
+                && HINT_OBJREMOVED == pSdrHint->GetKind())))
+    {
+        m_pView = 0;
+        m_pObj = 0;
+        m_pChecker.reset(); // avoid modifying deleted object
+        EndListening(rBC);
+    }
+}
+
+void SdrExternalToolEdit::Update(Graphic & rGraphic)
+{
+    assert(m_pObj && m_pView); // timer should be deleted by Notify() too
+    SdrPageView *const pPageView = m_pView->GetSdrPageView();
+    if (pPageView)
+    {
+        SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->Clone()));
+        assert(pNewObj);
+        OUString const description =
+            m_pView->GetDescriptionOfMarkedObjects() + " External Edit";
+        m_pView->BegUndo(description);
+        pNewObj->SetGraphicObject(rGraphic);
+        // set to new object before ReplaceObjectAtView() so that Notify() will
+        // not delete the running timer and crash
+        SdrObject *const pOldObj = m_pObj;
+        m_pObj = pNewObj;
+        m_pView->ReplaceObjectAtView(pOldObj, *pPageView, pNewObj);
+        m_pView->EndUndo();
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/grfsh.hxx b/sw/source/uibase/inc/grfsh.hxx
index 75c1ab0..5a74c46 100644
--- a/sw/source/uibase/inc/grfsh.hxx
+++ b/sw/source/uibase/inc/grfsh.hxx
@@ -23,6 +23,9 @@
 
 class SwGrfShell: public SwBaseShell
 {
+    class SwExternalToolEdit;
+    std::vector<std::unique_ptr<SwExternalToolEdit>> m_ExternalEdits;
+
 public:
     SFX_DECL_INTERFACE(SW_GRFSHELL)
 
@@ -39,6 +42,7 @@ public:
     void GetAttrStateForRotation(SfxItemSet& rRequest);
 
     SwGrfShell(SwView &rView);
+    virtual ~SwGrfShell();
 };
 
 #endif
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index b6714ce..b261adc 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -75,27 +75,37 @@
 #include <sfx2/msg.hxx>
 #include "swslots.hxx"
 #include "swabstdlg.hxx"
+#include <unocrsr.hxx>
 #include <boost/scoped_ptr.hpp>
 
 #define TOOLBOX_NAME "colorbar"
 
-namespace
+class SwGrfShell::SwExternalToolEdit
+    : public ExternalToolEdit
 {
-    class SwExternalToolEdit : public ExternalToolEdit
+private:
+    SwWrtShell *const m_pShell;
+    ::std::unique_ptr<SwUnoCrsr> const m_pCursor;
+
+public:
+    SwExternalToolEdit(SwWrtShell *const pShell)
+        : m_pShell(pShell)
+        , m_pCursor( // need only Point, must point to SwGrfNode
+            pShell->GetDoc()->CreateUnoCrsr(
+                *pShell->GetCurrentShellCursor().GetPoint()))
     {
-        SwWrtShell*  m_pShell;
-
-    public:
-        SwExternalToolEdit ( SwWrtShell* pShell ) :
-            m_pShell  (pShell)
-        {}
+    }
 
-        virtual void Update( Graphic& aGraphic ) SAL_OVERRIDE
-        {
-            m_pShell->ReRead(OUString(), OUString(), (const Graphic*) &aGraphic);
-        }
-    };
-}
+    virtual void Update(Graphic & rGraphic) SAL_OVERRIDE
+    {
+        DBG_TESTSOLARMUTEX();
+        m_pShell->Push();
+        m_pShell->GetCurrentShellCursor().DeleteMark();
+        *m_pShell->GetCurrentShellCursor().GetPoint() = *m_pCursor->GetPoint();
+        m_pShell->ReRead(OUString(), OUString(), &rGraphic);
+        m_pShell->Pop();
+    }
+};
 
 SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell)
 
@@ -180,11 +190,12 @@ void SwGrfShell::Execute(SfxRequest &rReq)
         {
             // When the graphic is selected to be opened via some external tool
             // for advanced editing
-            GraphicObject *pGraphicObject = (GraphicObject *) rSh.GetGraphicObj();
+            GraphicObject const*const pGraphicObject(rSh.GetGraphicObj());
             if(0 != pGraphicObject)
             {
-                SwExternalToolEdit* externalToolEdit = new SwExternalToolEdit( &rSh );
-                externalToolEdit->Edit ( pGraphicObject );
+                m_ExternalEdits.push_back(std::unique_ptr<SwExternalToolEdit>(
+                            new SwExternalToolEdit(&rSh)));
+                m_ExternalEdits.back()->Edit(pGraphicObject);
             }
         }
         break;
@@ -905,6 +916,10 @@ void SwGrfShell::GetAttrStateForRotation(SfxItemSet &rSet)
     SetGetStateSet( 0 );
 }
 
+SwGrfShell::~SwGrfShell()
+{
+}
+
 SwGrfShell::SwGrfShell(SwView &_rView) :
     SwBaseShell(_rView)
 {
commit 3b70717f02d5f2f255de078bd277e8662884bfb0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jan 16 19:00:04 2015 -0500

    Use 1/100mm map mode for rendering edit text objects.
    
    Change-Id: I0c82088342085c1b7d9aa3c6009684bc58a9fd21

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 5e364c2..07a5d62 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -945,7 +945,9 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 
     aOutData.DrawStrings(true);
 
-    // TODO : Edit texts don't get rendered at all.  Fix this.
+    // Edit texts need 1/100mm map mode to be rendered correctly.
+    aNewMapMode.SetMapUnit(MAP_100TH_MM);
+    rDevice.SetMapMode(aNewMapMode);
     aOutData.DrawEdit(true);
 
     rDevice.SetMapMode(aOldMapMode);
commit 88562ee6e352b5446bb55e906e8f1c2f34035a49
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jan 16 17:45:52 2015 -0500

    Get texts to scale correctly with zoom.
    
    We need to set scaling factors to device's map mode *only* for the texts.
    Calc handles scaling for all the rest.  Interesting how it works.
    
    Change-Id: Ia6aa122961ea5ddc2e31eacb28392f3e355a5ebf

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index a8abe26..5e364c2 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -935,10 +935,20 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     aOutData.DrawShadow();
     aOutData.DrawFrame();
 
-    // TODO : Scaling of strings is incorrect.  Find out why.
+    // Set scaling to map mode only for text rendering, to get texts to scale
+    // correctly.
+    MapMode aOldMapMode = rDevice.GetMapMode();
+    MapMode aNewMapMode = aOldMapMode;
+    aNewMapMode.SetScaleX(aFracX);
+    aNewMapMode.SetScaleY(aFracY);
+    rDevice.SetMapMode(aNewMapMode);
+
     aOutData.DrawStrings(true);
+
     // TODO : Edit texts don't get rendered at all.  Fix this.
     aOutData.DrawEdit(true);
+
+    rDevice.SetMapMode(aOldMapMode);
 }
 
 void ScGridWindow::CheckNeedsRepaint()
commit 7fb400c886f59fb75274213af4374798b44f04dd
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jan 16 16:58:49 2015 -0500

    Multiply tile position by the zoom level.
    
    With this, the tiles get rendered correctly at varying zoom levels.
    
    Change-Id: Id5ca18e363dfdb143af1685be96af2f3c3514ea9

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index b906bd4..a8abe26 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -898,8 +898,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     pViewData->SetZoom(aFracX, aFracY, true);
     pViewData->RefreshZoom();
 
-    double fTilePosXPixel = static_cast<double>(nTilePosX) * PIXEL_PER_TWIPS;
-    double fTilePosYPixel = static_cast<double>(nTilePosY) * PIXEL_PER_TWIPS;
+    double fTilePosXPixel = static_cast<double>(nTilePosX) * PIXEL_PER_TWIPS * static_cast<double>(aFracX);
+    double fTilePosYPixel = static_cast<double>(nTilePosY) * PIXEL_PER_TWIPS * static_cast<double>(aFracY);
 
     SCTAB nTab = pViewData->GetTabNo();
     ScDocument* pDoc = pViewData->GetDocument();
commit 9af8e14e67d354bb7736271a76a3dd8b6da78fd9
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jan 16 22:40:36 2015 +0100

    don't access empty range list, could be rhbz#1180312
    
    ScRangeList::DeleteArea() may remove an entire range, if it was the
    last range a subsequent call to ScConditionalFormat::DeleteArea() would
    attempt to access an invalid first element.
    
    Change-Id: I8d68c27963dc8561d61a94980093c271bd3aaffb

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index d091398..5b1bbef 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -2063,6 +2063,9 @@ void ScConditionalFormat::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt )
 
 void ScConditionalFormat::DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
 {
+    if (maRanges.empty())
+        return;
+
     SCTAB nTab = maRanges[0]->aStart.Tab();
     maRanges.DeleteArea( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
 }
commit 15e802fabbfff047c1a8d768dea8fc04a2f82a49
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jan 16 21:54:24 2015 +0100

    replace decrementing loop with -=
    
    This could save a million iterations ...
    
    Change-Id: I44fb228b951580bbeb5df5f6ec7be933077776ff

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index b997948..a162ca7 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -1476,8 +1476,9 @@ void ScColumn::EndListeningGroup( sc::EndListeningContext& rCxt, SCROW nRow )
 
     // Move back to the top cell.
     SCROW nTopDelta = (*pp)->aPos.Row() - xGroup->mpTopCell->aPos.Row();
-    for (SCROW i = 0; i < nTopDelta; ++i)
-        --pp;
+    assert(nTopDelta >= 0);
+    if (nTopDelta > 0)
+        pp -= nTopDelta;
 
     // Set the needs listening flag to all cells in the group.
     assert(*pp == xGroup->mpTopCell);
@@ -1505,8 +1506,9 @@ void ScColumn::SetNeedsListeningGroup( SCROW nRow )
 
     // Move back to the top cell.
     SCROW nTopDelta = (*pp)->aPos.Row() - xGroup->mpTopCell->aPos.Row();
-    for (SCROW i = 0; i < nTopDelta; ++i)
-        --pp;
+    assert(nTopDelta >= 0);
+    if (nTopDelta > 0)
+        pp -= nTopDelta;
 
     // Set the needs listening flag to all cells in the group.
     assert(*pp == xGroup->mpTopCell);
commit 4bd05b8abc801714e2bac1a9b239fa625de1178c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jan 16 15:36:29 2015 -0500

    Correctly offset based on tile position.
    
    This works well at 100% zoom, but the offsets are still not correct
    at zoom levels other than 100%.
    
    Change-Id: I301362b00ca916410b69f39aa58ed871ce177d88

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 366eb28..b906bd4 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -874,7 +874,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
 
 void ScGridWindow::PaintTile( VirtualDevice& rDevice,
                               int nOutputWidth, int nOutputHeight,
-                              int /*nTilePosX*/, int /*nTilePosY*/,
+                              int nTilePosX, int nTilePosY,
                               long nTileWidth, long nTileHeight )
 {
     // Output size is in pixels while tile position and size are in logical units (twips).
@@ -898,7 +898,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     pViewData->SetZoom(aFracX, aFracY, true);
     pViewData->RefreshZoom();
 
-    rDevice.SetOutputSizePixel(Size(nOutputWidth, nOutputHeight));
+    double fTilePosXPixel = static_cast<double>(nTilePosX) * PIXEL_PER_TWIPS;
+    double fTilePosYPixel = static_cast<double>(nTilePosY) * PIXEL_PER_TWIPS;
 
     SCTAB nTab = pViewData->GetTabNo();
     ScDocument* pDoc = pViewData->GetDocument();
@@ -914,7 +915,7 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     pDoc->FillInfo(aTabInfo, nCol1, nRow1, nCol2, nRow2, nTab, fPPTX, fPPTY, false, false, NULL);
 
     ScOutputData aOutData(
-        &rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, 0, 0, nCol1, nRow1, nCol2, nRow2, fPPTX, fPPTY);
+        &rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, -fTilePosXPixel, -fTilePosYPixel, nCol1, nRow1, nCol2, nRow2, fPPTX, fPPTY);
 
     const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
     Color aGridColor = rColorCfg.GetColorValue(svtools::CALCGRID, false).nColor;
commit 07703967551da769faa896bc89d3dca94cbc3b5b
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Jan 16 18:10:59 2015 +0000

    gtktiledviewer: improve table attach properties.
    
    Change-Id: I344efb9ea71d5eccdfb6255526db912622d115df

diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index d9be2df..b0c1c64 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -172,7 +172,10 @@ void renderDocument( LOKDocView* pDocView )
             pDocView->pCanvas[nRow * nColumns + nColumn] = gtk_image_new();
             gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas[nRow * nColumns + nColumn] ), pPixBuf );
             g_object_unref(G_OBJECT(pPixBuf));
-            gtk_table_attach_defaults(GTK_TABLE(pDocView->pTable), pDocView->pCanvas[nRow * nColumns + nColumn], nColumn, nColumn + 1, nRow, nRow + 1);
+            gtk_table_attach(GTK_TABLE(pDocView->pTable),
+                             pDocView->pCanvas[nRow * nColumns + nColumn],
+                             nColumn, nColumn + 1, nRow, nRow + 1,
+                             GTK_SHRINK, GTK_SHRINK, 0, 0);
             gtk_widget_show(pDocView->pCanvas[nRow * nColumns + nColumn]);
         }
     }
commit 550b6bf613494c30761629282fa622cfba871278
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jan 16 17:30:32 2015 +0100

    rtl_arena_alloc must never obey AMode_SYSTEM
    
    ...as e.g. the read+write+exec arena used in
    bridges/source/cpp_uno/shared/vtablefactory.cxx has specific requirements on
    obtained memory.  This broke recent 8b9968a26265facaf5e761485d750ce9cedab3ab
    "fdo#72755: Only use double mmap as fallback" for e.g. --enable-ooenv (which
    sets G_SLICE).  This is a partial revert of
    ce906b8096081dee15dc8cc96e570d5b0b587955 "skip tricky allocators on
    G_SLICE=always-malloc."
    
    Change-Id: I5a5fb7c3c920a7856381e6c55638137c625b5111

diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index 9f3b2d2..c733ecd 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -28,8 +28,6 @@
 #include <string.h>
 #include <stdio.h>
 
-extern AllocMode alloc_mode;
-
 /* ================================================================= *
  *
  * arena internals.
@@ -950,9 +948,6 @@ SAL_CALL rtl_arena_alloc (
     {
         sal_Size size;
 
-        if (alloc_mode == AMode_SYSTEM)
-            return rtl_allocateMemory(*pSize);
-
         size = RTL_MEMORY_ALIGN((*pSize), arena->m_quantum);
         if (size > arena->m_qcache_max)
         {
@@ -1022,12 +1017,6 @@ SAL_CALL rtl_arena_free (
 {
     if (arena != 0)
     {
-        if (alloc_mode == AMode_SYSTEM)
-        {
-            rtl_freeMemory(addr);
-            return;
-        }
-
         size = RTL_MEMORY_ALIGN(size, arena->m_quantum);
         if (size > arena->m_qcache_max)
         {
commit e60b589952985edff12b1a28392ce6fa0ca8d9be
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Jan 16 17:08:07 2015 +0100

    fdo#88475 BrowseBox/grid: reposition data cursor to current row after paint
    
    Change-Id: I0deee2c3cfdb111b178c4254d7b0544c4ce5c966

diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index b64b7c4..70486e9 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -1032,6 +1032,8 @@ void BrowseBox::ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, bool
         }
     }
 
+    OSL_ENSURE(SeekRow(nCurRow), "BrowseBox::ImplPaintData could not seek back to current row after paint");
+
     if (aPos.Y() > aOverallAreaBRPos.Y() + 1)
         aPos.Y() = aOverallAreaBRPos.Y() + 1;
         // needed for some of the following drawing
commit 556f967523067d65dfee471305aae612760e73d6
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri Jan 16 17:08:32 2015 +0200

    Add SAL_INFO messages for OpenCL buffers created
    
    Change-Id: Ib226d7ec13bc64ee6d32fab3c3f6cecc4eb8b151

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index c0540d9..0bb4ad6 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -170,6 +170,7 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program )
             pHostBuffer, &err);
         if (CL_SUCCESS != err)
             throw OpenCLError(err, __FILE__, __LINE__);
+        SAL_INFO("sc.opencl", "Created buffer " << mpClmem << " size " << szHostBuffer << " using host buffer " << pHostBuffer);
     }
     else
     {
@@ -181,6 +182,8 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program )
             szHostBuffer, NULL, &err);
         if (CL_SUCCESS != err)
             throw OpenCLError(err, __FILE__, __LINE__);
+        SAL_INFO("sc.opencl", "Created buffer " << mpClmem << " size " << szHostBuffer);
+
         double* pNanBuffer = (double*)clEnqueueMapBuffer(
             kEnv.mpkCmdQueue, mpClmem, CL_TRUE, CL_MAP_WRITE, 0,
             szHostBuffer, 0, NULL, NULL, &err);
@@ -766,6 +769,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro
             szHostBuffer, NULL, &err);
         if (CL_SUCCESS != err)
             throw OpenCLError(err, __FILE__, __LINE__);
+        SAL_INFO("sc.opencl", "Created buffer " << mpClmem << " size " << szHostBuffer);
 
         pHashBuffer = (cl_uint*)clEnqueueMapBuffer(
             kEnv.mpkCmdQueue, mpClmem, CL_TRUE, CL_MAP_WRITE, 0,
@@ -796,6 +800,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro
             szHostBuffer, NULL, &err);
         if (CL_SUCCESS != err)
             throw OpenCLError(err, __FILE__, __LINE__);
+        SAL_INFO("sc.opencl", "Created buffer " << mpClmem << " size " << szHostBuffer);
 
         pHashBuffer = (cl_uint*)clEnqueueMapBuffer(
             kEnv.mpkCmdQueue, mpClmem, CL_TRUE, CL_MAP_WRITE, 0,
@@ -1439,11 +1444,15 @@ public:
             (cl_mem_flags)CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
             szHostBuffer,
             pHostBuffer, &err);
+        SAL_INFO("sc.opencl", "Created buffer " << Base::mpClmem << " size " << nInput << "*" << sizeof(double) << "=" << szHostBuffer << " using host buffer " << pHostBuffer);
+
         mpClmem2 = clCreateBuffer(kEnv.mpkContext,
             CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
             sizeof(double) * w, NULL, NULL);
         if (CL_SUCCESS != err)
             throw OpenCLError(err, __FILE__, __LINE__);
+        SAL_INFO("sc.opencl", "Created buffer " << mpClmem2 << " size " << sizeof(double) << "*" << w << "=" << (sizeof(double)*w));
+
         // reproduce the reduction function name
         std::string kernelName;
         if (!dynamic_cast<OpAverage*>(mpCodeGen.get()))
@@ -1564,6 +1573,7 @@ public:
                 w * sizeof(double) * 2, pAllBuffer.get(), &err);
             if (CL_SUCCESS != err)
                 throw OpenCLError(err, __FILE__, __LINE__);
+            SAL_INFO("sc.opencl", "Created buffer " << mpClmem2 << " size " << w << "*" << sizeof(double) << "=" << (w*sizeof(double)) << " copying host buffer " << pAllBuffer.get());
         }
         // set kernel arg
         SAL_INFO("sc.opencl", "Kernel " << k << " arg " << argno << ": cl_mem: " << mpClmem2);
@@ -2184,6 +2194,7 @@ public:
                     sizeof(double) * nVectorWidth, NULL, &err);
                 if (CL_SUCCESS != err)
                     throw OpenCLError(err, __FILE__, __LINE__);
+                SAL_INFO("sc.opencl", "Created buffer " << pClmem2 << " size " << sizeof(double) << "*" << nVectorWidth << "=" << (sizeof(double)*nVectorWidth));
 
                 std::string kernelName = "GeoMean_reduction";
                 cl_kernel redKernel = clCreateKernel(pProgram, kernelName.c_str(), &err);
@@ -2254,6 +2265,7 @@ public:
                     sizeof(double) * nVectorWidth, NULL, &err);
                 if (CL_SUCCESS != err)
                     throw OpenCLError(err, __FILE__, __LINE__);
+                SAL_INFO("sc.opencl", "Created buffer " << mpClmem2 << " size " << sizeof(double) << "*" << nVectorWidth << "=" << (sizeof(double)*nVectorWidth));
 
                 std::string kernelName = mvSubArguments[0]->GetName() + "_SumIfs_reduction";
                 cl_kernel redKernel = clCreateKernel(pProgram, kernelName.c_str(), &err);
@@ -3778,6 +3790,8 @@ void DynamicKernel::Launch( size_t nr )
         nr * sizeof(double), NULL, &err);
     if (CL_SUCCESS != err)
         throw OpenCLError(err, __FILE__, __LINE__);
+    SAL_INFO("sc.opencl", "Created buffer " << mpResClmem << " size " << nr << "*" << sizeof(double) << "=" << (nr*sizeof(double)));
+
     SAL_INFO("sc.opencl", "Kernel " << mpKernel << " arg " << 0 << ": cl_mem: " << mpResClmem);
     err = clSetKernelArg(mpKernel, 0, sizeof(cl_mem), (void*)&mpResClmem);
     if (CL_SUCCESS != err)
commit 619b13f054c56d0ea3c97ff2a4ab52b39447d9f5
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jan 16 15:17:05 2015 +0100

    Variadic cppu::WeakComponentImplHelper
    
    Change-Id: I79371b4ad9d29a5ab8fd01244c3f80db92b07f97

diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index ece0d64..ed32764 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -40,7 +40,7 @@
 #include <uno/mapping.hxx>
 
 #include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/compbase.hxx>
 #include <cppuhelper/component_context.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 
@@ -331,8 +331,8 @@ protected:
 
 class ComponentContext
     : private MutexHolder
-    , public WeakComponentImplHelper2< XComponentContext,
-                                       container::XNameContainer >
+    , public WeakComponentImplHelper< XComponentContext,
+                                      container::XNameContainer >
 {
 protected:
     Reference< XComponentContext > m_xDelegate;
@@ -752,8 +752,7 @@ void ComponentContext::disposing()
 ComponentContext::ComponentContext(
     ContextEntry_Init const * pEntries, sal_Int32 nEntries,
     Reference< XComponentContext > const & xDelegate )
-    : WeakComponentImplHelper2< XComponentContext, container::XNameContainer >(
-        m_mutex ),
+    : WeakComponentImplHelper( m_mutex ),
       m_xDelegate( xDelegate )
 {
     for ( sal_Int32 nPos = 0; nPos < nEntries; ++nPos )
diff --git a/include/cppuhelper/compbase.hxx b/include/cppuhelper/compbase.hxx
new file mode 100644
index 0000000..9f0d648
--- /dev/null
+++ b/include/cppuhelper/compbase.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CPPUHELPER_COMPBASE_HXX
+#define INCLUDED_CPPUHELPER_COMPBASE_HXX
+
+#include <sal/config.h>
+
+#include <exception>
+
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Type.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <rtl/instance.hxx>
+#include <sal/types.h>
+
+namespace osl { class Mutex; }
+
+#if defined LIBO_INTERNAL_ONLY
+
+namespace cppu {
+
+/** Implementation helper implementing interfaces
+    com::sun::star::uno::XInterface, com::sun::star::lang::XTypeProvider, and
+    com::sun::star::lang::XComponent.
+
+    Upon disposing objects of this class, sub-classes receive a disposing()
+    call.
+
+    @attention
+    The mutex reference passed to the constructor has to outlive the constructed
+    instance.
+*/
+template<typename... Ifc>
+class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper:
+    public WeakComponentImplHelperBase, public css::lang::XTypeProvider,
+    public Ifc...
+{
+    struct cd:
+        rtl::StaticAggregate<
+            class_data, detail::ImplClassData<WeakComponentImplHelper, Ifc...>>
+    {};
+
+public:
+    WeakComponentImplHelper(osl::Mutex & mutex) throw ():
+        WeakComponentImplHelperBase(mutex) {}
+
+    css::uno::Any SAL_CALL queryInterface(css::uno::Type const & aType)
+        throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+    { return WeakComponentImplHelper_query(aType, cd::get(), this, this); }
+
+    void SAL_CALL acquire() throw () SAL_OVERRIDE
+    { WeakComponentImplHelperBase::acquire(); }
+
+    void SAL_CALL release() throw () SAL_OVERRIDE
+    { WeakComponentImplHelperBase::release(); }
+
+    css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
+        throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+    { return WeakComponentImplHelper_getTypes(cd::get()); }
+
+    css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
+        throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+    { return css::uno::Sequence<sal_Int8>(); }
+};
+
+}
+
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8b9968a26265facaf5e761485d750ce9cedab3ab
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jan 16 13:24:52 2015 +0100

    fdo#72755: Only use double mmap as fallback
    
    ...when write+exec mmap fails (due to SELinux deny_execmem).  This avoids the
    tmp file creation in environments that don't need it and which in turn have
    problems of their own with that tmp file business.
    
    An alternative would be to first check whether SELinux deny_execmem is enforced
    and only then try double mmap first.  An advantage could be that it might avoid
    false SELinux alerts in that case.  The disadvantage would be the overhead of
    introducing a conditional dependency on libselinux here.  And given that for one
    deny_execmem typically appears to be off by default (as at least both
    contemporary GNOME desktop and OpenJDK malfunction when it is enabled), and for
    another I guess deny_execmem could still change its value between the time of
    checking for it and the time of requesting a write+exec mmap, that just does not
    seem worth it.
    
    Change-Id: I3560803139b630557b6219d3db52945c7e0cdcd2

diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx
index ca77aea..226a994 100644
--- a/bridges/source/cpp_uno/shared/vtablefactory.cxx
+++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx
@@ -229,9 +229,14 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const
     sal_Size size = getBlockSize(slotCount);
     sal_Size pagesize = sysconf(_SC_PAGESIZE);
     block.size = (size + (pagesize - 1)) & ~(pagesize - 1);
-    block.start = block.exec = NULL;
     block.fd = -1;
 
+    // Try non-doublemmaped allocation first:
+    block.start = block.exec = rtl_arena_alloc(m_arena, &block.size);
+    if (block.start != nullptr) {
+        return true;
+    }
+
     osl::Security aSecurity;
     OUString strDirectory;
     OUString strURLDirectory;
@@ -290,12 +295,6 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const
 
         strDirectory.clear();
     }
-    if (!block.start || !block.exec || block.fd == -1)
-    {
-       //Fall back to non-doublemmaped allocation
-       block.fd = -1;
-       block.start = block.exec = rtl_arena_alloc(m_arena, &block.size);
-    }
     return (block.start != 0 && block.exec != 0);
 }
 
commit 7e01796c456d7006b73ad4ec2fc502bf8fe8d2ce
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 15 15:16:48 2015 +0100

    lokdocview: add LOKDocViewCallbackData
    
    So that the callback code running on the main thread can be aware of the
    event type and payload (necessary in the future to do partial repaints).
    
    Change-Id: I790b2ce0b6f9f88ba71d94a17bf0c8fc1b567c5f

diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 5e6e790..d9be2df 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -178,20 +178,30 @@ void renderDocument( LOKDocView* pDocView )
     }
 }
 
+/// Callback data, allocated in lok_docview_callback_worker(), released in lok_docview_callback().
+typedef struct
+{
+    int m_nType;
+    const char* m_pPayload;
+    LOKDocView* m_pDocView;
+}
+LOKDocViewCallbackData;
+
 /// Invoked on the main thread if lok_docview_callback_worker() requests so.
 static gboolean lok_docview_callback(gpointer pData)
 {
-    LOKDocView* pDocView = pData;
-
-#if ! GTK_CHECK_VERSION(2,12,0)
-    GDK_THREADS_ENTER();
-#endif
+    LOKDocViewCallbackData* pCallback = pData;
 
-    renderDocument(pDocView);
+    switch (pCallback->m_nType)
+    {
+    case LOK_CALLBACK_INVALIDATE_TILES:
+        renderDocument(pCallback->m_pDocView);
+        break;
+    default:
+        break;
+    }
 
-#if ! GTK_CHECK_VERSION(2,12,0)
-    GDK_THREADS_LEAVE();
-#endif
+    g_free(pCallback);
     return G_SOURCE_REMOVE;
 }
 
@@ -200,20 +210,15 @@ static void lok_docview_callback_worker(int nType, const char* pPayload, void* p
 {
     LOKDocView* pDocView = pData;
 
-    switch (nType)
-    {
-    case LOK_CALLBACK_INVALIDATE_TILES:
-        // TODO for now just always render the document.
-        (void)pPayload;
+    LOKDocViewCallbackData* pCallback = g_new0(LOKDocViewCallbackData, 1);
+    pCallback->m_nType = nType;
+    pCallback->m_pPayload = pPayload;
+    pCallback->m_pDocView = pDocView;
 #if GTK_CHECK_VERSION(2,12,0)
-        gdk_threads_add_idle(lok_docview_callback, pDocView);
+    gdk_threads_add_idle(lok_docview_callback, pCallback);
 #else
-        g_idle_add(lok_docview_callback, pDocView);
+    g_idle_add(lok_docview_callback, pDocView);
 #endif
-        break;
-    default:
-        break;
-    }
 }
 
 SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
commit bd065f5abacc0c5c0b55d15b67809ebf4898c646
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 19:03:39 2015 +0900

    android: Add key events in TileProvider & pass key events to LOK
    
    Change-Id: Id0a93f1c4199082b3c67802955082d04831ec124

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 32cb43c..3b7f657 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -147,6 +147,9 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
             case LOEvent.TOUCH:
                 touch(event.mTouchType, event.mMotionEvent);
                 break;
+            case LOEvent.KEY_PRESS:
+                mTileProvider.keyPress(event.mKeyEvent);
+                break;
         }
     }
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index b7dee3b..0970bbb 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -3,6 +3,7 @@ package org.libreoffice;
 import android.graphics.Bitmap;
 import android.graphics.RectF;
 import android.util.Log;
+import android.view.KeyEvent;
 
 import org.libreoffice.kit.DirectBufferAllocator;
 import org.libreoffice.kit.Document;
@@ -272,6 +273,11 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
         this.tileInvalidationCallback = tileInvalidationCallback;
     }
 
+    @Override
+    public void keyPress(KeyEvent keyEvent) {
+        mOffice.postKeyEvent(Office.KEY_PRESS, keyEvent.getKeyCode());
+    }
+
 
     @Override
     protected void finalize() throws Throwable {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 16772d0..15332a7 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -1,6 +1,7 @@
 package org.libreoffice;
 
 import android.graphics.Bitmap;
+import android.view.KeyEvent;
 
 import org.mozilla.gecko.gfx.BufferedCairoImage;
 import org.mozilla.gecko.gfx.CairoImage;
@@ -87,6 +88,10 @@ public class MockTileProvider implements TileProvider {
     }
 
     @Override
+    public void keyPress(KeyEvent keyEvent) {
+    }
+
+    @Override
     public void changePart(int partIndex) {
     }
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
index faa55a8..da0d0f4 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -3,6 +3,7 @@ package org.libreoffice;
 
 import android.graphics.Bitmap;
 import android.graphics.RectF;
+import android.view.KeyEvent;
 
 import org.mozilla.gecko.gfx.CairoImage;
 import org.mozilla.gecko.gfx.IntSize;
@@ -33,6 +34,8 @@ public interface TileProvider {
 
     void registerInvalidationCallback(TileProvider.TileInvalidationCallback tileInvalidationCallback);
 
+    void keyPress(KeyEvent keyEvent);
+
     /**
      * Callback to retrieve invalidation calls
      */
commit 89d41753df7ad3e2c266c77895370deb0a4af274
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 19:01:04 2015 +0900

    android: Add needed services for editing.
    
    Change-Id: I29acea58b4e18efcf33b51361812c3f7532282ab

diff --git a/android/experimental/LOAndroid3/Makefile b/android/experimental/LOAndroid3/Makefile
index a19fadc..e700daa 100644
--- a/android/experimental/LOAndroid3/Makefile
+++ b/android/experimental/LOAndroid3/Makefile
@@ -14,7 +14,7 @@ BOOTSTRAPDIR=../../Bootstrap
 include $(BOOTSTRAPDIR)/Makefile.shared
 
 native-code.cxx: $(SRCDIR)/solenv/bin/native-code.py
-	$< -j -g core -g writer -g calc -g draw > $@
+	$< -j -g core -g writer -g calc -g draw -g edit > $@
 
 build-ant: android_version_setup copy-stuff link-so properties
 #
diff --git a/android/mobile-config.py b/android/mobile-config.py
index 9981840..93e08c6 100755
--- a/android/mobile-config.py
+++ b/android/mobile-config.py
@@ -23,7 +23,6 @@ main_xcd_discard = [
 
     # no conventional UI; reverse sorted by size
     'org.openoffice.Office.UI/GenericCommands',
-    'org.openoffice.Office/Accelerators',
     'org.openoffice.Office.UI/DrawImpressCommands',
     'org.openoffice.Office.UI/Sidebar',
     'org.openoffice.Office.UI/ChartCommands',
commit 389fae7cbafac76591fb99054f0fcaeefb441a37
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 18:06:44 2015 +0900

    android: Add some comments.
    
    Change-Id: I77372ae2b1c7c4332dc4a8c244c67a82f9551e22

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 03b9aaf..5206694 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -49,6 +49,9 @@ public class LOKitShell {
 
     // EVENTS
 
+    /**
+     * Make sure LOKitThread is running and send event to it.
+     */
     public static void sendEvent(LOEvent event) {
         if (LibreOfficeMainActivity.mAppContext != null && LibreOfficeMainActivity.mAppContext.getLOKitThread() != null) {
             LibreOfficeMainActivity.mAppContext.getLOKitThread().queueEvent(event);
@@ -59,10 +62,16 @@ public class LOKitShell {
         LOKitShell.sendEvent(new LOEvent(LOEvent.THUMBNAIL, task));
     }
 
+    /**
+     * Send touch event to LOKitThread.
+     */
     public static void sentTouchEvent(String touchType, MotionEvent motionEvent) {
         LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, "SingleTap", motionEvent));
     }
 
+    /**
+     * Send key press event to LOKitThread.
+     */
     public static void sendKeyPressEvent(KeyEvent event) {
         LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_PRESS, event));
     }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 7eda1f1..b7dee3b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -15,6 +15,9 @@ import org.mozilla.gecko.gfx.IntSize;
 
 import java.nio.ByteBuffer;
 
+/**
+ * LOKit implementation of TileProvider.
+ */
 public class LOKitTileProvider implements TileProvider, Document.MessageCallback {
     private static final String LOGTAG = LOKitTileProvider.class.getSimpleName();
     private static int TILE_SIZE = 256;
@@ -261,6 +264,9 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
         return mDocument != null && mDocument.getDocumentType() == Document.DOCTYPE_TEXT;
     }
 
+    /**
+     * Register the tile invalidation callback.
+     */
     @Override
     public void registerInvalidationCallback(TileInvalidationCallback tileInvalidationCallback) {
         this.tileInvalidationCallback = tileInvalidationCallback;
@@ -284,6 +290,9 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
         return mDocument.getPart();
     }
 
+    /**
+     * Process the retrieved messages from LOK
+     */
     @Override
     public void messageRetrieved(int signalNumber, String payload) {
         switch (signalNumber) {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index b79217d..5efbc68 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -192,6 +192,10 @@ public class LibreOfficeMainActivity extends LOAbout {
         return mDocumentPartViewListAdapter;
     }
 
+    /**
+     * Show software keyboard.
+     * Force the request on main thread.
+     */
     public void showSoftKeyboard() {
         Log.i(LOGTAG, "SoftKeyboard show request..");
 
@@ -241,6 +245,10 @@ public class LibreOfficeMainActivity extends LOAbout {
         }
     }
 
+
+    /**
+     * Listen to key presses and send event to LOK.
+     */
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         LOKitShell.sendKeyPressEvent(event);
commit 376639778151e433371941487d030e157a6b75ef
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 17:45:48 2015 +0900

    android: add missing break
    
    Change-Id: I5e9598249457c62d3ccc9c5f754526c1fbe969bf

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 9334536..7eda1f1 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -305,6 +305,7 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
                         tileInvalidationCallback.invalidate(rect);
                     }
                 }
+                break;
         }
     }
 }
commit b7469087e107f1380e01f836d06d17e9bad12f63
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 17:44:27 2015 +0900

    android: add key_press event and send them to LOKitThread
    
    Change-Id: I306fbe12e0a91e28bb2308074ded03b768173440

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
index 7ec346b..809988d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
@@ -1,5 +1,6 @@
 package org.libreoffice;
 
+import android.view.KeyEvent;
 import android.view.MotionEvent;
 
 import org.mozilla.gecko.gfx.ComposedTileLayer;
@@ -17,6 +18,7 @@ public class LOEvent implements Comparable<LOEvent> {
     public static final int THUMBNAIL = 8;
     public static final int TILE_RERENDER = 9;
     public static final int TOUCH = 10;
+    public static final int KEY_PRESS = 11;
 
     public final int mType;
     public int mPriority = 0;
@@ -31,6 +33,7 @@ public class LOEvent implements Comparable<LOEvent> {
     public SubTile mTile;
     public String mTouchType;
     public MotionEvent mMotionEvent;
+    public KeyEvent mKeyEvent;
 
     public LOEvent(int type) {
         mType = type;
@@ -85,6 +88,11 @@ public class LOEvent implements Comparable<LOEvent> {
         mMotionEvent = motionEvent;
     }
 
+    public LOEvent(int type, KeyEvent keyEvent) {
+        mType = type;
+        mKeyEvent = keyEvent;
+    }
+
     public String getTypeString() {
         if (mTypeString == null) {
             return "Event type: " + mType;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index e894690..03b9aaf 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -3,6 +3,7 @@ package org.libreoffice;
 
 import android.os.Handler;
 import android.util.DisplayMetrics;
+import android.view.KeyEvent;
 import android.view.MotionEvent;
 
 
@@ -61,4 +62,8 @@ public class LOKitShell {
     public static void sentTouchEvent(String touchType, MotionEvent motionEvent) {
         LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, "SingleTap", motionEvent));
     }
+
+    public static void sendKeyPressEvent(KeyEvent event) {
+        LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_PRESS, event));
+    }
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index a40d78c..b79217d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -9,6 +9,7 @@ import android.os.Handler;
 import android.support.v4.widget.DrawerLayout;
 import android.util.DisplayMetrics;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -239,6 +240,12 @@ public class LibreOfficeMainActivity extends LOAbout {
             mDrawerLayout.closeDrawer(mDrawerList);
         }
     }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        LOKitShell.sendKeyPressEvent(event);
+        return super.onKeyDown(keyCode, event);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 56e7490ee611a746c1351d19c22a615cbf90afdf
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 16 16:02:38 2015 +0900

    android: remove invalidation registration on touch for now
    
    Change-Id: I7b3acba83de0c17bd4723fb6623827dbbb82fbbf

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index ed89536..32cb43c 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -22,7 +22,6 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
     private TileProvider mTileProvider;
     private ImmutableViewportMetrics mViewportMetrics;
     private GeckoLayerClient mLayerClient;
-    private boolean mInvalidationCallbackRegistered = false;
 
     public LOKitThread() {
         TileProviderFactory.initialize();
@@ -99,9 +98,9 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
         boolean isReady = mTileProvider.isReady();
         if (isReady) {
             LOKitShell.showProgressSpinner();
+            mTileProvider.registerInvalidationCallback(this);
             refresh();
             LOKitShell.hideProgressSpinner();
-            mInvalidationCallbackRegistered = false;
         }
         return isReady;
     }
@@ -153,10 +152,6 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
 
     private void touch(String touchType, MotionEvent motionEvent) {
         LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
-        if (!mInvalidationCallbackRegistered) {
-            mTileProvider.registerInvalidationCallback(this);
-            mInvalidationCallbackRegistered = true;
-        }
     }
 
     private void createThumbnail(final ThumbnailCreator.ThumbnailCreationTask task) {
commit db214657517648f8ade794abc276dae36376cf5d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 15 14:39:45 2015 +0100

    SwViewImp::AddPaintRect: when tiled rendering, ignore visual area
    
    With this, gtktiledviewer gets the proper invalidation rectangles after
    keypresses.
    
    Change-Id: I9bd1f5b59d05ae93a0a1d018dda8b2efc01cb38c

diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index b08aa42..35805bf 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -132,10 +132,16 @@ void SwViewImp::DelRegion()
 

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list