summaryrefslogtreecommitdiff
path: root/source/fitz/document.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-04-07 14:27:48 +0200
committerRobin Watts <robin.watts@artifex.com>2015-04-07 13:35:07 +0100
commitb8eb55a488aa9dc6884e01b06e948faf1f83012d (patch)
treeafce0b2a0e4bdc375662d65628988257602da611 /source/fitz/document.c
parent743b839e42dc76906ba0be0ff0b3bcb132ac5922 (diff)
downloadmupdf-b8eb55a488aa9dc6884e01b06e948faf1f83012d.tar.xz
Trigger default layout in fz_document layer.
Trigger the default layout when needed, but only if no manual layout has been done. This avoids doing a pointless double layout (once with default when loading the document, then with the manual layout call with the desired layout options).
Diffstat (limited to 'source/fitz/document.c')
-rw-r--r--source/fitz/document.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/fitz/document.c b/source/fitz/document.c
index 40113469..232aa931 100644
--- a/source/fitz/document.c
+++ b/source/fitz/document.c
@@ -5,6 +5,10 @@ enum
FZ_DOCUMENT_HANDLER_MAX = 10
};
+#define DEFW (450)
+#define DEFH (600)
+#define DEFEM (12)
+
struct fz_document_handler_context_s
{
int refs;
@@ -164,6 +168,16 @@ fz_drop_document(fz_context *ctx, fz_document *doc)
doc->close(ctx, doc);
}
+static void
+fz_ensure_layout(fz_context *ctx, fz_document *doc)
+{
+ if (doc && doc->layout && !doc->did_layout)
+ {
+ doc->layout(ctx, doc, DEFW, DEFH, DEFEM);
+ doc->did_layout = 1;
+ }
+}
+
int
fz_needs_password(fz_context *ctx, fz_document *doc)
{
@@ -192,12 +206,16 @@ void
fz_layout_document(fz_context *ctx, fz_document *doc, float w, float h, float em)
{
if (doc && doc->layout)
+ {
doc->layout(ctx, doc, w, h, em);
+ doc->did_layout = 1;
+ }
}
int
fz_count_pages(fz_context *ctx, fz_document *doc)
{
+ fz_ensure_layout(ctx, doc);
if (doc && doc->count_pages)
return doc->count_pages(ctx, doc);
return 0;
@@ -221,6 +239,7 @@ fz_write_document(fz_context *ctx, fz_document *doc, char *filename, fz_write_op
fz_page *
fz_load_page(fz_context *ctx, fz_document *doc, int number)
{
+ fz_ensure_layout(ctx, doc);
if (doc && doc->load_page)
return doc->load_page(ctx, doc, number);
return NULL;