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 "../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
9 #include "../include/fsdk_mgr.h" | 9 #include "../include/fsdk_mgr.h" |
10 #include "../include/fsdk_baseannot.h" | 10 #include "../include/fsdk_baseannot.h" |
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 ASSERT(pEnv); | 1750 ASSERT(pEnv); |
1751 if (!pEnv->IsJSInitiated()) | 1751 if (!pEnv->IsJSInitiated()) |
1752 return; | 1752 return; |
1753 | 1753 |
1754 if (m_bBusy) | 1754 if (m_bBusy) |
1755 return; | 1755 return; |
1756 | 1756 |
1757 m_bBusy = TRUE; | 1757 m_bBusy = TRUE; |
1758 | 1758 |
1759 if (IsCalculateEnabled()) { | 1759 if (IsCalculateEnabled()) { |
1760 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1760 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
1761 ASSERT(pRuntime != NULL); | 1761 ASSERT(pRuntime != NULL); |
1762 | 1762 |
1763 pRuntime->SetReaderDocument(m_pDocument); | 1763 pRuntime->SetReaderDocument(m_pDocument); |
1764 | 1764 |
1765 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 1765 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
1766 for (int i = 0; i < nSize; i++) { | 1766 for (int i = 0; i < nSize; i++) { |
1767 if (CPDF_FormField* pField = | 1767 if (CPDF_FormField* pField = |
1768 m_pInterForm->GetFieldInCalculationOrder(i)) { | 1768 m_pInterForm->GetFieldInCalculationOrder(i)) { |
1769 // ASSERT(pField != NULL); | 1769 // ASSERT(pField != NULL); |
1770 int nType = pField->GetFieldType(); | 1770 int nType = pField->GetFieldType(); |
1771 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 1771 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
1772 CPDF_AAction aAction = pField->GetAdditionalAction(); | 1772 CPDF_AAction aAction = pField->GetAdditionalAction(); |
1773 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { | 1773 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { |
1774 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); | 1774 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); |
1775 if (action) { | 1775 if (action) { |
1776 CFX_WideString csJS = action.GetJavaScript(); | 1776 CFX_WideString csJS = action.GetJavaScript(); |
1777 if (!csJS.IsEmpty()) { | 1777 if (!csJS.IsEmpty()) { |
1778 IFXJS_Context* pContext = pRuntime->NewContext(); | 1778 IJS_Context* pContext = pRuntime->NewContext(); |
1779 ASSERT(pContext != NULL); | 1779 ASSERT(pContext != NULL); |
1780 | 1780 |
1781 CFX_WideString sOldValue = pField->GetValue(); | 1781 CFX_WideString sOldValue = pField->GetValue(); |
1782 CFX_WideString sValue = sOldValue; | 1782 CFX_WideString sValue = sOldValue; |
1783 FX_BOOL bRC = TRUE; | 1783 FX_BOOL bRC = TRUE; |
1784 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); | 1784 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); |
1785 | 1785 |
1786 CFX_WideString sInfo; | 1786 CFX_WideString sInfo; |
1787 FX_BOOL bRet = pContext->RunScript(csJS, sInfo); | 1787 FX_BOOL bRet = pContext->RunScript(csJS, sInfo); |
1788 pRuntime->ReleaseContext(pContext); | 1788 pRuntime->ReleaseContext(pContext); |
(...skipping 21 matching lines...) Expand all Loading... |
1810 ASSERT(pFormField != NULL); | 1810 ASSERT(pFormField != NULL); |
1811 | 1811 |
1812 CFX_WideString sValue = pFormField->GetValue(); | 1812 CFX_WideString sValue = pFormField->GetValue(); |
1813 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1813 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1814 ASSERT(pEnv); | 1814 ASSERT(pEnv); |
1815 if (!pEnv->IsJSInitiated()) { | 1815 if (!pEnv->IsJSInitiated()) { |
1816 bFormated = FALSE; | 1816 bFormated = FALSE; |
1817 return sValue; | 1817 return sValue; |
1818 } | 1818 } |
1819 | 1819 |
1820 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1820 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
1821 ASSERT(pRuntime != NULL); | 1821 ASSERT(pRuntime != NULL); |
1822 | 1822 |
1823 pRuntime->SetReaderDocument(m_pDocument); | 1823 pRuntime->SetReaderDocument(m_pDocument); |
1824 | 1824 |
1825 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) { | 1825 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) { |
1826 if (pFormField->CountSelectedItems() > 0) { | 1826 if (pFormField->CountSelectedItems() > 0) { |
1827 int index = pFormField->GetSelectedIndex(0); | 1827 int index = pFormField->GetSelectedIndex(0); |
1828 if (index >= 0) | 1828 if (index >= 0) |
1829 sValue = pFormField->GetOptionLabel(index); | 1829 sValue = pFormField->GetOptionLabel(index); |
1830 } | 1830 } |
1831 } | 1831 } |
1832 | 1832 |
1833 bFormated = FALSE; | 1833 bFormated = FALSE; |
1834 | 1834 |
1835 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 1835 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
1836 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) { | 1836 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) { |
1837 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); | 1837 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); |
1838 if (action) { | 1838 if (action) { |
1839 CFX_WideString script = action.GetJavaScript(); | 1839 CFX_WideString script = action.GetJavaScript(); |
1840 if (!script.IsEmpty()) { | 1840 if (!script.IsEmpty()) { |
1841 CFX_WideString Value = sValue; | 1841 CFX_WideString Value = sValue; |
1842 | 1842 |
1843 IFXJS_Context* pContext = pRuntime->NewContext(); | 1843 IJS_Context* pContext = pRuntime->NewContext(); |
1844 ASSERT(pContext != NULL); | 1844 ASSERT(pContext != NULL); |
1845 | 1845 |
1846 pContext->OnField_Format(pFormField, Value, TRUE); | 1846 pContext->OnField_Format(pFormField, Value, TRUE); |
1847 | 1847 |
1848 CFX_WideString sInfo; | 1848 CFX_WideString sInfo; |
1849 FX_BOOL bRet = pContext->RunScript(script, sInfo); | 1849 FX_BOOL bRet = pContext->RunScript(script, sInfo); |
1850 pRuntime->ReleaseContext(pContext); | 1850 pRuntime->ReleaseContext(pContext); |
1851 | 1851 |
1852 if (bRet) { | 1852 if (bRet) { |
1853 sValue = Value; | 1853 sValue = Value; |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 ASSERT(pAnnot != NULL); | 2657 ASSERT(pAnnot != NULL); |
2658 | 2658 |
2659 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 2659 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
2660 ASSERT(pPDFAnnot != NULL); | 2660 ASSERT(pPDFAnnot != NULL); |
2661 | 2661 |
2662 CPDF_Rect rcAnnot; | 2662 CPDF_Rect rcAnnot; |
2663 pPDFAnnot->GetRect(rcAnnot); | 2663 pPDFAnnot->GetRect(rcAnnot); |
2664 | 2664 |
2665 return rcAnnot; | 2665 return rcAnnot; |
2666 } | 2666 } |
OLD | NEW |