2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSSpellServer</title>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
<abstract>Class to allow a spell checker to be available to other apps.</abstract>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-23 14:11:09 +00:00
|
|
|
Copyright (C) 2001, 1996 Free Software Foundation, Inc.
|
2001-06-21 01:05:11 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
Author by: Gregory John Casamento <borgheron@yahoo.com>
|
2001-06-23 14:11:09 +00:00
|
|
|
Date: 2001
|
2001-12-17 16:51:51 +00:00
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
1996-05-30 20:03:15 +00:00
|
|
|
Date: 1996
|
2001-06-21 01:05:11 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
2001-06-21 01:05:11 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
2005-05-26 02:52:46 +00:00
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
#include "config.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
#include "AppKit/NSSpellServer.h"
|
2001-06-21 01:05:11 +00:00
|
|
|
#include <Foundation/NSDictionary.h>
|
|
|
|
#include <Foundation/NSRunLoop.h>
|
|
|
|
#include <Foundation/NSFileManager.h>
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
|
|
|
#include <Foundation/NSPathUtilities.h>
|
|
|
|
#include <Foundation/NSConnection.h>
|
|
|
|
#include <Foundation/NSProcessInfo.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSSet.h>
|
|
|
|
|
|
|
|
/* User dictionary location */
|
|
|
|
static NSString *GNU_UserDictionariesDir = @"Dictionaries";
|
|
|
|
|
|
|
|
// Function to create name for spell server....
|
2001-06-23 14:11:09 +00:00
|
|
|
NSString*
|
|
|
|
GSSpellServerName(NSString *vendor, NSString *language)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSString *serverName = nil;
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (language == nil || vendor == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
serverName = [[vendor stringByAppendingString: language]
|
|
|
|
stringByAppendingString: @"SpellChecker"];
|
|
|
|
|
|
|
|
return serverName;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
@implementation NSSpellServer
|
|
|
|
|
|
|
|
// Class methods
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
if (self == [NSSpellServer class])
|
|
|
|
{
|
|
|
|
// Initial version
|
|
|
|
[self setVersion:1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// Non-private Instance methods
|
|
|
|
- init
|
|
|
|
{
|
2001-07-24 04:31:06 +00:00
|
|
|
NSArray *userLanguages = [NSUserDefaults userLanguages];
|
|
|
|
NSString *currentLanguage = [userLanguages objectAtIndex: 0];
|
|
|
|
|
2006-07-04 21:31:49 +00:00
|
|
|
if ((self = [super init]) != nil)
|
|
|
|
{
|
|
|
|
_delegate = nil;
|
|
|
|
_ignoredWords = nil;
|
|
|
|
ASSIGN(_userDictionaries, [NSMutableDictionary dictionary]);
|
|
|
|
ASSIGN(_currentLanguage, currentLanguage);
|
|
|
|
}
|
2001-06-21 01:05:11 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2001-07-24 04:31:06 +00:00
|
|
|
// Cleanup when deallocated
|
2006-07-04 21:31:49 +00:00
|
|
|
- (void) dealloc
|
2001-07-24 04:31:06 +00:00
|
|
|
{
|
|
|
|
RELEASE(_userDictionaries);
|
|
|
|
RELEASE(_currentLanguage);
|
2006-07-04 21:31:49 +00:00
|
|
|
[super dealloc];
|
2001-07-24 04:31:06 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Checking in Your Service
|
2004-01-07 04:38:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method vends the spell server to the Distributed Objects system
|
|
|
|
* so that it can be connected to by clients.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (BOOL)registerLanguage:(NSString *)language
|
|
|
|
byVendor:(NSString *)vendor
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
NSString *serverName = GSSpellServerName(vendor, language);
|
|
|
|
NSConnection *connection = nil;
|
|
|
|
BOOL result = NO;
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (serverName == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
connection = [[NSConnection alloc] init];
|
2005-11-16 11:34:25 +00:00
|
|
|
if (connection)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
RETAIN(connection);
|
|
|
|
[connection setRootObject: self];
|
|
|
|
result = [connection registerName: serverName];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Assigning a Delegate
|
2004-01-07 04:38:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the spell server delegate.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (id)delegate
|
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
return _delegate;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 04:38:15 +00:00
|
|
|
/**
|
|
|
|
* This method is used to set the delegate of the spellserver.
|
|
|
|
* When a spelling service is run the spell server is vended out
|
|
|
|
* to DO. The spelling service must instantiate an instance of
|
|
|
|
* this class and set itself to be the delegate. This allows
|
|
|
|
* the service to respond to messages sent by the client.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)setDelegate:(id)anObject
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2002-09-24 01:34:15 +00:00
|
|
|
/* FIXME - we should not retain the delegate ! */
|
2001-06-21 01:05:11 +00:00
|
|
|
RETAIN(anObject);
|
|
|
|
ASSIGN(_delegate, anObject);
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Running the Service
|
2004-01-07 04:38:15 +00:00
|
|
|
/**
|
|
|
|
* Initiate the run loop of this service. Once the spell server
|
|
|
|
* object is vended, this method is called so that the server can
|
|
|
|
* start responding to the messages sent by the client. These
|
|
|
|
* messages are passed on to the NSSpellServer instance's delegate.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)run
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
// Start the runloop explicitly.
|
|
|
|
[[NSRunLoop currentRunLoop] run];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Private method
|
|
|
|
// Determine the path to the dictionary
|
2004-01-07 04:38:15 +00:00
|
|
|
/**
|
|
|
|
* Path to the dictionary for the specified language.
|
|
|
|
*/
|
2001-06-21 01:05:11 +00:00
|
|
|
- (NSString *)_pathToDictionary: (NSString *)currentLanguage
|
|
|
|
{
|
|
|
|
NSString *path = nil;
|
|
|
|
NSString *user_gsroot = nil;
|
|
|
|
|
2002-02-13 21:57:48 +00:00
|
|
|
user_gsroot = [NSSearchPathForDirectoriesInDomains(NSUserDirectory,
|
|
|
|
NSUserDomainMask, YES) lastObject];
|
|
|
|
|
|
|
|
if (currentLanguage != nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSString *dirPath = nil;
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
|
|
|
|
// Build the path and try to get the dictionary
|
2001-06-23 14:11:09 +00:00
|
|
|
dirPath = [user_gsroot stringByAppendingPathComponent: GNU_UserDictionariesDir];
|
2001-06-21 01:05:11 +00:00
|
|
|
path = [dirPath stringByAppendingPathComponent: currentLanguage];
|
|
|
|
|
|
|
|
if (![mgr fileExistsAtPath: path ])
|
|
|
|
{
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([mgr fileExistsAtPath: dirPath])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
// The directory exists create the file.
|
|
|
|
NSArray *emptyDict = [NSArray array];
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (![emptyDict writeToFile: path atomically: YES])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Failed to create %@",path);
|
|
|
|
path = nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The directory does not exist create it.
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([mgr createDirectoryAtPath: dirPath attributes: nil])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
// Directory created. Now create the empty file.
|
|
|
|
NSArray *emptyDict = [NSArray array];
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (![emptyDict writeToFile: path atomically: YES])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Failed to create %@",path);
|
|
|
|
path = nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"Failed to create %@",dirPath);
|
|
|
|
path = nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Private method
|
2004-01-07 04:38:15 +00:00
|
|
|
/** Open up dictionary stored in the user's directory. */
|
2001-06-21 01:05:11 +00:00
|
|
|
- (NSMutableSet *)_openUserDictionary: (NSString *)language
|
|
|
|
{
|
|
|
|
NSString *path = nil;
|
|
|
|
NSMutableSet *words = nil;
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ((words = [_userDictionaries objectForKey: language]) == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
2005-11-16 11:34:25 +00:00
|
|
|
if ((path = [self _pathToDictionary: language]) != nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSArray *wordarray = [NSArray arrayWithContentsOfFile: path];
|
2005-11-16 11:34:25 +00:00
|
|
|
if (wordarray == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Unable to load user dictionary from path %@",path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
words = [NSMutableSet setWithArray: wordarray];
|
|
|
|
[_userDictionaries setObject: words forKey: language];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"Unable to find user dictionary at: %@", path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// successful in opening the desired dictionary..
|
|
|
|
return words;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checking User Dictionaries
|
2004-01-07 04:38:15 +00:00
|
|
|
/** Check if word is in dict, flag determines if the search is case sensitive. */
|
2001-06-21 01:05:11 +00:00
|
|
|
- (BOOL)_isWord: (NSString *)word
|
|
|
|
inDictionary: (NSSet *)dict
|
|
|
|
caseSensitive: (BOOL)flag
|
|
|
|
{
|
|
|
|
BOOL result = NO;
|
|
|
|
NSString *dictWord = nil;
|
2001-07-24 04:31:06 +00:00
|
|
|
NSEnumerator *setEnumerator = nil;
|
2001-06-21 01:05:11 +00:00
|
|
|
|
|
|
|
// Catch the odd cases before they start trouble later on...
|
2005-11-16 11:34:25 +00:00
|
|
|
if (word == nil || dict == nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return NO; // avoid checking, if NIL.
|
|
|
|
}
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([word length] == 0 || [dict count] == 0)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
return NO; // avoid checking, if has no length.
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
// Check the dictionary for the word...
|
2001-07-24 04:31:06 +00:00
|
|
|
setEnumerator = [dict objectEnumerator];
|
2005-11-16 11:34:25 +00:00
|
|
|
while ((dictWord = [setEnumerator nextObject]) && result == NO)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
// If the case is important then uppercase both strings
|
|
|
|
// and compare, otherwise do the comparison.
|
2005-11-16 11:34:25 +00:00
|
|
|
if (flag == NO)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSString *upperWord = [word uppercaseString];
|
|
|
|
NSString *upperDictWord = [dictWord uppercaseString];
|
|
|
|
|
|
|
|
result = [upperWord isEqualToString: upperDictWord];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = [word isEqualToString: dictWord];
|
|
|
|
}
|
|
|
|
}
|
2001-07-24 04:31:06 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (result == NO && _ignoredWords)
|
2001-07-24 04:31:06 +00:00
|
|
|
{
|
|
|
|
NSEnumerator *arrayEnumerator = [_ignoredWords objectEnumerator];
|
|
|
|
NSString *iword = nil;
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
while ((iword = [arrayEnumerator nextObject]) && result == NO)
|
2001-07-24 04:31:06 +00:00
|
|
|
{
|
|
|
|
// If the case is important then uppercase both strings
|
|
|
|
// and compare, otherwise do the comparison.
|
2005-11-16 11:34:25 +00:00
|
|
|
if (flag == NO)
|
2001-07-24 04:31:06 +00:00
|
|
|
{
|
|
|
|
NSString *upperWord = [word uppercaseString];
|
|
|
|
NSString *upperIWord = [iword uppercaseString];
|
|
|
|
|
|
|
|
result = [upperWord isEqualToString: upperIWord];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = [word isEqualToString: iword];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-21 01:05:11 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checking User Dictionaries
|
2004-01-07 04:38:15 +00:00
|
|
|
/**
|
|
|
|
Checks to see if the word is in the user's dictionary. The user dictionary
|
|
|
|
is a set of words learned by the spell service for that particular user.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (BOOL)isWordInUserDictionaries:(NSString *)word
|
|
|
|
caseSensitive:(BOOL)flag
|
|
|
|
{
|
2001-07-24 04:31:06 +00:00
|
|
|
NSSet *userDict = [self _openUserDictionary: _currentLanguage];
|
2001-06-21 01:05:11 +00:00
|
|
|
BOOL result = NO;
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if (userDict)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
result = [self _isWord: word
|
2001-06-23 14:11:09 +00:00
|
|
|
inDictionary: userDict
|
|
|
|
caseSensitive: flag];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 04:38:15 +00:00
|
|
|
/** Save the dictionary stored in user's directory. */
|
2001-06-21 01:05:11 +00:00
|
|
|
- (BOOL)_saveUserDictionary: (NSString *)language
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
NSString *path = nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ((path = [self _pathToDictionary: language]) != nil)
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSMutableSet *set = [_userDictionaries objectForKey: language];
|
2005-11-16 11:34:25 +00:00
|
|
|
if (![[set allObjects] writeToFile: path atomically: YES])
|
2001-06-21 01:05:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"Unable to save dictionary to path %@",path);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"Unable to save dictionary at: %@", path);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
// successful in saving the desired dictionary..
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 04:38:15 +00:00
|
|
|
/** Learn a new word and put it into the dictionary. */
|
2001-06-21 01:05:11 +00:00
|
|
|
-(BOOL)_learnWord: (NSString *)word
|
|
|
|
inDictionary: (NSString *)language
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2001-06-21 01:05:11 +00:00
|
|
|
NSMutableSet *set = [self _openUserDictionary: language];
|
|
|
|
[set addObject: word];
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[_delegate spellServer: self
|
2001-06-23 14:11:09 +00:00
|
|
|
didLearnWord: word
|
|
|
|
inLanguage: language];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
2001-06-23 14:11:09 +00:00
|
|
|
NSLog(@"Call to delegate cause the following exception: %@",
|
2001-06-21 01:05:11 +00:00
|
|
|
[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
|
|
|
return [self _saveUserDictionary: language];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 04:38:15 +00:00
|
|
|
/** Forget a word and remove it from the dictionary. */
|
2001-06-21 01:05:11 +00:00
|
|
|
-(BOOL)_forgetWord: (NSString *)word
|
|
|
|
inDictionary: (NSString *)language
|
|
|
|
{
|
|
|
|
NSMutableSet *set = [self _openUserDictionary: language];
|
|
|
|
[set removeObject: word];
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[_delegate spellServer: self
|
2001-06-23 14:11:09 +00:00
|
|
|
didForgetWord: word
|
|
|
|
inLanguage: language];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
2001-06-23 14:11:09 +00:00
|
|
|
NSLog(@"Call to delegate caused following exception: %@",
|
2001-06-21 01:05:11 +00:00
|
|
|
[localException reason]);
|
|
|
|
}
|
2001-07-24 04:31:06 +00:00
|
|
|
NS_ENDHANDLER
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-06-21 01:05:11 +00:00
|
|
|
return [self _saveUserDictionary: language];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2004-01-07 04:38:15 +00:00
|
|
|
/** Find a misspelled word. */
|
2001-06-21 01:05:11 +00:00
|
|
|
- (NSRange)_findMisspelledWordInString: (NSString *)stringToCheck
|
|
|
|
language: (NSString *)language
|
2001-07-24 04:31:06 +00:00
|
|
|
ignoredWords: (NSArray *)ignoredWords
|
2001-06-21 01:05:11 +00:00
|
|
|
wordCount: (int *)wordCount
|
|
|
|
countOnly: (BOOL)countOnly
|
|
|
|
{
|
|
|
|
NSRange r = NSMakeRange(0,0);
|
|
|
|
|
|
|
|
// Forward to delegate
|
|
|
|
NS_DURING
|
|
|
|
{
|
2001-07-24 04:31:06 +00:00
|
|
|
ASSIGN(_ignoredWords,ignoredWords);
|
2001-06-21 01:05:11 +00:00
|
|
|
r = [_delegate spellServer: self
|
2001-07-24 04:31:06 +00:00
|
|
|
findMisspelledWordInString: stringToCheck
|
|
|
|
language: language
|
|
|
|
wordCount: wordCount
|
|
|
|
countOnly: countOnly];
|
|
|
|
_ignoredWords = nil;
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSLog(@"Call to delegate caused the following exception: %@",
|
|
|
|
[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2004-01-07 04:38:15 +00:00
|
|
|
/** Suggest a correction for the word. */
|
2001-06-21 01:05:11 +00:00
|
|
|
- (NSArray *)_suggestGuessesForWord: (NSString *)word
|
|
|
|
inLanguage: (NSString *)language
|
|
|
|
{
|
|
|
|
NSArray *words = nil;
|
|
|
|
|
|
|
|
// Forward to delegate
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
words = [_delegate spellServer: self
|
2001-06-23 14:11:09 +00:00
|
|
|
suggestGuessesForWord: word
|
|
|
|
inLanguage: language];
|
2001-06-21 01:05:11 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSLog(@"Call to delegate caused the following exception: %@",
|
|
|
|
[localException reason]);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
|
|
|
return words;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|