Revision: 3462
http://skim-app.svn.sourceforge.net/skim-app/?rev=3462&view=rev
Author: hofman
Date: 2008-03-11 06:14:13 -0700 (Tue, 11 Mar 2008)
Log Message:
-----------
Use UTI instead of old-ctyle document type on 10.5 for documents opened from
clipboard.
Modified Paths:
--------------
trunk/SKDocumentController.m
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2008-03-11 12:47:15 UTC (rev 3461)
+++ trunk/SKDocumentController.m 2008-03-11 13:14:13 UTC (rev 3462)
@@ -88,6 +88,14 @@
return type;
}
+static inline NSString *SKPDFDocumentTypeOrUTI(void) {
+ return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKPDFDocumentType : SKPDFDocumentUTI;
+}
+
+static inline NSString *SKPostScriptDocumentTypeOrUTI(void) {
+ return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 ?
SKPostScriptDocumentType : SKPostScriptDocumentUTI;
+}
+
- (NSString *)typeForContentsOfURL:(NSURL *)inAbsoluteURL error:(NSError
**)outError {
unsigned int headerLength = 5;
@@ -111,9 +119,9 @@
NSFileHandle *fh = [NSFileHandle
fileHandleForReadingAtPath:fileName];
NSData *leadingData = [fh readDataOfLength:headerLength];
if ([leadingData length] >= [pdfHeaderData length] &&
[pdfHeaderData isEqual:[leadingData subdataWithRange:NSMakeRange(0,
[pdfHeaderData length])]]) {
- type = floor(NSAppKitVersionNumber) <=
NSAppKitVersionNumber10_4 ? SKPDFDocumentType : SKPDFDocumentUTI;
+ type = SKPostScriptDocumentTypeOrUTI();
} else if ([leadingData length] >= [psHeaderData length] &&
[psHeaderData isEqual:[leadingData subdataWithRange:NSMakeRange(0,
[psHeaderData length])]]) {
- type = floor(NSAppKitVersionNumber) <=
NSAppKitVersionNumber10_4 ? SKPostScriptDocumentType : SKPostScriptDocumentUTI;
+ type = SKPostScriptDocumentTypeOrUTI();
}
}
if (type == nil && outError)
@@ -172,7 +180,7 @@
pboardType = NSPDFPboardType;
}
- NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ?
SKPostScriptDocumentType : SKPDFDocumentType;
+ NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ?
SKPostScriptDocumentTypeOrUTI() : SKPDFDocumentTypeOrUTI();
NSError *error = nil;
document = [self makeUntitledDocumentOfType:type error:&error];
@@ -219,7 +227,7 @@
- (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL
display:(BOOL)displayDocument error:(NSError **)outError {
NSString *type = [self typeForContentsOfURL:absoluteURL error:NULL];
- if ([type isEqualToString:SKNotesDocumentType]) {
+ if ([type isEqualToString:SKNotesDocumentType] || [type
isEqualToString:SKNotesDocumentUTI]) {
NSAppleEventDescriptor *event = [[NSAppleEventManager
sharedAppleEventManager] currentAppleEvent];
if ([event eventID] == kAEOpenDocuments && [event
descriptorForKeyword:keyAESearchText]) {
NSString *pdfFile = [[absoluteURL path]
stringByReplacingPathExtension:@"pdf"];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit