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 #ifdef PDF_ENABLE_XFA | |
8 #include "../include/fpdfxfa/fpdfxfa_doc.h" | |
9 #include "../include/fpdfxfa/fpdfxfa_util.h" | |
10 #endif | |
11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 7 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
12 #include "fpdfsdk/include/fsdk_actionhandler.h" | 8 #include "fpdfsdk/include/fsdk_actionhandler.h" |
13 #include "fpdfsdk/include/fsdk_baseannot.h" | 9 #include "fpdfsdk/include/fsdk_baseannot.h" |
14 #include "fpdfsdk/include/fsdk_baseform.h" | 10 #include "fpdfsdk/include/fsdk_baseform.h" |
15 #include "fpdfsdk/include/fsdk_define.h" | 11 #include "fpdfsdk/include/fsdk_define.h" |
16 #include "fpdfsdk/include/fsdk_mgr.h" | 12 #include "fpdfsdk/include/fsdk_mgr.h" |
17 #include "fpdfsdk/include/javascript/IJavaScript.h" | 13 #include "fpdfsdk/include/javascript/IJavaScript.h" |
18 #include "third_party/base/nonstd_unique_ptr.h" | 14 #include "third_party/base/nonstd_unique_ptr.h" |
19 | 15 |
| 16 #ifdef PDF_ENABLE_XFA |
| 17 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 18 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 19 #endif // PDF_ENABLE_XFA |
| 20 |
20 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) | 21 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) |
21 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 22 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
22 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 23 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
23 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 24 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
24 | 25 |
25 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, | 26 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, |
26 CPDFSDK_PageView* pPageView, | 27 CPDFSDK_PageView* pPageView, |
27 CPDFSDK_InterForm* pInterForm) | 28 CPDFSDK_InterForm* pInterForm) |
28 : CPDFSDK_BAAnnot(pAnnot, pPageView), | 29 : CPDFSDK_BAAnnot(pAnnot, pPageView), |
29 m_pInterForm(pInterForm), | 30 m_pInterForm(pInterForm), |
30 m_nAppAge(0), | 31 m_nAppAge(0), |
31 #ifndef PDF_ENABLE_XFA | 32 m_nValueAge(0) |
32 m_nValueAge(0) { | 33 #ifdef PDF_ENABLE_XFA |
33 #else | 34 , |
34 m_nValueAge(0), | |
35 m_hMixXFAWidget(NULL), | 35 m_hMixXFAWidget(NULL), |
36 m_pWidgetHandler(NULL) { | 36 m_pWidgetHandler(NULL) |
37 #endif | 37 #endif // PDF_ENABLE_XFA |
38 ASSERT(m_pInterForm != NULL); | 38 { |
39 } | 39 } |
40 | 40 |
41 CPDFSDK_Widget::~CPDFSDK_Widget() {} | 41 CPDFSDK_Widget::~CPDFSDK_Widget() {} |
42 | 42 |
43 #ifdef PDF_ENABLE_XFA | 43 #ifdef PDF_ENABLE_XFA |
44 IXFA_Widget* CPDFSDK_Widget::GetMixXFAWidget() const { | 44 IXFA_Widget* CPDFSDK_Widget::GetMixXFAWidget() const { |
45 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 45 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
46 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 46 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
47 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 47 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
48 if (!m_hMixXFAWidget) { | 48 if (!m_hMixXFAWidget) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 pDocView->UpdateDocView(); | 246 pDocView->UpdateDocView(); |
247 } | 247 } |
248 } | 248 } |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 return FALSE; | 252 return FALSE; |
253 } | 253 } |
254 | 254 |
255 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { | 255 void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { |
256 #ifdef PDF_ENABLE_XFA | |
257 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 256 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
258 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 257 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
259 CPDF_FormField* pFormField = GetFormField(); | 258 CPDF_FormField* pFormField = GetFormField(); |
260 ASSERT(pFormField != NULL); | 259 ASSERT(pFormField != NULL); |
261 | 260 |
262 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 261 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
263 switch (GetFieldType()) { | 262 switch (GetFieldType()) { |
264 case FIELDTYPE_CHECKBOX: | 263 case FIELDTYPE_CHECKBOX: |
265 case FIELDTYPE_RADIOBUTTON: { | 264 case FIELDTYPE_RADIOBUTTON: { |
266 CPDF_FormControl* pFormCtrl = GetFormControl(); | 265 CPDF_FormControl* pFormCtrl = GetFormControl(); |
(...skipping 29 matching lines...) Expand all Loading... |
296 | 295 |
297 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); | 296 pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit); |
298 break; | 297 break; |
299 } | 298 } |
300 | 299 |
301 if (bSynchronizeElse) | 300 if (bSynchronizeElse) |
302 pWidgetAcc->ProcessValueChanged(); | 301 pWidgetAcc->ProcessValueChanged(); |
303 } | 302 } |
304 } | 303 } |
305 } | 304 } |
306 #endif // PDF_ENABLE_XFA | |
307 } | 305 } |
308 | 306 |
309 void CPDFSDK_Widget::SynchronizeXFAValue() { | 307 void CPDFSDK_Widget::SynchronizeXFAValue() { |
310 #ifdef PDF_ENABLE_XFA | |
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 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); | 310 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); |
314 if (!pXFADocView) | 311 if (!pXFADocView) |
315 return; | 312 return; |
316 | 313 |
317 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 314 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { |
318 if (GetXFAWidgetHandler()) { | 315 if (GetXFAWidgetHandler()) { |
319 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, GetFormField(), | 316 CPDFSDK_Widget::SynchronizeXFAValue(pXFADocView, hWidget, GetFormField(), |
320 GetFormControl()); | 317 GetFormControl()); |
321 } | 318 } |
322 } | 319 } |
323 #endif // PDF_ENABLE_XFA | |
324 } | 320 } |
325 | 321 |
326 void CPDFSDK_Widget::SynchronizeXFAItems() { | 322 void CPDFSDK_Widget::SynchronizeXFAItems() { |
327 #ifdef PDF_ENABLE_XFA | |
328 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 323 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
329 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 324 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
330 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); | 325 IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); |
331 if (!pXFADocView) | 326 if (!pXFADocView) |
332 return; | 327 return; |
333 | 328 |
334 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 329 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { |
335 if (GetXFAWidgetHandler()) | 330 if (GetXFAWidgetHandler()) |
336 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); | 331 SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); |
337 } | 332 } |
338 #endif // PDF_ENABLE_XFA | |
339 } | 333 } |
340 | 334 |
341 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, | 335 void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView, |
342 IXFA_Widget* hWidget, | 336 IXFA_Widget* hWidget, |
343 CPDF_FormField* pFormField, | 337 CPDF_FormField* pFormField, |
344 CPDF_FormControl* pFormControl) { | 338 CPDF_FormControl* pFormControl) { |
345 #ifdef PDF_ENABLE_XFA | |
346 ASSERT(pXFADocView != NULL); | 339 ASSERT(pXFADocView != NULL); |
347 ASSERT(hWidget != NULL); | 340 ASSERT(hWidget != NULL); |
348 | 341 |
349 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { | 342 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { |
350 ASSERT(pFormField != NULL); | 343 ASSERT(pFormField != NULL); |
351 ASSERT(pFormControl != NULL); | 344 ASSERT(pFormControl != NULL); |
352 | 345 |
353 switch (pFormField->GetFieldType()) { | 346 switch (pFormField->GetFieldType()) { |
354 case FIELDTYPE_CHECKBOX: { | 347 case FIELDTYPE_CHECKBOX: { |
355 if (CXFA_WidgetAcc* pWidgetAcc = | 348 if (CXFA_WidgetAcc* pWidgetAcc = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 397 } |
405 } | 398 } |
406 | 399 |
407 CFX_WideString sValue; | 400 CFX_WideString sValue; |
408 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); | 401 pWidgetAcc->GetValue(sValue, XFA_VALUEPICTURE_Display); |
409 pFormField->SetValue(sValue, TRUE); | 402 pFormField->SetValue(sValue, TRUE); |
410 } | 403 } |
411 } break; | 404 } break; |
412 } | 405 } |
413 } | 406 } |
414 #endif // PDF_ENABLE_XFA | |
415 } | 407 } |
416 | 408 |
417 void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, | 409 void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, |
418 IXFA_Widget* hWidget, | 410 IXFA_Widget* hWidget, |
419 CPDF_FormField* pFormField, | 411 CPDF_FormField* pFormField, |
420 CPDF_FormControl* pFormControl) { | 412 CPDF_FormControl* pFormControl) { |
421 #ifdef PDF_ENABLE_XFA | |
422 ASSERT(pXFADocView != NULL); | 413 ASSERT(pXFADocView != NULL); |
423 ASSERT(hWidget != NULL); | 414 ASSERT(hWidget != NULL); |
424 | 415 |
425 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { | 416 if (IXFA_WidgetHandler* pXFAWidgetHandler = pXFADocView->GetWidgetHandler()) { |
426 ASSERT(pFormField != NULL); | 417 ASSERT(pFormField != NULL); |
427 | 418 |
428 switch (pFormField->GetFieldType()) { | 419 switch (pFormField->GetFieldType()) { |
429 case FIELDTYPE_LISTBOX: { | 420 case FIELDTYPE_LISTBOX: { |
430 pFormField->ClearSelection(FALSE); | 421 pFormField->ClearSelection(FALSE); |
431 pFormField->ClearOptions(TRUE); | 422 pFormField->ClearOptions(TRUE); |
(...skipping 21 matching lines...) Expand all Loading... |
453 pWidgetAcc->GetChoiceListItem(swText, i); | 444 pWidgetAcc->GetChoiceListItem(swText, i); |
454 | 445 |
455 pFormField->InsertOption(swText, i, FALSE); | 446 pFormField->InsertOption(swText, i, FALSE); |
456 } | 447 } |
457 } | 448 } |
458 | 449 |
459 pFormField->SetValue(L"", TRUE); | 450 pFormField->SetValue(L"", TRUE); |
460 } break; | 451 } break; |
461 } | 452 } |
462 } | 453 } |
| 454 } |
463 #endif // PDF_ENABLE_XFA | 455 #endif // PDF_ENABLE_XFA |
464 } | |
465 | 456 |
466 #endif | |
467 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( | 457 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( |
468 CPDF_Annot::AppearanceMode mode) { | 458 CPDF_Annot::AppearanceMode mode) { |
469 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); | 459 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
470 if (!pAP) | 460 if (!pAP) |
471 return FALSE; | 461 return FALSE; |
472 | 462 |
473 // Choose the right sub-ap | 463 // Choose the right sub-ap |
474 const FX_CHAR* ap_entry = "N"; | 464 const FX_CHAR* ap_entry = "N"; |
475 if (mode == CPDF_Annot::Down) | 465 if (mode == CPDF_Annot::Down) |
476 ap_entry = "D"; | 466 ap_entry = "D"; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 return pField->GetFieldType(); | 499 return pField->GetFieldType(); |
510 } | 500 } |
511 | 501 |
512 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { | 502 FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { |
513 #ifdef PDF_ENABLE_XFA | 503 #ifdef PDF_ENABLE_XFA |
514 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); | 504 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); |
515 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 505 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
516 int nDocType = pDoc->GetDocType(); | 506 int nDocType = pDoc->GetDocType(); |
517 if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) | 507 if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) |
518 return TRUE; | 508 return TRUE; |
519 | 509 #endif // PDF_ENABLE_XFA |
520 #endif | |
521 return CPDFSDK_BAAnnot::IsAppearanceValid(); | 510 return CPDFSDK_BAAnnot::IsAppearanceValid(); |
522 } | 511 } |
523 | 512 |
524 int CPDFSDK_Widget::GetFieldFlags() const { | 513 int CPDFSDK_Widget::GetFieldFlags() const { |
525 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 514 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
526 ASSERT(pPDFInterForm != NULL); | 515 ASSERT(pPDFInterForm != NULL); |
527 | 516 |
528 CPDF_FormControl* pFormControl = | 517 CPDF_FormControl* pFormControl = |
529 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); | 518 pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); |
530 CPDF_FormField* pFormField = pFormControl->GetField(); | 519 CPDF_FormField* pFormField = pFormControl->GetField(); |
(...skipping 27 matching lines...) Expand all Loading... |
558 int CPDFSDK_Widget::GetRotate() const { | 547 int CPDFSDK_Widget::GetRotate() const { |
559 CPDF_FormControl* pCtrl = GetFormControl(); | 548 CPDF_FormControl* pCtrl = GetFormControl(); |
560 return pCtrl->GetRotation() % 360; | 549 return pCtrl->GetRotation() % 360; |
561 } | 550 } |
562 | 551 |
563 #ifdef PDF_ENABLE_XFA | 552 #ifdef PDF_ENABLE_XFA |
564 CFX_WideString CPDFSDK_Widget::GetName() const { | 553 CFX_WideString CPDFSDK_Widget::GetName() const { |
565 CPDF_FormField* pFormField = GetFormField(); | 554 CPDF_FormField* pFormField = GetFormField(); |
566 return pFormField->GetFullName(); | 555 return pFormField->GetFullName(); |
567 } | 556 } |
| 557 #endif // PDF_ENABLE_XFA |
568 | 558 |
569 #endif | |
570 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { | 559 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { |
571 CPDF_FormControl* pFormCtrl = GetFormControl(); | 560 CPDF_FormControl* pFormCtrl = GetFormControl(); |
572 ASSERT(pFormCtrl != NULL); | 561 ASSERT(pFormCtrl != NULL); |
573 | 562 |
574 int iColorType = 0; | 563 int iColorType = 0; |
575 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); | 564 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); |
576 | 565 |
577 return iColorType != COLORTYPE_TRANSPARENT; | 566 return iColorType != COLORTYPE_TRANSPARENT; |
578 } | 567 } |
579 | 568 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 600 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
612 CFX_ByteString csFont = ""; | 601 CFX_ByteString csFont = ""; |
613 FX_FLOAT fFontSize = 0.0f; | 602 FX_FLOAT fFontSize = 0.0f; |
614 pDa.GetFont(csFont, fFontSize); | 603 pDa.GetFont(csFont, fFontSize); |
615 | 604 |
616 return fFontSize; | 605 return fFontSize; |
617 } | 606 } |
618 | 607 |
619 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { | 608 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { |
620 #ifdef PDF_ENABLE_XFA | 609 #ifdef PDF_ENABLE_XFA |
621 #ifdef PDF_ENABLE_XFA | |
622 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 610 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
623 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 611 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
624 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 612 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
625 if (nIndex < pWidgetAcc->CountSelectedItems()) | 613 if (nIndex < pWidgetAcc->CountSelectedItems()) |
626 return pWidgetAcc->GetSelectedItem(nIndex); | 614 return pWidgetAcc->GetSelectedItem(nIndex); |
627 } | 615 } |
628 } | 616 } |
629 } | 617 } |
630 #endif // PDF_ENABLE_XFA | 618 #endif // PDF_ENABLE_XFA |
631 | |
632 #endif | |
633 CPDF_FormField* pFormField = GetFormField(); | 619 CPDF_FormField* pFormField = GetFormField(); |
634 return pFormField->GetSelectedIndex(nIndex); | 620 return pFormField->GetSelectedIndex(nIndex); |
635 } | 621 } |
636 | 622 |
637 #ifndef PDF_ENABLE_XFA | 623 #ifdef PDF_ENABLE_XFA |
638 CFX_WideString CPDFSDK_Widget::GetValue() const { | |
639 #else | |
640 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { | 624 CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { |
641 #ifdef PDF_ENABLE_XFA | |
642 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 625 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
643 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 626 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
644 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 627 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
645 CFX_WideString sValue; | 628 CFX_WideString sValue; |
646 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display | 629 pWidgetAcc->GetValue(sValue, bDisplay ? XFA_VALUEPICTURE_Display |
647 : XFA_VALUEPICTURE_Edit); | 630 : XFA_VALUEPICTURE_Edit); |
648 return sValue; | 631 return sValue; |
649 } | 632 } |
650 } | 633 } |
651 } | 634 } |
| 635 #else |
| 636 CFX_WideString CPDFSDK_Widget::GetValue() const { |
652 #endif // PDF_ENABLE_XFA | 637 #endif // PDF_ENABLE_XFA |
653 | |
654 #endif | |
655 CPDF_FormField* pFormField = GetFormField(); | 638 CPDF_FormField* pFormField = GetFormField(); |
656 return pFormField->GetValue(); | 639 return pFormField->GetValue(); |
657 } | 640 } |
658 | 641 |
659 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { | 642 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { |
660 CPDF_FormField* pFormField = GetFormField(); | 643 CPDF_FormField* pFormField = GetFormField(); |
661 ASSERT(pFormField != NULL); | 644 ASSERT(pFormField != NULL); |
662 | 645 |
663 return pFormField->GetDefaultValue(); | 646 return pFormField->GetDefaultValue(); |
664 } | 647 } |
665 | 648 |
666 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { | 649 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { |
667 CPDF_FormField* pFormField = GetFormField(); | 650 CPDF_FormField* pFormField = GetFormField(); |
668 ASSERT(pFormField != NULL); | 651 ASSERT(pFormField != NULL); |
669 | 652 |
670 return pFormField->GetOptionLabel(nIndex); | 653 return pFormField->GetOptionLabel(nIndex); |
671 } | 654 } |
672 | 655 |
673 int CPDFSDK_Widget::CountOptions() const { | 656 int CPDFSDK_Widget::CountOptions() const { |
674 CPDF_FormField* pFormField = GetFormField(); | 657 CPDF_FormField* pFormField = GetFormField(); |
675 ASSERT(pFormField != NULL); | 658 ASSERT(pFormField != NULL); |
676 | 659 |
677 return pFormField->CountOptions(); | 660 return pFormField->CountOptions(); |
678 } | 661 } |
679 | 662 |
680 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { | 663 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { |
681 #ifdef PDF_ENABLE_XFA | 664 #ifdef PDF_ENABLE_XFA |
682 #ifdef PDF_ENABLE_XFA | |
683 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 665 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
684 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 666 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
685 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 667 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
686 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) | 668 if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems()) |
687 return pWidgetAcc->GetItemState(nIndex); | 669 return pWidgetAcc->GetItemState(nIndex); |
688 | 670 |
689 return FALSE; | 671 return FALSE; |
690 } | 672 } |
691 } | 673 } |
692 } | 674 } |
693 #endif // PDF_ENABLE_XFA | 675 #endif // PDF_ENABLE_XFA |
694 | |
695 #endif | |
696 CPDF_FormField* pFormField = GetFormField(); | 676 CPDF_FormField* pFormField = GetFormField(); |
697 return pFormField->IsItemSelected(nIndex); | 677 return pFormField->IsItemSelected(nIndex); |
698 } | 678 } |
699 | 679 |
700 int CPDFSDK_Widget::GetTopVisibleIndex() const { | 680 int CPDFSDK_Widget::GetTopVisibleIndex() const { |
701 CPDF_FormField* pFormField = GetFormField(); | 681 CPDF_FormField* pFormField = GetFormField(); |
702 return pFormField->GetTopVisibleIndex(); | 682 return pFormField->GetTopVisibleIndex(); |
703 } | 683 } |
704 | 684 |
705 FX_BOOL CPDFSDK_Widget::IsChecked() const { | 685 FX_BOOL CPDFSDK_Widget::IsChecked() const { |
706 #ifdef PDF_ENABLE_XFA | 686 #ifdef PDF_ENABLE_XFA |
707 #ifdef PDF_ENABLE_XFA | |
708 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { | 687 if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { |
709 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { | 688 if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { |
710 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { | 689 if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { |
711 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; | 690 FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On; |
712 return bChecked; | 691 return bChecked; |
713 } | 692 } |
714 } | 693 } |
715 } | 694 } |
716 #endif // PDF_ENABLE_XFA | 695 #endif // PDF_ENABLE_XFA |
717 | |
718 #endif | |
719 CPDF_FormControl* pFormCtrl = GetFormControl(); | 696 CPDF_FormControl* pFormCtrl = GetFormControl(); |
720 return pFormCtrl->IsChecked(); | 697 return pFormCtrl->IsChecked(); |
721 } | 698 } |
722 | 699 |
723 int CPDFSDK_Widget::GetAlignment() const { | 700 int CPDFSDK_Widget::GetAlignment() const { |
724 CPDF_FormControl* pFormCtrl = GetFormControl(); | 701 CPDF_FormControl* pFormCtrl = GetFormControl(); |
725 ASSERT(pFormCtrl != NULL); | 702 ASSERT(pFormCtrl != NULL); |
726 | 703 |
727 return pFormCtrl->GetControlAlignment(); | 704 return pFormCtrl->GetControlAlignment(); |
728 } | 705 } |
729 | 706 |
730 int CPDFSDK_Widget::GetMaxLen() const { | 707 int CPDFSDK_Widget::GetMaxLen() const { |
731 CPDF_FormField* pFormField = GetFormField(); | 708 CPDF_FormField* pFormField = GetFormField(); |
732 ASSERT(pFormField != NULL); | 709 ASSERT(pFormField != NULL); |
733 | 710 |
734 return pFormField->GetMaxLen(); | 711 return pFormField->GetMaxLen(); |
735 } | 712 } |
736 | 713 |
737 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { | 714 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { |
738 CPDF_FormControl* pFormCtrl = GetFormControl(); | 715 CPDF_FormControl* pFormCtrl = GetFormControl(); |
739 ASSERT(pFormCtrl != NULL); | |
740 | |
741 CPDF_FormField* pFormField = pFormCtrl->GetField(); | 716 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
742 ASSERT(pFormField != NULL); | |
743 | |
744 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, | 717 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, |
745 bNotify); | 718 bNotify); |
746 #ifdef PDF_ENABLE_XFA | 719 #ifdef PDF_ENABLE_XFA |
747 if (!IsWidgetAppearanceValid(CPDF_Annot::Normal)) | 720 if (!IsWidgetAppearanceValid(CPDF_Annot::Normal)) |
748 ResetAppearance(TRUE); | 721 ResetAppearance(TRUE); |
749 if (!bNotify) | 722 if (!bNotify) |
750 Synchronize(TRUE); | 723 Synchronize(TRUE); |
751 #endif | 724 #endif // PDF_ENABLE_XFA |
752 } | 725 } |
753 | 726 |
754 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) { | 727 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) { |
755 CPDF_FormField* pFormField = GetFormField(); | 728 CPDF_FormField* pFormField = GetFormField(); |
756 ASSERT(pFormField != NULL); | |
757 | |
758 pFormField->SetValue(sValue, bNotify); | 729 pFormField->SetValue(sValue, bNotify); |
759 #ifdef PDF_ENABLE_XFA | 730 #ifdef PDF_ENABLE_XFA |
760 | |
761 if (!bNotify) | 731 if (!bNotify) |
762 Synchronize(TRUE); | 732 Synchronize(TRUE); |
763 #endif | 733 #endif // PDF_ENABLE_XFA |
764 } | 734 } |
765 | 735 |
766 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) {} | 736 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) {} |
767 void CPDFSDK_Widget::SetOptionSelection(int index, | 737 void CPDFSDK_Widget::SetOptionSelection(int index, |
768 FX_BOOL bSelected, | 738 FX_BOOL bSelected, |
769 FX_BOOL bNotify) { | 739 FX_BOOL bNotify) { |
770 CPDF_FormField* pFormField = GetFormField(); | 740 CPDF_FormField* pFormField = GetFormField(); |
771 ASSERT(pFormField != NULL); | |
772 | |
773 pFormField->SetItemSelection(index, bSelected, bNotify); | 741 pFormField->SetItemSelection(index, bSelected, bNotify); |
774 #ifdef PDF_ENABLE_XFA | 742 #ifdef PDF_ENABLE_XFA |
775 | |
776 if (!bNotify) | 743 if (!bNotify) |
777 Synchronize(TRUE); | 744 Synchronize(TRUE); |
778 #endif | 745 #endif // PDF_ENABLE_XFA |
779 } | 746 } |
780 | 747 |
781 void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) { | 748 void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) { |
782 CPDF_FormField* pFormField = GetFormField(); | 749 CPDF_FormField* pFormField = GetFormField(); |
783 ASSERT(pFormField != NULL); | |
784 | |
785 pFormField->ClearSelection(bNotify); | 750 pFormField->ClearSelection(bNotify); |
786 #ifdef PDF_ENABLE_XFA | 751 #ifdef PDF_ENABLE_XFA |
787 | |
788 if (!bNotify) | 752 if (!bNotify) |
789 Synchronize(TRUE); | 753 Synchronize(TRUE); |
790 #endif | 754 #endif // PDF_ENABLE_XFA |
791 } | 755 } |
792 | 756 |
793 void CPDFSDK_Widget::SetTopVisibleIndex(int index) {} | 757 void CPDFSDK_Widget::SetTopVisibleIndex(int index) {} |
794 | 758 |
795 void CPDFSDK_Widget::SetAppModified() { | 759 void CPDFSDK_Widget::SetAppModified() { |
796 m_bAppModified = TRUE; | 760 m_bAppModified = TRUE; |
797 } | 761 } |
798 | 762 |
799 void CPDFSDK_Widget::ClearAppModified() { | 763 void CPDFSDK_Widget::ClearAppModified() { |
800 m_bAppModified = FALSE; | 764 m_bAppModified = FALSE; |
(...skipping 13 matching lines...) Expand all Loading... |
814 if (bFormated) | 778 if (bFormated) |
815 this->ResetAppearance(sValue, TRUE); | 779 this->ResetAppearance(sValue, TRUE); |
816 else | 780 else |
817 this->ResetAppearance(NULL, TRUE); | 781 this->ResetAppearance(NULL, TRUE); |
818 } break; | 782 } break; |
819 default: | 783 default: |
820 this->ResetAppearance(NULL, FALSE); | 784 this->ResetAppearance(NULL, FALSE); |
821 break; | 785 break; |
822 } | 786 } |
823 } | 787 } |
| 788 #endif // PDF_ENABLE_XFA |
824 | 789 |
825 #endif | |
826 void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, | 790 void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, |
827 FX_BOOL bValueChanged) { | 791 FX_BOOL bValueChanged) { |
828 SetAppModified(); | 792 SetAppModified(); |
829 | 793 |
830 m_nAppAge++; | 794 m_nAppAge++; |
831 if (m_nAppAge > 999999) | 795 if (m_nAppAge > 999999) |
832 m_nAppAge = 0; | 796 m_nAppAge = 0; |
833 if (bValueChanged) | 797 if (bValueChanged) |
834 m_nValueAge++; | 798 m_nValueAge++; |
835 | 799 |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 int nMaxLen = pField->GetMaxLen(); | 1637 int nMaxLen = pField->GetMaxLen(); |
1674 FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; | 1638 FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; |
1675 FX_FLOAT fFontSize = GetFontSize(); | 1639 FX_FLOAT fFontSize = GetFontSize(); |
1676 | 1640 |
1677 #ifdef PDF_ENABLE_XFA | 1641 #ifdef PDF_ENABLE_XFA |
1678 CFX_WideString sValueTmp; | 1642 CFX_WideString sValueTmp; |
1679 if (!sValue && (NULL != this->GetMixXFAWidget())) { | 1643 if (!sValue && (NULL != this->GetMixXFAWidget())) { |
1680 sValueTmp = GetValue(TRUE); | 1644 sValueTmp = GetValue(TRUE); |
1681 sValue = sValueTmp; | 1645 sValue = sValueTmp; |
1682 } | 1646 } |
| 1647 #endif // PDF_ENABLE_XFA |
1683 | 1648 |
1684 #endif | |
1685 if (nMaxLen > 0) { | 1649 if (nMaxLen > 0) { |
1686 if (bCharArray) { | 1650 if (bCharArray) { |
1687 pEdit->SetCharArray(nMaxLen); | 1651 pEdit->SetCharArray(nMaxLen); |
1688 | 1652 |
1689 if (IsFloatZero(fFontSize)) { | 1653 if (IsFloatZero(fFontSize)) { |
1690 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetPDFFont(0), | 1654 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(FontMap.GetPDFFont(0), |
1691 rcClient, nMaxLen); | 1655 rcClient, nMaxLen); |
1692 } | 1656 } |
1693 } else { | 1657 } else { |
1694 if (sValue) | 1658 if (sValue) |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP")) { | 1947 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP")) { |
1984 pAPDict->RemoveAt(sAPType); | 1948 pAPDict->RemoveAt(sAPType); |
1985 } | 1949 } |
1986 } | 1950 } |
1987 | 1951 |
1988 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, | 1952 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
1989 PDFSDK_FieldAction& data, | 1953 PDFSDK_FieldAction& data, |
1990 CPDFSDK_PageView* pPageView) { | 1954 CPDFSDK_PageView* pPageView) { |
1991 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1955 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
1992 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1956 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 1957 |
1993 #ifdef PDF_ENABLE_XFA | 1958 #ifdef PDF_ENABLE_XFA |
1994 | |
1995 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 1959 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
1996 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { | 1960 if (IXFA_Widget* hWidget = GetMixXFAWidget()) { |
1997 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); | 1961 XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); |
1998 | 1962 |
1999 if (eEventType != XFA_EVENT_Unknown) { | 1963 if (eEventType != XFA_EVENT_Unknown) { |
2000 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { | 1964 if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { |
2001 CXFA_EventParam param; | 1965 CXFA_EventParam param; |
2002 param.m_eType = eEventType; | 1966 param.m_eType = eEventType; |
2003 param.m_wsChange = data.sChange; | 1967 param.m_wsChange = data.sChange; |
2004 param.m_iCommitKey = data.nCommitKey; | 1968 param.m_iCommitKey = data.nCommitKey; |
(...skipping 17 matching lines...) Expand all Loading... |
2022 | 1986 |
2023 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { | 1987 if (IXFA_DocView* pDocView = pDoc->GetXFADocView()) { |
2024 pDocView->UpdateDocView(); | 1988 pDocView->UpdateDocView(); |
2025 } | 1989 } |
2026 | 1990 |
2027 if (nRet == XFA_EVENTERROR_Sucess) | 1991 if (nRet == XFA_EVENTERROR_Sucess) |
2028 return TRUE; | 1992 return TRUE; |
2029 } | 1993 } |
2030 } | 1994 } |
2031 } | 1995 } |
| 1996 #endif // PDF_ENABLE_XFA |
2032 | 1997 |
2033 #endif | |
2034 CPDF_Action action = GetAAction(type); | 1998 CPDF_Action action = GetAAction(type); |
2035 | |
2036 if (action && action.GetType() != CPDF_Action::Unknown) { | 1999 if (action && action.GetType() != CPDF_Action::Unknown) { |
2037 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 2000 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
2038 return pActionHandler->DoAction_Field(action, type, pDocument, | 2001 return pActionHandler->DoAction_Field(action, type, pDocument, |
2039 GetFormField(), data); | 2002 GetFormField(), data); |
2040 } | 2003 } |
2041 return FALSE; | 2004 return FALSE; |
2042 } | 2005 } |
2043 | 2006 |
2044 CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) { | 2007 CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) { |
2045 switch (eAAT) { | 2008 switch (eAAT) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); | 2087 CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); |
2125 IXFA_DocView* pDocView = pDoc->GetXFADocView(); | 2088 IXFA_DocView* pDocView = pDoc->GetXFADocView(); |
2126 IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); | 2089 IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
2127 | 2090 |
2128 CFX_RectF rcBBox; | 2091 CFX_RectF rcBBox; |
2129 pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); | 2092 pWidgetHandler->GetRect(GetXFAWidget(), rcBBox); |
2130 | 2093 |
2131 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, | 2094 return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
2132 rcBBox.top + rcBBox.height); | 2095 rcBBox.top + rcBBox.height); |
2133 } | 2096 } |
| 2097 #endif // PDF_ENABLE_XFA |
2134 | 2098 |
2135 #endif | |
2136 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) | 2099 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) |
2137 : m_pDocument(pDocument), | 2100 : m_pDocument(pDocument), |
2138 m_pInterForm(NULL), | 2101 m_pInterForm(NULL), |
2139 m_bCalculate(TRUE), | |
2140 #ifdef PDF_ENABLE_XFA | 2102 #ifdef PDF_ENABLE_XFA |
2141 m_bXfaCalculate(TRUE), | 2103 m_bXfaCalculate(TRUE), |
2142 m_bXfaValidationsEnabled(TRUE), | 2104 m_bXfaValidationsEnabled(TRUE), |
2143 #endif | 2105 #endif // PDF_ENABLE_XFA |
| 2106 m_bCalculate(TRUE), |
2144 m_bBusy(FALSE) { | 2107 m_bBusy(FALSE) { |
2145 m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE); | 2108 m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE); |
2146 m_pInterForm->SetFormNotify(this); | 2109 m_pInterForm->SetFormNotify(this); |
2147 | 2110 |
2148 for (int i = 0; i < kNumFieldTypes; ++i) | 2111 for (int i = 0; i < kNumFieldTypes; ++i) |
2149 m_bNeedHightlight[i] = FALSE; | 2112 m_bNeedHightlight[i] = FALSE; |
2150 m_iHighlightAlpha = 0; | 2113 m_iHighlightAlpha = 0; |
2151 } | 2114 } |
2152 | 2115 |
2153 CPDFSDK_InterForm::~CPDFSDK_InterForm() { | 2116 CPDFSDK_InterForm::~CPDFSDK_InterForm() { |
2154 delete m_pInterForm; | 2117 delete m_pInterForm; |
2155 m_pInterForm = nullptr; | 2118 m_pInterForm = nullptr; |
2156 m_Map.clear(); | 2119 m_Map.clear(); |
2157 #ifdef PDF_ENABLE_XFA | 2120 #ifdef PDF_ENABLE_XFA |
2158 m_XFAMap.RemoveAll(); | 2121 m_XFAMap.RemoveAll(); |
2159 #endif | 2122 #endif // PDF_ENABLE_XFA |
2160 } | 2123 } |
2161 | 2124 |
2162 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { | 2125 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { |
2163 return FALSE; | 2126 return FALSE; |
2164 } | 2127 } |
2165 | 2128 |
2166 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, | 2129 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, |
2167 FX_BOOL bNext) const { | 2130 FX_BOOL bNext) const { |
2168 nonstd::unique_ptr<CBA_AnnotIterator> pIterator( | 2131 nonstd::unique_ptr<CBA_AnnotIterator> pIterator( |
2169 new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "")); | 2132 new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "")); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 | 2218 |
2256 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, | 2219 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, |
2257 CPDFSDK_Widget* pWidget) { | 2220 CPDFSDK_Widget* pWidget) { |
2258 m_Map[pControl] = pWidget; | 2221 m_Map[pControl] = pWidget; |
2259 } | 2222 } |
2260 | 2223 |
2261 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) { | 2224 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) { |
2262 m_Map.erase(pControl); | 2225 m_Map.erase(pControl); |
2263 } | 2226 } |
2264 | 2227 |
| 2228 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { |
| 2229 m_bCalculate = bEnabled; |
| 2230 } |
| 2231 |
| 2232 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { |
| 2233 return m_bCalculate; |
| 2234 } |
| 2235 |
2265 #ifdef PDF_ENABLE_XFA | 2236 #ifdef PDF_ENABLE_XFA |
2266 void CPDFSDK_InterForm::AddXFAMap(IXFA_Widget* hWidget, | 2237 void CPDFSDK_InterForm::AddXFAMap(IXFA_Widget* hWidget, |
2267 CPDFSDK_XFAWidget* pWidget) { | 2238 CPDFSDK_XFAWidget* pWidget) { |
2268 m_XFAMap.SetAt(hWidget, pWidget); | 2239 m_XFAMap.SetAt(hWidget, pWidget); |
2269 } | 2240 } |
2270 | 2241 |
2271 void CPDFSDK_InterForm::RemoveXFAMap(IXFA_Widget* hWidget) { | 2242 void CPDFSDK_InterForm::RemoveXFAMap(IXFA_Widget* hWidget) { |
2272 m_XFAMap.RemoveKey(hWidget); | 2243 m_XFAMap.RemoveKey(hWidget); |
2273 } | 2244 } |
2274 | 2245 |
2275 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(IXFA_Widget* hWidget) { | 2246 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(IXFA_Widget* hWidget) { |
2276 CPDFSDK_XFAWidget* pWidget = NULL; | 2247 CPDFSDK_XFAWidget* pWidget = NULL; |
2277 m_XFAMap.Lookup(hWidget, pWidget); | 2248 m_XFAMap.Lookup(hWidget, pWidget); |
2278 | 2249 |
2279 return pWidget; | 2250 return pWidget; |
2280 } | 2251 } |
2281 | 2252 |
2282 #endif | |
2283 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { | |
2284 m_bCalculate = bEnabled; | |
2285 } | |
2286 | |
2287 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { | |
2288 return m_bCalculate; | |
2289 } | |
2290 | |
2291 #ifdef PDF_ENABLE_XFA | |
2292 void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { | 2253 void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { |
2293 m_bXfaCalculate = bEnabled; | 2254 m_bXfaCalculate = bEnabled; |
2294 } | 2255 } |
2295 FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const { | 2256 FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const { |
2296 return m_bXfaCalculate; | 2257 return m_bXfaCalculate; |
2297 } | 2258 } |
2298 | 2259 |
2299 FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() { | 2260 FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() { |
2300 return m_bXfaValidationsEnabled; | 2261 return m_bXfaValidationsEnabled; |
2301 } | 2262 } |
2302 void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled) { | 2263 void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled) { |
2303 m_bXfaValidationsEnabled = bEnabled; | 2264 m_bXfaValidationsEnabled = bEnabled; |
2304 } | 2265 } |
| 2266 #endif // PDF_ENABLE_XFA |
2305 | 2267 |
2306 #endif | |
2307 #ifdef _WIN32 | 2268 #ifdef _WIN32 |
2308 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) { | 2269 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) { |
2309 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); | 2270 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); |
2310 CPDF_Stream* pRetStream = NULL; | 2271 CPDF_Stream* pRetStream = NULL; |
2311 | 2272 |
2312 if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str())) { | 2273 if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str())) { |
2313 int nWidth = pBmp->GetWidth(); | 2274 int nWidth = pBmp->GetWidth(); |
2314 int nHeight = pBmp->GetHeight(); | 2275 int nHeight = pBmp->GetHeight(); |
2315 | 2276 |
2316 CPDF_Image Image(pDocument); | 2277 CPDF_Image Image(pDocument); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2355 pRetStream->InitStream((uint8_t*)csStream.c_str(), csStream.GetLength(), | 2316 pRetStream->InitStream((uint8_t*)csStream.c_str(), csStream.GetLength(), |
2356 pStreamDict); | 2317 pStreamDict); |
2357 pDocument->AddIndirectObject(pRetStream); | 2318 pDocument->AddIndirectObject(pRetStream); |
2358 } | 2319 } |
2359 | 2320 |
2360 delete pBmp; | 2321 delete pBmp; |
2361 } | 2322 } |
2362 | 2323 |
2363 return pRetStream; | 2324 return pRetStream; |
2364 } | 2325 } |
2365 #endif | 2326 #endif // _WIN32 |
2366 | 2327 |
2367 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { | 2328 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { |
2368 ASSERT(m_pDocument != NULL); | 2329 ASSERT(m_pDocument != NULL); |
2369 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2330 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2370 ASSERT(pEnv); | 2331 ASSERT(pEnv); |
2371 if (!pEnv->IsJSInitiated()) | 2332 if (!pEnv->IsJSInitiated()) |
2372 return; | 2333 return; |
2373 | 2334 |
2374 if (m_bBusy) | 2335 if (m_bBusy) |
2375 return; | 2336 return; |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2718 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2679 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
2719 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2680 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2720 ASSERT(pFormCtrl != NULL); | 2681 ASSERT(pFormCtrl != NULL); |
2721 | 2682 |
2722 ASSERT(m_pInterForm != NULL); | 2683 ASSERT(m_pInterForm != NULL); |
2723 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { | 2684 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { |
2724 pWidget->Synchronize(bSynchronizeElse); | 2685 pWidget->Synchronize(bSynchronizeElse); |
2725 } | 2686 } |
2726 } | 2687 } |
2727 } | 2688 } |
| 2689 #endif // PDF_ENABLE_XFA |
2728 | 2690 |
2729 #endif | |
2730 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( | 2691 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
2731 const CFX_WideString& sFileExt) { | 2692 const CFX_WideString& sFileExt) { |
2732 CFX_WideString sFileName; | 2693 CFX_WideString sFileName; |
2733 return L""; | 2694 return L""; |
2734 } | 2695 } |
2735 | 2696 |
2736 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, | 2697 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, |
2737 FX_BOOL bUrlEncoded) { | 2698 FX_BOOL bUrlEncoded) { |
2738 if (sDestination.IsEmpty()) | 2699 if (sDestination.IsEmpty()) |
2739 return FALSE; | 2700 return FALSE; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 } | 2799 } |
2839 return -1; | 2800 return -1; |
2840 } | 2801 } |
2841 return 0; | 2802 return 0; |
2842 } | 2803 } |
2843 | 2804 |
2844 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) { | 2805 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) { |
2845 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2806 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2846 #ifdef PDF_ENABLE_XFA | 2807 #ifdef PDF_ENABLE_XFA |
2847 SynchronizeField(pFormField, FALSE); | 2808 SynchronizeField(pFormField, FALSE); |
2848 | 2809 #endif // PDF_ENABLE_XFA |
2849 #endif | |
2850 int nType = pFormField->GetFieldType(); | 2810 int nType = pFormField->GetFieldType(); |
2851 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 2811 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
2852 OnCalculate(pFormField); | 2812 OnCalculate(pFormField); |
2853 FX_BOOL bFormated = FALSE; | 2813 FX_BOOL bFormated = FALSE; |
2854 CFX_WideString sValue = OnFormat(pFormField, bFormated); | 2814 CFX_WideString sValue = OnFormat(pFormField, bFormated); |
2855 if (bFormated) | 2815 if (bFormated) |
2856 ResetFieldAppearance(pFormField, sValue.c_str(), TRUE); | 2816 ResetFieldAppearance(pFormField, sValue.c_str(), TRUE); |
2857 else | 2817 else |
2858 ResetFieldAppearance(pFormField, NULL, TRUE); | 2818 ResetFieldAppearance(pFormField, NULL, TRUE); |
2859 UpdateField(pFormField); | 2819 UpdateField(pFormField); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3180 break; | 3140 break; |
3181 } | 3141 } |
3182 } | 3142 } |
3183 } | 3143 } |
3184 | 3144 |
3185 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { | 3145 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { |
3186 CPDF_Rect rcAnnot; | 3146 CPDF_Rect rcAnnot; |
3187 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 3147 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
3188 return rcAnnot; | 3148 return rcAnnot; |
3189 } | 3149 } |
OLD | NEW |