summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/Library_sofficeapp.mk6
-rw-r--r--desktop/source/lib/init.cxx51
2 files changed, 56 insertions, 1 deletions
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 38e427d66173..215c7ed07251 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -99,9 +99,15 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,sofficeapp,\
endif
ifeq ($(OS),IOS)
+
$(eval $(call gb_Library_add_cflags,sofficeapp,\
$(gb_OBJCFLAGS) \
))
+
+$(eval $(call gb_Library_add_cxxflags,sofficeapp,\
+ $(gb_OBJCXXFLAGS) \
+))
+
endif
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5c89c1dbd386..32c0a0b2b03c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
@@ -13,6 +13,16 @@
#include <string.h>
#include <stdlib.h>
+#ifdef IOS
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unicode/udata.h>
+#include <unicode/ucnv.h>
+#include <premac.h>
+#import <Foundation/Foundation.h>
+#include <postmac.h>
+#endif
+
#include <algorithm>
#include <memory>
#include <iostream>
@@ -3871,6 +3881,45 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
if (osl::FileBase::getFileURLFromSystemPath(aAppPath, aAppURL) != osl::FileBase::E_None)
return 0;
+#ifdef IOS
+ // A LibreOffice-using iOS app should have the ICU data file in the app bundle. Initialize ICU
+ // to use that.
+ NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
+
+ int fd = open([[bundlePath stringByAppendingPathComponent:@U_ICUDATA_NAME".dat"] UTF8String], O_RDONLY);
+ if (fd == -1)
+ NSLog(@"Could not open ICU data file %s", [[bundlePath stringByAppendingPathComponent:@U_ICUDATA_NAME".dat"] UTF8String]);
+ else
+ {
+ struct stat st;
+ if (fstat(fd, &st) == -1)
+ NSLog(@"fstat on ICU data file failed: %s", strerror(errno));
+ else
+ {
+ void *icudata = mmap(0, (size_t) st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
+ if (icudata == MAP_FAILED)
+ NSLog(@"mmap failed: %s", strerror(errno));
+ else
+ {
+ UErrorCode icuStatus = U_ZERO_ERROR;
+ udata_setCommonData(icudata, &icuStatus);
+ if (U_FAILURE(icuStatus))
+ NSLog(@"udata_setCommonData failed");
+ else
+ {
+ // Quick 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);
+ }
+ }
+ }
+ close(fd);
+ }
+#endif
+
try
{
if (eStage != SECOND_INIT)