X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FAppleSpeller.m;h=806ae2be21129323af5bea90f6c541218f22c84d;hb=c1945d27dfd19ef698ae7506c1311ce94091207a;hp=86384cc885c09807f3f1d15eaaf3e74ee7d77b87;hpb=e7da6a6bc98271aad82a5db17e2af30c95b4c2ac;p=lyx.git diff --git a/src/support/AppleSpeller.m b/src/support/AppleSpeller.m index 86384cc885..806ae2be21 100644 --- a/src/support/AppleSpeller.m +++ b/src/support/AppleSpeller.m @@ -8,7 +8,6 @@ * Full author contact details are available in file CREDITS. */ -#import #import #import @@ -67,9 +66,9 @@ static NSString * toLanguage(AppleSpeller speller, const char * lang) NSString * lang_ = toString(lang); if ([NSSpellChecker instancesRespondToSelector:@selector(availableLanguages)]) { NSArray * languages = [speller->checker availableLanguages]; - + for (NSString *element in languages) { - if ([element isEqualToString:lang_]) { + if (0 == [element caseInsensitiveCompare:lang_]) { result = element; break; } else if ([lang_ hasPrefix:element]) { @@ -95,7 +94,7 @@ SpellCheckResult AppleSpeller_check(AppleSpeller speller, const char * word, con SpellCheckResult result = SPELL_CHECK_FAILED; int start = 0; int length = [word_ length]; - + [speller->misspelled release]; speller->misspelled = nil; @@ -104,7 +103,7 @@ SpellCheckResult AppleSpeller_check(AppleSpeller speller, const char * word, con checkSpellingOfString:word_ startingAt:start language:lang_ - wrap:NO + wrap:(BOOL)NO inSpellDocumentWithTag:speller->doctag wordCount:NULL]; @@ -115,7 +114,11 @@ SpellCheckResult AppleSpeller_check(AppleSpeller speller, const char * word, con result = SPELL_CHECK_LEARNED; } } else { +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) NSUInteger capacity = [speller->misspelled count] + 1; +#else + int capacity = [speller->misspelled count] + 1; +#endif NSMutableArray * misspelled = [NSMutableArray arrayWithCapacity:capacity]; [misspelled addObjectsFromArray:speller->misspelled]; [misspelled addObject:[NSValue valueWithRange:match]]; @@ -159,16 +162,11 @@ size_t AppleSpeller_makeSuggestion(AppleSpeller speller, const char * word, cons // Mac OS X 10.6 only NSInteger slen = [word_ length]; NSRange range = { 0, slen }; - - if ([NSSpellChecker instancesRespondToSelector:@selector(guessesForWordRange:)]) { - result = [speller->checker guessesForWordRange:range - inString:word_ - language:lang_ - inSpellDocumentWithTag:speller->doctag]; - } else { - [speller->checker setLanguage:lang_]; - result = [speller->checker guessesForWord:word_]; - } + + result = [speller->checker guessesForWordRange:range + inString:word_ + language:lang_ + inSpellDocumentWithTag:speller->doctag]; #else [speller->checker setLanguage:lang_]; result = [speller->checker guessesForWord:word_]; @@ -203,7 +201,7 @@ void AppleSpeller_learn(AppleSpeller speller, const char * word) if ([NSSpellChecker instancesRespondToSelector:@selector(learnWord:)]) [speller->checker learnWord:word_]; - + [word_ release]; [pool release]; #endif @@ -218,7 +216,7 @@ void AppleSpeller_unlearn(AppleSpeller speller, const char * word) if ([NSSpellChecker instancesRespondToSelector:@selector(unlearnWord:)]) [speller->checker unlearnWord:word_]; - + [word_ release]; [pool release]; #endif @@ -233,7 +231,11 @@ int AppleSpeller_numMisspelledWords(AppleSpeller speller) void AppleSpeller_misspelledWord(AppleSpeller speller, int index, int * start, int * length) { +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) NSRange range = [[speller->misspelled objectAtIndex:(NSUInteger)index] rangeValue]; +#else + NSRange range = [[speller->misspelled objectAtIndex:index] rangeValue]; +#endif *start = range.location; *length = range.length; } @@ -241,5 +243,9 @@ void AppleSpeller_misspelledWord(AppleSpeller speller, int index, int * start, i int AppleSpeller_hasLanguage(AppleSpeller speller, const char * lang) { +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) return toLanguage(speller, lang) != nil; +#else + return true; +#endif }