[Libreoffice-commits] core.git: 3 commits - desktop/source include/LibreOfficeKit ios/CustomTarget_TiledLibreOffice_app.mk ios/experimental

Tor Lillqvist tml at collabora.com
Wed Feb 4 09:08:58 PST 2015


 desktop/source/app/officeipcthread.cxx                                       |   24 +++-
 desktop/source/app/sofficemain.cxx                                           |   12 --
 desktop/source/lib/init.cxx                                                  |   21 +++
 include/LibreOfficeKit/LibreOfficeKitInit.h                                  |   12 +-
 ios/CustomTarget_TiledLibreOffice_app.mk                                     |   13 +-
 ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj |   20 +--
 ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m             |   53 +---------
 ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h               |    5 
 ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m               |   21 ++-
 ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h                    |    3 
 ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m                    |   21 ++-
 ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm                     |    5 
 12 files changed, 114 insertions(+), 96 deletions(-)

New commits:
commit 4b269ecb7a699318b067eb64c464460b1783d3d2
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Feb 4 17:48:41 2015 +0100

    Use LibreOfficeKit in the TiledLibreOffice iOS demo app, too
    
    For iOS, the pBuffer argument to LibreOfficeKitDocument::paintTile()
    is not a pixel buffer, but a CGContextRef. Thus we can keep the
    existing CGContext-oriented vcl code for iOS as is.
    
    I commented out the <touch/touch.h> -using code in sw, and it probably
    would be OK to just kill <touch/touch.h> and remove use and
    implementations of its API. I don't think they are used by our current
    Android or iOS code.
    
    This concludes the commits of the work I did at the post-FOSDEM
    hackfest and on the flight home. TiledLibreOffice now works as before,
    but uses LibreOfficeKit.
    
    Change-Id: Ibbde6e11d660561840eab6335f7fc0db6758173e

diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 58fa25a..c5f2367 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -449,12 +449,12 @@ void OfficeIPCThread::RequestsCompleted( int nCount )
 
 OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
 {
-#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
     ::osl::MutexGuard   aGuard( GetMutex() );
 
     if( pGlobalOfficeIPCThread.is() )
         return IPC_STATUS_OK;
 
+#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
     OUString aUserInstallPath;
     OUString aDummy;
 
@@ -605,14 +605,15 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
         return IPC_STATUS_2ND_OFFICE;
     }
 #else
-    pGlobalOfficeIPCThread = rtl::Reference< OfficeIPCThread >(new OfficeIPCThread);
+    rtl::Reference< OfficeIPCThread > pThread(new OfficeIPCThread);
+    pGlobalOfficeIPCThread = pThread;
+    pThread->launch();
 #endif
     return IPC_STATUS_OK;
 }
 
 void OfficeIPCThread::DisableOfficeIPCThread(bool join)
 {
-#if HAVE_FEATURE_DESKTOP || defined(ANDROID)
     osl::ClearableMutexGuard aMutex( GetMutex() );
 
     if( pGlobalOfficeIPCThread.is() )
@@ -635,9 +636,6 @@ void OfficeIPCThread::DisableOfficeIPCThread(bool join)
             pOfficeIPCThread->join();
         }
     }
-#else
-     (void) join;
-#endif
 }
 
 OfficeIPCThread::OfficeIPCThread() :
@@ -967,6 +965,20 @@ void OfficeIPCThread::execute()
             salhelper::Thread::wait( tval );
         }
     } while( schedule() );
+#else
+
+#if 0 // Seems to work fine to let this thread just die?
+
+    // Not sure what to do, so wait forever. Note that on iOS (or
+    // Android, but in this case ANDROID is handled like DESKTOP, see
+    // above) an app never exits voluntarily, but is always killed by
+    // the system when its resources are needed.)
+    TimeValue tval;
+    tval.Seconds = 100000;
+    tval.Nanosec = 0;
+    salhelper::Thread::wait( tval );
+#endif
+
 #endif
 }
 
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index 9cee2c4..0597a4f 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -49,10 +49,6 @@
 #  define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
 #endif
 
