[Libreoffice-commits] online.git: 3 commits - ios/ios.h ios/ios.mm kit/Kit.cpp Mobile/Mobile Mobile/Mobile.xcodeproj

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 21 07:30:27 UTC 2018


 Mobile/Mobile.xcodeproj/project.pbxproj |   54 +++++++++++++++++++++++++++++---
 Mobile/Mobile/Info.plist                |   33 +++++++++++++++----
 ios/ios.h                               |    6 ++-
 ios/ios.mm                              |   27 ++++++++++++++++
 kit/Kit.cpp                             |   34 ++++++++++++++++++--
 5 files changed, 139 insertions(+), 15 deletions(-)

New commits:
commit 72be8e3ad7fdc6eff85d5e33ec6b797b516aa1f8
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Sep 21 10:28:08 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Sep 21 10:29:56 2018 +0300

    Add some source files from core to the project
    
    For easier setting of breakpooints in them, in advance before stepping
    into their code.

diff --git a/Mobile/Mobile.xcodeproj/project.pbxproj b/Mobile/Mobile.xcodeproj/project.pbxproj
index da86e716c..e45f74138 100644
--- a/Mobile/Mobile.xcodeproj/project.pbxproj
+++ b/Mobile/Mobile.xcodeproj/project.pbxproj
@@ -31,6 +31,7 @@
 		BE5EB5D621401E0F00E0826C /* Storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE5EB5D521401E0F00E0826C /* Storage.cpp */; };
 		BE5EB5DA2140363100E0826C /* ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = BE5EB5D92140363100E0826C /* ios.mm */; };
 		BE5EB5DC2140480B00E0826C /* icudt62l.dat in Resources */ = {isa = PBXBuildFile; fileRef = BE5EB5DB2140480B00E0826C /* icudt62l.dat */; };
+		BE6362C22153B5B500F4237E /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE6362C12153B5B500F4237E /* MobileCoreServices.framework */; };
 		BE8D772C2136762500AC58EA /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = BE8D772B2136762500AC58EA /* AppDelegate.mm */; };
 		BE8D772F2136762500AC58EA /* DocumentBrowserViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BE8D772E2136762500AC58EA /* DocumentBrowserViewController.mm */; };
 		BE8D77322136762500AC58EA /* DocumentViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BE8D77312136762500AC58EA /* DocumentViewController.mm */; };
@@ -87,6 +88,15 @@
 		BE5EB5D92140363100E0826C /* ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ios.mm; path = ../../ios/ios.mm; sourceTree = "<group>"; };
 		BE5EB5DB2140480B00E0826C /* icudt62l.dat */ = {isa = PBXFileReference; lastKnownFileType = file; name = icudt62l.dat; path = "$(LOBUILDDIR)/workdir/CustomTarget/ios/resources/icudt62l.dat"; sourceTree = "<group>"; };
 		BE636210215101D000F4237E /* WebSocketHandler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WebSocketHandler.hpp; sourceTree = "<group>"; };
+		BE6362C02153A7B500F4237E /* init.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = init.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/desktop/source/lib/init.cxx"; sourceTree = "<group>"; };
+		BE6362C12153B5B500F4237E /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
+		BE6362D22154479000F4237E /* ctfonts.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = ctfonts.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/vcl/quartz/ctfonts.cxx"; sourceTree = "<group>"; };
+		BE6362D32154479000F4237E /* salvd.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = salvd.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/vcl/quartz/salvd.cxx"; sourceTree = "<group>"; };
+		BE6362D42154479000F4237E /* salbmp.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = salbmp.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/vcl/quartz/salbmp.cxx"; sourceTree = "<group>"; };
+		BE6362D52154479000F4237E /* utils.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = utils.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/vcl/quartz/utils.cxx"; sourceTree = "<group>"; };
+		BE6362D62154479000F4237E /* salgdi.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = salgdi.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/vcl/quartz/salgdi.cxx"; sourceTree = "<group>"; };
+		BE6362D72154479000F4237E /* salgdicommon.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = salgdicommon.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/vcl/quartz/salgdicommon.cxx"; sourceTree = "<group>"; };
+		BE6362D82154479000F4237E /* salgdiutils.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = salgdiutils.cxx; path = "../../../../../Volumes/TML13/lo/ios-device/vcl/quartz/salgdiutils.cxx"; sourceTree = "<group>"; };
 		BE8D77272136762500AC58EA /* Mobile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Mobile.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		BE8D772A2136762500AC58EA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		BE8D772B2136762500AC58EA /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; };
@@ -130,6 +140,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				BE6362C22153B5B500F4237E /* MobileCoreServices.framework in Frameworks */,
 				BEA2835A21470A1C00848631 /* WebKit.framework in Frameworks */,
 				BE00F8B7213ED573001CE2D4 /* libz.tbd in Frameworks */,
 				BE00F8B5213ED543001CE2D4 /* libiconv.tbd in Frameworks */,
