From 4050f2ef1b677954f5eaabef415111d2706cc4d5 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Thu, 26 Sep 2013 19:36:12 +0300 Subject: [PATCH v15 8/9] glib: Implement accessors for element attributes Implement inspecting the standard attributes of PopplerStructureElement objects. --- glib/poppler-structure-element.cc | 2184 +++++++++++++++++++++++++++++++++++ glib/poppler-structure-element.h | 334 ++++++ glib/reference/poppler-sections.txt | 44 + 3 files changed, 2562 insertions(+) diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc index 08ed892..fc52a1d 100644 --- a/glib/poppler-structure-element.cc +++ b/glib/poppler-structure-element.cc @@ -206,6 +206,292 @@ poppler_structure_element_get_kind (PopplerStructureElement *poppler_structure_e } } + +template +struct EnumNameValue { + const gchar *name; + EnumType value; + + static const EnumNameValue values[]; + static const EnumType null = static_cast (-1); +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "LrTb", POPPLER_STRUCTURE_WRITING_MODE_LR_TB }, + { "RlTb", POPPLER_STRUCTURE_WRITING_MODE_RL_TB }, + { "TbRl", POPPLER_STRUCTURE_WRITING_MODE_TB_RL }, + { NULL } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "Start", POPPLER_STRUCTURE_INLINE_ALIGN_START }, + { "Center", POPPLER_STRUCTURE_INLINE_ALIGN_CENTER }, + { "End", POPPLER_STRUCTURE_INLINE_ALIGN_END }, + { NULL } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "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 } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "rb", POPPLER_STRUCTURE_ROLE_RADIO_BUTTON }, + { "cb", POPPLER_STRUCTURE_ROLE_CHECKBOX }, + { "pb", POPPLER_STRUCTURE_ROLE_PUSH_BUTTON }, + { "tv", POPPLER_STRUCTURE_ROLE_TEXT_VALUE }, + { NULL } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "on", POPPLER_STRUCTURE_CHECKED_ON }, + { "off", POPPLER_STRUCTURE_CHECKED_OFF }, + { "neutral", POPPLER_STRUCTURE_CHECKED_NEUTRAL }, + { NULL } +}; + +template<> +const EnumNameValue EnumNameValue::values[] = +{ + { "Row", POPPLER_STRUCTURE_SCOPE_ROW }, + { "Column", POPPLER_STRUCTURE_SCOPE_COLUMN }, + { "Both", POPPLER_STRUCTURE_SCOPE_BOTH }, + { NULL } +}; + +template +static EnumType +name_to_enum (Object *name_value, + EnumType default_value = EnumNameValue::null) +{ + if (!name_value) + return default_value; + + for (const EnumNameValue *item = EnumNameValue::values ; item->name; item++) + if (name_value->isName (item->name)) + return item->value; + + return default_value; +} + + +template +static bool +name_to_enum (Object *name_value, EnumType& result) +{ + return (result = name_to_enum (name_value)) != EnumNameValue::null; +} + + +static GVariant * +make_variant_doubles_array (Object *object) +{ + Object item; + GVariantBuilder builder; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ad")); + + if (object->isNum ()) + g_variant_builder_add (&builder, "d", object->getNum ()); + else if (object->isArray ()) + { + const guint length = object->arrayGetLength (); + for (guint i = 0; i < length; i++) + { + if (object->arrayGet (i, &item)->isNum ()) + { + g_variant_builder_add (&builder, "d", item.getNum ()); + } + else + { + /* Free the resources in-use by the builder */ + g_variant_unref (g_variant_builder_end (&builder)); + return NULL; + } + } + } + + return g_variant_builder_end (&builder); +} + + +static GVariant * +make_variant_strings_array (Object *object) +{ + GVariantBuilder builder; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); + + if (object->isName ()) + g_variant_builder_add (&builder, "s", object->getName ()); + else if (object->isString ()) + { + gchar *utf8_string = _poppler_goo_string_to_utf8 (object->getString ()); + g_variant_builder_add (&builder, "s", utf8_string); + g_free (utf8_string); + } + else if (object->isArray ()) + { + for (int i = 0; i < object->arrayGetLength (); i++) + { + Object item; + if (object->arrayGet (i, &item)->isName ()) + g_variant_builder_add (&builder, "s", object->getName ()); + else if (object->isString ()) + { + gchar *utf8_string = _poppler_goo_string_to_utf8 (object->getString ()); + g_variant_builder_add (&builder, "s", utf8_string); + g_free (utf8_string); + } + else + { + /* Free the resources in-use by the builder */ + g_variant_unref (g_variant_builder_end (&builder)); + return NULL; + } + } + } + + return g_variant_builder_end (&builder); +} + +static inline Object * +attr_value_or_default (PopplerStructureElement *poppler_structure_element, + Attribute::Type attribute_type, + gboolean inherit) +{ + Object *value = Attribute::getDefaultValue (attribute_type); + const Attribute *attr; + + if ((attr = poppler_structure_element->elem->findAttribute (attribute_type, inherit))) + value = attr->getValue (); + + return value; +} + +template +static bool attr_to_enum (PopplerStructureElement *poppler_structure_element, + Attribute::Type attribute_type, + gboolean inherit, + EnumType *result_ptr) +{ + const Attribute *attr = poppler_structure_element->elem->findAttribute (attribute_type, inherit); + + EnumType result = name_to_enum ((attr == NULL) + ? Attribute::getDefaultValue (attribute_type) + : attr->getValue ()); + if (result_ptr != NULL) + *result_ptr = result; + + return (result == EnumNameValue::null); +} + /** * poppler_structure_element_get_page: * @poppler_structure_element: A #PopplerStructureElement @@ -891,6 +1177,1904 @@ poppler_text_span_is_bold_font (PopplerTextSpan *poppler_text_span) } /** + * poppler_structure_element_get_placement: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the placement type of the structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_placement (PopplerStructureElement *poppler_structure_element, + PopplerStructurePlacement *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::Placement, + inherit, + value); +} + +/** + * poppler_structure_element_get_writing_mode: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the writing mode (writing direction) of the content associated + * with a structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_writing_mode (PopplerStructureElement *poppler_structure_element, + PopplerStructureWritingMode *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::WritingMode, + inherit, + value); +} + + +static gboolean +convert_border_style (Object *object, PopplerStructureBorderStyle *value) +{ + if (object == NULL) + return FALSE; + + if (object->isArray () && object->arrayGetLength () == 4) + { + if (value != NULL) + { + Object item; + for (guint i = 0; i < 4; i++) + value[i] = name_to_enum (object->arrayGet (i, &item), + POPPLER_STRUCTURE_BORDER_STYLE_NONE); + } + } + else if (object->isName ()) + { + if (value != NULL) + { + value[0] = value[1] = value[2] = value[3] = + name_to_enum (object, + POPPLER_STRUCTURE_BORDER_STYLE_NONE); + } + } + else + return FALSE; + + return TRUE; +} + +static gboolean +convert_double_or_4_doubles (Object *object, gdouble *value) +{ + if (object == NULL) + return FALSE; + + if (object->isArray () && object->arrayGetLength () == 4) + { + if (value != NULL) + { + Object item; + for (guint i = 0; i < 4; i++) + { + if (object->arrayGet (i, &item)->isNum ()) + value[i] = item.getNum (); + else + value[i] = 0; + } + } + } + else if (object->isNum ()) + { + if (value != NULL) + value[0] = value[1] = value[2] = value[3] = object->getNum (); + } + else + return FALSE; + + return TRUE; +} + +static inline gboolean +convert_double (Object *object, gdouble *value) +{ + if (object == NULL) + return FALSE; + + if (object->isNum ()) + { + if (value != NULL) + *value = object->getNum (); + return TRUE; + } + else + return FALSE; +} + +static inline gboolean +convert_doubles_array (Object *object, gdouble **values, guint *n_values) +{ + if (!object->isArray ()) + return FALSE; + + const guint length = object->arrayGetLength (); + gdouble* doubles = g_new (double, length); + Object item; + + for (guint i = 0; i < length; i++) + { + if (!object->arrayGet (i, &item)->isNum ()) + goto _error; + doubles[i] = item.getNum (); + } + + if (values != NULL) + *values = doubles; + else + g_free (doubles); + + if (n_values != NULL) + *n_values = length; + + return TRUE; + +_error: + g_free (values); + item.free (); + return FALSE; +} + +static inline gboolean +convert_uint (Object *object, guint *value) +{ + if (object == NULL) + return FALSE; + + if (object->isNum () && object->getNum () >= 0) + { + if (value != NULL) + *value = (guint) object->getNum (); + return TRUE; + } + else + return FALSE; +} + +static gboolean +convert_color (Object *object, PopplerColor *color) +{ + if (!object->isArray () || object->arrayGetLength () != 3) + return FALSE; + + Object item; + gdouble r, g, b; + + if (!object->arrayGet (0, &item)->isNum ()) + return FALSE; + r = item.getNum (); + + if (!object->arrayGet (1, &item)->isNum ()) + return FALSE; + g = item.getNum (); + + if (!object->arrayGet (2, &item)->isNum ()) + return FALSE; + b = item.getNum (); + + if (color != NULL) + { + color->red = (guint16) (r * 65535); + color->green = (guint16) (g * 65535); + color->blue = (guint16) (b * 65535); + } + + return TRUE; +} + +static inline gboolean +convert_strings_array (Object *object, gchar ***values, guint *n_values) +{ + if (object == NULL || !object->isArray ()) + return FALSE; + + const guint length = object->arrayGetLength (); + gchar** strings = g_new0 (gchar*, length + 1); + Object item; + + for (guint i = 0; i < length; i++) + { + if (object->arrayGet (i, &item)->isString ()) + strings[i] = _poppler_goo_string_to_utf8 (item.getString ()); + else if (item.isName ()) + strings[i] = g_strdup (item.getName ()); + else + goto _error; + } + + if (values != NULL) + *values = strings; + else + g_free (strings); + + if (n_values != NULL) + *n_values = length; + + return TRUE; + +_error: + for (guint i = 0; i < length && strings[i] != NULL; i++) + g_free (strings[i]); + g_free (strings); + return FALSE; +} + +/** + * poppler_structure_element_get_border_style: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out) (array fixed-size=4): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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). + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_border_style (PopplerStructureElement *poppler_structure_element, + PopplerStructureBorderStyle *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_border_style (attr_value_or_default (poppler_structure_element, + Attribute::BorderStyle, + inherit), + value); +} + +/** + * poppler_structure_element_get_table_border_style: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out) (array fixed-size=4): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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). + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_table_border_style (PopplerStructureElement *poppler_structure_element, + PopplerStructureBorderStyle *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_border_style (attr_value_or_default (poppler_structure_element, + Attribute::TBorderStyle, + inherit), + value); +} + +/** + * poppler_structure_element_get_scope: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the scope (in a table) of a structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_scope (PopplerStructureElement *poppler_structure_element, + PopplerStructureScope *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::Scope, + inherit, + value); +} + +/** + * poppler_structure_element_get_text_align: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the text alignment mode of the text contained into a + * structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_text_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureTextAlign *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::TextAlign, + inherit, + value); +} + +/** + * poppler_structure_element_get_inline_align: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the block-alignment mode of the structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_inline_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureInlineAlign *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::InlineAlign, + inherit, + value); +} + +/** + * poppler_structure_element_get_block_align: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the block-alignment mode of the structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_block_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureBlockAlign *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::BlockAlign, + inherit, + value); +} + +/** + * poppler_structure_element_get_text_decoration: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the text decoration type of the text contained in the + * structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_text_decoration (PopplerStructureElement *poppler_structure_element, + PopplerStructureTextDecoration *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::TextDecorationType, + inherit, + value); +} + +/** + * poppler_structure_element_get_ruby_align: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the alignment for the ruby text contained in a + * structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_ruby_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureRubyAlign *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::RubyAlign, + inherit, + value); +} + +/** + * poppler_structure_element_get_ruby_position: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the position for the ruby text contained in a + * structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_ruby_position (PopplerStructureElement *poppler_structure_element, + PopplerStructureRubyPosition *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::RubyPosition, + inherit, + value); +} + +/** + * poppler_structure_element_get_glyph_orientation: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the glyph orientation for the text contained in a + * structure element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_glyph_orientation (PopplerStructureElement *poppler_structure_element, + PopplerStructureGlyphOrientation *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::GlyphOrientationVertical, + inherit, + value); +} + +/** + * poppler_structure_element_get_list_numbering: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the list numbering style for list items. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_list_numbering (PopplerStructureElement *poppler_structure_element, + PopplerStructureListNumbering *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::ListNumbering, + inherit, + value); +} + +/** + * poppler_structure_element_get_role: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_role (PopplerStructureElement *poppler_structure_element, + PopplerStructureRole *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::Role, + inherit, + value); +} + +/** + * poppler_structure_element_get_checked: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * For a structure element that is a form field, obtains in which state + * the associated control is expected to be rendered. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_checked (PopplerStructureElement *poppler_structure_element, + PopplerStructureChecked *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return attr_to_enum (poppler_structure_element, + Attribute::checked, + inherit, + value); +} + +/** + * poppler_structure_element_get_border_thickness: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out) (array fixed-size=4): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_border_thickness (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double_or_4_doubles (attr_value_or_default (poppler_structure_element, + Attribute::BorderThickness, + inherit), + value); +} + +/** + * poppler_structure_element_get_text_decoration_thickness: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the thickness of the text decoration for the text contained + * in the element.* + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_text_decoration_thickness (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double_or_4_doubles (attr_value_or_default (poppler_structure_element, + Attribute::TextDecorationThickness, + inherit), + value); +} + +/** + * poppler_structure_element_get_padding: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out) (array fixed-size=4): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in 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). + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_padding (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double_or_4_doubles (attr_value_or_default (poppler_structure_element, + Attribute::Padding, + inherit), + value); +} + +/** + * poppler_structure_element_get_table_padding: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out) (array fixed-size=4): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in 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. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_table_padding (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double_or_4_doubles (attr_value_or_default (poppler_structure_element, + Attribute::TPadding, + inherit), + value); +} + +/** + * poppler_structure_element_get_bounding_box: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute, a #PopplerRectangle + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_bounding_box (PopplerStructureElement *poppler_structure_element, + PopplerRectangle *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + + gdouble dimensions[4]; + if (!convert_double_or_4_doubles (attr_value_or_default (poppler_structure_element, + Attribute::BBox, + inherit), + dimensions)) + return FALSE; + + value->x1 = dimensions[0]; + value->y1 = dimensions[1]; + value->x2 = dimensions[2]; + value->y2 = dimensions[2]; + + return TRUE; +} + +/** + * poppler_structure_element_get_space_before: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the amount of empty space before the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_space_before (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::SpaceBefore, + inherit), + value); +} + +/** + * poppler_structure_element_get_space_after: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the amount of empty space after the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_space_after (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::SpaceAfter, + inherit), + value); +} + +/** + * poppler_structure_element_get_start_indent: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the amount of indentation at the beginning of the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_start_indent (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::StartIndent, + inherit), + value); +} + +/** + * poppler_structure_element_get_end_indent: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the amount of indentation at the end of the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_end_indent (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::EndIndent, + inherit), + value); +} + +/** + * poppler_structure_element_get_text_indent: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the amount of indentation of the text contained in the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_text_indent (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::TextIndent, + inherit), + value); +} + +/** + * poppler_structure_element_get_baseline_shift: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains how much the text contained in the element should be shifted, + * measuring from the baseline of the glyphs. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_baseline_shift (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::BaselineShift, + inherit), + value); +} + +/** + * poppler_structure_element_get_column_count: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the number of columns used to lay out the content contained + * in the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_column_count (PopplerStructureElement *poppler_structure_element, + guint *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_uint (attr_value_or_default (poppler_structure_element, + Attribute::ColumnCount, + inherit), + value); +} + +/** + * poppler_structure_element_get_color: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the color of the content contained in the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_color (attr_value_or_default (poppler_structure_element, + Attribute::Color, + inherit), + value); +} + +/** + * poppler_structure_element_get_background_color: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the background color of the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_background_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_color (attr_value_or_default (poppler_structure_element, + Attribute::BackgroundColor, + inherit), + value); +} + +/** + * poppler_structure_element_get_text_decoration_color: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the color of the text decoration for the text contained + * in the element. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_text_decoration_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_color (attr_value_or_default (poppler_structure_element, + Attribute::TextDecorationColor, + inherit), + value); +} + +/** + * poppler_structure_element_get_column_span: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the number of columns the element spans to. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_column_span (PopplerStructureElement *poppler_structure_element, + guint *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_uint (attr_value_or_default (poppler_structure_element, + Attribute::ColSpan, + inherit), + value); +} + +/** + * poppler_structure_element_get_row_span: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the number of rows the element spans to. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_row_span (PopplerStructureElement *poppler_structure_element, + guint *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_uint (attr_value_or_default (poppler_structure_element, + Attribute::RowSpan, + inherit), + value); +} + +/** + * poppler_structure_element_get_width: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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 meaningful value. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_width (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::Width, + inherit), + value); +} + +/** + * poppler_structure_element_get_width_is_auto: + * @poppler_structure_element: A #PopplerStructureElement + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Check whether the width of the element is to be calculated automatically + * depending on its contents. Note that when the width is automatic, + * poppler_structure_element_get_width() will return %FALSE. * + * + * Return value: Whether the width is automatic. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_width_is_auto (PopplerStructureElement *poppler_structure_element, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + Object *object = attr_value_or_default (poppler_structure_element, + Attribute::Width, + inherit); + return object->isName ("Auto"); +} + +/** + * poppler_structure_element_get_height: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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 meaningful value. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_height (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::Height, + inherit), + value); +} + +/** + * poppler_structure_element_get_height_is_auto: + * @poppler_structure_element: A #PopplerStructureElement + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Check whether the height of the element is to be calculated automatically + * depending on its contents. Note that when the height is automatic, + * poppler_structure_element_get_height() will return %FALSE. * + * + * Return value: Whether the height is automatic. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_height_is_auto (PopplerStructureElement *poppler_structure_element, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + Object *object = attr_value_or_default (poppler_structure_element, + Attribute::Height, + inherit); + return object->isName ("Auto"); +} + +/** + * poppler_structure_element_get_line_height: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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 meaningful value. + * + * Return value: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_line_height (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_double (attr_value_or_default (poppler_structure_element, + Attribute::LineHeight, + inherit), + value); +} + +/** + * poppler_structure_element_get_line_height_is_auto: + * @poppler_structure_element: A #PopplerStructureElement + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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 return %FALSE. + * + * 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, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + Object *object = attr_value_or_default (poppler_structure_element, + Attribute::LineHeight, + inherit); + return object->isName ("Auto"); +} + +/** + * poppler_structure_element_get_column_gaps: + * @poppler_structure_element: A #PopplerStructureElement + * @values: (out) (array length=n_values): Sizes of the gaps in between + * columns. + * @n_values: (out): Number of items in the returned array. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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, an empty array is returned. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_column_gaps (PopplerStructureElement *poppler_structure_element, + gdouble **values, + guint *n_values, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_doubles_array (attr_value_or_default (poppler_structure_element, + Attribute::ColumnGap, + inherit), + values, + n_values); +} + +/** + * poppler_structure_element_get_column_widths: + * @poppler_structure_element: A #PopplerStructureElement + * @values: (out) (array length=n_values): Widths of the columns. + * @n_values: (out): Number of items in the returned array. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_column_widths (PopplerStructureElement *poppler_structure_element, + gdouble **values, + guint *n_values, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_doubles_array (attr_value_or_default (poppler_structure_element, + Attribute::ColumnWidths, + inherit), + values, + n_values); +} + +/** + * poppler_structure_element_get_description: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * Obtains the textual descriptoin 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_description (PopplerStructureElement *poppler_structure_element, + gchar **value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + Object *object = attr_value_or_default (poppler_structure_element, + Attribute::Desc, + inherit); + if (object == NULL) + return FALSE; + + if (object->isString ()) + *value = _poppler_goo_string_to_utf8 (object->getString ()); + else if (object->isName ()) + *value = g_strdup (object->getName ()); + else + return FALSE; + + return TRUE; +} + + +static inline gboolean +convert_color_or_4_colors (Object *object, PopplerColor *values) +{ + if (object == NULL) + return FALSE; + + if (object->isArray () && object->arrayGetLength () == 4) + { + // One color per side. + PopplerColor colors[4]; + Object item; + for (guint i = 0; i < 4; i++) + if (!convert_color (object->arrayGet (i, &item), &colors[i])) + return FALSE; + + if (values != NULL) + for (guint i = 0; i < 4; i++) + values[i] = colors[i]; + + return TRUE; + } + else if (object->isArray () && object->arrayGetLength () == 3) + { + // Same color in all sides. + PopplerColor color; + if (!convert_color (object, &color)) + return FALSE; + + if (values != NULL) + values[0] = values[1] = values[2] = values[3] = color; + + return TRUE; + } + else + return FALSE; +} + +/** + * poppler_structure_element_get_summary: + * @poppler_structure_element: A #PopplerStructureElement + * @value: (out): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_summary (PopplerStructureElement *poppler_structure_element, + gchar **value, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + Object *object = attr_value_or_default (poppler_structure_element, + Attribute::Summary, + inherit); + if (object == NULL) + return FALSE; + + if (object->isString ()) + *value = _poppler_goo_string_to_utf8 (object->getString ()); + else if (object->isName ()) + *value = g_strdup (object->getName ()); + else + return FALSE; + + return TRUE; +} + +/** + * poppler_structure_element_get_border_color: + * @poppler_structure_element: A #PopplerStructureElement + * @values: (out) (array fixed-size=4): Value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_border_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *values, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_color_or_4_colors (attr_value_or_default (poppler_structure_element, + Attribute::BorderColor, + inherit), + values); +} + +/** + * poppler_structure_element_get_headers: + * @poppler_structure_element: A #PopplerStructureElement + * @values: (out) (array length=n_values): Names of the column headers. + * @n_values: (out): Number of items in the returned array. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * 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: Whether the attribute was looked up successfully. + * + * Since: 0.26 + */ +gboolean +poppler_structure_element_get_headers (PopplerStructureElement *poppler_structure_element, + gchar ***values, + guint *n_values, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), FALSE); + return convert_strings_array (attr_value_or_default (poppler_structure_element, + Attribute::Headers, + inherit), + values, + n_values); +} + + +template +struct convert +{ + private: + static GVariant* make_variant (gdouble value) { return g_variant_new_double (value); } + static GVariant* make_variant (gint32 value) { return g_variant_new_int32 (value); } + static GVariant* make_variant (guint32 value) { return g_variant_new_uint32 (value); } + static GVariant* make_variant (gchar* value) { return g_variant_new_take_string (value); } + + static GVariant* make_variant (const PopplerColor& value) { + return g_variant_new ("(ddd)", + (gdouble) value.red / 65535.0, + (gdouble) value.green / 65535.0, + (gdouble) value.blue / 65535.0); + } + + static GVariant* make_variant (const PopplerRectangle& value) { + return g_variant_new ("(dddd)", + value.x1, + value.y1, + value.x2, + value.y2); + } + + static GVariant* make_maybe_variant (gboolean is_maybe, gdouble value) { + return g_variant_new_maybe (G_VARIANT_TYPE_DOUBLE, + is_maybe ? NULL : make_variant (value)); + } + + public: + static GVariant* to_variant_4_tuple (const char *tuple_spec, + PopplerStructureElement *poppler_structure_element, + gboolean inherit) + { + Type value[4]; + if ((*attr_get) (poppler_structure_element, value, inherit)) + return g_variant_new (tuple_spec, value[0], value[1], value[2], value[3]); + return NULL; + } + + static GVariant* to_variant_4_color_tuple (PopplerStructureElement *poppler_structure_element, + gboolean inherit) + { + PopplerColor colors[4]; + if ((*attr_get) (poppler_structure_element, colors, inherit)) + return g_variant_new ("((ddd)(ddd)(ddd)(ddd))", + colors[0].red, colors[0].green, colors[0].blue, + colors[1].red, colors[1].green, colors[1].blue, + colors[2].red, colors[2].green, colors[2].blue, + colors[3].red, colors[3].green, colors[3].blue); + return NULL; + } + + static GVariant* to_variant (PopplerStructureElement *poppler_structure_element, + gboolean inherit) + { + Type value; + if ((*attr_get) (poppler_structure_element, &value, inherit)) + return make_variant (value); + return NULL; + } + + template + static GVariant* to_maybe_variant (PopplerStructureElement *poppler_structure_element, + gboolean inherit) + { + Type value; + if ((*attr_get) (poppler_structure_element, &value, inherit)) + return make_maybe_variant (FALSE, value); + + if ((*is_maybe) (poppler_structure_element, inherit)) + return make_maybe_variant (TRUE, value); + + return NULL; + } +}; + + +/** + * poppler_structure_element_get_attribute: + * @poppler_structure_element: A #PopplerStructureElement. + * @attribute: A #PopperStructureAttribute value. + * @value (out): A #GValue in which to return the value of the attribute. + * @inherit: Whether to look up for inheritable attribute values in the + * ancestors of the element, if the attribute is not defined in the + * element. + * + * + * Types returned for each attribute + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AttributesReturned type
POPPLER_STRUCTURE_ATTRIBUTE_PLACEMENTA #PopplerStructurePlacement value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_WRITING_MODEA #PopplerStructureWritingMode value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_TEXT_ALIGNA #PopplerStructureTextAlign, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_BLOCK_ALIGNA #PopplerStructureBlockAlign, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_INLINE_ALIGNA #PopplerStructureInlineAlign, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATIONA #PopplerStructureTextDecoration value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_RUBY_ALIGNA #PopplerStructureRubyAlign value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_RUBY_POSITIONA #PopplerStructureRubyPosition value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_GLYPH_ORIENTATIONA #PopplerStructureGlyphOrientation value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_LIST_NUMBERINGA #PopplerStructureListNumbering value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_ROLEA #PopplerStructureRole value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_CHECKEDA #PopplerStructureChecked value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_SCOPEA #PopplerStructureScope value, as a guint32.
POPPLER_STRUCTURE_ATTRIBUTE_DESCRIPTIONA string, as a const gchar*.
POPPLER_STRUCTURE_ATTRIBUTE_SUMMARY
POPPLER_STRUCTURE_ATTRIBUTE_SPACE_BEFORENumber, as a double.
POPPLER_STRUCTURE_ATTRIBUTE_SPACE_AFTER
POPPLER_STRUCTURE_ATTRIBUTE_START_INDENT
POPPLER_STRUCTURE_ATTRIBUTE_END_INDENT
POPPLER_STRUCTURE_ATTRIBUTE_TEXT_INDENT
POPPLER_STRUCTURE_ATTRIBUTE_BASELINE_SHIFT
POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION_THICKNESS
POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_COUNT
POPPLER_STRUCTURE_ATTRIBUTE_ROW_SPAN
POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_SPAN
POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_GAPS + * An array of double numbers. The type of the + * returned #GVariant is ad. + *
POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_WIDTHS
POPPLER_STRUCTURE_ATTRIBUTE_WIDTH + * A maybe-double number. That is, a #GVariant with type + * md. If the number is undefined, the value + * is meant to be calculated automatically. + *
POPPLER_STRUCTURE_ATTRIBUTE_HEIGHT
POPPLER_STRUCTURE_ATTRIBUTE_LINE_HEIGHT
POPPLER_STRUCTURE_ATTRIBUTE_COLOR + * A 3-tuple of doubles, with values in the [0, 1] range, + * in red-green-blue (RGB) order. The type of the returned #GVariant is + * (ddd). + *
POPPLER_STRUCTURE_ATTRIBUTE_BACKGROUND_COLOR
POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION_COLOR
POPPLER_STRUCTURE_ATTRIBUTE_BORDER_COLORA 4-tuple of 3-tuples. Each one of the tuples is a RGB color, + * being each color component a double in the [0, 1] + * range. The four returned colors are in top-right-bottom-left + * order. The type of the returned #GVariant is + * ((ddd)(ddd)(ddd)(ddd)). + *
POPPLER_STRUCTURE_ATTRIBUTE_BORDER_STYLE + * A 4-tuple of #PopplerStructureBorderStyle values, each one as a + * %guint32, in top-right-bottom-left order. The type of the + * returned #GVariant is (uuuu). + *
POPPLER_STRUCTURE_ATTRIBUTE_TABLE_BORDER_STYLE
POPPLER_STRUCTURE_ATTRIBUTE_BORDER_THICKNESS + * A 4-tuple of #double numbers, in top-right-bottom-left order. + * The type of the returned #GVariant is (dddd). + *
POPPLER_STRUCTURE_ATTRIBUTE_TABLE_PADDING
POPPLER_STRUCTURE_ATTRIBUTE_PADDING
POPPLER_STRUCTURE_ATTRIBUTE_BOUNDING_BOX
POPPLER_STRUCTURE_ATTRIBUTE_HEADERSAn array of strings, each string being a const gchar*. + * The type of the returned #GVariant is as.
+ * + * Return value: (transfer full): A #GVariant, with value varying depending + * on the attribute requested, as specified in the table. If the + * attribute is not defined, NULL is returned. + */ +GVariant * +poppler_structure_element_get_attribute (PopplerStructureElement *poppler_structure_element, + PopplerStructureAttribute attribute, + gboolean inherit) +{ + g_return_val_if_fail (POPPLER_IS_STRUCTURE_ELEMENT (poppler_structure_element), NULL); + g_return_val_if_fail (attribute != POPPLER_STRUCTURE_ATTRIBUTE_UNKNOWN, NULL); + g_return_val_if_fail (attribute != POPPLER_STRUCTURE_ATTRIBUTE_USER_PROPERTY, NULL); + + switch (attribute) + { + case POPPLER_STRUCTURE_ATTRIBUTE_PLACEMENT: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_WRITING_MODE: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_BACKGROUND_COLOR: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_BORDER_COLOR: + return convert + ::to_variant_4_color_tuple (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_BORDER_STYLE: + return convert + ::to_variant_4_tuple ("(iiii)", poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_BORDER_THICKNESS: + return convert + ::to_variant_4_tuple ("(dddd)", poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_COLOR: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_PADDING: + return convert + ::to_variant_4_tuple ("(dddd)", poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_SPACE_BEFORE: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_SPACE_AFTER: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_START_INDENT: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_END_INDENT: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_TEXT_INDENT: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_TEXT_ALIGN: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_BOUNDING_BOX: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_WIDTH: + return convert + ::to_maybe_variant + (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_HEIGHT: + return convert + ::to_maybe_variant + (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_BLOCK_ALIGN: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_INLINE_ALIGN: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_TABLE_BORDER_STYLE: + return convert + ::to_variant_4_tuple ("(iiii)", poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_TABLE_PADDING: + return convert + ::to_variant_4_tuple ("(dddd)", poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_BASELINE_SHIFT: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_LINE_HEIGHT: + return convert + ::to_maybe_variant + (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION_COLOR: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION_THICKNESS: + return convert + ::to_variant_4_tuple ("(dddd)", poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_RUBY_ALIGN: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_RUBY_POSITION: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_GLYPH_ORIENTATION: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_COUNT: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_GAPS: + return make_variant_doubles_array (attr_value_or_default (poppler_structure_element, + Attribute::ColumnGap, + inherit)); + + case POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_WIDTHS: + return make_variant_doubles_array (attr_value_or_default (poppler_structure_element, + Attribute::ColumnWidths, + inherit)); + + case POPPLER_STRUCTURE_ATTRIBUTE_LIST_NUMBERING: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_ROLE: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_CHECKED: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_SCOPE: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_DESCRIPTION: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_ROW_SPAN: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_SPAN: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_HEADERS: + return make_variant_strings_array (attr_value_or_default (poppler_structure_element, + Attribute::Headers, + inherit)); + + case POPPLER_STRUCTURE_ATTRIBUTE_SUMMARY: + return convert + ::to_variant (poppler_structure_element, inherit); + + case POPPLER_STRUCTURE_ATTRIBUTE_USER_PROPERTY: + case POPPLER_STRUCTURE_ATTRIBUTE_UNKNOWN: + default: + g_assert_not_reached (); + return NULL; + } +} + +/** * 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 24d5a35..d3b3014 100644 --- a/glib/poppler-structure-element.h +++ b/glib/poppler-structure-element.h @@ -83,6 +83,205 @@ typedef enum { } PopplerStructureElementKind; /** + * PopplerStructureAttribute: + */ +typedef enum { + POPPLER_STRUCTURE_ATTRIBUTE_UNKNOWN, + POPPLER_STRUCTURE_ATTRIBUTE_USER_PROPERTY, + POPPLER_STRUCTURE_ATTRIBUTE_PLACEMENT, + POPPLER_STRUCTURE_ATTRIBUTE_WRITING_MODE, + POPPLER_STRUCTURE_ATTRIBUTE_BACKGROUND_COLOR, + POPPLER_STRUCTURE_ATTRIBUTE_BORDER_COLOR, + POPPLER_STRUCTURE_ATTRIBUTE_BORDER_STYLE, + POPPLER_STRUCTURE_ATTRIBUTE_BORDER_THICKNESS, + POPPLER_STRUCTURE_ATTRIBUTE_COLOR, + POPPLER_STRUCTURE_ATTRIBUTE_PADDING, + POPPLER_STRUCTURE_ATTRIBUTE_SPACE_BEFORE, + POPPLER_STRUCTURE_ATTRIBUTE_SPACE_AFTER, + POPPLER_STRUCTURE_ATTRIBUTE_START_INDENT, + POPPLER_STRUCTURE_ATTRIBUTE_END_INDENT, + POPPLER_STRUCTURE_ATTRIBUTE_TEXT_INDENT, + POPPLER_STRUCTURE_ATTRIBUTE_TEXT_ALIGN, + POPPLER_STRUCTURE_ATTRIBUTE_BOUNDING_BOX, + POPPLER_STRUCTURE_ATTRIBUTE_WIDTH, + POPPLER_STRUCTURE_ATTRIBUTE_HEIGHT, + POPPLER_STRUCTURE_ATTRIBUTE_BLOCK_ALIGN, + POPPLER_STRUCTURE_ATTRIBUTE_INLINE_ALIGN, + POPPLER_STRUCTURE_ATTRIBUTE_TABLE_BORDER_STYLE, + POPPLER_STRUCTURE_ATTRIBUTE_TABLE_PADDING, + POPPLER_STRUCTURE_ATTRIBUTE_BASELINE_SHIFT, + POPPLER_STRUCTURE_ATTRIBUTE_LINE_HEIGHT, + POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION_COLOR, + POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION_THICKNESS, + POPPLER_STRUCTURE_ATTRIBUTE_TEXT_DECORATION, + POPPLER_STRUCTURE_ATTRIBUTE_RUBY_ALIGN, + POPPLER_STRUCTURE_ATTRIBUTE_RUBY_POSITION, + POPPLER_STRUCTURE_ATTRIBUTE_GLYPH_ORIENTATION, + POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_COUNT, + POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_GAPS, + POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_WIDTHS, + POPPLER_STRUCTURE_ATTRIBUTE_LIST_NUMBERING, + POPPLER_STRUCTURE_ATTRIBUTE_ROLE, + POPPLER_STRUCTURE_ATTRIBUTE_CHECKED, + POPPLER_STRUCTURE_ATTRIBUTE_DESCRIPTION, + POPPLER_STRUCTURE_ATTRIBUTE_ROW_SPAN, + POPPLER_STRUCTURE_ATTRIBUTE_COLUMN_SPAN, + POPPLER_STRUCTURE_ATTRIBUTE_HEADERS, + POPPLER_STRUCTURE_ATTRIBUTE_SCOPE, + POPPLER_STRUCTURE_ATTRIBUTE_SUMMARY, +} PopplerStructureAttribute; + +/** + * 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: */ typedef enum { @@ -111,6 +310,10 @@ 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); + +GVariant *poppler_structure_element_get_attribute (PopplerStructureElement *poppler_structure_element, + PopplerStructureAttribute attribute, + gboolean inherit); 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); @@ -140,6 +343,137 @@ 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); + +gboolean poppler_structure_element_get_description (PopplerStructureElement *poppler_structure_element, + gchar **value, + gboolean inherit); +gboolean poppler_structure_element_get_summary (PopplerStructureElement *poppler_structure_element, + gchar **value, + gboolean inherit); +gboolean poppler_structure_element_get_scope (PopplerStructureElement *poppler_structure_element, + PopplerStructureScope *value, + gboolean inherit); +gboolean poppler_structure_element_get_placement (PopplerStructureElement *poppler_structure_element, + PopplerStructurePlacement *value, + gboolean inherit); +gboolean poppler_structure_element_get_writing_mode (PopplerStructureElement *poppler_structure_element, + PopplerStructureWritingMode *value, + gboolean inherit); +gboolean poppler_structure_element_get_text_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureTextAlign *value, + gboolean inherit); +gboolean poppler_structure_element_get_inline_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureInlineAlign *value, + gboolean inherit); +gboolean poppler_structure_element_get_block_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureBlockAlign *value, + gboolean inherit); +gboolean poppler_structure_element_get_text_decoration (PopplerStructureElement *poppler_structure_element, + PopplerStructureTextDecoration *value, + gboolean inherit); +gboolean poppler_structure_element_get_text_decoration_thickness + (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_ruby_align (PopplerStructureElement *poppler_structure_element, + PopplerStructureRubyAlign *value, + gboolean inherit); +gboolean poppler_structure_element_get_ruby_position (PopplerStructureElement *poppler_structure_element, + PopplerStructureRubyPosition *value, + gboolean inherit); +gboolean poppler_structure_element_get_glyph_orientation (PopplerStructureElement *poppler_structure_element, + PopplerStructureGlyphOrientation *value, + gboolean inherit); +gboolean poppler_structure_element_get_list_numbering (PopplerStructureElement *poppler_structure_element, + PopplerStructureListNumbering *value, + gboolean inherit); +gboolean poppler_structure_element_get_role (PopplerStructureElement *poppler_structure_element, + PopplerStructureRole *value, + gboolean inherit); +gboolean poppler_structure_element_get_checked (PopplerStructureElement *poppler_structure_element, + PopplerStructureChecked *value, + gboolean inherit); +gboolean poppler_structure_element_get_padding (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_table_padding (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_bounding_box (PopplerStructureElement *poppler_structure_element, + PopplerRectangle *value, + gboolean inherit); +gboolean poppler_structure_element_get_border_thickness (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_border_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *values, + gboolean inherit); +gboolean poppler_structure_element_get_space_before (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_space_after (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_start_indent (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_end_indent (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_text_indent (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_baseline_shift (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *value, + gboolean inherit); +gboolean poppler_structure_element_get_text_decoration_color + (PopplerStructureElement *poppler_structure_element, + PopplerColor *value, + gboolean inherit); +gboolean poppler_structure_element_get_background_color (PopplerStructureElement *poppler_structure_element, + PopplerColor *value, + gboolean inherit); +gboolean poppler_structure_element_get_column_count (PopplerStructureElement *poppler_structure_element, + guint *value, + gboolean inherit); +gboolean poppler_structure_element_get_column_span (PopplerStructureElement *poppler_structure_element, + guint *value, + gboolean inherit); +gboolean poppler_structure_element_get_row_span (PopplerStructureElement *poppler_structure_element, + guint *value, + gboolean inherit); +gboolean poppler_structure_element_get_width (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_width_is_auto (PopplerStructureElement *poppler_structure_element, + gboolean inherit); +gboolean poppler_structure_element_get_height (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_height_is_auto (PopplerStructureElement *poppler_structure_element, + gboolean inherit); +gboolean poppler_structure_element_get_line_height (PopplerStructureElement *poppler_structure_element, + gdouble *value, + gboolean inherit); +gboolean poppler_structure_element_get_line_height_is_auto + (PopplerStructureElement *poppler_structure_element, + gboolean inherit); +gboolean poppler_structure_element_get_column_gaps (PopplerStructureElement *poppler_structure_element, + gdouble **values, + guint *n_values, + gboolean inherit); +gboolean poppler_structure_element_get_column_widths (PopplerStructureElement *poppler_structure_element, + gdouble **values, + guint *n_values, + gboolean inherit); +gboolean poppler_structure_element_get_headers (PopplerStructureElement *poppler_structure_element, + gchar ***values, + guint *n_values, + gboolean inherit); + G_END_DECLS #endif /* !__POPPLER_STRUCTURE_ELEMENT_H__ */ diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index 719b708..843853b 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -610,6 +610,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_columnt_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 -- 1.8.5.4