summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Stiles <henry.stiles@artifex.com>2013-01-30 14:07:41 -0700
committerChris Liddell <chris.liddell@artifex.com>2013-01-31 07:51:03 +0000
commit6e13685e1768771f87c94bdb2aaaab4d011d601c (patch)
tree0c6e9c7f16a3125259594812eea463c035ac016d
parent9c11bdaf7701b2736060ce291ae22fb0105ffaf5 (diff)
downloadghostpdl-6e13685e1768771f87c94bdb2aaaab4d011d601c.tar.gz
Fix Bug #692914 - Postscript MediaType lost.
Thanks to Hin-Tak Leung for adding support for MediaType to PXL output drivers.
-rw-r--r--gs/base/gdevlj56.c2
-rw-r--r--gs/base/gdevpx.c60
-rw-r--r--gs/base/gdevpxut.c23
-rw-r--r--gs/base/gdevpxut.h5
4 files changed, 80 insertions, 10 deletions
diff --git a/gs/base/gdevlj56.c b/gs/base/gdevlj56.c
index e11335144..95b1c5613 100644
--- a/gs/base/gdevlj56.c
+++ b/gs/base/gdevlj56.c
@@ -144,7 +144,7 @@ ljet5_print_page(gx_device_printer * pdev, FILE * prn_stream)
};
px_write_page_header(s, (gx_device *)pdev);
- px_write_select_media(s, (gx_device *)pdev, NULL, NULL, 0, false, false);
+ px_write_select_media(s, (gx_device *)pdev, NULL, NULL, 0, false, false, 0, NULL);
PX_PUT_LIT(s, page_header);
if (pdev->color_info.depth == 1)
PX_PUT_LIT(s, mono_header);
diff --git a/gs/base/gdevpx.c b/gs/base/gdevpx.c
index 32036ccf3..79d5627c9 100644
--- a/gs/base/gdevpx.c
+++ b/gs/base/gdevpx.c
@@ -62,6 +62,8 @@ typedef struct gx_device_pclxl_s {
bool ManualFeed_set;
int MediaPosition; /* MediaPosition attribute */
int MediaPosition_set;
+ char MediaType[64]; /* MediaType attribute */
+ int MediaType_set;
int page; /* Page number starting at 0 */
bool Duplex; /* Duplex attribute */
bool Tumble; /* Tumble attribute */
@@ -1032,7 +1034,8 @@ pclxl_beginpage(gx_device_vector * vdev)
px_write_select_media(s, (const gx_device *)vdev, &xdev->media_size,
&media_source,
- xdev->page, xdev->Duplex, xdev->Tumble);
+ xdev->page, xdev->Duplex, xdev->Tumble,
+ xdev->MediaType_set, xdev->MediaType);
spputc(s, pxtBeginPage);
return 0;
@@ -1389,6 +1392,10 @@ pclxl_open_device(gx_device * dev)
xdev->media_size = pxeMediaSize_next; /* no size selected */
memset(&xdev->chars, 0, sizeof(xdev->chars));
xdev->chars.next_in = xdev->chars.next_out = 2;
+ xdev->MediaPosition_set = false;
+ xdev->MediaType_set = false;
+ xdev->MediaPosition = eAutoSelect;
+ xdev->MediaType[0] = '\0';
return 0;
}
@@ -2156,6 +2163,7 @@ pclxl_get_params(gx_device *dev, /* I - Device info */
{
gx_device_pclxl *xdev; /* PCL XL device */
int code; /* Return code */
+ gs_param_string s; /* Temporary string value */
/*
* First process the "standard" page device parameters...
@@ -2173,9 +2181,17 @@ pclxl_get_params(gx_device *dev, /* I - Device info */
if ((code = param_write_bool(plist, "Duplex", &(xdev->Duplex))) < 0)
return (code);
- if ((code = param_write_int(plist, "MediaPosition",
- &(xdev->MediaPosition))) < 0)
- return (code);
+ if (xdev->MediaPosition_set)
+ if ((code = param_write_int(plist, "MediaPosition",
+ &(xdev->MediaPosition))) < 0)
+ return (code);
+
+ if (xdev->MediaType_set) {
+ if ((code = param_string_from_string(s, xdev->MediaType)) < 0)
+ return (code);
+ if ((code = param_write_string(plist, "MediaType", &s)) < 0)
+ return (code);
+ }
if ((code = param_write_bool(plist, "Tumble", &(xdev->Tumble))) < 0)
return (code);
@@ -2199,6 +2215,7 @@ pclxl_put_params(gx_device *dev, /* I - Device info */
int code; /* Error code */
int intval; /* Integer value */
bool boolval; /* Boolean value */
+ gs_param_string stringval; /* String value */
/*
* Process PCL-XL driver parameters...
@@ -2209,31 +2226,62 @@ pclxl_put_params(gx_device *dev, /* I - Device info */
#define intoption(name, sname, type) \
if ((code = param_read_int(plist, sname, &intval)) < 0) \
{ \
+ if_debug1('|', "Error setting %s\n", sname); \
param_signal_error(plist, sname, code); \
return (code); \
} \
else if (code == 0) \
{ \
+ if_debug2('|', "setting %s to %d\n", sname, intval); \
xdev->name = (type)intval; \
}
#define booloption(name, sname) \
if ((code = param_read_bool(plist, sname, &boolval)) < 0) \
{ \
+ if_debug1('|', "Error setting bool %s\n", sname); \
if ((code = param_read_null(plist, sname)) < 0) \
{ \
+ if_debug1('|', "Error setting bool %s null\n", sname); \
param_signal_error(plist, sname, code); \
return (code); \
} \
if (code == 0) \
xdev->name = false; \
} \
- else if (code == 0) \
- xdev->name = (bool)boolval;
+ else if (code == 0) { \
+ if_debug2('|', "setting %s to %d\n", sname, boolval); \
+ xdev->name = (bool)boolval; \
+ }
+
+#define stringoption(name, sname) \
+ if ((code = param_read_string(plist, sname, &stringval)) < 0) \
+ { \
+ if_debug1('|', "Error setting %s string\n", sname); \
+ if ((code = param_read_null(plist, sname)) < 0) \
+ { \
+ if_debug1('|', "Error setting %s null\n", sname); \
+ param_signal_error(plist, sname, code); \
+ return (code); \
+ } \
+ if (code == 0) { \
+ if_debug1('|', "setting %s to empty\n", sname); \
+ xdev->name[0] = '\0'; \
+ } \
+ } \
+ else if (code == 0) { \
+ strncpy(xdev->name, (const char *)(stringval.data), \
+ stringval.size); \
+ xdev->name[stringval.size] = '\0'; \
+ if_debug2('|', "setting %s to %s\n", sname, xdev->name); \
+ }
+ /* We need to have *_set to distinguish defaults from explicitly sets */
booloption(Duplex, "Duplex")
intoption(MediaPosition, "MediaPosition", int)
if (code == 0) xdev->MediaPosition_set = true;
+ stringoption(MediaType, "MediaType")
+ if (code == 0) xdev->MediaType_set = true;
booloption(Tumble, "Tumble")
intoption(CompressMode, "CompressMode", int)
diff --git a/gs/base/gdevpxut.c b/gs/base/gdevpxut.c
index c69136376..f29dfea15 100644
--- a/gs/base/gdevpxut.c
+++ b/gs/base/gdevpxut.c
@@ -125,7 +125,7 @@ px_write_page_header(stream *s, const gx_device *dev)
int
px_write_select_media(stream *s, const gx_device *dev,
pxeMediaSize_t *pms, byte *media_source,
- int page, bool Duplex, bool Tumble)
+ int page, bool Duplex, bool Tumble, int media_type_set, char *media_type)
{
#define MSD(ms, mstr, res, w, h) \
{ ms, mstr, (float)((w) * 1.0 / (res)), (float)((h) * 1.0 / res) },
@@ -181,7 +181,13 @@ px_write_select_media(stream *s, const gx_device *dev,
if (media_source != NULL)
tray = *media_source;
- px_put_uba(s, tray, pxaMediaSource);
+ /* suppress eAutoSelect if type is set */
+ if (!media_type_set || (tray != eAutoSelect))
+ px_put_uba(s, tray, pxaMediaSource);
+ /* suppress empty(="plain") type if tray is non-auto */
+ if (media_type_set)
+ if ((tray == eAutoSelect) || strlen(media_type))
+ px_put_ubaa(s, media_type, strlen(media_type), pxaMediaType);
if (Duplex)
{
@@ -401,6 +407,19 @@ px_put_rpa(stream * s, floatp rx, floatp ry, px_attribute_t a)
px_put_a(s, a);
}
+/* ubyte_array with attribute */
+void
+px_put_ubaa(stream * s, const byte * data, uint count, px_attribute_t a)
+{
+ if (count < 0)
+ return;
+ spputc(s, pxt_ubyte_array);
+ /* uint16 LE length field */
+ px_put_us(s, count);
+ px_put_bytes(s, data, count);
+ px_put_a(s, a);
+}
+
void
px_put_data_length(stream * s, uint num_bytes)
{
diff --git a/gs/base/gdevpxut.h b/gs/base/gdevpxut.h
index af09cc847..361d3ba03 100644
--- a/gs/base/gdevpxut.h
+++ b/gs/base/gdevpxut.h
@@ -32,7 +32,8 @@ int px_write_page_header(stream *s, const gx_device *dev);
int px_write_select_media(stream *s, const gx_device *dev,
pxeMediaSize_t *pms,
byte *media_source,
- int page, bool Duplex, bool Tumble);
+ int page, bool Duplex, bool Tumble,
+ int media_type_set, char *media_type);
/*
* Write the file trailer. Note that this takes a FILE *, not a stream *,
@@ -81,6 +82,8 @@ void px_put_rl(stream * s, floatp r); /* pxt_real32 tag */
void px_put_rp(stream * s, floatp rx, floatp ry);
void px_put_rpa(stream * s, floatp rx, floatp ry, px_attribute_t a);
+void px_put_ubaa(stream * s, const byte * data, uint count, px_attribute_t a);
+
void px_put_data_length(stream * s, uint num_bytes);
#endif /* gdevpxut_INCLUDED */