Revision: 4914
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4914&view=rev
Author:   hofman
Date:     2008-11-04 11:20:56 +0000 (Tue, 04 Nov 2008)

Log Message:
-----------
some fixes and improvements to grab script command

Modified Paths:
--------------
    trunk/PDFPage_SKExtensions.m
    trunk/Skim.sdef

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2008-11-03 21:20:48 UTC (rev 4913)
+++ trunk/PDFPage_SKExtensions.m        2008-11-04 11:20:56 UTC (rev 4914)
@@ -488,11 +488,10 @@
        NSDictionary *args = [command evaluatedArguments];
     NSData *boundsData = [args objectForKey:@"Bounds"];
     id asTIFF = [args objectForKey:@"AsTIFF"];
-    NSAppleEventDescriptor *desc = nil;
+    NSData *data = nil;
+    DescType type = 'PDF ';
     
-    if ([asTIFF respondsToSelector:@selector(boolValue)] == NO)
-        return nil;
-    if ([asTIFF boolValue]) {
+    if ([asTIFF respondsToSelector:@selector(boolValue)] && [asTIFF 
boolValue]) {
         NSImage *pageImage = [self imageForBox:kPDFDisplayBoxMediaBox];
         if (boundsData) {
             NSRect pageBounds = [self boundsForBox:kPDFDisplayBoxMediaBox];
@@ -507,11 +506,13 @@
             [image lockFocus];
             [pageImage drawInRect:targetRect fromRect:sourceRect 
operation:NSCompositeCopy fraction:1.0];
             [image unlockFocus];
-            pageImage = image;
+            data = [image TIFFRepresentation];
+        } else {
+            data = [pageImage TIFFRepresentation];
         }
-        desc = [NSAppleEventDescriptor descriptorWithDescriptorType:'TIFF' 
data:[pageImage TIFFRepresentation]];
+        type = typeTIFF;
     } else {
-        NSData *data = [self dataRepresentation];
+        data = [self dataRepresentation];
         if (boundsData) {
             if ([boundsData isKindOfClass:[NSData class]] == NO)
                 return nil;
@@ -534,11 +535,9 @@
             data = [page dataRepresentation];
             [page release];
         }
-        if (data)
-            desc = [NSAppleEventDescriptor descriptorWithDescriptorType:'PDF ' 
data:data];
     }
     
-    return desc;
+    return data ? [NSAppleEventDescriptor descriptorWithDescriptorType:type 
data:data] : nil;
 }
 
 @end

Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef     2008-11-03 21:20:48 UTC (rev 4913)
+++ trunk/Skim.sdef     2008-11-04 11:20:56 UTC (rev 4914)
@@ -653,7 +653,7 @@
                                <cocoa method=""/>
                        </responds-to>
                        <responds-to name="grab">
-                               <cocoa method="handleGrabScriptCommand"/>
+                               <cocoa method="handleGrabScriptCommand:"/>
                        </responds-to>
         </class>
 
@@ -1334,11 +1334,11 @@
                 <cocoa key="Bounds"/>
             </parameter>
             <parameter name="TIFF format" type="boolean" code="Tiff" 
optional="yes"
-                description="The format for the picture.">
+                description="Whether to return TIFF data. By default returns 
PDF data.">
                 <cocoa key="AsTIFF"/>
             </parameter>
             <result type="any"
-                description="The data of the picture."/>
+                description="The PDF or TIFF data of the picture."/>
         </command>
 
     </suite>


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 Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to