| 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 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 if (iColorType > 0) | 1411 if (iColorType > 0) |
| 1412 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1412 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1413 | 1413 |
| 1414 return crFill; | 1414 return crFill; |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, | 1417 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
| 1418 CPDF_Stream* pImage) { | 1418 CPDF_Stream* pImage) { |
| 1419 ASSERT(pImage != NULL); | 1419 ASSERT(pImage != NULL); |
| 1420 | 1420 |
| 1421 CPDF_Document* pDoc = | 1421 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
| 1422 m_pPageView->GetPDFDocument(); // pDocument->GetDocument(); | |
| 1423 ASSERT(pDoc != NULL); | 1422 ASSERT(pDoc != NULL); |
| 1424 | 1423 |
| 1425 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); | 1424 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
| 1426 ASSERT(pAPDict != NULL); | 1425 ASSERT(pAPDict != NULL); |
| 1427 | 1426 |
| 1428 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); | 1427 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); |
| 1429 ASSERT(pStream != NULL); | 1428 ASSERT(pStream != NULL); |
| 1430 | 1429 |
| 1431 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1430 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
| 1432 ASSERT(pStreamDict != NULL); | 1431 ASSERT(pStreamDict != NULL); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 if (IsCalculateEnabled()) { | 1758 if (IsCalculateEnabled()) { |
| 1760 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1759 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
| 1761 ASSERT(pRuntime != NULL); | 1760 ASSERT(pRuntime != NULL); |
| 1762 | 1761 |
| 1763 pRuntime->SetReaderDocument(m_pDocument); | 1762 pRuntime->SetReaderDocument(m_pDocument); |
| 1764 | 1763 |
| 1765 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 1764 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
| 1766 for (int i = 0; i < nSize; i++) { | 1765 for (int i = 0; i < nSize; i++) { |
| 1767 if (CPDF_FormField* pField = | 1766 if (CPDF_FormField* pField = |
| 1768 m_pInterForm->GetFieldInCalculationOrder(i)) { | 1767 m_pInterForm->GetFieldInCalculationOrder(i)) { |
| 1769 // ASSERT(pField != NULL); | |
| 1770 int nType = pField->GetFieldType(); | 1768 int nType = pField->GetFieldType(); |
| 1771 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 1769 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
| 1772 CPDF_AAction aAction = pField->GetAdditionalAction(); | 1770 CPDF_AAction aAction = pField->GetAdditionalAction(); |
| 1773 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { | 1771 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { |
| 1774 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); | 1772 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); |
| 1775 if (action) { | 1773 if (action) { |
| 1776 CFX_WideString csJS = action.GetJavaScript(); | 1774 CFX_WideString csJS = action.GetJavaScript(); |
| 1777 if (!csJS.IsEmpty()) { | 1775 if (!csJS.IsEmpty()) { |
| 1778 IJS_Context* pContext = pRuntime->NewContext(); | 1776 IJS_Context* pContext = pRuntime->NewContext(); |
| 1779 ASSERT(pContext != NULL); | 1777 ASSERT(pContext != NULL); |
| 1780 | 1778 |
| 1781 CFX_WideString sOldValue = pField->GetValue(); | 1779 CFX_WideString sOldValue = pField->GetValue(); |
| 1782 CFX_WideString sValue = sOldValue; | 1780 CFX_WideString sValue = sOldValue; |
| 1783 FX_BOOL bRC = TRUE; | 1781 FX_BOOL bRC = TRUE; |
| 1784 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); | 1782 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); |
| 1785 | 1783 |
| 1786 CFX_WideString sInfo; | 1784 CFX_WideString sInfo; |
| 1787 FX_BOOL bRet = pContext->RunScript(csJS, sInfo); | 1785 FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); |
| 1788 pRuntime->ReleaseContext(pContext); | 1786 pRuntime->ReleaseContext(pContext); |
| 1789 | 1787 |
| 1790 if (bRet) { | 1788 if (bRet) { |
| 1791 if (bRC) { | 1789 if (bRC) { |
| 1792 if (sValue.Compare(sOldValue) != 0) | 1790 if (sValue.Compare(sOldValue) != 0) |
| 1793 pField->SetValue(sValue, TRUE); | 1791 pField->SetValue(sValue, TRUE); |
| 1794 } | 1792 } |
| 1795 } | 1793 } |
| 1796 } | 1794 } |
| 1797 } | 1795 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 CFX_WideString script = action.GetJavaScript(); | 1837 CFX_WideString script = action.GetJavaScript(); |
| 1840 if (!script.IsEmpty()) { | 1838 if (!script.IsEmpty()) { |
| 1841 CFX_WideString Value = sValue; | 1839 CFX_WideString Value = sValue; |
| 1842 | 1840 |
| 1843 IJS_Context* pContext = pRuntime->NewContext(); | 1841 IJS_Context* pContext = pRuntime->NewContext(); |
| 1844 ASSERT(pContext != NULL); | 1842 ASSERT(pContext != NULL); |
| 1845 | 1843 |
| 1846 pContext->OnField_Format(pFormField, Value, TRUE); | 1844 pContext->OnField_Format(pFormField, Value, TRUE); |
| 1847 | 1845 |
| 1848 CFX_WideString sInfo; | 1846 CFX_WideString sInfo; |
| 1849 FX_BOOL bRet = pContext->RunScript(script, sInfo); | 1847 FX_BOOL bRet = pContext->RunScript(script, &sInfo); |
| 1850 pRuntime->ReleaseContext(pContext); | 1848 pRuntime->ReleaseContext(pContext); |
| 1851 | 1849 |
| 1852 if (bRet) { | 1850 if (bRet) { |
| 1853 sValue = Value; | 1851 sValue = Value; |
| 1854 bFormated = TRUE; | 1852 bFormated = TRUE; |
| 1855 } | 1853 } |
| 1856 } | 1854 } |
| 1857 } | 1855 } |
| 1858 } | 1856 } |
| 1859 | 1857 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields, | 2135 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields, |
| 2138 FX_BOOL bIncludeOrExclude, | 2136 FX_BOOL bIncludeOrExclude, |
| 2139 CFX_ByteTextBuf& textBuf) { | 2137 CFX_ByteTextBuf& textBuf) { |
| 2140 ASSERT(m_pDocument != NULL); | 2138 ASSERT(m_pDocument != NULL); |
| 2141 ASSERT(m_pInterForm != NULL); | 2139 ASSERT(m_pInterForm != NULL); |
| 2142 | 2140 |
| 2143 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( | 2141 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( |
| 2144 m_pDocument->GetPath(), (CFX_PtrArray&)fields, bIncludeOrExclude); | 2142 m_pDocument->GetPath(), (CFX_PtrArray&)fields, bIncludeOrExclude); |
| 2145 if (!pFDF) | 2143 if (!pFDF) |
| 2146 return FALSE; | 2144 return FALSE; |
| 2147 FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;// | 2145 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
| 2148 delete pFDF; | 2146 delete pFDF; |
| 2149 | 2147 |
| 2150 return bRet; | 2148 return bRet; |
| 2151 } | 2149 } |
| 2152 | 2150 |
| 2153 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( | 2151 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
| 2154 const CFX_WideString& sFileExt) { | 2152 const CFX_WideString& sFileExt) { |
| 2155 CFX_WideString sFileName; | 2153 CFX_WideString sFileName; |
| 2156 return L""; | 2154 return L""; |
| 2157 } | 2155 } |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2657 ASSERT(pAnnot != NULL); | 2655 ASSERT(pAnnot != NULL); |
| 2658 | 2656 |
| 2659 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 2657 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
| 2660 ASSERT(pPDFAnnot != NULL); | 2658 ASSERT(pPDFAnnot != NULL); |
| 2661 | 2659 |
| 2662 CPDF_Rect rcAnnot; | 2660 CPDF_Rect rcAnnot; |
| 2663 pPDFAnnot->GetRect(rcAnnot); | 2661 pPDFAnnot->GetRect(rcAnnot); |
| 2664 | 2662 |
| 2665 return rcAnnot; | 2663 return rcAnnot; |
| 2666 } | 2664 } |
| OLD | NEW |