Makefile.top                                                                   
              |    1 
 Module_tail_build.mk                                                           
              |    1 
 Repository.mk                                                                  
              |    8 
 RepositoryModule_ooo.mk                                                        
              |    1 
 android/Bootstrap/src/org/libreoffice/android/Bootstrap.java                   
              |    2 
 android/experimental/DocumentLoader/Makefile                                   
              |    2 
 
android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
 |  195 +++++----
 sal/android/lo-bootstrap.c                                                     
              |   23 +
 touch/CustomTarget_touch_javamaker.mk                                          
              |   21 
 touch/InternalUnoApi_touch.mk                                                  
              |   33 +
 touch/Library_libotouch.mk                                                     
              |   39 +
 touch/Makefile                                                                 
              |    7 
 touch/Module_touch.mk                                                          
              |   22 +
 touch/Package_inc.mk                                                           
              |   13 
 touch/README                                                                   
              |   20 
 touch/idl/org/libreoffice/touch/Document.idl                                   
              |   25 +
 touch/idl/org/libreoffice/touch/DocumentRenderCallback.idl                     
              |   25 +
 touch/idl/org/libreoffice/touch/XDocument.idl                                  
              |   73 +++
 touch/idl/org/libreoffice/touch/XDocumentRenderCallback.idl                    
              |   55 ++
 touch/inc/touch/libotouch.hxx                                                  
              |   15 
 touch/prj/build.lst                                                            
              |    1 
 touch/source/generic/libotouch.cxx                                             
              |   11 
 touch/source/ios/ios.cxx                                                       
              |   10 
 touch/source/uno/Document.cxx                                                  
              |  213 ++++++++++
 vcl/android/androidinst.cxx                                                    
              |    2 
 vcl/headless/svpbmp.cxx                                                        
              |    1 
 vcl/headless/svpframe.cxx                                                      
              |    5 
 vcl/headless/svpvd.cxx                                                         
              |    6 
 28 files changed, 744 insertions(+), 86 deletions(-)

New commits:
commit 8ae077379edcdbf7bf106121593361d2486aacb7
Author: Tor Lillqvist <tlillqv...@suse.com>
Date:   Tue Jun 5 17:05:56 2012 +0300

    Use 32bpp bitmaps on Android (and iOS)
    
    Modify DocumentLoader correspondingly. Take Android bug 32588 into
    account.
    
    Ideal would be to extend the XDevice stuff, or something, so that one
    could hand it a pre-allocated RGBA buffer into which the
    drawing/rendering would go. Then one could get rid of the silly
    convert-to-BMP phase, which prefixes the bitmap data with BMP and DIB
    headers (and thus, I guess, has to copy and allocate another
    copy). Will see.
    
    Change-Id: I4597cd933db8faa8105dc8f19638d712d5d2238a

diff --git a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java 
b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
index 47366a2..1f0c14e 100644
--- a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
+++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
@@ -116,6 +116,8 @@ public class Bootstrap extends NativeActivity
     // documentation sucks.
     public static native void twiddle_BGR_to_RGBA(byte[] source, int offset, 
int width, int height, ByteBuffer destination);
 
+    public static native void force_full_alpha(byte[] source, int offset, int 
size);
+
     // This setup() method is called 1) in apps that use *this* class as their 
activity from onCreate(),
     // and 2) should be called from other kinds of LO code using apps.
     public static void setup(Activity activity)
diff --git a/android/experimental/DocumentLoader/Makefile 
b/android/experimental/DocumentLoader/Makefile
index 1e9cebc..8129948 100644
--- a/android/experimental/DocumentLoader/Makefile
+++ b/android/experimental/DocumentLoader/Makefile
@@ -262,8 +262,10 @@ uninstall:
        $(ANDROID_SDK_HOME)/platform-tools/adb uninstall $(APP_PACKAGE)
 
 run:
+# /data/local/tmp/sample-document.odt
        adb shell am start -n org.libreoffice.android.examples/.DocumentLoader 
-e input /assets/test1.odt
 
+
 clean: properties
        $(ANT) clean
        rm -rf assets libs $(SODEST) $(OBJLOCAL)
diff --git 
a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
 
b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
index 8ead7a9..4f027ec 100644
--- 
a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ 
b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -150,18 +150,21 @@ public class DocumentLoader
             Log.i(TAG, "  " + t.getTypeName());
     }
 
-    static void dumpBytes(String imageName, byte[] image)
+    static void dumpBytes(String name, byte[] bytes, int offset)
     {
-        if (image == null) {
-            Log.i(TAG, imageName + " is null");
+        if (bytes == null) {
+            Log.i(TAG, name + " is null");
             return;
         }
-        Log.i(TAG, imageName + " is " + image.length + " bytes");
+        Log.i(TAG, name + ":");
 
-        for (int i = 0; i < Math.min(image.length, 160); i += 16) {
+        if (offset != 0)
+            Log.i(TAG, "  (offset " + offset + ")");
+
+        for (int i = offset; i < Math.min(bytes.length, offset+160); i += 16) {
             String s = "";
-            for (int j = i; j < Math.min(image.length, i+16); j++)
-                s = s + String.format(" %02x", image[j]);
+            for (int j = i; j < Math.min(bytes.length, i+16); j++)
+                s = s + String.format(" %02x", bytes[j]);
 
             Log.i(TAG, s);
         }
@@ -185,8 +188,8 @@ public class DocumentLoader
             Bootstrap.dlopen("libswdlo.so");
             Bootstrap.dlopen("libswlo.so");
             
-            Log.i(TAG, "Sleeping NOW");
-            Thread.sleep(20000);
+            // Log.i(TAG, "Sleeping NOW");
+            // Thread.sleep(20000);
 
             XComponentContext xContext = null;
 
@@ -225,113 +228,137 @@ public class DocumentLoader
 
             Log.i(TAG, "xCompLoader is" + (xCompLoader!=null ? " not" : "") + 
" null");
 
-            // Load the wanted document(s)
-            String[] inputs = input.split(":");
-            for (int i = 0; i < inputs.length; i++) {
-                PropertyValue loadProps[] = new PropertyValue[3];
-                loadProps[0] = new PropertyValue();
-                loadProps[0].Name = "Hidden";
-                loadProps[0].Value = new Boolean(true);
-                loadProps[1] = new PropertyValue();
-                loadProps[1].Name = "ReadOnly";
-                loadProps[1].Value = new Boolean(true);
-                loadProps[2] = new PropertyValue();
-                loadProps[2].Name = "Preview";
-                loadProps[2].Value = new Boolean(true);
+            // Load the wanted document
 
-                String sUrl = "file://" + inputs[i];
+            PropertyValue loadProps[] = new PropertyValue[3];
+            loadProps[0] = new PropertyValue();
+            loadProps[0].Name = "Hidden";
+            loadProps[0].Value = new Boolean(true);
+            loadProps[1] = new PropertyValue();
+            loadProps[1].Name = "ReadOnly";
+            loadProps[1].Value = new Boolean(true);
+            loadProps[2] = new PropertyValue();
+            loadProps[2].Name = "Preview";
+            loadProps[2].Value = new Boolean(true);
 
-                Log.i(TAG, "Attempting to load " + sUrl);
+            String sUrl = "file://" + input;
 
-                Object oDoc =
-                    xCompLoader.loadComponentFromURL
-                    (sUrl, "_blank", 0, loadProps);
+            Log.i(TAG, "Attempting to load " + sUrl);
 
-                dumpUNOObject("oDoc", oDoc);
+            Object oDoc =
+                xCompLoader.loadComponentFromURL
+                (sUrl, "_blank", 0, loadProps);
 
-                Object toolkit = xMCF.createInstanceWithContext
-                    ("com.sun.star.awt.Toolkit", xContext);
+            dumpUNOObject("oDoc", oDoc);
 
-                dumpUNOObject("toolkit", toolkit);
+            Object toolkit = xMCF.createInstanceWithContext
+                ("com.sun.star.awt.Toolkit", xContext);
 
-                XToolkit xToolkit = (XToolkit)
-                    UnoRuntime.queryInterface(XToolkit.class, toolkit);
+            dumpUNOObject("toolkit", toolkit);
 
-                XDevice device = xToolkit.createScreenCompatibleDevice(1024, 
1024);
+            XToolkit xToolkit = (XToolkit)
+                UnoRuntime.queryInterface(XToolkit.class, toolkit);
 
-                dumpUNOObject("device", device);
+            XDevice device = xToolkit.createScreenCompatibleDevice(1024, 1024);
 
-                // I guess the XRenderable thing might be what we want to use,
-                // having the code pretend it is printing?
+            dumpUNOObject("device", device);
 
-                XRenderable renderBabe = (XRenderable)
-                    UnoRuntime.queryInterface(XRenderable.class, oDoc);
+            XRenderable renderBabe = (XRenderable)
+                UnoRuntime.queryInterface(XRenderable.class, oDoc);
 
-                PropertyValue renderProps[] =
-                    new PropertyValue[3];
-                renderProps[0] = new PropertyValue();
-                renderProps[0].Name = "IsPrinter";
-                renderProps[0].Value = new Boolean(true);
-                renderProps[1] = new PropertyValue();
-                renderProps[1].Name = "RenderDevice";
-                renderProps[1].Value = device;
-                renderProps[2] = new PropertyValue();
-                renderProps[2].Name = "View";
-                renderProps[2].Value = new MyXController();
+            PropertyValue renderProps[] =
+                new PropertyValue[3];
+            renderProps[0] = new PropertyValue();
+            renderProps[0].Name = "IsPrinter";
+            renderProps[0].Value = new Boolean(true);
+            renderProps[1] = new PropertyValue();
+            renderProps[1].Name = "RenderDevice";
+            renderProps[1].Value = device;
+            renderProps[2] = new PropertyValue();
+            renderProps[2].Name = "View";
+            renderProps[2].Value = new MyXController();
 
-                Log.i(TAG, "getRendererCount: " + 
renderBabe.getRendererCount(oDoc, renderProps));
+            Log.i(TAG, "getRendererCount: " + 
renderBabe.getRendererCount(oDoc, renderProps));
 
-                renderBabe.render(0, oDoc, renderProps);
+            renderBabe.render(0, oDoc, renderProps);
 
-                XBitmap bitmap = device.createBitmap(0, 0, 1024, 1024);
+            XBitmap bitmap = device.createBitmap(0, 0, 1024, 1024);
 
-                byte[] image = bitmap.getDIB();
+            byte[] image = bitmap.getDIB();
 
-                dumpBytes("image", image);
+            dumpBytes("image", image, 0);
 
-                byte[] mask = bitmap.getMaskDIB();
+            if (image[0] != 'B' || image[1] != 'M') {
+                Log.wtf(TAG, "getDIB() didn't return a BMP file");
+                return;
+            }
 
-                dumpBytes("mask", mask);
+            ByteBuffer imagebb = ByteBuffer.wrap(image);
+            imagebb.order(ByteOrder.LITTLE_ENDIAN);
 
-                if (image[0] != 'B' || image[1] != 'M') {
-                    Log.e(TAG, "getDIB() didn't return a BMP file");
-                    return;
-                }
+            if (imagebb.getInt(0x0e) != 40) {
+                Log.wtf(TAG, "getDIB() didn't return a DIB with 
BITMAPINFOHEADER");
+                return;
+            }
 
-                ByteBuffer imagebb = ByteBuffer.wrap(image);
-                imagebb.order(ByteOrder.LITTLE_ENDIAN);
+            if (imagebb.getShort(0x1c) != 32) {
+                Log.wtf(TAG, "getDIB() didn't return a 32 bpp DIB");
+                return;
+            }
 
-                if (imagebb.getInt(0x0e) != 40) {
-                    Log.e(TAG, "getDIB() didn't return a DIB with 
BITMAPINFOHEADER");
-                    return;
-                }
+            if (imagebb.getInt(0x1e) != 3) {
+                Log.wtf(TAG, "getDIB() didn't return a BI_BITFIELDS DIB");
+                return;
+            }
 
-                if (imagebb.getShort(0x1c) != 24) {
-                    Log.e(TAG, "getDIB() didn't return a 24 bpp DIB");
-                    return;
-                }
+            int offset = imagebb.getInt(0x0a);
+            int width = imagebb.getInt(0x12);
+            int height = imagebb.getInt(0x16);
+
+            Log.i(TAG, String.format("offset: %d (%x), width: %d, height: %d", 
offset, offset, width, height));
+
+            Bootstrap.force_full_alpha(image, offset, width * height * 4);
 
-                if (imagebb.getInt(0x1e) != 0) {
-                    Log.e(TAG, "getDIB() didn't return a BI_RGB DIB");
-                    return;
+            Log.i(TAG, "after force_full_alpha:");
+            dumpBytes("image", image, 0);
+
+            for (int i = offset;  i < offset + width * height * 4; i++) {
+                if (image[i] != -1) {
+                    int o = offset + (((i-offset) - 4) / 4) * 4;
+                    dumpBytes("First non-ones bytes", image, o);
+                    o += 160;
+                    dumpBytes("...", image, o);
+                    o += 160;
+                    dumpBytes("...", image, o);
+                    o += 160;
+                    dumpBytes("...", image, o);
+                    break;
                 }
+            }
 
-                int width = imagebb.getInt(0x12);
-                int height = imagebb.getInt(0x16);
+            ImageView imageView = new GestureImageView(this);
+            imageView.setScaleY(-1);
 
-                ByteBuffer argb = ByteBuffer.allocateDirect(width * height * 
4);
+            Bitmap bm = Bitmap.createBitmap(width, height, 
Bitmap.Config.ARGB_8888);
+            imagebb.position(offset);
 
-                Bootstrap.twiddle_BGR_to_RGBA(image, imagebb.getInt(0x0a), 
width, height, argb);
+            // Thanks to Android bug 32588, the above is not enough to get the
+            // below copyPixelsFromBuffer() to start copying at offset, it
+            // will (as of Android 4.0.3) copy from position zero anyway. So
+            // instead have to shift (compact) the bloody buffer.
+            imagebb.compact();
 
-                ImageView imageView = new GestureImageView(this);
+            // I don't understand what the compact() documentation says about
+            // the new position; so explicitly put it at zero, in case
+            // runnning on an Android where copyPixelsFromBuffer() *does* take
+            // the position into account.
+            imagebb.position(0);
 
-                Bitmap bm = Bitmap.createBitmap(width, height, 
Bitmap.Config.ARGB_8888);
-                bm.copyPixelsFromBuffer(argb);
+            bm.copyPixelsFromBuffer(imagebb);
 
-                imageView.setImageBitmap(bm);
+            imageView.setImageBitmap(bm);
 
-                setContentView(imageView);
-            }
+            setContentView(imageView);
         }
         catch (Exception e) {
             e.printStackTrace(System.err);
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index fed7a4d..b6e29ba 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -1906,6 +1906,29 @@ 
Java_org_libreoffice_android_Bootstrap_twiddle_1BGR_1to_1RGBA(JNIEnv* env,
 }
 
 __attribute__ ((visibility("default")))
+void
+Java_org_libreoffice_android_Bootstrap_force_1full_1alpha(JNIEnv* env,
+                                                          jobject clazz,
+                                                          jbyteArray array,
+                                                          jint offset,
+                                                          jint size)
+{
+    void *a = (*env)->GetPrimitiveArrayCritical(env, array, NULL);
+    jbyte *p = ((jbyte *) a) + offset;
+
+    int i;
+
+    (void) clazz;
+
+    for (i = 0; i < size; i += 4) {
+        p[3] = 0xFF;
+        p += 4;
+    }
+
+    (*env)->ReleasePrimitiveArrayCritical(env, array, a, 0);
+}
+
+__attribute__ ((visibility("default")))
 JavaVM *
 lo_get_javavm(void)
 {
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 7c0968c..ac08ac5 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -702,7 +702,7 @@ public:
                      sal_uLong           nSalFrameStyle,
                      SystemParentData   *pSysParent )
         : SvpSalFrame( pInstance, pParent, nSalFrameStyle,
-                       true, basebmp::Format::TWENTYFOUR_BIT_TC_MASK,
+                       true, basebmp::Format::THIRTYTWO_BIT_TC_MASK, // FIXME: 
Or THIRTYTWO_BIT_TC_MASK_ARGB?
                        pSysParent )
     {
         enableDamageTracker();
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index d27b765..f1d8d49 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -59,6 +59,7 @@ bool SvpSalBitmap::Create( const Size& rSize,
         case 16: nFormat = Format::SIXTEEN_BIT_LSB_TC_MASK; break;
 #endif
         case 24: nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
+        // FIXME: Should this for Android be THIRTYTWO_BIT_TC_MASK_ARGB?
         case 32: nFormat = Format::THIRTYTWO_BIT_TC_MASK; break;
     }
     B2IVector aSize( rSize.Width(), rSize.Height() );
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 63f4a49..208313d 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -92,8 +92,13 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
     m_aSystemChildData.nSize        = sizeof( SystemChildData );
 #if defined( UNX ) // FIXME: prolly redundant
     m_aSystemChildData.pSalFrame    = this;
+#if defined(ANDROID) || defined(IOS)
+    // We want 32-bit RGBA bitmaps
+    m_aSystemChildData.nDepth       = 32;
+#else
     m_aSystemChildData.nDepth       = 24;
 #endif
+#endif
 
     if( m_pParent )
         m_pParent->m_aChildren.push_back( this );
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index 8b90d64..285eeaf 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -80,9 +80,13 @@ sal_Bool SvpSalVirtualDevice::SetSize( long nNewDX, long 
nNewDY )
 #else
             case 16: nFormat = Format::SIXTEEN_BIT_LSB_TC_MASK; break;
 #endif
-            case 0:
             case 24: nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
             case 32: nFormat = Format::THIRTYTWO_BIT_TC_MASK; break;
+#if defined(ANDROID) || defined(IOS)
+            case 0:  nFormat = Format::THIRTYTWO_BIT_TC_MASK; break;
+#else
+            case 0:  nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
+#endif
         }
         m_aDevice = aDevPal.empty()
                     ? createBitmapDevice( aDevSize, false, nFormat )
commit 92f23297c93dc105e2ffd9ff09c0dafff1ee0fd3
Author: Tor Lillqvist <tlillqv...@suse.com>
Date:   Tue Jun 5 16:35:49 2012 +0300

    Work in progress: Add "touch" module for Android and iOS stuff
    
    Change-Id: I10652743194d44d8465ddf8079f6b4458e6710f9

diff --git a/Makefile.top b/Makefile.top
index a560236..e243c3b 100644
--- a/Makefile.top
+++ b/Makefile.top
@@ -130,6 +130,7 @@ test\
 testtools\
 toolkit\
 tools\
+touch\
 translations\
 twain\
 ucb\
diff --git a/Module_tail_build.mk b/Module_tail_build.mk
index 949195a..334bce8 100644
--- a/Module_tail_build.mk
+++ b/Module_tail_build.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_Module_add_moduledirs,tail_end,\
     test \
     toolkit \
        tools \
+       touch \
     twain \
     ucb \
     unixODBC \
diff --git a/Repository.mk b/Repository.mk
index 2edad91..2ac927d 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -385,6 +385,14 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
     xsltfilter \
 ))
 
+ifneq (,$(filter ANDROID IOS,$(OS)))
+
+$(eval $(call gb_Helper_register_libraries,OOOLIBS, \
+       libotouch \
+))
+
+endif
+
 ifeq ($(filter MACOSX WNT,$(OS)),)
 
 $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
diff --git a/RepositoryModule_ooo.mk b/RepositoryModule_ooo.mk
index ca84fcc..6d879c6 100644
--- a/RepositoryModule_ooo.mk
+++ b/RepositoryModule_ooo.mk
@@ -133,6 +133,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\
     testtools \
     toolkit \
     tools \
+       touch \
        $(if $(filter TRANSLATIONS,$(BUILD_TYPE)),\
                translations \
        ) \
diff --git a/touch/CustomTarget_touch_javamaker.mk 
b/touch/CustomTarget_touch_javamaker.mk
new file mode 100644
index 0000000..a375c74
--- /dev/null
+++ b/touch/CustomTarget_touch_javamaker.mk
@@ -0,0 +1,21 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# Copyright 2012 LibreOffice contributors.
+#
+# 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/.
+
+$(eval $(call gb_CustomTarget_CustomTarget,touch/touch_javamaker))
+
+touch_javamaker_DIR := $(call gb_CustomTarget_get_workdir,touch)
+
+$(call gb_CustomTarget_get_target,touch/touch_javamaker) : 
$(touch_javamaker_DIR)/done
+
+$(touch_javamaker_DIR)/done : $(call gb_UnoApiTarget_get_target,touch) \
+       $(call gb_Executable_get_target_for_build,javamaker) | 
$(touch_javamaker_DIR)/.dir
+       $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),JVM,1)
+       $(call gb_Helper_abbreviate_dirs, \
+       $(call gb_Helper_execute,javamaker -BUCR -nD 
-O$(touch_javamaker_DIR)/class -X$(OUTDIR)/bin/types.rdb $<) && touch $@)
+
+# vim: set noet sw=4 ts=4:
diff --git a/touch/InternalUnoApi_touch.mk b/touch/InternalUnoApi_touch.mk
new file mode 100644
index 0000000..bb03402
--- /dev/null
+++ b/touch/InternalUnoApi_touch.mk
@@ -0,0 +1,33 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# Copyright 2012 LibreOffice contributors.
+#
+# 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/.
+
+$(eval $(call gb_InternalUnoApi_InternalUnoApi,touch))
+
+$(eval $(call gb_InternalUnoApi_use_api,touch,\
+       udkapi \
+))
+
+$(eval $(call gb_InternalUnoApi_define_api_dependencies,touch, \
+       offapi,\
+       udkapi \
+))
+
+$(eval $(call gb_InternalUnoApi_set_include,touch,\
+       -I$(SRCDIR)/touch/idl \
+       -I$(OUTDIR)/idl \
+       $$(INCLUDE) \
+))
+
+$(eval $(call 
gb_InternalUnoApi_add_idlfiles,touch,touch/idl/org/libreoffice/touch,\
+       Document \
+       DocumentRenderCallback \
+       XDocument \
+       XDocumentRenderCallback \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/touch/Library_libotouch.mk b/touch/Library_libotouch.mk
new file mode 100644
index 0000000..be355e3
--- /dev/null
+++ b/touch/Library_libotouch.mk
@@ -0,0 +1,39 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# Copyright 2012 LibreOffice contributors.
+#
+# 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/.
+
+$(eval $(call gb_Library_Library,libotouch))
+
+$(eval $(call gb_Library_set_include,libotouch,\
+    -I$(SRCDIR)/libotouch/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_internal_comprehensive_api,libotouch,\
+       udkapi \
+       offapi \
+       touch \
+))
+
+$(eval $(call gb_Library_use_libraries,libotouch,\
+       $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_Library_add_exception_objects,libotouch,\
+       touch/source/uno/Document \
+       touch/source/generic/libotouch \
+))
+
+ifeq ($(OS),IOS)
+
+$(eval $(call gb_Library_add_objcxx_objects,libotouch,\
+       touch/source/ios/ios \
+))
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/touch/Makefile b/touch/Makefile
new file mode 100644
index 0000000..ccb1c85
--- /dev/null
+++ b/touch/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/touch/Module_touch.mk b/touch/Module_touch.mk
new file mode 100644
index 0000000..fde090d
--- /dev/null
+++ b/touch/Module_touch.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# Copyright 2012 LibreOffice contributors.
+#
+# 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/.
+
+$(eval $(call gb_Module_Module,touch))
+
+ifneq (,$(filter IOS ANDROID,$(OS)))
+
+$(eval $(call gb_Module_add_targets,touch,\
+       CustomTarget_touch_javamaker \
+       InternalUnoApi_touch \
+       Library_libotouch \
+       Package_inc \
+))
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/touch/Package_inc.mk b/touch/Package_inc.mk
new file mode 100644
index 0000000..c7c393d
--- /dev/null
+++ b/touch/Package_inc.mk
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# Copyright 2012 LibreOffice contributors.
+#
+# 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/.
+
+$(eval $(call gb_Package_Package,touch_inc,$(SRCDIR)/touch/inc))
+
+$(eval $(call 
gb_Package_add_file,touch_inc,inc/touch/libotouch.hxx,touch/libotouch.hxx))
+
+# vim: set noet sw=4 ts=4:
diff --git a/touch/README b/touch/README
new file mode 100644
index 0000000..f1be5df
--- /dev/null
+++ b/touch/README
@@ -0,0 +1,20 @@
+Library that provides API used by LO-based apps on touch devices
+
+This is all very much a work in progress and the design can change radically
+at any moment. The name "touch" for this module and the library name
+"libotouch" are not fixed and might change if somebody comes up with niftier
+names.
+
+This module will contain an UNO API to be called either from Java (for
+Android), or directly (iOS). (Or, on iOS, possibly through some thin
+Objective-C layer to hide the UNO.)
+
+The API will provide a mechanism to render "tiles" of a document at some
+requested zoom level. Initially for viewer style apps, but the work should
+ideally be open-ended to potentially be a base for editing apps, too.
+
+For starters, concentrating on text ("Writer") documents as they are
+easiest. With spreadsheets come the added complexity of the cell grid being
+potentially unbounded and no clear "page" area. With presentations come the
+animation complications, and possibly LO-based viewer apps for presentations
+will be done in a totally different fashion.
diff --git a/touch/idl/org/libreoffice/touch/Document.idl 
b/touch/idl/org/libreoffice/touch/Document.idl
new file mode 100644
index 0000000..c05437c
--- /dev/null
+++ b/touch/idl/org/libreoffice/touch/Document.idl
@@ -0,0 +1,25 @@
+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+// Copyright 2012 LibreOffice contributors.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License 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/.
+
+#ifndef org_libreoffice_touch_Document_idl
+#define org_libreoffice_touch_Document_idl
+
+#include <org/libreoffice/touch/XDocument.idl>
+
+module org { module libreoffice { module touch {
+
+service Document:
+    XDocument {
+        create( [in] string uri );
+    };
+
+}; }; };
+
+#endif
+
+// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/touch/idl/org/libreoffice/touch/DocumentRenderCallback.idl 
b/touch/idl/org/libreoffice/touch/DocumentRenderCallback.idl
new file mode 100644
index 0000000..95e7e77
--- /dev/null
+++ b/touch/idl/org/libreoffice/touch/DocumentRenderCallback.idl
@@ -0,0 +1,25 @@
+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+// Copyright 2012 LibreOffice contributors.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License 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/.
+
+#ifndef org_libreoffice_touch_DocumentRenderCallback_idl
+#define org_libreoffice_touch_DocumentRenderCallback_idl
+
+#include <org/libreoffice/touch/XDocumentRenderCallback.idl>
+
+module org { module libreoffice { module touch {
+
+service DocumentRenderCallback: XDocumentRenderCallback
+{
+    create();
+};
+
+}; }; };
+
+#endif
+
+// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/touch/idl/org/libreoffice/touch/XDocument.idl 
b/touch/idl/org/libreoffice/touch/XDocument.idl
new file mode 100644
index 0000000..bc3d563
--- /dev/null
+++ b/touch/idl/org/libreoffice/touch/XDocument.idl
@@ -0,0 +1,73 @@
+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+// Copyright 2012 LibreOffice contributors.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License 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/.
+
+#ifndef org_libreoffice_touch_XDocument_idl
+#define org_libreoffice_touch_XDocument_idl
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+
+module org { module libreoffice { module touch {
+
+// Note that this is work in progress
+
+// Error handling? Presumably for true errors expected to be uncommon, or
+// invalid usage, the methods should throw exceptions.
+
+// Multithreaded use of this is undefined (the intent obviously is that this
+// API is called in another thread than the "main" UI thread, but calling this
+// stuff on the same object simultaneously in multiple threads is undefined).
+
+// Represents one (Writer, for now) document
+
+interface XDocumentRenderCallback;
+
+interface XDocument: com::sun::star::uno::XInterface
+{
+    [attribute, readonly] long numberOfPages;
+
+    // Renders a (part of a) page into a square bitmap, for Android in the
+    // android.graphics.Bitmap.Config.ARGB_8888 format. Despite the name, the
+    // order of bytes is R,G,B,A. Is this reliable, or coincidental depending
+    // on Android version and/or hardware? TBD. Will the same format be useful
+    // also for iOS? TBD.
+
+    // buffer must have an exact number of bytes for a square number of
+    // pixels, At the UNO level buffer is represented as the address of its
+    // bytes, i.e. on Android it must be a "direct" ByteBuffer for that to be
+    // meaningful.
+
+    // listener gets a "reasonable" number of callbacks during the rendering
+    // if it takes "significantly" long, and can inerrupt the rendering.
+
+    // zoomLevel is 0 for whole page, 1 for tiled into four, etc.
+
+    // x and y are in [0..2^zoomLevel]
+
+    // Should we have this method copy the rendered buffer into a Bitmap
+    // instead and return that? A Bitmap is presumably what the caller wants
+    // anyway?
+
+    // Or should we just go OpenGL ES and render into a texture?
+
+    void render( [in] hyper buffer,
+                 [in] long bufferSize,
+                 [in] XDocumentRenderCallback listener,
+                 [in] long pageNo,
+                 [in] long zoomLevel,
+                 [in] long x,
+                 [in] long y)
+        raises( com::sun::star::lang::IllegalArgumentException );
+
+};
+
+}; }; };
+
+#endif
+
+// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/touch/idl/org/libreoffice/touch/XDocumentRenderCallback.idl 
b/touch/idl/org/libreoffice/touch/XDocumentRenderCallback.idl
new file mode 100644
index 0000000..62da11c
--- /dev/null
+++ b/touch/idl/org/libreoffice/touch/XDocumentRenderCallback.idl
@@ -0,0 +1,55 @@
+// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+// Copyright 2012 LibreOffice contributors.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License 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/.
+
+#ifndef org_libreoffice_touch_XDocumentRenderCallback_idl
+#define org_libreoffice_touch_XDocumentRenderCallback_idl
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module org { module libreoffice { module touch {
+
+interface XDocument;
+
+interface XDocumentRenderCallback: com::sun::star::uno::XInterface
+{
+
+    // Return false from any of the callbacks if the render result isn't
+    // wanted after all and the rendering should stop
+
+    // pageWidth and pageHeight are in [1..squareSide] where squareSide is
+    // the side of the render target square implied by the size of the
+    // buffer passed to render().
+
+    // This always called at the start of rendering one page
+
+    boolean start( [in] long pageWidth,
+                   [in] long pageHeight );
+
+  // Called with unspecified frequency during the rendering, possibly
+  // even not at all, but the intent is to call this with "reasonable"
+  // frquency if the rendering takes a "long" time. Maybe around ten
+  // times a second?
+
+  // There is no guarantee in which order the bitmap is being rendered
+
+  // fraction is in [0..1] and is an approximation of unknown exactness
+  // If the rendering code doesn't even bother guessing, it can pass
+  // zero all the time. The fraction in subsequent calls never
+  // decreases.
+
+  boolean progress( [in] float fraction );
+
+  // There is no callback when the rendering finishes; render() just
+  // returns.
+};
+
+}; }; };
+
+#endif
+
+// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/touch/inc/touch/libotouch.hxx b/touch/inc/touch/libotouch.hxx
new file mode 100644
index 0000000..acfa0c1
--- /dev/null
+++ b/touch/inc/touch/libotouch.hxx
@@ -0,0 +1,15 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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/.
+ */
+
+#ifndef _TOUCH_LIBOTOUCH_HXX
+#define _TOUCH_LIBOTOUCH_HXX
+
+#endif // _TOUCH_LIBOTOUCH_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/touch/prj/build.lst b/touch/prj/build.lst
new file mode 100644
index 0000000..4709170
--- /dev/null
+++ b/touch/prj/build.lst
@@ -0,0 +1 @@
+th     touch : sw sc
diff --git a/touch/prj/d.lst b/touch/prj/d.lst
new file mode 100644
index 0000000..e69de29
diff --git a/touch/source/generic/libotouch.cxx 
b/touch/source/generic/libotouch.cxx
new file mode 100644
index 0000000..ce572e1
--- /dev/null
+++ b/touch/source/generic/libotouch.cxx
@@ -0,0 +1,11 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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/.
+ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/touch/source/ios/ios.cxx b/touch/source/ios/ios.cxx
new file mode 100644
index 0000000..be06b70
--- /dev/null
+++ b/touch/source/ios/ios.cxx
@@ -0,0 +1,10 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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/.
+ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/touch/source/uno/Document.cxx b/touch/source/uno/Document.cxx
new file mode 100644
index 0000000..975e9cc
--- /dev/null
+++ b/touch/source/uno/Document.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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/.
+ */
+
+// NOTE: Work in progress, most likely makes little sense
+
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/awt/XToolkit.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/view/XRenderable.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <org/libreoffice/touch/Document.hpp>
+
+using namespace ::com::sun::star;
+
+using ::rtl::OUString;
+using ::osl::MutexGuard;
+
+namespace org { namespace libreoffice { namespace touch
+{
+
+class DocumentImpl:
+    public XDocument
+{
+
+private:
+    OUString m_sURI;
+    uno::Reference< uno::XComponentContext > m_rContext;
+    uno::Reference< lang::XComponent > m_xComponent;
+    uno::Reference< frame::XController > m_xController;
+    uno::Reference< view::XRenderable > m_xRenderable;
+
+    beans::PropertyValues m_aRenderProps;
+
+    typedef ::cppu::WeakImplHelper1< frame::XController > MyXController_Base;
+
+    class MyXController:
+        public MyXController_Base,
+        public ::cppu::BaseMutex
+    {
+    private:
+        uno::Reference< frame::XFrame > m_xFrame;
+        uno::Reference< frame::XModel > m_xModel;
+
+    public:
+        virtual void SAL_CALL
+        attachFrame( const uno::Reference< frame::XFrame >& xFrame )
+            throw( uno::RuntimeException )
+        {
+            m_xFrame = xFrame;
+        }
+
+        virtual sal_Bool SAL_CALL
+        attachModel( const uno::Reference< frame::XModel >& xModel )
+            throw( uno::RuntimeException )
+        {
+            m_xModel = xModel;
+            return sal_True;
+        }
+
+        virtual sal_Bool SAL_CALL
+        suspend( sal_Bool /* bSuspend */ )
+            throw( uno::RuntimeException )
+        {
+            return sal_False;
+        }
+
+        virtual uno::Any SAL_CALL getViewData()
+            throw( uno::RuntimeException )
+        {
+            return uno::Any();
+        }
+
+        virtual void SAL_CALL restoreViewData( const uno::Any& /* data */ )
+            throw ( uno::RuntimeException )
+        {
+        }
+
+        virtual uno::Reference< frame::XModel > SAL_CALL
+        getModel()
+            throw ( uno::RuntimeException )
+        {
+            return m_xModel;
+        }
+
+        virtual uno::Reference< frame::XFrame > SAL_CALL
+        getFrame()
+            throw ( uno::RuntimeException )
+        {
+            return m_xFrame;
+        }
+
+        virtual void SAL_CALL
+        dispose()
+            throw ( uno::RuntimeException )
+        {
+        }
+
+        virtual void SAL_CALL
+        addEventListener( const uno::Reference< lang::XEventListener >& /* 
xListener */ )
+            throw ( uno::RuntimeException )
+        {
+        }
+
+        virtual void SAL_CALL
+        removeEventListener( const uno::Reference< lang::XEventListener >& /* 
xListener */ )
+            throw ( uno::RuntimeException )
+        {
+        }
+    };
+
+protected:
+    DocumentImpl( const uno::Reference< uno::XComponentContext > context ):
+        m_rContext( context )
+    {
+    }
+
+    virtual ~DocumentImpl()
+    {
+    }
+
+    // XInitialization
+    virtual void SAL_CALL
+    initialize( const uno::Sequence< uno::Any >& arguments )
+        throw ( uno::Exception, uno::RuntimeException )
+    {
+        if ( arguments.getLength() != 1 )
+            throw lang::IllegalArgumentException( OUString(), 
static_cast<uno::Reference< uno::XInterface> >(this), 1 );
+
+        uno::Sequence< beans::NamedValue > settings;
+        if ( arguments[0] >>= m_sURI )
+        {
+            // create( [in] string uri );
+            uno::Reference< frame::XDesktop > desktop( 
m_rContext->getServiceManager()->createInstanceWithContext( 
"com.sun.star.frame.Desktop", m_rContext ), uno::UNO_QUERY_THROW );
+            uno::Reference< frame::XComponentLoader > componentLoader( 
desktop, uno::UNO_QUERY_THROW );
+
+            (void) componentLoader;
+
+            beans::PropertyValues loadProps(3);
+            loadProps[0].Name = "Hidden";
+            loadProps[0].Value <<= sal_Bool(true);
+            loadProps[1].Name = "ReadOnly";
+            loadProps[1].Value <<= sal_Bool(true);
+            loadProps[2].Name = "Preview";
+            loadProps[2].Value <<= sal_Bool(true);
+
+            m_xComponent = componentLoader->loadComponentFromURL( m_sURI, 
"_blank", 0, loadProps );
+
+            uno::Reference< awt::XToolkit > toolkit( 
m_rContext->getServiceManager()->createInstanceWithContext( 
"com.sun.star.awt.Toolkit", m_rContext ), uno::UNO_QUERY_THROW );
+
+            uno::Reference< awt::XDevice > device( 
toolkit->createScreenCompatibleDevice( 1024, 1024 ) );
+
+            m_xRenderable = uno::Reference< view::XRenderable 
>(m_rContext->getServiceManager()->createInstanceWithContext( 
"com.sun.star.view.Renderable", m_rContext ), uno::UNO_QUERY_THROW );
+
+            m_xController = new MyXController();
+
+            m_aRenderProps.realloc( 3 );
+            m_aRenderProps[0].Name = "IsPrinter";
+            m_aRenderProps[0].Value <<= sal_Bool(true);
+            m_aRenderProps[1].Name = "RenderDevice";
+            m_aRenderProps[1].Value <<= device;
+            m_aRenderProps[2].Name = "View";
+            m_aRenderProps[2].Value <<= m_xController;
+        }
+    }
+
+    // XDocument
+    virtual sal_Int32 SAL_CALL
+    getNumberOfPages()
+        throw ( uno::RuntimeException )
+    {
+        uno::Any selection;
+        selection <<= m_xComponent;
+
+        return m_xRenderable->getRendererCount( selection, m_aRenderProps );
+    }
+
+    virtual void SAL_CALL
+    render( sal_Int64 buffer,
+            sal_Int32 bufferSize,
+            const uno::Reference< XDocumentRenderCallback >& listener,
+            sal_Int32 pageNo,
+            sal_Int32 zoomLevel,
+            sal_Int32 x,
+            sal_Int32 y )
+        throw ( lang::IllegalArgumentException, uno::RuntimeException)
+    {
+        (void) buffer;
+        (void) bufferSize;
+        (void) listener;
+        (void) pageNo;
+        (void) zoomLevel;
+        (void) x;
+        (void) y ;
+    }
+
+};
+
+} } } // namespace org::libreoffice::touch
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to