1 | //======================================================================== |
2 | // |
3 | // JSInfo.h |
4 | // |
5 | // This file is licensed under the GPLv2 or later |
6 | // |
7 | // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> |
8 | // Copyright (C) 2020, 2021 Albert Astals Cid <aacid@kde.org> |
9 | // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich |
10 | // Copyright (C) 2020 Oliver Sander <oliver.sander@tu-dresden.de> |
11 | // Copyright (C) 2020 Nelson Benítez León <nbenitezl@gmail.com> |
12 | // |
13 | // To see a description of the changes please see the Changelog file that |
14 | // came with your tarball or type make ChangeLog if you are building from git |
15 | // |
16 | //======================================================================== |
17 | |
18 | #ifndef JS_INFO_H |
19 | #define JS_INFO_H |
20 | |
21 | #include <cstdio> |
22 | #include "Object.h" |
23 | #include "PDFDoc.h" |
24 | #include "poppler_private_export.h" |
25 | #include "Link.h" |
26 | #include "UnicodeMap.h" |
27 | |
28 | class PDFDoc; |
29 | |
30 | class POPPLER_PRIVATE_EXPORT JSInfo |
31 | { |
32 | public: |
33 | // Constructor. |
34 | explicit JSInfo(PDFDoc *doc, int firstPage = 0); |
35 | |
36 | // Destructor. |
37 | ~JSInfo(); |
38 | |
39 | // scan for JS in the PDF |
40 | void scanJS(int nPages); |
41 | |
42 | // scan and print JS in the PDF |
43 | void scanJS(int nPages, FILE *fout, const UnicodeMap *uMap); |
44 | |
45 | // scan but exit after finding first JS in the PDF |
46 | void scanJS(int nPages, bool stopOnFirstJS); |
47 | |
48 | // return true if PDF contains JavaScript |
49 | bool containsJS(); |
50 | |
51 | private: |
52 | PDFDoc *doc; |
53 | int currentPage; |
54 | bool hasJS; |
55 | bool print; |
56 | FILE *file; |
57 | const UnicodeMap *uniMap; |
58 | bool onlyFirstJS; /* stop scanning after finding first JS */ |
59 | |
60 | void scan(int nPages); |
61 | void scanLinkAction(LinkAction *link, const char *action); |
62 | void printJS(const GooString *js); |
63 | }; |
64 | |
65 | #endif |
66 | |