[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - lingucomponent/Module_lingucomponent.mk lingucomponent/source postprocess/Rdb_services.mk Repository.mk solenv/bin

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 25 12:35:20 UTC 2019


 Repository.mk                                                |    2 +
 lingucomponent/Module_lingucomponent.mk                      |    2 -
 lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx |   11 +++++--
 lingucomponent/source/spellcheck/macosxspell/macspellimp.mm  |   16 +++++++++++
 postprocess/Rdb_services.mk                                  |    4 ++
 solenv/bin/native-code.py                                    |    3 +-
 6 files changed, 32 insertions(+), 6 deletions(-)

New commits:
commit f6cc8a7469bf62333ea4cbcee447c2ce2e54f879
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Mar 25 14:23:38 2019 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Mon Mar 25 14:34:35 2019 +0200

    tdf#124172: Use the MacOSXSpell library on iOS, too
    
    The code needed just a small amount of ifdefs to use UITextChecker on
    iOS instead of NSSpellChecker.
    
    Change-Id: I19edfffd3cc317a79beacc0b94668a6fd5ea3b32

diff --git a/Repository.mk b/Repository.mk
index 1c6f3871dfcb..ba7301782f44 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -470,6 +470,8 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
 			AppleRemote \
 		) \
 		fps_aqua \
+	) \
+	$(if $(filter IOS MACOSX,$(OS)), \
 		MacOSXSpell \
 	) \
 ))
diff --git a/lingucomponent/Module_lingucomponent.mk b/lingucomponent/Module_lingucomponent.mk
index 92d582cc346a..5df75c87b1fd 100644
--- a/lingucomponent/Module_lingucomponent.mk
+++ b/lingucomponent/Module_lingucomponent.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Module_add_targets,lingucomponent,\
 	Library_guesslang \
 	Library_hyphen \
 	Library_lnth \
-	$(if $(filter MACOSX,$(OS)),Library_MacOSXSpell) \
+	$(if $(filter IOS MACOSX,$(OS)),Library_MacOSXSpell) \
 	Library_spell \
 	StaticLibrary_ulingu \
 ))
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx b/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx
index e0c075ecbc72..cf0f49472ff0 100644
--- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx
+++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx
@@ -22,12 +22,14 @@
 
 #include <cppuhelper/implbase.hxx>
 
-#ifdef MACOSX
 #include <premac.h>
+#ifdef MACOSX
 #include <Carbon/Carbon.h>
 #import <Cocoa/Cocoa.h>
-#include <postmac.h>
+#else
+#include <UIKit/UIKit.h>
 #endif
+#include <postmac.h>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceDisplayName.hpp>
@@ -63,8 +65,11 @@ class MacSpellChecker :
     Locale *                aDLocs;
     OUString *              aDNames;
     sal_Int32               numdict;
+#ifdef MACOSX
     int                     macTag;   // unique tag for this doc
-
+#else
+    UITextChecker *         pChecker;
+#endif
     ::comphelper::OInterfaceContainerHelper2       aEvtListeners;
     Reference< XPropertyChangeListener >    xPropHelper;
     linguistic::PropertyHelper_Spell *      pPropHelper;
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
index 0bbee2ec282d..bc542245ab6a 100644
--- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
+++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
@@ -55,10 +55,14 @@ MacSpellChecker::MacSpellChecker() :
     bDisposing = false;
     pPropHelper = nullptr;
     numdict = 0;
+#ifndef IOS
     NSApplicationLoad();
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     macTag = [NSSpellChecker uniqueSpellDocumentTag];
     [pool release];
+#else
+    pChecker = [[UITextChecker alloc] init];
+#endif
 }
 
 
@@ -110,7 +114,11 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales()
         // TODO How on Mac OS X?
 
         // invoke a second  dictionary manager to get the shared dictionary list
+#ifdef MACOSX
         NSArray *aSpellCheckLanguages = [[NSSpellChecker sharedSpellChecker] availableLanguages];
+#else
+        NSArray *aSpellCheckLanguages = [UITextChecker availableLanguages];
+#endif
 
         for (NSUInteger i = 0; i < [aSpellCheckLanguages count]; i++)
         {
@@ -333,8 +341,12 @@ sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale
             aLang = [aLang  stringByAppendingString:aTaggedCountry];
         }
 
+#ifdef MACOSX
         NSInteger aCount;
         NSRange range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:false inSpellDocumentWithTag:macTag wordCount:&aCount];
+#else
+        NSRange range = [pChecker rangeOfMisspelledWordInString:aNSStr range:NSMakeRange(0, [aNSStr length]) startingAt:0 wrap:NO language:aLang];
+#endif
         int rVal = 0;
         if(range.length>0)
         {
@@ -432,8 +444,12 @@ Reference< XSpellAlternatives >
             NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry];
             aLang = [aLang  stringByAppendingString:aTaggedCountry];
         }
+#ifdef MACOSX
         [[NSSpellChecker sharedSpellChecker] setLanguage:aLang];
         NSArray *guesses = [[NSSpellChecker sharedSpellChecker] guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang inSpellDocumentWithTag:0];
+#else
+        NSArray *guesses = [pChecker guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang];
+#endif
         count = [guesses count];
         if (count)
         {
diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk
index 934c458720cb..0b5479222eac 100644
--- a/postprocess/Rdb_services.mk
+++ b/postprocess/Rdb_services.mk
@@ -131,11 +131,13 @@ $(eval $(call gb_Rdb_add_components,services,\
 				$(call gb_Helper_optional,AVMEDIA,avmedia/source/quicktime/avmediaQuickTime) \
 			) \
 		) \
-		lingucomponent/source/spellcheck/macosxspell/MacOSXSpell \
 		fpicker/source/aqua/fps_aqua \
 		shell/source/backends/macbe/macbe1 \
 		vcl/vcl.macosx \
 	) \
+	$(if $(filter IOS MACOSX,$(OS)), \
+		lingucomponent/source/spellcheck/macosxspell/MacOSXSpell \
+	) \
 	$(if $(filter WNT,$(OS)), \
 		avmedia/source/win/avmediawin \
 		dtrans/source/generic/dtrans \
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 106ae3cec1f1..bc84b9d6cf42 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -64,7 +64,8 @@ core_factory_list = [
     ("libspelllo.a", "spell_component_getFactory"),
     ("libpdffilterlo.a", "pdffilter_component_getFactory"),
     ("libsvtlo.a", "svt_component_getFactory"),
-    ("libctllo.a", "ctl_component_getFactory")
+    ("libctllo.a", "ctl_component_getFactory"),
+    ("libMacOSXSpelllo.a", "MacOSXSpell_component_getFactory", "#ifdef IOS"),
     ]
 
 core_constructor_list = [


More information about the Libreoffice-commits mailing list