-#ifdef IOS
-#include <touch/touch.h>
-#endif
-
 extern "C" int DESKTOP_DLLPUBLIC soffice_main()
 {
 #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
@@ -114,22 +110,16 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
 extern "C" SAL_JNI_EXPORT void JNICALL
 Java_org_libreoffice_android_AppSupport_runMain(JNIEnv* /* env */,
                                                 jobject /* clazz */)
-#else
-extern "C"
-void
-touch_lo_runMain()
-#endif
 {
     int nRet;
     do {
         nRet = soffice_main();
-#ifdef ANDROID
         LOGI("soffice_main returned %d", nRet);
-#endif
     } while (nRet == EXITHELPER_NORMAL_RESTART ||
              nRet == EXITHELPER_CRASH_WITH_RESTART); // pretend to re-start.
 
 }
+#endif
 
 extern "C" void PtylTestEncryptionAndExport(const char *pathname)
 {
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c79db3b..940f413 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -50,9 +50,8 @@
 #include <app.hxx>
 #include <salinst.hxx>
 
-// Tiled Rendering is Linux only for now.
 #if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
-// And let's also grab the SvpSalInstance and SvpSalVirtualDevice
+// Let's grab the SvpSalInstance and SvpSalVirtualDevice
 #include <headless/svpinst.hxx>
 #include <headless/svpframe.hxx>
 #include <headless/svpvd.hxx>
@@ -582,6 +581,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
     SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
     pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
 
+#ifndef IOS
     VirtualDevice aDevice(0, Size(1, 1), (sal_uInt16)32);
     boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
     aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
@@ -596,6 +596,18 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
 
     *pRowStride = pBmpDev->getScanlineStride();
 #else
+    SystemGraphicsData aData;
+    aData.rCGContext = reinterpret_cast<CGContextRef>(pBuffer);
+    // the Size argument is irrelevant, I hope
+    VirtualDevice aDevice(&aData, Size(1, 1), (sal_uInt16)0);
+
+    pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
+                    nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+
+    (void) pRowStride;
+#endif
+
+#else
     (void) pBuffer;
     (void) nCanvasWidth;
     (void) nCanvasHeight;
diff --git a/ios/CustomTarget_TiledLibreOffice_app.mk b/ios/CustomTarget_TiledLibreOffice_app.mk
index d578d23..f9f8028 100644
--- a/ios/CustomTarget_TiledLibreOffice_app.mk
+++ b/ios/CustomTarget_TiledLibreOffice_app.mk
@@ -50,14 +50,14 @@ TiledLibreOffice_setup:
 	# Resources #
 	rm -rf $(TiledLibreOffice_resource) 2>/dev/null
 	mkdir -p $(TiledLibreOffice_resource)
-	mkdir -p $(TiledLibreOffice_resource)/ure
+	mkdir -p $(TiledLibreOffice_resource)/services
 
 	# copy rdb files
-	cp $(INSTDIR)/program/types.rdb	            $(TiledLibreOffice_resource)
+	cp $(INSTDIR)/program/types.rdb	            $(TiledLibreOffice_resource)/udkapi.rdb
 	cp $(INSTDIR)/program/types/offapi.rdb      $(TiledLibreOffice_resource)
 	cp $(INSTDIR)/program/types/oovbaapi.rdb  	$(TiledLibreOffice_resource)
-	cp $(INSTDIR)/program/services/services.rdb $(TiledLibreOffice_resource)
-	cp $(INSTDIR)/program/services.rdb          $(TiledLibreOffice_resource)/ure
+	cp $(INSTDIR)/program/services/services.rdb $(TiledLibreOffice_resource)/services
+	cp $(INSTDIR)/program/services.rdb          $(TiledLibreOffice_resource)
 
 	# copy .res files
 	# program/resource is hardcoded in tools/source/rc/resmgr.cxx. Sure,
@@ -93,7 +93,10 @@ TiledLibreOffice_setup:
 	echo '[Bootstrap]'                                      >  $$file; \
 	echo 'LO_LIB_DIR=file://$$APP_DATA_DIR/lib/'            >> $$file; \
 	echo 'BRAND_BASE_DIR=file://$$APP_DATA_DIR'             >> $$file; \
-	echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry res:$${BRAND_BASE_DIR}/registry' >> $$file;
+	echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry res:$${BRAND_BASE_DIR}/registry' >> $$file; \
+	echo 'UNO_TYPES=file://$$APP_DATA_DIR/udkapi.rdb file://$$APP_DATA_DIR/offapi.rdb' >> $$file; \
+	echo 'UNO_SERVICES=file://$$APP_DATA_DIR/services.rdb file://$$APP_DATA_DIR/services/services.rdb' >> $$file; \
+	echo 'OSL_SOCKET_PATH=$$APP_DATA_DIR/cache' >> $$file
 
 	file=$(TiledLibreOffice_resource)/unorc; \
 	echo '[Bootstrap]' > $$file;
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj b/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
index 1b418bb..c5d9a6c2 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice.xcodeproj/project.pbxproj
@@ -24,7 +24,7 @@
 		BED2594118F6B89000C94C72 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED2594018F6B89000C94C72 /* MobileCoreServices.framework */; };
 		BEEE02D11860ABDB00FBDE67 /* program in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02CE1860ABB700FBDE67 /* program */; };
 		BEEE02D21860ABDB00FBDE67 /* share in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02CF1860ABB700FBDE67 /* share */; };
