From 7f959219214990503ce2534ff34740962032b69f Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Thu, 26 Sep 2013 19:36:12 +0300 Subject: [PATCH v17 5/5] glib: Implement accessors for element attributes Implement inspecting the standard attributes of PopplerStructureElement objects. --- glib/poppler-structure-element.cc | 1278 +++++++++++++++++++++++++++++++++++ glib/poppler-structure-element.h | 204 ++++++ glib/reference/poppler-sections.txt | 87 +++ 3 files changed, 1569 insertions(+) diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc index 11a25db..b819ff3 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,203 @@ 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 (PopplerStructureRole, Role) +{ + { "rb", POPPLER_STRUCTURE_ROLE_RADIO_BUTTON }, + { "cb", POPPLER_STRUCTURE_ROLE_CHECKBOX }, + { "pb", POPPLER_STRUCTURE_ROLE_PUSH_BUTTON }, + { "tv", POPPLER_STRUCTURE_ROLE_TEXT_VALUE }, + { NULL } +}; + +ENUM_VALUES (PopplerStructureChecked, checked) +{ + { "on", POPPLER_STRUCTURE_CHECKED_ON }, + { "off", POPPLER_STRUCTURE_CHECKED_OFF }, + { "neutral", POPPLER_STRUCTURE_CHECKED_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) +{ + g_assert (name_value != NULL); + + /* + * 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 @@ -767,8 +965,15 @@ text_span_poppler_text_span (const TextSpan& span) * poppler_structure_element_get_form_field: * @poppler_structure_element: A #PopplerStructureElement * + * Obtains the #PopplerFormField out of an element of type + * %POPPLER_STRUCTURE_ELEMENT_FORM. The returned value must be freed + * with g_object_unref(). Note that there is one structure element + * per form field. + * * Return value: (transfer full): A #PopplerFormField, or %NULL if * the element is not a %POPPLER_STRUCTURE_ELEMENT_FORM. + * + * Since: 0.26 */ PopplerFormField * poppler_structure_element_get_form_field (PopplerStructureElement *poppler_structure_element) @@ -811,8 +1016,15 @@ poppler_structure_element_get_form_field (PopplerStructureElement *poppler_struc * poppler_structure_element_get_form_field_mapping: * @poppler_structure_element: a #PopplerStructureElement * + * Obtains the #PopplerFormField out of an element of type + * %POPPLER_STRUCTURE_ELEMENT_FORM. The returned value must be freed + * with g_object_unref(). Note that there is one structure element + * per form field. + * * Return value: (transfer full): A #PopplerFormFieldMapping, or %NULL if * the element is not a %POPPLER_STRUCTURE_ELEMENT_FORM + * + * Since: 0.26 */ PopplerFormFieldMapping * poppler_structure_element_get_form_field_mapping (PopplerStructureElement *poppler_structure_element) @@ -925,6 +1137,1072 @@ poppler_text_span_is_bold_font (PopplerTextSpan *poppler_text_span) return (poppler_text_span->flags & POPPLER_TEXT_SPAN_BOLD); } +#define ATTRIBUTE_GETTER_BODY(T) \ + 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_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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructurePlacement); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureWritingMode); +} + + +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); + Object item; + for (guint i = 0; i < 4; i++) + values[i] = name_to_enum (object->arrayGet (i, &item)); + } + else + { + values[0] = values[1] = values[2] = values[3] = + name_to_enum (object); + } +} + +static void +convert_double_or_4_doubles (Object *object, gdouble *value) +{ + g_assert (object != NULL); + + if (object->isArray ()) + { + g_assert (object->arrayGetLength () == 4); + Object item; + for (guint i = 0; i < 4; i++) + value[i] = object->arrayGet (i, &item)->getNum (); + } + 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); + Object item; + + for (guint i = 0; i < *n_values; i++) + doubles[i] = object->arrayGet (i, &item)->getNum (); +} + + +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; + color->green = object->arrayGet (1, &item)->getNum () * 65535; + color->blue = object->arrayGet (2, &item)->getNum () * 65535; +} + + +/** + * poppler_structure_element_get_border_style: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the border style of a structure 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). The returned + * value must be freed with g_free(). +* + * Return value: (transfer full) (array fixed-size=4): An array with the + * border styles of the four sides of the element. + * + * Since: 0.26 + */ +PopplerStructureBorderStyle * +poppler_structure_element_get_border_style (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + + PopplerStructureBorderStyle *result = g_new0 (PopplerStructureBorderStyle, 4); + convert_border_style (attr_value_or_default (poppler_structure_element, Attribute::BorderStyle), result); + return result; + +} + +/** + * poppler_structure_element_get_table_border_style: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the table border style of a structure 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). The returned + * value must be freed with g_free(). + * + * Return value: (transfer full) (array fixed-size=4): An array with the + * border styles of the four sides of the element. + * + * Since: 0.26 + */ +PopplerStructureBorderStyle * +poppler_structure_element_get_table_border_style (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + + PopplerStructureBorderStyle *result = g_new0 (PopplerStructureBorderStyle, 4); + convert_border_style (attr_value_or_default (poppler_structure_element, Attribute::TBorderStyle), result); + return result; +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureScope); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureTextAlign); +} + +/** + * poppler_structure_element_get_inline_align: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the block-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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureInlineAlign); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureBlockAlign); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureTextDecoration); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureRubyAlign); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureRubyPosition); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureGlyphOrientation); +} + +/** + * 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) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureListNumbering); +} + +/** + * poppler_structure_element_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 #PopplerStructureRole value. + * + * Since: 0.26 + */ +PopplerStructureRole +poppler_structure_element_get_role (PopplerStructureElement *poppler_structure_element) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureRole); +} + +/** + * 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 #PopplerStructureChecked value. + * + * Since: 0.26 + */ +PopplerStructureChecked +poppler_structure_element_get_checked (PopplerStructureElement *poppler_structure_element) +{ + ATTRIBUTE_GETTER_BODY (PopplerStructureChecked); +} + +/** + * poppler_structure_element_get_border_thickness: + * @poppler_structure_element: A #PopplerStructureElement + * + * 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: (transfer full) (array fixed-length=4): Thickness of + * the borders, or %NULL if not defined. + * + * Since: 0.26 + */ +gdouble * +poppler_structure_element_get_border_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::BorderThickness); + if (value == NULL) + return NULL; + + gdouble *result = g_new0 (gdouble, 4); + convert_double_or_4_doubles (value, result); + return result; +} + +/** + * 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 + * + * 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). + * + * Return value: (transfer full) (array fixed-size=4): Padding for + * the four sides of the element. + * + * Since: 0.26 + */ +gdouble * +poppler_structure_element_get_padding (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::Padding); + gdouble *result = g_new0 (gdouble, 4); + convert_double_or_4_doubles (value, result); + return result; +} + +/** + * poppler_structure_element_get_table_padding: + * @poppler_structure_element: A #PopplerStructureElement + * + * 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. + * + * Return value: (transfer full) (array fixed-size=4): The paddings for + * the four sides of the table element. + * + * Since: 0.26 + */ +gdouble * +poppler_structure_element_get_table_padding (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::TPadding); + gdouble *result = g_new0 (gdouble, 4); + convert_double_or_4_doubles (value, result); + return result; +} + +/** + * poppler_structure_element_get_bounding_box: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the size of the bounding box of the element. This has to be + * used instead of poppler_structure_element_get_padding() for table + * elements. + * + * Return value: (transfer full): A #PopplerRectangle with the dimensions + * of the bounding box for the element, or %NULL if not defined. + * + * Since: 0.26 + */ +PopplerRectangle * +poppler_structure_element_get_bounding_box (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::BBox); + if (value == NULL) + return NULL; + + gdouble dimensions[4]; + convert_double_or_4_doubles (value, dimensions); + + PopplerRectangle *result = g_new0 (PopplerRectangle, 1); + result->x1 = dimensions[0]; + result->y1 = dimensions[1]; + result->x2 = dimensions[2]; + result->y2 = dimensions[3]; + + return result; +} + +/** + * 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 + * + * Obtains the color of the content contained in the element. + * + * Return value: (transfer full): A #PopplerColor, or %NULL if the + * attribute is not defined. + * + * Since: 0.26 + */ +PopplerColor * +poppler_structure_element_get_color (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::Color); + if (value == NULL) + return NULL; + + PopplerColor *result = g_new0 (PopplerColor, 1); + convert_color (value, result); + return result; +} + +/** + * poppler_structure_element_get_background_color: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the background color of the element. + * + * Return value: (transfer full): A #PopplerColor, or %NULL if the + * attribute is not defined. + * + * Since: 0.26 + */ +PopplerColor * +poppler_structure_element_get_background_color (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::BackgroundColor); + if (value == NULL) + return NULL; + + PopplerColor *result = g_new0 (PopplerColor, 1); + convert_color (value, result); + return result; +} + +/** + * poppler_structure_element_get_text_decoration_color: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the color of the text decoration for the text contained + * in the element. + * + * Return value: (transfer full): A #PopplerColor, or %NULL if the + * attribute is not defined. + * + * Since: 0.26 + */ +PopplerColor * +poppler_structure_element_get_text_decoration_color (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::TextDecorationColor); + if (value == NULL) + return NULL; + + PopplerColor *result = g_new0 (PopplerColor, 1); + convert_color (value, result); + return result; +} + +/** + * 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 you may want to use + * poppler_structure_element_get_width_is_auto() to check whether this + * function will return a value. + * + * Return value: A positive value. + * + * 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); + g_return_val_if_fail (!poppler_structure_element_get_width_is_auto (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::Width)->getNum (); +} + +/** + * poppler_structure_element_get_width_is_auto: + * @poppler_structure_element: A #PopplerStructureElement + * + * Check whether the width of the element is to be calculated automatically + * depending on its contents. Note that when the width is automatic, using + * poppler_structure_element_get_width() will fail. + * + * Return value: Whether the width is automatic. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_width_is_auto (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_value_or_default (poppler_structure_element, Attribute::Width)->isName ("Auto"); +} + +/** + * poppler_structure_element_get_height: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the height of the element. Note that you may want to use + * poppler_structure_element_get_height_is_auto() to check whether this + * function will return a value. + * + * Return value: A positive value. + * + * 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); + g_return_val_if_fail (!poppler_structure_element_get_height_is_auto (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::Height)->getNum (); +} + +/** + * poppler_structure_element_get_height_is_auto: + * @poppler_structure_element: A #PopplerStructureElement + * + * Check whether the height of the element is to be calculated automatically + * depending on its contents. Note that when the height is automatic, using + * poppler_structure_element_get_height() will fail. + * + * Return value: Whether the height is automatic. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_height_is_auto (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_value_or_default (poppler_structure_element, Attribute::Height)->isName ("Auto"); +} + +/** + * poppler_structure_element_get_line_height: + * @poppler_structure_element: A #PopplerStructureElement + * + * Obtains the line height for the text contained in the element. Note + * that you may want to use + * poppler_structure_element_get_line_height_is_auto() to check whether + * this function will return a value. + * + * Return value: Line height. + * + * 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); + g_return_val_if_fail (!poppler_structure_element_get_line_height_is_auto (poppler_structure_element), NAN); + return attr_value_or_default (poppler_structure_element, Attribute::LineHeight)->getNum (); +} + +/** + * poppler_structure_element_get_line_height_is_auto: + * @poppler_structure_element: A #PopplerStructureElement + * + * Check whether the line height for the text contained in the element is + * to be calculated automatically depending on the font size. Note that + * when the line height is automatic, + * poppler_structure_element_get_line_height() will fail. + * + * Return value: Whether the text line height is automatic. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_line_height_is_auto (PopplerStructureElement *poppler_structure_element) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + Object *object = attr_value_or_default (poppler_structure_element, Attribute::LineHeight); + return object->isName ("Auto") || object->isName ("Normal"); +} + +/** + * 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 attriibute 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): 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): 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) + { + *n_values = static_cast (-1); + 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 + * + * 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: (transfer full) (array fixed-size=4): Border colors, + * or %NULL if the attribute is not defined. + * + * Since: 0.26 + */ +PopplerColor * +poppler_structure_element_get_border_color (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::BorderColor); + if (value == NULL) + return NULL; + + g_assert (value->isArray ()); + PopplerColor *result = g_new0 (PopplerColor, 4); + + if (value->arrayGetLength () == 4) + { + // One color per side. + Object item; + for (guint i = 0; i < 4; i++) + convert_color (value->arrayGet (i, &item), &result[i]); + } + else + { + // Same color in all sides. + g_assert (value->arrayGetLength () == 3); + convert_color (value, &result[0]); + result[1] = result[2] = result[3] = result[0]; + } + + return result; +} + +/** + * poppler_structure_element_get_headers: + * @poppler_structure_element: A #PopplerStructureElement + * @n_values: (out): Number of items in the returned array. + * + * 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. When it is + * not needed anymore, be sure to call g_strfreev() on the returned + * value. + * + * Return value: (transfer full) (array zero-terminated=1 length=n_values): + * 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, + 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::Headers); + if (value == NULL) + return NULL; + + g_assert (value->isArray ()); + + *n_values = value->arrayGetLength (); + gchar **result = g_new0 (gchar*, *n_values + 1); + Object item; + + for (guint i = 0; i < *n_values; i++) + { + 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 (); + } + + return result; +} + /** * poppler_structure_element_is_reference: * @poppler_structure_element: A #PopplerStructureElement diff --git a/glib/poppler-structure-element.h b/glib/poppler-structure-element.h index bc6063e..f8c2008 100644 --- a/glib/poppler-structure-element.h +++ b/glib/poppler-structure-element.h @@ -86,6 +86,157 @@ 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; + +/** + * PopplerStructureRole: + */ +typedef enum { + POPPLER_STRUCTURE_ROLE_RADIO_BUTTON, + POPPLER_STRUCTURE_ROLE_PUSH_BUTTON, + POPPLER_STRUCTURE_ROLE_TEXT_VALUE, + POPPLER_STRUCTURE_ROLE_CHECKBOX, +} PopplerStructureRole; + +/** + * PopplerStructureChecked: + */ +typedef enum { + POPPLER_STRUCTURE_CHECKED_ON, + POPPLER_STRUCTURE_CHECKED_OFF, + POPPLER_STRUCTURE_CHECKED_NEUTRAL, +} PopplerStructureChecked; + +/** + * PopplerStructureScope: + */ +typedef enum { + POPPLER_STRUCTURE_SCOPE_ROW, + POPPLER_STRUCTURE_SCOPE_COLUMN, + POPPLER_STRUCTURE_SCOPE_BOTH, +} PopplerStructureScope; + /** * PopplerStructureReference: */ @@ -116,6 +267,7 @@ gchar *poppler_structure_element_get_alt_text 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); + gboolean poppler_structure_element_is_reference (PopplerStructureElement *poppler_structure_element); PopplerStructureReference poppler_structure_element_get_reference_type (PopplerStructureElement *poppler_structure_element); PopplerAction *poppler_structure_element_get_reference_link_action (PopplerStructureElement *poppler_structure_element); @@ -145,6 +297,58 @@ void poppler_text_span_get_color const gchar *poppler_text_span_get_text (PopplerTextSpan *poppler_text_span); const gchar *poppler_text_span_get_font_name (PopplerTextSpan *poppler_text_span); + +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); +PopplerStructureRole poppler_structure_element_get_role (PopplerStructureElement *poppler_structure_element); +PopplerStructureChecked poppler_structure_element_get_checked (PopplerStructureElement *poppler_structure_element); +PopplerStructureBorderStyle *poppler_structure_element_get_border_style (PopplerStructureElement *poppler_structure_element); +PopplerStructureBorderStyle *poppler_structure_element_get_table_border_style (PopplerStructureElement *poppler_structure_element); +gdouble *poppler_structure_element_get_padding (PopplerStructureElement *poppler_structure_element); +gdouble *poppler_structure_element_get_table_padding (PopplerStructureElement *poppler_structure_element); +PopplerRectangle *poppler_structure_element_get_bounding_box (PopplerStructureElement *poppler_structure_element); +gdouble *poppler_structure_element_get_border_thickness (PopplerStructureElement *poppler_structure_element); +PopplerColor *poppler_structure_element_get_border_color (PopplerStructureElement *poppler_structure_element); +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); +PopplerColor *poppler_structure_element_get_color (PopplerStructureElement *poppler_structure_element); +PopplerColor *poppler_structure_element_get_text_decoration_color + (PopplerStructureElement *poppler_structure_element); +PopplerColor *poppler_structure_element_get_background_color (PopplerStructureElement *poppler_structure_element); +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, + guint *n_values); + G_END_DECLS #endif /* !__POPPLER_STRUCTURE_ELEMENT_H__ */ diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index f17633a..31f200f 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -590,6 +590,20 @@ poppler_movie_get_type PopplerStructureElement PopplerStructureElementKind PopplerStructureElementIter +PopplerStructurePlacement +PopplerStructureWritingMode +PopplerStructureBorderStyle +PopplerStructureTextAlign +PopplerStructureBlockAlign +PopplerStructureInlineAlign +PopplerStructureTextDecoration +PopplerStructureRubyAlign +PopplerStructureRubyPosition +PopplerStructureGlyphOrientation +PopplerStructureListNumbering +PopplerStructureRole +PopplerStructureChecked +PopplerStructureScope PopplerTextSpan poppler_structure_element_iter_new poppler_structure_element_iter_next @@ -611,6 +625,50 @@ 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_table_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_role +poppler_structure_element_get_checked +poppler_structure_element_get_border_thickness +poppler_structure_element_get_text_decoration_thickness +poppler_structure_element_get_padding +poppler_structure_element_get_table_padding +poppler_structure_element_get_bounding_box +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_width_is_auto +poppler_structure_element_get_height +poppler_structure_element_get_height_is_auto +poppler_structure_element_get_line_height +poppler_structure_element_get_line_height_is_auto +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_text_span_copy poppler_text_span_free poppler_text_span_is_fixed_width_font @@ -626,11 +684,40 @@ 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_CHECKED +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_ROLE +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_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_role_get_type +poppler_structure_checked_get_type +poppler_structure_scope_get_type poppler_text_span_get_type -- 1.9.0