Skip to content
Snippets Groups Projects
Commit 70c7b2d8 authored by Martin Mareš's avatar Martin Mareš
Browse files

PPD: More bits...

parent f1dd212e
Branches
No related tags found
No related merge requests found
...@@ -82,6 +82,12 @@ set('d/ColorDevice:b', 0); ...@@ -82,6 +82,12 @@ set('d/ColorDevice:b', 0);
set('d/DefaultColorSpace:q', 'Gray'); set('d/DefaultColorSpace:q', 'Gray');
set('d/FileSystem:b', 0); set('d/FileSystem:b', 0);
# Section "c": CUPS options
# (none by default)
# Section "j": JCL options
# (none by default)
my @ui_groups = (); my @ui_groups = ();
sub ui_group($) { sub ui_group($) {
...@@ -102,7 +108,7 @@ $options{'n'} = { Key => '', Options => [] }; ...@@ -102,7 +108,7 @@ $options{'n'} = { Key => '', Options => [] };
# option({ # option({
# Key => key, # (mandatory) # Key => key, # (mandatory)
# Name => name, # descriptive name (default: same as Key) # Name => name, # descriptive name (default: same as Key)
# Type => type, # PickOne / PickMany / Boolean # Type => type, # PickOne (default) / PickMany / Boolean
# UI => group, # UI group ('' if outside groups, default: non-UI option) # UI => group, # UI group ('' if outside groups, default: non-UI option)
# JCL => 1, # if this is a JCL option # JCL => 1, # if this is a JCL option
# Section => sec, # OrderDependency section: ExitServer / Prolog / DocumentSetup / # Section => sec, # OrderDependency section: ExitServer / Prolog / DocumentSetup /
...@@ -137,9 +143,11 @@ sub heading($) { ...@@ -137,9 +143,11 @@ sub heading($) {
print "\n"; print "\n";
} }
sub emit($) { sub emit($;$) {
my ($section) = @_; my ($section, $heading) = @_;
my $opts = $options{$section}; my $opts = $options{$section};
$opts or return;
heading($heading) if defined $heading;
for my $k (sort keys %$opts) { for my $k (sort keys %$opts) {
my $v = $opts->{$k}; my $v = $opts->{$k};
if (!$v) { if (!$v) {
...@@ -161,14 +169,19 @@ sub get_default($) { ...@@ -161,14 +169,19 @@ sub get_default($) {
sub emit_option($) { sub emit_option($) {
my ($o) = @_; my ($o) = @_;
my $key = $o->{Key}; my $key = $o->{Key};
my $type = $o->{Type} // 'PickOne';
print "%* === $key ===\n";
my $jcl = ($o->{JCL} // ($key =~ /^JCL/)) ? "JCL" : ""; my $jcl = ($o->{JCL} // ($key =~ /^JCL/)) ? "JCL" : "";
if (defined $o->{UI}) { print "*${jcl}OpenUI *$key/", ($o->{Name} // $o->{Key}), ': ', $o->{Type}, "\n"; } if (defined $o->{UI}) { print "*${jcl}OpenUI *$key/", ($o->{Name} // $o->{Key}), ": $type\n"; }
my $pri = $o->{Priority} // 100; my $pri = $o->{Priority} // 100;
my $sec = $o->{Section} // ($jcl ? "JCLSetup" : "AnySetup"); my $sec = $o->{Section} // ($jcl ? "JCLSetup" : "AnySetup");
print '*', ((defined $o->{UI}) ? "" : 'NonUI'), "OrderDependency $pri $sec *$key\n"; print '*', ((defined $o->{UI}) ? "" : 'NonUI'), "OrderDependency $pri $sec *$key\n";
print "*Default$key: ", get_default($o), "\n"; print "*Default$key: ", get_default($o), "\n";
for my $v (@{$o->{Values}}) { for my $v (@{$o->{Values}}) {
print "*$key ", $v->{Key}, '/', ($v->{Name} // $v->{Key}), ': ', format_value('i', $v->{PS}), "\n"; my $ps = $v->{PS};
# $ps = "\n$ps" unless $ps =~ /^\n/s;
# $ps = "$ps\n" unless $ps =~ /\n$/s;
print "*$key ", $v->{Key}, '/', ($v->{Name} // $v->{Key}), ': ', format_value('i', $ps), "\n";
} }
if (defined $o->{UI}) { print "*${jcl}CloseUI *$key\n"; } if (defined $o->{UI}) { print "*${jcl}CloseUI *$key\n"; }
print "\n"; print "\n";
...@@ -202,14 +215,11 @@ sub generate() { ...@@ -202,14 +215,11 @@ sub generate() {
print "*% PPD file generated by UCW PPD generator\n"; print "*% PPD file generated by UCW PPD generator\n";
fill_missing(); fill_missing();
heading("File version"); emit('f', 'File version');
emit('f'); emit('p', 'Product information');
emit('d', 'Device capabilities');
heading("Product information"); emit('c', 'CUPS options');
emit('p'); emit('j', 'JCL setup');
heading("Device capabilities");
emit('d');
for my $g (@ui_groups) { for my $g (@ui_groups) {
next if $g->{Key} eq ''; next if $g->{Key} eq '';
...@@ -220,8 +230,10 @@ sub generate() { ...@@ -220,8 +230,10 @@ sub generate() {
heading("General UI options"); heading("General UI options");
emit_group($ui_groups[0]); emit_group($ui_groups[0]);
if (@{$options{'n'}->{Options}}) {
heading("Non-UI options"); heading("Non-UI options");
emit_group($options{'n'}); emit_group($options{'n'});
} }
}
42; 42;
package PPD::PJL;
use PPD;
sub add_jcl() {
set('j/JCLBegin', '<1B>%-12345X@PJL<0A>');
set('j/JCLToPSInterpreter', '@PJL ENTER LANGUAGE = POSTSCRIPT<0A>');
set('j/JCLEnd', '<1B>%-12345X@PJL EOJ<0A><1B>%-12345X<0A>');
}
42;
...@@ -5,6 +5,7 @@ use warnings; ...@@ -5,6 +5,7 @@ use warnings;
use lib "."; use lib ".";
use PPD; use PPD;
use PPD::PJL;
set('f/FileVersion', '1.0'); set('f/FileVersion', '1.0');
set('f/PCFileName', 'HP4350.PPD'); set('f/PCFileName', 'HP4350.PPD');
...@@ -18,10 +19,11 @@ set('d/TTRasterizer:s', 'Type42'); ...@@ -18,10 +19,11 @@ set('d/TTRasterizer:s', 'Type42');
set('d/VariablePaperSize:b', 1); set('d/VariablePaperSize:b', 1);
set('d/Protocols:s', 'PJL TBCP'); set('d/Protocols:s', 'PJL TBCP');
set('c/cupsProtocol:s', 'None');
option({ option({
Key => 'Duplex', Key => 'Duplex',
Name => '2-Sided Printing', Name => '2-Sided Printing',
Type => 'PickOne',
UI => '', UI => '',
Values => [ Values => [
{ Key => 'None', Name => 'Off (1-Sided)', PS => "<< /Duplex false >> setpagedevice" }, { Key => 'None', Name => 'Off (1-Sided)', PS => "<< /Duplex false >> setpagedevice" },
...@@ -30,4 +32,53 @@ option({ ...@@ -30,4 +32,53 @@ option({
] ]
}); });
option({
Key => 'Resolution',
Name => 'Printer Resolution',
UI => '',
Priority => 5,
Section => 'DocumentSetup',
Values => [
{ Key => '1200x1200dpi', Name => 'ProRes 1200', PS => '<< /HWResolution [1200 1200] /PreRenderingEnhance false >> setpagedevice' },
{ Key => '600x600x2dpi', Name => 'FastRes 1200', PS => '<< /HWResolution [1200 1200] /PreRenderingEnhance true >> setpagedevice', Default => 1 },
{ Key => '600x600dpi', Name => '600 DPI', PS => '<< /HWResolution [600 600] /PreRenderingEnhance false >> setpagedevice' },
]
});
option({
Key => 'HPEconoMode',
Name => 'EconoMode',
Type => 'Boolean',
UI => '',
Values => [
{ Key => 'False', Name => 'Highest Quality', PS => '<< /EconoMode false >> setpagedevice', Default => 1 },
{ Key => 'True', Name => 'Save Toner', PS => '<< /EconoMode true >> setpagedevice' },
]
});
option({
Key => 'Smoothing',
Name => 'Resolution Enhancement',
Type => 'Boolean',
UI => '',
Priority => 20,
Section => 'DocumentSetup',
Values => [
{ Key => 'False', Name => 'Off', PS => '<< /PostRenderingEnhance true /PostRenderingEnhanceDetails << /REValue 0 /Type 8 >> >> setpagedevice' },
{ Key => 'True', Name => 'On', PS => '<< /PostRenderingEnhance true /PostRenderingEnhanceDetails << /REValue 2 /Type 8 >> >> setpagedevice', Default => 1 },
]
});
option({
Key => 'Collate',
Type => 'Boolean',
UI => '',
Values => [
{ Key => 'False', Name => 'Off', PS => '<< /Collate false >> setpagedevice' },
{ Key => 'True', Name => 'On', PS => '<< /Collate true >> setpagedevice', Default => 1 },
]
});
PPD::PJL::add_jcl();
generate(); generate();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment