From 29537fb4137274d0638eed0aa9439cd281114d05 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Thu, 26 Sep 2013 19:36:12 +0300 Subject: [PATCH v18 5/5] glib: Implement accessors for element attributes Implement inspecting the standard attributes of PopplerStructureElement objects. --- glib/poppler-structure-element.cc | 1256 ++++++++++++++++++++++++++++++++++- glib/poppler-structure-element.h | 247 ++++++- glib/reference/poppler-sections.txt | 84 +++ 3 files changed, 1565 insertions(+), 22 deletions(-) diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc index fe87fc4..49b0b29 100644 --- a/glib/poppler-structure-element.cc +++ b/glib/poppler-structure-element.cc @@ -24,6 +24,7 @@ #include #include #include +#include #endif /* !__GI_SCANNER__ */ #include "poppler.h" @@ -221,6 +222,201 @@ poppler_structure_element_get_kind (PopplerStructureElement *poppler_structure_e return POPPLER_STRUCTURE_ELEMENT_CONTENT; } + +template +struct EnumNameValue { + const gchar *name; + EnumType value; + + static const EnumNameValue values[]; + static const Attribute::Type attribute_type; +}; + +#define ENUM_VALUES(E, A) \ + template<> const Attribute::Type EnumNameValue::attribute_type = Attribute::A; \ + template<> const EnumNameValue EnumNameValue::values[] = + +ENUM_VALUES (PopplerStructurePlacement, Placement) +{ + { "Block", POPPLER_STRUCTURE_PLACEMENT_BLOCK }, + { "Inline", POPPLER_STRUCTURE_PLACEMENT_INLINE }, + { "Before", POPPLER_STRUCTURE_PLACEMENT_BEFORE }, + { "Start", POPPLER_STRUCTURE_PLACEMENT_START }, + { "End", POPPLER_STRUCTURE_PLACEMENT_END }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureWritingMode, WritingMode) +{ + { "LrTb", POPPLER_STRUCTURE_WRITING_MODE_LR_TB }, + { "RlTb", POPPLER_STRUCTURE_WRITING_MODE_RL_TB }, + { "TbRl", POPPLER_STRUCTURE_WRITING_MODE_TB_RL }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureBorderStyle, BorderStyle) +{ + { "None", POPPLER_STRUCTURE_BORDER_STYLE_NONE }, + { "Hidden", POPPLER_STRUCTURE_BORDER_STYLE_HIDDEN }, + { "Dotted", POPPLER_STRUCTURE_BORDER_STYLE_DOTTED }, + { "Dashed", POPPLER_STRUCTURE_BORDER_STYLE_DASHED }, + { "Solid", POPPLER_STRUCTURE_BORDER_STYLE_SOLID }, + { "Double", POPPLER_STRUCTURE_BORDER_STYLE_DOUBLE }, + { "Groove", POPPLER_STRUCTURE_BORDER_STYLE_GROOVE }, + { "Inset", POPPLER_STRUCTURE_BORDER_STYLE_INSET }, + { "Outset", POPPLER_STRUCTURE_BORDER_STYLE_OUTSET }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureTextAlign, TextAlign) +{ + { "Start", POPPLER_STRUCTURE_TEXT_ALIGN_START }, + { "Center", POPPLER_STRUCTURE_TEXT_ALIGN_CENTER }, + { "End", POPPLER_STRUCTURE_TEXT_ALIGN_END }, + { "Justify", POPPLER_STRUCTURE_TEXT_ALIGN_JUSTIFY }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureBlockAlign, BlockAlign) +{ + { "Before", POPPLER_STRUCTURE_BLOCK_ALIGN_BEFORE }, + { "Middle", POPPLER_STRUCTURE_BLOCK_ALIGN_MIDDLE }, + { "After", POPPLER_STRUCTURE_BLOCK_ALIGN_AFTER }, + { "Justify", POPPLER_STRUCTURE_BLOCK_ALIGN_JUSTIFY }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureInlineAlign, InlineAlign) +{ + { "Start", POPPLER_STRUCTURE_INLINE_ALIGN_START }, + { "Center", POPPLER_STRUCTURE_INLINE_ALIGN_CENTER }, + { "End", POPPLER_STRUCTURE_INLINE_ALIGN_END }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureTextDecoration, TextDecorationType) +{ + { "None", POPPLER_STRUCTURE_TEXT_DECORATION_NONE }, + { "Underline", POPPLER_STRUCTURE_TEXT_DECORATION_UNDERLINE }, + { "Overline", POPPLER_STRUCTURE_TEXT_DECORATION_OVERLINE }, + { "LineThrough", POPPLER_STRUCTURE_TEXT_DECORATION_LINETHROUGH }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureRubyAlign, RubyAlign) +{ + { "Start", POPPLER_STRUCTURE_RUBY_ALIGN_START }, + { "Center", POPPLER_STRUCTURE_RUBY_ALIGN_CENTER }, + { "End", POPPLER_STRUCTURE_RUBY_ALIGN_END }, + { "Justify", POPPLER_STRUCTURE_RUBY_ALIGN_JUSTIFY }, + { "Distribute", POPPLER_STRUCTURE_RUBY_ALIGN_DISTRIBUTE }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureRubyPosition, RubyPosition) +{ + { "Before", POPPLER_STRUCTURE_RUBY_POSITION_BEFORE }, + { "After", POPPLER_STRUCTURE_RUBY_POSITION_AFTER }, + { "Warichu", POPPLER_STRUCTURE_RUBY_POSITION_WARICHU }, + { "Inline", POPPLER_STRUCTURE_RUBY_POSITION_INLINE }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureGlyphOrientation, GlyphOrientationVertical) +{ + { "Auto", POPPLER_STRUCTURE_GLYPH_ORIENTATION_AUTO }, + { "90", POPPLER_STRUCTURE_GLYPH_ORIENTATION_90 }, + { "180", POPPLER_STRUCTURE_GLYPH_ORIENTATION_180 }, + { "270", POPPLER_STRUCTURE_GLYPH_ORIENTATION_270 }, + { "360", POPPLER_STRUCTURE_GLYPH_ORIENTATION_0 }, + { "-90", POPPLER_STRUCTURE_GLYPH_ORIENTATION_270 }, + { "-180", POPPLER_STRUCTURE_GLYPH_ORIENTATION_180 }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureListNumbering, ListNumbering) +{ + { "None", POPPLER_STRUCTURE_LIST_NUMBERING_NONE }, + { "Disc", POPPLER_STRUCTURE_LIST_NUMBERING_DISC }, + { "Circle", POPPLER_STRUCTURE_LIST_NUMBERING_CIRCLE }, + { "Square", POPPLER_STRUCTURE_LIST_NUMBERING_SQUARE }, + { "Decimal", POPPLER_STRUCTURE_LIST_NUMBERING_DECIMAL }, + { "UpperRoman", POPPLER_STRUCTURE_LIST_NUMBERING_UPPER_ROMAN }, + { "LowerRoman", POPPLER_STRUCTURE_LIST_NUMBERING_LOWER_ROMAN }, + { "UpperAlpha", POPPLER_STRUCTURE_LIST_NUMBERING_UPPER_ALPHA }, + { "LowerAlpha", POPPLER_STRUCTURE_LIST_NUMBERING_LOWER_ALPHA }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureFormRole, Role) +{ + { "rb", POPPLER_STRUCTURE_FORM_ROLE_RADIO_BUTTON }, + { "cb", POPPLER_STRUCTURE_FORM_ROLE_CHECKBOX }, + { "pb", POPPLER_STRUCTURE_FORM_ROLE_PUSH_BUTTON }, + { "tv", POPPLER_STRUCTURE_FORM_ROLE_TEXT_VALUE }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureFormState, checked) +{ + { "on", POPPLER_STRUCTURE_FORM_STATE_ON }, + { "off", POPPLER_STRUCTURE_FORM_STATE_OFF }, + { "neutral", POPPLER_STRUCTURE_FORM_STATE_NEUTRAL }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureScope, Scope) +{ + { "Row", POPPLER_STRUCTURE_SCOPE_ROW }, + { "Column", POPPLER_STRUCTURE_SCOPE_COLUMN }, + { "Both", POPPLER_STRUCTURE_SCOPE_BOTH }, + { NULL } +}; + +#undef ENUM_VALUES + + +template +static EnumType +name_to_enum (Object *name_value) +{ + /* + * Non-NULL names must always be valid because Poppler + * discards the invalid attributes when parsing them. + */ + g_assert (name_value != NULL); + + for (const EnumNameValue *item = EnumNameValue::values ; item->name; item++) + if (name_value->isName (item->name)) + return item->value; + + g_assert_not_reached (); + return static_cast (-1); +} + + +template +static EnumType +attr_to_enum (PopplerStructureElement *poppler_structure_element) +{ + const Attribute *attr = + poppler_structure_element->elem->findAttribute (EnumNameValue::attribute_type, gTrue); + return name_to_enum ((attr != NULL) + ? attr->getValue () + : Attribute::getDefaultValue (EnumNameValue::attribute_type)); +} + + +static inline Object * +attr_value_or_default (PopplerStructureElement *poppler_structure_element, + Attribute::Type attribute_type) +{ + const Attribute *attr = + poppler_structure_element->elem->findAttribute (attribute_type, gTrue); + return attr ? attr->getValue () : Attribute::getDefaultValue (attribute_type); +} + + /** * poppler_structure_element_get_page: * @poppler_structure_element: A #PopplerStructureElement @@ -911,6 +1107,24 @@ poppler_text_span_is_bold_font (PopplerTextSpan *poppler_text_span) return (poppler_text_span->flags & POPPLER_TEXT_SPAN_BOLD); } +/** + * poppler_structure_element_get_placement: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the placement type of the structure element. + * + * Return value: A #PopplerStructurePlacement value. + * + * Since: 0.26 + */ +PopplerStructurePlacement +poppler_structure_element_get_placement (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + typedef enum { REFERENCE_UNKNOWN, @@ -937,13 +1151,54 @@ _element_reference_type (StructElement *element, XRef *xref) reftype = REFERENCE_ANNOT_LINK; subtype.free(); } - - obj.free(); } return reftype; } +/** + * poppler_structure_element_get_writing_mode: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the writing mode (writing direction) of the content associated + * with a structure element. + * + * Return value: A #PopplerStructureWritingMode value. + * + * Since: 0.26 + */ +PopplerStructureWritingMode +poppler_structure_element_get_writing_mode (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + + +static void +convert_border_style (Object *object, PopplerStructureBorderStyle *values) +{ + g_assert (object != NULL); + g_assert (values != NULL); + + if (object->isArray ()) + { + g_assert (object->arrayGetLength () == 4); + for (guint i = 0; i < 4; i++) + { + Object item; + values[i] = name_to_enum (object->arrayGet (i, &item)); + item.free (); + } + } + else + { + values[0] = values[1] = values[2] = values[3] = + name_to_enum (object); + } +} + AnnotLink * _poppler_structure_element_link_get_annot_link (PopplerStructureElement *element) @@ -990,6 +1245,67 @@ _poppler_structure_element_link_get_annot_link (PopplerStructureElement *element return annot_link; } +static void +convert_double_or_4_doubles (Object *object, gdouble *value) +{ + g_assert (object != NULL); + + if (object->isArray ()) + { + g_assert (object->arrayGetLength () == 4); + for (guint i = 0; i < 4; i++) + { + Object item; + value[i] = object->arrayGet (i, &item)->getNum (); + item.free (); + } + } + else + { + g_assert (object->isNum ()); + value[0] = value[1] = value[2] = value[3] = object->getNum (); + } +} + + +static inline void +convert_doubles_array (Object *object, gdouble **values, guint *n_values) +{ + g_assert (object->isArray ()); + g_assert (n_values != NULL); + g_assert (values != NULL); + + *n_values = object->arrayGetLength (); + gdouble* doubles = g_new (gdouble, *n_values); + + for (guint i = 0; i < *n_values; i++) + { + Object item; + doubles[i] = object->arrayGet (i, &item)->getNum (); + item.free (); + } +} + + +static inline void +convert_color (Object *object, PopplerColor *color) +{ + g_assert (color != NULL); + g_assert (object->isArray () && object->arrayGetLength () != 3); + + Object item; + + color->red = object->arrayGet (0, &item)->getNum () * 65535; + item.free (); + + color->green = object->arrayGet (1, &item)->getNum () * 65535; + item.free (); + + color->blue = object->arrayGet (2, &item)->getNum () * 65535; + item.free (); +} + + /** * poppler_structure_element_link_get_action: * @poppler_structure_element: A #PopplerStructureElement @@ -1018,6 +1334,941 @@ poppler_structure_element_link_get_action (PopplerStructureElement *poppler_stru return result; } +/* + * poppler_structure_element_get_border_style: + * @poppler_structure_element: A #PopplerStructureElement + * @border_styles: (out) (array fixed-size=4) (element-type PopplerStructureBorderStyle): + * An array of four #PopplerStructureBorderStyle elements. + * + * Obtains the border style of a structure element. The result values + * are in before-after-start-end ordering. For example, using Western + * left-to-right writing, that is top-bottom-left-right. + * + * Since: 0.26 + */ +void +poppler_structure_element_get_border_style (PopplerStructureElement *poppler_structure_element, + PopplerStructureBorderStyle *border_styles) +{ + g_return_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element)); + g_return_if_fail (border_styles != NULL); + + convert_border_style (attr_value_or_default (poppler_structure_element, + Attribute::BorderStyle), + border_styles); +} + +/** + * poppler_structure_element_table_get_border_style: + * @poppler_structure_element: A #PopplerStructureElement + * @border_styles: (out) (array fixed-size=4) (element-type PopplerStructureBorderStyle): + * An array of four #PopplerStructureBorderStyle elements. + * + * Obtains the table border style of a structure element. The result values + * are in before-after-start-end ordering. For example, using Western + * left-to-right writing, that is top-bottom-left-right. + * + * Since: 0.26 + */ +void +poppler_structure_element_table_get_border_style (PopplerStructureElement *poppler_structure_element, + PopplerStructureBorderStyle *border_styles) +{ + g_return_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element)); + g_return_if_fail (border_styles != NULL); + + convert_border_style (attr_value_or_default (poppler_structure_element, + Attribute::TBorderStyle), + border_styles); +} + +/** + * poppler_structure_element_get_scope: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the scope (in a table) of a structure element. + * + * Return value: A #PopplerStructureScope value. + * + * Since: 0.26 + */ +PopplerStructureScope +poppler_structure_element_get_scope (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_text_align: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the text alignment mode of the text contained into a + * structure element. + * + * Return value: A #PopplerStructureTextAlign value. + * + * Since: 0.26 + */ +PopplerStructureTextAlign +poppler_structure_element_get_text_align (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_inline_align: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the inline-alignment mode of the structure element. + * + * Return value: A #PopplerStructureInlineAlign value. + * + * Since: 0.26 + */ +PopplerStructureInlineAlign +poppler_structure_element_get_inline_align (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_block_align: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the block-alignment mode of the structure element. + * + * Return value: A #PopplerStructureBlockAlign value. + * + * Since: 0.26 + */ +PopplerStructureBlockAlign +poppler_structure_element_get_block_align (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_text_decoration: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the text decoration type of the text contained in the + * structure element. + * + * Return value: A #PopplerStructureTextDecoration value. + * + * Since: 0.26 + */ +PopplerStructureTextDecoration +poppler_structure_element_get_text_decoration (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_ruby_align: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the alignment for the ruby text contained in a + * structure element. + * + * Return value: A #PopplerStructureRubyAlign value. + * + * Since: 0.26 + */ +PopplerStructureRubyAlign +poppler_structure_element_get_ruby_align (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_ruby_position: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the position for the ruby text contained in a + * structure element. + * + * Return value: A #PopplerStructureRubyPosition value. + * + * Since: 0.26 + */ +PopplerStructureRubyPosition +poppler_structure_element_get_ruby_position (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_glyph_orientation: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the glyph orientation for the text contained in a + * structure element. + * + * Return value: A #PopplerStructureGlyphOrientation value. + * + * Since: 0.26 + */ +PopplerStructureGlyphOrientation +poppler_structure_element_get_glyph_orientation (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_list_numbering: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the list numbering style for list items. + * + * Return value: A #PopplerStructureListNumbering value. + * + * Since: 0.26 + */ +PopplerStructureListNumbering +poppler_structure_element_get_list_numbering (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_form_get_role: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the role of a structure element that is part of a form, or is + * a form field. This hints how the control for the element is intended + * to be rendered. + * + * Return value: A #PopplerStructureFormRole value. + * + * Since: 0.26 + */ +PopplerStructureFormRole +poppler_structure_element_form_get_role (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_checked: + * @poppler_structure_element: A #PopplerStructureElement + * + * For a structure element that is a form field, obtains in which state + * the associated control is expected to be rendered. + * + * Return value: A #PopplerStructureFormState value. + * + * Since: 0.26 + */ +PopplerStructureFormState +poppler_structure_element_form_get_state (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), + EnumNameValue::values[0].value); + return attr_to_enum (poppler_structure_element); +} + +/** + * poppler_structure_element_get_border_thickness: + * @poppler_structure_element: A #PopplerStructureElement + * @border_thicknesses: (out) (array fixed-size=4) (element-type gdouble): + * Array with the four values of border thicknesses. + * + * Obtains the thickness of the border of an element. The result values + * are in before-after-start-end ordering (for the typical Western + * left-to-right writing, that is top-bottom-left-right). + * + * Return value: %TRUE if the border thickness attribute is defined for + * the element, %FALSE otherwise. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_border_thickness (PopplerStructureElement *poppler_structure_element, + gdouble *border_thicknesses) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + g_return_val_if_fail (border_thicknesses != NULL, FALSE); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::BorderThickness); + if (value == NULL) + return FALSE; + + convert_double_or_4_doubles (value, border_thicknesses); + return TRUE; +} + +/** + * poppler_structure_element_get_text_decoration_thickness: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the thickness of the text decoration for the text contained + * in the element. + * + * Return value: Thickness of the text decoration, or %NaN if not defined. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_text_decoration_thickness (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::TextDecorationThickness); + return (value == NULL) ? NAN : value->getNum (); +} + +/** + * poppler_structure_element_get_padding: + * @poppler_structure_element: A #PopplerStructureElement + * @paddings: (out) (array fixed-size=4) (element-type gdouble): + * Padding for the four sides of the element. + * + * Obtains the padding of an element (space around it). The result + * values are in before-after-start-end ordering. For example using + * Western left-to-right writing, that is top-bottom-left-right. + * + * Since: 0.26 + */ +void +poppler_structure_element_get_padding (PopplerStructureElement *poppler_structure_element, + gdouble *paddings) +{ + g_return_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element)); + g_return_if_fail (paddings != NULL); + + convert_double_or_4_doubles (attr_value_or_default (poppler_structure_element, + Attribute::Padding), + paddings); +} + +/** + * poppler_structure_element_table_get_padding: + * @poppler_structure_element: A #PopplerStructureElement + * @paddings: (out) (array fixed-size=4) (element-type gdouble): + * Padding for the four sides of the element. + * + * Obtains the padding of an element (space around it). The result + * values are in before-after-start-end ordering (for the typical + * Western left-to-right writing, that is top-bottom-left-right). + * + * This has to be used instead of poppler_structure_element_get_padding() + * for table elements. + * + * Since: 0.26 + */ +void +poppler_structure_element_table_get_padding (PopplerStructureElement *poppler_structure_element, + gdouble *paddings) +{ + g_return_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element)); + g_return_if_fail (paddings != NULL); + + convert_double_or_4_doubles (attr_value_or_default (poppler_structure_element, + Attribute::TPadding), + paddings); +} + +/** + * poppler_structure_element_table_get_bounding_box: + * @poppler_structure_element: A #PopplerStructureElement + * @bounding_box: (out): A #PopplerRectangle. + * + * Obtains the size of the bounding box of a table element. + * + * Return value: %TRUE if a bounding box is defined for the element, + * %FALSE otherwise. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_table_get_bounding_box (PopplerStructureElement *poppler_structure_element, + PopplerRectangle *bounding_box) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + g_return_val_if_fail (bounding_box != NULL, FALSE); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::BBox); + if (value == NULL) + return FALSE; + + gdouble dimensions[4]; + convert_double_or_4_doubles (value, dimensions); + + bounding_box->x1 = dimensions[0]; + bounding_box->y1 = dimensions[1]; + bounding_box->x2 = dimensions[2]; + bounding_box->y2 = dimensions[3]; + + return TRUE; +} + +/** + * poppler_structure_element_get_space_before: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the amount of empty space before the element. + * + * Return value: A positive value. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_space_before (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::SpaceBefore)->getNum (); +} + +/** + * poppler_structure_element_get_space_after: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the amount of empty space after the element. + * + * Return value: A positive value. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_space_after (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::SpaceAfter)->getNum (); +} + +/** + * poppler_structure_element_get_start_indent: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the amount of indentation at the beginning of the element. + * + * Return value: A numeric value. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_start_indent (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::StartIndent)->getNum (); +} + +/** + * poppler_structure_element_get_end_indent: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the amount of indentation at the end of the element. + * + * Return value: A numeric value. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_end_indent (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::EndIndent)->getNum (); +} + +/** + * poppler_structure_element_get_text_indent: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the amount of indentation of the text contained in the element. + * + * Return value: A numeric value. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_text_indent (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::TextIndent)->getNum (); +} + +/** + * poppler_structure_element_get_baseline_shift: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains how much the text contained in the element should be shifted, + * measuring from the baseline of the glyphs. + * + * Return value: A numeric value. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_baseline_shift (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::BaselineShift)->getNum (); +} + +/** + * poppler_structure_element_get_column_count: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the number of columns used to lay out the content contained + * in the element. + * + * Return value: Number of columns. + * + * Since: 0.26 + */ +guint +poppler_structure_element_get_column_count (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), 0); + return static_cast (attr_value_or_default (poppler_structure_element, + Attribute::ColumnCount)->getInt ()); +} + +/** + * poppler_structure_element_get_color: + * @poppler_structure_element: A #PopplerStructureElement + * @color: (out): A #PopplerColor. + * + * Obtains the color of the content contained in the element. + * + * Return value: %TRUE if a color is defined for the element, + * %FALSE otherwise. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *color) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + g_return_val_if_fail (color != NULL, FALSE); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::Color); + if (value == NULL) + return FALSE; + + convert_color (value, color); + return TRUE; +} + +/** + * poppler_structure_element_get_background_color: + * @poppler_structure_element: A #PopplerStructureElement + * @color: (out): A #PopplerColor. + * + * Obtains the background color of the element. + * + * Return value: %TRUE if a color is defined for the element, + * %FALSE otherwise. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_background_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *color) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + g_return_val_if_fail (color != NULL, FALSE); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::BackgroundColor); + if (value == NULL) + return FALSE; + + convert_color (value, color); + return TRUE; +} + +/** + * poppler_structure_element_get_text_decoration_color: + * @poppler_structure_element: A #PopplerStructureElement + * @color: (out): A #PopplerColor. + * + * Obtains the color of the text decoration for the text contained + * in the element. + * + * Return value: %TRUE if a color is defined for the element, + * %FALSE otherwise. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_text_decoration_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *color) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + g_return_val_if_fail (color != NULL, FALSE); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::TextDecorationColor); + if (value == NULL) + return FALSE; + + convert_color (value, color); + return FALSE; +} + +/** + * poppler_structure_element_get_column_span: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the number of columns the element spans to. + * + * Return value: A positive, non-zero value. + * + * Since: 0.26 + */ +guint +poppler_structure_element_get_column_span (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), 0); + return static_cast (attr_value_or_default (poppler_structure_element, + Attribute::ColSpan)->getInt ()); +} + +/** + * poppler_structure_element_get_row_span: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the number of rows the element spans to. + * + * Return value: A positive, non-zero value. + * + * Since: 0.26 + */ +guint +poppler_structure_element_get_row_span (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), 0); + return static_cast (attr_value_or_default (poppler_structure_element, + Attribute::RowSpan)->getInt ()); +} + +/** + * poppler_structure_element_get_width: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the width of the element. Note that for elements which do + * not specify a width, it has to be calculated, and in this case a + * negative value is returned. + * + * Return value: A positive value if a width is defined, or a negative + * value if the width is to be calculated automatically. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_width (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + Object *value = attr_value_or_default (poppler_structure_element, Attribute::Width); + return value->isName ("Auto") ? -1.0 : value->getNum (); +} + +/** + * poppler_structure_element_get_height: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the height of the element. Note that for elements which do + * not specify a height, it has to be calculated, and in this case a + * negative value is returned. + * + * Return value: A positive value if a width is defined, or a negative + * value if the height is to be calculated automatically. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_height (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + Object *value = attr_value_or_default (poppler_structure_element, Attribute::Height); + return value->isName ("Auto") ? -1.0 : value->getNum (); +} + +/** + * poppler_structure_element_get_line_height: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the line height for the text contained in the element. Note that + * for elements which do* not specify a line height, it has to be calculated, + * and in this case a negative value is returned. + * + * Return value: A positive value if a line height is defined, or a negative + * value if the height is to be calculated automatically. + * + * Since: 0.26 + */ +gdouble +poppler_structure_element_get_line_height (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NAN); + Object *value = attr_value_or_default (poppler_structure_element, Attribute::LineHeight); + return (value->isName ("Normal") || value->isName ("Auto")) ? -1.0 : value->getNum (); +} + +/** + * poppler_structure_element_get_column_gaps: + * @poppler_structure_element: A #PopplerStructureElement + * @n_values: (out): Size of the returned array. + * + * Obtains the size of the gaps in between adjacent columns. Returns an + * array of elements: the first one is the size of the gap in between + * columns 1 and 2, second is the size between columns 2 and 3, and so on. + * + * For elements which use a single column, %NULL is returned and %n_values + * is set to zero. + * + * If the attribute is undefined, %NULL is returned and %n_values is set + * to a non-zero value. + * + * The array with the results is allocated by the function. When it is + * not needed anymore, be sure to call g_free() on it. + * + * Return value: (transfer full) (array length=n_values) (element-type gdouble): + * Array containing the values for the column gaps, or %NULL if the + * array is empty or the attribute is not defined. + * + * Since: 0.26 + */ +gdouble * +poppler_structure_element_get_column_gaps (PopplerStructureElement *poppler_structure_element, + guint *n_values) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + g_return_val_if_fail (n_values != NULL, NULL); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::ColumnGap); + if (value == NULL) + { + *n_values = static_cast (-1); + return NULL; + } + + gdouble *result = NULL; + convert_doubles_array (value, &result, n_values); + return result; +} + +/** + * poppler_structure_element_get_column_widths: + * @poppler_structure_element: A #PopplerStructureElement + * @n_values: (out): Size of the returned array. + * + * Obtains an array with the widths of the columns. + * + * The array with the results is allocated by the function. When it is + * not needed anymore, be sure to call g_free() on it. + * + * Return value: (transfer full) (array length=n_values) (element-type gdouble): + * Array containing widths of the columns, or %NULL if the attribute + * is not defined. + * + * Since: 0.26 + */ +gdouble * +poppler_structure_element_get_column_widths (PopplerStructureElement *poppler_structure_element, + guint *n_values) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + g_return_val_if_fail (n_values != NULL, NULL); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::ColumnWidths); + if (value == NULL) + return NULL; + + gdouble *result = NULL; + convert_doubles_array (value, &result, n_values); + return result; +} + +/** + * poppler_structure_element_get_description: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the textual description of the element. Note that the + * description is for informative purposes, and it is not intended + * to be rendered. For example, assistive technologies may use the + * description field to provide an alternate way of presenting an + * element to the user. + * + * The returned string is allocated by the function. When it is + * not needed anymore, be sure to call g_free() on it. + * + * Return value: (transfer full): A string, or %NULL if the attribute + * is not defined. + * + * Since: 0.26 + */ +gchar * +poppler_structure_element_get_description (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::Desc); + if (value == NULL) + return NULL; + if (value->isString ()) + return _poppler_goo_string_to_utf8 (value->getString ()); + if (value->isName ()) + return g_strdup (value->getName ()); + + g_assert_not_reached (); + return NULL; +} + +/** + * poppler_structure_element_get_summary: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the textual summary of the contents of the element. Note that + * the summary is meant for informative purposes, and it is not intended + * to be rendered. For example, assistive technologies may use the + * description field to provide an alternate way of presenting an element + * to the user, or a document indexer may want to scan it for additional + * keywords. + * + * The returned string is allocated by the function. When it is + * not needed anymore, be sure to call g_free() on it. + * + * Return value: (transfer full): A string, or %NULL if the attribute + * is not defined. + * + * Since: 0.26 + */ +gchar * +poppler_structure_element_get_summary (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::Summary); + if (value == NULL) + return NULL; + if (value->isString ()) + return _poppler_goo_string_to_utf8 (value->getString ()); + if (value->isName ()) + return g_strdup (value->getName ()); + + g_assert_not_reached (); + return NULL; +} + +/** + * poppler_structure_element_get_border_color: + * @poppler_structure_element: A #PopplerStructureElement + * @colors: (out) (array fixed-size=4) (element-type PopplerColor): An array + * of four #PopplerColor. + * + * Obtains the color of border around the element. The result values + * are in before-after-start-end ordering (for the typical Western + * left-to-right writing, that is top-bottom-left-right). + * + * Return value: %TRUE if a color is defined for the element, + * %FALSE otherwise. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_border_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *colors) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + g_return_val_if_fail (colors != NULL, FALSE); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::BorderColor); + if (value == NULL) + return FALSE; + + g_assert (value->isArray ()); + if (value->arrayGetLength () == 4) + { + // One color per side. + for (guint i = 0; i < 4; i++) + { + Object item; + convert_color (value->arrayGet (i, &item), &colors[i]); + item.free (); + } + } + else + { + // Same color in all sides. + g_assert (value->arrayGetLength () == 3); + convert_color (value, &colors[0]); + colors[1] = colors[2] = colors[3] = colors[0]; + } + + return TRUE; +} + +/** + * poppler_structure_element_get_headers: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains an array with the names of the column headers. This is only + * useful for table header row elements. + * + * The array with the results is allocated by the function. The number + * of items in the returned array can be obtained with g_strv_length(). + * The returned value must be freed using g_strfreev(). + * + * Return value: (transfer full) (array zero-terminated=1) (element-type gchar*): + * Zero-terminated array of strings with the table header names, + * or %NULL if the attribute is not defined. + * + * Since: 0.26 + */ +gchar ** +poppler_structure_element_get_headers (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + + Object *value = attr_value_or_default (poppler_structure_element, Attribute::Headers); + if (value == NULL) + return NULL; + + g_assert (value->isArray ()); + + const guint n_values = value->arrayGetLength (); + gchar **result = g_new0 (gchar*, n_values + 1); + + for (guint i = 0; i < n_values; i++) + { + Object item; + + if (value->arrayGet (i, &item)->isString ()) + result[i] = _poppler_goo_string_to_utf8 (item.getString ()); + else if (item.isName ()) + result[i] = g_strdup (item.getName ()); + else + g_assert_not_reached (); + + item.free (); + } + + return result; +} + + /** * poppler_text_span_get_color: * @poppler_text_span: a #PopplerTextSpan @@ -1074,7 +2325,6 @@ poppler_text_span_get_font_name (PopplerTextSpan *poppler_text_span) return poppler_text_span->font_name; } - /** * poppler_structure_element_get_text_spans: * @poppler_structure_element: A #PopplerStructureElement diff --git a/glib/poppler-structure-element.h b/glib/poppler-structure-element.h index cb96d51..8a9c461 100644 --- a/glib/poppler-structure-element.h +++ b/glib/poppler-structure-element.h @@ -86,29 +86,238 @@ typedef enum { POPPLER_STRUCTURE_ELEMENT_FORM, } PopplerStructureElementKind; +/** + * PopplerStructurePlacement: + */ +typedef enum { + POPPLER_STRUCTURE_PLACEMENT_BLOCK, + POPPLER_STRUCTURE_PLACEMENT_INLINE, + POPPLER_STRUCTURE_PLACEMENT_BEFORE, + POPPLER_STRUCTURE_PLACEMENT_START, + POPPLER_STRUCTURE_PLACEMENT_END, +} PopplerStructurePlacement; + +/** + * PopplerStructureWritingMode: + */ +typedef enum { + POPPLER_STRUCTURE_WRITING_MODE_LR_TB, + POPPLER_STRUCTURE_WRITING_MODE_RL_TB, + POPPLER_STRUCTURE_WRITING_MODE_TB_RL, +} PopplerStructureWritingMode; + +/** + * PopplerStructureBorderStyle: + */ +typedef enum { + POPPLER_STRUCTURE_BORDER_STYLE_NONE, + POPPLER_STRUCTURE_BORDER_STYLE_HIDDEN, + POPPLER_STRUCTURE_BORDER_STYLE_DOTTED, + POPPLER_STRUCTURE_BORDER_STYLE_DASHED, + POPPLER_STRUCTURE_BORDER_STYLE_SOLID, + POPPLER_STRUCTURE_BORDER_STYLE_DOUBLE, + POPPLER_STRUCTURE_BORDER_STYLE_GROOVE, + POPPLER_STRUCTURE_BORDER_STYLE_INSET, + POPPLER_STRUCTURE_BORDER_STYLE_OUTSET, +} PopplerStructureBorderStyle; + +/** + * PopplerStructureTextAlign: + */ +typedef enum { + POPPLER_STRUCTURE_TEXT_ALIGN_START, + POPPLER_STRUCTURE_TEXT_ALIGN_CENTER, + POPPLER_STRUCTURE_TEXT_ALIGN_END, + POPPLER_STRUCTURE_TEXT_ALIGN_JUSTIFY, +} PopplerStructureTextAlign; + +/** + * PopplerStructureBlockAlign: + */ +typedef enum { + POPPLER_STRUCTURE_BLOCK_ALIGN_BEFORE, + POPPLER_STRUCTURE_BLOCK_ALIGN_MIDDLE, + POPPLER_STRUCTURE_BLOCK_ALIGN_AFTER, + POPPLER_STRUCTURE_BLOCK_ALIGN_JUSTIFY, +} PopplerStructureBlockAlign; + +/** + * PopplerStructureInlineAlign: + */ +typedef enum { + POPPLER_STRUCTURE_INLINE_ALIGN_START, + POPPLER_STRUCTURE_INLINE_ALIGN_CENTER, + POPPLER_STRUCTURE_INLINE_ALIGN_END, +} PopplerStructureInlineAlign; + +/** + * PopplerStructureTextDecoration: + */ +typedef enum { + POPPLER_STRUCTURE_TEXT_DECORATION_NONE, + POPPLER_STRUCTURE_TEXT_DECORATION_UNDERLINE, + POPPLER_STRUCTURE_TEXT_DECORATION_OVERLINE, + POPPLER_STRUCTURE_TEXT_DECORATION_LINETHROUGH, +} PopplerStructureTextDecoration; + +/** + * PopplerStructureRubyAlign: + */ +typedef enum +{ + POPPLER_STRUCTURE_RUBY_ALIGN_START, + POPPLER_STRUCTURE_RUBY_ALIGN_CENTER, + POPPLER_STRUCTURE_RUBY_ALIGN_END, + POPPLER_STRUCTURE_RUBY_ALIGN_JUSTIFY, + POPPLER_STRUCTURE_RUBY_ALIGN_DISTRIBUTE, +} PopplerStructureRubyAlign; + +/** + * PopplerStructureRubyPosition: + */ +typedef enum { + POPPLER_STRUCTURE_RUBY_POSITION_BEFORE, + POPPLER_STRUCTURE_RUBY_POSITION_AFTER, + POPPLER_STRUCTURE_RUBY_POSITION_WARICHU, + POPPLER_STRUCTURE_RUBY_POSITION_INLINE, +} PopplerStructureRubyPosition; + +/** + * PopplerStructureGlyphOrientation: + */ +typedef enum { + POPPLER_STRUCTURE_GLYPH_ORIENTATION_AUTO, + POPPLER_STRUCTURE_GLYPH_ORIENTATION_0 = POPPLER_STRUCTURE_GLYPH_ORIENTATION_AUTO, + POPPLER_STRUCTURE_GLYPH_ORIENTATION_90, + POPPLER_STRUCTURE_GLYPH_ORIENTATION_180, + POPPLER_STRUCTURE_GLYPH_ORIENTATION_270, +} PopplerStructureGlyphOrientation; + +/** + * PopplerStructureListNumbering: + */ +typedef enum { + POPPLER_STRUCTURE_LIST_NUMBERING_NONE, + POPPLER_STRUCTURE_LIST_NUMBERING_DISC, + POPPLER_STRUCTURE_LIST_NUMBERING_CIRCLE, + POPPLER_STRUCTURE_LIST_NUMBERING_SQUARE, + POPPLER_STRUCTURE_LIST_NUMBERING_DECIMAL, + POPPLER_STRUCTURE_LIST_NUMBERING_UPPER_ROMAN, + POPPLER_STRUCTURE_LIST_NUMBERING_LOWER_ROMAN, + POPPLER_STRUCTURE_LIST_NUMBERING_UPPER_ALPHA, + POPPLER_STRUCTURE_LIST_NUMBERING_LOWER_ALPHA, +} PopplerStructureListNumbering; + +/** + * PopplerStructureFormRole: + */ +typedef enum { + POPPLER_STRUCTURE_FORM_ROLE_RADIO_BUTTON, + POPPLER_STRUCTURE_FORM_ROLE_PUSH_BUTTON, + POPPLER_STRUCTURE_FORM_ROLE_TEXT_VALUE, + POPPLER_STRUCTURE_FORM_ROLE_CHECKBOX, +} PopplerStructureFormRole; + +/** + * PopplerStructureFormState: + */ +typedef enum { + POPPLER_STRUCTURE_FORM_STATE_ON, + POPPLER_STRUCTURE_FORM_STATE_OFF, + POPPLER_STRUCTURE_FORM_STATE_NEUTRAL, +} PopplerStructureFormState; + +/** + * PopplerStructureScope: + */ +typedef enum { + POPPLER_STRUCTURE_SCOPE_ROW, + POPPLER_STRUCTURE_SCOPE_COLUMN, + POPPLER_STRUCTURE_SCOPE_BOTH, +} PopplerStructureScope; + typedef struct _PopplerTextSpan PopplerTextSpan; -GType poppler_structure_element_get_type (void) G_GNUC_CONST; -PopplerStructureElementKind poppler_structure_element_get_kind (PopplerStructureElement *poppler_structure_element); -gint poppler_structure_element_get_page (PopplerStructureElement *poppler_structure_element); -gboolean poppler_structure_element_is_content (PopplerStructureElement *poppler_structure_element); -gboolean poppler_structure_element_is_inline (PopplerStructureElement *poppler_structure_element); -gboolean poppler_structure_element_is_block (PopplerStructureElement *poppler_structure_element); -gboolean poppler_structure_element_is_grouping (PopplerStructureElement *poppler_structure_element); -gchar *poppler_structure_element_get_id (PopplerStructureElement *poppler_structure_element); -gchar *poppler_structure_element_get_title (PopplerStructureElement *poppler_structure_element); -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); -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, - guint *n_text_spans); -PopplerFormField *poppler_structure_element_form_get_field (PopplerStructureElement *poppler_structure_element); -PopplerAction *poppler_structure_element_link_get_action (PopplerStructureElement *poppler_structure_element); +GType poppler_structure_element_get_type (void) G_GNUC_CONST; +PopplerStructureElementKind poppler_structure_element_get_kind (PopplerStructureElement *poppler_structure_element); +gint poppler_structure_element_get_page (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_is_content (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_is_inline (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_is_block (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_is_grouping (PopplerStructureElement *poppler_structure_element); +gchar *poppler_structure_element_get_id (PopplerStructureElement *poppler_structure_element); +gchar *poppler_structure_element_get_title (PopplerStructureElement *poppler_structure_element); +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); +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, + guint *n_text_spans); +gchar *poppler_structure_element_get_description (PopplerStructureElement *poppler_structure_element); +gchar *poppler_structure_element_get_summary (PopplerStructureElement *poppler_structure_element); +PopplerStructureScope poppler_structure_element_get_scope (PopplerStructureElement *poppler_structure_element); +PopplerStructurePlacement poppler_structure_element_get_placement (PopplerStructureElement *poppler_structure_element); +PopplerStructureWritingMode poppler_structure_element_get_writing_mode (PopplerStructureElement *poppler_structure_element); +PopplerStructureTextAlign poppler_structure_element_get_text_align (PopplerStructureElement *poppler_structure_element); +PopplerStructureInlineAlign poppler_structure_element_get_inline_align (PopplerStructureElement *poppler_structure_element); +PopplerStructureBlockAlign poppler_structure_element_get_block_align (PopplerStructureElement *poppler_structure_element); +PopplerStructureTextDecoration poppler_structure_element_get_text_decoration (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_text_decoration_thickness + (PopplerStructureElement *poppler_structure_element); +PopplerStructureRubyAlign poppler_structure_element_get_ruby_align (PopplerStructureElement *poppler_structure_element); +PopplerStructureRubyPosition poppler_structure_element_get_ruby_position (PopplerStructureElement *poppler_structure_element); +PopplerStructureGlyphOrientation poppler_structure_element_get_glyph_orientation (PopplerStructureElement *poppler_structure_element); +PopplerStructureListNumbering poppler_structure_element_get_list_numbering (PopplerStructureElement *poppler_structure_element); +void poppler_structure_element_get_border_style (PopplerStructureElement *poppler_structure_element, + PopplerStructureBorderStyle *border_styles); +void poppler_structure_element_get_padding (PopplerStructureElement *poppler_structure_element, + gdouble *paddings); +gboolean poppler_structure_element_get_border_thickness (PopplerStructureElement *poppler_structure_element, + gdouble *border_thicknesses); +gdouble poppler_structure_element_get_space_before (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_space_after (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_start_indent (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_end_indent (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_text_indent (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_baseline_shift (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_get_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *color); +gboolean poppler_structure_element_get_background_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *color); +gboolean poppler_structure_element_get_border_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *colors); +gboolean poppler_structure_element_get_text_decoration_color + (PopplerStructureElement *poppler_structure_element, + PopplerColor *color); +guint poppler_structure_element_get_column_count (PopplerStructureElement *poppler_structure_element); +guint poppler_structure_element_get_column_span (PopplerStructureElement *poppler_structure_element); +guint poppler_structure_element_get_row_span (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_width (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_get_width_is_auto (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_height (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_get_height_is_auto (PopplerStructureElement *poppler_structure_element); +gdouble poppler_structure_element_get_line_height (PopplerStructureElement *poppler_structure_element); +gboolean poppler_structure_element_get_line_height_is_auto + (PopplerStructureElement *poppler_structure_element); +gdouble *poppler_structure_element_get_column_gaps (PopplerStructureElement *poppler_structure_element, + guint *n_values); +gdouble *poppler_structure_element_get_column_widths (PopplerStructureElement *poppler_structure_element, + guint *n_values); +gchar **poppler_structure_element_get_headers (PopplerStructureElement *poppler_structure_element); +PopplerStructureFormState poppler_structure_element_form_get_state (PopplerStructureElement *poppler_structure_element); +PopplerStructureFormRole poppler_structure_element_form_get_role (PopplerStructureElement *poppler_structure_element); +PopplerFormField *poppler_structure_element_form_get_field (PopplerStructureElement *poppler_structure_element); +PopplerAction *poppler_structure_element_link_get_action (PopplerStructureElement *poppler_structure_element); +void poppler_structure_element_table_get_padding (PopplerStructureElement *poppler_structure_element, + gdouble *paddings); +gboolean poppler_structure_element_table_get_bounding_box (PopplerStructureElement *poppler_structure_element, + PopplerRectangle *bounding_box); +void poppler_structure_element_table_get_border_style (PopplerStructureElement *poppler_structure_element, + PopplerStructureBorderStyle *border_styles); #define POPPLER_TYPE_STRUCTURE_ELEMENT_ITER (poppler_structure_element_iter_get_type ()) diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index 67e8117..8139b7b 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -591,6 +591,20 @@ poppler_movie_get_type PopplerStructureElement PopplerStructureElementKind PopplerStructureElementIter +PopplerStructurePlacement +PopplerStructureWritingMode +PopplerStructureBorderStyle +PopplerStructureTextAlign +PopplerStructureBlockAlign +PopplerStructureInlineAlign +PopplerStructureTextDecoration +PopplerStructureRubyAlign +PopplerStructureRubyPosition +PopplerStructureGlyphOrientation +PopplerStructureListNumbering +PopplerStructureScope +PopplerStructureFormRole +PopplerStructureFormState PopplerTextSpan poppler_structure_element_iter_new poppler_structure_element_iter_next @@ -612,8 +626,49 @@ poppler_structure_element_get_text poppler_structure_element_get_alt_text poppler_structure_element_get_actual_text poppler_structure_element_get_text_spans +poppler_structure_element_get_placement +poppler_structure_element_get_writing_mode +poppler_structure_element_get_border_style +poppler_structure_element_get_scope +poppler_structure_element_get_text_align +poppler_structure_element_get_inline_align +poppler_structure_element_get_block_align +poppler_structure_element_get_text_decoration +poppler_structure_element_get_ruby_align +poppler_structure_element_get_ruby_position +poppler_structure_element_get_glyph_orientation +poppler_structure_element_get_list_numbering +poppler_structure_element_get_border_thickness +poppler_structure_element_get_text_decoration_thickness +poppler_structure_element_get_padding +poppler_structure_element_get_space_before +poppler_structure_element_get_space_after +poppler_structure_element_get_start_indent +poppler_structure_element_get_end_indent +poppler_structure_element_get_text_indent +poppler_structure_element_get_baseline_shift +poppler_structure_element_get_column_count +poppler_structure_element_get_color +poppler_structure_element_get_background_color +poppler_structure_element_get_text_decoration_color +poppler_structure_element_get_column_span +poppler_structure_element_get_row_span +poppler_structure_element_get_width +poppler_structure_element_get_height +poppler_structure_element_get_line_height +poppler_structure_element_get_column_gaps +poppler_structure_element_get_column_widths +poppler_structure_element_get_description +poppler_structure_element_get_summary +poppler_structure_element_get_border_color +poppler_structure_element_get_headers +poppler_structure_element_form_get_role +poppler_structure_element_form_get_state poppler_structure_element_form_get_field poppler_structure_element_link_get_action +poppler_structure_element_table_get_padding +poppler_structure_element_table_get_border_style +poppler_structure_element_table_get_bounding_box poppler_text_span_copy poppler_text_span_free poppler_text_span_is_fixed_width_font @@ -629,12 +684,41 @@ POPPLER_IS_STRUCTURE_ELEMENT POPPLER_TYPE_STRUCTURE_ELEMENT POPPLER_TYPE_STRUCTURE_ELEMENT_ITER POPPLER_TYPE_STRUCTURE_ELEMENT_KIND +POPPLER_TYPE_STRUCTURE_BLOCK_ALIGN +POPPLER_TYPE_STRUCTURE_BORDER_STYLE +POPPLER_TYPE_STRUCTURE_GLYPH_ORIENTATION +POPPLER_TYPE_STRUCTURE_INLINE_ALIGN +POPPLER_TYPE_STRUCTURE_LIST_NUMBERING +POPPLER_TYPE_STRUCTURE_PLACEMENT +POPPLER_TYPE_STRUCTURE_REFERENCE +POPPLER_TYPE_STRUCTURE_RUBY_ALIGN +POPPLER_TYPE_STRUCTURE_RUBY_POSITION +POPPLER_TYPE_STRUCTURE_SCOPE +POPPLER_TYPE_STRUCTURE_TEXT_ALIGN +POPPLER_TYPE_STRUCTURE_TEXT_DECORATION +POPPLER_TYPE_STRUCTURE_WRITING_MODE +POPPLER_TYPE_STRUCTURE_FORM_STATE +POPPLER_TYPE_STRUCTURE_FORM_ROLE POPPLER_TYPE_TEXT_SPAN poppler_structure_element_get_type poppler_structure_element_kind_get_type poppler_structure_element_iter_get_type +poppler_structure_placement_get_type +poppler_structure_writing_mode_get_type +poppler_structure_border_style_get_type +poppler_structure_text_align_get_type +poppler_structure_block_align_get_type +poppler_structure_inline_align_get_type +poppler_structure_text_decoration_get_type +poppler_structure_ruby_align_get_type +poppler_structure_ruby_position_get_type +poppler_structure_glyph_orientation_get_type +poppler_structure_list_numbering_get_type +poppler_structure_form_state_get_type +poppler_structure_form_role_get_type +poppler_structure_scope_get_type poppler_text_span_get_type -- 1.9.0