OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TESTING_EMBEDDER_TEST_H_ | 5 #ifndef TESTING_EMBEDDER_TEST_H_ |
6 #define TESTING_EMBEDDER_TEST_H_ | 6 #define TESTING_EMBEDDER_TEST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 #endif // PDF_ENABLE_V8 | 72 #endif // PDF_ENABLE_V8 |
73 | 73 |
74 void SetDelegate(Delegate* delegate) { | 74 void SetDelegate(Delegate* delegate) { |
75 delegate_ = delegate ? delegate : default_delegate_.get(); | 75 delegate_ = delegate ? delegate : default_delegate_.get(); |
76 } | 76 } |
77 | 77 |
78 FPDF_DOCUMENT document() { return document_; } | 78 FPDF_DOCUMENT document() { return document_; } |
79 FPDF_FORMHANDLE form_handle() { return form_handle_; } | 79 FPDF_FORMHANDLE form_handle() { return form_handle_; } |
80 | 80 |
| 81 // Create an empty document, and its form fill environment. Returns true |
| 82 // on success or false on failure. |
| 83 virtual bool CreateEmptyDocument(); |
| 84 |
81 // Open the document specified by |filename|, and create its form fill | 85 // Open the document specified by |filename|, and create its form fill |
82 // environment, or return false on failure. | 86 // environment, or return false on failure. |
83 // The filename is relative to the test data directory where we store all the | 87 // The filename is relative to the test data directory where we store all the |
84 // test files. | 88 // test files. |
85 virtual bool OpenDocument(const std::string& filename, | 89 virtual bool OpenDocument(const std::string& filename, |
86 bool must_linearize = false); | 90 bool must_linearize = false); |
87 | 91 |
88 // Perform JavaScript actions that are to run at document open time. | 92 // Perform JavaScript actions that are to run at document open time. |
89 virtual void DoOpenActions(); | 93 virtual void DoOpenActions(); |
90 | 94 |
91 // Determine the page numbers present in the document. | 95 // Determine the page numbers present in the document. |
92 virtual int GetFirstPageNum(); | 96 virtual int GetFirstPageNum(); |
93 virtual int GetPageCount(); | 97 virtual int GetPageCount(); |
94 | 98 |
95 // Load a specific page of the open document. | 99 // Load a specific page of the open document. |
96 virtual FPDF_PAGE LoadPage(int page_number); | 100 virtual FPDF_PAGE LoadPage(int page_number); |
97 | 101 |
98 // Load a specific page of the open document using delegate_->GetPage. | 102 // Load a specific page of the open document using delegate_->GetPage. |
99 // delegate_->GetPage also caches loaded page. | 103 // delegate_->GetPage also caches loaded page. |
100 virtual FPDF_PAGE LoadAndCachePage(int page_number); | 104 virtual FPDF_PAGE LoadAndCachePage(int page_number); |
101 | 105 |
102 // Convert a loaded page into a bitmap. | 106 // Convert a loaded page into a bitmap. |
103 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); | 107 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); |
104 | 108 |
105 // Relese the resources obtained from LoadPage(). Further use of |page| | 109 // Relese the resources obtained from LoadPage(). Further use of |page| |
106 // is prohibited after this call is made. | 110 // is prohibited after this call is made. |
107 virtual void UnloadPage(FPDF_PAGE page); | 111 virtual void UnloadPage(FPDF_PAGE page); |
108 | 112 |
109 protected: | 113 protected: |
| 114 void SetupFormFillEnvironment(); |
| 115 |
110 Delegate* delegate_; | 116 Delegate* delegate_; |
111 std::unique_ptr<Delegate> default_delegate_; | 117 std::unique_ptr<Delegate> default_delegate_; |
112 FPDF_DOCUMENT document_; | 118 FPDF_DOCUMENT document_; |
113 FPDF_FORMHANDLE form_handle_; | 119 FPDF_FORMHANDLE form_handle_; |
114 FPDF_AVAIL avail_; | 120 FPDF_AVAIL avail_; |
115 FX_DOWNLOADHINTS hints_; | 121 FX_DOWNLOADHINTS hints_; |
116 FPDF_FILEACCESS file_access_; | 122 FPDF_FILEACCESS file_access_; |
117 FX_FILEAVAIL file_avail_; | 123 FX_FILEAVAIL file_avail_; |
118 #ifdef PDF_ENABLE_V8 | 124 #ifdef PDF_ENABLE_V8 |
119 v8::Platform* platform_; | 125 v8::Platform* platform_; |
(...skipping 15 matching lines...) Expand all Loading... |
135 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, | 141 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, |
136 int msecs, | 142 int msecs, |
137 TimerCallback fn); | 143 TimerCallback fn); |
138 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); | 144 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); |
139 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info, | 145 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info, |
140 FPDF_DOCUMENT document, | 146 FPDF_DOCUMENT document, |
141 int page_index); | 147 int page_index); |
142 }; | 148 }; |
143 | 149 |
144 #endif // TESTING_EMBEDDER_TEST_H_ | 150 #endif // TESTING_EMBEDDER_TEST_H_ |
OLD | NEW |