From ee955d1c853cab401b29e8c43f1be7165bc27425 Mon Sep 17 00:00:00 2001 From: infirit Date: Tue, 9 Dec 2014 11:51:02 +0100 Subject: [pdf] Add support for OCG State actions Based on evince commit: e39bde3f3b8ce3c111c27f7aa6b384c7a5f98672 From: Carlos Garcia Campos --- backend/pdf/ev-poppler.cc | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'backend/pdf/ev-poppler.cc') diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc index 72d7ac92..74c6c48e 100644 --- a/backend/pdf/ev-poppler.cc +++ b/backend/pdf/ev-poppler.cc @@ -1123,8 +1123,47 @@ ev_link_from_action (PdfDocument *pdf_document, case POPPLER_ACTION_RENDITION: unimplemented_action = "POPPLER_ACTION_RENDITION"; break; - case POPPLER_ACTION_OCG_STATE: - unimplemented_action = "POPPLER_ACTION_OCG_STATE"; + case POPPLER_ACTION_OCG_STATE: { + GList *on_list = NULL; + GList *off_list = NULL; + GList *toggle_list = NULL; + GList *l, *m; + + for (l = action->ocg_state.state_list; l; l = g_list_next (l)) { + PopplerActionLayer *action_layer = (PopplerActionLayer *)l->data; + + for (m = action_layer->layers; m; m = g_list_next (m)) { + PopplerLayer *layer = (PopplerLayer *)m->data; + EvLayer *ev_layer; + + ev_layer = ev_layer_new (poppler_layer_is_parent (layer), + poppler_layer_get_radio_button_group_id (layer)); + g_object_set_data_full (G_OBJECT (ev_layer), + "poppler-layer", + g_object_ref (layer), + (GDestroyNotify)g_object_unref); + + switch (action_layer->action) { + case POPPLER_ACTION_LAYER_ON: + on_list = g_list_prepend (on_list, ev_layer); + break; + case POPPLER_ACTION_LAYER_OFF: + off_list = g_list_prepend (off_list, ev_layer); + break; + case POPPLER_ACTION_LAYER_TOGGLE: + toggle_list = g_list_prepend (toggle_list, ev_layer); + break; + } + } + } + + /* The action takes the ownership of the lists */ + ev_action = ev_link_action_new_layers_state (g_list_reverse (on_list), + g_list_reverse (off_list), + g_list_reverse (toggle_list)); + + + } break; #endif case POPPLER_ACTION_UNKNOWN: -- cgit v1.2.1