summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-08-21 16:54:23 +0200
committerTor Andersson <tor.andersson@artifex.com>2017-08-21 17:20:10 +0200
commitbf67596f71774d9b854b0c988f3e1f9e66731717 (patch)
tree483ca92ebba8486c1128a02dd09f89e125be493d
parentbdbbea6d8868489391c29a9b2e84902e02e5058b (diff)
downloadmupdf-bf67596f71774d9b854b0c988f3e1f9e66731717.tar.xz
Make fz_stext_block and fz_stext_line double linked lists.
-rw-r--r--include/mupdf/fitz/structured-text.h6
-rw-r--r--source/fitz/stext-device.c2
2 files changed, 5 insertions, 3 deletions
diff --git a/include/mupdf/fitz/structured-text.h b/include/mupdf/fitz/structured-text.h
index 4386fd31..cb9dfe5b 100644
--- a/include/mupdf/fitz/structured-text.h
+++ b/include/mupdf/fitz/structured-text.h
@@ -62,7 +62,7 @@ enum
};
/*
- A text block is a list of lines of text, or an image.
+ A text block is a list of lines of text (typically a paragraph), or an image.
*/
struct fz_stext_block_s
{
@@ -72,7 +72,7 @@ struct fz_stext_block_s
struct { fz_stext_line *first_line, *last_line; } t;
struct { fz_matrix transform; fz_image *image; } i;
} u;
- fz_stext_block *next;
+ fz_stext_block *prev, *next;
};
/*
@@ -84,7 +84,7 @@ struct fz_stext_line_s
fz_point dir; /* normalized direction of baseline */
fz_rect bbox;
fz_stext_char *first_char, *last_char;
- fz_stext_line *next;
+ fz_stext_line *prev, *next;
};
/*
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index 2d8a0b29..b4532d8b 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -72,6 +72,7 @@ static fz_stext_block *
add_block_to_page(fz_context *ctx, fz_stext_page *page)
{
fz_stext_block *block = fz_pool_alloc(ctx, page->pool, sizeof *page->first_block);
+ block->prev = page->last_block;
if (!page->first_block)
page->first_block = page->last_block = block;
else
@@ -109,6 +110,7 @@ static fz_stext_line *
add_line_to_block(fz_context *ctx, fz_stext_page *page, fz_stext_block *block, const fz_point *dir, int wmode)
{
fz_stext_line *line = fz_pool_alloc(ctx, page->pool, sizeof *block->u.t.first_line);
+ line->prev = block->u.t.last_line;
if (!block->u.t.first_line)
block->u.t.first_line = block->u.t.last_line = line;
else