Revision: 7063
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7063&view=rev
Author:   hofman
Date:     2011-01-10 10:42:31 +0000 (Mon, 10 Jan 2011)

Log Message:
-----------
convenience method for equal case insensitive strings

Modified Paths:
--------------
    trunk/NSDocument_SKExtensions.m
    trunk/NSString_SKExtensions.h
    trunk/NSString_SKExtensions.m
    trunk/SKFileUpdateChecker.m
    trunk/SKMainDocument.m
    trunk/SKNotesDocument.m
    trunk/SKTemplateParser.m
    trunk/SKTypeSelectHelper.m

Modified: trunk/NSDocument_SKExtensions.m
===================================================================
--- trunk/NSDocument_SKExtensions.m     2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/NSDocument_SKExtensions.m     2011-01-10 10:42:31 UTC (rev 7063)
@@ -185,7 +185,7 @@
 
 - (NSFileWrapper *)notesFileWrapperUsingTemplateFile:(NSString *)templateFile {
     NSFileWrapper *fileWrapper = nil;
-    if ([[templateFile pathExtension] caseInsensitiveCompare:@"rtfd"] == 
NSOrderedSame) {
+    if ([[templateFile pathExtension] isCaseInsensitiveEqual:@"rtfd"]) {
         NSString *templatePath = [[NSFileManager defaultManager] 
pathForApplicationSupportFile:[templateFile stringByDeletingPathExtension] 
ofType:[templateFile pathExtension] inDirectory:TEMPLATES_FOLDER_NAME];
         NSDictionary *docAttributes = nil;
         NSAttributedString *templateAttrString = [[NSAttributedString alloc] 
initWithPath:templatePath documentAttributes:&docAttributes];

Modified: trunk/NSString_SKExtensions.h
===================================================================
--- trunk/NSString_SKExtensions.h       2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/NSString_SKExtensions.h       2011-01-10 10:42:31 UTC (rev 7063)
@@ -57,6 +57,8 @@
 
 - (NSComparisonResult)localizedCaseInsensitiveNumericCompare:(NSString *)aStr;
 
+- (BOOL)isCaseInsensitiveEqual:(NSString *)aString;
+
 - (NSString *)lossyASCIIString;
 - (NSString *)lossyISOLatin1String;
 

Modified: trunk/NSString_SKExtensions.m
===================================================================
--- trunk/NSString_SKExtensions.m       2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/NSString_SKExtensions.m       2011-01-10 10:42:31 UTC (rev 7063)
@@ -295,6 +295,10 @@
                   locale:[NSLocale currentLocale]];
 }
 
+- (BOOL)isCaseInsensitiveEqual:(NSString *)aString {
+    return [aString caseInsensitiveCompare:aString] == NSOrderedSame;
+}
+
 - (NSString *)lossyASCIIString {
     return [[[NSString alloc] initWithData:[self 
dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] 
encoding:NSASCIIStringEncoding] autorelease];
 }

Modified: trunk/SKFileUpdateChecker.m
===================================================================
--- trunk/SKFileUpdateChecker.m 2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/SKFileUpdateChecker.m 2011-01-10 10:42:31 UTC (rev 7063)
@@ -43,6 +43,7 @@
 #import "NSData_SKExtensions.h"
 #import <SkimNotes/SkimNotes.h>
 #import "NSUserDefaultsController_SKExtensions.h"
+#import "NSString_SKExtensions.h"
 
 #define SKAutoReloadFileUpdateKey @"SKAutoReloadFileUpdate"
 
@@ -184,11 +185,11 @@
     if (extension) {
         NSWorkspace *ws = [NSWorkspace sharedWorkspace];
         NSString *theUTI = [ws typeOfFile:[[fileName 
stringByStandardizingPath] stringByResolvingSymlinksInPath] error:NULL];
-        if ([extension caseInsensitiveCompare:@"pdfd"] == NSOrderedSame || [ws 
type:theUTI conformsToType:@"net.sourceforge.skim-app.pdfd"]) {
+        if ([extension isCaseInsensitiveEqual:@"pdfd"] || [ws type:theUTI 
conformsToType:@"net.sourceforge.skim-app.pdfd"]) {
             fileName = [[NSFileManager defaultManager] 
bundledFileWithExtension:@"pdf" inPDFBundleAtPath:fileName error:NULL];
             if (fileName == nil)
                 return NO;
-        } else if ([extension caseInsensitiveCompare:@"dvi"] == NSOrderedSame 
|| [extension caseInsensitiveCompare:@"xdv"] == NSOrderedSame) {
+        } else if ([extension :@"dvi"] || [extension 
isCaseInsensitiveEqual:@"xdv"]) {
             isDVI = YES;
         }
     }

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/SKMainDocument.m      2011-01-10 10:42:31 UTC (rev 7063)
@@ -494,7 +494,7 @@
 }
 
 - (NSFileWrapper *)PDFBundleFileWrapperForName:(NSString *)name {
-    if ([name caseInsensitiveCompare:BUNDLE_DATA_FILENAME] == NSOrderedSame)
+    if ([name isCaseInsensitiveEqual:BUNDLE_DATA_FILENAME])
         name = [name stringByAppendingString:@"1"];
     NSData *data;
     NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] 
initDirectoryWithFileWrappers:[NSDictionary dictionary]];
@@ -576,7 +576,7 @@
             didWrite = [data writeToURL:absoluteURL options:0 error:&error];
         else 
             error = [NSError errorWithDomain:SKDocumentErrorDomain 
code:SKWriteFileError userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to write notes as FDF", 
@"Error description"), NSLocalizedDescriptionKey, nil]];
-    } else if ([[typeName pathExtension] caseInsensitiveCompare:@"rtfd"] == 
NSOrderedSame) {
+    } else if ([[typeName pathExtension] isCaseInsensitiveEqual:@"rtfd"]) {
         NSFileWrapper *fileWrapper = [self 
notesFileWrapperUsingTemplateFile:typeName];
         if (fileWrapper)
             didWrite = [fileWrapper writeToFile:[absoluteURL path] 
atomically:NO updateFilenames:NO];
@@ -903,7 +903,7 @@
     NSString *extension = [[notesURL path] pathExtension];
     NSArray *array = nil;
     
-    if ([extension caseInsensitiveCompare:@"skim"] == NSOrderedSame) {
+    if ([extension isCaseInsensitiveEqual:@"skim"]) {
         array = [NSKeyedUnarchiver unarchiveObjectWithFile:[notesURL path]];
     } else {
         NSData *fdfData = [NSData dataWithContentsOfURL:notesURL];
@@ -1101,7 +1101,7 @@
     NSString *scriptFormat = nil;
     NSString *mailAppID = [(NSString 
*)LSCopyDefaultHandlerForURLScheme(CFSTR("mailto")) autorelease];
     
-    if ([@"com.microsoft.entourage" caseInsensitiveCompare:mailAppID] == 
NSOrderedSame) {
+    if ([@"com.microsoft.entourage" isCaseInsensitiveEqual:mailAppID]) {
         scriptFormat = @"tell application \"Microsoft Entourage\"\n"
                        @"activate\n"
                        @"set m to make new draft window with properties 
{subject:\"%...@\", visible:true}\n"
@@ -1109,7 +1109,7 @@
                        @"make new attachment with properties {file:POSIX file 
\"%...@\"}\n"
                        @"end tell\n"
                        @"end tell\n";
-    } else if ([@"com.barebones.mailsmith" caseInsensitiveCompare:mailAppID] 
== NSOrderedSame) {
+    } else if ([@"com.barebones.mailsmith" isCaseInsensitiveEqual:mailAppID]) {
         scriptFormat = @"tell application \"Mailsmith\"\n"
                        @"activate\n"
                        @"set m to make new message window with properties 
{subject:\"%...@\", visible:true}\n"
@@ -1117,7 +1117,7 @@
                        @"make new enclosure with properties {file:POSIX file 
\"%...@\"}\n"
                        @"end tell\n"
                        @"end tell\n";
-    } else if ([@"com.mailplaneapp.Mailplane" 
caseInsensitiveCompare:mailAppID] == NSOrderedSame) {
+    } else if ([@"com.mailplaneapp.Mailplane" 
isCaseInsensitiveEqual:mailAppID]) {
         scriptFormat = @"tell application \"Mailplane\"\n"
                        @"activate\n"
                        @"set m to make new outgoing message with properties 
{subject:\"%...@\", visible:true}\n"
@@ -1125,12 +1125,12 @@
                        @"make new mail attachment with properties 
{path:\"%...@\"}\n"
                        @"end tell\n"
                        @"end tell\n";
-    } else if ([@"com.postbox-inc.postboxexpress" 
caseInsensitiveCompare:mailAppID] == NSOrderedSame) {
+    } else if ([@"com.postbox-inc.postboxexpress" 
isCaseInsensitiveEqual:mailAppID]) {
         scriptFormat = @"tell application \"PostboxExpress\"\n"
                        @"activate\n"
                        @"send message subject \"%...@\" attachment \"%...@\"\n"
                        @"end tell\n";
-    } else if ([@"com.postbox-inc.postbox" caseInsensitiveCompare:mailAppID] 
== NSOrderedSame) {
+    } else if ([@"com.postbox-inc.postbox" isCaseInsensitiveEqual:mailAppID]) {
         scriptFormat = @"tell application \"Postbox\"\n"
                        @"activate\n"
                        @"send message subject \"%...@\" attachment \"%...@\"\n"

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/SKNotesDocument.m     2011-01-10 10:42:31 UTC (rev 7063)
@@ -213,13 +213,12 @@
 - (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError 
**)outError {
     NSFileWrapper *fileWrapper = nil;
     
-    if ([typeName isEqualToString:SKNotesDocumentType] || [typeName 
isEqualToString:SKNotesTextDocumentType] || [typeName 
isEqualToString:SKNotesRTFDocumentType] || [typeName 
isEqualToString:SKNotesFDFDocumentType] || [[typeName pathExtension] 
caseInsensitiveCompare:@"rtfd"] != NSOrderedSame) {
-        fileWrapper = [super fileWrapperOfType:typeName error:outError];
-    } else if ([typeName isEqualToString:SKNotesRTFDocumentType]) {
+    if ([typeName isEqualToString:SKNotesRTFDocumentType])
         fileWrapper = [self notesRTFDFileWrapper];
-    } else {
+    else if ([typeName isEqualToString:SKNotesDocumentType] || [typeName 
isEqualToString:SKNotesTextDocumentType] || [typeName 
isEqualToString:SKNotesRTFDocumentType] || [typeName 
isEqualToString:SKNotesFDFDocumentType] || [[typeName pathExtension] 
isCaseInsensitiveEqual:@"rtfd"] == NO)
+        fileWrapper = [super fileWrapperOfType:typeName error:outError];
+    else
         fileWrapper = [self notesFileWrapperUsingTemplateFile:typeName];
-    }
     
     if (fileWrapper == nil && outError != NULL)
         *outError = [NSError errorWithDomain:SKDocumentErrorDomain 
code:SKWriteFileError userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to write notes", 
@"Error description"), NSLocalizedDescriptionKey, nil]];

Modified: trunk/SKTemplateParser.m
===================================================================
--- trunk/SKTemplateParser.m    2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/SKTemplateParser.m    2011-01-10 10:42:31 UTC (rev 7063)
@@ -38,6 +38,7 @@
 
 #import "SKTemplateParser.h"
 #import "SKTemplateTag.h"
+#import "NSString_SKExtensions.h"
 
 #define START_TAG_OPEN_DELIM            @"<$"
 #define END_TAG_OPEN_DELIM              @"</$"
@@ -200,7 +201,7 @@
         NSString *stringValue = [keyValue templateStringValue] ?: @"";
         switch (matchType) {
             case SKTemplateTagMatchEqual:
-                return [stringValue caseInsensitiveCompare:matchString] == 
NSOrderedSame;
+                return [stringValue isCaseInsensitiveEqual:matchString];
             case SKTemplateTagMatchContain:
                 return [stringValue rangeOfString:matchString 
options:NSCaseInsensitiveSearch].location != NSNotFound;
             case SKTemplateTagMatchSmaller:

Modified: trunk/SKTypeSelectHelper.m
===================================================================
--- trunk/SKTypeSelectHelper.m  2011-01-09 12:22:20 UTC (rev 7062)
+++ trunk/SKTypeSelectHelper.m  2011-01-10 10:42:31 UTC (rev 7063)
@@ -38,6 +38,7 @@
 
 #import "SKTypeSelectHelper.h"
 #import "SKRuntime.h"
+#import "NSString_SKExtensions.h"
 
 #define SKWindowDidChangeFirstResponderNotification 
@"SKWindowDidChangeFirstResponderNotification"
 
@@ -365,7 +366,7 @@
         label = [[self searchCache] objectAtIndex:labelIndex];
         
         if (tshFlags.matchOption == SKFullStringMatch) {
-            if ([label caseInsensitiveCompare:searchString] == NSOrderedSame)
+            if ([label isCaseInsensitiveEqual:searchString])
                 return labelIndex;
         } else {
             if ([label containsStringStartingAtWord:searchString 
options:options range:NSMakeRange(0, [label length])]) {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to