@@ -171,6 +182,7 @@
 		BE00F8B3213ED542001CE2D4 /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				BE6362C12153B5B500F4237E /* MobileCoreServices.framework */,
 				BEA2835921470A1C00848631 /* WebKit.framework */,
 				BE00F8B6213ED573001CE2D4 /* libz.tbd */,
 				BE00F8B4213ED543001CE2D4 /* libiconv.tbd */,
@@ -186,8 +198,9 @@
 				BEA2835B21498ABF00848631 /* net */,
 				BE5EB5B7213FE21600E0826C /* wsd */,
 			);
-			path = Online;
-			sourceTree = "<group>";
+			name = Online;
+			path = ..;
+			sourceTree = SOURCE_ROOT;
 		};
 		BE5EB5B6213FE21000E0826C /* common */ = {
 			isa = PBXGroup;
@@ -203,9 +216,8 @@
 				BE5EB5BA213FE29900E0826C /* SpookyV2.cpp */,
 				BE5EB5BC213FE29900E0826C /* Util.cpp */,
 			);
-			name = common;
-			path = ../common;
-			sourceTree = SOURCE_ROOT;
+			path = common;
+			sourceTree = "<group>";
 		};
 		BE5EB5B7213FE21600E0826C /* wsd */ = {
 			isa = PBXGroup;
@@ -220,9 +232,41 @@
 			path = ../wsd;
 			sourceTree = SOURCE_ROOT;
 		};
