Revision: 5361
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5361&view=rev
Author:   hofman
Date:     2009-05-07 11:52:37 +0000 (Thu, 07 May 2009)

Log Message:
-----------
use generic methods to get readable document type UTIs to workaround 10.5 bug

Modified Paths:
--------------
    trunk/SKDocumentController.m

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2009-05-07 11:25:47 UTC (rev 5360)
+++ trunk/SKDocumentController.m        2009-05-07 11:52:37 UTC (rev 5361)
@@ -210,6 +210,22 @@
             object:self userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:document, @"document", nil]];
 }
 
+- (NSString *)readableTypeFromFileExtension:(NSString *)extension {
+    NSEnumerator *classEnum = [[self documentClassNames] objectEnumerator];
+    NSString *className;
+    while (className = [classEnum nextObject]) {
+        NSEnumerator *typeEnum = [[NSClassFromString(className) readableTypes] 
objectEnumerator];
+        NSString *type;
+        while (type = [typeEnum nextObject]) {
+            if ([[NSWorkspace sharedWorkspace] filenameExtension:extension 
isValidForType:type]) {
+                return type;
+                break;
+            }
+        }
+    }
+    return nil;
+}
+
 - (NSString *)typeForContentsOfURL:(NSURL *)inAbsoluteURL error:(NSError 
**)outError {
     NSUInteger headerLength = 5;
     
@@ -240,14 +256,7 @@
                 type = SKPostScriptDocumentType;
             } else if ([extension length]) {
                 // On 10.5 when another app declares a different UTI for one 
of our types, we may get their UTI, rdar://problem/6864895
-                if ([extension caseInsensitiveCompare:@"pdf"] == NSOrderedSame)
-                    type = SKPDFDocumentType;
-                else if ([extension caseInsensitiveCompare:@"ps"] == 
NSOrderedSame)
-                    type = SKPostScriptDocumentType;
-                else if ([extension caseInsensitiveCompare:@"dvi"] == 
NSOrderedSame)
-                    type = SKDVIDocumentType;
-                else if ([extension caseInsensitiveCompare:@"skim"] == 
NSOrderedSame)
-                    type = SKNotesDocumentType;
+                type = [self readableTypeFromFileExtension:extension] ?: type;
             }
         }
         if (type == nil && outError)


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

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to