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 "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
11 #include "../include/fsdk_mgr.h" | 11 #include "../include/fsdk_mgr.h" |
12 #include "../include/fpdfxfa/fpdfxfa_page.h" | 12 #include "../include/fpdfxfa/fpdfxfa_page.h" |
13 #include "../include/fpdfxfa/fpdfxfa_app.h" | 13 #include "../include/fpdfxfa/fpdfxfa_app.h" |
14 | 14 |
15 | 15 |
16 #include "../include/javascript/IJavaScript.h" | 16 #include "../include/javascript/IJavaScript.h" |
17 | 17 |
18 | 18 namespace { |
19 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_ PAGE page,double page_x, double page_y) | 19 |
20 { | 20 CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) |
21 » if(!page || !hHandle) | 21 { |
22 » » return -1; | 22 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; |
23 » CPDF_Page * pPage = ((CPDFXFA_Page*) page)->GetPDFPage(); | 23 return pEnv ? pEnv->GetSDKDocument() : nullptr; |
24 » if (pPage) | 24 } |
25 » { | 25 |
26 » » CPDF_InterForm * pInterForm = NULL; | 26 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) |
27 » » pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE); | 27 { |
28 » » if (!pInterForm) | 28 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
29 » » » return -1; | 29 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; |
30 » » CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPag e, (FX_FLOAT)page_x, (FX_FLOAT)page_y); | 30 } |
31 » » if(!pFormCtrl) | 31 |
32 » » { | 32 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page) |
33 » » » delete pInterForm; | 33 { |
34 » » » return -1; | 34 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
35 » » } | 35 return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr; |
36 » » CPDF_FormField* pFormField = pFormCtrl->GetField(); | 36 } |
37 » » if(!pFormField) | 37 |
38 » » { | 38 } // namespace |
39 » » » delete pInterForm; | 39 |
40 » » » return -1; | 40 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint( |
41 » » } | 41 FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) |
42 | 42 { |
43 » » int nType = pFormField->GetFieldType(); | 43 if(!page || !hHandle) |
44 » » delete pInterForm; | 44 return -1; |
45 » » return nType; | 45 CPDF_Page * pPage = ((CPDFXFA_Page*) page)->GetPDFPage(); |
46 » } | 46 if (pPage) |
47 | 47 { |
48 » IXFA_PageView* pPageView = ((CPDFXFA_Page*)page)->GetXFAPageView(); | 48 CPDF_InterForm * pInterForm = NULL; |
49 » if (pPageView) | 49 pInterForm = new CPDF_InterForm(pPage->m_pDocument,FALSE); |
50 » { | 50 if (!pInterForm) |
51 » » IXFA_WidgetHandler* pWidgetHandler = NULL; | 51 return -1; |
52 » » IXFA_DocView* pDocView = pPageView->GetDocView(); | 52 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(pPage, (FX_F LOAT)page_x, (FX_FLOAT)page_y); |
53 » » if (!pDocView) | 53 if(!pFormCtrl) |
54 » » » return -1; | 54 { |
55 | 55 delete pInterForm; |
56 » » pWidgetHandler = pDocView->GetWidgetHandler(); | 56 return -1; |
57 » » if (!pWidgetHandler) | 57 } |
58 » » » return -1; | 58 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
59 | 59 if(!pFormField) |
60 » » IXFA_Widget* pXFAAnnot = NULL; | 60 { |
61 » » IXFA_WidgetIterator* pWidgetIterator = pPageView->CreateWidgetIt erator(XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType) ; | 61 delete pInterForm; |
62 » » if (!pWidgetIterator) | 62 return -1; |
63 » » » return -1; | 63 } |
64 » » pXFAAnnot = pWidgetIterator->MoveToNext(); | 64 |
65 » » while (pXFAAnnot) { | 65 int nType = pFormField->GetFieldType(); |
66 » » » CFX_RectF rcBBox; | 66 delete pInterForm; |
67 » » » pWidgetHandler->GetBBox (pXFAAnnot, rcBBox, 0); | 67 return nType; |
68 » » » CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.l eft + rcBBox.width, rcBBox.top+rcBBox.height); | 68 } |
69 » » » rcWidget.left -= 1.0f; | 69 |
70 » » » rcWidget.right += 1.0f; | 70 IXFA_PageView* pPageView = ((CPDFXFA_Page*)page)->GetXFAPageView(); |
71 » » » rcWidget.bottom -= 1.0f; | 71 if (pPageView) |
72 » » » rcWidget.top += 1.0f; | 72 { |
73 | 73 IXFA_WidgetHandler* pWidgetHandler = NULL; |
74 » » » if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), | 74 IXFA_DocView* pDocView = pPageView->GetDocView(); |
75 » » » » static_cast<FX_FLOAT>(page_y))) { | 75 if (!pDocView) |
76 » » » » pWidgetIterator->Release(); | 76 return -1; |
77 » » » » return FPDF_FORMFIELD_XFA; | 77 |
78 » » » } | 78 pWidgetHandler = pDocView->GetWidgetHandler(); |
79 » » » pXFAAnnot = pWidgetIterator->MoveToNext(); | 79 if (!pWidgetHandler) |
80 » » } | 80 return -1; |
81 | 81 |
82 » » pWidgetIterator->Release(); | 82 IXFA_Widget* pXFAAnnot = NULL; |
83 » } | 83 IXFA_WidgetIterator* pWidgetIterator = pPageView->CreateWidgetIterator(X FA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType); |
84 | 84 if (!pWidgetIterator) |
85 » return -1; | 85 return -1; |
86 pXFAAnnot = pWidgetIterator->MoveToNext(); | |
87 while (pXFAAnnot) { | |
88 CFX_RectF rcBBox; | |
89 pWidgetHandler->GetBBox (pXFAAnnot, rcBBox, 0); | |
90 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox .width, rcBBox.top+rcBBox.height); | |
91 rcWidget.left -= 1.0f; | |
92 rcWidget.right += 1.0f; | |
93 rcWidget.bottom -= 1.0f; | |
94 rcWidget.top += 1.0f; | |
95 | |
96 if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), | |
97 static_cast<FX_FLOAT>(page_y))) { | |
98 pWidgetIterator->Release(); | |
99 return FPDF_FORMFIELD_XFA; | |
100 } | |
101 pXFAAnnot = pWidgetIterator->MoveToNext(); | |
102 } | |
103 | |
104 pWidgetIterator->Release(); | |
105 } | |
106 | |
107 return -1; | |
86 } | 108 } |
87 | 109 |
88 DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) | 110 DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) |
89 { | 111 { |
90 » if(!document || !formInfo || formInfo->version!=2) | 112 if (!document || !formInfo || formInfo->version != 1) |
Lei Zhang
2015/07/16 21:12:15
This changed from 2 to 1
Tom Sepez
2015/07/16 21:39:04
Nice catch.
| |
91 » » return NULL; | 113 return nullptr; |
92 » CPDFXFA_Document * pDocument = (CPDFXFA_Document*) document; | 114 |
93 » CPDFDoc_Environment * pEnv = NULL; | 115 CPDFXFA_Document *pDocument = (CPDFXFA_Document*)document; |
94 » pEnv = new CPDFDoc_Environment(pDocument); | 116 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); |
95 » if (!pEnv) | 117 pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); |
96 » » return NULL; | 118 |
97 » pEnv->RegAppHandle(formInfo); | 119 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); |
98 | 120 pApp->AddFormFillEnv(pEnv); |
99 » CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); | 121 |
100 » pApp->AddFormFillEnv(pEnv); | 122 return pEnv; |
101 | |
102 » if(pEnv->GetPDFXFADocument()) | |
Lei Zhang
2015/07/16 21:12:15
This block of code went missing
Tom Sepez
2015/07/16 21:39:04
It should be covered by line 117 in the new code.
| |
103 » { | |
104 » » //CPDFSDK_Document* pSDKDoc = new CPDFSDK_Document(pEnv->GetPDFX FADocument(), pEnv); | |
105 » » CPDFSDK_Document* pSDKDoc = pDocument->GetSDKDocument(pEnv); | |
106 » » if(pSDKDoc) { | |
107 » » » pEnv->SetCurrentDoc(pSDKDoc); | |
108 » » } | |
109 » } | |
110 » return pEnv; | |
111 } | 123 } |
112 | 124 |
113 DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) | 125 DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) |
114 { | 126 { |
115 » if (!hHandle) | 127 if (!hHandle) |
116 » » return; | 128 return; |
117 » CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); | 129 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); |
118 » pApp->RemoveFormFillEnv((CPDFDoc_Environment*)hHandle); | 130 pApp->RemoveFormFillEnv((CPDFDoc_Environment*)hHandle); |
119 » delete (CPDFDoc_Environment*)hHandle; | 131 delete (CPDFDoc_Environment*)hHandle; |
120 » hHandle = NULL; | |
121 } | 132 } |
122 | 133 |
123 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) | 134 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) |
124 { | 135 { |
125 » if (!hHandle || !page) | 136 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
126 » » return FALSE; | 137 if (!pPageView) |
127 // » CPDF_Page * pPage = (CPDF_Page*) page; | 138 return FALSE; |
128 // » CPDF_Document * pDoc = pPage->m_pDocument; | 139 |
129 //» CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | 140 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
130 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 141 return pPageView->OnMouseMove(pt, modifier); |
131 » if(!pFXDoc) | |
132 » » return FALSE; | |
133 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
134 » if(!pPageView) | |
135 » » return FALSE; | |
136 | |
137 // » double page_x = 0; | |
138 // » double page_y = 0; | |
139 //» pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
140 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
141 » return pPageView->OnMouseMove(pt, modifier); | |
142 } | 142 } |
143 | 143 |
144 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG E page, int modifier, double page_x, double page_y) | 144 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG E page, int modifier, double page_x, double page_y) |
145 { | 145 { |
146 » if (!hHandle || !page) | 146 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
147 » » return FALSE; | 147 if (!pPageView) |
148 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 148 return FALSE; |
149 » if(!pFXDoc) | 149 |
150 » » return FALSE; | 150 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
151 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | 151 return pPageView->OnLButtonDown(pt, modifier); |
152 » if(!pPageView) | |
153 » » return FALSE; | |
154 // » double page_x = 0; | |
155 // » double page_y = 0; | |
156 // » pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
157 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
158 » return pPageView->OnLButtonDown(pt, modifier); | |
159 } | 152 } |
160 | 153 |
161 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) | 154 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) |
162 { | 155 { |
163 » if (!hHandle || !page) | 156 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
164 » » return FALSE; | 157 if (!pPageView) |
165 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 158 return FALSE; |
166 » if(!pFXDoc) | 159 |
167 » » return FALSE; | 160 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
168 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | 161 return pPageView->OnLButtonUp(pt, modifier); |
169 » if(!pPageView) | |
170 » » return FALSE; | |
171 // » double page_x = 0; | |
172 // » double page_y = 0; | |
173 // » pEnv->FFI_DeviceToPage(page, point_x, point_y, &page_x, &page_y); | |
174 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
175 » return pPageView->OnLButtonUp(pt, modifier); | |
176 } | 162 } |
177 | 163 |
178 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG E page, int modifier, double page_x, double page_y) | 164 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG E page, int modifier, double page_x, double page_y) |
179 { | 165 { |
180 » if (!hHandle || !page) | 166 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
181 » » return FALSE; | 167 if (!pPageView) |
182 | 168 return FALSE; |
183 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 169 |
184 » if(!pFXDoc) | 170 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
185 » » return FALSE; | 171 return pPageView->OnRButtonDown(pt, modifier); |
186 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
187 » if(!pPageView) | |
188 » » return FALSE; | |
189 | |
190 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
191 » return pPageView->OnRButtonDown(pt, modifier); | |
192 } | 172 } |
193 | 173 |
194 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) | 174 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) |
195 { | 175 { |
196 » if (!hHandle || !page) | 176 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
197 » » return FALSE; | 177 if (!pPageView) |
198 | 178 return FALSE; |
199 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 179 |
200 » if(!pFXDoc) | 180 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); |
201 » » return FALSE; | 181 return pPageView->OnRButtonUp(pt, modifier); |
202 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
203 » if(!pPageView) | |
204 » » return FALSE; | |
205 | |
206 » CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); | |
207 » return pPageView->OnRButtonUp(pt, modifier); | |
208 } | 182 } |
209 | 183 |
210 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa ge, int nKeyCode, int modifier) | 184 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa ge, int nKeyCode, int modifier) |
211 { | 185 { |
212 » if (!hHandle || !page) | 186 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
213 » » return FALSE; | 187 if (!pPageView) |
214 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 188 return FALSE; |
215 » if(!pFXDoc) | 189 |
216 » » return FALSE; | 190 return pPageView->OnKeyDown(nKeyCode, modifier); |
217 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
218 » if(!pPageView) | |
219 » » return FALSE; | |
220 | |
221 | |
222 » return pPageView->OnKeyDown(nKeyCode, modifier); | |
223 } | 191 } |
224 | 192 |
225 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page , int nKeyCode, int modifier) | 193 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page , int nKeyCode, int modifier) |
226 { | 194 { |
227 » if (!hHandle || !page) | 195 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
228 » » return FALSE; | 196 if (!pPageView) |
229 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 197 return FALSE; |
230 » if(!pFXDoc) | 198 |
231 » » return FALSE; | 199 return pPageView->OnKeyUp(nKeyCode, modifier); |
232 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | 200 } |
233 » if(!pPageView) | |
234 » » return FALSE; | |
235 | |
236 | |
237 » return pPageView->OnKeyUp(nKeyCode, modifier); | |
238 } | |
239 | |
240 | 201 |
241 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier) | 202 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier) |
242 { | 203 { |
243 » if (!hHandle || !page) | 204 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
244 » » return FALSE; | 205 if (!pPageView) |
245 » CPDFSDK_Document* pFXDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDo c(); | 206 return FALSE; |
246 » if(!pFXDoc) | 207 |
247 » » return FALSE; | 208 return pPageView->OnChar(nChar, modifier); |
248 » CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page); | |
249 » if(!pPageView) | |
250 » » return FALSE; | |
251 » return pPageView->OnChar(nChar, modifier); | |
252 | |
253 } | 209 } |
254 | 210 |
255 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) | 211 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) |
256 { | 212 { |
257 » if(!hHandle) | 213 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
258 » » return FALSE; | 214 if (!pSDKDoc) |
259 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | 215 return FALSE; |
260 » if(!pSDKDoc) | 216 |
261 » » return FALSE; | 217 return pSDKDoc->KillFocusAnnot(0); |
262 » //Kill the current focus. | 218 } |
263 » return pSDKDoc->KillFocusAnnot(0); | 219 |
264 } | 220 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, |
265 | 221 int start_x, int start_y, int size_x, int si ze_y, int rotate, int flags) |
266 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, | 222 { |
267 » » » » » » » » » » » » int size_x, int size_y, int rotate, int flags) | 223 if (!hHandle || !page) |
268 { | 224 return ; |
269 » if (!hHandle || !page) | 225 |
270 » » return ; | 226 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; |
271 | 227 CPDFXFA_Document* pDocument = pPage->GetDocument(); |
272 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | 228 if (!pDocument) |
273 » CPDFXFA_Document* pDocument = pPage->GetDocument(); | 229 return; |
274 » if (!pDocument) | 230 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); |
275 » » return; | 231 if (!pPDFDoc) |
276 » CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); | 232 return; |
277 » if (!pPDFDoc) | 233 |
278 » » return; | 234 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; |
279 | 235 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); |
280 » CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | 236 if (!pFXDoc) |
281 » CPDFSDK_Document* pFXDoc = pEnv->GetCurrentDoc(); | 237 return; |
282 » if (!pFXDoc) | 238 |
283 » » return; | 239 CFX_AffineMatrix matrix; |
284 | 240 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); |
285 » CFX_AffineMatrix matrix; | 241 |
286 » pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate ); | 242 FX_RECT clip; |
287 | 243 clip.left = start_x; |
288 » FX_RECT clip; | 244 clip.right = start_x + size_x; |
289 » clip.left = start_x; | 245 clip.top = start_y; |
290 » clip.right = start_x + size_x; | 246 clip.bottom = start_y + size_y; |
291 » clip.top = start_y; | |
292 » clip.bottom = start_y + size_y; | |
293 | 247 |
294 #ifdef _SKIA_SUPPORT_ | 248 #ifdef _SKIA_SUPPORT_ |
295 » CFX_SkiaDevice* pDevice = FX_NEW CFX_SkiaDevice; | 249 CFX_SkiaDevice* pDevice = FX_NEW CFX_SkiaDevice; |
Lei Zhang
2015/07/16 21:12:15
Not going to put in a unique_ptr here?
Tom Sepez
2015/07/16 21:39:04
Will do. This seemed different enough in XFA that
| |
296 #else | 250 #else |
297 » CFX_FxgeDevice* pDevice = NULL; | 251 CFX_FxgeDevice* pDevice = NULL; |
298 » pDevice = FX_NEW CFX_FxgeDevice; | 252 pDevice = FX_NEW CFX_FxgeDevice; |
299 #endif | 253 #endif |
300 | 254 |
301 » if (!pDevice) | 255 if (!pDevice) |
302 » » return; | 256 return; |
303 » pDevice->Attach((CFX_DIBitmap*)bitmap); | 257 pDevice->Attach((CFX_DIBitmap*)bitmap); |
304 » pDevice->SaveState(); | 258 pDevice->SaveState(); |
305 » pDevice->SetClip_Rect(&clip); | 259 pDevice->SetClip_Rect(&clip); |
306 | 260 |
307 » CPDF_RenderOptions options; | 261 CPDF_RenderOptions options; |
308 » if (flags & FPDF_LCD_TEXT) | 262 if (flags & FPDF_LCD_TEXT) |
309 » » options.m_Flags |= RENDER_CLEARTYPE; | 263 options.m_Flags |= RENDER_CLEARTYPE; |
310 » else | 264 else |
311 » » options.m_Flags &= ~RENDER_CLEARTYPE; | 265 options.m_Flags &= ~RENDER_CLEARTYPE; |
312 | 266 |
313 » //Grayscale output | 267 //Grayscale output |
314 » if (flags & FPDF_GRAYSCALE) | 268 if (flags & FPDF_GRAYSCALE) |
315 » { | 269 { |
316 » » options.m_ColorMode = RENDER_COLOR_GRAY; | 270 options.m_ColorMode = RENDER_COLOR_GRAY; |
317 » » options.m_ForeColor = 0; | 271 options.m_ForeColor = 0; |
318 » » options.m_BackColor = 0xffffff; | 272 options.m_BackColor = 0xffffff; |
319 » } | 273 } |
320 » options.m_AddFlags = flags >> 8; | 274 options.m_AddFlags = flags >> 8; |
321 | 275 |
322 » options.m_pOCContext = FX_NEW CPDF_OCContext(pPDFDoc); | 276 options.m_pOCContext = FX_NEW CPDF_OCContext(pPDFDoc); |
323 | 277 |
324 » if(CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page )) | 278 if(CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page)) |
325 » { | 279 { |
326 » » pPageView->PageView_OnDraw(pDevice, &matrix, &options, &clip); | 280 pPageView->PageView_OnDraw(pDevice, &matrix, &options, &clip); |
327 » } | 281 } |
328 » pDevice->RestoreState(); | 282 pDevice->RestoreState(); |
329 | 283 |
330 » if(options.m_pOCContext) | 284 if(options.m_pOCContext) |
331 » { | 285 { |
332 » » delete options.m_pOCContext; | 286 delete options.m_pOCContext; |
333 » » options.m_pOCContext = NULL; | 287 options.m_pOCContext = NULL; |
334 » } | 288 } |
335 » if(pDevice) | 289 if(pDevice) |
336 » { | 290 { |
337 » » delete pDevice; | 291 delete pDevice; |
338 » » pDevice = NULL; | 292 pDevice = NULL; |
339 » } | 293 } |
340 | |
341 } | 294 } |
342 DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWid get) | 295 DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWid get) |
343 { | 296 { |
344 » if (NULL == hWidget || NULL == document) | 297 if (NULL == hWidget || NULL == document) |
345 » » return; | 298 return; |
346 | 299 |
347 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 300 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
348 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 301 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
349 » » return; | 302 return; |
350 | 303 |
351 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 304 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
352 » if (pXFAMenuHander == NULL) | 305 if (pXFAMenuHander == NULL) |
353 » » return; | 306 return; |
354 | 307 |
355 » pXFAMenuHander->Undo((IXFA_Widget*)hWidget); | 308 pXFAMenuHander->Undo((IXFA_Widget*)hWidget); |
356 | 309 |
357 } | 310 } |
358 DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWid get) | 311 DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWid get) |
359 { | 312 { |
360 » if (NULL == hWidget || NULL == document) | 313 if (NULL == hWidget || NULL == document) |
361 » » return; | 314 return; |
362 | 315 |
363 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 316 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
364 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 317 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
365 » » return; | 318 return; |
366 | 319 |
367 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 320 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
368 » if (pXFAMenuHander == NULL) | 321 if (pXFAMenuHander == NULL) |
369 » » return; | 322 return; |
370 | 323 |
371 » pXFAMenuHander->Redo((IXFA_Widget*)hWidget); | 324 pXFAMenuHander->Redo((IXFA_Widget*)hWidget); |
372 } | 325 } |
373 | 326 |
374 DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) | 327 DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) |
375 { | 328 { |
376 » if (NULL == hWidget || NULL == document) | 329 if (NULL == hWidget || NULL == document) |
377 » » return; | 330 return; |
378 | 331 |
379 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 332 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
380 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 333 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
381 » » return; | 334 return; |
382 | 335 |
383 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 336 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
384 » if (pXFAMenuHander == NULL) | 337 if (pXFAMenuHander == NULL) |
385 » » return; | 338 return; |
386 | 339 |
387 » pXFAMenuHander->SelectAll((IXFA_Widget*)hWidget); | 340 pXFAMenuHander->SelectAll((IXFA_Widget*)hWidget); |
388 } | 341 } |
389 DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid get, FPDF_WIDESTRING wsText, FPDF_DWORD* size) | 342 DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid get, FPDF_WIDESTRING wsText, FPDF_DWORD* size) |
390 { | 343 { |
391 » if (NULL == hWidget || NULL == document) | 344 if (NULL == hWidget || NULL == document) |
392 » » return; | 345 return; |
393 | 346 |
394 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 347 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
395 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 348 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
396 » » return; | 349 return; |
397 | 350 |
398 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 351 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
399 » if (pXFAMenuHander == NULL) | 352 if (pXFAMenuHander == NULL) |
400 » » return; | 353 return; |
401 | 354 |
402 » CFX_WideString wsCpText; | 355 CFX_WideString wsCpText; |
403 » pXFAMenuHander->Copy((IXFA_Widget*)hWidget, wsCpText); | 356 pXFAMenuHander->Copy((IXFA_Widget*)hWidget, wsCpText); |
404 | 357 |
405 » CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); | 358 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
406 » int len = bsCpText.GetLength()/sizeof(unsigned short); | 359 int len = bsCpText.GetLength()/sizeof(unsigned short); |
407 » if (wsText == NULL) { | 360 if (wsText == NULL) { |
408 » » *size = len; | 361 *size = len; |
409 » » return; | 362 return; |
410 » } | 363 } |
411 | 364 |
412 » int real_size = len < *size ? len : *size; | 365 int real_size = len < *size ? len : *size; |
413 » if (real_size > 0) | 366 if (real_size > 0) |
414 » { | 367 { |
415 » » FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(u nsigned short)),real_size*sizeof(unsigned short)); | 368 FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(unsigned short)),real_size*sizeof(unsigned short)); |
416 » » bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); | 369 bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); |
417 » } | 370 } |
418 » *size = real_size; | 371 *size = real_size; |
419 } | 372 } |
420 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg et, FPDF_WIDESTRING wsText, FPDF_DWORD* size) | 373 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg et, FPDF_WIDESTRING wsText, FPDF_DWORD* size) |
421 { | 374 { |
422 » if (NULL == hWidget || NULL == document) | 375 if (NULL == hWidget || NULL == document) |
423 » » return; | 376 return; |
424 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 377 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
425 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 378 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
426 » » return; | 379 return; |
427 | 380 |
428 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 381 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
429 » if (pXFAMenuHander == NULL) | 382 if (pXFAMenuHander == NULL) |
430 » » return; | 383 return; |
431 | 384 |
432 » CFX_WideString wsCpText; | 385 CFX_WideString wsCpText; |
433 » pXFAMenuHander->Cut((IXFA_Widget*)hWidget, wsCpText); | 386 pXFAMenuHander->Cut((IXFA_Widget*)hWidget, wsCpText); |
434 | 387 |
435 » CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); | 388 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
436 » int len = bsCpText.GetLength()/sizeof(unsigned short); | 389 int len = bsCpText.GetLength()/sizeof(unsigned short); |
437 » if (wsText == NULL) { | 390 if (wsText == NULL) { |
438 » » *size = len; | 391 *size = len; |
439 » » return; | 392 return; |
440 » } | 393 } |
441 | 394 |
442 » int real_size = len < *size ? len : *size; | 395 int real_size = len < *size ? len : *size; |
443 » if (real_size > 0) | 396 if (real_size > 0) |
444 » { | 397 { |
445 » » FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(u nsigned short)),real_size*sizeof(unsigned short)); | 398 FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(unsigned short)),real_size*sizeof(unsigned short)); |
446 » » bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); | 399 bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); |
447 » } | 400 } |
448 » *size = real_size; | 401 *size = real_size; |
449 } | 402 } |
450 DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, FPDF_WIDGET hWi dget, FPDF_WIDESTRING wsText, FPDF_DWORD size) | 403 DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, FPDF_WIDGET hWi dget, FPDF_WIDESTRING wsText, FPDF_DWORD size) |
451 { | 404 { |
452 » if (NULL == hWidget || NULL == document) | 405 if (NULL == hWidget || NULL == document) |
453 » » return; | 406 return; |
454 | 407 |
455 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 408 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
456 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 409 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
457 » » return; | 410 return; |
458 | 411 |
459 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 412 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
460 » if (pXFAMenuHander == NULL) | 413 if (pXFAMenuHander == NULL) |
461 » » return; | 414 return; |
462 | 415 |
463 » CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); | 416 CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); |
464 » pXFAMenuHander->Paste((IXFA_Widget*)hWidget, wstr); | 417 pXFAMenuHander->Paste((IXFA_Widget*)hWidget, wstr); |
465 | 418 |
466 } | 419 } |
467 DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText) | 420 DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText) |
468 { | 421 { |
469 » if (NULL == hWidget || NULL == document) | 422 if (NULL == hWidget || NULL == document) |
470 » » return; | 423 return; |
471 | 424 |
472 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 425 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
473 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 426 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
474 » » return; | 427 return; |
475 | 428 |
476 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 429 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
477 » if (pXFAMenuHander == NULL) | 430 if (pXFAMenuHander == NULL) |
478 » » return; | 431 return; |
479 | 432 |
480 » CFX_PointF ptPopup; | 433 CFX_PointF ptPopup; |
481 » ptPopup.x = x; | 434 ptPopup.x = x; |
482 » ptPopup.y = y; | 435 ptPopup.y = y; |
483 » CFX_ByteStringC bs(bsText); | 436 CFX_ByteStringC bs(bsText); |
484 » pXFAMenuHander->ReplaceSpellCheckWord((IXFA_Widget*)hWidget,ptPopup,bs); | 437 pXFAMenuHander->ReplaceSpellCheckWord((IXFA_Widget*)hWidget,ptPopup,bs); |
485 | 438 |
486 } | 439 } |
487 DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FP DF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle) | 440 DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FP DF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle) |
488 { | 441 { |
489 » if (NULL == hWidget || NULL == document) | 442 if (NULL == hWidget || NULL == document) |
490 » » return; | 443 return; |
491 | 444 |
492 » CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 445 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
493 » if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT ype() != XFA_DOCTYPE_Static) | 446 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType( ) != XFA_DOCTYPE_Static) |
494 » » return; | 447 return; |
495 | 448 |
496 » IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp ()->GetMenuHandler(); | 449 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()-> GetMenuHandler(); |
497 » if (pXFAMenuHander == NULL) | 450 if (pXFAMenuHander == NULL) |
498 » » return; | 451 return; |
499 | 452 |
500 » CFX_ByteStringArray* sSuggestWords = FX_NEW CFX_ByteStringArray; | 453 CFX_ByteStringArray* sSuggestWords = FX_NEW CFX_ByteStringArray; |
501 » CFX_PointF ptPopup; | 454 CFX_PointF ptPopup; |
502 » ptPopup.x = x; | 455 ptPopup.x = x; |
503 » ptPopup.y = y; | 456 ptPopup.y = y; |
504 » pXFAMenuHander->GetSuggestWords((IXFA_Widget*)hWidget, ptPopup, *sSugges tWords); | 457 pXFAMenuHander->GetSuggestWords((IXFA_Widget*)hWidget, ptPopup, *sSuggestWor ds); |
505 » *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords; | 458 *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords; |
506 } | 459 } |
507 DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle) | 460 DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle) |
508 { | 461 { |
509 » if (stringHandle == NULL) | 462 if (stringHandle == NULL) |
510 » » return -1; | 463 return -1; |
511 » CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; | 464 CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; |
512 » return sSuggestWords->GetSize(); | 465 return sSuggestWords->GetSize(); |
513 } | 466 } |
514 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size) | 467 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size) |
515 { | 468 { |
516 » if (stringHandle == NULL || size == NULL) | 469 if (stringHandle == NULL || size == NULL) |
517 » » return FALSE; | 470 return FALSE; |
518 » int count = FPDF_StringHandleCounts(stringHandle); | 471 int count = FPDF_StringHandleCounts(stringHandle); |
519 » if (index < 0|| index >= count) | 472 if (index < 0|| index >= count) |
520 » » return FALSE; | 473 return FALSE; |
521 | 474 |
522 » CFX_ByteStringArray sSuggestWords = *(CFX_ByteStringArray*)stringHandle; | 475 CFX_ByteStringArray sSuggestWords = *(CFX_ByteStringArray*)stringHandle; |
523 » int len = sSuggestWords[index].GetLength(); | 476 int len = sSuggestWords[index].GetLength(); |
524 | 477 |
525 » if (bsText == NULL) { | 478 if (bsText == NULL) { |
526 » » *size = len; | 479 *size = len; |
527 » » return TRUE; | 480 return TRUE; |
528 » } | 481 } |
529 | 482 |
530 » int real_size = len < *size ? len : *size; | 483 int real_size = len < *size ? len : *size; |
531 » if (real_size > 0) | 484 if (real_size > 0) |
532 » » FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(sSuggestWords[index ]), real_size); | 485 FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(sSuggestWords[index]), real _size); |
533 » *size = real_size; | 486 *size = real_size; |
534 | 487 |
535 » return TRUE; | 488 return TRUE; |
536 } | 489 } |
537 DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) | 490 DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) |
538 { | 491 { |
539 » if (stringHandle == NULL) | 492 if (stringHandle == NULL) |
540 » » return; | 493 return; |
541 » CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; | 494 CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; |
542 » delete sSuggestWords; | 495 delete sSuggestWords; |
543 } | 496 } |
544 | 497 |
545 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringH andle, FPDF_BYTESTRING bsText, FPDF_DWORD size) | 498 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringH andle, FPDF_BYTESTRING bsText, FPDF_DWORD size) |
546 { | 499 { |
547 » if (stringHandle == NULL || bsText == NULL || size <= 0) | 500 if (stringHandle == NULL || bsText == NULL || size <= 0) |
548 » » return FALSE; | 501 return FALSE; |
549 | 502 |
550 » CFX_ByteStringArray* stringArr = (CFX_ByteStringArray*)stringHandle; | 503 CFX_ByteStringArray* stringArr = (CFX_ByteStringArray*)stringHandle; |
551 » CFX_ByteString bsStr(bsText, size); | 504 CFX_ByteString bsStr(bsText, size); |
552 | 505 |
553 » stringArr->Add(bsStr); | 506 stringArr->Add(bsStr); |
554 » return TRUE; | 507 return TRUE; |
555 } | 508 } |
556 | 509 |
557 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color) | 510 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color) |
558 { | 511 { |
559 » if (!hHandle) | 512 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
560 » » return; | 513 pInterForm->SetHighlightColor(color, fieldType); |
561 //» CPDFDoc_Environment* pEnv = (CPDFDoc_Environment* )hHandle; | |
562 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | |
563 » if(pSDKDoc) | |
564 » { | |
565 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
566 » » { | |
567 » » » pInterForm->SetHighlightColor(color, fieldType); | |
568 » » } | |
569 | |
570 » } | |
571 | |
572 } | 514 } |
573 | 515 |
574 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha) | 516 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha) |
575 { | 517 { |
576 » if (!hHandle) | 518 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
577 » » return; | 519 pInterForm->SetHighlightAlpha(alpha); |
578 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | |
579 » if(pSDKDoc) | |
580 » { | |
581 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
582 » » » pInterForm->SetHighlightAlpha(alpha); | |
583 » } | |
584 } | 520 } |
585 | 521 |
586 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) | 522 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) |
587 { | 523 { |
588 » if (!hHandle) | 524 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) |
589 » » return; | 525 pInterForm->RemoveAllHighLight(); |
590 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | |
591 » if(pSDKDoc) | |
592 » { | |
593 » » if(CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm()) | |
594 » » » pInterForm->RemoveAllHighLight(); | |
595 » } | |
596 } | 526 } |
597 | 527 |
598 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan dle) | 528 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan dle) |
599 { | 529 { |
600 » if(!hHandle || !page) | 530 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) |
601 » » return; | 531 pPageView->SetValid(TRUE); |
602 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | |
603 » if(!pSDKDoc) | |
604 » » return; | |
605 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | |
606 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, TRUE); | |
607 » if(pPageView) | |
608 » { | |
609 » » pPageView->SetValid(TRUE); | |
610 » } | |
611 } | 532 } |
612 | 533 |
613 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH andle) | 534 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH andle) |
614 { | 535 { |
615 » if(!hHandle || !page) | 536 if (!hHandle || !page) |
616 » » return; | 537 return; |
617 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | 538 |
618 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | 539 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( ); |
619 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); | 540 if (!pSDKDoc) |
620 » if(pPageView) | 541 return; |
621 » { | 542 |
622 » » pPageView->SetValid(FALSE); | 543 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; |
623 » » // ReMovePageView() takes care of the delete for us. | 544 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); |
624 » » pSDKDoc->ReMovePageView(pPage); | 545 if (pPageView) |
625 » } | 546 { |
626 } | 547 pPageView->SetValid(FALSE); |
548 // ReMovePageView() takes care of the delete for us. | |
549 pSDKDoc->ReMovePageView(pPage); | |
550 } | |
551 } | |
552 | |
627 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) | 553 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) |
628 { | 554 { |
629 » if(!hHandle) | 555 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
630 » » return; | 556 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
631 » if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurr entDoc()) | 557 pSDKDoc->ProcJavascriptFun(); |
632 » { | |
633 » » if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | |
634 » » » pSDKDoc->ProcJavascriptFun(); | |
635 » } | |
636 } | 558 } |
637 | 559 |
638 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) | 560 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) |
639 { | 561 { |
640 » if(!hHandle) | 562 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
641 » » return; | 563 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
642 » if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurr entDoc()) | 564 pSDKDoc->ProcOpenAction(); |
643 » { | 565 } |
644 » » if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | 566 |
645 » » » pSDKDoc->ProcOpenAction(); | |
646 » } | |
647 } | |
648 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp e) | 567 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaTyp e) |
649 { | 568 { |
650 » if(!hHandle) | 569 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); |
651 » » return; | 570 if (!pSDKDoc) |
652 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | 571 return; |
653 » if(pSDKDoc) | 572 |
654 » { | 573 CPDF_Document* pDoc = pSDKDoc->GetDocument()->GetPDFDoc(); |
655 » » CPDF_Document* pDoc = pSDKDoc->GetDocument()->GetPDFDoc(); | 574 CPDF_Dictionary* pDic = pDoc->GetRoot(); |
656 » » CPDF_Dictionary* pDic = pDoc->GetRoot(); | 575 if (!pDic) |
657 » » if (!pDic) | 576 return; |
658 » » » return; | 577 CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA")); |
659 » » CPDF_AAction aa = pDic->GetDict(FX_BSTRC("AA")); | 578 if(aa.ActionExist((CPDF_AAction::AActionType)aaType)) |
660 | 579 { |
661 » » if(aa.ActionExist((CPDF_AAction::AActionType)aaType)) | 580 CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType); |
662 » » { | 581 CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Environment*)hHandle)- >GetActionHander(); |
663 » » » CPDF_Action action = aa.GetAction((CPDF_AAction::AAction Type)aaType); | 582 ASSERT(pActionHandler != NULL); |
664 » » » CPDFSDK_ActionHandler *pActionHandler = ((CPDFDoc_Enviro nment*)hHandle)->GetActionHander(); | 583 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaT ype, pSDKDoc); |
665 » » » ASSERT(pActionHandler != NULL); | 584 } |
666 » » » pActionHandler->DoAction_Document(action, (CPDF_AAction: :AActionType)aaType, pSDKDoc); | 585 } |
667 » » } | 586 |
668 » } | |
669 } | |
670 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl e, int aaType) | 587 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl e, int aaType) |
671 { | 588 { |
672 » if(!hHandle || !page) | 589 if(!hHandle || !page) |
673 » » return; | 590 return; |
674 » CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentD oc(); | 591 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( ); |
675 » CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | 592 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; |
676 » CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); | 593 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); |
677 » if(pPageView) | 594 if(pPageView) |
678 » { | 595 { |
679 » » CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv(); | 596 CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv(); |
680 » » ASSERT(pEnv != NULL); | 597 CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander(); |
681 | 598 CPDF_Dictionary *pPageDict = pPage->GetPDFPage()->m_pFormDict; |
682 » » CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander(); | 599 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); |
683 » » ASSERT(pActionHandler != NULL); | 600 |
684 | 601 FX_BOOL bExistOAAction = FALSE; |
685 » » if (!pPage->GetPDFPage()) | 602 FX_BOOL bExistCAAction = FALSE; |
686 » » » return; | 603 if (FPDFPAGE_AACTION_OPEN == aaType) |
687 » » CPDF_Dictionary *pPageDict = pPage->GetPDFPage()->m_pFormDict; | 604 { |
688 » » ASSERT(pPageDict != NULL); | 605 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); |
689 | 606 if (bExistOAAction) |
690 » » CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); | 607 { |
691 | 608 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); |
692 » » FX_BOOL bExistOAAction = FALSE; | 609 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pS DKDoc); |
693 » » FX_BOOL bExistCAAction = FALSE; | 610 } |
694 » » if (FPDFPAGE_AACTION_OPEN == aaType) | 611 } |
695 » » { | 612 else |
696 » » » bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); | 613 { |
697 » » » if (bExistOAAction) | 614 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); |
698 » » » { | 615 if (bExistCAAction) |
699 » » » » CPDF_Action action = aa.GetAction(CPDF_AAction:: OpenPage); | 616 { |
700 » » » » pActionHandler->DoAction_Page(action, CPDF_AActi on::OpenPage, pSDKDoc); | 617 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
701 » » » } | 618 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, p SDKDoc); |
702 » » } | 619 } |
703 » » else | 620 } |
704 » » { | 621 } |
705 » » » bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage) ; | 622 } |
706 » » » if (bExistCAAction) | |
707 » » » { | |
708 » » » » CPDF_Action action = aa.GetAction(CPDF_AAction:: ClosePage); | |
709 » » » » pActionHandler->DoAction_Page(action, CPDF_AActi on::ClosePage, pSDKDoc); | |
710 » » » } | |
711 » » } | |
712 » } | |
713 } | |
714 | |
715 | |
OLD | NEW |