-		BEEE02D31860ABDB00FBDE67 /* ure in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02D01860ABB700FBDE67 /* ure */; };
+		BEEE02D31860ABDB00FBDE67 /* services in Resources */ = {isa = PBXBuildFile; fileRef = BEEE02D01860ABB700FBDE67 /* services */; };
 		BEEEF9641860740400FBDE67 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BEEEF9631860740400FBDE67 /* libiconv.dylib */; };
 		BEEEF9661860741400FBDE67 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BEEEF9651860741400FBDE67 /* libz.dylib */; };
 		BEEEF96A1860A25400FBDE67 /* test1.odt in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF9691860A25400FBDE67 /* test1.odt */; };
@@ -33,7 +33,7 @@
 		BEEEFE031860A89100FBDE67 /* oovbaapi.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF96F1860A82900FBDE67 /* oovbaapi.rdb */; };
 		BEEEFE041860A89100FBDE67 /* rc in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF9AA1860A82900FBDE67 /* rc */; };
 		BEEEFE051860A89100FBDE67 /* services.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEF9AB1860A82900FBDE67 /* services.rdb */; };
-		BEEEFE061860A89100FBDE67 /* types.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEFDFD1860A82C00FBDE67 /* types.rdb */; };
+		BEEEFE061860A89100FBDE67 /* udkapi.rdb in Resources */ = {isa = PBXBuildFile; fileRef = BEEEFDFD1860A82C00FBDE67 /* udkapi.rdb */; };
 		BEEEFE071860A89100FBDE67 /* unorc in Resources */ = {isa = PBXBuildFile; fileRef = BEEEFDFE1860A82C00FBDE67 /* unorc */; };
 /* End PBXBuildFile section */
 
@@ -449,7 +449,7 @@
 		BE6DC92E19D9B5DD00AFB393 /* mutex.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = mutex.c; path = ../../../sal/osl/unx/mutex.c; sourceTree = "<group>"; };
 		BE6DC92F19D9B5DD00AFB393 /* nlsupport.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = nlsupport.c; path = ../../../sal/osl/unx/nlsupport.c; sourceTree = "<group>"; };
 		BE6DC93019D9B5DD00AFB393 /* osxlocale.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = osxlocale.cxx; path = ../../../sal/osl/unx/osxlocale.cxx; sourceTree = "<group>"; };
-		BE6DC93119D9B5DD00AFB393 /* pipe.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = pipe.c; path = ../../../sal/osl/unx/pipe.c; sourceTree = "<group>"; };
+		BE6DC93119D9B5DD00AFB393 /* pipe.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = pipe.cxx; path = ../../../sal/osl/unx/pipe.cxx; sourceTree = "<group>"; };
 		BE6DC93219D9B5DD00AFB393 /* process_impl.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = process_impl.cxx; path = ../../../sal/osl/unx/process_impl.cxx; sourceTree = "<group>"; };
 		BE6DC93319D9B5DD00AFB393 /* process.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = process.cxx; path = ../../../sal/osl/unx/process.cxx; sourceTree = "<group>"; };
 		BE6DC93419D9B5DD00AFB393 /* profile.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = profile.cxx; path = ../../../sal/osl/unx/profile.cxx; sourceTree = "<group>"; };
@@ -898,7 +898,7 @@
 		BEDB0F08185B7537009A6F26 /* lo.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = lo.xcconfig; path = ../../../lo.xcconfig; sourceTree = "<group>"; };
 		BEEE02CE1860ABB700FBDE67 /* program */ = {isa = PBXFileReference; lastKnownFileType = folder; name = program; path = Resources/program; sourceTree = SOURCE_ROOT; };
 		BEEE02CF1860ABB700FBDE67 /* share */ = {isa = PBXFileReference; lastKnownFileType = folder; name = share; path = Resources/share; sourceTree = SOURCE_ROOT; };
