Printing updates

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20207 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
cehardin 2004-10-08 05:22:22 +00:00
parent 348b610c27
commit 21c4e04b00
4 changed files with 141 additions and 201 deletions

View file

@ -1,3 +1,13 @@
2004-10-08 Chad Hardin <cehardin@mac.com>
* Printing/GSLPR/GSLPRPrintOperation: Removed useless #defines and
did a minor format cleanup.
* Printing/GSLPR/GSLPRPrinter.m: Took out a few PS specific methods so
that they can be put into the parent class, NSPrinter.
* Source/NSPrinter: Received PS specific methods from GSLPRPrinter so
that they can be used by GSCUPS as well. Also removed some useless
NSDebugs.
2004-10-05 Adam Fedor <fedor@gnu.org> 2004-10-05 Adam Fedor <fedor@gnu.org>
* Source/GNUmakefile.postamble (libgnustep-gui.def): Search for both * Source/GNUmakefile.postamble (libgnustep-gui.def): Search for both

View file

@ -57,9 +57,6 @@
#include <AppKit/PSOperators.h> #include <AppKit/PSOperators.h>
#include "GSLPRPrintOperation.h" #include "GSLPRPrintOperation.h"
#define NSNUMBER(a) [NSNumber numberWithInt: (a)]
#define NSFNUMBER(a) [NSNumber numberWithFloat: (a)]
@ -76,7 +73,7 @@
- (id)initWithView:(NSView *)aView - (id)initWithView:(NSView *)aView
printInfo:(NSPrintInfo *)aPrintInfo printInfo:(NSPrintInfo *)aPrintInfo
{ {
self = [super initWithView: aView self = [super initWithView: aView
printInfo: aPrintInfo]; printInfo: aPrintInfo];

View file

@ -139,170 +139,6 @@
} }
-(BOOL) acceptsBinary
{
// FIXME: I'm not sure if acceptsBinary is the same as BCP protocol?
NSString *result;
NSScanner *protocols;
result = [self stringForKey: @"Protocols"
inTable: @"PPD"];
if (!result)
return NO;
protocols = [NSScanner scannerWithString: result];
while( ![protocols isAtEnd] )
{
[protocols scanUpToCharactersFromSet: [NSCharacterSet whitespaceCharacterSet]
intoString: &result];
if ( [result isEqual:@"BCP"] )
return YES;
}
return NO;
}
-(NSRect) imageRectForPaper: (NSString*) paperName
{
NSString *key;
key = [NSString stringWithFormat: @"ImageableArea/%@", paperName];
return [self rectForKey: key
inTable: @"PPD"];
}
-(NSSize) pageSizeForPaper: (NSString*) paperName
{
NSString *key;
key = [NSString stringWithFormat: @"PaperDimension/%@", paperName];
return [self sizeForKey: key
inTable: @"PPD"];
}
-(BOOL) isColor
{
return [self booleanForKey: @"ColorDevice"
inTable: @"PPD"];
}
-(BOOL) isFontAvailable: (NSString*) fontName
{
NSString *key;
key = [NSString stringWithFormat: @"Font/%@", fontName];
return [self isKey: key
inTable: @"PPD"];
}
-(int) languageLevel
{
return [self intForKey: @"LanguageLevel"
inTable: @"PPD"];
}
-(BOOL) isOutputStackInReverseOrder
{
// FIXME: Is this what is needed? I'm not sure how this is worked out.
NSString *result;
result = [self stringForKey: @"DefaultOutputOrder"
inTable: @"PPD"];
if (!result)
return NO;
if ( [result caseInsensitiveCompare: @"REVERSE"] == NSOrderedSame)
return YES;
else
return NO;
}
-(NSDictionary*) deviceDescription
{
NSMutableDictionary *result;
result = [NSMutableDictionary dictionary];
if( [self isKey: @"DefaultResolution"
inTable:@"PPD"])
{
int dpi = [self intForKey: @"DefaultResolution"
inTable: @"PPD"];
[result setObject: [NSNumber numberWithInt: dpi]
forKey: NSDeviceResolution];
}
if( [self isKey: @"ColorDevice"
inTable: @"PPD"])
{
BOOL color = [self booleanForKey: @"ColorDevice"
inTable: @"PPD"];
// FIXME: Should NSDeviceWhiteColorSpace be NSDeviceBlackColorSpace?
// FIXME #2: Are they calibrated?
// Basically I'm not sure which color spaces should be used...
if( color == YES )
{
[result setObject: NSDeviceCMYKColorSpace
forKey: NSDeviceColorSpaceName];
}
else
{
[result setObject: NSDeviceWhiteColorSpace
forKey: NSDeviceColorSpaceName];
}
}
if( [self isKey: @"DefaultBitsPerPixel"
inTable: @"PPD"] )
{
int bits = [self intForKey: @"DefaultBitsPerPixel"
inTable: @"PPD"];
[result setObject: [NSNumber numberWithInt: bits]
forKey: NSDeviceBitsPerSample];
}
if( [self isKey: @"DefaultPageSize"
inTable: @"PPD"] )
{
NSString* defaultPageSize = [self stringForKey: @"DefaultPageSize"
inTable: @"PPD"];
if( defaultPageSize )
{
NSSize paperSize = [self pageSizeForPaper: defaultPageSize];
[result setObject: [NSValue valueWithSize:paperSize]
forKey: NSDeviceSize];
}
}
[result setObject: [NSNumber numberWithBool:NO]
forKey: NSDeviceIsScreen];
[result setObject: [NSNumber numberWithBool:YES]
forKey: NSDeviceIsPrinter];
NSDebugMLLog(@"GSPrinting", @"Device Description: %@", [result description]);
return result;
}
-(id) initWithCoder: (NSCoder*) coder -(id) initWithCoder: (NSCoder*) coder
{ {

View file

@ -148,7 +148,6 @@ static NSMutableDictionary* printerCache;
NSEnumerator *keyEnum; NSEnumerator *keyEnum;
NSString *key; NSString *key;
NSPrinter *printer; NSPrinter *printer;
//First, the cache has to be managed. //First, the cache has to be managed.
//Take into account any deleted printers. //Take into account any deleted printers.
@ -156,13 +155,13 @@ static NSMutableDictionary* printerCache;
while( (key = [keyEnum nextObject]) ) while( (key = [keyEnum nextObject]) )
{ {
NSEnumerator *namesEnum; NSEnumerator *namesEnum;
NSString *string; NSString *validName;
BOOL stillValid = NO; BOOL stillValid = NO;
namesEnum = [[self printerNames] objectEnumerator]; namesEnum = [[self printerNames] objectEnumerator];
while( (string = [namesEnum nextObject]) ) while( (validName = [namesEnum nextObject]) )
{ {
if( [string isEqualToString: key] ) if( [validName isEqualToString: key] )
{ {
stillValid = YES; stillValid = YES;
break; break;
@ -171,8 +170,7 @@ static NSMutableDictionary* printerCache;
if( stillValid == NO ) if( stillValid == NO )
{ {
NSDebugMLLog(@"GSPrinting", @"Printer named %@ removed from cache", [printerCache removeObjectForKey: key];
name);
} }
} }
@ -180,17 +178,12 @@ static NSMutableDictionary* printerCache;
if( printer ) if( printer )
{ {
NSDebugMLLog(@"GSPrinting", @"Printer named %@ found in cache",
name);
return printer; return printer;
} }
else else
{ {
Class principalClass; Class principalClass;
NSDebugMLLog(@"GSPrinting", @"Printer named %@ not found in cache",
name);
principalClass = [[GSPrinting printingBundle] principalClass]; principalClass = [[GSPrinting printingBundle] principalClass];
if( principalClass == nil ) if( principalClass == nil )
@ -202,8 +195,6 @@ static NSMutableDictionary* printerCache;
{ {
[printerCache setObject: printer [printerCache setObject: printer
forKey: name]; forKey: name];
NSDebugMLLog(@"GSPrinting", @"Printer named %@ added to cache",
name);
} }
return printer; return printer;
} }
@ -237,15 +228,15 @@ static NSMutableDictionary* printerCache;
while( (printerName = [printerNamesEnum nextObject]) ) while( (printerName = [printerNamesEnum nextObject]) )
{ {
NSPrinter *printer; NSPrinter *printer;
printer = [self printerWithName: printerName]; printer = [self printerWithName: printerName];
if( [[printer type] isEqualToString: type] ) if( [[printer type] isEqualToString: type] )
{ {
return printer; return printer;
} }
} }
return nil; return nil;
} }
@ -317,44 +308,85 @@ static NSMutableDictionary* printerCache;
// //
-(BOOL) acceptsBinary -(BOOL) acceptsBinary
{ {
[self subclassResponsibility: _cmd]; // FIXME: I'm not sure if acceptsBinary is the same as BCP protocol?
return NO; NSString *result;
NSScanner *protocols;
result = [self stringForKey: @"Protocols"
inTable: @"PPD"];
if (!result)
return NO;
protocols = [NSScanner scannerWithString: result];
while( ![protocols isAtEnd] )
{
[protocols scanUpToCharactersFromSet: [NSCharacterSet whitespaceCharacterSet]
intoString: &result];
if ( [result isEqual:@"BCP"] )
return YES;
}
return NO;
} }
-(NSRect) imageRectForPaper: (NSString*) paperName -(NSRect) imageRectForPaper: (NSString*) paperName
{ {
[self subclassResponsibility: _cmd]; NSString *key;
return NSZeroRect;
key = [NSString stringWithFormat: @"ImageableArea/%@", paperName];
return [self rectForKey: key
inTable: @"PPD"];
} }
-(NSSize) pageSizeForPaper: (NSString*) paperName -(NSSize) pageSizeForPaper: (NSString*) paperName
{ {
[self subclassResponsibility: _cmd]; NSString *key;
return NSZeroSize;
key = [NSString stringWithFormat: @"PaperDimension/%@", paperName];
return [self sizeForKey: key
inTable: @"PPD"];
} }
-(BOOL) isColor -(BOOL) isColor
{ {
[self subclassResponsibility: _cmd]; return [self booleanForKey: @"ColorDevice"
return NO; inTable: @"PPD"];
} }
-(BOOL) isFontAvailable: (NSString*) fontName -(BOOL) isFontAvailable: (NSString*) fontName
{ {
[self subclassResponsibility: _cmd]; NSString *key;
return NO;
key = [NSString stringWithFormat: @"Font/%@", fontName];
return [self isKey: key
inTable: @"PPD"];
} }
-(int) languageLevel -(int) languageLevel
{ {
[self subclassResponsibility: _cmd]; return [self intForKey: @"LanguageLevel"
return 0; inTable: @"PPD"];
} }
-(BOOL) isOutputStackInReverseOrder -(BOOL) isOutputStackInReverseOrder
{ {
[self subclassResponsibility: _cmd]; // FIXME: Is this what is needed? I'm not sure how this is worked out.
return NO; NSString *result;
result = [self stringForKey: @"DefaultOutputOrder"
inTable: @"PPD"];
if (!result)
return NO;
if ( [result caseInsensitiveCompare: @"REVERSE"] == NSOrderedSame)
return YES;
else
return NO;
} }
// //
@ -379,8 +411,74 @@ static NSMutableDictionary* printerCache;
-(NSDictionary*) deviceDescription -(NSDictionary*) deviceDescription
{ {
[self subclassResponsibility: _cmd]; NSMutableDictionary *result;
return nil;
result = [NSMutableDictionary dictionary];
if( [self isKey: @"DefaultResolution"
inTable:@"PPD"])
{
int dpi = [self intForKey: @"DefaultResolution"
inTable: @"PPD"];
[result setObject: [NSNumber numberWithInt: dpi]
forKey: NSDeviceResolution];
}
if( [self isKey: @"ColorDevice"
inTable: @"PPD"])
{
BOOL color = [self booleanForKey: @"ColorDevice"
inTable: @"PPD"];
// FIXME: Should NSDeviceWhiteColorSpace be NSDeviceBlackColorSpace?
// FIXME #2: Are they calibrated?
// Basically I'm not sure which color spaces should be used...
if( color == YES )
{
[result setObject: NSDeviceCMYKColorSpace
forKey: NSDeviceColorSpaceName];
}
else
{
[result setObject: NSDeviceWhiteColorSpace
forKey: NSDeviceColorSpaceName];
}
}
if( [self isKey: @"DefaultBitsPerPixel"
inTable: @"PPD"] )
{
int bits = [self intForKey: @"DefaultBitsPerPixel"
inTable: @"PPD"];
[result setObject: [NSNumber numberWithInt: bits]
forKey: NSDeviceBitsPerSample];
}
if( [self isKey: @"DefaultPageSize"
inTable: @"PPD"] )
{
NSString* defaultPageSize = [self stringForKey: @"DefaultPageSize"
inTable: @"PPD"];
if( defaultPageSize )
{
NSSize paperSize = [self pageSizeForPaper: defaultPageSize];
[result setObject: [NSValue valueWithSize:paperSize]
forKey: NSDeviceSize];
}
}
[result setObject: [NSNumber numberWithBool:NO]
forKey: NSDeviceIsScreen];
[result setObject: [NSNumber numberWithBool:YES]
forKey: NSDeviceIsPrinter];
NSDebugMLLog(@"GSPrinting", @"Device Description: %@", [result description]);
return result;
} }
@ -794,7 +892,6 @@ static NSMutableDictionary* printerCache;
NSScanner* ppdData; NSScanner* ppdData;
NSString* keyword; NSString* keyword;
//See if this ppd has been processed before //See if this ppd has been processed before
if( [inclusionSet member: ppdPath] ) if( [inclusionSet member: ppdPath] )