Revision: 5369
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5369&view=rev
Author:   hofman
Date:     2009-05-08 12:07:59 +0000 (Fri, 08 May 2009)

Log Message:
-----------
improve document type checking for applescript save command

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

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2009-05-08 11:48:06 UTC (rev 5368)
+++ trunk/SKDocumentController.m        2009-05-08 12:07:59 UTC (rev 5369)
@@ -133,6 +133,9 @@
     RETURN_IF_IS_DOCUMENT_TYPE(BarePostScript);
     RETURN_IF_IS_DOCUMENT_TYPE(DVI);
     RETURN_IF_IS_DOCUMENT_TYPE(BareDVI);
+    if ([docType isEqualToString:@"PDF"]) return SKPDFDocumentType;
+    if ([docType isEqualToString:@"PostScript"]) return 
SKPostScriptDocumentType;
+    if ([docType isEqualToString:@"DVI"]) return SKDVIDocumentType;
     return docType;
 }
 

Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m       2009-05-08 11:48:06 UTC (rev 5368)
+++ trunk/SKPDFDocument.m       2009-05-08 12:07:59 UTC (rev 5369)
@@ -2023,36 +2023,33 @@
        NSDictionary *args = [command evaluatedArguments];
     id fileURL = [args objectForKey:@"File"];
     id fileType = [args objectForKey:@"FileType"];
-    // we don't want to expose the values of SKPDFDocumentType and 
SKPostScriptDocumentType to the user, we advertise these type as "PDF" and 
"PostScript".
-    if ([fileType isEqualToString:@"PDF"]) {
-        fileType = SKPDFDocumentType;
-        NSMutableDictionary *arguments = [[command arguments] mutableCopy];
-        [arguments setObject:fileType forKey:@"FileType"];
-        [command setArguments:arguments];
-        [arguments release];
-    } else if ([fileType isEqualToString:@"PostScript"]) {
-        fileType = SKPostScriptDocumentType;
-        NSMutableDictionary *arguments = [[command arguments] mutableCopy];
-        [arguments setObject:fileType forKey:@"FileType"];
-        [command setArguments:arguments];
-        [arguments release];
-    } else if ([fileType isEqualToString:@"DVI"]) {
-        fileType = SKDVIDocumentType;
-        NSMutableDictionary *arguments = [[command arguments] mutableCopy];
-        [arguments setObject:fileType forKey:@"FileType"];
-        [command setArguments:arguments];
-        [arguments release];
+    // we don't want to expose the pboard types or UTIs to the user
+    if (fileType) {
+        NSString *normalizedType = SKNormalizedDocumentType(fileType);
+        if ([fileType isEqualToString:normalizedType] == NO) {
+            fileType = SKPDFDocumentType;
+            NSMutableDictionary *arguments = [[command arguments] mutableCopy];
+            [arguments setObject:fileType forKey:@"FileType"];
+            [command setArguments:arguments];
+            [arguments release];
+        }
     }
     if (fileURL) {
         if ([fileURL isKindOfClass:[NSURL class]] == NO) {
             [command setScriptErrorNumber:NSArgumentsWrongScriptError];
             [command setScriptErrorString:@"The file is not a file or alias."];
         } else {
-            NSSaveOperationType saveOperation = fileType ? NSSaveToOperation : 
NSSaveAsOperation;
-            fileType = fileType ? SKNormalizedDocumentType(fileType) : 
SKPDFDocumentType;
+            NSSaveOperationType saveOperation = NSSaveToOperation;
+            NSString *extension = [[fileURL path] pathExtension];
             
+            if (fileType == nil) {
+                fileType = [[NSDocumentController sharedDocumentController] 
typeFromFileExtension:extension];
+                if (fileType == nil || [[self class] isNativeType:fileType] == 
NO || [[self writableTypesForSaveOperation:NSSaveAsOperation] 
containsObject:fileType] == NO)
+                    fileType = [self fileType];
+                saveOperation = NSSaveAsOperation;
+            }
+            
             NSString *requiredExtension = [self 
fileNameExtensionForType:fileType saveOperation:saveOperation];
-            NSString *extension = [[fileURL path] pathExtension];
             
             if (extension == nil && requiredExtension) {
                 extension = requiredExtension;


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