[evince/BUG_has_javascript] properties: add "Contains javascript" document property



commit ae5cf641fb891c1478a5aed4603c496ac2a4bae9
Author: Nelson Benítez León <nbenitezl gmail com>
Date:   Wed Jun 17 14:26:19 2020 -0400

    properties: add "Contains javascript" document property
    
    and implement it for poppler backend. This property
    tells the user if the pdf has any javascript in it,
    it's shown in the document properties dialog.
    
    This depends on the new poppler-glib api:
    gboolean poppler_document_has_javascript (PopplerDocument *document);
    
    which is being proposed in:
    https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/571

 backend/pdf/ev-poppler.cc       | 7 +++++++
 libdocument/ev-document-info.h  | 4 +++-
 properties/ev-properties-view.c | 6 ++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 911894b9..a71a4cb0 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -1062,6 +1062,9 @@ pdf_document_get_info (EvDocument *document)
                            EV_DOCUMENT_INFO_N_PAGES |
                            EV_DOCUMENT_INFO_SECURITY |
                            EV_DOCUMENT_INFO_PAPER_SIZE |
+#if POPPLER_CHECK_VERSION(0, 89, 0)
+                           EV_DOCUMENT_INFO_CONTAINS_JS |
+#endif
                            EV_DOCUMENT_INFO_LICENSE;
 
        g_object_get (PDF_DOCUMENT (document)->document,
@@ -1189,6 +1192,10 @@ pdf_document_get_info (EvDocument *document)
 
        info->linearized = linearized ? g_strdup (_("Yes")) : g_strdup (_("No"));
 
+#if POPPLER_CHECK_VERSION(0, 89, 0)
+       info->contains_js = poppler_document_has_javascript (PDF_DOCUMENT (document)->document);
+#endif
+
        return info;
 }
 
diff --git a/libdocument/ev-document-info.h b/libdocument/ev-document-info.h
index e857b4b1..1e30191e 100644
--- a/libdocument/ev-document-info.h
+++ b/libdocument/ev-document-info.h
@@ -100,7 +100,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 +127,7 @@ struct _EvDocumentInfo
        double paper_height;
        double paper_width;
        EvDocumentLicense *license;
+       gboolean contains_js; /* wheter it contains any javascript */
 
        /* Mask of all the valid fields */
        guint fields_mask;
diff --git a/properties/ev-properties-view.c b/properties/ev-properties-view.c
index 707e172f..6ad73fce 100644
--- a/properties/ev-properties-view.c
+++ b/properties/ev-properties-view.c
@@ -47,6 +47,7 @@ typedef enum {
        LINEARIZED_PROPERTY,
        FORMAT_PROPERTY,
        SECURITY_PROPERTY,
+       CONTAINS_JS_PROPERTY,
        PAPER_SIZE_PROPERTY,
        FILE_SIZE_PROPERTY,
        N_PROPERTIES,
@@ -71,6 +72,7 @@ static const PropertyInfo properties_info[] = {
        { LINEARIZED_PROPERTY,    N_("Optimized:") },
        { FORMAT_PROPERTY,        N_("Format:") },
        { SECURITY_PROPERTY,      N_("Security:") },
+       { CONTAINS_JS_PROPERTY,   N_("Contains Javascript:") },
        { PAPER_SIZE_PROPERTY,    N_("Paper Size:") },
        { FILE_SIZE_PROPERTY,     N_("Size:") }
 };
@@ -418,6 +420,10 @@ ev_properties_view_set_info (EvPropertiesView *properties, const EvDocumentInfo
                set_property (properties, GTK_GRID (grid), PAPER_SIZE_PROPERTY, text, &row);
                g_free (text);
        }
+       if (info->fields_mask & EV_DOCUMENT_INFO_CONTAINS_JS) {
+               text = info->contains_js ? _("Yes") : _("No");
+               set_property (properties, GTK_GRID (grid), CONTAINS_JS_PROPERTY, text, &row);
+       }
        if (properties->file_size) {
                text = g_format_size (properties->file_size);
                set_property (properties, GTK_GRID (grid), FILE_SIZE_PROPERTY, text, &row);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]