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