Revision: 3773
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3773&view=rev
Author:   hofman
Date:     2008-04-19 06:30:50 -0700 (Sat, 19 Apr 2008)

Log Message:
-----------
Use proper method to get file extension for override of print script command on 
Leopard. Normalize document type to get the proper type for the system.

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

Modified: trunk/SKDocumentController.h
===================================================================
--- trunk/SKDocumentController.h        2008-04-19 13:13:57 UTC (rev 3772)
+++ trunk/SKDocumentController.h        2008-04-19 13:30:50 UTC (rev 3773)
@@ -52,6 +52,8 @@
 extern BOOL SKIsPostScriptDocumentType(NSString *docType);
 extern BOOL SKIsDVIDocumentType(NSString *docType);
 
+extern NSString *SKNormalizedDocumentType(NSString *docType);
+
 extern NSString *SKPDFDocumentType;
 extern NSString *SKPDFBundleDocumentType;
 extern NSString *SKEmbeddedPDFDocumentType;

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2008-04-19 13:13:57 UTC (rev 3772)
+++ trunk/SKDocumentController.m        2008-04-19 13:30:50 UTC (rev 3773)
@@ -122,6 +122,33 @@
     return SKIsEqualToDocumentType(docType, SKDVIDocumentTypeName, 
SKDVIDocumentUTI);
 }
 
+NSString *SKNormalizedDocumentType(NSString *docType) {
+    if (SKIsPDFDocumentType(docType))
+        return SKPDFDocumentType;
+    else if (SKIsPDFBundleDocumentType(docType))
+        return SKPDFBundleDocumentType;
+    else if (SKIsEmbeddedPDFDocumentType(docType))
+        return SKEmbeddedPDFDocumentType;
+    else if (SKIsBarePDFDocumentType(docType))
+        return SKBarePDFDocumentType;
+    else if (SKIsNotesDocumentType(docType))
+        return SKNotesDocumentType;
+    else if (SKIsNotesTextDocumentType(docType))
+        return SKNotesTextDocumentType;
+    else if (SKIsNotesRTFDocumentType(docType))
+        return SKNotesRTFDocumentType;
+    else if (SKIsNotesRTFDDocumentType(docType))
+        return SKNotesRTFDDocumentType;
+    else if (SKIsNotesFDFDocumentType(docType))
+        return SKNotesFDFDocumentType;
+    else if (SKIsPostScriptDocumentType(docType))
+        return SKPostScriptDocumentType;
+    else if (SKIsDVIDocumentType(docType))
+        return SKDVIDocumentType;
+    else
+        return SKPDFDocumentType;
+}
+
 @implementation SKDocumentController
 
 + (void)initialize {

Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m       2008-04-19 13:13:57 UTC (rev 3772)
+++ trunk/SKPDFDocument.m       2008-04-19 13:30:50 UTC (rev 3773)
@@ -1753,9 +1753,14 @@
             [command setScriptErrorNumber:NSArgumentsWrongScriptError];
             [command setScriptErrorString:@"The file is not a file or alias."];
         } else {
-            NSArray *fileExtensions = [[NSDocumentController 
sharedDocumentController] fileExtensionsFromType:fileType ? fileType : 
NSPDFPboardType];
+            NSArray *fileExtensions = nil;
             NSString *extension = [[fileURL path] pathExtension];
-            if (extension == nil) {
+            if (NSAppKitVersionNumber > NSAppKitVersionNumber10_4)
+                fileExtensions = [NSArray arrayWithObjects:[self 
fileNameExtensionForType:SKNormalizedDocumentType(fileType) 
saveOperation:fileType ? NSSaveToOperation : NSSaveAsOperation], nil];
+            else
+                fileExtensions = [[NSDocumentController 
sharedDocumentController] 
fileExtensionsFromType:SKNormalizedDocumentType(fileType)];
+            
+            if (extension == nil && [fileExtensions count]) {
                 extension = [fileExtensions objectAtIndex:0];
                 fileURL = [NSURL fileURLWithPath:[[fileURL path] 
stringByAppendingPathExtension:extension]];
             }
@@ -1763,7 +1768,7 @@
                 [command setScriptErrorNumber:NSArgumentsWrongScriptError];
                 [command setScriptErrorString:[NSString 
stringWithFormat:@"Invalid file extension for this file type."]];
             } else if (fileType) {
-                if ([self saveToURL:fileURL ofType:fileType 
forSaveOperation:NSSaveToOperation error:NULL] == NO) {
+                if ([self saveToURL:fileURL 
ofType:SKNormalizedDocumentType(fileType) forSaveOperation:NSSaveToOperation 
error:NULL] == NO) {
                     [command setScriptErrorNumber:NSInternalScriptError];
                     [command setScriptErrorString:@"Unable to export."];
                 }


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 the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to