-		BEEE02D01860ABB700FBDE67 /* ure */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ure; path = Resources/ure; sourceTree = SOURCE_ROOT; };
+		BEEE02D01860ABB700FBDE67 /* services */ = {isa = PBXFileReference; lastKnownFileType = folder; name = services; path = Resources/services; sourceTree = SOURCE_ROOT; };
 		BEEEF9631860740400FBDE67 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
 		BEEEF9651860741400FBDE67 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
 		BEEEF9691860A25400FBDE67 /* test1.odt */ = {isa = PBXFileReference; lastKnownFileType = file; name = test1.odt; path = ../../../../odk/examples/java/DocumentHandling/test/test1.odt; sourceTree = "<group>"; };
@@ -907,7 +907,7 @@
 		BEEEF96F1860A82900FBDE67 /* oovbaapi.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = oovbaapi.rdb; path = Resources/oovbaapi.rdb; sourceTree = SOURCE_ROOT; };
 		BEEEF9AA1860A82900FBDE67 /* rc */ = {isa = PBXFileReference; lastKnownFileType = text; name = rc; path = Resources/rc; sourceTree = SOURCE_ROOT; };
 		BEEEF9AB1860A82900FBDE67 /* services.rdb */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = services.rdb; path = Resources/services.rdb; sourceTree = SOURCE_ROOT; };
-		BEEEFDFD1860A82C00FBDE67 /* types.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = types.rdb; path = Resources/types.rdb; sourceTree = SOURCE_ROOT; };
+		BEEEFDFD1860A82C00FBDE67 /* udkapi.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = udkapi.rdb; path = Resources/udkapi.rdb; sourceTree = SOURCE_ROOT; };
 		BEEEFDFE1860A82C00FBDE67 /* unorc */ = {isa = PBXFileReference; lastKnownFileType = text; name = unorc; path = Resources/unorc; sourceTree = SOURCE_ROOT; };
 /* End PBXFileReference section */
 
@@ -1539,7 +1539,7 @@
 				BE6DC92E19D9B5DD00AFB393 /* mutex.c */,
 				BE6DC92F19D9B5DD00AFB393 /* nlsupport.c */,
 				BE6DC93019D9B5DD00AFB393 /* osxlocale.cxx */,
-				BE6DC93119D9B5DD00AFB393 /* pipe.c */,
+				BE6DC93119D9B5DD00AFB393 /* pipe.cxx */,
 				BE6DC93219D9B5DD00AFB393 /* process_impl.cxx */,
 				BE6DC93319D9B5DD00AFB393 /* process.cxx */,
 				BE6DC93419D9B5DD00AFB393 /* profile.cxx */,
@@ -2237,9 +2237,9 @@
 				BEEEF9AA1860A82900FBDE67 /* rc */,
 				BEEEF9AB1860A82900FBDE67 /* services.rdb */,
 				BEEE02CF1860ABB700FBDE67 /* share */,
-				BEEEFDFD1860A82C00FBDE67 /* types.rdb */,
+				BEEEFDFD1860A82C00FBDE67 /* udkapi.rdb */,
 				BEEEFDFE1860A82C00FBDE67 /* unorc */,
-				BEEE02D01860ABB700FBDE67 /* ure */,
+				BEEE02D01860ABB700FBDE67 /* services */,
 				BEEEF9691860A25400FBDE67 /* test1.odt */,
 				BE03BF9218F9A7CC00620DC7 /* icudt54l.dat */,
 			);
