* Source/NSPrinter.m (-addPPDKeyword:withScanner:withPPDPath:):

Protect against value being nil.
* Source/NSPageLayout.m (-tableView:objectValueForTableColumn:row:):
With standard papers, calculate margins taking into account factorValue.
* Source/NSPrintInfo.m (-initWithDictionary): Fix border calculation.
Idea by Yavor Doganov <yavor@gnu.org>
This commit is contained in:
fredkiefer 2018-07-14 20:21:32 +02:00
parent 44f8a4dccb
commit 4b04426c06
4 changed files with 35 additions and 18 deletions

View file

@ -1,3 +1,12 @@
2018-07-14 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPrinter.m (-addPPDKeyword:withScanner:withPPDPath:):
Protect against value being nil.
* Source/NSPageLayout.m (-tableView:objectValueForTableColumn:row:):
With standard papers, calculate margins taking into account factorValue.
* Source/NSPrintInfo.m (-initWithDictionary): Fix border calculation.
Idea by Yavor Doganov <yavor@gnu.org>
2018-07-08 Ivan Vucica <ivan@vucica.net>
* Source/NSOpenGLView.m:

View file

@ -986,10 +986,10 @@ enum {
paperName = [standardPaperSizePopUp titleOfSelectedItem];
paperSize = [printer pageSizeForPaper: paperName];
imageRect = [printer imageRectForPaper: paperName];
topMargin = paperSize.height - imageRect.size.height;
bottomMargin = imageRect.origin.x;
leftMargin = imageRect.origin.y;
rightMargin = paperSize.width - imageRect.size.width;
topMargin = (paperSize.height - NSMaxY(imageRect)) * factorValue;
bottomMargin = imageRect.origin.x * factorValue;
leftMargin = imageRect.origin.y * factorValue;
rightMargin = (paperSize.width - NSMaxX(imageRect)) * factorValue;
}
else //Custom Papers
{

View file

@ -143,6 +143,8 @@ static NSPrintInfo *sharedPrintInfo = nil;
{
NSPrinter *printer;
NSString *pageSize;
NSRect imageRect;
NSSize paperSize;
if (!(self = [super init]))
{
@ -160,7 +162,6 @@ static NSPrintInfo *sharedPrintInfo = nil;
printer = [NSPrintInfo defaultPrinter];
[self setPrinter: printer];
/* Set up other defaults from the printer object */
pageSize = [printer stringForKey: @"DefaultPageSize"
@ -172,11 +173,13 @@ static NSPrintInfo *sharedPrintInfo = nil;
[self setPaperName: pageSize];
/* Set default margins. FIXME: Probably should check ImageableArea */
[self setRightMargin: 36];
[self setLeftMargin: 36];
[self setTopMargin: 72];
[self setBottomMargin: 72];
/* Set default margins. */
paperSize = [printer pageSizeForPaper: pageSize];
imageRect = [printer imageRectForPaper: pageSize];
[self setRightMargin: (paperSize.width - NSMaxX(imageRect))];
[self setLeftMargin: imageRect.origin.y];
[self setTopMargin: (paperSize.height - NSMaxY(imageRect))];
[self setBottomMargin: imageRect.origin.x];
[self setOrientation: NSPortraitOrientation];
if (aDict != nil)

View file

@ -1140,9 +1140,6 @@ static NSMutableDictionary* printerCache;
[ppdData scanUpToString: @"\"" /*"*/
intoString: &value];
if (!value)
value = @"";
[ppdData scanString: @"\"" /*"*/
intoString: NULL];
@ -1160,6 +1157,12 @@ static NSMutableDictionary* printerCache;
[ppdData scanUpToCharactersFromSet: valueEndSet
intoString: &value];
}
if (!value)
{
value = @"";
}
// If there is a value translation, scan it
if ([ppdData scanString: @"/"
intoString: NULL])
@ -1169,11 +1172,8 @@ static NSMutableDictionary* printerCache;
}
// The translations also have to have any hex substrings interpreted
if (optionTranslation)
optionTranslation = [self interpretQuotedValue: optionTranslation];
if (valueTranslation)
valueTranslation = [self interpretQuotedValue: valueTranslation];
optionTranslation = [self interpretQuotedValue: optionTranslation];
valueTranslation = [self interpretQuotedValue: valueTranslation];
// The keyword (or keyword/option pair, if there's a option), should only
// only have one value, unless it's one of the optionless keywords which
@ -1442,6 +1442,11 @@ static NSMutableDictionary* printerCache;
int location;
NSRange range;
if (!qString)
{
return nil;
}
// Don't bother unless there's something to convert
range = [qString rangeOfString: @"<"];
if (!range.length)