summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-06-13 19:02:12 +0100
committerRobin Watts <robin.watts@artifex.com>2012-06-14 19:15:53 +0100
commit836d6a62162e51e7d7925773064c30ef500ded94 (patch)
tree87fc5e7d94b9ec1ba9538523f1f6c16c3cfa9707 /fitz
parentf5d721764811484be4e98d7cddc5b83ae72e6277 (diff)
downloadmupdf-836d6a62162e51e7d7925773064c30ef500ded94.tar.xz
Add -j flag to mudraw; create simple mujstest scripts automatically.
We add a new fz_bound_annots function (and associated pdf_bound_annots function) that calls a given callback with the page rectangle of the annotations on a given page. This is marked as being a 'temporary' function, so we can remove it/change it in future if required. It seems likely that we'll want to have some sort of 'iterate over annotations' function eventually, and this does the job for now. Add a -j flag to mudraw that outputs a simple mujstest script. For each page with annotations, the script jumps to that page, then for each annotation on the page, it sets some text to be entered, and clicks the annotation. In the case of text fields, this will cause the text to be entered into that text field; in the case of buttons it will execute the button. At the end of each page with annotations, the script is told to snapshot the page. These test scripts are not designed to be full tests, but they do at least provide an easy way for us to generate scripts where every field in our test suite is interacted with.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/doc_document.c7
-rw-r--r--fitz/fitz-internal.h1
-rw-r--r--fitz/fitz.h9
3 files changed, 17 insertions, 0 deletions
diff --git a/fitz/doc_document.c b/fitz/doc_document.c
index b1ca8eac..0699f00f 100644
--- a/fitz/doc_document.c
+++ b/fitz/doc_document.c
@@ -109,6 +109,13 @@ fz_bound_page(fz_document *doc, fz_page *page)
}
void
+fz_bound_annots(fz_document *doc, fz_page *page, void (*callback)(void *arg, fz_rect *), void *arg)
+{
+ if (doc && doc->bound_annots && page && callback)
+ doc->bound_annots(doc, page, callback, arg);
+}
+
+void
fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix transform, fz_cookie *cookie)
{
if (doc && doc->run_page && page)
diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h
index 61ccd2a0..0f413893 100644
--- a/fitz/fitz-internal.h
+++ b/fitz/fitz-internal.h
@@ -1112,6 +1112,7 @@ struct fz_document_s
int (*meta)(fz_document *doc, int key, void *ptr, int size);
fz_interactive *(*interact)(fz_document *doc);
void (*write)(fz_document *doc, char *filename, fz_write_options *opts);
+ void (*bound_annots)(fz_document *doc, fz_page *page, void (*callback)(void *arg, fz_rect *), void *arg);
};
#endif
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 60cddf9a..669ab6e4 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -2161,6 +2161,15 @@ fz_link *fz_load_links(fz_document *doc, fz_page *page);
fz_rect fz_bound_page(fz_document *doc, fz_page *page);
/*
+ fz_bound_annots: Bound the annotations on a page.
+
+ (Temporary function - do not rely on this remaining in future)
+
+ Does not throw exceptions (unless the callback does).
+*/
+void fz_bound_annots(fz_document *doc, fz_page *page, void(*callback)(void *arg, fz_rect *), void *arg);
+
+/*
fz_run_page: Run a page through a device.
page: Page obtained from fz_load_page.