2 |
- |
1 |
/* Copyright (C) 1997 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: gxclpage.c,v 1.4 2002/02/21 22:24:53 giles Exp $ */
|
|
|
18 |
/* Page object management */
|
|
|
19 |
#include "gdevprn.h"
|
|
|
20 |
#include "gxcldev.h"
|
|
|
21 |
#include "gxclpage.h"
|
|
|
22 |
|
|
|
23 |
/* Save a page. */
|
|
|
24 |
int
|
|
|
25 |
gdev_prn_save_page(gx_device_printer * pdev, gx_saved_page * page,
|
|
|
26 |
int num_copies)
|
|
|
27 |
{
|
|
|
28 |
/* Make sure we are banding. */
|
|
|
29 |
if (!pdev->buffer_space)
|
|
|
30 |
return_error(gs_error_rangecheck);
|
|
|
31 |
if (strlen(pdev->dname) >= sizeof(page->dname))
|
|
|
32 |
return_error(gs_error_limitcheck);
|
|
|
33 |
{
|
|
|
34 |
gx_device_clist_writer * const pcldev =
|
|
|
35 |
(gx_device_clist_writer *)pdev;
|
|
|
36 |
int code;
|
|
|
37 |
|
|
|
38 |
if ((code = clist_end_page(pcldev)) < 0 ||
|
|
|
39 |
(code = clist_fclose(pcldev->page_cfile, pcldev->page_cfname, false)) < 0 ||
|
|
|
40 |
(code = clist_fclose(pcldev->page_bfile, pcldev->page_bfname, false)) < 0
|
|
|
41 |
)
|
|
|
42 |
return code;
|
|
|
43 |
/* Save the device information. */
|
|
|
44 |
memcpy(&page->device, pdev, sizeof(gx_device));
|
|
|
45 |
strcpy(page->dname, pdev->dname);
|
|
|
46 |
/* Save the page information. */
|
|
|
47 |
page->info = pcldev->page_info;
|
|
|
48 |
page->info.cfile = 0;
|
|
|
49 |
page->info.bfile = 0;
|
|
|
50 |
}
|
|
|
51 |
/* Save other information. */
|
|
|
52 |
page->num_copies = num_copies;
|
|
|
53 |
return (*gs_clist_device_procs.open_device) ((gx_device *) pdev);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
/* Render an array of saved pages. */
|
|
|
57 |
int
|
|
|
58 |
gdev_prn_render_pages(gx_device_printer * pdev,
|
|
|
59 |
const gx_placed_page * ppages, int count)
|
|
|
60 |
{
|
|
|
61 |
gx_device_clist_reader * const pcldev =
|
|
|
62 |
(gx_device_clist_reader *)pdev;
|
|
|
63 |
|
|
|
64 |
/* Check to make sure the pages are compatible with the device. */
|
|
|
65 |
{
|
|
|
66 |
int i;
|
|
|
67 |
gx_band_params_t params;
|
|
|
68 |
|
|
|
69 |
for (i = 0; i < count; ++i) {
|
|
|
70 |
const gx_saved_page *page = ppages[i].page;
|
|
|
71 |
|
|
|
72 |
/* We would like to fully check the color representation, */
|
|
|
73 |
/* but we don't have enough information to do that. */
|
|
|
74 |
if (strcmp(page->dname, pdev->dname) != 0 ||
|
|
|
75 |
memcmp(&page->device.color_info, &pdev->color_info,
|
|
|
76 |
sizeof(pdev->color_info)) != 0
|
|
|
77 |
)
|
|
|
78 |
return_error(gs_error_rangecheck);
|
|
|
79 |
/* Currently we don't allow translation in Y. */
|
|
|
80 |
if (ppages[i].offset.y != 0)
|
|
|
81 |
return_error(gs_error_rangecheck);
|
|
|
82 |
/* Make sure the band parameters are compatible. */
|
|
|
83 |
if (page->info.band_params.BandBufferSpace !=
|
|
|
84 |
pdev->buffer_space ||
|
|
|
85 |
page->info.band_params.BandWidth !=
|
|
|
86 |
pdev->width
|
|
|
87 |
)
|
|
|
88 |
return_error(gs_error_rangecheck);
|
|
|
89 |
/* Currently we require all band heights to be the same. */
|
|
|
90 |
if (i == 0)
|
|
|
91 |
params = page->info.band_params;
|
|
|
92 |
else if (page->info.band_params.BandHeight !=
|
|
|
93 |
params.BandHeight
|
|
|
94 |
)
|
|
|
95 |
return_error(gs_error_rangecheck);
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
/* Set up the page list in the device. */
|
|
|
99 |
/****** SHOULD FACTOR THIS OUT OF clist_render_init ******/
|
|
|
100 |
pcldev->ymin = pcldev->ymax = 0;
|
|
|
101 |
pcldev->pages = ppages;
|
|
|
102 |
pcldev->num_pages = count;
|
|
|
103 |
/* Render the pages. */
|
|
|
104 |
{
|
|
|
105 |
int code = (*dev_proc(pdev, output_page))
|
|
|
106 |
((gx_device *) pdev, ppages[0].page->num_copies, true);
|
|
|
107 |
|
|
|
108 |
/* Delete the temporary files. */
|
|
|
109 |
int i;
|
|
|
110 |
|
|
|
111 |
for (i = 0; i < count; ++i) {
|
|
|
112 |
const gx_saved_page *page = ppages[i].page;
|
|
|
113 |
|
|
|
114 |
clist_unlink(page->info.cfname);
|
|
|
115 |
clist_unlink(page->info.bfname);
|
|
|
116 |
}
|
|
|
117 |
return code;
|
|
|
118 |
}
|
|
|
119 |
}
|