[evince/BUG_has_javascript: 90/91] EvDocumentInfo: add new field "contains_js"
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/BUG_has_javascript: 90/91] EvDocumentInfo: add new field "contains_js"
- Date: Sun, 24 Jan 2021 02:07:54 +0000 (UTC)
commit cf4c328ec25fbcd96b1860a443dbf90abf411fcf
Author: Nelson Benítez León <nbenitezl gmail com>
Date: Mon Jul 13 16:31:11 2020 -0400
EvDocumentInfo: add new field "contains_js"
and implement it for poppler backend. This field
tells the user if the pdf has any javascript in it.
This depends on the new poppler-glib api (0.90+):
gboolean poppler_document_has_javascript (PopplerDocument *document);
backend/pdf/ev-poppler.cc | 8 ++++++++
libdocument/ev-document-info.h | 11 ++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 551b37a0..3984a586 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -1080,6 +1080,7 @@ pdf_document_get_info (EvDocument *document)
EV_DOCUMENT_INFO_N_PAGES |
EV_DOCUMENT_INFO_SECURITY |
EV_DOCUMENT_INFO_PAPER_SIZE |
+ EV_DOCUMENT_INFO_CONTAINS_JS |
EV_DOCUMENT_INFO_LICENSE;
g_object_get (PDF_DOCUMENT (document)->document,
@@ -1207,6 +1208,13 @@ pdf_document_get_info (EvDocument *document)
info->linearized = linearized ? g_strdup (_("Yes")) : g_strdup (_("No"));
+#if POPPLER_CHECK_VERSION(0, 90, 0)
+ info->contains_js = poppler_document_has_javascript (PDF_DOCUMENT (document)->document) ?
+ EV_DOCUMENT_CONTAINS_JS_YES : EV_DOCUMENT_CONTAINS_JS_NO;
+#else
+ info->contains_js = EV_DOCUMENT_CONTAINS_JS_UNKNOWN;
+#endif
+
return info;
}
diff --git a/libdocument/ev-document-info.h b/libdocument/ev-document-info.h
index e857b4b1..ebeeea36 100644
--- a/libdocument/ev-document-info.h
+++ b/libdocument/ev-document-info.h
@@ -55,6 +55,13 @@ typedef enum
EV_DOCUMENT_MODE_PRESENTATION = EV_DOCUMENT_MODE_FULL_SCREEN /* Will these be different? */
} EvDocumentMode;
+typedef enum
+{
+ EV_DOCUMENT_CONTAINS_JS_UNKNOWN,
+ EV_DOCUMENT_CONTAINS_JS_NO,
+ EV_DOCUMENT_CONTAINS_JS_YES
+} EvDocumentContainsJS;
+
typedef enum
{
EV_DOCUMENT_UI_HINT_HIDE_TOOLBAR = 1 << 0,
@@ -100,7 +107,8 @@ typedef enum
EV_DOCUMENT_INFO_N_PAGES = 1 << 14,
EV_DOCUMENT_INFO_SECURITY = 1 << 15,
EV_DOCUMENT_INFO_PAPER_SIZE = 1 << 16,
- EV_DOCUMENT_INFO_LICENSE = 1 << 17
+ EV_DOCUMENT_INFO_LICENSE = 1 << 17,
+ EV_DOCUMENT_INFO_CONTAINS_JS = 1 << 18
} EvDocumentInfoFields;
@@ -126,6 +134,7 @@ struct _EvDocumentInfo
double paper_height;
double paper_width;
EvDocumentLicense *license;
+ EvDocumentContainsJS contains_js; /* wheter it contains any javascript */
/* Mask of all the valid fields */
guint fields_mask;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]