Revision: 15282
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15282&view=rev
Author:   hofman
Date:     2009-05-07 11:58:28 +0000 (Thu, 07 May 2009)

Log Message:
-----------
add a workaround for the 10.5 bug where another app may override the UTI for 
one of our readable document type UTIs.

Modified Paths:
--------------
    trunk/bibdesk/BDSKDocumentController.m

Modified: trunk/bibdesk/BDSKDocumentController.m
===================================================================
--- trunk/bibdesk/BDSKDocumentController.m      2009-05-07 10:01:49 UTC (rev 
15281)
+++ trunk/bibdesk/BDSKDocumentController.m      2009-05-07 11:58:28 UTC (rev 
15282)
@@ -528,6 +528,35 @@
     return docClass;
 }
 
+- (NSString *)readableTypeFromFileExtension:(NSString *)extension {
+    if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4)
+        return nil;
+    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 {
+    NSString *type = [super typeForContentsOfURL:inAbsoluteURL error:outError];
+    if ([self documentClassForType:type] == Nil) {
+        // On 10.5 when another app declares a different UTI for one of our 
types, we may get their UTI, rdar://problem/6864895
+        NSString *extension = [[inAbsoluteURL path] pathExtension];
+        if ([extension length])
+            type = [self readableTypeFromFileExtension:extension] ?: type;
+    }
+    return type;
+}
+
 - (NSString *)displayNameForType:(NSString *)documentTypeName{
     NSString *displayName = nil;
     if([documentTypeName isEqualToString:BDSKMinimalBibTeXDocumentType])


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
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to