Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: fpdfsdk/src/fpdfformfill.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 { 14 namespace {
15 15
16 CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) 16 CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) {
17 { 17 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
18 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; 18 return pEnv ? pEnv->GetSDKDocument() : nullptr;
19 return pEnv ? pEnv->GetSDKDocument() : nullptr; 19 }
20 } 20
21 21 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) {
22 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) 22 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
23 { 23 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr;
24 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 24 }
25 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; 25
26 } 26 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
27 27 FPDF_PAGE page) {
28 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page) 28 if (!page)
29 { 29 return nullptr;
30 if (!page) 30
31 return nullptr; 31 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
32 32 return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr;
33 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
34 return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr;
35 } 33 }
36 34
37 } // namespace 35 } // namespace
38 36
39 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint( 37 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
40 FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) 38 FPDF_PAGE page,
41 { 39 double page_x,
42 if (!page || !hHandle) 40 double page_y) {
43 return -1; 41 if (!page || !hHandle)
44 CPDF_Page* pPage = (CPDF_Page*) page; 42 return -1;
45 43 CPDF_Page* pPage = (CPDF_Page*)page;
46 nonstd::unique_ptr<CPDF_InterForm> pInterForm( 44
47 new CPDF_InterForm(pPage->m_pDocument, FALSE)); 45 nonstd::unique_ptr<CPDF_InterForm> pInterForm(
48 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint( 46 new CPDF_InterForm(pPage->m_pDocument, FALSE));
49 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y); 47 CPDF_FormControl* pFormCtrl =
50 if (!pFormCtrl) 48 pInterForm->GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y);
51 return -1; 49 if (!pFormCtrl)
52 50 return -1;
53 CPDF_FormField* pFormField = pFormCtrl->GetField(); 51
54 if(!pFormField) 52 CPDF_FormField* pFormField = pFormCtrl->GetField();
55 return -1; 53 if (!pFormField)
56 54 return -1;
57 return pFormField->GetFieldType(); 55
58 } 56 return pFormField->GetFieldType();
59 57 }
60 DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment( 58
61 FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) 59 DLLEXPORT FPDF_FORMHANDLE STDCALL
62 { 60 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
63 if (!document || !formInfo || formInfo->version != 1) 61 FPDF_FORMFILLINFO* formInfo) {
64 return nullptr; 62 if (!document || !formInfo || formInfo->version != 1)
65 63 return nullptr;
66 CPDF_Document* pDocument = (CPDF_Document*)document; 64
67 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); 65 CPDF_Document* pDocument = (CPDF_Document*)document;
68 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv)); 66 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo);
69 return pEnv; 67 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv));
70 } 68 return pEnv;
71 69 }
72 DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) 70
73 { 71 DLLEXPORT void STDCALL
74 if (!hHandle) 72 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
75 return; 73 if (!hHandle)
76 74 return;
77 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; 75
78 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) 76 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
79 { 77 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) {
80 pEnv->SetSDKDocument(NULL); 78 pEnv->SetSDKDocument(NULL);
81 delete pSDKDoc; 79 delete pSDKDoc;
80 }
81 delete pEnv;
82 }
83
84 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,
85 FPDF_PAGE page,
86 int modifier,
87 double page_x,
88 double page_y) {
89 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
90 if (!pPageView)
91 return FALSE;
92
93 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
94 return pPageView->OnMouseMove(pt, modifier);
95 }
96
97 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,
98 FPDF_PAGE page,
99 int modifier,
100 double page_x,
101 double page_y) {
102 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
103 if (!pPageView)
104 return FALSE;
105
106 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
107 return pPageView->OnLButtonDown(pt, modifier);
108 }
109
110 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
111 FPDF_PAGE page,
112 int modifier,
113 double page_x,
114 double page_y) {
115 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
116 if (!pPageView)
117 return FALSE;
118
119 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
120 return pPageView->OnLButtonUp(pt, modifier);
121 }
122
123 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
124 FPDF_PAGE page,
125 int nKeyCode,
126 int modifier) {
127 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
128 if (!pPageView)
129 return FALSE;
130
131 return pPageView->OnKeyDown(nKeyCode, modifier);
132 }
133
134 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,
135 FPDF_PAGE page,
136 int nKeyCode,
137 int modifier) {
138 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
139 if (!pPageView)
140 return FALSE;
141
142 return pPageView->OnKeyUp(nKeyCode, modifier);
143 }
144
145 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle,
146 FPDF_PAGE page,
147 int nChar,
148 int modifier) {
149 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
150 if (!pPageView)
151 return FALSE;
152
153 return pPageView->OnChar(nChar, modifier);
154 }
155
156 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
157 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
158 if (!pSDKDoc)
159 return FALSE;
160
161 return pSDKDoc->KillFocusAnnot(0);
162 }
163
164 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
165 FPDF_BITMAP bitmap,
166 FPDF_PAGE page,
167 int start_x,
168 int start_y,
169 int size_x,
170 int size_y,
171 int rotate,
172 int flags) {
173 if (!hHandle || !page)
174 return;
175
176 CPDF_Page* pPage = (CPDF_Page*)page;
177 CPDF_RenderOptions options;
178 if (flags & FPDF_LCD_TEXT)
179 options.m_Flags |= RENDER_CLEARTYPE;
180 else
181 options.m_Flags &= ~RENDER_CLEARTYPE;
182
183 // Grayscale output
184 if (flags & FPDF_GRAYSCALE) {
185 options.m_ColorMode = RENDER_COLOR_GRAY;
186 options.m_ForeColor = 0;
187 options.m_BackColor = 0xffffff;
188 }
189
190 options.m_AddFlags = flags >> 8;
191 options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument);
192
193 CFX_AffineMatrix matrix;
194 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
195
196 FX_RECT clip;
197 clip.left = start_x;
198 clip.right = start_x + size_x;
199 clip.top = start_y;
200 clip.bottom = start_y + size_y;
201
202 #ifdef _SKIA_SUPPORT_
203 nonstd::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice);
204 #else
205 nonstd::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
206 #endif
207 pDevice->Attach((CFX_DIBitmap*)bitmap);
208 pDevice->SaveState();
209 pDevice->SetClip_Rect(&clip);
210
211 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
212 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
213
214 pDevice->RestoreState();
215 delete options.m_pOCContext;
216 }
217
218 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
219 int fieldType,
220 unsigned long color) {
221 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
222 pInterForm->SetHighlightColor(color, fieldType);
223 }
224
225 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle,
226 unsigned char alpha) {
227 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
228 pInterForm->SetHighlightAlpha(alpha);
229 }
230
231 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) {
232 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
233 pInterForm->RemoveAllHighLight();
234 }
235
236 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page,
237 FPDF_FORMHANDLE hHandle) {
238 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
239 pPageView->SetValid(TRUE);
240 }
241
242 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page,
243 FPDF_FORMHANDLE hHandle) {
244 if (!hHandle || !page)
245 return;
246
247 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
248 if (!pSDKDoc)
249 return;
250
251 CPDF_Page* pPage = (CPDF_Page*)page;
252 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
253 if (pPageView) {
254 pPageView->SetValid(FALSE);
255 // ReMovePageView() takes care of the delete for us.
256 pSDKDoc->ReMovePageView(pPage);
257 }
258 }
259
260 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) {
261 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
262 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
263 pSDKDoc->ProcJavascriptFun();
264 }
265
266 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) {
267 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
268 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
269 pSDKDoc->ProcOpenAction();
270 }
271
272 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
273 int aaType) {
274 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
275 if (!pSDKDoc)
276 return;
277
278 CPDF_Document* pDoc = pSDKDoc->GetDocument();
279 CPDF_Dictionary* pDic = pDoc->GetRoot();
280 if (!pDic)
281 return;
282
283 CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA"));
284 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) {
285 CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
286 CPDFSDK_ActionHandler* pActionHandler =
287 ((CPDFDoc_Environment*)hHandle)->GetActionHander();
288 ASSERT(pActionHandler != NULL);
289 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType,
290 pSDKDoc);
291 }
292 }
293
294 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
295 FPDF_FORMHANDLE hHandle,
296 int aaType) {
297 if (!hHandle || !page)
298 return;
299 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
300 CPDF_Page* pPage = (CPDF_Page*)page;
301 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
302 if (pPageView) {
303 CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
304 ASSERT(pEnv != NULL);
305
306 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
307 ASSERT(pActionHandler != NULL);
308
309 CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
310 ASSERT(pPageDict != NULL);
311
312 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
313
314 FX_BOOL bExistOAAction = FALSE;
315 FX_BOOL bExistCAAction = FALSE;
316 if (FPDFPAGE_AACTION_OPEN == aaType) {
317 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage);
318 if (bExistOAAction) {
319 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
320 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
321 }
322 } else {
323 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage);
324 if (bExistCAAction) {
325 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
326 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
327 }
82 } 328 }
83 delete pEnv; 329 }
84 } 330 }
85
86 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
87 {
88 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
89 if (!pPageView)
90 return FALSE;
91
92 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
93 return pPageView->OnMouseMove(pt, modifier);
94 }
95
96 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG E page, int modifier, double page_x, double page_y)
97 {
98 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
99 if (!pPageView)
100 return FALSE;
101
102 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
103 return pPageView->OnLButtonDown(pt, modifier);
104 }
105
106 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
107 {
108 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
109 if (!pPageView)
110 return FALSE;
111
112 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
113 return pPageView->OnLButtonUp(pt, modifier);
114 }
115
116 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa ge, int nKeyCode, int modifier)
117 {
118 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
119 if (!pPageView)
120 return FALSE;
121
122 return pPageView->OnKeyDown(nKeyCode, modifier);
123 }
124
125 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page , int nKeyCode, int modifier)
126 {
127 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
128 if (!pPageView)
129 return FALSE;
130
131 return pPageView->OnKeyUp(nKeyCode, modifier);
132 }
133
134 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier)
135 {
136 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
137 if (!pPageView)
138 return FALSE;
139
140 return pPageView->OnChar(nChar, modifier);
141 }
142
143 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle)
144 {
145 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
146 if (!pSDKDoc)
147 return FALSE;
148
149 return pSDKDoc->KillFocusAnnot(0);
150 }
151
152 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page,
153 int start_x, int start_y, int size_x, int si ze_y, int rotate, int flags)
154 {
155 if (!hHandle || !page)
156 return;
157
158 CPDF_Page* pPage = (CPDF_Page*)page;
159 CPDF_RenderOptions options;
160 if (flags & FPDF_LCD_TEXT)
161 options.m_Flags |= RENDER_CLEARTYPE;
162 else
163 options.m_Flags &= ~RENDER_CLEARTYPE;
164
165 //Grayscale output
166 if (flags & FPDF_GRAYSCALE)
167 {
168 options.m_ColorMode = RENDER_COLOR_GRAY;
169 options.m_ForeColor = 0;
170 options.m_BackColor = 0xffffff;
171 }
172
173 options.m_AddFlags = flags >> 8;
174 options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument);
175
176 CFX_AffineMatrix matrix;
177 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
178
179 FX_RECT clip;
180 clip.left = start_x;
181 clip.right = start_x + size_x;
182 clip.top = start_y;
183 clip.bottom = start_y + size_y;
184
185 #ifdef _SKIA_SUPPORT_
186 nonstd::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice);
187 #else
188 nonstd::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
189 #endif
190 pDevice->Attach((CFX_DIBitmap*)bitmap);
191 pDevice->SaveState();
192 pDevice->SetClip_Rect(&clip);
193
194 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
195 pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
196
197 pDevice->RestoreState();
198 delete options.m_pOCContext;
199 }
200
201 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color)
202 {
203 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
204 pInterForm->SetHighlightColor(color, fieldType);
205 }
206
207 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha)
208 {
209 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
210 pInterForm->SetHighlightAlpha(alpha);
211 }
212
213 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle)
214 {
215 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
216 pInterForm->RemoveAllHighLight();
217 }
218
219 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan dle)
220 {
221 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
222 pPageView->SetValid(TRUE);
223 }
224
225 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH andle)
226 {
227 if (!hHandle || !page)
228 return;
229
230 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( );
231 if (!pSDKDoc)
232 return;
233
234 CPDF_Page* pPage = (CPDF_Page*)page;
235 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
236 if (pPageView)
237 {
238 pPageView->SetValid(FALSE);
239 // ReMovePageView() takes care of the delete for us.
240 pSDKDoc->ReMovePageView(pPage);
241 }
242 }
243
244 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle)
245 {
246 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
247 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
248 pSDKDoc->ProcJavascriptFun();
249 }
250
251 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle)
252 {
253 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
254 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
255 pSDKDoc->ProcOpenAction();
256 }
257
258 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp e)
259 {
260 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
261 if (!pSDKDoc)
262 return;
263
264 CPDF_Document* pDoc = pSDKDoc->GetDocument();
265 CPDF_Dictionary* pDic = pDoc->GetRoot();
266 if (!pDic)
267 return;
268
269 CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA"));
270 if (aa.ActionExist((CPDF_AAction::AActionType)aaType))
271 {
272 CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
273 CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Environment*)hHandle)- >GetActionHander();
274 ASSERT(pActionHandler != NULL);
275 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaT ype, pSDKDoc);
276 }
277 }
278
279 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl e, int aaType)
280 {
281 if(!hHandle || !page)
282 return;
283 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( );
284 CPDF_Page* pPage = (CPDF_Page*)page;
285 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
286 if(pPageView)
287 {
288 CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv();
289 ASSERT(pEnv != NULL);
290
291 CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander();
292 ASSERT(pActionHandler != NULL);
293
294 CPDF_Dictionary *pPageDict = pPage->m_pFormDict;
295 ASSERT(pPageDict != NULL);
296
297 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
298
299 FX_BOOL bExistOAAction = FALSE;
300 FX_BOOL bExistCAAction = FALSE;
301 if (FPDFPAGE_AACTION_OPEN == aaType)
302 {
303 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage);
304 if (bExistOAAction)
305 {
306 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
307 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pS DKDoc);
308 }
309 }
310 else
311 {
312 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage);
313 if (bExistCAAction)
314 {
315 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
316 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, p SDKDoc);
317 }
318 }
319 }
320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698