summaryrefslogtreecommitdiff
path: root/base/pagelist.h
diff options
context:
space:
mode:
authorRay Johnston <ray.johnston@pobox.com>2022-05-31 10:19:01 -0700
committerRay Johnston <ray.johnston@pobox.com>2022-07-30 10:26:52 -0700
commitaf3fa99aece39bfb83583d28e817c630c269bfea (patch)
treedef55ccc2d61266142c574a249a0db9a26bc7da4 /base/pagelist.h
parentb097603e36106f26550f85eadc124efba9e6d39b (diff)
downloadghostpdl-af3fa99aece39bfb83583d28e817c630c269bfea.tar.gz
New PageList processing, supporting PDF and XPS random order.
Supports out-of-order ranges (if the parser allows it and disables the PageHandler, i.e., flp device). Also adds support for ranges appended to the "even" and "odd" keyword following a ":". As before a trailing "-" in a range implies the last page, and as was supported by the previous 'gxps' code, a leading "-" also is the last page. For example, with XPS or PDF: -sPageList=odd:3-7,even:4-8,1-,-1,9 prints pages: 3, 5, 7, 4, 6, 8, 1, 2, ..., last, last, last-1, ..., 1, 9 The PageList string is parsed using C code into an array that consists of an initial int that is > 0 if the list is ordered, followed by sets of 3 integers per range, even/odd flag (odd=1, even=2), start, end. The final 3 ints are 0,0,0 as a marker. The initial int is used by 'pagelist_test_printed' as an index to the next range to be processed when the PageList is used for languages that can only be processed sequentially (e.g. PS and PCL) and is updated when the page passes the end of the current range. A value of -1 means the ranges are not ordered (not strctly increasing). The flp_fillpage is changed to ignore errors from processing the PageList performed by ParsePageList (called from SkipPage) when PageCount is 0 so that parsers that support out of order processing (PDF and XPS) can continue until later. This should have little or no performance impact since it is limited to PageCount == 0. Note that the new PDF parser also uses the C code parser and then uses the array of ranges returned by ".PDFparsePageList". The old PostScript based parser has not been updated, although it is easy to do so.
Diffstat (limited to 'base/pagelist.h')
-rw-r--r--base/pagelist.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/base/pagelist.h b/base/pagelist.h
new file mode 100644
index 000000000..832b21572
--- /dev/null
+++ b/base/pagelist.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2022-2022 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied,
+ modified or distributed except as expressly authorized under the terms
+ of the license contained in the file LICENSE in this distribution.
+
+ Refer to licensing information at http://www.artifex.com or contact
+ Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
+ CA 94945, U.S.A., +1(415)492-9861, for further information.
+*/
+
+/* Functions to parse a PageList string and processing utilitiess */
+
+/* Allocate an array of ranges. A range of 0-0 terminates the list */
+/* array contains even/odd flag, start, end (3 ints per range). */
+/* returns error code < 0 or number of ranges if success */
+int pagelist_parse_to_array(char *pPageList, gs_memory_t *mem, int num_pages, int **parray);
+
+/* function to calculate the total number of pages to be output */
+int pagelist_number_of_pages(const int *parray);
+
+/* Return true if this pagelist is in strict increasing order */
+bool pagelist_test_ordered(int *parray);
+
+/* Return true if this page is to be printed (for sequential processing) */
+/* This assumes that the PageList is strictly sequential, tested by client. */
+bool pagelist_test_printed(int *parray, int pagenum);
+
+void pagelist_free_range_array(gs_memory_t *mem, int *parray);