Revision: 7261 http://skim-app.svn.sourceforge.net/skim-app/?rev=7261&view=rev Author: hofman Date: 2011-06-07 18:05:50 +0000 (Tue, 07 Jun 2011)
Log Message: ----------- Support a "page=N" fragment in the URL, pass it on by the download manager. In practice won't be passed for files, as Launch Services passes them as bookmark data rather than file URL. Modified Paths: -------------- trunk/SKDocumentController.m trunk/SKDownloadController.m Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2011-06-07 17:51:41 UTC (rev 7260) +++ trunk/SKDocumentController.m 2011-06-07 18:05:50 UTC (rev 7261) @@ -331,6 +331,10 @@ } - (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL display:(BOOL)displayDocument error:(NSError **)outError { + NSString *fragment = [absoluteURL fragment]; + if ([fragment length] > 0) + absoluteURL = [NSURL fileURLWithPath:[absoluteURL path]]; + NSString *type = [self typeForContentsOfURL:absoluteURL error:NULL]; if ([type isEqualToString:SKNotesDocumentType]) { NSAppleEventDescriptor *event = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; @@ -384,7 +388,16 @@ *outError = error ?: [NSError readFileErrorWithLocalizedDescription:NSLocalizedString(@"Unable to load file", @"Error description")]; return doc; } - return [super openDocumentWithContentsOfURL:absoluteURL display:displayDocument error:outError]; + + id document = [super openDocumentWithContentsOfURL:absoluteURL display:displayDocument error:outError]; + + if ([document isPDFDocument] && [fragment length] > 5 && [fragment compare:@"page=" options:NSAnchoredSearch | NSCaseInsensitiveSearch range:NSMakeRange(0, 5)] == NSOrderedSame) { + NSInteger page = [[fragment substringFromIndex:5] integerValue]; + if (page > 1) + [[document mainWindowController] setPageNumber:page]; + } + + return document; } - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2011-06-07 17:51:41 UTC (rev 7260) +++ trunk/SKDownloadController.m 2011-06-07 18:05:50 UTC (rev 7261) @@ -338,6 +338,10 @@ - (void)downloadDidEnd:(SKDownload *)download { if ([download status] == SKDownloadStatusFinished) { NSURL *URL = [NSURL fileURLWithPath:[download filePath]]; + NSString *fragment = [[download URL] fragment]; + if ([fragment length] > 0) + URL = [NSURL URLWithString:[[URL absoluteString] stringByAppendingString:fragment]]; + NSError *error = nil; id document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:URL display:YES error:&error]; if (document == nil && [error isUserCancelledError] == NO) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit