From 1af27c4ef6021fc37cfc7d8139652c44b6a03206 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Fri, 21 Feb 2014 15:02:44 +0200 Subject: [PATCH] glib: Handle missing structure element types Element Art (article); RB, RP, RB (Ruby text inner elements); and WT, WP (Warichu inner elements) were not being handled. This adds the corresponding handling in poppler-glib. Also, the "default" case in the switch in poppler_structure_element_get_type() is removed, so the compiler can emit warnings when enum values are not handled. --- glib/poppler-structure-element.cc | 25 +++++++++++++++++++------ glib/poppler-structure-element.h | 9 +++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc index 48de79d..80a70c0 100644 --- a/glib/poppler-structure-element.cc +++ b/glib/poppler-structure-element.cc @@ -119,6 +119,8 @@ poppler_structure_element_get_kind (PopplerStructureElement *poppler_structure_e return POPPLER_STRUCTURE_ELEMENT_DOCUMENT; case StructElement::Part: return POPPLER_STRUCTURE_ELEMENT_PART; + case StructElement::Art: + return POPPLER_STRUCTURE_ELEMENT_ARTICLE; case StructElement::Sect: return POPPLER_STRUCTURE_ELEMENT_SECTION; case StructElement::Div: @@ -139,10 +141,6 @@ poppler_structure_element_get_kind (PopplerStructureElement *poppler_structure_e return POPPLER_STRUCTURE_ELEMENT_LINK; case StructElement::Annot: return POPPLER_STRUCTURE_ELEMENT_ANNOT; - case StructElement::Ruby: - return POPPLER_STRUCTURE_ELEMENT_RUBY; - case StructElement::Warichu: - return POPPLER_STRUCTURE_ELEMENT_WARICHU; case StructElement::BlockQuote: return POPPLER_STRUCTURE_ELEMENT_BLOCKQUOTE; case StructElement::Caption: @@ -195,15 +193,30 @@ poppler_structure_element_get_kind (PopplerStructureElement *poppler_structure_e return POPPLER_STRUCTURE_ELEMENT_TABLE_FOOTER; case StructElement::TBody: return POPPLER_STRUCTURE_ELEMENT_TABLE_BODY; + case StructElement::Ruby: + return POPPLER_STRUCTURE_ELEMENT_RUBY; + case StructElement::RB: + return POPPLER_STRUCTURE_ELEMENT_RUBY_BASE_TEXT; + case StructElement::RT: + return POPPLER_STRUCTURE_ELEMENT_RUBY_ANNOT_TEXT; + case StructElement::RP: + return POPPLER_STRUCTURE_ELEMENT_RUBY_PUNCTUATION; + case StructElement::Warichu: + return POPPLER_STRUCTURE_ELEMENT_WARICHU; + case StructElement::WT: + return POPPLER_STRUCTURE_ELEMENT_WARICHU_TEXT; + case StructElement::WP: + return POPPLER_STRUCTURE_ELEMENT_WARICHU_PUNCTUATION; case StructElement::Figure: return POPPLER_STRUCTURE_ELEMENT_FIGURE; case StructElement::Formula: return POPPLER_STRUCTURE_ELEMENT_FORMULA; case StructElement::Form: return POPPLER_STRUCTURE_ELEMENT_FORM; - default: - g_assert_not_reached (); } + + g_assert_not_reached (); + return POPPLER_STRUCTURE_ELEMENT_UNKNOWN; } diff --git a/glib/poppler-structure-element.h b/glib/poppler-structure-element.h index efb5d29..cafe1bf 100644 --- a/glib/poppler-structure-element.h +++ b/glib/poppler-structure-element.h @@ -49,8 +49,6 @@ typedef enum { POPPLER_STRUCTURE_ELEMENT_CODE, POPPLER_STRUCTURE_ELEMENT_LINK, POPPLER_STRUCTURE_ELEMENT_ANNOT, - POPPLER_STRUCTURE_ELEMENT_RUBY, - POPPLER_STRUCTURE_ELEMENT_WARICHU, POPPLER_STRUCTURE_ELEMENT_BLOCKQUOTE, POPPLER_STRUCTURE_ELEMENT_CAPTION, POPPLER_STRUCTURE_ELEMENT_NONSTRUCT, @@ -77,6 +75,13 @@ typedef enum { POPPLER_STRUCTURE_ELEMENT_TABLE_HEADER, POPPLER_STRUCTURE_ELEMENT_TABLE_FOOTER, POPPLER_STRUCTURE_ELEMENT_TABLE_BODY, + POPPLER_STRUCTURE_ELEMENT_RUBY, + POPPLER_STRUCTURE_ELEMENT_RUBY_BASE_TEXT, + POPPLER_STRUCTURE_ELEMENT_RUBY_ANNOT_TEXT, + POPPLER_STRUCTURE_ELEMENT_RUBY_PUNCTUATION, + POPPLER_STRUCTURE_ELEMENT_WARICHU, + POPPLER_STRUCTURE_ELEMENT_WARICHU_TEXT, + POPPLER_STRUCTURE_ELEMENT_WARICHU_PUNCTUATION, POPPLER_STRUCTURE_ELEMENT_FIGURE, POPPLER_STRUCTURE_ELEMENT_FORMULA, POPPLER_STRUCTURE_ELEMENT_FORM, -- 1.9.0