| 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/javascript/Field.h" | 7 #include "fpdfsdk/javascript/Field.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 vp << false; | 1524 vp << false; |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 return TRUE; | 1527 return TRUE; |
| 1528 } | 1528 } |
| 1529 | 1529 |
| 1530 void Field::SetHidden(CPDFSDK_Document* pDocument, | 1530 void Field::SetHidden(CPDFSDK_Document* pDocument, |
| 1531 const CFX_WideString& swFieldName, | 1531 const CFX_WideString& swFieldName, |
| 1532 int nControlIndex, | 1532 int nControlIndex, |
| 1533 bool b) { | 1533 bool b) { |
| 1534 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 1534 int display = b ? 1 /*Hidden*/ : 0 /*Visible*/; |
| 1535 std::vector<CPDF_FormField*> FieldArray = | 1535 SetDisplay(pDocument, swFieldName, nControlIndex, display); |
| 1536 GetFormFields(pDocument, swFieldName); | |
| 1537 for (CPDF_FormField* pFormField : FieldArray) { | |
| 1538 if (nControlIndex < 0) { | |
| 1539 FX_BOOL bSet = FALSE; | |
| 1540 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { | |
| 1541 if (CPDFSDK_Widget* pWidget = | |
| 1542 pInterForm->GetWidget(pFormField->GetControl(i), false)) { | |
| 1543 uint32_t dwFlags = pWidget->GetFlags(); | |
| 1544 | |
| 1545 if (b) { | |
| 1546 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1547 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1548 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); | |
| 1549 } else { | |
| 1550 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1551 dwFlags &= (~ANNOTFLAG_HIDDEN); | |
| 1552 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1553 dwFlags |= ANNOTFLAG_PRINT; | |
| 1554 } | |
| 1555 | |
| 1556 if (dwFlags != pWidget->GetFlags()) { | |
| 1557 pWidget->SetFlags(dwFlags); | |
| 1558 bSet = TRUE; | |
| 1559 } | |
| 1560 } | |
| 1561 } | |
| 1562 | |
| 1563 if (bSet) | |
| 1564 UpdateFormField(pDocument, pFormField, TRUE, FALSE, TRUE); | |
| 1565 } else { | |
| 1566 if (nControlIndex >= pFormField->CountControls()) | |
| 1567 return; | |
| 1568 if (CPDF_FormControl* pFormControl = | |
| 1569 pFormField->GetControl(nControlIndex)) { | |
| 1570 if (CPDFSDK_Widget* pWidget = | |
| 1571 pInterForm->GetWidget(pFormControl, false)) { | |
| 1572 uint32_t dwFlags = pWidget->GetFlags(); | |
| 1573 | |
| 1574 if (b) { | |
| 1575 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1576 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1577 dwFlags |= (ANNOTFLAG_HIDDEN | ANNOTFLAG_PRINT); | |
| 1578 } else { | |
| 1579 dwFlags &= (~ANNOTFLAG_INVISIBLE); | |
| 1580 dwFlags &= (~ANNOTFLAG_HIDDEN); | |
| 1581 dwFlags &= (~ANNOTFLAG_NOVIEW); | |
| 1582 dwFlags |= ANNOTFLAG_PRINT; | |
| 1583 } | |
| 1584 | |
| 1585 if (dwFlags != pWidget->GetFlags()) { | |
| 1586 pWidget->SetFlags(dwFlags); | |
| 1587 UpdateFormControl(pDocument, pFormControl, TRUE, FALSE, TRUE); | |
| 1588 } | |
| 1589 } | |
| 1590 } | |
| 1591 } | |
| 1592 } | |
| 1593 } | 1536 } |
| 1594 | 1537 |
| 1595 FX_BOOL Field::highlight(IJS_Context* cc, | 1538 FX_BOOL Field::highlight(IJS_Context* cc, |
| 1596 CJS_PropValue& vp, | 1539 CJS_PropValue& vp, |
| 1597 CFX_WideString& sError) { | 1540 CFX_WideString& sError) { |
| 1598 ASSERT(m_pDocument); | 1541 ASSERT(m_pDocument); |
| 1599 | 1542 |
| 1600 if (vp.IsSetting()) { | 1543 if (vp.IsSetting()) { |
| 1601 if (!m_bCanSet) | 1544 if (!m_bCanSet) |
| 1602 return FALSE; | 1545 return FALSE; |
| (...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3527 } | 3470 } |
| 3528 } | 3471 } |
| 3529 | 3472 |
| 3530 void Field::AddField(CPDFSDK_Document* pDocument, | 3473 void Field::AddField(CPDFSDK_Document* pDocument, |
| 3531 int nPageIndex, | 3474 int nPageIndex, |
| 3532 int nFieldType, | 3475 int nFieldType, |
| 3533 const CFX_WideString& sName, | 3476 const CFX_WideString& sName, |
| 3534 const CFX_FloatRect& rcCoords) { | 3477 const CFX_FloatRect& rcCoords) { |
| 3535 // Not supported. | 3478 // Not supported. |
| 3536 } | 3479 } |
| OLD | NEW |