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

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

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

Powered by Google App Engine
This is Rietveld 408576698