OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../public/fpdf_formfill.h" | 7 #include "../../public/fpdf_formfill.h" |
8 #include "../../public/fpdfview.h" | 8 #include "../../public/fpdfview.h" |
9 #include "../../third_party/base/nonstd_unique_ptr.h" | 9 #include "../../third_party/base/nonstd_unique_ptr.h" |
10 #include "../include/fsdk_define.h" | 10 #include "../include/fsdk_define.h" |
11 #include "../include/fsdk_mgr.h" | 11 #include "../include/fsdk_mgr.h" |
12 #include "../include/javascript/IJavaScript.h" | 12 #include "../include/javascript/IJavaScript.h" |
13 | 13 |
| 14 namespace { |
| 15 |
| 16 CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) |
| 17 { |
| 18 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; |
| 19 return pEnv ? pEnv->GetSDKDocument() : nullptr; |
| 20 } |
| 21 |
| 22 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) |
| 23 { |
| 24 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 25 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; |
| 26 } |
| 27 |
| 28 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page) |
| 29 { |
| 30 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
| 31 return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr; |
| 32 } |
| 33 |
| 34 } // namespace |
| 35 |
14 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint( | 36 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint( |
15 FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) | 37 FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) |
16 { | 38 { |
17 if (!page || !hHandle) | 39 if (!page || !hHandle) |
18 return -1; | 40 return -1; |
19 CPDF_Page* pPage = (CPDF_Page*) page; | 41 CPDF_Page* pPage = (CPDF_Page*) page; |
20 | 42 |
21 nonstd::unique_ptr<CPDF_InterForm> pInterForm( | 43 nonstd::unique_ptr<CPDF_InterForm> pInterForm( |
22 new CPDF_InterForm(pPage->m_pDocument, FALSE)); | 44 new CPDF_InterForm(pPage->m_pDocument, FALSE)); |
23 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint( | 45 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint( |
24 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y); | 46 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y); |
25 if (!pFormCtrl) | 47 if (!pFormCtrl) |
26 return -1; | 48 return -1; |
27 | 49 |
28 CPDF_FormField* pFormField = pFormCtrl->GetField(); | 50 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
29 if(!pFormField) | 51 if(!pFormField) |
30 return -1; | 52 return -1; |
31 | 53 |
32 return pFormField->GetFieldType(); | 54 return pFormField->GetFieldType(); |
33 } | 55 } |
34 | 56 |
35 DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment( | 57 DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment( |
36 FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) | 58 FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) |
37 { | 59 { |
38 if (!document || !formInfo || formInfo->version != 1) | 60 if (!document || !formInfo || formInfo->version != 1) |
39 return nullptr; | 61 return nullptr; |
40 CPDF_Document * pDocument = (CPDF_Document*) document; | 62 |
41 CPDFDoc_Environment * pEnv = new CPDFDoc_Environment(pDocument); | 63 CPDF_Document* pDocument = (CPDF_Document*)document; |
42 pEnv->RegAppHandle(formInfo); | 64 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); |
43 if (CPDF_Document* pEnvDocument = pEnv->GetPDFDocument()) | 65 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv)); |
44 pEnv->SetCurrentDoc(new CPDFSDK_Document(pEnvDocument, pEnv)); | |
45 return pEnv; | 66 return pEnv; |
46 } | 67 } |
47 | 68 |
48 DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) | 69 DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) |
49 { | 70 { |
50 » if(!hHandle) | 71 if (!hHandle) |
51 » » return; | 72 return; |
52 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 73 |
53 » if(pSDKDoc) | 74 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; |
54 » { | 75 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) |
55 » » ((CPDFDoc_Environment*)hHandle)->SetCurrentDoc(NULL); | 76 { |
56 » » delete pSDKDoc; | 77 pEnv->SetSDKDocument(NULL); |
57 » } | 78 delete pSDKDoc; |
58 » delete (CPDFDoc_Environment*)hHandle; | 79 } |
59 » hHandle = NULL; | 80 delete pEnv; |
60 } | 81 } |
61 | 82 |
62 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) | 83 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) |
63 { | 84 { |
64 » if (!hHandle || !page) | 85 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
65 » » return FALSE; | 86 if (!pPageView) |
66 // » CPDF_Page * pPage = (CPDF_Page*) page; | 87 return FALSE; |
67 // » CPDF_Document * pDoc = pPage->m_pDocument; | 88 |
68 //» CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | 89 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
69 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 90 return pPageView->OnMouseMove(pt, modifier); |
70 » if(!pFXDoc) | |
71 » » return FALSE; | |
72 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page); | |
73 » if(!pPageView) | |
74 » » return FALSE; | |
75 | |
76 // » double page_x = 0; | |
77 // » double page_y = 0; | |
78 //» pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
79 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
80 » return pPageView->OnMouseMove(pt, modifier); | |
81 } | 91 } |
82 | 92 |
83 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG
E page, int modifier, double page_x, double page_y) | 93 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG
E page, int modifier, double page_x, double page_y) |
84 { | 94 { |
85 » if (!hHandle || !page) | 95 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
86 » » return FALSE; | 96 if (!pPageView) |
87 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 97 return FALSE; |
88 » if(!pFXDoc) | 98 |
89 » » return FALSE; | 99 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
90 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page); | 100 return pPageView->OnLButtonDown(pt, modifier); |
91 » if(!pPageView) | |
92 » » return FALSE; | |
93 // » double page_x = 0; | |
94 // » double page_y = 0; | |
95 // » pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
96 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
97 » return pPageView->OnLButtonDown(pt, modifier); | |
98 } | 101 } |
99 | 102 |
100 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) | 103 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE
page, int modifier, double page_x, double page_y) |
101 { | 104 { |
102 » if (!hHandle || !page) | 105 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
103 » » return FALSE; | 106 if (!pPageView) |
104 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 107 return FALSE; |
105 » if(!pFXDoc) | 108 |
106 » » return FALSE; | 109 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
107 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page); | 110 return pPageView->OnLButtonUp(pt, modifier); |
108 » if(!pPageView) | |
109 » » return FALSE; | |
110 // » double page_x = 0; | |
111 // » double page_y = 0; | |
112 // » pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
113 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
114 » return pPageView->OnLButtonUp(pt, modifier); | |
115 } | 111 } |
116 | 112 |
117 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa
ge, int nKeyCode, int modifier) | 113 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa
ge, int nKeyCode, int modifier) |
118 { | 114 { |
119 » if (!hHandle || !page) | 115 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
120 » » return FALSE; | 116 if (!pPageView) |
121 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 117 return FALSE; |
122 » if(!pFXDoc) | 118 |
123 » » return FALSE; | 119 return pPageView->OnKeyDown(nKeyCode, modifier); |
124 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page); | |
125 » if(!pPageView) | |
126 » » return FALSE; | |
127 | |
128 | |
129 » return pPageView->OnKeyDown(nKeyCode, modifier); | |
130 } | 120 } |
131 | 121 |
132 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page
, int nKeyCode, int modifier) | 122 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page
, int nKeyCode, int modifier) |
133 { | 123 { |
134 » if (!hHandle || !page) | 124 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
135 » » return FALSE; | 125 if (!pPageView) |
136 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 126 return FALSE; |
137 » if(!pFXDoc) | 127 |
138 » » return FALSE; | 128 return pPageView->OnKeyUp(nKeyCode, modifier); |
139 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page); | 129 } |
140 » if(!pPageView) | |
141 » » return FALSE; | |
142 | |
143 | |
144 » return pPageView->OnKeyUp(nKeyCode, modifier); | |
145 } | |
146 | |
147 | 130 |
148 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page,
int nChar, int modifier) | 131 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page,
int nChar, int modifier) |
149 { | 132 { |
150 » if (!hHandle || !page) | 133 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
151 » » return FALSE; | 134 if (!pPageView) |
152 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo
c(); | 135 return FALSE; |
153 » if(!pFXDoc) | 136 |
154 » » return FALSE; | 137 return pPageView->OnChar(nChar, modifier); |
155 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDF_Page*)page); | |
156 » if(!pPageView) | |
157 » » return FALSE; | |
158 » return pPageView->OnChar(nChar, modifier); | |
159 | |
160 } | 138 } |
161 | 139 |
162 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) | 140 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) |
163 { | 141 { |
164 » if(!hHandle) | 142 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
165 » » return FALSE; | 143 if (!pSDKDoc) |
166 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 144 return FALSE; |
167 » if(!pSDKDoc) | 145 |
168 » » return FALSE; | 146 return pSDKDoc->KillFocusAnnot(0); |
169 » //Kill the current focus. | 147 } |
170 » return pSDKDoc->KillFocusAnnot(0); | 148 |
171 } | 149 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
FPDF_PAGE page, |
172 | 150 int start_x, int start_y, int size_x, int si
ze_y, int rotate, int flags) |
173 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap,
FPDF_PAGE page, int start_x, int start_y, | 151 { |
174 » » » » » » » » » »
» » int size_x, int size_y, int rotate, int flags) | 152 if (!hHandle || !page) |
175 { | 153 return; |
176 » if (!hHandle || !page) | 154 |
177 » » return ; | 155 CPDF_Page* pPage = (CPDF_Page*)page; |
178 » CPDF_Page* pPage = (CPDF_Page*)page; | 156 CPDF_RenderOptions options; |
179 | 157 if (flags & FPDF_LCD_TEXT) |
180 » CPDF_RenderOptions options; | 158 options.m_Flags |= RENDER_CLEARTYPE; |
181 » if (flags & FPDF_LCD_TEXT) | 159 else |
182 » » options.m_Flags |= RENDER_CLEARTYPE; | 160 options.m_Flags &= ~RENDER_CLEARTYPE; |
183 » else | 161 |
184 » » options.m_Flags &= ~RENDER_CLEARTYPE; | 162 //Grayscale output |
185 | 163 if (flags & FPDF_GRAYSCALE) |
186 » //Grayscale output | 164 { |
187 » if (flags & FPDF_GRAYSCALE) | 165 options.m_ColorMode = RENDER_COLOR_GRAY; |
188 » { | 166 options.m_ForeColor = 0; |
189 » » options.m_ColorMode = RENDER_COLOR_GRAY; | 167 options.m_BackColor = 0xffffff; |
190 » » options.m_ForeColor = 0; | 168 } |
191 » » options.m_BackColor = 0xffffff; | 169 |
192 » } | 170 options.m_AddFlags = flags >> 8; |
193 | 171 options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument); |
194 » options.m_AddFlags = flags >> 8; | 172 |
195 » options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument); | 173 CFX_AffineMatrix matrix; |
196 | 174 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); |
197 » CFX_AffineMatrix matrix; | 175 |
198 » pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate
); | 176 FX_RECT clip; |
199 | 177 clip.left = start_x; |
200 » FX_RECT clip; | 178 clip.right = start_x + size_x; |
201 » clip.left = start_x; | 179 clip.top = start_y; |
202 » clip.right = start_x + size_x; | 180 clip.bottom = start_y + size_y; |
203 » clip.top = start_y; | |
204 » clip.bottom = start_y + size_y; | |
205 | 181 |
206 #ifdef _SKIA_SUPPORT_ | 182 #ifdef _SKIA_SUPPORT_ |
207 » CFX_SkiaDevice* pDevice = new CFX_SkiaDevice; | 183 nonstd::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice); |
208 #else | 184 #else |
209 » CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; | 185 nonstd::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); |
210 #endif | 186 #endif |
211 » pDevice->Attach((CFX_DIBitmap*)bitmap); | 187 pDevice->Attach((CFX_DIBitmap*)bitmap); |
212 » pDevice->SaveState(); | 188 pDevice->SaveState(); |
213 » pDevice->SetClip_Rect(&clip); | 189 pDevice->SetClip_Rect(&clip); |
214 | 190 |
215 » CPDF_RenderContext* pContext = new CPDF_RenderContext; | 191 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) |
216 » CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | 192 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); |
217 » CPDFSDK_Document* pFXDoc = pEnv->GetCurrentDoc(); | 193 |
218 » if(!pFXDoc) | 194 pDevice->RestoreState(); |
219 » { | 195 delete options.m_pOCContext; |
220 » » delete pContext; | |
221 » » delete pDevice; | |
222 » » pContext = NULL; | |
223 » » pDevice = NULL; | |
224 » » return; | |
225 » } | |
226 » if(CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage)) | |
227 » { | |
228 » » pPageView->PageView_OnDraw(pDevice, &matrix, &options); | |
229 » } | |
230 » pDevice->RestoreState(); | |
231 | |
232 » if(options.m_pOCContext) | |
233 » { | |
234 » » delete options.m_pOCContext; | |
235 » » options.m_pOCContext = NULL; | |
236 » } | |
237 » if(pContext) | |
238 » { | |
239 » » delete pContext; | |
240 » » pContext = NULL; | |
241 » } | |
242 » if(pDevice) | |
243 » { | |
244 » » delete pDevice; | |
245 » » pDevice = NULL; | |
246 » } | |
247 | |
248 } | 196 } |
249 | 197 |
250 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
int fieldType, unsigned long color) | 198 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
int fieldType, unsigned long color) |
251 { | 199 { |
252 » if (!hHandle) | 200 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
253 » » return; | 201 pInterForm->SetHighlightColor(color, fieldType); |
254 //» CPDFDoc_Environment* pEnv = (CPDFDoc_Environment* )hHandle; | |
255 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
256 » if(pSDKDoc) | |
257 » { | |
258 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
259 » » { | |
260 » » » pInterForm->SetHighlightColor(color, fieldType); | |
261 » » } | |
262 | |
263 » } | |
264 | |
265 } | 202 } |
266 | 203 |
267 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle,
unsigned char alpha) | 204 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle,
unsigned char alpha) |
268 { | 205 { |
269 » if (!hHandle) | 206 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
270 » » return; | 207 pInterForm->SetHighlightAlpha(alpha); |
271 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
272 » if(pSDKDoc) | |
273 » { | |
274 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
275 » » » pInterForm->SetHighlightAlpha(alpha); | |
276 » } | |
277 } | 208 } |
278 | 209 |
279 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) | 210 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) |
280 { | 211 { |
281 » if (!hHandle) | 212 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
282 » » return; | 213 pInterForm->RemoveAllHighLight(); |
283 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
284 » if(pSDKDoc) | |
285 » { | |
286 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
287 » » » pInterForm->RemoveAllHighLight(); | |
288 » } | |
289 } | 214 } |
290 | 215 |
291 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan
dle) | 216 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan
dle) |
292 { | 217 { |
293 » if(!hHandle || !page) | 218 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) |
294 » » return; | 219 pPageView->SetValid(TRUE); |
295 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | |
296 » if(!pSDKDoc) | |
297 » » return; | |
298 » CPDF_Page* pPage = (CPDF_Page*)page; | |
299 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, TRUE); | |
300 » if(pPageView) | |
301 » { | |
302 » » pPageView->SetValid(TRUE); | |
303 » } | |
304 } | 220 } |
305 | 221 |
306 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH
andle) | 222 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH
andle) |
307 { | 223 { |
308 » if(!hHandle || !page) | 224 if (!hHandle || !page) |
309 » » return; | 225 return; |
310 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 226 |
311 » CPDF_Page* pPage = (CPDF_Page*)page; | 227 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(
); |
312 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); | 228 if (!pSDKDoc) |
313 » if(pPageView) | 229 return; |
314 » { | 230 |
315 » » pPageView->SetValid(FALSE); | 231 CPDF_Page* pPage = (CPDF_Page*)page; |
316 » » // ReMovePageView() takes care of the delete for us. | 232 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); |
317 » » pSDKDoc->ReMovePageView(pPage); | 233 if (pPageView) |
318 » } | 234 { |
319 } | 235 pPageView->SetValid(FALSE); |
| 236 // ReMovePageView() takes care of the delete for us. |
| 237 pSDKDoc->ReMovePageView(pPage); |
| 238 } |
| 239 } |
| 240 |
320 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) | 241 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) |
321 { | 242 { |
322 » if(!hHandle) | 243 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
323 » » return; | 244 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
324 » if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurr
entDoc()) | 245 pSDKDoc->ProcJavascriptFun(); |
325 » { | |
326 » » if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | |
327 » » » pSDKDoc->ProcJavascriptFun(); | |
328 » } | |
329 } | 246 } |
330 | 247 |
331 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) | 248 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) |
332 { | 249 { |
333 » if(!hHandle) | 250 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
334 » » return; | 251 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
335 » if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurr
entDoc()) | 252 pSDKDoc->ProcOpenAction(); |
336 » { | 253 } |
337 » » if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | 254 |
338 » » » pSDKDoc->ProcOpenAction(); | |
339 » } | |
340 } | |
341 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp
e) | 255 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp
e) |
342 { | 256 { |
343 » if(!hHandle) | 257 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
344 » » return; | 258 if (!pSDKDoc) |
345 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 259 return; |
346 » if(pSDKDoc) | 260 |
347 » { | 261 CPDF_Document* pDoc = pSDKDoc->GetDocument(); |
348 » » CPDF_Document* pDoc = pSDKDoc->GetDocument(); | 262 CPDF_Dictionary* pDic = pDoc->GetRoot(); |
349 » » CPDF_Dictionary* pDic = pDoc->GetRoot(); | 263 if (!pDic) |
350 » » if (!pDic) | 264 return; |
351 » » » return; | 265 |
352 » » CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA")); | 266 CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA")); |
353 | 267 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) |
354 » » if(aa.ActionExist((CPDF_AAction::AActionType)aaType)) | 268 { |
355 » » { | 269 CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType); |
356 » » » CPDF_Action action = aa.GetAction((CPDF_AAction::AAction
Type)aaType); | 270 CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Environment*)hHandle)-
>GetActionHander(); |
357 » » » CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Enviro
nment*)hHandle)->GetActionHander(); | 271 ASSERT(pActionHandler != NULL); |
358 » » » ASSERT(pActionHandler != NULL); | 272 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaT
ype, pSDKDoc); |
359 » » » pActionHandler->DoAction_Document(action, (CPDF_AAction:
:AActionType)aaType, pSDKDoc); | 273 } |
360 » » } | 274 } |
361 » } | 275 |
362 } | |
363 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl
e, int aaType) | 276 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl
e, int aaType) |
364 { | 277 { |
365 » if(!hHandle || !page) | 278 if(!hHandle || !page) |
366 » » return; | 279 return; |
367 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD
oc(); | 280 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(
); |
368 » CPDF_Page* pPage = (CPDF_Page*)page; | 281 CPDF_Page* pPage = (CPDF_Page*)page; |
369 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); | 282 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); |
370 » if(pPageView) | 283 if(pPageView) |
371 » { | 284 { |
372 » » CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv(); | 285 CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv(); |
373 » » ASSERT(pEnv != NULL); | 286 ASSERT(pEnv != NULL); |
374 | 287 |
375 » » CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander(); | 288 CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander(); |
376 » » ASSERT(pActionHandler != NULL); | 289 ASSERT(pActionHandler != NULL); |
377 | 290 |
378 » » CPDF_Dictionary *pPageDict = pPage->m_pFormDict; | 291 CPDF_Dictionary *pPageDict = pPage->m_pFormDict; |
379 » » ASSERT(pPageDict != NULL); | 292 ASSERT(pPageDict != NULL); |
380 | 293 |
381 » » CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); | 294 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); |
382 | 295 |
383 » » FX_BOOL bExistOAAction = FALSE; | 296 FX_BOOL bExistOAAction = FALSE; |
384 » » FX_BOOL bExistCAAction = FALSE; | 297 FX_BOOL bExistCAAction = FALSE; |
385 » » if (FPDFPAGE_AACTION_OPEN == aaType) | 298 if (FPDFPAGE_AACTION_OPEN == aaType) |
386 » » { | 299 { |
387 » » » bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); | 300 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); |
388 » » » if (bExistOAAction) | 301 if (bExistOAAction) |
389 » » » { | 302 { |
390 » » » » CPDF_Action action = aa.GetAction(CPDF_AAction::
OpenPage); | 303 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); |
391 » » » » pActionHandler->DoAction_Page(action, CPDF_AActi
on::OpenPage, pSDKDoc); | 304 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pS
DKDoc); |
392 » » » } | 305 } |
393 » » } | 306 } |
394 » » else | 307 else |
395 » » { | 308 { |
396 » » » bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage)
; | 309 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); |
397 » » » if (bExistCAAction) | 310 if (bExistCAAction) |
398 » » » { | 311 { |
399 » » » » CPDF_Action action = aa.GetAction(CPDF_AAction::
ClosePage); | 312 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
400 » » » » pActionHandler->DoAction_Page(action, CPDF_AActi
on::ClosePage, pSDKDoc); | 313 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, p
SDKDoc); |
401 » » » } | 314 } |
402 » » } | 315 } |
403 » } | 316 } |
404 } | 317 } |
405 | |
406 | |
OLD | NEW |