diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-06-19 13:15:31 +0200 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2018-06-22 16:48:50 +0100 |
commit | f7ace61076d0ab3c71e1d2bd70967ddb0b86f220 (patch) | |
tree | 8bd8b4fe4d7414685d162f66911e9951ea3dce16 /include | |
parent | 148b0934370336fc8b260e8c3aef83daf4d80ba4 (diff) | |
download | mupdf-f7ace61076d0ab3c71e1d2bd70967ddb0b86f220.tar.xz |
Keep copy of decoded utf8 text string in pdf_obj.
Removes the need to alloc/free text strings in the API, allowing
for simple functions like pdf_dict_get_text_string.
Diffstat (limited to 'include')
-rw-r--r-- | include/mupdf/pdf/annot.h | 8 | ||||
-rw-r--r-- | include/mupdf/pdf/object.h | 11 | ||||
-rw-r--r-- | include/mupdf/pdf/widget.h | 6 |
3 files changed, 15 insertions, 10 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h index e9b91da9..d616436c 100644 --- a/include/mupdf/pdf/annot.h +++ b/include/mupdf/pdf/annot.h @@ -220,9 +220,9 @@ void pdf_set_annot_vertex(fz_context *ctx, pdf_annot *annot, int i, fz_point p); void pdf_set_text_annot_position(fz_context *ctx, pdf_annot *annot, fz_point pt); /* - pdf_copy_annot_contents: return a copy of the contents of an annotation. + pdf_get_annot_contents: return the contents of an annotation. */ -char *pdf_copy_annot_contents(fz_context *ctx, pdf_annot *annot); +const char *pdf_get_annot_contents(fz_context *ctx, pdf_annot *annot); /* pdf_set_annot_contents: set the contents of an annotation. @@ -230,9 +230,9 @@ char *pdf_copy_annot_contents(fz_context *ctx, pdf_annot *annot); void pdf_set_annot_contents(fz_context *ctx, pdf_annot *annot, const char *text); /* - pdf_copy_annot_author: return a copy of the author of an annotation. + pdf_get_annot_author: return the author of an annotation. */ -char *pdf_copy_annot_author(fz_context *ctx, pdf_annot *annot); +const char *pdf_get_annot_author(fz_context *ctx, pdf_annot *annot); /* pdf_set_annot_author: set the author of an annotation. diff --git a/include/mupdf/pdf/object.h b/include/mupdf/pdf/object.h index 4bb368ea..71a8d9d8 100644 --- a/include/mupdf/pdf/object.h +++ b/include/mupdf/pdf/object.h @@ -79,6 +79,8 @@ int pdf_to_int(fz_context *ctx, pdf_obj *obj); int64_t pdf_to_int64(fz_context *ctx, pdf_obj *obj); float pdf_to_real(fz_context *ctx, pdf_obj *obj); const char *pdf_to_name(fz_context *ctx, pdf_obj *obj); +const char *pdf_to_text_string(fz_context *ctx, pdf_obj *obj); +const char *pdf_to_string(fz_context *ctx, pdf_obj *obj, size_t *sizep); char *pdf_to_str_buf(fz_context *ctx, pdf_obj *obj); int pdf_to_str_len(fz_context *ctx, pdf_obj *obj); int pdf_to_num(fz_context *ctx, pdf_obj *obj); @@ -135,6 +137,7 @@ int pdf_dict_get_int(fz_context *ctx, pdf_obj *dict, pdf_obj *key); float pdf_dict_get_real(fz_context *ctx, pdf_obj *dict, pdf_obj *key); const char *pdf_dict_get_name(fz_context *ctx, pdf_obj *dict, pdf_obj *key); const char *pdf_dict_get_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, size_t *sizep); +const char *pdf_dict_get_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key); void pdf_array_push_bool(fz_context *ctx, pdf_obj *array, int x); void pdf_array_push_int(fz_context *ctx, pdf_obj *array, int64_t x); @@ -148,6 +151,8 @@ pdf_obj *pdf_array_push_dict(fz_context *ctx, pdf_obj *array, int initial); int pdf_array_get_bool(fz_context *ctx, pdf_obj *array, int index); int pdf_array_get_int(fz_context *ctx, pdf_obj *array, int index); float pdf_array_get_real(fz_context *ctx, pdf_obj *array, int index); +const char *pdf_array_get_string(fz_context *ctx, pdf_obj *array, int index, size_t *sizep); +const char *pdf_array_get_text_string(fz_context *ctx, pdf_obj *array, int index); /* Recurse through the object structure setting the node's parent_num to num. @@ -168,10 +173,10 @@ int pdf_print_encrypted_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int t void pdf_debug_obj(fz_context *ctx, pdf_obj *obj); -char *pdf_to_utf8(fz_context *ctx, pdf_obj *src); -char *pdf_load_stream_as_utf8(fz_context *ctx, pdf_obj *src); +char *pdf_new_utf8_from_pdf_string(fz_context *ctx, const char *srcptr, size_t srclen); +char *pdf_new_utf8_from_pdf_string_obj(fz_context *ctx, pdf_obj *src); +char *pdf_new_utf8_from_pdf_stream_obj(fz_context *ctx, pdf_obj *src); char *pdf_load_stream_or_string_as_utf8(fz_context *ctx, pdf_obj *src); -pdf_obj *pdf_to_utf8_name(fz_context *ctx, pdf_obj *src); fz_rect *pdf_to_rect(fz_context *ctx, pdf_obj *array, fz_rect *rect); fz_matrix *pdf_to_matrix(fz_context *ctx, pdf_obj *array, fz_matrix *mat); diff --git a/include/mupdf/pdf/widget.h b/include/mupdf/pdf/widget.h index 5f2c38af..04c9f887 100644 --- a/include/mupdf/pdf/widget.h +++ b/include/mupdf/pdf/widget.h @@ -100,7 +100,7 @@ int pdf_text_widget_set_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw, is true, then the export values will be returned and not the list values if there are export values present. */ -int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int exportval, char *opts[]); +int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int exportval, const char *opts[]); /* pdf_choice_widget_is_multiselect: returns whether a list box or @@ -115,13 +115,13 @@ int pdf_choice_widget_is_multiselect(fz_context *ctx, pdf_document *doc, pdf_wid with NULL as the array to find out how big the array need to be. The filled in elements should not be freed by the caller. */ -int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *opts[]); +int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, const char *opts[]); /* pdf_widget_set_value: set the value of a choice widget. The caller should pass the number of options selected and an array of their names */ -void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int n, char *opts[]); +void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int n, const char *opts[]); #endif |