@@ -2308,9 +2308,9 @@
 				BEEEFE051860A89100FBDE67 /* services.rdb in Resources */,
 				BEEE02D21860ABDB00FBDE67 /* share in Resources */,
 				BE03BF9318F9A7CC00620DC7 /* icudt54l.dat in Resources */,
-				BEEEFE061860A89100FBDE67 /* types.rdb in Resources */,
+				BEEEFE061860A89100FBDE67 /* udkapi.rdb in Resources */,
 				BEEEFE071860A89100FBDE67 /* unorc in Resources */,
-				BEEE02D31860ABDB00FBDE67 /* ure in Resources */,
+				BEEE02D31860ABDB00FBDE67 /* services in Resources */,
 				BEEEF96A1860A25400FBDE67 /* test1.odt in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
index 17fa433..652496c 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m
@@ -6,7 +6,8 @@
 // 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/.
 
-#include <touch/touch.h>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitInit.h>
 
 #import "AppDelegate.h"
 #import "DocumentTableViewController.h"
@@ -17,12 +18,14 @@
 @interface AppDelegate ()
 
 - (void)showDocumentList:(NSArray*)documents inFolder:(NSString*)folder;
-- (void)threadMainMethod:(NSString *)documentPath;
 
 @end
 
 @implementation AppDelegate
 
+static LibreOfficeKit* kit;
+static LibreOfficeKitDocument* document;
+
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
@@ -72,16 +75,11 @@ const char *ptyl_test_encryption_pathname;
 
     ptyl_test_encryption_pathname = [documentPath UTF8String];
 
-    [[[NSThread alloc] initWithTarget:self selector:@selector(threadMainMethod:) object:documentPath] start];
-    vc.view = [[View alloc] initWithFrame:[self.window frame]];
-}
-
-- (void)threadMainMethod:(NSString *)documentPath
-{
-    @autoreleasepool {
-        lo_initialize(documentPath);
-        touch_lo_runMain();
-    }
+    // kit = lok_init([[[NSBundle mainBundle] bundlePath] UTF8String]);
+    kit = lok_init(NULL);
+    document = kit->pClass->documentLoad(kit, [documentPath UTF8String]);
+    document->pClass->initializeForRendering(document);
+    vc.view = [[View alloc] initWithFrame:[self.window frame] kit:kit document:document];
 }
 
 - (void)showDocumentList:(NSArray*)documents inFolder:(NSString*)folder
@@ -133,35 +131,4 @@ const char *ptyl_test_encryption_pathname;
 
 @end
 
-// dummies
-
-void touch_ui_selection_start(MLOSelectionKind kind,
-                              const void *documentHandle,
-                              MLORect *rectangles,
-                              int rectangleCount,
-                              void *preview)
-{
-}
-
-void touch_ui_selection_none()
-{
-}
-
-MLODialogResult touch_ui_dialog_modal(MLODialogKind kind, const char *message)
-{
-    return MLODialogCancel;
-}
-
-void touch_ui_show_keyboard()
-{
-}
-
-void touch_ui_hide_keyboard()
-{
-}
-
-void touch_ui_damaged(int minX, int minY, int width, int height)
-{
-}
-
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h
index 2b228e6..d0d20c3 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.h
@@ -8,9 +8,12 @@
 
 #import <UIKit/UIKit.h>
 
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
 @interface TiledView : UIView
 
-- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom;
+- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom document:(LibreOfficeKitDocument*)document;
 
 @end
 
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
index 1b8b8c2..4092379 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
@@ -8,7 +8,8 @@
 
 #include <CoreText/CoreText.h>
 
-#include <touch/touch.h>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
 
 #import "View.h"
 #import "TiledView.h"
@@ -31,6 +32,8 @@ static struct {
 static int oldestTimestampIndex = 0;
 static int nextTimestampIndex = 0;
 
+static LibreOfficeKitDocument* loDocument;
+
 static void dropOldTimestamps(CFTimeInterval now)
 {
     // Drop too old timestamps
@@ -96,8 +99,10 @@ int DBG_DRAW_ROUNDS_MAX = INT_MAX;
         [NSTimer scheduledTimerWithTimeInterval:DBG_DRAW_DELAY target:self selector:@selector(redraw) userInfo:nil repeats:NO];
 }
 
-- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom
+- (id)initWithFrame:(CGRect)frame scale:(CGFloat)scale maxZoom:(int)maxZoom document:(LibreOfficeKitDocument*)document
 {
+    loDocument = document;
+
     self = [super initWithFrame:frame];
     if (self) {
         self.scale = scale;
@@ -157,7 +162,7 @@ extern const char *ptyl_test_encryption_pathname;
     // CGSize tileSize = [catl tileSize];
     CGSize tileSize = bb.size;
 
-    // NSLog(@"bb:%.0fx%.0f@(%.0f,%.0f) zoomScale:%.0f tile:%.0fx%.0f at:(%.0f,%.0f) size:%.0fx%.0f", bb.size.width, bb.size.height, bb.origin.x, bb.origin.y, zoomScale, tileSize.width, tileSize.height, bb.origin.x/self.scale, bb.origin.y/self.scale, bb.size.width/self.scale, bb.size.height/self.scale);
+    NSLog(@"bb:%.0fx%.0f@(%.0f,%.0f) zoomScale:%.0f tile:%.0fx%.0f at:(%.0f,%.0f) size:%.0fx%.0f", bb.size.width, bb.size.height, bb.origin.x, bb.origin.y, [((View *) [self superview]) zoomScale], tileSize.width, tileSize.height, bb.origin.x/self.scale, bb.origin.y/self.scale, bb.size.width/self.scale, bb.size.height/self.scale);
 
     // I don't really claim to fully understand all this. It did at
     // first seem a bit weird to be passing in a "context width x
@@ -171,10 +176,12 @@ extern const char *ptyl_test_encryption_pathname;
 
     if (!getenv("DRAW_ONLY_TILE") || tileMatches(getenv("DRAW_ONLY_TILE"), bb)) {
         fprintf(stderr, "+++ rendering to context %p\n", ctx);
-        touch_lo_draw_tile(ctx,
-                           tileSize.width, tileSize.height,
-                           CGPointMake(bb.origin.x/self.scale, bb.origin.y/self.scale),
-                           CGSizeMake(bb.size.width/self.scale, bb.size.height/self.scale));
+        int rowStride;
+        loDocument->pClass->paintTile(loDocument, (unsigned char *)ctx,
+                                      tileSize.width, tileSize.height,
+                                      &rowStride,
+                                      bb.origin.x/self.scale, bb.origin.y/self.scale,
+                                      bb.size.width/self.scale, bb.size.height/self.scale);
     } else {
         CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
         CGContextFillRect(ctx, CGRectMake(0, 0, bb.size.width, bb.size.height));
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
index 041471d..c426956 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
@@ -7,9 +7,12 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 #import <UIKit/UIKit.h>
+#import <LibreOfficeKit/LibreOfficeKit.h>
 
 @interface View : UIScrollView <UIScrollViewDelegate>
 
+- (id)initWithFrame:(CGRect)frame kit:(LibreOfficeKit*)kit document:(LibreOfficeKitDocument*)document;
+
 @property UILabel *tpsLabel;
 
 @end
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
index 76ede6f..33690e1 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
@@ -6,7 +6,8 @@
 // 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/.
 
-#include <touch/touch.h>
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
 
 #import "View.h"
 #import "TiledView.h"
@@ -19,8 +20,13 @@
 
 @implementation View
 
-- (id)initWithFrame:(CGRect)frame
+static LibreOfficeKit* loKit;
+static LibreOfficeKitDocument* loDocument;
+
+- (id)initWithFrame:(CGRect)frame kit:(LibreOfficeKit*)kit document:(LibreOfficeKitDocument*)document
 {
+    loKit = kit;
+    loDocument = document;
     self = [super initWithFrame:frame];
     if (self) {
         const int MAXZOOM = 8;
@@ -28,14 +34,15 @@
         [self setMaximumZoomScale:MAXZOOM];
         [self setDelegate:self];
 
-        MLODpxSize docSize = touch_lo_get_content_size();
+        long docWidth, docHeight;
+        document->pClass->getDocumentSize(document, &docWidth, &docHeight);
 
-        double widthScale = frame.size.width / docSize.width;
-        double docAspectRatio = docSize.height / docSize.width;
+        double widthScale = frame.size.width / docWidth;
+        double docAspectRatio = docHeight / docWidth;
 
-        // NSLog(@"View frame=%.0fx%.0f docSize=%.0fx%.0f scale=%.3f aspectRatio=%.3f", frame.size.width, frame.size.height, docSize.width, docSize.height, widthScale, docAspectRatio);
+        // NSLog(@"View frame=%.0fx%.0f docSize=%.0fx%.0f scale=%.3f aspectRatio=%.3f", frame.size.width, frame.size.height, docWidth, docHeight, widthScale, docAspectRatio);
 
-        self.subView = [[TiledView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.width*docAspectRatio) scale:widthScale maxZoom:MAXZOOM];
+        self.subView = [[TiledView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.width*docAspectRatio) scale:widthScale maxZoom:MAXZOOM document:loDocument];
         [self addSubview:self.subView];
 
         UILabel *tpsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 300, 40)];
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
index de02cff..f41593d 100644
--- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
+++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/lo.mm
@@ -15,7 +15,6 @@
 #include <postmac.h>
 
 #include <osl/process.h>
-#include <touch/touch.h>
 
 #include <unicode/udata.h>
 #include <unicode/ucnv.h>
@@ -43,6 +42,10 @@ static NSString *createPaths(NSString *base, NSString *appRootEscaped, NSArray *
     return result;
 }
 
+// Force reference to libreofficekit_hook
+extern "C" void *libreofficekit_hook(const char *);
+static __attribute__((used)) void *(*foop)(const char *) = libreofficekit_hook;
+
 extern "C" void lo_initialize(NSString *documentPath)
 {
     NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
commit ac8a2dee02032db2523888927f7973b219f3a9a9
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Feb 4 17:41:55 2015 +0100

    Adapt for iOS, too
    
    Change-Id: Ic5c6d6501d477544c6e4a4d6bb2510b6a5a92956

diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index b6552a2..a6599fd 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -17,7 +17,7 @@ extern "C"
 {
 #endif
 
-#if defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) || defined(_WIN32)
+#if defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) || defined(_WIN32) || defined(__APPLE__)
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -117,10 +117,12 @@ typedef LibreOfficeKit *(HookFunction)( const char *install_path);
 static LibreOfficeKit *lok_init( const char *install_path )
 {
     char *imp_lib;
-    size_t partial_length;
     void *dlhandle;
     HookFunction *pSym;
 
+#if !(defined(__APPLE__) && defined(__arm__))
+    size_t partial_length;
+
     if (!install_path)
         return NULL;
 
@@ -154,6 +156,10 @@ static LibreOfficeKit *lok_init( const char *install_path )
             return NULL;
         }
     }
+#else
+    imp_lib = strdup("the app executable");
+    dlhandle = RTLD_MAIN_ONLY;
+#endif
 
     pSym = (HookFunction *) _dlsym( dlhandle, "libreofficekit_hook" );
     if (!pSym)
@@ -168,7 +174,7 @@ static LibreOfficeKit *lok_init( const char *install_path )
     return pSym( install_path );
 }
 
-#endif // defined(__linux__) || defined(_AIX)
+#endif // defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) || defined(_WIN32) || defined(__APPLE__)
 
 #ifdef __cplusplus
 }
commit 57853ab7ace0ccc2c2953d7153fdce8d1be3c20d
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Feb 3 15:47:53 2015 +0100

    For iOS we already hardocde the inifile as rc in the .app directory
    
    Change-Id: I5971aa4db91adc89f8aeeb7384a1893dab329411

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 498ef80..c79db3b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -711,7 +711,12 @@ static void aBasicErrorFunc(const OUString& rError, const OUString& rAction)
 
 static bool initialize_uno(const OUString& aAppProgramURL)
 {
+#ifdef IOS
+    // For iOS we already hardocde the inifile as "rc" in the .app directory.
+    (void) aAppProgramURL;
+#else
     rtl::Bootstrap::setIniFilename(aAppProgramURL + "/" SAL_CONFIGFILE("soffice"));
+#endif
 
     xContext = cppu::defaultBootstrap_InitialComponentContext();
     if (!xContext.is())


More information about the Libreoffice-commits mailing list