Skip to content

Commit

Permalink
runOperation is ignoring the page range set in the print info
Browse files Browse the repository at this point in the history
  • Loading branch information
airy10 committed Sep 20, 2013
1 parent a525034 commit 1ef3e80
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions AppKit/NSPrintOperation.m
Expand Up @@ -286,19 +286,28 @@ -(BOOL)runOperation {
BOOL knowsPageRange;
NSGraphicsContext *graphicsContext;
CGContextRef context;

NSMutableDictionary *dict = [_printInfo dictionary];

_currentOperation=self;

// Set the page range if not set yet
knowsPageRange=[_view knowsPageRange:&pageRange];

if(knowsPageRange){
[[_printInfo dictionary] setObject:[NSNumber numberWithInt:pageRange.location] forKey:NSPrintFirstPage];
[[_printInfo dictionary] setObject:[NSNumber numberWithInt:NSMaxRange(pageRange)-1] forKey:NSPrintLastPage];
}
else {
[[_printInfo dictionary] setObject:[NSNumber numberWithInt:1] forKey:NSPrintFirstPage];
[[_printInfo dictionary] setObject:[NSNumber numberWithInt:1] forKey:NSPrintLastPage];
}
if(knowsPageRange){
if ([dict objectForKey:NSPrintFirstPage] == nil) {
[dict setObject:[NSNumber numberWithInt:pageRange.location] forKey:NSPrintFirstPage];
}
if ([dict objectForKey:NSPrintLastPage] == nil) {
[dict setObject:[NSNumber numberWithInt:NSMaxRange(pageRange)-1] forKey:NSPrintLastPage];
}
} else {
if ([dict objectForKey:NSPrintFirstPage] == nil) {
[dict setObject:[NSNumber numberWithInt:1] forKey:NSPrintFirstPage];
}
if ([dict objectForKey:NSPrintLastPage] == nil) {
[dict setObject:[NSNumber numberWithInt:1] forKey:NSPrintLastPage];
}
}

graphicsContext=[self createContext];
if (graphicsContext == nil) {
Expand All @@ -307,8 +316,8 @@ -(BOOL)runOperation {
}

if (knowsPageRange) {
int firstPage = [[[_printInfo dictionary] objectForKey:NSPrintFirstPage] intValue];
int lastPage = [[[_printInfo dictionary] objectForKey:NSPrintLastPage] intValue];
int firstPage = [[dict objectForKey:NSPrintFirstPage] intValue];
int lastPage = [[dict objectForKey:NSPrintLastPage] intValue];
pageRange.location = firstPage;
pageRange.length = lastPage - firstPage + 1;
}
Expand Down

0 comments on commit 1ef3e80

Please sign in to comment.