~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Source/NSSpellServer.m

Tags: upstream-1.20.0
ImportĀ upstreamĀ versionĀ 1.20.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
28
*/ 
29
29
 
30
 
#include "config.h"
31
 
#include "Foundation/NSSpellServer.h"
32
 
#include "Foundation/NSDictionary.h"
33
 
#include "Foundation/NSRunLoop.h"
34
 
#include "Foundation/NSFileManager.h"
35
 
#include "Foundation/NSUserDefaults.h"
36
 
#include "Foundation/NSPathUtilities.h"
37
 
#include "Foundation/NSConnection.h"
38
 
#include "Foundation/NSProcessInfo.h"
39
 
#include "Foundation/NSString.h"
40
 
#include "Foundation/NSException.h"
41
 
#include "Foundation/NSSet.h"
 
30
#import "common.h"
 
31
#define EXPOSE_NSSpellServer_IVARS      1
 
32
#import "Foundation/NSSpellServer.h"
 
33
#import "Foundation/NSDictionary.h"
 
34
#import "Foundation/NSRunLoop.h"
 
35
#import "Foundation/NSFileManager.h"
 
36
#import "Foundation/NSUserDefaults.h"
 
37
#import "Foundation/NSPathUtilities.h"
 
38
#import "Foundation/NSConnection.h"
 
39
#import "Foundation/NSProcessInfo.h"
 
40
#import "Foundation/NSException.h"
 
41
#import "Foundation/NSSet.h"
42
42
 
43
43
NSString *const NSGrammarRange = @"NSGrammarRange";
44
44
NSString *const NSGrammarUserDescription = @"NSGrammarUserDescription";
122
122
  connection = [[NSConnection alloc] init];
123
123
  if (connection)
124
124
    {
125
 
      RETAIN(connection);
 
125
      IF_NO_GC(RETAIN(connection);)
126
126
      [connection setRootObject: self];
127
127
      result = [connection registerName: serverName];
128
128
    }
150
150
- (void) setDelegate: (id)anObject
151
151
{
152
152
  /* FIXME - we should not retain the delegate ! */
153
 
  RETAIN(anObject);
 
153
  IF_NO_GC(RETAIN(anObject);)
154
154
  ASSIGN(_delegate, anObject);
155
155
}
156
156
 
301
301
          result = [word isEqualToString: dictWord];
302
302
        }
303
303
    }
 
304
  
 
305
  return result;
 
306
}
 
307
 
 
308
// Checking User Dictionaries
 
309
/** 
 
310
Checks to see if the word is in the user's dictionary.  The user dictionary
 
311
is a set of words learned by the spell service for that particular user
 
312
combined with the set of ignored words in the current document.
 
313
*/
 
314
- (BOOL) isWordInUserDictionaries: (NSString *)word
 
315
                    caseSensitive: (BOOL)flag
 
316
{
 
317
  NSSet *userDict = [self _openUserDictionary: _currentLanguage];
 
318
  BOOL result = NO;
 
319
 
 
320
  if (userDict)
 
321
    {
 
322
      result = [self _isWord: word
 
323
                inDictionary: userDict
 
324
               caseSensitive: flag];
 
325
    }
304
326
 
305
327
  if (result == NO && _ignoredWords)
306
328
    {
324
346
            }
325
347
        }      
326
348
    }
327
 
  
328
 
  return result;
329
 
}
330
 
 
331
 
// Checking User Dictionaries
332
 
/** 
333
 
Checks to see if the word is in the user's dictionary.  The user dictionary
334
 
is a set of words learned by the spell service for that particular user.
335
 
*/
336
 
- (BOOL) isWordInUserDictionaries: (NSString *)word
337
 
                    caseSensitive: (BOOL)flag
338
 
{
339
 
  NSSet *userDict = [self _openUserDictionary: _currentLanguage];
340
 
  BOOL result = NO;
341
 
 
342
 
  if (userDict)
343
 
    {
344
 
      result = [self _isWord: word
345
 
                inDictionary: userDict
346
 
               caseSensitive: flag];
347
 
    }
348
349
 
349
350
  return result;
350
351
}
423
424
- (NSRange) _findMisspelledWordInString: (NSString *)stringToCheck
424
425
                               language: (NSString *)language
425
426
                           ignoredWords: (NSArray *)ignoredWords
426
 
                              wordCount: (int *)wordCount
 
427
                              wordCount: (int32_t *)wordCount
427
428
                              countOnly: (BOOL)countOnly
428
429
{
429
430
  NSRange r = NSMakeRange(0,0);