diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2020-08-26 16:53:36 -0700 |
---|---|---|
committer | Michael Vrhel <michael.vrhel@artifex.com> | 2020-09-22 10:13:31 -0700 |
commit | 9bfaeeace268f6a59f325e12efab9fb8273f64e0 (patch) | |
tree | 4cb7bdb6ee283bcef465e2918ff00d68db8d9021 /xps/xpsdoc.c | |
parent | c4e79952b42ebccb669063e053e3d7ce0f88cc22 (diff) | |
download | ghostpdl-9bfaeeace268f6a59f325e12efab9fb8273f64e0.tar.gz |
XPS interpreter: Have interpreter handle page range processing
This has the obvious benefit that the interpreter will skip processing
pages except those that lie in the FirstPage LastPage range.
If the PageList is used, the XPS interpreter will create a new
list of linked pages to process. The XPS interpreter handles all
the PageList cases currently implemented by the PDF interpreter
including even and odd. In addition, the XPS interpreter will handle
backward indexing (e.g. 100-1), as well as starting from last page
to another page (e.g. -2 which means from last page to second page),
and page repeats (e.g. 1,2,1,2,1,2 or 1-3,3-1 or 1-,-1 which is
do page 1 to end and end to page 1) Also, setting -dFirstPage=4
-dLastPage=1 will create pages 4,3,2,1
Diffstat (limited to 'xps/xpsdoc.c')
-rw-r--r-- | xps/xpsdoc.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/xps/xpsdoc.c b/xps/xpsdoc.c index 17fce9fc1..97445ec2f 100644 --- a/xps/xpsdoc.c +++ b/xps/xpsdoc.c @@ -134,6 +134,24 @@ xps_add_fixed_page(xps_context_t *ctx, char *name, int width, int height) if (!strcmp(page->name, name)) return; + if (ctx->page_range && !ctx->page_range->page_list) + { + ctx->page_range->current++; + + if (ctx->page_range->reverse) + { + if (ctx->page_range->current < ctx->page_range->last || + ctx->page_range->current > ctx->page_range->first) + return; + } + else + { + if ((ctx->page_range->first != 0 && ctx->page_range->current < ctx->page_range->first) || + (ctx->page_range->last != 0 && ctx->page_range->current > ctx->page_range->last)) + return; + } + } + if_debug1m('|', ctx->memory, "doc: adding page %s\n", name); page = xps_alloc(ctx, sizeof(xps_page_t)); @@ -153,8 +171,17 @@ xps_add_fixed_page(xps_context_t *ctx, char *name, int width, int height) } else { - ctx->last_page->next = page; - ctx->last_page = page; + /* FirstPage < LastPage? */ + if (ctx->page_range && ctx->page_range->reverse) + { + page->next = ctx->first_page; + ctx->first_page = page; + } + else + { + ctx->last_page->next = page; + ctx->last_page = page; + } } } |