summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-form.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-07-17 15:05:22 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-08-10 14:09:46 +0200
commit4944aa0734523573e76e26c42f65e8998b8692ed (patch)
tree1c89caef8b2ab9c71f12558211a3eac195ee01cd /source/pdf/pdf-form.c
parent1fbbe664d21be2d8a52b2274f1c39861c17c5cc1 (diff)
downloadmupdf-4944aa0734523573e76e26c42f65e8998b8692ed.tar.xz
Remove functions that implement duplicate functionality.
pdf_get_inheritable also looks in trailer/Root/AcroForm for missing keys, but this behavior is not supported by anything in the specification.
Diffstat (limited to 'source/pdf/pdf-form.c')
-rw-r--r--source/pdf/pdf-form.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index a838b4b8..454d3a6e 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -132,7 +132,7 @@ static void reset_form_field(fz_context *ctx, pdf_document *doc, pdf_obj *field)
case PDF_WIDGET_TYPE_RADIOBUTTON:
case PDF_WIDGET_TYPE_CHECKBOX:
{
- pdf_obj *leafv = pdf_get_inheritable(ctx, doc, field, PDF_NAME(V));
+ pdf_obj *leafv = pdf_dict_get_inheritable(ctx, field, PDF_NAME(V));
if (leafv)
pdf_keep_obj(ctx, leafv);
@@ -974,7 +974,7 @@ void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
char buf[100];
const char *font;
float size, color[3], black;
- const char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, field, PDF_NAME(DA)));
+ const char *da = pdf_to_str_buf(ctx, pdf_dict_get_inheritable(ctx, field, PDF_NAME(DA)));
pdf_parse_default_appearance(ctx, da, &font, &size, color);
@@ -1031,39 +1031,27 @@ int pdf_text_widget_max_len(fz_context *ctx, pdf_document *doc, pdf_widget *tw)
{
pdf_annot *annot = (pdf_annot *)tw;
- return pdf_to_int(ctx, pdf_get_inheritable(ctx, doc, annot->obj, PDF_NAME(MaxLen)));
+ return pdf_to_int(ctx, pdf_dict_get_inheritable(ctx, annot->obj, PDF_NAME(MaxLen)));
}
int pdf_text_widget_content_type(fz_context *ctx, pdf_document *doc, pdf_widget *tw)
{
pdf_annot *annot = (pdf_annot *)tw;
- char *code = NULL;
int type = PDF_WIDGET_CONTENT_UNRESTRAINED;
-
- fz_var(code);
- fz_try(ctx)
- {
- code = pdf_get_string_or_stream(ctx, doc, pdf_dict_getl(ctx, annot->obj, PDF_NAME(AA), PDF_NAME(F), PDF_NAME(JS), NULL));
- if (code)
- {
- if (strstr(code, "AFNumber_Format"))
- type = PDF_WIDGET_CONTENT_NUMBER;
- else if (strstr(code, "AFSpecial_Format"))
- type = PDF_WIDGET_CONTENT_SPECIAL;
- else if (strstr(code, "AFDate_FormatEx"))
- type = PDF_WIDGET_CONTENT_DATE;
- else if (strstr(code, "AFTime_FormatEx"))
- type = PDF_WIDGET_CONTENT_TIME;
- }
- }
- fz_always(ctx)
- {
+ pdf_obj *js = pdf_dict_getl(ctx, annot->obj, PDF_NAME(AA), PDF_NAME(F), PDF_NAME(JS), NULL);
+ if (js)
+ {
+ char *code = pdf_load_stream_or_string_as_utf8(ctx, js);
+ if (strstr(code, "AFNumber_Format"))
+ type = PDF_WIDGET_CONTENT_NUMBER;
+ else if (strstr(code, "AFSpecial_Format"))
+ type = PDF_WIDGET_CONTENT_SPECIAL;
+ else if (strstr(code, "AFDate_FormatEx"))
+ type = PDF_WIDGET_CONTENT_DATE;
+ else if (strstr(code, "AFTime_FormatEx"))
+ type = PDF_WIDGET_CONTENT_TIME;
fz_free(ctx, code);
}
- fz_catch(ctx)
- {
- fz_warn(ctx, "failure in fz_text_widget_content_type");
- }
return type;
}