[poppler] [Patch] glib-frontend: add PopplerActionJavaScript object
Carlos Garcia Campos
carlosgc at gnome.org
Tue Mar 29 10:03:40 PDT 2011
Excerpts from jose.aliste at gmail.com's message of mar mar 29 11:07:04 +0200 2011:
> Hi,
>
> the following patch add a wrapper for JavascriptActions to the glib
> bindings. Comments and review welcome.
>
>
> Greets
>
> José
> From f4b0e8d9f038e3ef4033e2c9af45bb48adf0c224 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Jos=C3=A9=20Aliste?= <jaliste at src.gnome.org>
> Date: Tue, 29 Mar 2011 04:56:37 -0400
> Subject: [PATCH] glib: add PopplerActionJavaScript wrapper.
> ---
> glib/poppler-action.cc | 22 ++++++++++++++++++++++
> glib/poppler-action.h | 14 +++++++++++++-
> 2 files changed, 35 insertions(+), 1 deletions(-)
> diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc
> index ca88ca4..8b95543 100644
> --- a/glib/poppler-action.cc
> +++ b/glib/poppler-action.cc
> @@ -140,6 +140,10 @@ poppler_action_free (PopplerAction *action)
> g_list_free (action->ocg_state.state_list);
> }
> break;
> + case POPPLER_ACTION_JAVASCRIPT:
> + if (action->javascript.script)
> + g_free (action->javascript.script);
> + break;
> default:
> break;
> }
> @@ -514,6 +518,20 @@ build_movie (PopplerDocument *document,
> }
You should copy the string in poppler_action_copy() too.
> static void
> +build_javascript (PopplerAction *action,
> + LinkJavaScript *link)
> +{
> + action->javascript.script = NULL;
PopplerAction is allocated with g_slice_new0() so you don't need
initializations.
> + if (link) {
_poppler_action_new() already checks whether link is NULL to return
early.
> + GooString *script;
> +
> + script = link->getScript();
> + if (script)
> + action->javascript.script = g_strdup (script->getCString ());
JavaScript might be PDFDocEncoding or Unicode, we always expose UTF-8
strings in the glib frontend.
> + }
> +}
> +
> +static void
> build_rendition (PopplerAction *action,
> LinkRendition *link)
> {
> @@ -650,6 +668,10 @@ _poppler_action_new (PopplerDocument *document,
> action->type = POPPLER_ACTION_OCG_STATE;
> build_ocg_state (document, action, dynamic_cast<LinkOCGState*> (link));
> break;
> + case actionJavaScript:
> + action->type = POPPLER_ACTION_JAVASCRIPT;
> + build_javascript (action, dynamic_cast<LinkJavaScript*> (link));
> + break;
> case actionUnknown:
> default:
> action->type = POPPLER_ACTION_UNKNOWN;
Regards,
--
Carlos Garcia Campos
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20110329/5c3bfd61/attachment.pgp>
More information about the poppler
mailing list