MCPcopy Index your code
hub / github.com/ArtifexSoftware/mupdf / ViewerCore

Class ViewerCore

platform/java/example/ViewerCore.java:30–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28import java.util.Vector;
29
30public class ViewerCore {
31
32 protected Worker worker;
33 protected Callback callback;
34
35 protected String documentPath;
36 protected String acceleratorPath;
37
38 protected Document doc;
39 protected Page page;
40
41 protected Location currentPage;
42 protected Location searchHitPage;
43 protected String searchNeedle;
44
45 protected OutlineItem[] outline;
46
47 protected boolean cancelSearch;
48
49 public ViewerCore(Worker worker, Callback callback, String documentPath) {
50 this.worker = worker;
51 this.callback = callback;
52 this.documentPath = documentPath;
53 }
54
55 public void openDocument(final OnException onException) {
56 worker.add(new Worker.Task() {
57 Document doc = null;
58 String acceleratorPath = null;
59 boolean needsPassword = false;
60 protected String getAcceleratorPath(String documentPath) {
61 try {
62 String accelerator = new File(documentPath).
63 getCanonicalFile().
64 getPath().
65 replace(File.separatorChar, '%').
66 replace('\\', '%').
67 replace('/', '%').
68 replace(':', '%') + ".accel";
69 String tmpdir = System.getProperty("java.io.tmpdir");
70 return new File(tmpdir, accelerator).getCanonicalFile().getPath();
71 } catch (Exception e) {
72 return null;
73 }
74 }
75 protected boolean acceleratorValid(String documentPath, String acceleratorPath) {
76 try {
77 long documentModified = new File(documentPath).lastModified();
78 long acceleratorModified = new File(acceleratorPath).lastModified();
79 return acceleratorModified != 0 && acceleratorModified > documentModified;
80 } catch (Exception e) {
81 return false;
82 }
83 }
84 public void work() {
85 String acceleratorPath = getAcceleratorPath(documentPath);
86 if (!acceleratorValid(documentPath, acceleratorPath))
87 acceleratorPath = null;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…