From d30b11c615f2522ff14d3ef4f87b174f7a7da4ef Mon Sep 17 00:00:00 2001 From: Steven Maude Date: Fri, 21 Jul 2023 09:07:04 +0000 Subject: [PATCH 1/2] Update to poppler 0.76.0 --- vendor/anongit.freedesktop.org/git/poppler/poppler.git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/anongit.freedesktop.org/git/poppler/poppler.git b/vendor/anongit.freedesktop.org/git/poppler/poppler.git index e68916f..e0eb356 160000 --- a/vendor/anongit.freedesktop.org/git/poppler/poppler.git +++ b/vendor/anongit.freedesktop.org/git/poppler/poppler.git @@ -1 +1 @@ -Subproject commit e68916fca85e497d73327625d72fcf8879ed67b2 +Subproject commit e0eb356d85e2b43751af6ea7ccd753833f8f967c From dbda00e7fe38d7f3815288737421146ecbc369d2 Mon Sep 17 00:00:00 2001 From: Steven Maude Date: Mon, 30 Oct 2023 15:44:56 +0000 Subject: [PATCH 2/2] Remove use of `goo/GooList.h` This is no longer available in Poppler 0.76.0. See https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/131 Specifically: * https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/131/diffs#diff-content-86c4368355d8c4026eb454d057770cfb6a5feb2a * https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/131/diffs#c836dd74f32ce64cc94ce19d6ddb0bffb9b8f44d_4534_4551 --- src/main.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 29beb06..2727578 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -161,17 +160,17 @@ static const char *fontTypeNames[] = { void dump_font_info(PDFDoc *doc) { FontInfoScanner scanner(doc, 0); - GooList *fonts = scanner.scan(doc->getNumPages()); + std::vector *fonts = scanner.scan(doc->getNumPages()); if (!fonts) { packer.pack_nil(); return; } - packer.pack_array(fonts->getLength()); + packer.pack_array(fonts->size()); - for (int i = 0; i < fonts->getLength(); ++i) { - auto font = reinterpret_cast(fonts->get(i)); + for (std::size_t i = 0; i < fonts->size(); ++i) { + auto font = reinterpret_cast((*fonts)[i]); packer.pack_map(6); @@ -343,14 +342,14 @@ TextPagePtr page_to_text_page(Page *page) { return TextPagePtr(dev->takeText(), TextPageDecRef); } -int count_glyphs(GooList **lines, int n_lines) { +int count_glyphs(std::vector **lines, int n_lines) { int total_glyphs = 0; for (int i = 0; i < n_lines; i++) { auto *words = lines[i]; - total_glyphs += words->getLength() - 1; // spaces - for (int j = 0; j < words->getLength(); j++) { - auto *x = reinterpret_cast(words->get(j)); + total_glyphs += words->size() - 1; // spaces + for (std::size_t j = 0; j < words->size(); j++) { + auto *x = reinterpret_cast((*words)[j]); auto *word = reinterpret_cast(x->getWord()); total_glyphs += word->getLength(); } @@ -358,14 +357,14 @@ int count_glyphs(GooList **lines, int n_lines) { return total_glyphs; } -void dump_glyphs(GooList **lines, int n_lines) { +void dump_glyphs(std::vector **lines, int n_lines) { // Lines for (int i = 0; i < n_lines; i++) { - GooList *line_words = lines[i]; + std::vector *line_words = lines[i]; // Words - for (int j = 0; j < line_words->getLength(); j++) { - auto word_sel = reinterpret_cast(line_words->get(j)); + for (std::size_t j = 0; j < line_words->size(); j++) { + auto word_sel = reinterpret_cast((*line_words)[j]); TextWord *word = word_sel->getWord(); // Glyphs @@ -382,9 +381,9 @@ void dump_glyphs(GooList **lines, int n_lines) { word->getBBox(&x1, &y1, &x2, &y2); // Spaces - if (j < line_words->getLength() - 1) { + if (j < line_words->size() - 1) { auto word_sel = - reinterpret_cast(line_words->get(j + 1)); + reinterpret_cast((*line_words)[j + 1]); word_sel->getWord()->getBBox(&x3, &y3, &x4, &y4); // space is from one word to other and with the same height as // first word. @@ -409,13 +408,16 @@ void dump_page_glyphs(Page *page) { PDFRectangle whole_page(-inf, -inf, inf, inf); int n_lines; - auto deleter = [&](GooList **lines) { + auto deleter = [&](std::vector **lines) { for (int i = 0; i < n_lines; i++) { - deleteGooList(lines[i]); + for (auto entry : *(lines[i])) { + delete entry; + } + delete lines[i]; } gfree(lines); }; - auto word_list = std::unique_ptr( + auto word_list = std::unique_ptr *, decltype(deleter)>( text->getSelectionWords(&whole_page, selectionStyleGlyph, &n_lines), deleter);