From c1f46c54a62030efb93443c025487d2caade5b9c Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Thu, 23 Feb 2017 12:47:34 +0100 Subject: [PATCH] ios LibreOfficeLight LOkit integration Integrated LibreOfficeLight into gbuild. added lo.xcconfig and Resources (needed to link with LO and run LO) added swift --> C interface for LOkit add known commands from JS client added C++ condition in LibreOfficekitInit.h (inline no good in a C file) Change-Id: I19ebe8912546408bf701c96c0c63541d6e37cad8 Reviewed-on: https://gerrit.libreoffice.org/35430 Tested-by: Jenkins Reviewed-by: jan iversen --- include/LibreOfficeKit/LibreOfficeKitInit.h | 10 + ios/CustomTarget_LibreOfficeLight_app.mk | 30 ++ ios/Module_ios.mk | 1 + .../project.pbxproj | 130 ++++- .../LibreOfficeLight/LO.swift | 2 +- .../LibreOfficeLight-Prefix.pch | 22 + .../LibreOfficeLight/lokit-Bridging-Header.h | 11 + .../LibreOfficeLight/LibreOfficeLight/lokit.c | 491 ++++++++++++++++++ 8 files changed, 693 insertions(+), 4 deletions(-) create mode 100644 ios/CustomTarget_LibreOfficeLight_app.mk create mode 100644 ios/experimental/LibreOfficeLight/LibreOfficeLight/LibreOfficeLight-Prefix.pch create mode 100644 ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h create mode 100755 ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h index f4ab9cdf2082..d19aa0fae9ef 100644 --- a/include/LibreOfficeKit/LibreOfficeKitInit.h +++ b/include/LibreOfficeKit/LibreOfficeKitInit.h @@ -43,7 +43,9 @@ extern "C" #define SEPARATOR '/' #ifndef __OBJC__ +#ifdef __cplusplus inline +#endif #endif void *lok_loadlib(const char *pFN) { @@ -55,7 +57,9 @@ extern "C" } #ifndef __OBJC__ +#ifdef __cplusplus inline +#endif #endif char *lok_dlerror(void) { @@ -63,7 +67,9 @@ extern "C" } #ifndef __OBJC__ +#ifdef __cplusplus inline +#endif #endif void *lok_dlsym(void *Hnd, const char *pName) { @@ -71,7 +77,9 @@ extern "C" } #ifndef __OBJC__ +#ifdef __cplusplus inline +#endif #endif int lok_dlclose(void *Hnd) { @@ -79,7 +87,9 @@ extern "C" } #ifndef __OBJC__ +#ifdef __cplusplus inline +#endif #endif void extendUnoPath(const char *pPath) { diff --git a/ios/CustomTarget_LibreOfficeLight_app.mk b/ios/CustomTarget_LibreOfficeLight_app.mk new file mode 100644 index 000000000000..ed61f279e2cf --- /dev/null +++ b/ios/CustomTarget_LibreOfficeLight_app.mk @@ -0,0 +1,30 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. + +#- Env ------------------------------------------------------------------------ +BUILDID :=$(shell cd $(SRCDIR) && git log -1 --format=%H) + +#- Targets -------------------------------------------------------------------- + +.PHONY: LibreOfficeLight_setup + +# Register target +$(eval $(call gb_CustomTarget_CustomTarget,ios/LibreOfficeLight)) + +# Build +# Depend on the custom target that sets up lo.xcconfig +$(call gb_CustomTarget_get_target,ios/LibreOfficeLight): $(call gb_CustomTarget_get_target,ios/Lo_Xcconfig) + $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),APP,2) + $(call IOSbuild,LibreOfficeLight, clean build) + +# Clean +$(call gb_CustomTarget_get_clean_target,ios/LibreOfficeLight): + $(call gb_Output_announce,$(subst $(WORKDIR)/Clean/,,$@),$(false),APP,2) + $(call IOSbuild,LibreOfficeLight, clean) + +# vim: set noet sw=4 ts=4: diff --git a/ios/Module_ios.mk b/ios/Module_ios.mk index 13c607b9d497..22b551214631 100644 --- a/ios/Module_ios.mk +++ b/ios/Module_ios.mk @@ -14,6 +14,7 @@ $(eval $(call gb_Module_add_targets,ios,\ CustomTarget_Lo_Xcconfig \ CustomTarget_TiledLibreOffice_app \ CustomTarget_Prototype_app \ + CustomTarget_LibreOfficeLight_app \ )) endif diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj b/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj index 837aa290bfee..73e789d2311b 100644 --- a/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj +++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj @@ -21,6 +21,17 @@ 3992D85E1E5B764A00BEA987 /* ViewFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3992D85C1E5B764A00BEA987 /* ViewFileManager.swift */; }; 399648471E5B87DC00E73E83 /* ViewProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 399648461E5B87DC00E73E83 /* ViewProperties.swift */; }; 399648491E5C4E5500E73E83 /* LO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 399648481E5C4E5500E73E83 /* LO.swift */; }; + 39A83A8F1E5F471D00D0C683 /* lokit.c in Sources */ = {isa = PBXBuildFile; fileRef = 39A83A8E1E5F471D00D0C683 /* lokit.c */; }; + 39B084E31E5F0A9600682A59 /* lo.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; }; + 39B08B9D1E5F0BB600682A59 /* fundamentalrc in Resources */ = {isa = PBXBuildFile; fileRef = 39B084E51E5F0BB400682A59 /* fundamentalrc */; }; + 39B08B9E1E5F0BB600682A59 /* offapi.rdb in Resources */ = {isa = PBXBuildFile; fileRef = 39B084E61E5F0BB400682A59 /* offapi.rdb */; }; + 39B08B9F1E5F0BB600682A59 /* oovbaapi.rdb in Resources */ = {isa = PBXBuildFile; fileRef = 39B084E71E5F0BB400682A59 /* oovbaapi.rdb */; }; + 39B08BD71E5F0BB600682A59 /* rc in Resources */ = {isa = PBXBuildFile; fileRef = 39B085211E5F0BB400682A59 /* rc */; }; + 39B08BD91E5F0BB600682A59 /* services.rdb in Resources */ = {isa = PBXBuildFile; fileRef = 39B085241E5F0BB400682A59 /* services.rdb */; }; + 39B091CD1E5F0BB800682A59 /* udkapi.rdb in Resources */ = {isa = PBXBuildFile; fileRef = 39B08B9B1E5F0BB600682A59 /* udkapi.rdb */; }; + 39B091CE1E5F0BB800682A59 /* unorc in Resources */ = {isa = PBXBuildFile; fileRef = 39B08B9C1E5F0BB600682A59 /* unorc */; }; + 39B091D01E5F102E00682A59 /* test1.odt in Resources */ = {isa = PBXBuildFile; fileRef = 39B091CF1E5F102E00682A59 /* test1.odt */; }; + 39B091D21E5F109A00682A59 /* icudt58l.dat in Resources */ = {isa = PBXBuildFile; fileRef = 39B091D11E5F109A00682A59 /* icudt58l.dat */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -61,6 +72,19 @@ 3992D85C1E5B764A00BEA987 /* ViewFileManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewFileManager.swift; sourceTree = ""; }; 399648461E5B87DC00E73E83 /* ViewProperties.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewProperties.swift; sourceTree = ""; }; 399648481E5C4E5500E73E83 /* LO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LO.swift; sourceTree = ""; }; + 39A83A8D1E5F471C00D0C683 /* lokit-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = "lokit-Bridging-Header.h"; sourceTree = ""; }; + 39A83A8E1E5F471D00D0C683 /* lokit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lokit.c; path = LibreOfficeLight/lokit.c; sourceTree = SOURCE_ROOT; }; + 39B084E21E5F0A9600682A59 /* lo.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = lo.xcconfig; path = "../../../../ios-work/workdir/ios/generated/lo.xcconfig"; sourceTree = SOURCE_ROOT; }; + 39B084E51E5F0BB400682A59 /* fundamentalrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = fundamentalrc; path = "../../../../ios-work/workdir/ios/resources/fundamentalrc"; sourceTree = SOURCE_ROOT; }; + 39B084E61E5F0BB400682A59 /* offapi.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = offapi.rdb; path = "../../../../ios-work/workdir/ios/resources/offapi.rdb"; sourceTree = SOURCE_ROOT; }; + 39B084E71E5F0BB400682A59 /* oovbaapi.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = oovbaapi.rdb; path = "../../../../ios-work/workdir/ios/resources/oovbaapi.rdb"; sourceTree = SOURCE_ROOT; }; + 39B085211E5F0BB400682A59 /* rc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = rc; path = "../../../../ios-work/workdir/ios/resources/rc"; sourceTree = SOURCE_ROOT; }; + 39B085241E5F0BB400682A59 /* services.rdb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = services.rdb; path = "../../../../ios-work/workdir/ios/resources/services.rdb"; sourceTree = SOURCE_ROOT; }; + 39B08B9B1E5F0BB600682A59 /* udkapi.rdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = udkapi.rdb; path = "../../../../ios-work/workdir/ios/resources/udkapi.rdb"; sourceTree = SOURCE_ROOT; }; + 39B08B9C1E5F0BB600682A59 /* unorc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = unorc; path = "../../../../ios-work/workdir/ios/resources/unorc"; sourceTree = SOURCE_ROOT; }; + 39B091CF1E5F102E00682A59 /* test1.odt */ = {isa = PBXFileReference; lastKnownFileType = file; name = test1.odt; path = ../../../odk/examples/java/DocumentHandling/test/test1.odt; sourceTree = SOURCE_ROOT; }; + 39B091D11E5F109A00682A59 /* icudt58l.dat */ = {isa = PBXFileReference; lastKnownFileType = file; name = icudt58l.dat; path = "../../../../ios-work/workdir/UnpackedTarball/icu/source/data/in/icudt58l.dat"; sourceTree = ""; }; + 39B092501E5F3DEA00682A59 /* LibreOfficeLight-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "LibreOfficeLight-Prefix.pch"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -91,6 +115,8 @@ 3911D89F1E5993600050D6BC /* Support files */ = { isa = PBXGroup; children = ( + 39B092501E5F3DEA00682A59 /* LibreOfficeLight-Prefix.pch */, + 39B084E21E5F0A9600682A59 /* lo.xcconfig */, 397E09071E597BD8001374E0 /* Assets.xcassets */, 397E09041E597BD8001374E0 /* LibreOfficeLight.xcdatamodeld */, 397E090C1E597BD8001374E0 /* Info.plist */, @@ -102,6 +128,8 @@ 397E08F11E597BD8001374E0 = { isa = PBXGroup; children = ( + 39B084E41E5F0B5200682A59 /* Resources */, + 3911D89F1E5993600050D6BC /* Support files */, 397E08FC1E597BD8001374E0 /* LibreOfficeLight */, 397E09141E597BD8001374E0 /* LibreOfficeLightTests */, 397E091F1E597BD8001374E0 /* LibreOfficeLightUITests */, @@ -122,6 +150,7 @@ 397E08FC1E597BD8001374E0 /* LibreOfficeLight */ = { isa = PBXGroup; children = ( + 39A83A8E1E5F471D00D0C683 /* lokit.c */, 397E08FD1E597BD8001374E0 /* AppDelegate.swift */, 3992D8571E5B761700BEA987 /* ViewController.swift */, 3992D85B1E5B764A00BEA987 /* SideMenu.swift */, @@ -132,7 +161,7 @@ 399648481E5C4E5500E73E83 /* LO.swift */, 397E09011E597BD8001374E0 /* Main.storyboard */, 397868D81E59A3EA007F9248 /* LaunchScreen.xib */, - 3911D89F1E5993600050D6BC /* Support files */, + 39A83A8D1E5F471C00D0C683 /* lokit-Bridging-Header.h */, ); path = LibreOfficeLight; sourceTree = SOURCE_ROOT; @@ -155,6 +184,22 @@ path = LibreOfficeLightUITests; sourceTree = SOURCE_ROOT; }; + 39B084E41E5F0B5200682A59 /* Resources */ = { + isa = PBXGroup; + children = ( + 39B084E51E5F0BB400682A59 /* fundamentalrc */, + 39B084E61E5F0BB400682A59 /* offapi.rdb */, + 39B084E71E5F0BB400682A59 /* oovbaapi.rdb */, + 39B085211E5F0BB400682A59 /* rc */, + 39B085241E5F0BB400682A59 /* services.rdb */, + 39B08B9B1E5F0BB600682A59 /* udkapi.rdb */, + 39B08B9C1E5F0BB600682A59 /* unorc */, + 39B091CF1E5F102E00682A59 /* test1.odt */, + 39B091D11E5F109A00682A59 /* icudt58l.dat */, + ); + name = Resources; + sourceTree = SOURCE_ROOT; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -223,6 +268,7 @@ TargetAttributes = { 397E08F91E597BD8001374E0 = { CreatedOnToolsVersion = 8.2; + LastSwiftMigration = 0820; ProvisioningStyle = Automatic; }; 397E09101E597BD8001374E0 = { @@ -261,8 +307,18 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 39B091D21E5F109A00682A59 /* icudt58l.dat in Resources */, 397E09081E597BD8001374E0 /* Assets.xcassets in Resources */, + 39B08BD71E5F0BB600682A59 /* rc in Resources */, + 39B08B9E1E5F0BB600682A59 /* offapi.rdb in Resources */, + 39B084E31E5F0A9600682A59 /* lo.xcconfig in Resources */, 397868D61E59A3EA007F9248 /* LaunchScreen.xib in Resources */, + 39B08B9F1E5F0BB600682A59 /* oovbaapi.rdb in Resources */, + 39B08B9D1E5F0BB600682A59 /* fundamentalrc in Resources */, + 39B091CD1E5F0BB800682A59 /* udkapi.rdb in Resources */, + 39B08BD91E5F0BB600682A59 /* services.rdb in Resources */, + 39B091D01E5F102E00682A59 /* test1.odt in Resources */, + 39B091CE1E5F0BB800682A59 /* unorc in Resources */, 397E09031E597BD8001374E0 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -295,6 +351,7 @@ 3992D85E1E5B764A00BEA987 /* ViewFileManager.swift in Sources */, 3992D85A1E5B762A00BEA987 /* ViewDocument.swift in Sources */, 397E08FE1E597BD8001374E0 /* AppDelegate.swift in Sources */, + 39A83A8F1E5F471D00D0C683 /* lokit.c in Sources */, 399648491E5C4E5500E73E83 /* LO.swift in Sources */, 3992D8581E5B761700BEA987 /* ViewController.swift in Sources */, ); @@ -354,6 +411,7 @@ /* Begin XCBuildConfiguration section */ 397E09231E597BD8001374E0 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -392,6 +450,26 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(LO_BUILDDIR)/config_host", + "$(LO_SRCDIR)/include", + "$(LO_WORKDIR)/UnoApiHeadersTarget/udkapi/comprehensive", + "$(LO_WORKDIR)/UnoApiHeadersTarget/offapi/comprehensive", + "$(LO_WORKDIR)/UnpackedTarball/icu/source/common", + "$(LO_WORKDIR)/ios/generated", + ); + "HEADER_SEARCH_PATHS[arch=*]" = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(LO_BUILDDIR)/config_host", + "$(LO_SRCDIR)/include", + "$(LO_WORKDIR)/UnoApiHeadersTarget/udkapi/comprehensive", + "$(LO_WORKDIR)/UnoApiHeadersTarget/offapi/comprehensive", + "$(LO_WORKDIR)/UnpackedTarball/icu/source/common", + "$(LO_WORKDIR)/ios/generated", + ); IPHONEOS_DEPLOYMENT_TARGET = 10.2; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -404,6 +482,7 @@ }; 397E09241E597BD8001374E0 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -436,8 +515,29 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(LO_BUILDDIR)/config_host", + "$(LO_SRCDIR)/include", + "$(LO_WORKDIR)/UnoApiHeadersTarget/udkapi/comprehensive", + "$(LO_WORKDIR)/UnoApiHeadersTarget/offapi/comprehensive", + "$(LO_WORKDIR)/UnpackedTarball/icu/source/common", + "$(LO_WORKDIR)/ios/generated", + ); + "HEADER_SEARCH_PATHS[arch=*]" = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(LO_BUILDDIR)/config_host", + "$(LO_SRCDIR)/include", + "$(LO_WORKDIR)/UnoApiHeadersTarget/udkapi/comprehensive", + "$(LO_WORKDIR)/UnoApiHeadersTarget/offapi/comprehensive", + "$(LO_WORKDIR)/UnpackedTarball/icu/source/common", + "$(LO_WORKDIR)/ios/generated", + ); IPHONEOS_DEPLOYMENT_TARGET = 10.2; MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; @@ -447,30 +547,51 @@ }; 397E09261E597BD8001374E0 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = NO; + CLANG_WARN_INFINITE_RECURSION = NO; + ENABLE_TESTABILITY = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "LibreOfficeLight/LibreOfficeLight-Prefix.pch"; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; INFOPLIST_FILE = LibreOfficeLight/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = jani.libreofficeLight.LibreOfficeLight; + PRODUCT_BUNDLE_IDENTIFIER = LibreOfficeLight; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "LibreOfficeLight/lokit-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; }; name = Debug; }; 397E09271E597BD8001374E0 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = NO; + CLANG_WARN_INFINITE_RECURSION = NO; + COPY_PHASE_STRIP = YES; + ENABLE_TESTABILITY = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "LibreOfficeLight/LibreOfficeLight-Prefix.pch"; INFOPLIST_FILE = LibreOfficeLight/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = jani.libreofficeLight.LibreOfficeLight; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = LibreOfficeLight; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "LibreOfficeLight/lokit-Bridging-Header.h"; SWIFT_VERSION = 3.0; }; name = Release; }; 397E09291E597BD8001374E0 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -485,6 +606,7 @@ }; 397E092A1E597BD8001374E0 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -499,6 +621,7 @@ }; 397E092C1E597BD8001374E0 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; INFOPLIST_FILE = LibreOfficeLightUITests/Info.plist; @@ -512,6 +635,7 @@ }; 397E092D1E597BD8001374E0 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 39B084E21E5F0A9600682A59 /* lo.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; INFOPLIST_FILE = LibreOfficeLightUITests/Info.plist; diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift b/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift index e6556adafe3a..ed039fccd49f 100755 --- a/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift +++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/LO.swift @@ -16,7 +16,7 @@ class LOkit { init() { - + LOkit_Init() } diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/LibreOfficeLight-Prefix.pch b/ios/experimental/LibreOfficeLight/LibreOfficeLight/LibreOfficeLight-Prefix.pch new file mode 100644 index 000000000000..638bf30e867e --- /dev/null +++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/LibreOfficeLight-Prefix.pch @@ -0,0 +1,22 @@ +// -*- Mode: ObjC; 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/. + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #include + #import + #import + #include +#endif + +// vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h new file mode 100644 index 000000000000..862785f0ac50 --- /dev/null +++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h @@ -0,0 +1,11 @@ +// +// 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/. +// + + +// Bridge functions to LibreOfficeKit +int LOkit_Init(); diff --git a/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c new file mode 100755 index 000000000000..af77f40454d0 --- /dev/null +++ b/ios/experimental/LibreOfficeLight/LibreOfficeLight/lokit.c @@ -0,0 +1,491 @@ +// +// 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/. +// +#include +#define LOK_USE_UNSTABLE_API +#include + +// pointers to our instance +static LibreOfficeKit* kit; +static LibreOfficeKitDocument* document; + + +// Bridge functions to LibreOfficeKit +int LOkit_Init() +{ + // Initialize LibreOfficeKit + kit = lok_init(NULL); + return 0; +} + + +int LOkit_open(char *file) +{ + document = kit->pClass->documentLoad(kit, file); + document->pClass->initializeForRendering(document, ""); + return 0; +} + + +#if 0 +// createpath from tiled +static NSString *createPaths(NSString *base, NSString *appRootEscaped, NSArray *fileNames) +{ + NSString *result; + NSString *prefix = @"file://"; + BOOL first = YES; + + result = base; + for (NSString *fileName in fileNames) { + result = [result stringByAppendingString: prefix]; + result = [result stringByAppendingString: [appRootEscaped stringByAppendingPathComponent: fileName]]; + + if (first) { + prefix = [@" " stringByAppendingString:prefix]; + first = NO; + } + } + + 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]; + NSString *app_root_escaped = [bundlePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSString *uno_types = createPaths(@"-env:UNO_TYPES=", app_root_escaped, @[@"offapi.rdb", @"oovbaapi.rdb", @"types.rdb"]); + NSString *uno_services = createPaths(@"-env:UNO_SERVICES=", app_root_escaped, @[@"ure/services.rdb", @"services.rdb"]); + + int fd = open([[bundlePath stringByAppendingPathComponent:@U_ICUDATA_NAME".dat"] UTF8String], O_RDONLY); + if (fd != -1) { + struct stat st; + if (fstat(fd, &st) != -1 + && st.st_size < (size_t)-1) { + void *icudata = mmap(0, (size_t) st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); + if (icudata == MAP_FAILED) { +#if OSL_DEBUG_LEVEL > 0 + NSLog(@"mmap failed:%s", strerror(errno)); +#endif + } else { + UErrorCode icuStatus = U_ZERO_ERROR; + udata_setCommonData(icudata, &icuStatus); +#if OSL_DEBUG_LEVEL > 0 + if (U_FAILURE(icuStatus)) + NSLog(@"udata_setCommonData failed"); + else { + // Test that ICU works... + UConverter *cnv = ucnv_open("iso-8859-3", &icuStatus); + NSLog(@"ucnv_open(iso-8859-3)-> %p, err = %s, name=%s", + (void *)cnv, u_errorName(icuStatus), (!cnv)?"?":ucnv_getName(cnv,&icuStatus)); + if (U_SUCCESS(icuStatus)) + ucnv_close(cnv); + } +#endif + } + } + close(fd); + } + + const char *argv[] = { + [[[NSBundle mainBundle] executablePath] UTF8String], + "-env:URE_INTERNAL_LIB_DIR=file:///", + [uno_types UTF8String], + [uno_services UTF8String], + [[@"file://" stringByAppendingString: [documentPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] UTF8String] + }; + + const int argc = sizeof(argv)/sizeof(*argv); + + osl_setCommandArgs(argc, (char **) argv); +} + +#endif + + +#if 0 +// LOK_main (online) +#endif + + +// CLIENT COMMAND INTERFACE +static bool client_canceltiles(char *input, int argc, char *args[]) +{ + // command: canceltiles + // arguments: NONE + // description: + // All outstanding tile messages from the client to the server are + // dropped and will not be handled, except tile messages with an id + // parameter. There is no guarantee of exactly which tile: messages + // might still be sent back to the client. + // + return true; +} + +static bool client_clientvisiblearea(char *input, int argc, char *args[]) +{ + // command: clientvisiblearea + // arguments: x= + // y= + // width= + // height= + return true; +} + +static bool client_closedocument(char *input, int argc, char *args[]) +{ + // command: closedocument + // arguments: None + // description: + // This gives document owners the ability to terminate all sessions + // currently having that document opened. This functionality is enabled + // only in case WOPI. host mentions 'EnableOwnerTermination' flag in + // its CheckFileInfo response + return true; +} + +static bool client_commandvalues(char *input, int argc, char *args[]) +{ + // command: commandvalues + // arguments: None + return true; +} + +static bool client_downloadas(char *input, int argc, char *args[]) +{ + // command: downloadas + // arguments: name= + // id= + // format= + // options= + // description: + // Exports the current document to the desired format and returns a + // download URL. The id identifies the request on the client. id can + // take following values: + // * 'print': When request for download is basically for print purposes + // * 'slideshow': When request for download is for showing slideshow + // * 'export': Just a simple download + return true; +} + +static bool client_getchildid(char *input, int argc, char *args[]) +{ + // command: getchildid + // arguments: None + // description: + // Requests the child id so that it knows where the files needs to be sent + // when it is inserted in the document + return true; +} + +static bool client_gettextselection(char *input, int argc, char *args[]) +{ + // command: gettextselection + // arguments: None + // description: + // Request selection's content + return true; +} + +static bool client_insertfile(char *input, int argc, char *args[]) +{ + // command: insertfile + // arguments: name= + // type= + // description: + // Inserts the file with the name into the document, + // we currently support type = 'graphic' + return true; +} + +static bool client_key(char *input, int argc, char *args[]) +{ + // command: key + // arguments: type= + // char= + // key= + // description: + // is 'input' or 'up', and are numbers. + return true; +} + +static bool client_load(char *input, int argc, char *args[]) +{ + // command: load + // arguments: [part=] + // url= + // [timestamp=