From 7e7329873b263917ff963b38dfd804727d0914d0 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Mon, 16 Oct 2017 14:14:30 +0200 Subject: iOS, change prelink lib to pure C. Removed object C and replaced with C to make lib pure. Change-Id: Ie0f49f7e2f4577195dadfa0fdec70212af7c698a --- ios/CustomTarget_iOS.mk | 8 +-- .../LibreOfficeKit.xcodeproj/project.pbxproj | 20 +++---- ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.c | 61 ++++++++++++++++++++++ ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.h | 8 +++ .../LibreOfficeKit/LibreOfficeKit.mm | 52 ------------------ 5 files changed, 84 insertions(+), 65 deletions(-) create mode 100644 ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.c delete mode 100644 ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.mm (limited to 'ios') diff --git a/ios/CustomTarget_iOS.mk b/ios/CustomTarget_iOS.mk index 7effabcaa769..9f19f279a964 100644 --- a/ios/CustomTarget_iOS.mk +++ b/ios/CustomTarget_iOS.mk @@ -10,6 +10,8 @@ IOSGEN := $(SRCDIR)/ios/generated IOSRES := $(IOSGEN)/resources IOSKITXC := $(WORKDIR)/ios/loKit.xcconfig IOSAPPXC := $(WORKDIR)/ios/loApp.xcconfig +IOSKITSRC := $(SRCDIR)/ios/LibreOfficeKit/LibreOfficeKit +IOSAPPSRC := $(SRCDIR)/ios/LibreOfficeLight/LibreOfficeLight IOSKITPRJ := $(SRCDIR)/ios/LibreOfficeKit/LibreOfficeKit.xcodeproj IOSAPPPRJ := $(SRCDIR)/ios/LibreOfficeLight/LibreOfficeLight.xcodeproj IOSAPP := $(INSTDIR)/LibreOfficeLight.app @@ -58,7 +60,7 @@ ifeq ("$(wildcard $(IOSRES))","") # generate file with call declarations $(SRCDIR)/solenv/bin/native-code.py \ -g core -g writer -g calc -g draw -g edit \ - > $(IOSGEN)/native-code.mm + > $(IOSGEN)/native-code.h # generate resource files used to start/run LibreOffice cp $(WORKDIR)/UnpackedTarball/icu/source/data/in/icudt59l.dat $(IOSRES)/icudt59l.dat @@ -108,7 +110,7 @@ endif #- build --------------------------------------------------------------------- -$(IOSGEN)/$(IOSKIT): $(IOSKITPRJ)/project.pbxproj $(IOSKITXC) $(IOSAPPXC) +$(IOSGEN)/$(IOSKIT): $(IOSKITPRJ)/project.pbxproj $(IOSKITXC) $(IOSAPPXC) $(IOSKITSRC)/LibreOfficeKit.h $(IOSKITSRC)/LibreOfficeKit.c $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),APP,2) CC=; \ $(call gb_Helper_print_on_error, \ @@ -145,7 +147,7 @@ $(INSTDIR)/$(IOSAPP): $(IOSAPPPRJ)/project.pbxproj $(IOSGEN)/$(IOSKIT) #- clean ios ----------------------------------------------------------------- $(call gb_CustomTarget_get_clean_target,ios/ios): $(call gb_Output_announce,$(subst $(WORKDIR)/Clean/,,$@),$(false),ENV,2) - rm $(IOSGEN)/$(IOSKIT) + rm -f $(IOSGEN)/$(IOSKIT) rm -rf $(SRCDIR)/ios/LibreOfficeKit/LibreOfficeKit.xcodeproj/project.xcworkspace rm -rf $(SRCDIR)/ios/LibreOfficeKit/LibreOfficeKit.xcodeproj/xcuserdata rm -rf $(SRCDIR)/ios/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.xcworkspace diff --git a/ios/LibreOfficeKit/LibreOfficeKit.xcodeproj/project.pbxproj b/ios/LibreOfficeKit/LibreOfficeKit.xcodeproj/project.pbxproj index 99a6a26ca0f7..69faf4fb80a9 100644 --- a/ios/LibreOfficeKit/LibreOfficeKit.xcodeproj/project.pbxproj +++ b/ios/LibreOfficeKit/LibreOfficeKit.xcodeproj/project.pbxproj @@ -7,27 +7,25 @@ objects = { /* Begin PBXBuildFile section */ - 39B5D21A1F78130F008FB162 /* LibreOfficeKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39B5D2191F78130F008FB162 /* LibreOfficeKit.mm */; }; - 39B5D21B1F78130F008FB162 /* LibreOfficeKit.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 39B5D2181F78130F008FB162 /* LibreOfficeKit.h */; }; + 39503A731F94CBA000F19C78 /* LibreOfficeKit.c in Sources */ = {isa = PBXBuildFile; fileRef = 39503A721F94CBA000F19C78 /* LibreOfficeKit.c */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ 39B5D2131F78130F008FB162 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; + dstPath = "$(SRCDIR)/ios/generated"; + dstSubfolderSpec = 0; files = ( - 39B5D21B1F78130F008FB162 /* LibreOfficeKit.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 39503A6E1F94C3B700F19C78 /* LibreOfficeKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibreOfficeKit.h; sourceTree = ""; }; + 39503A721F94CBA000F19C78 /* LibreOfficeKit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = LibreOfficeKit.c; sourceTree = ""; }; 39B5D2151F78130F008FB162 /* libLibreOfficeKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLibreOfficeKit.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 39B5D2181F78130F008FB162 /* LibreOfficeKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LibreOfficeKit.h; sourceTree = ""; }; - 39B5D2191F78130F008FB162 /* LibreOfficeKit.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LibreOfficeKit.mm; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -68,8 +66,8 @@ 39B5D2171F78130F008FB162 /* LibreOfficeKit */ = { isa = PBXGroup; children = ( - 39B5D2181F78130F008FB162 /* LibreOfficeKit.h */, - 39B5D2191F78130F008FB162 /* LibreOfficeKit.mm */, + 39503A721F94CBA000F19C78 /* LibreOfficeKit.c */, + 39503A6E1F94C3B700F19C78 /* LibreOfficeKit.h */, ); path = LibreOfficeKit; sourceTree = ""; @@ -131,7 +129,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 39B5D21A1F78130F008FB162 /* LibreOfficeKit.mm in Sources */, + 39503A731F94CBA000F19C78 /* LibreOfficeKit.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -276,6 +274,7 @@ 39B5D21F1F78130F008FB162 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + MACH_O_TYPE = staticlib; OTHER_LDFLAGS = ""; PRELINK_FLAGS = "-ios_version_min 10.3"; PRELINK_LIBS = ""; @@ -287,6 +286,7 @@ 39B5D2201F78130F008FB162 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + MACH_O_TYPE = staticlib; OTHER_LDFLAGS = ""; PRELINK_FLAGS = "-ios_version_min 10.3"; PRELINK_LIBS = ""; diff --git a/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.c b/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.c new file mode 100644 index 000000000000..b3c41c3a5d4b --- /dev/null +++ b/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.c @@ -0,0 +1,61 @@ +// +// 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 "LibreOfficeKit.h" +#include +#include +#define LOK_USE_UNSTABLE_API +#include + +#include + +#include +#include + +// generated by solenv/bin/native-code.py: +#include "native-code.h" + + +// Force reference to libreofficekit_hook +extern __attribute__((used)) void *libreofficekit_hook(const char *); +static __attribute__((used)) void *(*foop)(const char *) = libreofficekit_hook; + +// pointers to our instance +static LibreOfficeKit* kit; +static LibreOfficeKitDocument* document; + + + + +// Bridge functions to LibreOfficeKit +int BridgeLOkit_Init(const char *path) +{ + char bufUserPath[200]; + strcpy(bufUserPath, path); + strcpy(bufUserPath + strlen(path), "/user"); + + // Initialize LibreOfficeKit + if (!kit) + kit = lok_init_2(path, bufUserPath); + return 0; +} + + + +int BridgeLOkit_open(const char *path) +{ + document = kit->pClass->documentLoad(kit, path); + document->pClass->initializeForRendering(document, ""); + return 0; +} + + + +int BridgeLOkit_ClientCommand(const char *input) +{ + return 0; +} diff --git a/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.h b/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.h index 3d4366495382..b86156211893 100644 --- a/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.h +++ b/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.h @@ -6,3 +6,11 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +// Bridge functions between LibreOfficeKit library and swift application. +// Only functions mentioned here can be used from the application +// The swift compiler uses this header to generate a needed interface +// The functions (LibreOfficeKit.mm) calls functions directly in LibreOffice + +int BridgeLOkit_Init(const char *path); +int BridgeLOkit_open(const char *path); +int BridgeLOkit_ClientCommand(const char *input); diff --git a/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.mm b/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.mm deleted file mode 100644 index 677386ce196b..000000000000 --- a/ios/LibreOfficeKit/LibreOfficeKit/LibreOfficeKit.mm +++ /dev/null @@ -1,52 +0,0 @@ -// -// 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 -#include -#define LOK_USE_UNSTABLE_API -#include - -#include - -#include -#include - -// generated by solenv/bin/native-code.py: -#include "native-code.mm" - - -// Force reference to libreofficekit_hook -extern "C" __attribute__((used)) void *libreofficekit_hook(const char *); -static __attribute__((used)) void *(*foop)(const char *) = libreofficekit_hook; - -// pointers to our instance -static LibreOfficeKit* kit; -static LibreOfficeKitDocument* document; - - - - -// Bridge functions to LibreOfficeKit -extern "C" int BridgeLOkit_Init(const char *path) -{ - char bufUserPath[200]; - strcpy(bufUserPath, path); - strcpy(bufUserPath + strlen(path), "/user"); - - // Initialize LibreOfficeKit - if (!kit) - kit = lok_init_2(path, bufUserPath); - return 0; -} - -int LOkit_open(char *file) -{ - document = kit->pClass->documentLoad(kit, file); - document->pClass->initializeForRendering(document, ""); - return 0; -} - -- cgit