Revision: 5000
http://skim-app.svn.sourceforge.net/skim-app/?rev=5000&view=rev
Author: hofman
Date: 2008-11-27 12:20:18 +0000 (Thu, 27 Nov 2008)
Log Message:
-----------
Use generic data method to get data for images to write to pasteboard
Modified Paths:
--------------
trunk/SKPDFView.m
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-11-26 22:08:23 UTC (rev 4999)
+++ trunk/SKPDFView.m 2008-11-27 12:20:18 UTC (rev 5000)
@@ -1773,60 +1773,15 @@
NSMutableArray *writeTypes = [NSMutableArray array];
NSData *pdfData = nil;
NSData *tiffData = nil;
-
NSRect selRect = NSIntegralRect(selectionRect);
- NSRect targetRect = selRect;
- if ([types containsObject:NSPDFPboardType]) {
- PDFPage *page = [self currentSelectionPage];
-
- if ([page rotation]) {
- NSAffineTransform *transform = [NSAffineTransform transform];
- NSRect bounds = [page boundsForBox:kPDFDisplayBoxMediaBox];
- switch ([page rotation]) {
- case 90:
- [transform translateXBy:0.0 yBy:NSWidth(bounds)];
- break;
- case 180:
- [transform translateXBy:NSWidth(bounds)
yBy:NSHeight(bounds)];
- break;
- case 270:
- [transform translateXBy:NSHeight(bounds) yBy:0.0];
- break;
- }
- [transform rotateByDegrees:-[page rotation]];
- targetRect = [transform transformRect:targetRect];
- }
-
- PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[page
dataRepresentation]];
- page = [pdfDoc pageAtIndex:0];
- [page setBounds:targetRect forBox:kPDFDisplayBoxCropBox];
- [page setBounds:NSZeroRect forBox:kPDFDisplayBoxBleedBox];
- [page setBounds:NSZeroRect forBox:kPDFDisplayBoxTrimBox];
- [page setBounds:NSZeroRect forBox:kPDFDisplayBoxArtBox];
-
- if (pdfData = [page dataRepresentation])
- [writeTypes addObject:NSPDFPboardType];
- [pdfDoc release];
- }
+ if ([types containsObject:NSPDFPboardType] &&
+ (pdfData = [[self currentSelectionPage] PDFDataForRect:selRect]))
+ [writeTypes addObject:NSPDFPboardType];
- if ([types containsObject:NSTIFFPboardType]) {
- NSRect bounds = [[self currentPage] boundsForBox:[self
displayBox]];
- NSRect sourceRect = selRect;
- NSImage *pageImage = [[self currentPage] imageForBox:[self
displayBox]];
- NSImage *image = nil;
-
- sourceRect.origin = SKSubstractPoints(sourceRect.origin,
bounds.origin);
- targetRect.origin = NSZeroPoint;
- targetRect.size = sourceRect.size;
- image = [[NSImage alloc] initWithSize:targetRect.size];
- [image lockFocus];
- [pageImage drawInRect:targetRect fromRect:sourceRect
operation:NSCompositeCopy fraction:1.0];
- [image unlockFocus];
- if (tiffData = [image TIFFRepresentation])
- [writeTypes addObject:NSTIFFPboardType];
- [image release];
- }
+ if ([types containsObject:NSTIFFPboardType] &&
+ (tiffData = [[self currentSelectionPage] TIFFDataForRect:selRect]))
+ [writeTypes addObject:NSTIFFPboardType];
[pboard declareTypes:writeTypes owner:nil];
if (pdfData)
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