Revision: 7476
http://skim-app.svn.sourceforge.net/skim-app/?rev=7476&view=rev
Author: hofman
Date: 2011-09-08 10:02:36 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
Don't copy or drag PDF from thumbnail view when the PDF does not allow
printing, as it does not work
Modified Paths:
--------------
trunk/SKMainWindowController_UI.m
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2011-09-08 09:49:00 UTC (rev 7475)
+++ trunk/SKMainWindowController_UI.m 2011-09-08 10:02:36 UTC (rev 7476)
@@ -304,12 +304,19 @@
NSUInteger idx = [rowIndexes firstIndex];
if (idx != NSNotFound) {
PDFPage *page = [[pdfView document] pageAtIndex:idx];
- NSData *pdfData = [page dataRepresentation];
+ NSString *filename = [self draggedFileNameForPage:page];
NSData *tiffData = [page TIFFDataForRect:[page
boundsForBox:[pdfView displayBox]]];
- [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType,
NSTIFFPboardType, NSFilesPromisePboardType, nil] owner:self];
- [pboard setData:pdfData forType:NSPDFPboardType];
+ if ([[pdfView document] allowsPrinting]) {
+ NSData *pdfData = [page dataRepresentation];
+ filename = [filename stringByAppendingPathExtension:@"pdf"];
+ [pboard declareTypes:[NSArray
arrayWithObjects:NSPDFPboardType, NSTIFFPboardType, NSFilesPromisePboardType,
nil] owner:self];
+ [pboard setData:pdfData forType:NSPDFPboardType];
+ } else {
+ filename = [filename stringByAppendingPathExtension:@"tiff"];
+ [pboard declareTypes:[NSArray
arrayWithObjects:NSTIFFPboardType, NSFilesPromisePboardType, nil] owner:self];
+ }
[pboard setData:tiffData forType:NSTIFFPboardType];
- [pboard setPropertyList:[NSArray arrayWithObject:[self
draggedFileNameForPage:page]] forType:NSFilesPromisePboardType];
+ [pboard setPropertyList:[NSArray arrayWithObject:filename]
forType:NSFilesPromisePboardType];
return YES;
}
} else if ([tv isEqual:rightSideController.snapshotTableView]) {
@@ -332,13 +339,24 @@
if (idx != NSNotFound) {
PDFPage *page = [[pdfView document] pageAtIndex:idx];
NSString *basePath = [[dropDestination path]
stringByAppendingPathComponent:[self draggedFileNameForPage:page]];
- NSString *path = [basePath stringByAppendingPathExtension:@"pdf"];
+ NSString *pathExt = nil;
+ NSData *data = nil;
+
+ if ([[pdfView document] allowsPrinting]) {
+ pathExt = @"pdf";
+ data = [page dataRepresentation];
+ } else {
+ pathExt = @"tiff";
+ data = [page TIFFDataForRect:[page boundsForBox:[pdfView
displayBox]]];
+ }
+
+ NSString *path = [basePath stringByAppendingPathExtension:pathExt];
NSFileManager *fm = [NSFileManager defaultManager];
NSInteger i = 0;
while ([fm fileExistsAtPath:path])
- path = [[basePath stringByAppendingFormat:@" - %ld",
(long)++i] stringByAppendingPathExtension:@"pdf"];
- if ([[page dataRepresentation] writeToFile:path atomically:YES])
+ path = [[basePath stringByAppendingFormat:@" - %ld",
(long)++i] stringByAppendingPathExtension:pathExt];
+ if ([data writeToFile:path atomically:YES])
return [NSArray arrayWithObjects:[path lastPathComponent],
nil];
}
} else if ([tv isEqual:rightSideController.snapshotTableView]) {
@@ -443,11 +461,15 @@
NSUInteger idx = [rowIndexes firstIndex];
if (idx != NSNotFound) {
PDFPage *page = [[pdfView document] pageAtIndex:idx];
- NSData *pdfData = [page dataRepresentation];
NSData *tiffData = [page TIFFDataForRect:[page
boundsForBox:[pdfView displayBox]]];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
- [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType,
NSTIFFPboardType, nil] owner:nil];
- [pboard setData:pdfData forType:NSPDFPboardType];
+ if ([[pdfView document] allowsPrinting]) {
+ NSData *pdfData = [page dataRepresentation];
+ [pboard declareTypes:[NSArray
arrayWithObjects:NSPDFPboardType, NSTIFFPboardType, nil] owner:nil];
+ [pboard setData:pdfData forType:NSPDFPboardType];
+ } else {
+ [pboard declareTypes:[NSArray
arrayWithObjects:NSTIFFPboardType, nil] owner:nil];
+ }
[pboard setData:tiffData forType:NSTIFFPboardType];
}
} else if ([tv isEqual:leftSideController.findTableView]) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops? How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit