Revision: 4913
http://skim-app.svn.sourceforge.net/skim-app/?rev=4913&view=rev
Author: hofman
Date: 2008-11-03 21:20:48 +0000 (Mon, 03 Nov 2008)
Log Message:
-----------
Implement grab script command as object first command
Modified Paths:
--------------
trunk/PDFPage_SKExtensions.h
trunk/PDFPage_SKExtensions.m
trunk/Skim.sdef
trunk/Skim.xcodeproj/project.pbxproj
Removed Paths:
-------------
trunk/SKGrabCommand.h
trunk/SKGrabCommand.m
Modified: trunk/PDFPage_SKExtensions.h
===================================================================
--- trunk/PDFPage_SKExtensions.h 2008-11-03 19:30:31 UTC (rev 4912)
+++ trunk/PDFPage_SKExtensions.h 2008-11-03 21:20:48 UTC (rev 4913)
@@ -91,4 +91,6 @@
- (void)insertInNotes:(id)newNote atIndex:(unsigned int)index;
- (void)removeFromNotesAtIndex:(unsigned int)index;
+- (id)handleGrabScriptCommand:(NSScriptCommand *)command;
+
@end
Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m 2008-11-03 19:30:31 UTC (rev 4912)
+++ trunk/PDFPage_SKExtensions.m 2008-11-03 21:20:48 UTC (rev 4913)
@@ -484,4 +484,61 @@
[[pdfView undoManager] setActionName:NSLocalizedString(@"Remove Note",
@"Undo action name")];
}
+- (id)handleGrabScriptCommand:(NSScriptCommand *)command {
+ NSDictionary *args = [command evaluatedArguments];
+ NSData *boundsData = [args objectForKey:@"Bounds"];
+ id asTIFF = [args objectForKey:@"AsTIFF"];
+ NSAppleEventDescriptor *desc = nil;
+
+ if ([asTIFF respondsToSelector:@selector(boolValue)] == NO)
+ return nil;
+ if ([asTIFF boolValue]) {
+ NSImage *pageImage = [self imageForBox:kPDFDisplayBoxMediaBox];
+ if (boundsData) {
+ NSRect pageBounds = [self boundsForBox:kPDFDisplayBoxMediaBox];
+ NSRect bounds = [boundsData rectValueAsQDRect];
+ NSRect sourceRect = bounds;
+ NSRect targetRect = {NSZeroPoint, sourceRect.size};
+ NSImage *image = nil;
+
+ sourceRect.origin.x -= NSMinX(pageBounds);
+ sourceRect.origin.y -= NSMinY(pageBounds);
+ image = [[NSImage alloc] initWithSize:targetRect.size];
+ [image lockFocus];
+ [pageImage drawInRect:targetRect fromRect:sourceRect
operation:NSCompositeCopy fraction:1.0];
+ [image unlockFocus];
+ pageImage = image;
+ }
+ desc = [NSAppleEventDescriptor descriptorWithDescriptorType:'TIFF'
data:[pageImage TIFFRepresentation]];
+ } else {
+ NSData *data = [self dataRepresentation];
+ if (boundsData) {
+ if ([boundsData isKindOfClass:[NSData class]] == NO)
+ return nil;
+ PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:data];
+ PDFPage *page = [pdfDoc pageAtIndex:0];
+ NSRect bounds = [boundsData rectValueAsQDRect];
+
+ if (NSIsEmptyRect(bounds))
+ return nil;
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4) {
+ [page setBounds:bounds forBox:kPDFDisplayBoxMediaBox];
+ [page setBounds:NSZeroRect forBox:kPDFDisplayBoxCropBox];
+ } else {
+ // setting the media box is buggy on Tiger, see bug # 1928384
+ [page setBounds:bounds forBox:kPDFDisplayBoxCropBox];
+ }
+ [page setBounds:NSZeroRect forBox:kPDFDisplayBoxBleedBox];
+ [page setBounds:NSZeroRect forBox:kPDFDisplayBoxTrimBox];
+ [page setBounds:NSZeroRect forBox:kPDFDisplayBoxArtBox];
+ data = [page dataRepresentation];
+ [page release];
+ }
+ if (data)
+ desc = [NSAppleEventDescriptor descriptorWithDescriptorType:'PDF '
data:data];
+ }
+
+ return desc;
+}
+
@end
Deleted: trunk/SKGrabCommand.h
===================================================================
--- trunk/SKGrabCommand.h 2008-11-03 19:30:31 UTC (rev 4912)
+++ trunk/SKGrabCommand.h 2008-11-03 21:20:48 UTC (rev 4913)
@@ -1,43 +0,0 @@
-//
-// SKGrabCommand.h
-// Skim
-//
-// Created by Christiaan Hofman on 11/3/08.
-/*
- This software is Copyright (c) 2008
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-
[EMAIL PROTECTED] SKGrabCommand : NSScriptCommand
[EMAIL PROTECTED]
Deleted: trunk/SKGrabCommand.m
===================================================================
--- trunk/SKGrabCommand.m 2008-11-03 19:30:31 UTC (rev 4912)
+++ trunk/SKGrabCommand.m 2008-11-03 21:20:48 UTC (rev 4913)
@@ -1,107 +0,0 @@
-//
-// SKGrabCommand.m
-// Skim
-//
-// Created by Christiaan Hofman on 11/3/08.
-/*
- This software is Copyright (c) 2008
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SKGrabCommand.h"
-#import <Quartz/Quartz.h>
-#import "NSData_SKExtensions.h"
-#import "PDFPage_SKExtensions.h"
-
-
[EMAIL PROTECTED] SKGrabCommand
-
-- (id)performDefaultImplementation {
- NSDictionary *args = [self evaluatedArguments];
- PDFPage *page = [self evaluatedReceivers];
- NSData *boundsData = [args objectForKey:@"Bounds"];
- id asTIFF = [args objectForKey:@"AsTIFF"];
- NSAppleEventDescriptor *desc = nil;
-
- if ([page isKindOfClass:[PDFPage class]]) {
- if ([asTIFF boolValue]) {
- NSImage *pageImage = [page imageForBox:kPDFDisplayBoxMediaBox];
- if (boundsData) {
- NSRect pageBounds = [page boundsForBox:kPDFDisplayBoxMediaBox];
- NSRect bounds = [boundsData rectValueAsQDRect];
- NSRect sourceRect = bounds;
- NSRect targetRect = {NSZeroPoint,sourceRect.size };
- NSImage *image = nil;
-
- sourceRect.origin.x -= NSMinX(pageBounds);
- sourceRect.origin.y -= NSMinY(pageBounds);
- image = [[NSImage alloc] initWithSize:targetRect.size];
- [image lockFocus];
- [pageImage drawInRect:targetRect fromRect:sourceRect
operation:NSCompositeCopy fraction:1.0];
- [image unlockFocus];
- pageImage = image;
- }
- desc = [NSAppleEventDescriptor descriptorWithDescriptorType:'TIFF'
data:[pageImage TIFFRepresentation]];
- } else {
- NSData *data = nil;
- if (boundsData) {
- if ([boundsData isKindOfClass:[NSData class]] == NO)
- return nil;
- PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[page
dataRepresentation]];
- PDFPage *pageCopy = [pdfDoc pageAtIndex:0];
- NSRect bounds = [boundsData rectValueAsQDRect];
-
- if (NSIsEmptyRect(bounds))
- return nil;
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4) {
- [pageCopy setBounds:bounds forBox:kPDFDisplayBoxMediaBox];
- [pageCopy setBounds:NSZeroRect
forBox:kPDFDisplayBoxCropBox];
- } else {
- // setting the media box is buggy on Tiger, see bug #
1928384
- [pageCopy setBounds:bounds forBox:kPDFDisplayBoxCropBox];
- }
- [pageCopy setBounds:NSZeroRect forBox:kPDFDisplayBoxBleedBox];
- [pageCopy setBounds:NSZeroRect forBox:kPDFDisplayBoxTrimBox];
- [pageCopy setBounds:NSZeroRect forBox:kPDFDisplayBoxArtBox];
- data = [pageCopy dataRepresentation];
- [pdfDoc release];
- } else {
- data = [page dataRepresentation];
- }
- if (data)
- desc = [NSAppleEventDescriptor
descriptorWithDescriptorType:'PDF ' data:data];
- }
- }
-
- return desc;
-}
-
[EMAIL PROTECTED]
Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef 2008-11-03 19:30:31 UTC (rev 4912)
+++ trunk/Skim.sdef 2008-11-03 21:20:48 UTC (rev 4913)
@@ -653,7 +653,7 @@
<cocoa method=""/>
</responds-to>
<responds-to name="grab">
- <cocoa method=""/>
+ <cocoa method="handleGrabScriptCommand"/>
</responds-to>
</class>
@@ -1327,7 +1327,6 @@
<command name="grab" code="SKIMGrab"
description="Grab a picture from a page.">
- <cocoa class="SKGrabCommand"/>
<direct-parameter type="page"
description="The page for the picture."/>
<parameter name="for" type="rectangle" code="for " optional="yes"
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-11-03 19:30:31 UTC (rev
4912)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-11-03 21:20:48 UTC (rev
4913)
@@ -199,7 +199,6 @@
CEAFFD7D0C40ED5400C3ECBB /* ToolbarFonts.tiff in Resources */ =
{isa = PBXBuildFile; fileRef = CEAFFD7B0C40ED5400C3ECBB /* ToolbarFonts.tiff
*/; };
CEAFFD9D0C40F2A800C3ECBB /* ToolbarLines.tiff in Resources */ =
{isa = PBXBuildFile; fileRef = CEAFFD9C0C40F2A800C3ECBB /* ToolbarLines.tiff
*/; };
CEB735A20C4A8CD6000350F9 /* TransitionShading.tiff in Resources
*/ = {isa = PBXBuildFile; fileRef = CEB735A10C4A8CD6000350F9 /*
TransitionShading.tiff */; };
- CEBB6A7F0EBF793100F2768B /* SKGrabCommand.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEBB6A7E0EBF793100F2768B /* SKGrabCommand.m */;
};
CEBD52ED0C9C0AE500FBF6A4 /* SKBookmark.m in Sources */ = {isa =
PBXBuildFile; fileRef = CEBD52EB0C9C0AE500FBF6A4 /* SKBookmark.m */; };
CEBF85E20CCE2DE70057A050 /* NSAffineTransform_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEBF85E00CCE2DE70057A050 /*
NSAffineTransform_SKExtensions.m */; };
CEC3AD240E23EC0300F40B0B /* PDFAnnotationLink_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEC3AD230E23EC0300F40B0B /*
PDFAnnotationLink_SKExtensions.m */; };
@@ -811,8 +810,6 @@
CEAFFD9C0C40F2A800C3ECBB /* ToolbarLines.tiff */ = {isa =
PBXFileReference; lastKnownFileType = image.tiff; path = ToolbarLines.tiff;
sourceTree = "<group>"; };
CEB72B890C4A189D000350F9 /* SKTransitionController.h */ = {isa
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path
= SKTransitionController.h; sourceTree = "<group>"; };
CEB735A10C4A8CD6000350F9 /* TransitionShading.tiff */ = {isa =
PBXFileReference; lastKnownFileType = image.tiff; path =
TransitionShading.tiff; sourceTree = "<group>"; };
- CEBB6A7D0EBF793100F2768B /* SKGrabCommand.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKGrabCommand.h; sourceTree = "<group>"; };
- CEBB6A7E0EBF793100F2768B /* SKGrabCommand.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKGrabCommand.m; sourceTree = "<group>"; };
CEBD52EA0C9C0AE500FBF6A4 /* SKBookmark.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKBookmark.h; sourceTree = "<group>"; };
CEBD52EB0C9C0AE500FBF6A4 /* SKBookmark.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKBookmark.m; sourceTree = "<group>"; };
CEBF85DF0CCE2DE70057A050 /* NSAffineTransform_SKExtensions.h */
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.h; path = NSAffineTransform_SKExtensions.h; sourceTree =
"<group>"; };
@@ -1408,8 +1405,6 @@
children = (
CE4643DC0DF6B77800CFD8D2 /* SKBoundsCommand.h
*/,
CE4643DD0DF6B77800CFD8D2 /* SKBoundsCommand.m
*/,
- CEBB6A7D0EBF793100F2768B /* SKGrabCommand.h */,
- CEBB6A7E0EBF793100F2768B /* SKGrabCommand.m */,
CE4643D90DF6B66000CFD8D2 /* SKIndexCommand.h */,
CE4643DA0DF6B66000CFD8D2 /* SKIndexCommand.m */,
CE4643CD0DF6B5A400CFD8D2 /* SKJoinCommand.h */,
@@ -2135,7 +2130,6 @@
CED6A3120EADF37800E8CD11 /*
NSImageCell_SKExtensions.m in Sources */,
CEE0F5EB0EBB3DEC000A7A8C /*
SKLevelIndicatorCell.m in Sources */,
CE0A3C8E0EBF3AAA00526C74 /*
NSResponder_SKExtensions.m in Sources */,
- CEBB6A7F0EBF793100F2768B /* SKGrabCommand.m in
Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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