Kaydet (Commit) f6cc8a74 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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
üst 8e005a56
...@@ -470,6 +470,8 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ ...@@ -470,6 +470,8 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
AppleRemote \ AppleRemote \
) \ ) \
fps_aqua \ fps_aqua \
) \
$(if $(filter IOS MACOSX,$(OS)), \
MacOSXSpell \ MacOSXSpell \
) \ ) \
)) ))
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_Module_add_targets,lingucomponent,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Module_add_targets,lingucomponent,\
Library_guesslang \ Library_guesslang \
Library_hyphen \ Library_hyphen \
Library_lnth \ Library_lnth \
$(if $(filter MACOSX,$(OS)),Library_MacOSXSpell) \ $(if $(filter IOS MACOSX,$(OS)),Library_MacOSXSpell) \
Library_spell \ Library_spell \
StaticLibrary_ulingu \ StaticLibrary_ulingu \
)) ))
......
...@@ -22,12 +22,14 @@ ...@@ -22,12 +22,14 @@
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#ifdef MACOSX
#include <premac.h> #include <premac.h>
#ifdef MACOSX
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <postmac.h> #else
#include <UIKit/UIKit.h>
#endif #endif
#include <postmac.h>
#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceDisplayName.hpp> #include <com/sun/star/lang/XServiceDisplayName.hpp>
...@@ -63,8 +65,11 @@ class MacSpellChecker : ...@@ -63,8 +65,11 @@ class MacSpellChecker :
Locale * aDLocs; Locale * aDLocs;
OUString * aDNames; OUString * aDNames;
sal_Int32 numdict; sal_Int32 numdict;
#ifdef MACOSX
int macTag; // unique tag for this doc int macTag; // unique tag for this doc
#else
UITextChecker * pChecker;
#endif
::comphelper::OInterfaceContainerHelper2 aEvtListeners; ::comphelper::OInterfaceContainerHelper2 aEvtListeners;
Reference< XPropertyChangeListener > xPropHelper; Reference< XPropertyChangeListener > xPropHelper;
linguistic::PropertyHelper_Spell * pPropHelper; linguistic::PropertyHelper_Spell * pPropHelper;
......
...@@ -55,10 +55,14 @@ MacSpellChecker::MacSpellChecker() : ...@@ -55,10 +55,14 @@ MacSpellChecker::MacSpellChecker() :
bDisposing = false; bDisposing = false;
pPropHelper = nullptr; pPropHelper = nullptr;
numdict = 0; numdict = 0;
#ifndef IOS
NSApplicationLoad(); NSApplicationLoad();
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
macTag = [NSSpellChecker uniqueSpellDocumentTag]; macTag = [NSSpellChecker uniqueSpellDocumentTag];
[pool release]; [pool release];
#else
pChecker = [[UITextChecker alloc] init];
#endif
} }
...@@ -110,7 +114,11 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales() ...@@ -110,7 +114,11 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales()
// TODO How on Mac OS X? // TODO How on Mac OS X?
// invoke a second dictionary manager to get the shared dictionary list // invoke a second dictionary manager to get the shared dictionary list
#ifdef MACOSX
NSArray *aSpellCheckLanguages = [[NSSpellChecker sharedSpellChecker] availableLanguages]; NSArray *aSpellCheckLanguages = [[NSSpellChecker sharedSpellChecker] availableLanguages];
#else
NSArray *aSpellCheckLanguages = [UITextChecker availableLanguages];
#endif
for (NSUInteger i = 0; i < [aSpellCheckLanguages count]; i++) for (NSUInteger i = 0; i < [aSpellCheckLanguages count]; i++)
{ {
...@@ -333,8 +341,12 @@ sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale ...@@ -333,8 +341,12 @@ sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale
aLang = [aLang stringByAppendingString:aTaggedCountry]; aLang = [aLang stringByAppendingString:aTaggedCountry];
} }
#ifdef MACOSX
NSInteger aCount; NSInteger aCount;
NSRange range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:false inSpellDocumentWithTag:macTag wordCount:&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; int rVal = 0;
if(range.length>0) if(range.length>0)
{ {
...@@ -432,8 +444,12 @@ Reference< XSpellAlternatives > ...@@ -432,8 +444,12 @@ Reference< XSpellAlternatives >
NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry]; NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry];
aLang = [aLang stringByAppendingString:aTaggedCountry]; aLang = [aLang stringByAppendingString:aTaggedCountry];
} }
#ifdef MACOSX
[[NSSpellChecker sharedSpellChecker] setLanguage:aLang]; [[NSSpellChecker sharedSpellChecker] setLanguage:aLang];
NSArray *guesses = [[NSSpellChecker sharedSpellChecker] guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang inSpellDocumentWithTag:0]; 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]; count = [guesses count];
if (count) if (count)
{ {
......
...@@ -131,11 +131,13 @@ $(eval $(call gb_Rdb_add_components,services,\ ...@@ -131,11 +131,13 @@ $(eval $(call gb_Rdb_add_components,services,\
$(call gb_Helper_optional,AVMEDIA,avmedia/source/quicktime/avmediaQuickTime) \ $(call gb_Helper_optional,AVMEDIA,avmedia/source/quicktime/avmediaQuickTime) \
) \ ) \
) \ ) \
lingucomponent/source/spellcheck/macosxspell/MacOSXSpell \
fpicker/source/aqua/fps_aqua \ fpicker/source/aqua/fps_aqua \
shell/source/backends/macbe/macbe1 \ shell/source/backends/macbe/macbe1 \
vcl/vcl.macosx \ vcl/vcl.macosx \
) \ ) \
$(if $(filter IOS MACOSX,$(OS)), \
lingucomponent/source/spellcheck/macosxspell/MacOSXSpell \
) \
$(if $(filter WNT,$(OS)), \ $(if $(filter WNT,$(OS)), \
avmedia/source/win/avmediawin \ avmedia/source/win/avmediawin \
dtrans/source/generic/dtrans \ dtrans/source/generic/dtrans \
......
...@@ -64,7 +64,8 @@ core_factory_list = [ ...@@ -64,7 +64,8 @@ core_factory_list = [
("libspelllo.a", "spell_component_getFactory"), ("libspelllo.a", "spell_component_getFactory"),
("libpdffilterlo.a", "pdffilter_component_getFactory"), ("libpdffilterlo.a", "pdffilter_component_getFactory"),
("libsvtlo.a", "svt_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 = [ core_constructor_list = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment