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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 { | 358 { |
359 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) | 359 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) |
360 return TRUE; | 360 return TRUE; |
361 } | 361 } |
362 | 362 |
363 return FALSE; | 363 return FALSE; |
364 } | 364 } |
365 | 365 |
366 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) | 366 CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) |
367 { | 367 { |
368 » ASSERT(pFormField != NULL); | 368 » if (!pFormField->CountControls() || m_nFormControlIndex >= pFormField->C
ountControls()) |
369 » if(!pFormField->CountControls() || m_nFormControlIndex>=pFormField->Coun
tControls()) return NULL; | 369 return NULL; |
370 | 370 |
371 » if (m_nFormControlIndex<0) | 371 » if (m_nFormControlIndex < 0) |
372 return pFormField->GetControl(0); | 372 return pFormField->GetControl(0); |
373 » else | 373 |
374 » » return pFormField->GetControl(m_nFormControlIndex); | 374 return pFormField->GetControl(m_nFormControlIndex); |
375 } | 375 } |
376 | 376 |
377 /* ---------------------------------------- property ---------------------------
------------- */ | 377 /* ---------------------------------------- property ---------------------------
------------- */ |
378 | 378 |
379 FX_BOOL Field::alignment(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 379 FX_BOOL Field::alignment(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
380 { | 380 { |
381 ASSERT(m_pDocument != NULL); | 381 ASSERT(m_pDocument != NULL); |
382 | 382 |
383 if (vp.IsSetting()) | 383 if (vp.IsSetting()) |
384 { | 384 { |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 | 1536 |
1537 return TRUE; | 1537 return TRUE; |
1538 } | 1538 } |
1539 | 1539 |
1540 FX_BOOL Field::exportValues(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | 1540 FX_BOOL Field::exportValues(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) |
1541 { | 1541 { |
1542 ASSERT(m_pDocument != NULL); | 1542 ASSERT(m_pDocument != NULL); |
1543 | 1543 |
1544 CFX_PtrArray FieldArray; | 1544 CFX_PtrArray FieldArray; |
1545 GetFormFields(m_FieldName,FieldArray); | 1545 GetFormFields(m_FieldName,FieldArray); |
1546 » if (FieldArray.GetSize() <= 0) return FALSE; | 1546 » if (FieldArray.GetSize() <= 0) |
| 1547 return FALSE; |
1547 | 1548 |
1548 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1549 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
1549 ASSERT(pFormField != NULL); | |
1550 | |
1551 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && | 1550 if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && |
1552 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) | 1551 pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) |
1553 return FALSE; | 1552 return FALSE; |
1554 | 1553 |
1555 if (vp.IsSetting()) | 1554 if (vp.IsSetting()) |
1556 { | 1555 { |
1557 » » if (!m_bCanSet) return FALSE; | 1556 » » if (!m_bCanSet) |
1558 » » if (!vp.IsArrayObject())return FALSE; | 1557 return FALSE; |
| 1558 |
| 1559 » » if (!vp.IsArrayObject()) |
| 1560 return FALSE; |
1559 } | 1561 } |
1560 else | 1562 else |
1561 { | 1563 { |
1562 CJS_Array ExportValusArray(m_isolate); | 1564 CJS_Array ExportValusArray(m_isolate); |
1563 | |
1564 if (m_nFormControlIndex < 0) | 1565 if (m_nFormControlIndex < 0) |
1565 { | 1566 { |
1566 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) | 1567 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) |
1567 { | 1568 { |
1568 CPDF_FormControl* pFormControl = pFormField->Get
Control(i); | 1569 CPDF_FormControl* pFormControl = pFormField->Get
Control(i); |
1569 ASSERT(pFormControl != NULL); | |
1570 | |
1571 ExportValusArray.SetElement(i, CJS_Value(m_isola
te,pFormControl->GetExportValue().c_str())); | 1570 ExportValusArray.SetElement(i, CJS_Value(m_isola
te,pFormControl->GetExportValue().c_str())); |
1572 } | 1571 } |
1573 } | 1572 } |
1574 else | 1573 else |
1575 { | 1574 { |
1576 » » » if(m_nFormControlIndex >= pFormField->CountControls()) r
eturn FALSE; | 1575 » » » if (m_nFormControlIndex >= pFormField->CountControls()) |
| 1576 return FALSE; |
| 1577 |
1577 CPDF_FormControl* pFormControl = pFormField->GetControl(
m_nFormControlIndex); | 1578 CPDF_FormControl* pFormControl = pFormField->GetControl(
m_nFormControlIndex); |
1578 » » » if (!pFormControl) return FALSE; | 1579 » » » if (!pFormControl) |
| 1580 return FALSE; |
1579 | 1581 |
1580 ExportValusArray.SetElement(0, CJS_Value(m_isolate,pForm
Control->GetExportValue().c_str())); | 1582 ExportValusArray.SetElement(0, CJS_Value(m_isolate,pForm
Control->GetExportValue().c_str())); |
1581 } | 1583 } |
1582 | |
1583 vp << ExportValusArray; | 1584 vp << ExportValusArray; |
1584 } | 1585 } |
1585 | |
1586 return TRUE; | 1586 return TRUE; |
1587 } | 1587 } |
1588 | 1588 |
1589 FX_BOOL Field::fileSelect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) | 1589 FX_BOOL Field::fileSelect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1590 { | 1590 { |
1591 ASSERT(m_pDocument != NULL); | 1591 ASSERT(m_pDocument != NULL); |
1592 | 1592 |
1593 CFX_PtrArray FieldArray; | 1593 CFX_PtrArray FieldArray; |
1594 GetFormFields(m_FieldName, FieldArray); | 1594 GetFormFields(m_FieldName, FieldArray); |
1595 » if (FieldArray.GetSize() <= 0) return FALSE; | 1595 » if (FieldArray.GetSize() <= 0) |
| 1596 return FALSE; |
1596 | 1597 |
1597 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 1598 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
1598 ASSERT(pFormField != NULL); | |
1599 | |
1600 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) | 1599 if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) |
1601 return FALSE; | 1600 return FALSE; |
1602 | 1601 |
1603 if (vp.IsSetting()) | 1602 if (vp.IsSetting()) |
1604 { | 1603 { |
1605 » » if (!m_bCanSet) return FALSE; | 1604 » » if (!m_bCanSet) |
| 1605 return FALSE; |
1606 | 1606 |
1607 bool bVP; | 1607 bool bVP; |
1608 vp >> bVP; | 1608 vp >> bVP; |
1609 | |
1610 } | 1609 } |
1611 else | 1610 else |
1612 { | 1611 { |
1613 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) | 1612 if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) |
1614 vp << true; | 1613 vp << true; |
1615 else | 1614 else |
1616 vp << false; | 1615 vp << false; |
1617 } | 1616 } |
1618 | |
1619 return TRUE; | 1617 return TRUE; |
1620 } | 1618 } |
1621 | 1619 |
1622 FX_BOOL Field::fillColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1620 FX_BOOL Field::fillColor(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
1623 { | 1621 { |
1624 ASSERT(m_pDocument != NULL); | 1622 ASSERT(m_pDocument != NULL); |
1625 | 1623 |
1626 CJS_Array crArray(m_isolate); | 1624 CJS_Array crArray(m_isolate); |
1627 | 1625 |
1628 CFX_PtrArray FieldArray; | 1626 CFX_PtrArray FieldArray; |
1629 » GetFormFields(m_FieldName,FieldArray); | 1627 » GetFormFields(m_FieldName, FieldArray); |
1630 » if (FieldArray.GetSize() <= 0) return FALSE; | 1628 » if (FieldArray.GetSize() <= 0) |
| 1629 return FALSE; |
1631 | 1630 |
1632 if (vp.IsSetting()) | 1631 if (vp.IsSetting()) |
1633 { | 1632 { |
1634 » » if (!m_bCanSet) return FALSE; | 1633 » » if (!m_bCanSet) |
1635 » » if (!vp.IsArrayObject()) return FALSE; | 1634 return FALSE; |
| 1635 |
| 1636 » » if (!vp.IsArrayObject()) |
| 1637 return FALSE; |
1636 | 1638 |
1637 vp >> crArray; | 1639 vp >> crArray; |
1638 | 1640 |
1639 CPWL_Color color; | 1641 CPWL_Color color; |
1640 color::ConvertArrayToPWLColor(crArray, color); | 1642 color::ConvertArrayToPWLColor(crArray, color); |
1641 | |
1642 if (m_bDelay) | 1643 if (m_bDelay) |
1643 { | 1644 { |
1644 AddDelay_Color(FP_FILLCOLOR, color); | 1645 AddDelay_Color(FP_FILLCOLOR, color); |
1645 } | 1646 } |
1646 else | 1647 else |
1647 { | 1648 { |
1648 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormCon
trolIndex, color); | 1649 Field::SetFillColor(m_pDocument, m_FieldName, m_nFormCon
trolIndex, color); |
1649 } | 1650 } |
1650 } | 1651 } |
1651 else | 1652 else |
1652 { | 1653 { |
1653 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.Element
At(0); | 1654 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.Element
At(0); |
1654 ASSERT(pFormField != NULL); | 1655 ASSERT(pFormField != NULL); |
1655 | 1656 |
1656 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField
); | 1657 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField
); |
1657 » » if (!pFormControl)return FALSE; | 1658 » » if (!pFormControl) |
| 1659 return FALSE; |
1658 | 1660 |
1659 int iColorType; | 1661 int iColorType; |
1660 pFormControl->GetBackgroundColor(iColorType); | 1662 pFormControl->GetBackgroundColor(iColorType); |
1661 | 1663 |
1662 CPWL_Color color; | 1664 CPWL_Color color; |
1663 | |
1664 if (iColorType == COLORTYPE_TRANSPARENT) | 1665 if (iColorType == COLORTYPE_TRANSPARENT) |
1665 { | 1666 { |
1666 color = CPWL_Color(COLORTYPE_TRANSPARENT); | 1667 color = CPWL_Color(COLORTYPE_TRANSPARENT); |
1667 } | 1668 } |
1668 else if (iColorType == COLORTYPE_GRAY) | 1669 else if (iColorType == COLORTYPE_GRAY) |
1669 { | 1670 { |
1670 color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOrig
inalBackgroundColor(0)); | 1671 color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOrig
inalBackgroundColor(0)); |
1671 } | 1672 } |
1672 else if (iColorType == COLORTYPE_RGB) | 1673 else if (iColorType == COLORTYPE_RGB) |
1673 { | 1674 { |
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4106 | 4107 |
4107 #define JS_FIELD_MINWIDTH 1 | 4108 #define JS_FIELD_MINWIDTH 1 |
4108 #define JS_FIELD_MINHEIGHT 1 | 4109 #define JS_FIELD_MINHEIGHT 1 |
4109 | 4110 |
4110 void Field::AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType
, | 4111 void Field::AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType
, |
4111 const CFX_WideString& sN
ame, const CPDF_Rect& rcCoords) | 4112 const CFX_WideString& sN
ame, const CPDF_Rect& rcCoords) |
4112 { | 4113 { |
4113 //Not supported. | 4114 //Not supported. |
4114 } | 4115 } |
4115 | 4116 |
OLD | NEW |