From bf67596f71774d9b854b0c988f3e1f9e66731717 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 21 Aug 2017 16:54:23 +0200 Subject: Make fz_stext_block and fz_stext_line double linked lists. --- include/mupdf/fitz/structured-text.h | 6 +++--- source/fitz/stext-device.c | 2 ++ 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 -- cgit v1.2.3