diff options
38 files changed, 310 insertions, 317 deletions
diff --git a/android/jni/mupdf.c b/android/jni/mupdf.c index 5d7eeb0d..757c02c0 100644 --- a/android/jni/mupdf.c +++ b/android/jni/mupdf.c @@ -22,7 +22,7 @@ /* Globals */ fz_colorspace *colorspace; -pdf_xref *xref; +pdf_document *xref; int pagenum = 1; int resolution = 160; float pageWidth = 100; @@ -64,7 +64,7 @@ Java_com_artifex_mupdf_MuPDFCore_openFile(JNIEnv * env, jobject thiz, jstring jf LOGE("Opening document..."); fz_try(ctx) { - xref = pdf_open_xref(ctx, filename); + xref = pdf_open_document(ctx, filename); } fz_catch(ctx) { @@ -76,7 +76,7 @@ Java_com_artifex_mupdf_MuPDFCore_openFile(JNIEnv * env, jobject thiz, jstring jf fz_catch(ctx) { LOGE("Failed: %s", ctx->error->message); - pdf_free_xref(xref); + pdf_close_document(xref); xref = NULL; fz_free_context(ctx); ctx = NULL; @@ -247,6 +247,6 @@ Java_com_artifex_mupdf_MuPDFCore_destroying(JNIEnv * env, jobject thiz) { fz_free_display_list(ctx, currentPageList); currentPageList = NULL; - pdf_free_xref(xref); + pdf_close_document(xref); xref = NULL; } diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 3ad71c9a..9a3b9d0f 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -107,13 +107,13 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) fz_context *ctx = app->ctx; /* - * Open PDF and load xref table + * Open PDF document */ fz_try(ctx) { file = fz_open_fd(ctx, fd); - app->xref = pdf_open_xref_with_stream(file); + app->pdf = pdf_open_document_with_stream(file); fz_close(file); } fz_catch(ctx) @@ -125,15 +125,15 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) * Handle encrypted PDF files */ - if (pdf_needs_password(app->xref)) + if (pdf_needs_password(app->pdf)) { - int okay = pdf_authenticate_password(app->xref, password); + int okay = pdf_authenticate_password(app->pdf, password); while (!okay) { password = winpassword(app, filename); if (!password) pdfapp_error(app, "Needs a password."); - okay = pdf_authenticate_password(app->xref, password); + okay = pdf_authenticate_password(app->pdf, password); if (!okay) pdfapp_warn(app, "Invalid password."); } @@ -143,7 +143,7 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) * Load meta information */ - info = fz_dict_gets(app->xref->trailer, "Info"); + info = fz_dict_gets(app->pdf->trailer, "Info"); if (info) { obj = fz_dict_gets(info, "Title"); @@ -164,9 +164,9 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) * Start at first page */ - app->pagecount = pdf_count_pages(app->xref); + app->pagecount = pdf_count_pages(app->pdf); - app->outline = pdf_load_outline(app->xref); + app->outline = pdf_load_outline(app->pdf); } static void pdfapp_open_xps(pdfapp_t *app, char *filename, int fd) @@ -176,7 +176,7 @@ static void pdfapp_open_xps(pdfapp_t *app, char *filename, int fd) file = fz_open_fd(app->ctx, fd); fz_try(app->ctx) { - app->xps = xps_open_stream(file); + app->xps = xps_open_document_with_stream(file); } fz_catch(app->ctx) { @@ -242,15 +242,15 @@ void pdfapp_close(pdfapp_t *app) fz_free_outline(app->outline); app->outline = NULL; - if (app->xref) + if (app->pdf) { - pdf_free_xref(app->xref); - app->xref = NULL; + pdf_close_document(app->pdf); + app->pdf = NULL; } if (app->xps) { - xps_free_context(app->xps); + xps_close_document(app->xps); app->xps = NULL; } @@ -296,14 +296,14 @@ static void pdfapp_loadpage_pdf(pdfapp_t *app) fz_try(app->ctx) { - page = pdf_load_page(app->xref, app->pageno - 1); + page = pdf_load_page(app->pdf, app->pageno - 1); } fz_catch(app->ctx) { pdfapp_error(app, "cannot load page"); } - app->page_bbox = pdf_bound_page(app->xref, page); + app->page_bbox = pdf_bound_page(app->pdf, page); app->page_links = page->links; page->links = NULL; @@ -312,7 +312,7 @@ static void pdfapp_loadpage_pdf(pdfapp_t *app) mdev = fz_new_list_device(app->ctx, app->page_list); fz_try(app->ctx) { - pdf_run_page(app->xref, page, mdev, fz_identity, NULL); + pdf_run_page(app->pdf, page, mdev, fz_identity, NULL); } fz_catch(app->ctx) { @@ -369,7 +369,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai if (app->page_links) fz_free_link(app->ctx, app->page_links); - if (app->xref) + if (app->pdf) pdfapp_loadpage_pdf(app); if (app->xps) pdfapp_loadpage_xps(app); diff --git a/apps/pdfapp.h b/apps/pdfapp.h index 7aad1238..c1b03be2 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -30,10 +30,10 @@ extern void winfullscreen(pdfapp_t*, int state); struct pdfapp_s { /* current document params */ + pdf_document *pdf; + xps_document *xps; char *doctitle; - pdf_xref *xref; fz_outline *outline; - xps_document *xps; int pagecount; diff --git a/apps/pdfclean.c b/apps/pdfclean.c index 82eb7c03..8a163502 100644 --- a/apps/pdfclean.c +++ b/apps/pdfclean.c @@ -30,7 +30,7 @@ static int dogarbage = 0; static int doexpand = 0; static int doascii = 0; -static pdf_xref *xref = NULL; +static pdf_document *xref = NULL; static fz_context *ctx = NULL; static void usage(void) @@ -775,7 +775,7 @@ int main(int argc, char **argv) exit(1); } - xref = pdf_open_xref(ctx, infile); + xref = pdf_open_document(ctx, infile); if (pdf_needs_password(xref)) if (!pdf_authenticate_password(xref, password)) fz_throw(ctx, "cannot authenticate password: %s\n", infile); @@ -836,7 +836,7 @@ int main(int argc, char **argv) fz_free(xref->ctx, genlist); fz_free(xref->ctx, renumbermap); - pdf_free_xref(xref); + pdf_close_document(xref); fz_free_context(ctx); return 0; } diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c index 893b5b2b..552fe31a 100644 --- a/apps/pdfdraw.c +++ b/apps/pdfdraw.c @@ -85,13 +85,13 @@ static int isrange(char *s) return 1; } -static void drawpage(pdf_xref *xref, int pagenum) +static void drawpage(pdf_document *doc, int pagenum) { pdf_page *page; fz_display_list *list = NULL; fz_device *dev = NULL; int start; - fz_context *ctx = xref->ctx; + fz_context *ctx = doc->ctx; fz_var(list); fz_var(dev); @@ -103,7 +103,7 @@ static void drawpage(pdf_xref *xref, int pagenum) fz_try(ctx) { - page = pdf_load_page(xref, pagenum - 1); + page = pdf_load_page(doc, pagenum - 1); } fz_catch(ctx) { @@ -116,7 +116,7 @@ static void drawpage(pdf_xref *xref, int pagenum) { list = fz_new_display_list(ctx); dev = fz_new_list_device(ctx, list); - pdf_run_page(xref, page, dev, fz_identity, NULL); + pdf_run_page(doc, page, dev, fz_identity, NULL); } fz_catch(ctx) { @@ -138,7 +138,7 @@ static void drawpage(pdf_xref *xref, int pagenum) if (list) fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox, NULL); else - pdf_run_page(xref, page, dev, fz_identity, NULL); + pdf_run_page(doc, page, dev, fz_identity, NULL); printf("</page>\n"); } fz_catch(ctx) @@ -165,7 +165,7 @@ static void drawpage(pdf_xref *xref, int pagenum) if (list) fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox, NULL); else - pdf_run_page(xref, page, dev, fz_identity, NULL); + pdf_run_page(doc, page, dev, fz_identity, NULL); fz_free_device(dev); dev = NULL; printf("[Page %d]\n", pagenum); @@ -199,7 +199,7 @@ static void drawpage(pdf_xref *xref, int pagenum) fz_var(pix); - bounds = pdf_bound_page(xref, page); + bounds = pdf_bound_page(doc, page); zoom = resolution / 72; ctm = fz_scale(zoom, zoom); ctm = fz_concat(ctm, fz_rotate(rotation)); @@ -220,7 +220,7 @@ static void drawpage(pdf_xref *xref, int pagenum) if (list) fz_execute_display_list(list, dev, ctm, bbox, NULL); else - pdf_run_page(xref, page, dev, ctm, NULL); + pdf_run_page(doc, page, dev, ctm, NULL); fz_free_device(dev); dev = NULL; @@ -310,7 +310,7 @@ static void drawpage(pdf_xref *xref, int pagenum) fz_flush_warnings(ctx); } -static void drawrange(pdf_xref *xref, char *range) +static void drawrange(pdf_document *doc, char *range) { int page, spage, epage; char *spec, *dash; @@ -321,7 +321,7 @@ static void drawrange(pdf_xref *xref, char *range) dash = strchr(spec, '-'); if (dash == spec) - spage = epage = pdf_count_pages(xref); + spage = epage = pdf_count_pages(doc); else spage = epage = atoi(spec); @@ -330,26 +330,26 @@ static void drawrange(pdf_xref *xref, char *range) if (strlen(dash) > 1) epage = atoi(dash + 1); else - epage = pdf_count_pages(xref); + epage = pdf_count_pages(doc); } - spage = CLAMP(spage, 1, pdf_count_pages(xref)); - epage = CLAMP(epage, 1, pdf_count_pages(xref)); + spage = CLAMP(spage, 1, pdf_count_pages(doc)); + epage = CLAMP(epage, 1, pdf_count_pages(doc)); if (spage < epage) for (page = spage; page <= epage; page++) - drawpage(xref, page); + drawpage(doc, page); else for (page = spage; page >= epage; page--) - drawpage(xref, page); + drawpage(doc, page); spec = fz_strsep(&range, ","); } } -static void drawoutline(pdf_xref *xref) +static void drawoutline(pdf_document *doc) { - fz_outline *outline = pdf_load_outline(xref); + fz_outline *outline = pdf_load_outline(doc); if (showoutline > 1) fz_debug_outline_xml(outline, 0); else @@ -366,11 +366,11 @@ int main(int argc, char **argv) char *password = ""; int grayscale = 0; int accelerate = 1; - pdf_xref *xref = NULL; + pdf_document *doc = NULL; int c; fz_context *ctx; - fz_var(xref); + fz_var(doc); while ((c = fz_getopt(argc, argv, "lo:p:r:R:Aab:dgmtx5G:I")) != -1) { @@ -445,41 +445,41 @@ int main(int argc, char **argv) fz_try(ctx) { - xref = pdf_open_xref(ctx, filename); + doc = pdf_open_document(ctx, filename); } fz_catch(ctx) { fz_throw(ctx, "cannot open document: %s", filename); } - if (pdf_needs_password(xref)) - if (!pdf_authenticate_password(xref, password)) + if (pdf_needs_password(doc)) + if (!pdf_authenticate_password(doc, password)) fz_throw(ctx, "cannot authenticate password: %s", filename); if (showxml) printf("<document name=\"%s\">\n", filename); if (showoutline) - drawoutline(xref); + drawoutline(doc); if (showtext || showxml || showtime || showmd5 || output) { if (fz_optind == argc || !isrange(argv[fz_optind])) - drawrange(xref, "1-"); + drawrange(doc, "1-"); if (fz_optind < argc && isrange(argv[fz_optind])) - drawrange(xref, argv[fz_optind++]); + drawrange(doc, argv[fz_optind++]); } if (showxml) printf("</document>\n"); - pdf_free_xref(xref); - xref = NULL; + pdf_close_document(doc); + doc = NULL; } } fz_catch(ctx) { - pdf_free_xref(xref); + pdf_close_document(doc); } if (showtime) diff --git a/apps/pdfextract.c b/apps/pdfextract.c index f69fd751..1407f7f3 100644 --- a/apps/pdfextract.c +++ b/apps/pdfextract.c @@ -5,7 +5,7 @@ #include "fitz.h" #include "mupdf.h" -static pdf_xref *xref = NULL; +static pdf_document *doc = NULL; static fz_context *ctx = NULL; static int dorgb = 0; @@ -35,11 +35,11 @@ static void saveimage(int num) fz_obj *ref; char name[1024]; - ref = fz_new_indirect(ctx, num, 0, xref); + ref = fz_new_indirect(ctx, num, 0, doc); /* TODO: detect DCTD and save as jpeg */ - img = pdf_load_image(xref, ref); + img = pdf_load_image(doc, ref); if (dorgb && img->colorspace && img->colorspace != fz_device_rgb) { @@ -121,7 +121,7 @@ static void savefont(fz_obj *dict, int num) return; } - buf = pdf_load_stream(xref, fz_to_num(stream), fz_to_gen(stream)); + buf = pdf_load_stream(doc, fz_to_num(stream), fz_to_gen(stream)); sprintf(name, "%s-%04d.%s", fontname, num, ext); printf("extracting font %s\n", name); @@ -144,10 +144,10 @@ static void showobject(int num) { fz_obj *obj; - if (!xref) + if (!doc) fz_throw(ctx, "no file specified"); - obj = pdf_load_object(xref, num, 0); + obj = pdf_load_object(doc, num, 0); if (isimage(obj)) saveimage(num); @@ -189,14 +189,14 @@ int main(int argc, char **argv) exit(1); } - xref = pdf_open_xref(ctx, infile); - if (pdf_needs_password(xref)) - if (!pdf_authenticate_password(xref, password)) + doc = pdf_open_document(ctx, infile); + if (pdf_needs_password(doc)) + if (!pdf_authenticate_password(doc, password)) fz_throw(ctx, "cannot authenticate password: %s\n", infile); if (fz_optind == argc) { - for (o = 0; o < xref->len; o++) + for (o = 0; o < doc->len; o++) showobject(o); } else @@ -208,7 +208,7 @@ int main(int argc, char **argv) } } - pdf_free_xref(xref); + pdf_close_document(doc); fz_flush_warnings(ctx); fz_free_context(ctx); return 0; diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c index 47f26c18..c6c6b35c 100644 --- a/apps/pdfinfo.c +++ b/apps/pdfinfo.c @@ -6,7 +6,7 @@ #include "fitz.h" #include "mupdf.h" -pdf_xref *xref; +pdf_document *xref; fz_context *ctx; int pagecount; @@ -94,7 +94,7 @@ void closexref(void) int i; if (xref) { - pdf_free_xref(xref); + pdf_close_document(xref); xref = NULL; } @@ -993,7 +993,7 @@ int main(int argc, char **argv) filename = argv[fz_optind]; printf("%s:\n", filename); - xref = pdf_open_xref(ctx, filename); + xref = pdf_open_document(ctx, filename); if (pdf_needs_password(xref)) if (!pdf_authenticate_password(xref, password)) fz_throw(ctx, "cannot authenticate password: %s\n", filename); diff --git a/apps/pdfshow.c b/apps/pdfshow.c index 2fbfdc2f..53578fd7 100644 --- a/apps/pdfshow.c +++ b/apps/pdfshow.c @@ -5,7 +5,7 @@ #include "fitz.h" #include "mupdf.h" -static pdf_xref *xref = NULL; +static pdf_document *doc = NULL; static fz_context *ctx = NULL; static int showbinary = 0; static int showdecode = 1; @@ -22,18 +22,18 @@ static void usage(void) static void showtrailer(void) { - if (!xref) + if (!doc) fz_throw(ctx, "no file specified"); printf("trailer\n"); - fz_debug_obj(xref->trailer); + fz_debug_obj(doc->trailer); printf("\n"); } static void showxref(void) { - if (!xref) + if (!doc) fz_throw(ctx, "no file specified"); - pdf_debug_xref(xref); + pdf_debug_xref(doc); printf("\n"); } @@ -43,13 +43,13 @@ static void showpagetree(void) int count; int i; - if (!xref) + if (!doc) fz_throw(ctx, "no file specified"); - count = pdf_count_pages(xref); + count = pdf_count_pages(doc); for (i = 0; i < count; i++) { - ref = xref->page_refs[i]; + ref = doc->page_refs[i]; printf("page %d = %d %d R\n", i + 1, fz_to_num(ref), fz_to_gen(ref)); } printf("\n"); @@ -87,9 +87,9 @@ static void showstream(int num, int gen) showcolumn = 0; if (showdecode) - stm = pdf_open_stream(xref, num, gen); + stm = pdf_open_stream(doc, num, gen); else - stm = pdf_open_raw_stream(xref, num, gen); + stm = pdf_open_raw_stream(doc, num, gen); while (1) { @@ -109,12 +109,12 @@ static void showobject(int num, int gen) { fz_obj *obj; - if (!xref) + if (!doc) fz_throw(ctx, "no file specified"); - obj = pdf_load_object(xref, num, gen); + obj = pdf_load_object(doc, num, gen); - if (pdf_is_stream(xref, num, gen)) + if (pdf_is_stream(doc, num, gen)) { if (showbinary) { @@ -145,13 +145,13 @@ static void showgrep(char *filename) fz_obj *obj; int i; - for (i = 0; i < xref->len; i++) + for (i = 0; i < doc->len; i++) { - if (xref->table[i].type == 'n' || xref->table[i].type == 'o') + if (doc->table[i].type == 'n' || doc->table[i].type == 'o') { fz_try(ctx) { - obj = pdf_load_object(xref, i, 0); + obj = pdf_load_object(doc, i, 0); } fz_catch(ctx) { @@ -169,7 +169,7 @@ static void showgrep(char *filename) } printf("%s:trailer: ", filename); - fz_fprint_obj(stdout, xref->trailer, 1); + fz_fprint_obj(stdout, doc->trailer, 1); } #ifdef MUPDF_COMBINED_EXE @@ -205,12 +205,12 @@ int main(int argc, char **argv) exit(1); } - fz_var(xref); + fz_var(doc); fz_try(ctx) { - xref = pdf_open_xref(ctx, filename); - if (pdf_needs_password(xref)) - if (!pdf_authenticate_password(xref, password)) + doc = pdf_open_document(ctx, filename); + if (pdf_needs_password(doc)) + if (!pdf_authenticate_password(doc, password)) fz_throw(ctx, "cannot authenticate password: %s", filename); if (fz_optind == argc) @@ -233,7 +233,7 @@ int main(int argc, char **argv) { } - pdf_free_xref(xref); + pdf_close_document(doc); fz_free_context(ctx); return 0; } diff --git a/apps/win_main.c b/apps/win_main.c index 4818c58b..db5b92db 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -168,7 +168,7 @@ INT CALLBACK dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { char buf[256]; - pdf_xref *xref = gapp.xref; + pdf_document *doc = gapp.doc; fz_obj *info, *obj; switch(message) @@ -177,7 +177,7 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) SetDlgItemTextW(hwnd, 0x10, wbuf); - if (!xref) + if (!doc) { SetDlgItemTextA(hwnd, 0x11, "XPS"); SetDlgItemTextA(hwnd, 0x12, "None"); @@ -185,22 +185,22 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; } - sprintf(buf, "PDF %d.%d", xref->version / 10, xref->version % 10); + sprintf(buf, "PDF %d.%d", doc->version / 10, doc->version % 10); SetDlgItemTextA(hwnd, 0x11, buf); - if (xref->crypt) + if (doc->crypt) { - sprintf(buf, "Standard V%d %d-bit %s", pdf_get_crypt_revision(xref), - pdf_get_crypt_length(xref), pdf_get_crypt_method(xref)); + sprintf(buf, "Standard V%d %d-bit %s", pdf_get_crypt_revision(doc), + pdf_get_crypt_length(doc), pdf_get_crypt_method(doc)); SetDlgItemTextA(hwnd, 0x12, buf); strcpy(buf, ""); - if (pdf_has_permission(xref, PDF_PERM_PRINT)) + if (pdf_has_permission(doc, PDF_PERM_PRINT)) strcat(buf, "print, "); - if (pdf_has_permission(xref, PDF_PERM_CHANGE)) + if (pdf_has_permission(doc, PDF_PERM_CHANGE)) strcat(buf, "modify, "); - if (pdf_has_permission(xref, PDF_PERM_COPY)) + if (pdf_has_permission(doc, PDF_PERM_COPY)) strcat(buf, "copy, "); - if (pdf_has_permission(xref, PDF_PERM_NOTES)) + if (pdf_has_permission(doc, PDF_PERM_NOTES)) strcat(buf, "annotate, "); if (strlen(buf) > 2) buf[strlen(buf)-2] = 0; @@ -214,14 +214,14 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) SetDlgItemTextA(hwnd, 0x13, "n/a"); } - info = fz_dict_gets(xref->trailer, "Info"); + info = fz_dict_gets(doc->trailer, "Info"); if (!info) return TRUE; #define SETUCS(ID) \ { \ unsigned short *ucs; \ - ucs = pdf_to_ucs2(xref->ctx, obj); \ + ucs = pdf_to_ucs2(doc->ctx, obj); \ SetDlgItemTextW(hwnd, ID, ucs); \ fz_free(context, ucs); \ } diff --git a/apps/xpsdraw.c b/apps/xpsdraw.c index 50a2c3e3..8fec8efa 100644 --- a/apps/xpsdraw.c +++ b/apps/xpsdraw.c @@ -338,7 +338,7 @@ int main(int argc, char **argv) fz_try(ctx) { - doc = xps_open_file(ctx, filename); + doc = xps_open_document(ctx, filename); if (showxml) printf("<document name=\"%s\">\n", filename); @@ -357,11 +357,11 @@ int main(int argc, char **argv) if (showxml) printf("</document>\n"); - xps_free_context(doc); + xps_close_document(doc); } fz_catch(ctx) { - xps_free_context(doc); + xps_close_document(doc); } } diff --git a/fitz/base_object.c b/fitz/base_object.c index 4037c871..a3b38c49 100644 --- a/fitz/base_object.c +++ b/fitz/base_object.c @@ -294,7 +294,7 @@ int fz_to_gen(fz_obj *obj) return obj->u.r.gen; } -void *fz_get_indirect_xref(fz_obj *obj) +void *fz_get_indirect_document(fz_obj *obj) { if (!obj || obj->kind != FZ_INDIRECT) return NULL; diff --git a/fitz/fitz.h b/fitz/fitz.h index 49db7dc2..e156cb27 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -641,7 +641,7 @@ fz_obj *fz_new_int(fz_context *ctx, int i); fz_obj *fz_new_real(fz_context *ctx, float f); fz_obj *fz_new_name(fz_context *ctx, char *str); fz_obj *fz_new_string(fz_context *ctx, char *str, int len); -fz_obj *fz_new_indirect(fz_context *ctx, int num, int gen, void *xref); +fz_obj *fz_new_indirect(fz_context *ctx, int num, int gen, void *doc); fz_obj *fz_new_array(fz_context *ctx, int initialcap); fz_obj *fz_new_dict(fz_context *ctx, int initialcap); @@ -704,7 +704,7 @@ void fz_debug_obj(fz_obj *obj); void fz_debug_ref(fz_obj *obj); void fz_set_str_len(fz_obj *obj, int newlen); /* private */ -void *fz_get_indirect_xref(fz_obj *obj); /* private */ +void *fz_get_indirect_document(fz_obj *obj); /* private */ /* * Data buffers. @@ -1067,8 +1067,8 @@ struct fz_font_s fz_buffer **t3procs; /* has 256 entries if used */ float *t3widths; /* has 256 entries if used */ char *t3flags; /* has 256 entries if used */ - void *t3xref; /* a pdf_xref for the callback */ - void (*t3run)(void *xref, fz_obj *resources, fz_buffer *contents, + void *t3doc; /* a pdf_document for the callback */ + void (*t3run)(void *doc, fz_obj *resources, fz_buffer *contents, struct fz_device_s *dev, fz_matrix ctm, void *gstate); fz_rect bbox; /* font bbox is used only for t3 fonts */ diff --git a/fitz/res_font.c b/fitz/res_font.c index 7bc8f48b..9f1bc73b 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -37,7 +37,7 @@ fz_new_font(fz_context *ctx, char *name, int use_glyph_bbox, int glyph_count) font->t3procs = NULL; font->t3widths = NULL; font->t3flags = NULL; - font->t3xref = NULL; + font->t3doc = NULL; font->t3run = NULL; font->bbox.x0 = 0; @@ -646,7 +646,7 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm) FZ_DEVFLAG_LINEJOIN_UNDEFINED | FZ_DEVFLAG_MITERLIMIT_UNDEFINED | FZ_DEVFLAG_LINEWIDTH_UNDEFINED; - font->t3run(font->t3xref, font->t3resources, contents, dev, ctm, NULL); + font->t3run(font->t3doc, font->t3resources, contents, dev, ctm, NULL); font->t3flags[gid] = dev->flags; fz_free_device(dev); @@ -702,7 +702,7 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co ctm = fz_concat(font->t3matrix, trm); dev = fz_new_draw_device_type3(ctx, glyph); - font->t3run(font->t3xref, font->t3resources, contents, dev, ctm, NULL); + font->t3run(font->t3doc, font->t3resources, contents, dev, ctm, NULL); /* RJW: "cannot draw type3 glyph" */ fz_free_device(dev); @@ -744,7 +744,7 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gi } ctm = fz_concat(font->t3matrix, trm); - font->t3run(font->t3xref, font->t3resources, contents, dev, ctm, gstate); + font->t3run(font->t3doc, font->t3resources, contents, dev, ctm, gstate); /* RJW: "cannot draw type3 glyph" */ } diff --git a/ios/document.c b/ios/document.c index 5531a980..9c209046 100644 --- a/ios/document.c +++ b/ios/document.c @@ -18,18 +18,11 @@ open_document(fz_context *ctx, char *filename) fz_try(ctx) { if (strstr(filename, ".pdf") || strstr(filename, ".PDF")) - { - doc->pdf = pdf_open_xref(ctx, filename); - pdf_load_page_tree(doc->pdf); - } + doc->pdf = pdf_open_document(ctx, filename); else if (strstr(filename, ".xps") || strstr(filename, ".XPS")) - { - doc->xps = xps_open_file(ctx, filename); - } + doc->xps = xps_open_document(ctx, filename); else - { fz_throw(ctx, "unknown document format"); - } } fz_catch(ctx) { @@ -264,12 +257,12 @@ close_document(struct document *doc) if (doc->pdf) { if (doc->pdf_page) pdf_free_page(doc->ctx, doc->pdf_page); - pdf_free_xref(doc->pdf); + pdf_close_document(doc->pdf); } if (doc->xps) { if (doc->xps_page) xps_free_page(doc->xps, doc->xps_page); - xps_free_context(doc->xps); + xps_close_document(doc->xps); } fz_flush_warnings(doc->ctx); fz_free(doc->ctx, doc); diff --git a/ios/document.h b/ios/document.h index ad0a8a62..5e3c740e 100644 --- a/ios/document.h +++ b/ios/document.h @@ -16,7 +16,7 @@ struct document { fz_context *ctx; - pdf_xref *pdf; + pdf_document *pdf; xps_document *xps; int number; pdf_page *pdf_page; diff --git a/pdf/mupdf.h b/pdf/mupdf.h index f1b29e14..f0951976 100644 --- a/pdf/mupdf.h +++ b/pdf/mupdf.h @@ -5,7 +5,7 @@ #error "fitz.h must be included before mupdf.h" #endif -typedef struct pdf_xref_s pdf_xref; +typedef struct pdf_document_s pdf_document; /* * tokenizer and low-level object parser @@ -27,10 +27,10 @@ enum int pdf_lex(fz_stream *f, char *buf, int n, int *len); -fz_obj *pdf_parse_array(pdf_xref *xref, fz_stream *f, char *buf, int cap); -fz_obj *pdf_parse_dict(pdf_xref *xref, fz_stream *f, char *buf, int cap); -fz_obj *pdf_parse_stm_obj(pdf_xref *xref, fz_stream *f, char *buf, int cap); -fz_obj * pdf_parse_ind_obj(pdf_xref *xref, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stm_ofs); +fz_obj *pdf_parse_array(pdf_document *doc, fz_stream *f, char *buf, int cap); +fz_obj *pdf_parse_dict(pdf_document *doc, fz_stream *f, char *buf, int cap); +fz_obj *pdf_parse_stm_obj(pdf_document *doc, fz_stream *f, char *buf, int cap); +fz_obj * pdf_parse_ind_obj(pdf_document *doc, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stm_ofs); fz_rect pdf_to_rect(fz_context *ctx, fz_obj *array); fz_matrix pdf_to_matrix(fz_context *ctx, fz_obj *array); @@ -71,7 +71,7 @@ struct pdf_ocg_descriptor_s fz_obj *intent; }; -struct pdf_xref_s +struct pdf_document_s { fz_context *ctx; fz_stream *file; @@ -94,27 +94,27 @@ struct pdf_xref_s }; fz_obj *pdf_resolve_indirect(fz_obj *ref); -void pdf_cache_object(pdf_xref *, int num, int gen); -fz_obj *pdf_load_object(pdf_xref *, int num, int gen); -void pdf_update_object( pdf_xref *xref, int num, int gen, fz_obj *newobj); - -int pdf_is_stream(pdf_xref *xref, int num, int gen); -fz_stream *pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length); -fz_buffer *pdf_load_raw_stream(pdf_xref *xref, int num, int gen); -fz_buffer *pdf_load_stream(pdf_xref *xref, int num, int gen); -fz_stream *pdf_open_raw_stream(pdf_xref *, int num, int gen); -fz_stream *pdf_open_stream(pdf_xref *, int num, int gen); -fz_stream *pdf_open_stream_at(pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs); - -pdf_xref *pdf_open_xref_with_stream(fz_stream *file); -pdf_xref *pdf_open_xref(fz_context *ctx, const char *filename); -void pdf_free_xref(pdf_xref *); +void pdf_cache_object(pdf_document *doc, int num, int gen); +fz_obj *pdf_load_object(pdf_document *doc, int num, int gen); +void pdf_update_object( pdf_document *doc, int num, int gen, fz_obj *newobj); + +int pdf_is_stream(pdf_document *doc, int num, int gen); +fz_stream *pdf_open_inline_stream(fz_stream *chain, pdf_document *doc, fz_obj *stmobj, int length); +fz_buffer *pdf_load_raw_stream(pdf_document *doc, int num, int gen); +fz_buffer *pdf_load_stream(pdf_document *doc, int num, int gen); +fz_stream *pdf_open_raw_stream(pdf_document *doc, int num, int gen); +fz_stream *pdf_open_stream(pdf_document *doc, int num, int gen); +fz_stream *pdf_open_stream_at(pdf_document *doc, int num, int gen, fz_obj *dict, int stm_ofs); + +pdf_document *pdf_open_document_with_stream(fz_stream *file); +pdf_document *pdf_open_document(fz_context *ctx, const char *filename); +void pdf_close_document(pdf_document *doc); /* private */ -void pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize); -void pdf_repair_obj_stms(pdf_xref *xref); -void pdf_debug_xref(pdf_xref *); -void pdf_resize_xref(pdf_xref *xref, int newcap); +void pdf_repair_xref(pdf_document *doc, char *buf, int bufsize); +void pdf_repair_obj_stms(pdf_document *doc); +void pdf_debug_xref(pdf_document *); +void pdf_resize_xref(pdf_document *doc, int newcap); /* * Encryption @@ -140,14 +140,14 @@ void pdf_crypt_obj(fz_context *ctx, pdf_crypt *crypt, fz_obj *obj, int num, int fz_stream *pdf_open_crypt(fz_stream *chain, pdf_crypt *crypt, int num, int gen); fz_stream *pdf_open_crypt_with_filter(fz_stream *chain, pdf_crypt *crypt, char *name, int num, int gen); -int pdf_needs_password(pdf_xref *xref); -int pdf_authenticate_password(pdf_xref *xref, char *pw); -int pdf_has_permission(pdf_xref *xref, int p); +int pdf_needs_password(pdf_document *doc); +int pdf_authenticate_password(pdf_document *doc, char *pw); +int pdf_has_permission(pdf_document *doc, int p); -int pdf_get_crypt_revision(pdf_xref *xref); -char *pdf_get_crypt_method(pdf_xref *xref); -int pdf_get_crypt_length(pdf_xref *xref); -unsigned char *pdf_get_crypt_key(pdf_xref *xref); +int pdf_get_crypt_revision(pdf_document *doc); +char *pdf_get_crypt_method(pdf_document *doc); +int pdf_get_crypt_length(pdf_document *doc); +unsigned char *pdf_get_crypt_key(pdf_document *doc); void pdf_debug_crypt(pdf_crypt *crypt); @@ -157,19 +157,19 @@ void pdf_debug_crypt(pdf_crypt *crypt); typedef struct pdf_function_s pdf_function; -pdf_function *pdf_load_function(pdf_xref *xref, fz_obj *ref); +pdf_function *pdf_load_function(pdf_document *doc, fz_obj *ref); void pdf_eval_function(fz_context *ctx, pdf_function *func, float *in, int inlen, float *out, int outlen); pdf_function *pdf_keep_function(fz_context *ctx, pdf_function *func); void pdf_drop_function(fz_context *ctx, pdf_function *func); unsigned int pdf_function_size(pdf_function *func); -fz_colorspace *pdf_load_colorspace(pdf_xref *xref, fz_obj *obj); +fz_colorspace *pdf_load_colorspace(pdf_document *doc, fz_obj *obj); fz_pixmap *pdf_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src); -fz_shade *pdf_load_shading(pdf_xref *xref, fz_obj *obj); +fz_shade *pdf_load_shading(pdf_document *doc, fz_obj *obj); -fz_pixmap *pdf_load_inline_image(pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file); -fz_pixmap *pdf_load_image(pdf_xref *xref, fz_obj *obj); +fz_pixmap *pdf_load_inline_image(pdf_document *doc, fz_obj *rdb, fz_obj *dict, fz_stream *file); +fz_pixmap *pdf_load_image(pdf_document *doc, fz_obj *obj); int pdf_is_jpx_image(fz_context *ctx, fz_obj *dict); /* @@ -190,7 +190,7 @@ struct pdf_pattern_s fz_buffer *contents; }; -pdf_pattern *pdf_load_pattern(pdf_xref *xref, fz_obj *obj); +pdf_pattern *pdf_load_pattern(pdf_document *doc, fz_obj *obj); pdf_pattern *pdf_keep_pattern(fz_context *ctx, pdf_pattern *pat); void pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat); @@ -214,7 +214,7 @@ struct pdf_xobject_s fz_obj *me; }; -pdf_xobject *pdf_load_xobject(pdf_xref *xref, fz_obj *obj); +pdf_xobject *pdf_load_xobject(pdf_document *doc, fz_obj *obj); pdf_xobject *pdf_keep_xobject(fz_context *ctx, pdf_xobject *xobj); void pdf_drop_xobject(fz_context *ctx, pdf_xobject *xobj); @@ -285,7 +285,7 @@ unsigned char *pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, int *cpt); pdf_cmap *pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes); pdf_cmap *pdf_parse_cmap(fz_stream *file); -pdf_cmap *pdf_load_embedded_cmap(pdf_xref *xref, fz_obj *ref); +pdf_cmap *pdf_load_embedded_cmap(pdf_document *doc, fz_obj *ref); pdf_cmap *pdf_load_system_cmap(fz_context *ctx, char *name); pdf_cmap *pdf_find_builtin_cmap(char *cmap_name); @@ -389,7 +389,7 @@ void pdf_end_vmtx(pdf_font_desc *font); pdf_hmtx pdf_get_hmtx(pdf_font_desc *font, int cid); pdf_vmtx pdf_get_vmtx(pdf_font_desc *font, int cid); -void pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm); +void pdf_load_to_unicode(pdf_font_desc *font, pdf_document *doc, char **strings, char *collection, fz_obj *cmapstm); int pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid); @@ -397,8 +397,8 @@ unsigned char *pdf_find_builtin_font(char *name, unsigned int *len); unsigned char *pdf_find_substitute_font(int mono, int serif, int bold, int italic, unsigned int *len); unsigned char *pdf_find_substitute_cjk_font(int ros, int serif, unsigned int *len); -pdf_font_desc *pdf_load_type3_font(pdf_xref *xref, fz_obj *rdb, fz_obj *obj); -pdf_font_desc *pdf_load_font(pdf_xref *xref, fz_obj *rdb, fz_obj *obj); +pdf_font_desc *pdf_load_type3_font(pdf_document *doc, fz_obj *rdb, fz_obj *obj); +pdf_font_desc *pdf_load_font(pdf_document *doc, fz_obj *rdb, fz_obj *obj); pdf_font_desc *pdf_new_font_desc(fz_context *ctx); pdf_font_desc *pdf_keep_font(fz_context *ctx, pdf_font_desc *fontdesc); @@ -421,17 +421,17 @@ struct pdf_annot_s pdf_annot *next; }; -fz_link_dest pdf_parse_link_dest(pdf_xref *xref, fz_obj *dest); -fz_link_dest pdf_parse_action(pdf_xref *xref, fz_obj *action); -fz_obj *pdf_lookup_dest(pdf_xref *xref, fz_obj *needle); -fz_obj *pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle); -fz_obj *pdf_load_name_tree(pdf_xref *xref, char *which); +fz_link_dest pdf_parse_link_dest(pdf_document *doc, fz_obj *dest); +fz_link_dest pdf_parse_action(pdf_document *doc, fz_obj *action); +fz_obj *pdf_lookup_dest(pdf_document *doc, fz_obj *needle); +fz_obj *pdf_lookup_name(pdf_document *doc, char *which, fz_obj *needle); +fz_obj *pdf_load_name_tree(pdf_document *doc, char *which); -fz_outline *pdf_load_outline(pdf_xref *xref); +fz_outline *pdf_load_outline(pdf_document *doc); -fz_link *pdf_load_links(pdf_xref *, fz_obj *annots, fz_matrix page_ctm); +fz_link *pdf_load_links(pdf_document *, fz_obj *annots, fz_matrix page_ctm); -pdf_annot *pdf_load_annots(pdf_xref *, fz_obj *annots); +pdf_annot *pdf_load_annots(pdf_document *, fz_obj *annots); void pdf_free_annot(fz_context *ctx, pdf_annot *link); /* @@ -452,19 +452,19 @@ struct pdf_page_s pdf_annot *annots; }; -int pdf_find_page_number(pdf_xref *xref, fz_obj *pageobj); -int pdf_count_pages(pdf_xref *xref); +int pdf_find_page_number(pdf_document *doc, fz_obj *pageobj); +int pdf_count_pages(pdf_document *doc); -pdf_page *pdf_load_page(pdf_xref *xref, int number); -fz_rect pdf_bound_page(pdf_xref *xref, pdf_page *page); +pdf_page *pdf_load_page(pdf_document *doc, int number); +fz_rect pdf_bound_page(pdf_document *doc, pdf_page *page); void pdf_free_page(fz_context *ctx, pdf_page *page); /* * Content stream parsing */ -void pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *event, fz_cookie *cookie); -void pdf_run_page(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie); -void pdf_run_glyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate); +void pdf_run_page_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, fz_matrix ctm, char *event, fz_cookie *cookie); +void pdf_run_page(pdf_document *doc, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie); +void pdf_run_glyph(pdf_document *doc, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate); #endif diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c index 1daf8dbf..12c08bf4 100644 --- a/pdf/pdf_annot.c +++ b/pdf/pdf_annot.c @@ -2,7 +2,7 @@ #include "mupdf.h" static fz_obj * -resolve_dest_rec(pdf_xref *xref, fz_obj *dest, int depth) +resolve_dest_rec(pdf_document *xref, fz_obj *dest, int depth) { if (depth > 10) /* Arbitrary to avoid infinite recursion */ return NULL; @@ -31,13 +31,13 @@ resolve_dest_rec(pdf_xref *xref, fz_obj *dest, int depth) } static fz_obj * -resolve_dest(pdf_xref *xref, fz_obj *dest) +resolve_dest(pdf_document *xref, fz_obj *dest) { return resolve_dest_rec(xref, dest, 0); } fz_link_dest -pdf_parse_link_dest(pdf_xref *xref, fz_obj *dest) +pdf_parse_link_dest(pdf_document *xref, fz_obj *dest) { fz_link_dest ld; fz_obj *obj; @@ -192,7 +192,7 @@ pdf_parse_link_dest(pdf_xref *xref, fz_obj *dest) } fz_link_dest -pdf_parse_action(pdf_xref *xref, fz_obj *action) +pdf_parse_action(pdf_document *xref, fz_obj *action) { fz_link_dest ld; fz_obj *obj, *dest; @@ -238,7 +238,7 @@ pdf_parse_action(pdf_xref *xref, fz_obj *action) } static fz_link * -pdf_load_link(pdf_xref *xref, fz_obj *dict, fz_matrix page_ctm) +pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm) { fz_obj *dest = NULL; fz_obj *action; @@ -278,7 +278,7 @@ pdf_load_link(pdf_xref *xref, fz_obj *dict, fz_matrix page_ctm) } fz_link * -pdf_load_links(pdf_xref *xref, fz_obj *annots, fz_matrix page_ctm) +pdf_load_links(pdf_document *xref, fz_obj *annots, fz_matrix page_ctm) { fz_link *link, *head, *tail; fz_obj *obj; @@ -349,7 +349,7 @@ pdf_transform_annot(pdf_annot *annot) } pdf_annot * -pdf_load_annots(pdf_xref *xref, fz_obj *annots) +pdf_load_annots(pdf_document *xref, fz_obj *annots) { pdf_annot *annot, *head, *tail; fz_obj *obj, *ap, *as, *n, *rect; diff --git a/pdf/pdf_cmap_load.c b/pdf/pdf_cmap_load.c index bcfc61ae..0d56bd03 100644 --- a/pdf/pdf_cmap_load.c +++ b/pdf/pdf_cmap_load.c @@ -16,7 +16,7 @@ pdf_cmap_size(pdf_cmap *cmap) * Load CMap stream in PDF file */ pdf_cmap * -pdf_load_embedded_cmap(pdf_xref *xref, fz_obj *stmobj) +pdf_load_embedded_cmap(pdf_document *xref, fz_obj *stmobj) { fz_stream *file = NULL; pdf_cmap *cmap = NULL; diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c index b7f9f131..7a410df8 100644 --- a/pdf/pdf_colorspace.c +++ b/pdf/pdf_colorspace.c @@ -4,7 +4,7 @@ /* ICCBased */ static fz_colorspace * -load_icc_based(pdf_xref *xref, fz_obj *dict) +load_icc_based(pdf_document *xref, fz_obj *dict) { int n; @@ -91,7 +91,7 @@ free_separation(fz_context *ctx, fz_colorspace *cs) } static fz_colorspace * -load_separation(pdf_xref *xref, fz_obj *array) +load_separation(pdf_document *xref, fz_obj *array) { fz_colorspace *cs; struct separation *sep = NULL; @@ -218,7 +218,7 @@ pdf_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src) } static fz_colorspace * -load_indexed(pdf_xref *xref, fz_obj *array) +load_indexed(pdf_document *xref, fz_obj *array) { struct indexed *idx = NULL; fz_context *ctx = xref->ctx; @@ -304,7 +304,7 @@ load_indexed(pdf_xref *xref, fz_obj *array) /* Parse and create colorspace from PDF object */ static fz_colorspace * -pdf_load_colorspace_imp(pdf_xref *xref, fz_obj *obj) +pdf_load_colorspace_imp(pdf_document *xref, fz_obj *obj) { if (fz_is_name(obj)) { @@ -390,7 +390,7 @@ pdf_load_colorspace_imp(pdf_xref *xref, fz_obj *obj) } fz_colorspace * -pdf_load_colorspace(pdf_xref *xref, fz_obj *obj) +pdf_load_colorspace(pdf_document *xref, fz_obj *obj) { fz_context *ctx = xref->ctx; fz_colorspace *cs; diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c index 18b3d554..c3cd5d8c 100644 --- a/pdf/pdf_crypt.c +++ b/pdf/pdf_crypt.c @@ -575,7 +575,7 @@ pdf_authenticate_owner_password(pdf_crypt *crypt, unsigned char *ownerpass, int } int -pdf_authenticate_password(pdf_xref *xref, char *password) +pdf_authenticate_password(pdf_document *xref, char *password) { if (xref->crypt) { @@ -591,7 +591,7 @@ pdf_authenticate_password(pdf_xref *xref, char *password) } int -pdf_needs_password(pdf_xref *xref) +pdf_needs_password(pdf_document *xref) { if (!xref->crypt) return 0; @@ -601,7 +601,7 @@ pdf_needs_password(pdf_xref *xref) } int -pdf_has_permission(pdf_xref *xref, int p) +pdf_has_permission(pdf_document *xref, int p) { if (!xref->crypt) return 1; @@ -609,7 +609,7 @@ pdf_has_permission(pdf_xref *xref, int p) } unsigned char * -pdf_get_crypt_key(pdf_xref *xref) +pdf_get_crypt_key(pdf_document *xref) { if (xref->crypt) return xref->crypt->key; @@ -617,7 +617,7 @@ pdf_get_crypt_key(pdf_xref *xref) } int -pdf_get_crypt_revision(pdf_xref *xref) +pdf_get_crypt_revision(pdf_document *xref) { if (xref->crypt) return xref->crypt->v; @@ -625,7 +625,7 @@ pdf_get_crypt_revision(pdf_xref *xref) } char * -pdf_get_crypt_method(pdf_xref *xref) +pdf_get_crypt_method(pdf_document *xref) { if (xref->crypt) { @@ -642,7 +642,7 @@ pdf_get_crypt_method(pdf_xref *xref) } int -pdf_get_crypt_length(pdf_xref *xref) +pdf_get_crypt_length(pdf_document *xref) { if (xref->crypt) return xref->crypt->length; diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index b6c59153..65309a73 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -5,7 +5,7 @@ #include FT_FREETYPE_H #include FT_XFREE86_H -static void pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *dict, char *collection, char *basefont); +static void pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *dict, char *collection, char *basefont); static char *base_font_names[14][7] = { @@ -266,7 +266,7 @@ pdf_load_system_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname, c } static void -pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *stmref) +pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *stmref) { fz_buffer *buf; fz_context *ctx = xref->ctx; @@ -392,7 +392,7 @@ pdf_new_font_desc(fz_context *ctx) */ static pdf_font_desc * -pdf_load_simple_font(pdf_xref *xref, fz_obj *dict) +pdf_load_simple_font(pdf_document *xref, fz_obj *dict) { fz_obj *descriptor; fz_obj *encoding; @@ -704,7 +704,7 @@ pdf_load_simple_font(pdf_xref *xref, fz_obj *dict) */ static pdf_font_desc * -load_cid_font(pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode) +load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode) { fz_obj *widths; fz_obj *descriptor; @@ -936,7 +936,7 @@ load_cid_font(pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode } static pdf_font_desc * -pdf_load_type0_font(pdf_xref *xref, fz_obj *dict) +pdf_load_type0_font(pdf_document *xref, fz_obj *dict) { fz_obj *dfonts; fz_obj *dfont; @@ -969,7 +969,7 @@ pdf_load_type0_font(pdf_xref *xref, fz_obj *dict) */ static void -pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *dict, char *collection, char *basefont) +pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *dict, char *collection, char *basefont) { fz_obj *obj1, *obj2, *obj3, *obj; char *fontname; @@ -1067,7 +1067,7 @@ pdf_make_width_table(fz_context *ctx, pdf_font_desc *fontdesc) } pdf_font_desc * -pdf_load_font(pdf_xref *xref, fz_obj *rdb, fz_obj *dict) +pdf_load_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict) { char *subtype; fz_obj *dfonts; diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index 7111cae7..34b419e5 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -816,7 +816,7 @@ parse_code(pdf_function *func, fz_stream *stream, int *codeptr) } static void -load_postscript_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen) +load_postscript_func(pdf_function *func, pdf_document *xref, fz_obj *dict, int num, int gen) { fz_stream *stream = NULL; int codeptr; @@ -884,7 +884,7 @@ eval_postscript_func(fz_context *ctx, pdf_function *func, float *in, float *out) */ static void -load_sample_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen) +load_sample_func(pdf_function *func, pdf_document *xref, fz_obj *dict, int num, int gen) { fz_context *ctx = xref->ctx; fz_stream *stream; @@ -1169,7 +1169,7 @@ eval_exponential_func(fz_context *ctx, pdf_function *func, float in, float *out) */ static void -load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict) +load_stitching_func(pdf_function *func, pdf_document *xref, fz_obj *dict) { fz_context *ctx = xref->ctx; pdf_function **funcs; @@ -1340,7 +1340,7 @@ pdf_function_size(pdf_function *func) } pdf_function * -pdf_load_function(pdf_xref *xref, fz_obj *dict) +pdf_load_function(pdf_document *xref, fz_obj *dict) { fz_context *ctx = xref->ctx; pdf_function *func; diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index 33e6077d..80cbb062 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -4,7 +4,7 @@ /* TODO: store JPEG compressed samples */ /* TODO: store flate compressed samples */ -static fz_pixmap *pdf_load_jpx_image(pdf_xref *xref, fz_obj *dict); +static fz_pixmap *pdf_load_jpx_image(pdf_document *xref, fz_obj *dict); static void pdf_mask_color_key(fz_pixmap *pix, int n, int *colorkey) @@ -26,7 +26,7 @@ pdf_mask_color_key(fz_pixmap *pix, int n, int *colorkey) } static fz_pixmap * -pdf_load_image_imp(pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask) +pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask) { fz_stream *stm = NULL; fz_pixmap *tile = NULL; @@ -275,7 +275,7 @@ pdf_load_image_imp(pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, i } fz_pixmap * -pdf_load_inline_image(pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file) +pdf_load_inline_image(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file) { return pdf_load_image_imp(xref, rdb, dict, file, 0); /* RJW: "cannot load inline image" */ @@ -298,7 +298,7 @@ pdf_is_jpx_image(fz_context *ctx, fz_obj *dict) } static fz_pixmap * -pdf_load_jpx_image(pdf_xref *xref, fz_obj *dict) +pdf_load_jpx_image(pdf_document *xref, fz_obj *dict) { fz_buffer *buf = NULL; fz_colorspace *colorspace = NULL; @@ -367,7 +367,7 @@ pdf_load_jpx_image(pdf_xref *xref, fz_obj *dict) } fz_pixmap * -pdf_load_image(pdf_xref *xref, fz_obj *dict) +pdf_load_image(pdf_document *xref, fz_obj *dict) { fz_context *ctx = xref->ctx; fz_pixmap *pix; diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index ff9a8f2c..3b774d71 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -64,7 +64,7 @@ struct pdf_gstate_s struct pdf_csi_s { fz_device *dev; - pdf_xref *xref; + pdf_document *xref; /* usage mode for optional content groups */ char *event; /* "View", "Print", "Export" */ @@ -942,7 +942,7 @@ copy_state(fz_context *ctx, pdf_gstate *gs, pdf_gstate *old) static pdf_csi * -pdf_new_csi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *event, fz_cookie *cookie, pdf_gstate *gstate) +pdf_new_csi(pdf_document *xref, fz_device *dev, fz_matrix ctm, char *event, fz_cookie *cookie, pdf_gstate *gstate) { pdf_csi *csi; fz_context *ctx = dev->ctx; @@ -2685,7 +2685,7 @@ pdf_run_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents) } void -pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *event, fz_cookie *cookie) +pdf_run_page_with_usage(pdf_document *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *event, fz_cookie *cookie) { fz_context *ctx = dev->ctx; pdf_csi *csi; @@ -2760,13 +2760,13 @@ pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matri } void -pdf_run_page(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie) +pdf_run_page(pdf_document *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie) { pdf_run_page_with_usage(xref, page, dev, ctm, "View", cookie); } void -pdf_run_glyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate) +pdf_run_glyph(pdf_document *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate) { pdf_csi *csi = pdf_new_csi(xref, dev, ctm, "View", NULL, gstate); fz_context *ctx = xref->ctx; diff --git a/pdf/pdf_nametree.c b/pdf/pdf_nametree.c index bbb956f1..c78e238d 100644 --- a/pdf/pdf_nametree.c +++ b/pdf/pdf_nametree.c @@ -71,7 +71,7 @@ pdf_lookup_name_imp(fz_context *ctx, fz_obj *node, fz_obj *needle) } fz_obj * -pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle) +pdf_lookup_name(pdf_document *xref, char *which, fz_obj *needle) { fz_context *ctx = xref->ctx; @@ -82,7 +82,7 @@ pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle) } fz_obj * -pdf_lookup_dest(pdf_xref *xref, fz_obj *needle) +pdf_lookup_dest(pdf_document *xref, fz_obj *needle) { fz_context *ctx = xref->ctx; @@ -111,7 +111,7 @@ pdf_lookup_dest(pdf_xref *xref, fz_obj *needle) } static void -pdf_load_name_tree_imp(fz_obj *dict, pdf_xref *xref, fz_obj *node) +pdf_load_name_tree_imp(fz_obj *dict, pdf_document *xref, fz_obj *node) { fz_context *ctx = xref->ctx; fz_obj *kids = fz_dict_gets(node, "Kids"); @@ -146,7 +146,7 @@ pdf_load_name_tree_imp(fz_obj *dict, pdf_xref *xref, fz_obj *node) } fz_obj * -pdf_load_name_tree(pdf_xref *xref, char *which) +pdf_load_name_tree(pdf_document *xref, char *which) { fz_context *ctx = xref->ctx; diff --git a/pdf/pdf_outline.c b/pdf/pdf_outline.c index 5762be05..2815d918 100644 --- a/pdf/pdf_outline.c +++ b/pdf/pdf_outline.c @@ -2,7 +2,7 @@ #include "mupdf.h" static fz_outline * -pdf_load_outline_imp(pdf_xref *xref, fz_obj *dict) +pdf_load_outline_imp(pdf_document *xref, fz_obj *dict) { fz_context *ctx = xref->ctx; fz_outline *node, **prev, *first; @@ -58,7 +58,7 @@ pdf_load_outline_imp(pdf_xref *xref, fz_obj *dict) } fz_outline * -pdf_load_outline(pdf_xref *xref) +pdf_load_outline(pdf_document *xref) { fz_obj *root, *obj, *first; diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c index 8cfadfb7..ed80aa90 100644 --- a/pdf/pdf_page.c +++ b/pdf/pdf_page.c @@ -28,7 +28,7 @@ put_marker_bool(fz_context *ctx, fz_obj *rdb, char *marker, int val) } static void -pdf_load_page_tree_node(pdf_xref *xref, fz_obj *node, struct info info) +pdf_load_page_tree_node(pdf_document *xref, fz_obj *node, struct info info) { fz_obj *dict, *kids, *count; fz_obj *obj; @@ -99,7 +99,7 @@ pdf_load_page_tree_node(pdf_xref *xref, fz_obj *node, struct info info) } static void -pdf_load_page_tree(pdf_xref *xref) +pdf_load_page_tree(pdf_document *xref) { fz_context *ctx = xref->ctx; fz_obj *catalog; @@ -133,14 +133,14 @@ pdf_load_page_tree(pdf_xref *xref) } int -pdf_count_pages(pdf_xref *xref) +pdf_count_pages(pdf_document *xref) { pdf_load_page_tree(xref); return xref->page_len; } int -pdf_find_page_number(pdf_xref *xref, fz_obj *page) +pdf_find_page_number(pdf_document *xref, fz_obj *page) { int i, num = fz_to_num(page); @@ -239,7 +239,7 @@ found: /* we need to combine all sub-streams into one for the content stream interpreter */ static fz_buffer * -pdf_load_page_contents_array(pdf_xref *xref, fz_obj *list) +pdf_load_page_contents_array(pdf_document *xref, fz_obj *list) { fz_buffer *big; fz_buffer *one; @@ -282,7 +282,7 @@ pdf_load_page_contents_array(pdf_xref *xref, fz_obj *list) } static fz_buffer * -pdf_load_page_contents(pdf_xref *xref, fz_obj *obj) +pdf_load_page_contents(pdf_document *xref, fz_obj *obj) { fz_context *ctx = xref->ctx; @@ -302,7 +302,7 @@ pdf_load_page_contents(pdf_xref *xref, fz_obj *obj) } pdf_page * -pdf_load_page(pdf_xref *xref, int number) +pdf_load_page(pdf_document *xref, int number) { fz_context *ctx = xref->ctx; pdf_page *page; @@ -389,7 +389,7 @@ pdf_load_page(pdf_xref *xref, int number) } fz_rect -pdf_bound_page(pdf_xref *xref, pdf_page *page) +pdf_bound_page(pdf_document *xref, pdf_page *page) { fz_rect bounds, mediabox = fz_transform_rect(fz_rotate(page->rotate), page->mediabox); bounds.x0 = bounds.y0 = 0; diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c index b2f4fbf7..220eb30c 100644 --- a/pdf/pdf_parse.c +++ b/pdf/pdf_parse.c @@ -171,7 +171,7 @@ pdf_to_utf8_name(fz_context *ctx, fz_obj *src) } fz_obj * -pdf_parse_array(pdf_xref *xref, fz_stream *file, char *buf, int cap) +pdf_parse_array(pdf_document *xref, fz_stream *file, char *buf, int cap) { fz_obj *ary = NULL; fz_obj *obj = NULL; @@ -312,7 +312,7 @@ end: } fz_obj * -pdf_parse_dict(pdf_xref *xref, fz_stream *file, char *buf, int cap) +pdf_parse_dict(pdf_document *xref, fz_stream *file, char *buf, int cap) { fz_obj *dict = NULL; fz_obj *key = NULL; @@ -414,7 +414,7 @@ pdf_parse_dict(pdf_xref *xref, fz_stream *file, char *buf, int cap) } fz_obj * -pdf_parse_stm_obj(pdf_xref *xref, fz_stream *file, char *buf, int cap) +pdf_parse_stm_obj(pdf_document *xref, fz_stream *file, char *buf, int cap) { int tok; int len; @@ -444,7 +444,7 @@ pdf_parse_stm_obj(pdf_xref *xref, fz_stream *file, char *buf, int cap) } fz_obj * -pdf_parse_ind_obj(pdf_xref *xref, +pdf_parse_ind_obj(pdf_document *xref, fz_stream *file, char *buf, int cap, int *onum, int *ogen, int *ostmofs) { diff --git a/pdf/pdf_pattern.c b/pdf/pdf_pattern.c index 2b4d32a2..9ffbee02 100644 --- a/pdf/pdf_pattern.c +++ b/pdf/pdf_pattern.c @@ -34,7 +34,7 @@ pdf_pattern_size(pdf_pattern *pat) } pdf_pattern * -pdf_load_pattern(pdf_xref *xref, fz_obj *dict) +pdf_load_pattern(pdf_document *xref, fz_obj *dict) { pdf_pattern *pat; fz_obj *obj; diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index cdd8c521..15886a8f 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -141,7 +141,7 @@ atobjend: } static void -pdf_repair_obj_stm(pdf_xref *xref, int num, int gen) +pdf_repair_obj_stm(pdf_document *xref, int num, int gen) { fz_obj *obj; fz_stream *stm = NULL; @@ -193,7 +193,7 @@ pdf_repair_obj_stm(pdf_xref *xref, int num, int gen) } void -pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) +pdf_repair_xref(pdf_document *xref, char *buf, int bufsize) { fz_obj *dict, *obj; fz_obj *length; @@ -475,7 +475,7 @@ pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) } void -pdf_repair_obj_stms(pdf_xref *xref) +pdf_repair_obj_stms(pdf_document *xref) { fz_obj *dict; int i; diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c index 4f43c225..15f5de6b 100644 --- a/pdf/pdf_shade.c +++ b/pdf/pdf_shade.c @@ -363,7 +363,7 @@ pdf_sample_shade_function(fz_context *ctx, fz_shade *shade, int funcs, pdf_funct /* Type 1-3 -- Function-based, axial and radial shadings */ static void -pdf_load_function_based_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_function *func) +pdf_load_function_based_shading(fz_shade *shade, pdf_document *xref, fz_obj *dict, pdf_function *func) { fz_obj *obj; float x0, y0, x1, y1; @@ -428,7 +428,7 @@ pdf_load_function_based_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, p } static void -pdf_load_axial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func) +pdf_load_axial_shading(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func) { fz_obj *obj; float d0, d1; @@ -479,7 +479,7 @@ pdf_load_axial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, } static void -pdf_load_radial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func) +pdf_load_radial_shading(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func) { fz_obj *obj; float d0, d1; @@ -553,7 +553,7 @@ struct mesh_params }; static void -pdf_load_mesh_params(pdf_xref *xref, fz_obj *dict, struct mesh_params *p) +pdf_load_mesh_params(pdf_document *xref, fz_obj *dict, struct mesh_params *p) { fz_obj *obj; int i, n; @@ -603,7 +603,7 @@ pdf_load_mesh_params(pdf_xref *xref, fz_obj *dict, struct mesh_params *p) } static void -pdf_load_type4_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type4_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { fz_context *ctx = xref->ctx; @@ -668,7 +668,7 @@ pdf_load_type4_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, } static void -pdf_load_type5_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type5_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { fz_context *ctx = xref->ctx; @@ -718,7 +718,7 @@ pdf_load_type5_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, /* Type 6 & 7 -- Patch mesh shadings */ static void -pdf_load_type6_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type6_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { fz_context *ctx = xref->ctx; @@ -837,7 +837,7 @@ pdf_load_type6_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, } static void -pdf_load_type7_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type7_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { fz_context *ctx = xref->ctx; @@ -958,7 +958,7 @@ pdf_load_type7_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, /* Load all of the shading dictionary parameters, then switch on the shading type. */ static fz_shade * -pdf_load_shading_dict(pdf_xref *xref, fz_obj *dict, fz_matrix transform) +pdf_load_shading_dict(pdf_document *xref, fz_obj *dict, fz_matrix transform) { fz_shade *shade = NULL; pdf_function *func[FZ_MAX_COLORS] = { NULL }; @@ -1089,7 +1089,7 @@ fz_shade_size(fz_shade *s) } fz_shade * -pdf_load_shading(pdf_xref *xref, fz_obj *dict) +pdf_load_shading(pdf_document *xref, fz_obj *dict) { fz_matrix mat; fz_obj *obj; diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c index bf9ccc70..75c0f59c 100644 --- a/pdf/pdf_stream.c +++ b/pdf/pdf_stream.c @@ -5,7 +5,7 @@ * Check if an object is a stream or not. */ int -pdf_is_stream(pdf_xref *xref, int num, int gen) +pdf_is_stream(pdf_document *xref, int num, int gen) { if (num < 0 || num >= xref->len) return 0; @@ -49,7 +49,7 @@ pdf_stream_has_crypt(fz_context *ctx, fz_obj *stm) * Create a filter given a name and param dictionary. */ static fz_stream * -build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, int gen) +build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int num, int gen) { char *s; fz_context *ctx = chain->ctx; @@ -127,7 +127,7 @@ build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, * Assume ownership of head. */ static fz_stream * -build_filter_chain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int num, int gen) +build_filter_chain(fz_stream *chain, pdf_document *xref, fz_obj *fs, fz_obj *ps, int num, int gen) { fz_obj *f; fz_obj *p; @@ -150,7 +150,7 @@ build_filter_chain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int * stream length, followed by a decryption filter. */ static fz_stream * -pdf_open_raw_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen) +pdf_open_raw_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int num, int gen) { int hascrypt; int len; @@ -182,7 +182,7 @@ pdf_open_raw_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, i * to stream length and decrypting. */ static fz_stream * -pdf_open_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen) +pdf_open_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int num, int gen) { fz_obj *filters; fz_obj *params; @@ -205,7 +205,7 @@ pdf_open_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int g * constraining to stream length, and without decryption. */ fz_stream * -pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length) +pdf_open_inline_stream(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int length) { fz_obj *filters; fz_obj *params; @@ -229,7 +229,7 @@ pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int len * Using xref->file while this is open is a bad idea. */ fz_stream * -pdf_open_raw_stream(pdf_xref *xref, int num, int gen) +pdf_open_raw_stream(pdf_document *xref, int num, int gen) { pdf_xref_entry *x; fz_stream *stm; @@ -258,7 +258,7 @@ pdf_open_raw_stream(pdf_xref *xref, int num, int gen) * Using xref->file while a stream is open is a Bad idea. */ fz_stream * -pdf_open_stream(pdf_xref *xref, int num, int gen) +pdf_open_stream(pdf_document *xref, int num, int gen) { pdf_xref_entry *x; fz_stream *stm; @@ -280,7 +280,7 @@ pdf_open_stream(pdf_xref *xref, int num, int gen) } fz_stream * -pdf_open_stream_at(pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs) +pdf_open_stream_at(pdf_document *xref, int num, int gen, fz_obj *dict, int stm_ofs) { fz_stream *stm; @@ -296,7 +296,7 @@ pdf_open_stream_at(pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs) * Load raw (compressed but decrypted) contents of a stream into buf. */ fz_buffer * -pdf_load_raw_stream(pdf_xref *xref, int num, int gen) +pdf_load_raw_stream(pdf_document *xref, int num, int gen) { fz_stream *stm; fz_obj *dict; @@ -340,7 +340,7 @@ pdf_guess_filter_length(int len, char *filter) * Load uncompressed contents of a stream into buf. */ fz_buffer * -pdf_load_stream(pdf_xref *xref, int num, int gen) +pdf_load_stream(pdf_document *xref, int num, int gen) { fz_context *ctx = xref->ctx; fz_stream *stm = NULL; diff --git a/pdf/pdf_type3.c b/pdf/pdf_type3.c index d9bf528e..176bf32a 100644 --- a/pdf/pdf_type3.c +++ b/pdf/pdf_type3.c @@ -2,13 +2,13 @@ #include "mupdf.h" static void -pdf_run_glyph_func(void *xref, fz_obj *rdb, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate) +pdf_run_glyph_func(void *doc, fz_obj *rdb, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate) { - pdf_run_glyph(xref, rdb, contents, dev, ctm, gstate); + pdf_run_glyph(doc, rdb, contents, dev, ctm, gstate); } pdf_font_desc * -pdf_load_type3_font(pdf_xref *xref, fz_obj *rdb, fz_obj *dict) +pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict) { char buf[256]; char *estrings[256]; @@ -125,7 +125,7 @@ pdf_load_type3_font(pdf_xref *xref, fz_obj *rdb, fz_obj *dict) if (!fontdesc->font->t3resources) fz_warn(ctx, "no resource dictionary for type 3 font!"); - fontdesc->font->t3xref = xref; + fontdesc->font->t3doc = xref; fontdesc->font->t3run = pdf_run_glyph_func; /* CharProcs */ diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c index 95e7fa00..1fed0f63 100644 --- a/pdf/pdf_unicode.c +++ b/pdf/pdf_unicode.c @@ -4,7 +4,7 @@ /* Load or synthesize ToUnicode map for fonts */ void -pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, +pdf_load_to_unicode(pdf_font_desc *font, pdf_document *xref, char **strings, char *collection, fz_obj *cmapstm) { pdf_cmap *cmap; diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c index e33ac858..91bf4db3 100644 --- a/pdf/pdf_xobject.c +++ b/pdf/pdf_xobject.c @@ -37,7 +37,7 @@ pdf_xobject_size(pdf_xobject *xobj) } pdf_xobject * -pdf_load_xobject(pdf_xref *xref, fz_obj *dict) +pdf_load_xobject(pdf_document *xref, fz_obj *dict) { pdf_xobject *form; fz_obj *obj; diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index bfd04acb..7fb247d9 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -13,7 +13,7 @@ static inline int iswhite(int ch) */ static void -pdf_load_version(pdf_xref *xref) +pdf_load_version(pdf_document *xref) { char buf[20]; @@ -26,7 +26,7 @@ pdf_load_version(pdf_xref *xref) } static void -pdf_read_start_xref(pdf_xref *xref) +pdf_read_start_xref(pdf_document *xref) { unsigned char buf[1024]; int t, n; @@ -63,7 +63,7 @@ pdf_read_start_xref(pdf_xref *xref) */ static void -pdf_read_old_trailer(pdf_xref *xref, char *buf, int cap) +pdf_read_old_trailer(pdf_document *xref, char *buf, int cap) { int len; char *s; @@ -119,7 +119,7 @@ pdf_read_old_trailer(pdf_xref *xref, char *buf, int cap) } static void -pdf_read_new_trailer(pdf_xref *xref, char *buf, int cap) +pdf_read_new_trailer(pdf_document *xref, char *buf, int cap) { fz_try(xref->ctx) { @@ -132,7 +132,7 @@ pdf_read_new_trailer(pdf_xref *xref, char *buf, int cap) } static void -pdf_read_trailer(pdf_xref *xref, char *buf, int cap) +pdf_read_trailer(pdf_document *xref, char *buf, int cap) { int c; @@ -162,7 +162,7 @@ pdf_read_trailer(pdf_xref *xref, char *buf, int cap) */ void -pdf_resize_xref(pdf_xref *xref, int newlen) +pdf_resize_xref(pdf_document *xref, int newlen) { int i; @@ -179,7 +179,7 @@ pdf_resize_xref(pdf_xref *xref, int newlen) } static fz_obj * -pdf_read_old_xref(pdf_xref *xref, char *buf, int cap) +pdf_read_old_xref(pdf_document *xref, char *buf, int cap) { int ofs, len; char *s; @@ -260,7 +260,7 @@ pdf_read_old_xref(pdf_xref *xref, char *buf, int cap) } static void -pdf_read_new_xref_section(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, int w1, int w2) +pdf_read_new_xref_section(pdf_document *xref, fz_stream *stm, int i0, int i1, int w0, int w1, int w2) { int i, n; @@ -294,7 +294,7 @@ pdf_read_new_xref_section(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0 } static fz_obj * -pdf_read_new_xref(pdf_xref *xref, char *buf, int cap) +pdf_read_new_xref(pdf_document *xref, char *buf, int cap) { fz_stream *stm = NULL; fz_obj *trailer = NULL; @@ -373,7 +373,7 @@ pdf_read_new_xref(pdf_xref *xref, char *buf, int cap) } static fz_obj * -pdf_read_xref(pdf_xref *xref, int ofs, char *buf, int cap) +pdf_read_xref(pdf_document *xref, int ofs, char *buf, int cap) { int c; fz_context *ctx = xref->ctx; @@ -402,7 +402,7 @@ pdf_read_xref(pdf_xref *xref, int ofs, char *buf, int cap) } static void -pdf_read_xref_sections(pdf_xref *xref, int ofs, char *buf, int cap) +pdf_read_xref_sections(pdf_document *xref, int ofs, char *buf, int cap) { fz_obj *trailer = NULL; fz_obj *xrefstm = NULL; @@ -436,7 +436,7 @@ pdf_read_xref_sections(pdf_xref *xref, int ofs, char *buf, int cap) */ static void -pdf_load_xref(pdf_xref *xref, char *buf, int bufsize) +pdf_load_xref(pdf_document *xref, char *buf, int bufsize) { fz_obj *size; int i; @@ -473,7 +473,7 @@ pdf_load_xref(pdf_xref *xref, char *buf, int bufsize) } void -pdf_ocg_set_config(pdf_xref *xref, int config) +pdf_ocg_set_config(pdf_document *xref, int config) { int i, j, len, len2; pdf_ocg_descriptor *desc = xref->ocg; @@ -578,7 +578,7 @@ pdf_ocg_set_config(pdf_xref *xref, int config) } static void -pdf_read_ocg(pdf_xref *xref) +pdf_read_ocg(pdf_document *xref) { fz_obj *obj, *ocg; int len, i; @@ -638,10 +638,10 @@ pdf_free_ocg(fz_context *ctx, pdf_ocg_descriptor *desc) * If password is not null, try to decrypt. */ -pdf_xref * -pdf_open_xref_with_stream(fz_stream *file) +pdf_document * +pdf_open_document_with_stream(fz_stream *file) { - pdf_xref *xref; + pdf_document *xref; fz_obj *encrypt, *id; fz_obj *dict = NULL; fz_obj *obj; @@ -655,7 +655,7 @@ pdf_open_xref_with_stream(fz_stream *file) /* install pdf specific callback */ fz_resolve_indirect = pdf_resolve_indirect; - xref = fz_calloc(ctx, 1, sizeof(pdf_xref)); + xref = fz_calloc(ctx, 1, sizeof(pdf_document)); xref->file = fz_keep_stream(file); xref->ctx = ctx; @@ -749,7 +749,7 @@ pdf_open_xref_with_stream(fz_stream *file) { fz_drop_obj(dict); fz_drop_obj(nobj); - pdf_free_xref(xref); + pdf_close_document(xref); fz_throw(ctx, "cannot open document"); } @@ -766,7 +766,7 @@ pdf_open_xref_with_stream(fz_stream *file) } void -pdf_free_xref(pdf_xref *xref) +pdf_close_document(pdf_document *xref) { int i; fz_context *ctx; @@ -817,7 +817,7 @@ pdf_free_xref(pdf_xref *xref) } void -pdf_debug_xref(pdf_xref *xref) +pdf_debug_xref(pdf_document *xref) { int i; printf("xref\n0 %d\n", xref->len); @@ -836,7 +836,7 @@ pdf_debug_xref(pdf_xref *xref) */ static void -pdf_load_obj_stm(pdf_xref *xref, int num, int gen, char *buf, int cap) +pdf_load_obj_stm(pdf_document *xref, int num, int gen, char *buf, int cap) { fz_stream *stm = NULL; fz_obj *objstm = NULL; @@ -925,7 +925,7 @@ pdf_load_obj_stm(pdf_xref *xref, int num, int gen, char *buf, int cap) */ void -pdf_cache_object(pdf_xref *xref, int num, int gen) +pdf_cache_object(pdf_document *xref, int num, int gen) { pdf_xref_entry *x; int rnum, rgen; @@ -991,7 +991,7 @@ pdf_cache_object(pdf_xref *xref, int num, int gen) } fz_obj * -pdf_load_object(pdf_xref *xref, int num, int gen) +pdf_load_object(pdf_document *xref, int num, int gen) { fz_context *ctx = xref->ctx; @@ -1016,13 +1016,13 @@ pdf_resolve_indirect(fz_obj *ref) int num; int gen; fz_context *ctx = NULL; /* Avoid warning for stupid compilers */ - pdf_xref *xref; + pdf_document *xref; while (fz_is_indirect(ref)) { if (--sanity == 0) fz_throw(ctx, "Too many indirections (possible indirection cycle involving %d %d R)", num, gen); - xref = fz_get_indirect_xref(ref); + xref = fz_get_indirect_document(ref); if (!xref) return NULL; ctx = xref->ctx; @@ -1047,7 +1047,7 @@ pdf_resolve_indirect(fz_obj *ref) /* Replace numbered object -- for use by pdfclean and similar tools */ void -pdf_update_object(pdf_xref *xref, int num, int gen, fz_obj *newobj) +pdf_update_object(pdf_document *xref, int num, int gen, fz_obj *newobj) { pdf_xref_entry *x; @@ -1068,20 +1068,20 @@ pdf_update_object(pdf_xref *xref, int num, int gen, fz_obj *newobj) } /* - * Convenience function to open a file then call pdf_open_xref_with_stream. + * Convenience function to open a file then call pdf_open_document_with_stream. */ -pdf_xref * -pdf_open_xref(fz_context *ctx, const char *filename) +pdf_document * +pdf_open_document(fz_context *ctx, const char *filename) { fz_stream *file = NULL; - pdf_xref *xref; + pdf_document *xref; fz_var(file); fz_try(ctx) { file = fz_open_file(ctx, filename); - xref = pdf_open_xref_with_stream(file); + xref = pdf_open_document_with_stream(file); } fz_catch(ctx) { diff --git a/xps/muxps.h b/xps/muxps.h index c708ac60..e7bdfa41 100644 --- a/xps/muxps.h +++ b/xps/muxps.h @@ -251,9 +251,9 @@ struct xps_document_s fz_device *dev; }; -xps_document *xps_open_file(fz_context *ctx, char *filename); -xps_document *xps_open_stream(fz_stream *file); -void xps_free_context(xps_document *doc); +xps_document *xps_open_document(fz_context *ctx, char *filename); +xps_document *xps_open_document_with_stream(fz_stream *file); +void xps_close_document(xps_document *doc); /* * Parsing helper functions diff --git a/xps/xps_zip.c b/xps/xps_zip.c index cc7fbb5e..f38538c3 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -451,7 +451,7 @@ xps_has_part(xps_document *doc, char *partname) } static xps_document * -xps_open_directory(fz_context *ctx, char *directory) +xps_open_document_with_directory(fz_context *ctx, char *directory) { xps_document *doc; @@ -467,7 +467,7 @@ xps_open_directory(fz_context *ctx, char *directory) } fz_catch(ctx) { - xps_free_context(doc); + xps_close_document(doc); fz_rethrow(ctx); } @@ -475,7 +475,7 @@ xps_open_directory(fz_context *ctx, char *directory) } xps_document * -xps_open_stream(fz_stream *file) +xps_open_document_with_stream(fz_stream *file) { fz_context *ctx = file->ctx; xps_document *doc; @@ -493,7 +493,7 @@ xps_open_stream(fz_stream *file) } fz_catch(ctx) { - xps_free_context(doc); + xps_close_document(doc); fz_rethrow(ctx); } @@ -501,7 +501,7 @@ xps_open_stream(fz_stream *file) } xps_document * -xps_open_file(fz_context *ctx, char *filename) +xps_open_document(fz_context *ctx, char *filename) { char buf[2048]; fz_stream *file; @@ -515,7 +515,7 @@ xps_open_file(fz_context *ctx, char *filename) if (!p) p = strstr(buf, "\\_rels\\.rels"); *p = 0; - return xps_open_directory(ctx, buf); + return xps_open_document_with_directory(ctx, buf); } file = fz_open_file(ctx, filename); @@ -524,7 +524,7 @@ xps_open_file(fz_context *ctx, char *filename) fz_try(ctx) { - doc = xps_open_stream(file); + doc = xps_open_document_with_stream(file); } fz_catch(ctx) { @@ -536,7 +536,7 @@ xps_open_file(fz_context *ctx, char *filename) } void -xps_free_context(xps_document *doc) +xps_close_document(xps_document *doc) { xps_font_cache *font, *next; int i; |