From 1ef3e80efc2eeaad488546527142f3a57de5d7b4 Mon Sep 17 00:00:00 2001 From: Airy ANDRE Date: Fri, 20 Sep 2013 16:04:14 +0200 Subject: [PATCH] runOperation is ignoring the page range set in the print info --- AppKit/NSPrintOperation.m | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/AppKit/NSPrintOperation.m b/AppKit/NSPrintOperation.m index 33daa3b79d..dc8b075008 100755 --- a/AppKit/NSPrintOperation.m +++ b/AppKit/NSPrintOperation.m @@ -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) { @@ -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; }