summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Perez de Castro <aperez@igalia.com>2014-03-05 11:19:48 +0200
committerCarlos Garcia Campos <carlosgc@gnome.org>2014-03-10 09:55:04 +0100
commitb984a3b5946ebcd736e0583a10eb614cede3388a (patch)
treed6d300d33ee646c16e1dbb82990590955b46c60a
parent94df09de1e07d442895ec1fb5cc23cacd9826552 (diff)
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. https://bugs.freedesktop.org/show_bug.cgi?id=75796
-rw-r--r--glib/poppler-structure-element.cc12
-rw-r--r--glib/poppler-structure-element.h14
-rw-r--r--glib/reference/poppler-sections.txt3
3 files changed, 23 insertions, 6 deletions
diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc
index 7e57a3dd..25edece4 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
+ * %POPPLER_STRUCTURE_GET_TEXT_NONE 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 53bdca05..4596a413 100644
--- a/glib/poppler-structure-element.h
+++ b/glib/poppler-structure-element.h
@@ -87,6 +87,18 @@ typedef enum {
} PopplerStructureElementKind;
/**
+ * PopplerStructureGetTextFlags:
+ * @POPPLER_STRUCTURE_GET_TEXT_NONE: No flags.
+ * @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_NONE = 0,
+ POPPLER_STRUCTURE_GET_TEXT_RECURSIVE = (1 << 0),
+} PopplerStructureGetTextFlags;
+
+/**
* PopplerStructurePlacement:
*/
typedef enum {
@@ -253,7 +265,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 38ded4fc..742065a3 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -590,6 +590,7 @@ poppler_movie_get_type
PopplerStructureElement
PopplerStructureElementKind
PopplerStructureElementIter
+PopplerStructureGetTextFlags
PopplerStructurePlacement
PopplerStructureWritingMode
PopplerStructureBorderStyle
@@ -681,6 +682,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
@@ -702,6 +704,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