+		BE6362BE2153A79200F4237E /* Core */ = {
+			isa = PBXGroup;
+			children = (
+				BE6362BF2153A7A200F4237E /* desktop */,
+				BE6362C32154473C00F4237E /* vcl */,
+			);
+			name = Core;
+			sourceTree = "<group>";
+		};
+		BE6362BF2153A7A200F4237E /* desktop */ = {
+			isa = PBXGroup;
+			children = (
+				BE6362C02153A7B500F4237E /* init.cxx */,
+			);
+			name = desktop;
+			sourceTree = "<group>";
+		};
+		BE6362C32154473C00F4237E /* vcl */ = {
+			isa = PBXGroup;
+			children = (
+				BE6362D22154479000F4237E /* ctfonts.cxx */,
+				BE6362D42154479000F4237E /* salbmp.cxx */,
+				BE6362D62154479000F4237E /* salgdi.cxx */,
+				BE6362D72154479000F4237E /* salgdicommon.cxx */,
+				BE6362D82154479000F4237E /* salgdiutils.cxx */,
+				BE6362D32154479000F4237E /* salvd.cxx */,
+				BE6362D52154479000F4237E /* utils.cxx */,
+			);
+			name = vcl;
+			sourceTree = "<group>";
+		};
 		BE8D771E2136762500AC58EA = {
 			isa = PBXGroup;
 			children = (
+				BE6362BE2153A79200F4237E /* Core */,
 				BE5EB5B5213FE1F900E0826C /* Online */,
 				BE8D77292136762500AC58EA /* Mobile */,
 				BE8D77282136762500AC58EA /* Products */,
commit 26323fb92b3e860665c2a37deba049e9e310a7e9
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Sep 21 10:24:04 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Sep 21 10:29:56 2018 +0300

    Struggle a bit back and forth with the UTIs etc in Info.plist
    
    This stuff is a bit fragile, and the presence of other apps on the
    device that claim to support "our" file types might, or might not,
    affect how it works. Also, upgrading to iOS 12 seemed to have an
    effect. Anyway, now it is back to working as I need.

diff --git a/Mobile/Mobile/Info.plist b/Mobile/Mobile/Info.plist
index b142a9205..d1e18e428 100644
--- a/Mobile/Mobile/Info.plist
+++ b/Mobile/Mobile/Info.plist
@@ -2,11 +2,23 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>UIFileSharingEnabled</key>
+	<true/>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>$(DEVELOPMENT_LANGUAGE)</string>
 	<key>CFBundleDocumentTypes</key>
 	<array>
 		<dict>
+			<key>LSItemContentTypes</key>
+			<array>
+				<string>com.collabora.office.uti.fodt</string>
+			</array>
+			<key>CFBundleTypeName</key>
+			<string>OpenDocument Flat Text</string>
+			<key>LSHandlerRank</key>
+			<string>Default</string>
+		</dict>
+		<dict>
 			<key>CFBundleTypeIconFiles</key>
 			<array/>
 			<key>CFBundleTypeName</key>
@@ -21,12 +33,8 @@
 			</array>
 		</dict>
 		<dict>
-			<key>CFBundleTypeIconFiles</key>
-			<array/>
 			<key>CFBundleTypeName</key>
 			<string>OpenDocument Text</string>
-			<key>CFBundleTypeRole</key>
-			<string>Editor</string>
 			<key>LSHandlerRank</key>
 			<string>Owner</string>
 			<key>LSItemContentTypes</key>
@@ -109,6 +117,19 @@
 			<array>
 				<string>public.data</string>
 			</array>
+			<key>UTTypeIdentifier</key>
+			<string>com.collabora.office.uti.fodt</string>
+			<key>UTTypeTagSpecification</key>
+			<dict>
+				<key>public.filename-extension</key>
+				<string>fodt</string>
+			</dict>
+		</dict>
+		<dict>
+			<key>UTTypeConformsTo</key>
+			<array>
+				<string>public.data</string>
+			</array>
 			<key>UTTypeDescription</key>
 			<string>OpenDocument Text</string>
 			<key>UTTypeIconFiles</key>
@@ -140,8 +161,6 @@
 		</dict>
 	</array>
 	<key>UTImportedTypeDeclarations</key>
-	<array>
-		<dict/>
-	</array>
+	<array/>
 </dict>
 </plist>
commit f3786f5cb7d823bb1883e3dcdcc13bdf186b2189
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Sep 21 10:10:53 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Sep 21 10:29:56 2018 +0300

    Pass correct argument on iOS as pBuffer to lok::Document::paintTile()
    
    On iOS it shouldn't actually be pointer to a pixel char buffer, but a
    craphics context reference. (This is how it has been since the
    experimental TiledLibreOffice app, maybe five years ago? Sadly it
    wasn't documented in the LibreOfficeKit include file. But it is how
    LibreOfficeLight used the API, too.)
    
    In TiledLibreOffice we rendered tiles directly into the CALayer of the
    view. In this Online-based app we of course do render tiles into pixel
    char buffers, just like in real Online, but we need to create bitmap
    graphics contexts for them and pass that to paintTile().
    
    Now I get white tiles, not totally zero-filled ones. But still no
    document contents rendered.
    
    I don't yet want to change the pBuffer parameter to actually be a
    buffer pointer on iOS, too, like on other platforms. Also, changing it
    will mean the LibreOfficeLight app would need changing, too, and I
    don't feel like doing that. But ideally, sure, that should be done.

diff --git a/ios/ios.h b/ios/ios.h
index 2fe488c9e..f613b93ff 100644
--- a/ios/ios.h
+++ b/ios/ios.h
@@ -7,8 +7,12 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-extern const char* lo_ios_app_getCacheDir();
+extern const char *lo_ios_app_getCacheDir();
 
 extern int loolwsd_server_socket_fd;
 
+extern unsigned char *lo_ios_app_get_cgcontext_for_buffer(unsigned char *buffer, int width, int height);
+
+extern void lo_ios_app_release_cgcontext_for_buffer();
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ios/ios.mm b/ios/ios.mm
index cc0c0f902..a5202ed50 100644
--- a/ios/ios.mm
+++ b/ios/ios.mm
@@ -9,6 +9,7 @@
 #include <cstring>
 
 #import <Foundation/Foundation.h>
+#import <CoreGraphics/CoreGraphics.h>
 
 extern "C" {
 #import <native-code.h>
@@ -16,6 +17,8 @@ extern "C" {
 
 int loolwsd_server_socket_fd = -1;
 
+static thread_local CGContextRef cgc = nullptr;
+
 const char* lo_ios_app_getCacheDir()
 {
     static NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
@@ -24,4 +27,28 @@ const char* lo_ios_app_getCacheDir()
     return result;
 }
 
+extern unsigned char *lo_ios_app_get_cgcontext_for_buffer(unsigned char *buffer, int width, int height)
+{
+    assert(cgc == nullptr);
+
+    cgc = CGBitmapContextCreate(buffer, width, height, 8, width*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst);
+
+#if 0
+    // Do we need to turn the coordinate system upside down, or not? Unclear yet whether this is
+    // taken care of in LO core or not. Anyway, with or without this, I still at the moment get no
+    // contents rendered in the tiles.
+    CGContextTranslateCTM(cgc, 0, height);
+    CGContextScaleCTM(cgc, 1, -1);
+#endif
+
+    return (unsigned char*)cgc;
+}
+
+extern void lo_ios_app_release_cgcontext_for_buffer()
+{
+    assert(cgc != nullptr);
+    CGContextRelease(cgc);
+    cgc = nullptr;
+}
+
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 0e96f78ac..d8cce0218 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -82,6 +82,10 @@
 #include "LOOLWSD.hpp"
 #endif
 
+#ifdef IOS
+#include "ios.h"
+#endif
+
 #define LIB_SOFFICEAPP  "lib" "sofficeapp" ".so"
 #define LIB_MERGED      "lib" "mergedlo" ".so"
 
@@ -963,10 +967,19 @@ public:
 
         const double area = tile.getWidth() * tile.getHeight();
         Timestamp timestamp;
-        _loKitDocument->paintPartTile(pixmap.data(), tile.getPart(),
+        _loKitDocument->paintPartTile(
+#ifndef IOS
+                                      pixmap.data(),
+#else
+                                      lo_ios_app_get_cgcontext_for_buffer(pixmap.data(), tile.getWidth(), tile.getHeight()),
+#endif
+                                      tile.getPart(),
                                       tile.getWidth(), tile.getHeight(),
                                       tile.getTilePosX(), tile.getTilePosY(),
                                       tile.getTileWidth(), tile.getTileHeight());
+#ifdef IOS
+        lo_ios_app_release_cgcontext_for_buffer();
+#endif
         const Poco::Timestamp::TimeDiff elapsed = timestamp.elapsed();
         LOG_TRC("paintTile at (" << tile.getPart() << ',' << tile.getTilePosX() << ',' << tile.getTilePosY() <<
                 ") " << "ver: " << tile.getVersion() << " rendered in " << (elapsed/1000.) <<
@@ -1061,14 +1074,31 @@ public:
 
         const double area = pixmapWidth * pixmapHeight;
         Timestamp timestamp;
-        _loKitDocument->paintPartTile(pixmap.data(), tileCombined.getPart(),
+        LOG_TRC("Calling paintPartTile(" << (void*)pixmap.data() << ")");
+        _loKitDocument->paintPartTile(
+#ifndef IOS
+                                      pixmap.data(),
+#else
+                                      lo_ios_app_get_cgcontext_for_buffer(pixmap.data(), pixmapWidth, pixmapHeight),
+#endif
+                                      tileCombined.getPart(),
                                       pixmapWidth, pixmapHeight,
                                       renderArea.getLeft(), renderArea.getTop(),
                                       renderArea.getWidth(), renderArea.getHeight());
+#ifdef IOS
+        lo_ios_app_release_cgcontext_for_buffer();
+#endif
         Timestamp::TimeDiff elapsed = timestamp.elapsed();
         LOG_DBG("paintTile (combined) at (" << renderArea.getLeft() << ", " << renderArea.getTop() << "), (" <<
                 renderArea.getWidth() << ", " << renderArea.getHeight() << ") " <<
                 " rendered in " << (elapsed/1000.) << " ms (" << area / elapsed << " MP/s).");
+
+        auto& log = Log::logger();
+        if (log.trace()) {
+            LOG_TRC("Dump of middle of rendered tile");
+            log.dump("", pixmap.data() + pixmapSize/2 - 32, 64);
+        }
+
         const auto mode = static_cast<LibreOfficeKitTileMode>(_loKitDocument->getTileMode());
 
         std::vector<char> output;


More information about the Libreoffice-commits mailing list