From 3a471413519021a0b7fb012889a6211ccde8c81d Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Thu, 16 Jul 2009 07:18:52 +0000 Subject: [PATCH] * Source/NSPrintOperation.m (-_printPaginateWithInfo:knowsRange:, -_print): Try to handle not set print information more graceful. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28396 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSPrintOperation.m | 29 ++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c0225906..b576bc326 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-07-16 Fred Kiefer + + * Source/NSPrintOperation.m (-_printPaginateWithInfo:knowsRange:, -_print): + Try to handle not set print information more graceful. + 2009-07-14 Fred Kiefer * Source/NSPrintOperation.m (-_printPaginateWithInfo:knowsRange:): diff --git a/Source/NSPrintOperation.m b/Source/NSPrintOperation.m index 07233276c..a760f79fb 100644 --- a/Source/NSPrintOperation.m +++ b/Source/NSPrintOperation.m @@ -760,14 +760,18 @@ scaleRect(NSRect rect, double scale) - (void) _printPaginateWithInfo: (page_info_t *)info knowsRange: (BOOL)knowsRange { NSMutableDictionary *dict; + NSNumber *value; + dict = [_print_info dictionary]; info->paperSize = [_print_info paperSize]; info->orient = [_print_info orientation]; - if ([dict objectForKey: NSPrintScalingFactor]) - info->printScale = [[dict objectForKey: NSPrintScalingFactor] doubleValue]; + value = [dict objectForKey: NSPrintScalingFactor]; + if (value != nil) + info->printScale = [value doubleValue]; else info->printScale = 1.0; + info->nup = [[dict objectForKey: NSPrintPagesPerSheet] intValue]; info->nupScale = 1; if (info->nup < 1 || (info->nup > 1 && (((info->nup) & 0x1) == 1))) @@ -942,6 +946,7 @@ scaleRect(NSRect rect, double scale) BOOL knowsPageRange, allPages; NSRange viewPageRange; NSMutableDictionary *dict; + NSNumber *value; page_info_t info; dict = [_print_info dictionary]; @@ -962,7 +967,11 @@ scaleRect(NSRect rect, double scale) [dict setObject: NSNUMBER(NSMaxRange(viewPageRange)) forKey: @"NSPrintTotalPages"]; - allPages = [[dict objectForKey: NSPrintAllPages] boolValue]; + value = [dict objectForKey: NSPrintAllPages]; + if (value != nil) + allPages = [value boolValue]; + else + allPages = YES; if (allPages == YES) { info.first = viewPageRange.location; @@ -970,8 +979,18 @@ scaleRect(NSRect rect, double scale) } else { - info.first = [[dict objectForKey: NSPrintFirstPage] intValue]; - info.last = [[dict objectForKey: NSPrintLastPage] intValue]; + value = [dict objectForKey: NSPrintFirstPage]; + if (value != nil) + info.first = [value intValue]; + else + info.first = 1; + + value = [dict objectForKey: NSPrintLastPage]; + if (value != nil) + info.last = [value intValue]; + else + info.last = INT_MAX; + info.first = MAX(info.first, (int)viewPageRange.location); info.first = MIN(info.first, (int)(NSMaxRange(viewPageRange) - 1)); info.last = MAX(info.last, info.first);