summaryrefslogtreecommitdiff
path: root/utils/JSInfo.h
blob: 14a26c627f060fed223b68734f206a815cecddc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//========================================================================
//
// JSInfo.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2016 Albert Astals Cid <aacid@kde.org>
// 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
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
//
//========================================================================

#ifndef JS_INFO_H
#define JS_INFO_H

#include <cstdio>
#include "Object.h"
#include "PDFDoc.h"

#include "Link.h"
#include "UnicodeMap.h"

class PDFDoc;

class JSInfo {
public:

  // Constructor.
  JSInfo(PDFDoc *doc, int firstPage = 0);

  // Destructor.
  ~JSInfo();

  // scan for JS in the PDF
  void scanJS(int nPages);

  // scan and print JS in the PDF
  void scanJS(int nPages, FILE *fout, UnicodeMap *uMap);

  // return true if PDF contains JavaScript
  bool containsJS();

private:

  PDFDoc *doc;
  int currentPage;
  bool hasJS;
  bool print;
  FILE *file;
  UnicodeMap *uniMap;

  void scan(int nPages);
  void scanLinkAction(LinkAction *link, const char *action, bool deleteLink = true);
  void printJS(const GooString *js);

};

#endif