glib/demo/forms.c | 26 ++++++++++--- glib/poppler-document.cc | 4 +- glib/poppler-form-field.cc | 68 ++++++++++++++++++++++++++++++++++++ glib/poppler-form-field.h | 3 + glib/reference/poppler-sections.txt | 3 + poppler/Form.cc | 64 +++++++++++++++++++++++++++++++++ poppler/Form.h | 8 ++++ 7 files changed, 168 insertions(+), 8 deletions(-)
New commits: commit 9554cbc3cb4fc0cd7ad2295f5d27a18e030c6aee Author: Carlos Garcia Campos <[email protected]> Date: Wed Sep 22 12:54:25 2010 +0200 [glib-demo] Show form field names in forms demo diff --git a/glib/demo/forms.c b/glib/demo/forms.c index e4b1fd8..7836b86 100644 --- a/glib/demo/forms.c +++ b/glib/demo/forms.c @@ -134,6 +134,7 @@ pgd_form_field_view_set_field (GtkWidget *field_view, GtkWidget *alignment; GtkWidget *table; GEnumValue *enum_value; + gchar *text; gint row = 0; alignment = gtk_bin_get_child (GTK_BIN (field_view)); @@ -149,10 +150,26 @@ pgd_form_field_view_set_field (GtkWidget *field_view, if (!field) return; - table = gtk_table_new (10, 2, FALSE); + table = gtk_table_new (13, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); + text = poppler_form_field_get_name (field); + if (text) { + pgd_table_add_property (GTK_TABLE (table), "<b>Name:</b>", text, &row); + g_free (text); + } + text = poppler_form_field_get_partial_name (field); + if (text) { + pgd_table_add_property (GTK_TABLE (table), "<b>Partial Name:</b>", text, &row); + g_free (text); + } + text = poppler_form_field_get_mapping_name (field); + if (text) { + pgd_table_add_property (GTK_TABLE (table), "<b>Mapping Name:</b>", text, &row); + g_free (text); + } + switch (poppler_form_field_get_field_type (field)) { case POPPLER_FORM_FIELD_BUTTON: enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_BUTTON_TYPE), @@ -161,9 +178,7 @@ pgd_form_field_view_set_field (GtkWidget *field_view, pgd_table_add_property (GTK_TABLE (table), "<b>Button State:</b>", poppler_form_field_button_get_state (field) ? "Active" : "Inactive", &row); break; - case POPPLER_FORM_FIELD_TEXT: { - gchar *text; - + case POPPLER_FORM_FIELD_TEXT: enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_TEXT_TYPE), poppler_form_field_text_get_text_type (field)); pgd_table_add_property (GTK_TABLE (table), "<b>Text Type:</b>", enum_value->value_name, &row); @@ -184,10 +199,9 @@ pgd_form_field_view_set_field (GtkWidget *field_view, poppler_form_field_text_is_rich_text (field) ? "Yes" : "No", &row); pgd_table_add_property (GTK_TABLE (table), "<b>Pasword type:</b>", poppler_form_field_text_is_password (field) ? "Yes" : "No", &row); - } break; case POPPLER_FORM_FIELD_CHOICE: { - gchar *text, *item; + gchar *item; gint selected; enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_CHOICE_TYPE), commit 257634b26b682628dba5ee5f94cb0bad030bcb4f Author: Mark Riedesel <[email protected]> Date: Wed Sep 22 12:52:49 2010 +0200 [glib] Add methods to get mapping, partial an fully qualified form field names See bug #28780. diff --git a/glib/poppler-form-field.cc b/glib/poppler-form-field.cc index 33c4b15..9d4ffbb 100644 --- a/glib/poppler-form-field.cc +++ b/glib/poppler-form-field.cc @@ -220,6 +220,74 @@ poppler_form_field_button_set_state (PopplerFormField *field, static_cast<FormWidgetButton*>(field->widget)->setState ((GBool)state); } +/** + * poppler_form_field_get_partial_name: + * @field: a #PopplerFormField + * + * Gets the partial name of @field. + * + * Return value: a new allocated string. It must be freed with g_free() when done. + * + * Since: 0.16 + **/ +gchar* +poppler_form_field_get_partial_name (PopplerFormField *field) +{ + GooString *tmp; + + g_return_val_if_fail (POPPLER_IS_FORM_FIELD (field), NULL); + + tmp = field->widget->getPartialName(); + + return tmp ? _poppler_goo_string_to_utf8 (tmp) : NULL; +} + +/** + * poppler_form_field_get_mapping_name: + * @field: a #PopplerFormField + * + * Gets the mapping name of @field that is used when + * exporting interactive form field data from the document + * + * Return value: a new allocated string. It must be freed with g_free() when done. + * + * Since: 0.16 + **/ +gchar* +poppler_form_field_get_mapping_name (PopplerFormField *field) +{ + GooString *tmp; + + g_return_val_if_fail (POPPLER_IS_FORM_FIELD (field), NULL); + + tmp = field->widget->getMappingName(); + + return tmp ? _poppler_goo_string_to_utf8 (tmp) : NULL; +} + +/** + * poppler_form_field_get_name: + * @field: a #PopplerFormField + * + * Gets the fully qualified name of @field. It's constructed by concatenating + * the partial field names of the field and all of its ancestors. + * + * Return value: a new allocated string. It must be freed with g_free() when done. + * + * Since: 0.16 + **/ +gchar* +poppler_form_field_get_name (PopplerFormField *field) +{ + GooString *tmp; + + g_return_val_if_fail (POPPLER_IS_FORM_FIELD (field), NULL); + + tmp = field->widget->getFullyQualifiedName(); + + return tmp ? _poppler_goo_string_to_utf8 (tmp) : NULL; +} + /* Text Field */ /** * poppler_form_field_text_get_text_type: diff --git a/glib/poppler-form-field.h b/glib/poppler-form-field.h index b8727e9..8ae718e 100644 --- a/glib/poppler-form-field.h +++ b/glib/poppler-form-field.h @@ -64,6 +64,9 @@ PopplerFormFieldType poppler_form_field_get_field_type (PopplerFormFie gint poppler_form_field_get_id (PopplerFormField *field); gdouble poppler_form_field_get_font_size (PopplerFormField *field); gboolean poppler_form_field_is_read_only (PopplerFormField *field); +gchar *poppler_form_field_get_partial_name (PopplerFormField *field); +gchar *poppler_form_field_get_mapping_name (PopplerFormField *field); +gchar *poppler_form_field_get_name (PopplerFormField *field); /* Button Field */ PopplerFormButtonType poppler_form_field_button_get_button_type (PopplerFormField *field); diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index 96eaf75..5bc665d 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -272,6 +272,9 @@ poppler_form_field_get_field_type poppler_form_field_get_id poppler_form_field_is_read_only poppler_form_field_get_font_size +poppler_form_field_get_partial_name +poppler_form_field_get_mapping_name +poppler_form_field_get_name poppler_form_field_button_get_button_type poppler_form_field_button_get_state poppler_form_field_button_set_state commit 6db98abc59c154dcb18d69fc37e44ce804c3ccc9 Author: Mark Riedesel <[email protected]> Date: Wed Sep 22 12:41:16 2010 +0200 Add getLabel method to FormWidget See bug #28780. diff --git a/poppler/Form.cc b/poppler/Form.cc index ae9c509..39b4b61 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -73,6 +73,21 @@ FormWidget::FormWidget(XRef *xrefA, Object *aobj, unsigned num, Ref aref, FormFi type = formUndef; field = fieldA; Dict *dict = obj.getDict(); + fullyQualifiedName = NULL; + + if (dict->lookup("T", &obj1)->isString()) { + partialName = obj1.getString()->copy(); + } else { + partialName = NULL; + } + obj1.free(); + + if(dict->lookup("TM", &obj1)->isString()) { + mappingName = obj1.getString()->copy(); + } else { + mappingName = NULL; + } + obj1.free(); if (!dict->lookup("Rect", &obj1)->isArray()) { error(-1, "Annotation rectangle is wrong type"); @@ -123,6 +138,9 @@ FormWidget::FormWidget(XRef *xrefA, Object *aobj, unsigned num, Ref aref, FormFi FormWidget::~FormWidget() { + delete partialName; + delete mappingName; + delete fullyQualifiedName; obj.free (); } @@ -164,6 +182,52 @@ void FormWidget::updateField (const char *key, Object *value) xref->setModifiedObject(obj1, ref1); } +GooString* FormWidget::getFullyQualifiedName() { + Object obj1, obj2; + Object parent; + GooString *parent_name; + GooString *full_name; + + if (fullyQualifiedName) + return fullyQualifiedName; + + full_name = new GooString(); + + obj.copy(&obj1); + while (obj1.dictLookup("Parent", &parent)->isDict()) { + if (parent.dictLookup("T", &obj2)->isString()) { + parent_name = obj2.getString(); + + if (parent_name->hasUnicodeMarker()) { + parent_name->del(0, 2); // Remove the unicode BOM + full_name->insert(0, "\0.", 2); // 2-byte unicode period + } else { + full_name->insert(0, '.'); // 1-byte ascii period + } + + full_name->insert(0, parent_name); + obj2.free(); + } + obj1.free(); + parent.copy(&obj1); + parent.free(); + } + obj1.free(); + parent.free(); + + if (partialName) { + full_name->append(partialName); + } else { + int len = full_name->getLength(); + // Remove the last period + if (len > 0) + full_name->del(len - 1, 1); + } + + fullyQualifiedName = full_name; + return fullyQualifiedName; +} + FormWidgetButton::FormWidgetButton (XRef *xrefA, Object *aobj, unsigned num, Ref ref, FormField *p) : FormWidget(xrefA, aobj, num, ref, p) { diff --git a/poppler/Form.h b/poppler/Form.h index 35d66af..fea7c67 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -83,6 +83,10 @@ public: void setFontSize(double f) { fontSize = f; } double getFontSize () { return fontSize; } + GooString *getPartialName() const { return partialName; } + GooString *getMappingName() const { return mappingName; } + GooString *getFullyQualifiedName(); + GBool isModified () { return modified; } bool isReadOnly() const; @@ -104,6 +108,10 @@ protected: XRef *xref; GBool defaultsLoaded; GBool modified; + GooString *partialName; // T field + GooString *mappingName; // TM field + GooString *fullyQualifiedName; + //index of this field in the parent's child list unsigned childNum; commit bcdca66fd57439735e0b9aa182ab7cfce29e9ed0 Author: Carlos Garcia Campos <[email protected]> Date: Tue Sep 21 11:49:37 2010 +0200 [glib] Fix minimum value of creation and modification date properties It should be -1 which means there's no date specified diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index 873fddb..6dd60bf 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -1297,7 +1297,7 @@ poppler_document_class_init (PopplerDocumentClass *klass) g_param_spec_int ("creation-date", "Creation Date", "The date and time the document was created", - 0, G_MAXINT, -1, + -1, G_MAXINT, -1, G_PARAM_READABLE)); /** @@ -1310,7 +1310,7 @@ poppler_document_class_init (PopplerDocumentClass *klass) g_param_spec_int ("mod-date", "Modification Date", "The date and time the document was modified", - 0, G_MAXINT, -1, + -1, G_MAXINT, -1, G_PARAM_READABLE)); /** _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
