From 3f9cc6d87b329daa2a3b85ab413aa9cfc64ad80e Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Wed, 5 Mar 2014 11:19:48 +0200 Subject: [PATCH] glib: Use flags argument in poppler_structure_element_get_text() Instead of accepting a boolean argument to enable recursive text extraction, use a flags value. Text extraction may add features in the future (for example, allowing using alternate text as replacement for inline figures), and this will allow to extend the method without introducing ABI or API breakage. --- glib/poppler-structure-element.cc | 12 +++++++----- glib/poppler-structure-element.h | 12 +++++++++++- glib/reference/poppler-sections.txt | 3 +++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc index 60d8b4e..0a4a95c 100644 --- a/glib/poppler-structure-element.cc +++ b/glib/poppler-structure-element.cc @@ -666,8 +666,8 @@ poppler_structure_element_get_actual_text (PopplerStructureElement *poppler_stru /** * poppler_structure_element_get_text: * @poppler_structure_element: A #PopplerStructureElement - * @recursive: If %TRUE, the text of child elements is gathered recursively - * in logical order and returned as part of the result. + * @flags: A #PopplerStructureGetTextFlags value, or %0 to disable + * all the flags. * * Obtains the text enclosed by an element, or the text enclosed by the * elements in the subtree (including the element itself). @@ -677,13 +677,15 @@ poppler_structure_element_get_actual_text (PopplerStructureElement *poppler_stru * Since: 0.26 */ gchar * -poppler_structure_element_get_text (PopplerStructureElement *poppler_structure_element, - gboolean recursive) +poppler_structure_element_get_text (PopplerStructureElement *poppler_structure_element, + PopplerStructureGetTextFlags flags) { g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); g_return_val_if_fail (poppler_structure_element->elem != NULL, NULL); - GooString *string = poppler_structure_element->elem->getText (recursive); + + GooString *string = + poppler_structure_element->elem->getText (flags & POPPLER_STRUCTURE_GET_TEXT_RECURSIVE); gchar *result = string ? _poppler_goo_string_to_utf8 (string) : NULL; delete string; return result; diff --git a/glib/poppler-structure-element.h b/glib/poppler-structure-element.h index ec7d390..fa12ab7 100644 --- a/glib/poppler-structure-element.h +++ b/glib/poppler-structure-element.h @@ -87,6 +87,16 @@ typedef enum { } PopplerStructureElementKind; /** + * PopplerStructureGetTextFlags: + * @POPPLER_STRUCTURE_GET_TEXT_RECURSIVE: For non-leaf, non-content + * elements, recursively obtain the text from all the elements + * enclosed in the subtree. + */ +typedef enum { + POPPLER_STRUCTURE_GET_TEXT_RECURSIVE = (1 << 0), +} PopplerStructureGetTextFlags; + +/** * PopplerStructurePlacement: */ typedef enum { @@ -253,7 +263,7 @@ gchar *poppler_structure_element_get_title gchar *poppler_structure_element_get_abbreviation (PopplerStructureElement *poppler_structure_element); gchar *poppler_structure_element_get_language (PopplerStructureElement *poppler_structure_element); gchar *poppler_structure_element_get_text (PopplerStructureElement *poppler_structure_element, - gboolean recursive); + PopplerStructureGetTextFlags flags); gchar *poppler_structure_element_get_alt_text (PopplerStructureElement *poppler_structure_element); gchar *poppler_structure_element_get_actual_text (PopplerStructureElement *poppler_structure_element); PopplerTextSpan **poppler_structure_element_get_text_spans (PopplerStructureElement *poppler_structure_element, diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index c2726fb..01d92c3 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -592,6 +592,7 @@ poppler_movie_get_type PopplerStructureElement PopplerStructureElementKind PopplerStructureElementIter +PopplerStructureGetTextFlags PopplerStructurePlacement PopplerStructureWritingMode PopplerStructureBorderStyle @@ -685,6 +686,7 @@ POPPLER_IS_STRUCTURE_ELEMENT POPPLER_TYPE_STRUCTURE_ELEMENT POPPLER_TYPE_STRUCTURE_ELEMENT_ITER POPPLER_TYPE_STRUCTURE_ELEMENT_KIND +POPPLER_TYPE_STRUCTURE_GET_TEXT_FLAGS POPPLER_TYPE_STRUCTURE_BLOCK_ALIGN POPPLER_TYPE_STRUCTURE_BORDER_STYLE POPPLER_TYPE_STRUCTURE_GLYPH_ORIENTATION @@ -706,6 +708,7 @@ POPPLER_TYPE_TEXT_SPAN poppler_structure_element_get_type poppler_structure_element_kind_get_type poppler_structure_element_iter_get_type +poppler_structure_get_text_flags_get_type poppler_structure_placement_get_type poppler_structure_writing_mode_get_type poppler_structure_border_style_get_type -- 1.9.0