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 "fpdfsdk/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 13 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
14 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" |
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
18 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 18 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
19 #include "fpdfsdk/include/fsdk_actionhandler.h" | 19 #include "fpdfsdk/include/fsdk_actionhandler.h" |
20 #include "fpdfsdk/include/fsdk_baseannot.h" | 20 #include "fpdfsdk/include/fsdk_baseannot.h" |
21 #include "fpdfsdk/include/fsdk_define.h" | 21 #include "fpdfsdk/include/fsdk_define.h" |
22 #include "fpdfsdk/include/fsdk_mgr.h" | 22 #include "fpdfsdk/include/fsdk_mgr.h" |
23 #include "fpdfsdk/javascript/ijs_context.h" | 23 #include "fpdfsdk/javascript/ijs_context.h" |
24 #include "fpdfsdk/javascript/ijs_runtime.h" | 24 #include "fpdfsdk/javascript/ijs_runtime.h" |
25 #include "fpdfsdk/pdfwindow/PWL_Utils.h" | 25 #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
26 | 26 |
27 #ifdef PDF_ENABLE_XFA | 27 #ifdef PDF_ENABLE_XFA |
28 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 28 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
29 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" | 29 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" |
| 30 #include "xfa/include/fxfa/xfa_ffwidget.h" |
30 #endif // PDF_ENABLE_XFA | 31 #endif // PDF_ENABLE_XFA |
31 | 32 |
32 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) | 33 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) |
33 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 34 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
34 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 35 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
35 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 36 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
36 | 37 |
37 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, | 38 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, |
38 CPDFSDK_PageView* pPageView, | 39 CPDFSDK_PageView* pPageView, |
39 CPDFSDK_InterForm* pInterForm) | 40 CPDFSDK_InterForm* pInterForm) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 183 } |
183 | 184 |
184 FX_BOOL CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) { | 185 FX_BOOL CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) { |
185 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 186 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
186 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 187 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
187 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); | 188 XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); |
188 | 189 |
189 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && | 190 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && |
190 GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 191 GetFieldType() == FIELDTYPE_RADIOBUTTON) { |
191 if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { | 192 if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { |
192 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); | 193 CXFA_WidgetAcc* pAcc = hGroupWidget->GetDataAcc(); |
193 if (pXFAWidgetHandler->HasEvent(pAcc, eEventType)) | 194 if (pXFAWidgetHandler->HasEvent(pAcc, eEventType)) |
194 return TRUE; | 195 return TRUE; |
195 } | 196 } |
196 } | 197 } |
197 | 198 |
198 { | 199 { |
199 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); | 200 CXFA_WidgetAcc* pAcc = hWidget->GetDataAcc(); |
200 return pXFAWidgetHandler->HasEvent(pAcc, eEventType); | 201 return pXFAWidgetHandler->HasEvent(pAcc, eEventType); |
201 } | 202 } |
202 } | 203 } |
203 } | 204 } |
204 | 205 |
205 return FALSE; | 206 return FALSE; |
206 } | 207 } |
207 | 208 |
208 FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, | 209 FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, |
209 PDFSDK_FieldAction& data, | 210 PDFSDK_FieldAction& data, |
(...skipping 19 matching lines...) Expand all Loading... |
229 if (data.nSelEnd > data.nSelStart) | 230 if (data.nSelEnd > data.nSelStart) |
230 param.m_wsNewText.Delete(data.nSelStart, | 231 param.m_wsNewText.Delete(data.nSelStart, |
231 data.nSelEnd - data.nSelStart); | 232 data.nSelEnd - data.nSelStart); |
232 for (int i = 0; i < data.sChange.GetLength(); i++) | 233 for (int i = 0; i < data.sChange.GetLength(); i++) |
233 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); | 234 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); |
234 param.m_wsPrevText = data.sValue; | 235 param.m_wsPrevText = data.sValue; |
235 | 236 |
236 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && | 237 if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && |
237 GetFieldType() == FIELDTYPE_RADIOBUTTON) { | 238 GetFieldType() == FIELDTYPE_RADIOBUTTON) { |
238 if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { | 239 if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { |
239 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hGroupWidget); | 240 CXFA_WidgetAcc* pAcc = hGroupWidget->GetDataAcc(); |
240 param.m_pTarget = pAcc; | 241 param.m_pTarget = pAcc; |
241 if (pXFAWidgetHandler->ProcessEvent(pAcc, ¶m) != | 242 if (pXFAWidgetHandler->ProcessEvent(pAcc, ¶m) != |
242 XFA_EVENTERROR_Success) { | 243 XFA_EVENTERROR_Success) { |
243 return FALSE; | 244 return FALSE; |
244 } | 245 } |
245 } | 246 } |
246 } | 247 } |
247 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); | 248 CXFA_WidgetAcc* pAcc = hWidget->GetDataAcc(); |
248 param.m_pTarget = pAcc; | 249 param.m_pTarget = pAcc; |
249 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); | 250 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); |
250 | 251 |
251 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 252 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
252 pDocView->UpdateDocView(); | 253 pDocView->UpdateDocView(); |
253 } | 254 } |
254 return nRet == XFA_EVENTERROR_Success; | 255 return nRet == XFA_EVENTERROR_Success; |
255 } | 256 } |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 return FALSE; | 260 return FALSE; |
260 } | 261 } |
261 | 262 |
262 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { | 263 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { |
263 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 264 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
264 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 265 CPDF_FormField* pFormField = GetFormField(); |
265 CPDF_FormField* pFormField = GetFormField(); | 266 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
266 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 267 switch (GetFieldType()) { |
267 switch (GetFieldType()) { | 268 case FIELDTYPE_CHECKBOX: |
268 case FIELDTYPE_CHECKBOX: | 269 case FIELDTYPE_RADIOBUTTON: { |
269 case FIELDTYPE_RADIOBUTTON: { | 270 CPDF_FormControl* pFormCtrl = GetFormControl(); |
270 CPDF_FormControl* pFormCtrl = GetFormControl(); | 271 XFA_CHECKSTATE eCheckState = |
271 XFA_CHECKSTATE eCheckState = | 272 pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; |
272 pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; | 273 pWidgetAcc->SetCheckState(eCheckState); |
273 pWidgetAcc->SetCheckState(eCheckState); | 274 } break; |
274 } break; | 275 case FIELDTYPE_TEXTFIELD: |
275 case FIELDTYPE_TEXTFIELD: | 276 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); |
276 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); | 277 break; |
277 break; | 278 case FIELDTYPE_LISTBOX: { |
278 case FIELDTYPE_LISTBOX: { | 279 pWidgetAcc->ClearAllSelections(); |
279 pWidgetAcc->ClearAllSelections(); | |
280 | 280 |
281 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; | 281 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
282 i++) { | 282 int nIndex = pFormField->GetSelectedIndex(i); |
283 int nIndex = pFormField->GetSelectedIndex(i); | 283 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) |
284 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) | 284 pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); |
285 pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); | 285 } |
286 } | 286 } break; |
287 } break; | 287 case FIELDTYPE_COMBOBOX: { |
288 case FIELDTYPE_COMBOBOX: { | 288 pWidgetAcc->ClearAllSelections(); |
289 pWidgetAcc->ClearAllSelections(); | |
290 | 289 |
291 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; | 290 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
292 i++) { | 291 int nIndex = pFormField->GetSelectedIndex(i); |
293 int nIndex = pFormField->GetSelectedIndex(i); | 292 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) |
294 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) | 293 pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); |
295 pWidgetAcc->SetItemState(nIndex, TRUE, FALSE); | |
296 } | |
297 } | 294 } |
298 | |
299 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); | |
300 break; | |
301 } | 295 } |
302 | 296 |
303 if (bSynchronizeElse) | 297 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); |
304 pWidgetAcc->ProcessValueChanged(); | 298 break; |
305 } | 299 } |
| 300 |
| 301 if (bSynchronizeElse) |
| 302 pWidgetAcc->ProcessValueChanged(); |
306 } | 303 } |
307 } | 304 } |
308 } | 305 } |
309 | 306 |
310 void CPDFSDK_Widget::SynchronizeXFAValue() { | 307 void CPDFSDK_Widget::SynchronizeXFAValue() { |
311 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 308 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
312 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 309 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
313 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); | 310 CXFA_FFDocView* pXFADocView = pDoc->GetXFADocView(); |
314 if (!pXFADocView) | 311 if (!pXFADocView) |
315 return; | 312 return; |
(...skipping 17 matching lines...) Expand all Loading... |
333 if (GetXFAWidgetHandler()) | 330 if (GetXFAWidgetHandler()) |
334 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); | 331 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); |
335 } | 332 } |
336 } | 333 } |
337 | 334 |
338 void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, | 335 void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, |
339 CXFA_FFWidget* hWidget, | 336 CXFA_FFWidget* hWidget, |
340 CPDF_FormField* pFormField, | 337 CPDF_FormField* pFormField, |
341 CPDF_FormControl* pFormControl) { | 338 CPDF_FormControl* pFormControl) { |
342 ASSERT(hWidget); | 339 ASSERT(hWidget); |
| 340 ASSERT(pFormControl); |
343 | 341 |
344 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = | 342 switch (pFormField->GetFieldType()) { |
345 pXFADocView->GetWidgetHandler()) { | 343 case FIELDTYPE_CHECKBOX: { |
346 ASSERT(pFormControl); | 344 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
| 345 pFormField->CheckControl( |
| 346 pFormField->GetControlIndex(pFormControl), |
| 347 pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); |
| 348 } |
| 349 } break; |
| 350 case FIELDTYPE_RADIOBUTTON: { |
| 351 // TODO(weili): Check whether we need to handle checkbox and radio |
| 352 // button differently, otherwise, merge these two cases. |
| 353 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
| 354 pFormField->CheckControl( |
| 355 pFormField->GetControlIndex(pFormControl), |
| 356 pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); |
| 357 } |
| 358 } break; |
| 359 case FIELDTYPE_TEXTFIELD: { |
| 360 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
| 361 CFX_WideString sValue; |
| 362 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); |
| 363 pFormField->SetValue(sValue, TRUE); |
| 364 } |
| 365 } break; |
| 366 case FIELDTYPE_LISTBOX: { |
| 367 pFormField->ClearSelection(FALSE); |
347 | 368 |
348 switch (pFormField->GetFieldType()) { | 369 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
349 case FIELDTYPE_CHECKBOX: { | 370 for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { |
350 if (CXFA_WidgetAcc* pWidgetAcc = | 371 int nIndex = pWidgetAcc->GetSelectedItem(i); |
351 pXFAWidgetHandler->GetDataAcc(hWidget)) { | |
352 pFormField->CheckControl( | |
353 pFormField->GetControlIndex(pFormControl), | |
354 pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); | |
355 } | |
356 } break; | |
357 case FIELDTYPE_RADIOBUTTON: { | |
358 // TODO(weili): Check whether we need to handle checkbox and radio | |
359 // button differently, otherwise, merge these two cases. | |
360 if (CXFA_WidgetAcc* pWidgetAcc = | |
361 pXFAWidgetHandler->GetDataAcc(hWidget)) { | |
362 pFormField->CheckControl( | |
363 pFormField->GetControlIndex(pFormControl), | |
364 pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On, true); | |
365 } | |
366 } break; | |
367 case FIELDTYPE_TEXTFIELD: { | |
368 if (CXFA_WidgetAcc* pWidgetAcc = | |
369 pXFAWidgetHandler->GetDataAcc(hWidget)) { | |
370 CFX_WideString sValue; | |
371 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); | |
372 pFormField->SetValue(sValue, TRUE); | |
373 } | |
374 } break; | |
375 case FIELDTYPE_LISTBOX: { | |
376 pFormField->ClearSelection(FALSE); | |
377 | 372 |
378 if (CXFA_WidgetAcc* pWidgetAcc = | 373 if (nIndex > -1 && nIndex < pFormField->CountOptions()) { |
379 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 374 pFormField->SetItemSelection(nIndex, TRUE, TRUE); |
380 for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { | |
381 int nIndex = pWidgetAcc->GetSelectedItem(i); | |
382 | |
383 if (nIndex > -1 && nIndex < pFormField->CountOptions()) { | |
384 pFormField->SetItemSelection(nIndex, TRUE, TRUE); | |
385 } | |
386 } | 375 } |
387 } | 376 } |
388 } break; | 377 } |
389 case FIELDTYPE_COMBOBOX: { | 378 } break; |
390 pFormField->ClearSelection(FALSE); | 379 case FIELDTYPE_COMBOBOX: { |
| 380 pFormField->ClearSelection(FALSE); |
391 | 381 |
392 if (CXFA_WidgetAcc* pWidgetAcc = | 382 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
393 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 383 for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { |
394 for (int i = 0, sz = pWidgetAcc->CountSelectedItems(); i < sz; i++) { | 384 int nIndex = pWidgetAcc->GetSelectedItem(i); |
395 int nIndex = pWidgetAcc->GetSelectedItem(i); | |
396 | 385 |
397 if (nIndex > -1 && nIndex < pFormField->CountOptions()) { | 386 if (nIndex > -1 && nIndex < pFormField->CountOptions()) { |
398 pFormField->SetItemSelection(nIndex, TRUE, TRUE); | 387 pFormField->SetItemSelection(nIndex, TRUE, TRUE); |
399 } | |
400 } | 388 } |
| 389 } |
401 | 390 |
402 CFX_WideString sValue; | 391 CFX_WideString sValue; |
403 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); | 392 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); |
404 pFormField->SetValue(sValue, TRUE); | 393 pFormField->SetValue(sValue, TRUE); |
405 } | 394 } |
406 } break; | 395 } break; |
407 } | |
408 } | 396 } |
409 } | 397 } |
410 | 398 |
411 void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, | 399 void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, |
412 CXFA_FFWidget* hWidget, | 400 CXFA_FFWidget* hWidget, |
413 CPDF_FormField* pFormField, | 401 CPDF_FormField* pFormField, |
414 CPDF_FormControl* pFormControl) { | 402 CPDF_FormControl* pFormControl) { |
415 ASSERT(hWidget); | 403 ASSERT(hWidget); |
416 | 404 |
417 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = | 405 switch (pFormField->GetFieldType()) { |
418 pXFADocView->GetWidgetHandler()) { | 406 case FIELDTYPE_LISTBOX: { |
419 switch (pFormField->GetFieldType()) { | 407 pFormField->ClearSelection(FALSE); |
420 case FIELDTYPE_LISTBOX: { | 408 pFormField->ClearOptions(TRUE); |
421 pFormField->ClearSelection(FALSE); | |
422 pFormField->ClearOptions(TRUE); | |
423 | 409 |
424 if (CXFA_WidgetAcc* pWidgetAcc = | 410 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
425 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 411 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; i++) { |
426 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; | 412 CFX_WideString swText; |
427 i++) { | 413 pWidgetAcc->GetChoiceListItem(swText, i); |
428 CFX_WideString swText; | |
429 pWidgetAcc->GetChoiceListItem(swText, i); | |
430 | 414 |
431 pFormField->InsertOption(swText, i, TRUE); | 415 pFormField->InsertOption(swText, i, TRUE); |
432 } | |
433 } | 416 } |
434 } break; | 417 } |
435 case FIELDTYPE_COMBOBOX: { | 418 } break; |
436 pFormField->ClearSelection(FALSE); | 419 case FIELDTYPE_COMBOBOX: { |
437 pFormField->ClearOptions(FALSE); | 420 pFormField->ClearSelection(FALSE); |
| 421 pFormField->ClearOptions(FALSE); |
438 | 422 |
439 if (CXFA_WidgetAcc* pWidgetAcc = | 423 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
440 pXFAWidgetHandler->GetDataAcc(hWidget)) { | 424 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; i++) { |
441 for (int i = 0, sz = pWidgetAcc->CountChoiceListItems(); i < sz; | 425 CFX_WideString swText; |
442 i++) { | 426 pWidgetAcc->GetChoiceListItem(swText, i); |
443 CFX_WideString swText; | |
444 pWidgetAcc->GetChoiceListItem(swText, i); | |
445 | 427 |
446 pFormField->InsertOption(swText, i, FALSE); | 428 pFormField->InsertOption(swText, i, FALSE); |
447 } | |
448 } | 429 } |
| 430 } |
449 | 431 |
450 pFormField->SetValue(L"", TRUE); | 432 pFormField->SetValue(L"", TRUE); |
451 } break; | 433 } break; |
452 } | |
453 } | 434 } |
454 } | 435 } |
455 #endif // PDF_ENABLE_XFA | 436 #endif // PDF_ENABLE_XFA |
456 | 437 |
457 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( | 438 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( |
458 CPDF_Annot::AppearanceMode mode) { | 439 CPDF_Annot::AppearanceMode mode) { |
459 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 440 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); |
460 if (!pAP) | 441 if (!pAP) |
461 return FALSE; | 442 return FALSE; |
462 | 443 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 CFX_ByteString csFont = ""; | 569 CFX_ByteString csFont = ""; |
589 FX_FLOAT fFontSize = 0.0f; | 570 FX_FLOAT fFontSize = 0.0f; |
590 pDa.GetFont(csFont, fFontSize); | 571 pDa.GetFont(csFont, fFontSize); |
591 | 572 |
592 return fFontSize; | 573 return fFontSize; |
593 } | 574 } |
594 | 575 |
595 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { | 576 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { |
596 #ifdef PDF_ENABLE_XFA | 577 #ifdef PDF_ENABLE_XFA |
597 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 578 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
598 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 579 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
599 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 580 if (nIndex < pWidgetAcc->CountSelectedItems()) |
600 if (nIndex < pWidgetAcc->CountSelectedItems()) | 581 return pWidgetAcc->GetSelectedItem(nIndex); |
601 return pWidgetAcc->GetSelectedItem(nIndex); | |
602 } | |
603 } | 582 } |
604 } | 583 } |
605 #endif // PDF_ENABLE_XFA | 584 #endif // PDF_ENABLE_XFA |
606 CPDF_FormField* pFormField = GetFormField(); | 585 CPDF_FormField* pFormField = GetFormField(); |
607 return pFormField->GetSelectedIndex(nIndex); | 586 return pFormField->GetSelectedIndex(nIndex); |
608 } | 587 } |
609 | 588 |
610 #ifdef PDF_ENABLE_XFA | 589 #ifdef PDF_ENABLE_XFA |
611 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { | 590 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { |
612 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 591 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
613 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 592 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
614 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 593 CFX_WideString sValue; |
615 CFX_WideString sValue; | 594 pWidgetAcc->GetValue( |
616 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display | 595 sValue, bDisplay ? XFA_VALUEPICTURE_Display : XFA_VALUEPICTURE_Edit); |
617 : XFA_VALUEPICTURE_Edit); | 596 return sValue; |
618 return sValue; | |
619 } | |
620 } | 597 } |
621 } | 598 } |
622 #else | 599 #else |
623 CFX_WideString CPDFSDK_Widget::GetValue() const { | 600 CFX_WideString CPDFSDK_Widget::GetValue() const { |
624 #endif // PDF_ENABLE_XFA | 601 #endif // PDF_ENABLE_XFA |
625 CPDF_FormField* pFormField = GetFormField(); | 602 CPDF_FormField* pFormField = GetFormField(); |
626 return pFormField->GetValue(); | 603 return pFormField->GetValue(); |
627 } | 604 } |
628 | 605 |
629 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { | 606 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { |
630 CPDF_FormField* pFormField = GetFormField(); | 607 CPDF_FormField* pFormField = GetFormField(); |
631 return pFormField->GetDefaultValue(); | 608 return pFormField->GetDefaultValue(); |
632 } | 609 } |
633 | 610 |
634 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { | 611 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { |
635 CPDF_FormField* pFormField = GetFormField(); | 612 CPDF_FormField* pFormField = GetFormField(); |
636 return pFormField->GetOptionLabel(nIndex); | 613 return pFormField->GetOptionLabel(nIndex); |
637 } | 614 } |
638 | 615 |
639 int CPDFSDK_Widget::CountOptions() const { | 616 int CPDFSDK_Widget::CountOptions() const { |
640 CPDF_FormField* pFormField = GetFormField(); | 617 CPDF_FormField* pFormField = GetFormField(); |
641 return pFormField->CountOptions(); | 618 return pFormField->CountOptions(); |
642 } | 619 } |
643 | 620 |
644 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { | 621 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { |
645 #ifdef PDF_ENABLE_XFA | 622 #ifdef PDF_ENABLE_XFA |
646 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 623 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
647 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 624 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) { |
648 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 625 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) |
649 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) | 626 return pWidgetAcc->GetItemState(nIndex); |
650 return pWidgetAcc->GetItemState(nIndex); | |
651 | 627 |
652 return FALSE; | 628 return FALSE; |
653 } | |
654 } | 629 } |
655 } | 630 } |
656 #endif // PDF_ENABLE_XFA | 631 #endif // PDF_ENABLE_XFA |
657 CPDF_FormField* pFormField = GetFormField(); | 632 CPDF_FormField* pFormField = GetFormField(); |
658 return pFormField->IsItemSelected(nIndex); | 633 return pFormField->IsItemSelected(nIndex); |
659 } | 634 } |
660 | 635 |
661 int CPDFSDK_Widget::GetTopVisibleIndex() const { | 636 int CPDFSDK_Widget::GetTopVisibleIndex() const { |
662 CPDF_FormField* pFormField = GetFormField(); | 637 CPDF_FormField* pFormField = GetFormField(); |
663 return pFormField->GetTopVisibleIndex(); | 638 return pFormField->GetTopVisibleIndex(); |
664 } | 639 } |
665 | 640 |
666 bool CPDFSDK_Widget::IsChecked() const { | 641 bool CPDFSDK_Widget::IsChecked() const { |
667 #ifdef PDF_ENABLE_XFA | 642 #ifdef PDF_ENABLE_XFA |
668 if (CXFA_FFWidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 643 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { |
669 if (CXFA_FFWidget* hWidget = GetMixXFAWidget()) { | 644 if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc()) |
670 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) | 645 return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; |
671 return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; | |
672 } | |
673 } | 646 } |
674 #endif // PDF_ENABLE_XFA | 647 #endif // PDF_ENABLE_XFA |
675 CPDF_FormControl* pFormCtrl = GetFormControl(); | 648 CPDF_FormControl* pFormCtrl = GetFormControl(); |
676 return pFormCtrl->IsChecked(); | 649 return pFormCtrl->IsChecked(); |
677 } | 650 } |
678 | 651 |
679 int CPDFSDK_Widget::GetAlignment() const { | 652 int CPDFSDK_Widget::GetAlignment() const { |
680 CPDF_FormControl* pFormCtrl = GetFormControl(); | 653 CPDF_FormControl* pFormCtrl = GetFormControl(); |
681 return pFormCtrl->GetControlAlignment(); | 654 return pFormCtrl->GetControlAlignment(); |
682 } | 655 } |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 param.m_bKeyDown = data.bKeyDown; | 1866 param.m_bKeyDown = data.bKeyDown; |
1894 param.m_bModifier = data.bModifier; | 1867 param.m_bModifier = data.bModifier; |
1895 param.m_wsNewText = data.sValue; | 1868 param.m_wsNewText = data.sValue; |
1896 if (data.nSelEnd > data.nSelStart) | 1869 if (data.nSelEnd > data.nSelStart) |
1897 param.m_wsNewText.Delete(data.nSelStart, | 1870 param.m_wsNewText.Delete(data.nSelStart, |
1898 data.nSelEnd - data.nSelStart); | 1871 data.nSelEnd - data.nSelStart); |
1899 for (int i = data.sChange.GetLength() - 1; i >= 0; i--) | 1872 for (int i = data.sChange.GetLength() - 1; i >= 0; i--) |
1900 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); | 1873 param.m_wsNewText.Insert(data.nSelStart, data.sChange[i]); |
1901 param.m_wsPrevText = data.sValue; | 1874 param.m_wsPrevText = data.sValue; |
1902 | 1875 |
1903 CXFA_WidgetAcc* pAcc = pXFAWidgetHandler->GetDataAcc(hWidget); | 1876 CXFA_WidgetAcc* pAcc = hWidget->GetDataAcc(); |
1904 param.m_pTarget = pAcc; | 1877 param.m_pTarget = pAcc; |
1905 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); | 1878 int32_t nRet = pXFAWidgetHandler->ProcessEvent(pAcc, ¶m); |
1906 | 1879 |
1907 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { | 1880 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { |
1908 pDocView->UpdateDocView(); | 1881 pDocView->UpdateDocView(); |
1909 } | 1882 } |
1910 | 1883 |
1911 if (nRet == XFA_EVENTERROR_Success) | 1884 if (nRet == XFA_EVENTERROR_Success) |
1912 return TRUE; | 1885 return TRUE; |
1913 } | 1886 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 | 1967 |
1995 FX_BOOL CPDFSDK_XFAWidget::IsXFAField() { | 1968 FX_BOOL CPDFSDK_XFAWidget::IsXFAField() { |
1996 return TRUE; | 1969 return TRUE; |
1997 } | 1970 } |
1998 | 1971 |
1999 CFX_ByteString CPDFSDK_XFAWidget::GetType() const { | 1972 CFX_ByteString CPDFSDK_XFAWidget::GetType() const { |
2000 return FSDK_XFAWIDGET_TYPENAME; | 1973 return FSDK_XFAWIDGET_TYPENAME; |
2001 } | 1974 } |
2002 | 1975 |
2003 CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { | 1976 CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { |
2004 CPDFSDK_PageView* pPageView = GetPageView(); | |
2005 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | |
2006 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | |
2007 CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); | |
2008 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); | |
2009 | |
2010 CFX_RectF rcBBox; | 1977 CFX_RectF rcBBox; |
2011 pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); | 1978 GetXFAWidget()->GetRect(rcBBox); |
2012 | |
2013 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, | 1979 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
2014 rcBBox.top + rcBBox.height); | 1980 rcBBox.top + rcBBox.height); |
2015 } | 1981 } |
2016 #endif // PDF_ENABLE_XFA | 1982 #endif // PDF_ENABLE_XFA |
2017 | 1983 |
2018 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) | 1984 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) |
2019 : m_pDocument(pDocument), | 1985 : m_pDocument(pDocument), |
2020 m_pInterForm(NULL), | 1986 m_pInterForm(NULL), |
2021 #ifdef PDF_ENABLE_XFA | 1987 #ifdef PDF_ENABLE_XFA |
2022 m_bXfaCalculate(TRUE), | 1988 m_bXfaCalculate(TRUE), |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 break; | 2829 break; |
2864 } | 2830 } |
2865 } | 2831 } |
2866 } | 2832 } |
2867 | 2833 |
2868 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2834 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
2869 CFX_FloatRect rcAnnot; | 2835 CFX_FloatRect rcAnnot; |
2870 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2836 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
2871 return rcAnnot; | 2837 return rcAnnot; |
2872 } | 2838 } |
OLD | NEW |