Revision: 2606 http://skim-app.svn.sourceforge.net/skim-app/?rev=2606&view=rev Author: hofman Date: 2007-08-05 13:29:27 -0700 (Sun, 05 Aug 2007)
Log Message: ----------- Remove copying and contextual menu code from BDSKZoomablePDFView as this is not relevant here. Modified Paths: -------------- trunk/BDSKZoomablePDFView.h trunk/BDSKZoomablePDFView.m Modified: trunk/BDSKZoomablePDFView.h =================================================================== --- trunk/BDSKZoomablePDFView.h 2007-08-05 16:45:53 UTC (rev 2605) +++ trunk/BDSKZoomablePDFView.h 2007-08-05 20:29:27 UTC (rev 2606) @@ -42,7 +42,6 @@ @interface BDSKZoomablePDFView : PDFView { NSPopUpButton *scalePopUpButton; - NSDictionary *pasteboardInfo; } - (void)setScaleFactor:(float)factor adjustPopup:(BOOL)flag; Modified: trunk/BDSKZoomablePDFView.m =================================================================== --- trunk/BDSKZoomablePDFView.m 2007-08-05 16:45:53 UTC (rev 2605) +++ trunk/BDSKZoomablePDFView.m 2007-08-05 20:29:27 UTC (rev 2606) @@ -63,170 +63,6 @@ static float BDSKDefaultScaleMenuFactors[] = {/* 0.0, */ 0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.28, 1.5, 2.0, 4.0, 8.0}; static float BDSKScaleMenuFontSize = 11.0; -#pragma mark Instance methods - -- (id)initWithFrame:(NSRect)rect { - if (self = [super initWithFrame:rect]) { - pasteboardInfo = [[NSMutableDictionary alloc] initWithCapacity:2]; - } - return self; -} - -- (id)initWithCoder:(NSCoder *)coder { - if (self = [super initWithCoder:coder]) { - pasteboardInfo = [[NSMutableDictionary alloc] initWithCapacity:2]; - } - return self; -} - -- (void)dealloc{ - [pasteboardInfo release]; - [super dealloc]; -} - -- (void)printDocument:(id)sender{ - id document = [[[self window] windowController] document]; - if ([document respondsToSelector:_cmd]) - [document printDocument:sender]; - else if ([PDFView instancesRespondToSelector:_cmd]) - [(id)super printDocument:sender]; -} - -#pragma mark Copying - -// used to cache the selection info and document for lazy copying -- (void)updatePasteboardInfo; -{ - PDFSelection *theSelection = [self currentSelection]; - if(!theSelection) - theSelection = [[self document] selectionForEntireDocument]; - - // @@ copy selection since it's mutable; may eliminate exceptions when providing data, but I've never been able to reproduce the problem - [pasteboardInfo setValue:[[theSelection copy] autorelease] forKey:@"selection"]; - [pasteboardInfo setValue:[self document] forKey:@"document"]; - [pasteboardInfo setValue:[self currentPage] forKey:@"page"]; -} - -// override so we can put the entire document on the pasteboard if there is no selection -- (void)copy:(id)sender; -{ - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSGeneralPboard]; - [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType, NSStringPboardType, NSRTFPboardType, nil] owner:self]; - [self updatePasteboardInfo]; -} - -- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type; -{ - PDFSelection *theSelection = [pasteboardInfo valueForKey:@"selection"]; - PDFDocument *theDocument = [pasteboardInfo valueForKey:@"document"]; - PDFPage *thePage = [pasteboardInfo valueForKey:@"page"]; - - // use a private type to signal that we need to provide a page as PDF - if([type isEqualToString:NSPDFPboardType] && [[sender types] containsObject:@"BDSKPrivatePDFPageDataPboardType"]){ - [sender setData:[thePage dataRepresentation] forType:type]; - } else if([type isEqualToString:NSPDFPboardType]){ - // write the whole document - [sender setData:[theDocument dataRepresentation] forType:type]; - } else if([type isEqualToString:NSStringPboardType]){ - [sender setString:[theSelection string] forType:type]; - } else if([type isEqualToString:NSRTFPboardType]){ - NSAttributedString *attrString = [theSelection attributedString]; - [sender setData:[attrString RTFFromRange:NSMakeRange(0, [attrString length]) documentAttributes:nil] forType:type]; - } else NSBeep(); -} - -- (void)copyAsPDF:(id)sender; -{ - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSGeneralPboard]; - // don't add the private page pboard type here - [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType, nil] owner:self]; - [self updatePasteboardInfo]; -} - -- (void)copyAsText:(id)sender; -{ - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSGeneralPboard]; - [pboard declareTypes:[NSArray arrayWithObjects:NSStringPboardType, NSRTFPboardType, nil] owner:self]; - [self updatePasteboardInfo]; -} - -- (void)copyPDFPage:(id)sender; -{ - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSGeneralPboard]; - [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType, @"BDSKPrivatePDFPageDataPboardType", nil] owner:self]; - [self updatePasteboardInfo]; -} - -- (void)saveDocumentSheetDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; -{ - NSError *error = nil; - if(returnCode == NSOKButton){ - // -[PDFDocument writeToURL:] returns YES even if you don't have write permission, so we'll use NSData rdar://problem/4475062 - NSData *data = [[self document] dataRepresentation]; - - if([data writeToURL:[sheet URL] options:NSAtomicWrite error:&error] == NO){ - [sheet orderOut:nil]; - [self presentError:error]; - } - } -} - -- (void)saveDocumentAs:(id)sender; -{ - NSString *name = [[[[self document] documentURL] path] lastPathComponent]; - [[NSSavePanel savePanel] beginSheetForDirectory:nil file:(name ? name : NSLocalizedString(@"Untitled.pdf", @"Default file name for saved PDF")) modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(saveDocumentSheetDidEnd:returnCode:contextInfo:) contextInfo:NULL]; -} - -- (void)lookUpCurrentSelectionInDictionary:(id)sender; -{ - NSString *text = [[self currentSelection] string]; - if (nil == text) - NSBeep(); - else - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[@"dict://" stringByAppendingString:text]]]; -} - -- (NSMenu *)menuForEvent:(NSEvent *)theEvent; -{ - NSMenu *menu = [super menuForEvent:theEvent]; - [menu addItem:[NSMenuItem separatorItem]]; - NSMenuItem *item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:NSLocalizedString(@"Copy Document as PDF", @"Menu item title") action:@selector(copyAsPDF:) keyEquivalent:@""]; - [menu addItem:item]; - [item release]; - - item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:NSLocalizedString(@"Copy Page as PDF", @"Menu item title") action:@selector(copyPDFPage:) keyEquivalent:@""]; - [menu addItem:item]; - [item release]; - - NSString *title = (nil == [self currentSelection]) ? NSLocalizedString(@"Copy All Text", @"Menu item title") : NSLocalizedString(@"Copy Selected Text", @"Menu item title"); - - item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:title action:@selector(copyAsText:) keyEquivalent:@""]; - [menu addItem:item]; - [item release]; - - if ([self currentSelection]) { - long version; - OSStatus err = Gestalt(gestaltSystemVersion, &version); - - if (noErr == err && version < 0x00001050) { - - [menu addItem:[NSMenuItem separatorItem]]; - - item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:NSLocalizedString(@"Look Up in Dictionary", @"") action:@selector(lookUpCurrentSelectionInDictionary:) keyEquivalent:@""]; - [menu addItem:item]; - [item release]; - } - } - - [menu addItem:[NSMenuItem separatorItem]]; - - item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:[NSLocalizedString(@"Save PDF As", @"Menu item title") stringByAppendingFormat:@"%C", 0x2026] action:@selector(saveDocumentAs:) keyEquivalent:@""]; - [menu addItem:item]; - [item release]; - - return menu; -} - #pragma mark Popup button - (void)makeScalePopUpButton { 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: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit