| 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/fpdfxfa/fpdfxfa_doc.h" | 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_util.h" | 10 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 if (iColorType > 0) | 1989 if (iColorType > 0) |
| 1990 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1990 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
| 1991 | 1991 |
| 1992 return crFill; | 1992 return crFill; |
| 1993 } | 1993 } |
| 1994 | 1994 |
| 1995 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, | 1995 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
| 1996 CPDF_Stream* pImage) { | 1996 CPDF_Stream* pImage) { |
| 1997 ASSERT(pImage != NULL); | 1997 ASSERT(pImage != NULL); |
| 1998 | 1998 |
| 1999 CPDF_Document* pDoc = | 1999 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
| 2000 m_pPageView->GetPDFDocument(); // pDocument->GetDocument(); | |
| 2001 ASSERT(pDoc != NULL); | 2000 ASSERT(pDoc != NULL); |
| 2002 | 2001 |
| 2003 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); | 2002 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP"); |
| 2004 ASSERT(pAPDict != NULL); | 2003 ASSERT(pAPDict != NULL); |
| 2005 | 2004 |
| 2006 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); | 2005 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); |
| 2007 ASSERT(pStream != NULL); | 2006 ASSERT(pStream != NULL); |
| 2008 | 2007 |
| 2009 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 2008 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
| 2010 ASSERT(pStreamDict != NULL); | 2009 ASSERT(pStreamDict != NULL); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2446 if (IsCalculateEnabled()) { | 2445 if (IsCalculateEnabled()) { |
| 2447 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 2446 IJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
| 2448 ASSERT(pRuntime != NULL); | 2447 ASSERT(pRuntime != NULL); |
| 2449 | 2448 |
| 2450 pRuntime->SetReaderDocument(m_pDocument); | 2449 pRuntime->SetReaderDocument(m_pDocument); |
| 2451 | 2450 |
| 2452 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 2451 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
| 2453 for (int i = 0; i < nSize; i++) { | 2452 for (int i = 0; i < nSize; i++) { |
| 2454 if (CPDF_FormField* pField = | 2453 if (CPDF_FormField* pField = |
| 2455 m_pInterForm->GetFieldInCalculationOrder(i)) { | 2454 m_pInterForm->GetFieldInCalculationOrder(i)) { |
| 2456 // ASSERT(pField != NULL); | |
| 2457 int nType = pField->GetFieldType(); | 2455 int nType = pField->GetFieldType(); |
| 2458 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 2456 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
| 2459 CPDF_AAction aAction = pField->GetAdditionalAction(); | 2457 CPDF_AAction aAction = pField->GetAdditionalAction(); |
| 2460 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { | 2458 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { |
| 2461 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); | 2459 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); |
| 2462 if (action) { | 2460 if (action) { |
| 2463 CFX_WideString csJS = action.GetJavaScript(); | 2461 CFX_WideString csJS = action.GetJavaScript(); |
| 2464 if (!csJS.IsEmpty()) { | 2462 if (!csJS.IsEmpty()) { |
| 2465 IJS_Context* pContext = pRuntime->NewContext(); | 2463 IJS_Context* pContext = pRuntime->NewContext(); |
| 2466 ASSERT(pContext != NULL); | 2464 ASSERT(pContext != NULL); |
| 2467 | 2465 |
| 2468 CFX_WideString sOldValue = pField->GetValue(); | 2466 CFX_WideString sOldValue = pField->GetValue(); |
| 2469 CFX_WideString sValue = sOldValue; | 2467 CFX_WideString sValue = sOldValue; |
| 2470 FX_BOOL bRC = TRUE; | 2468 FX_BOOL bRC = TRUE; |
| 2471 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); | 2469 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); |
| 2472 | 2470 |
| 2473 CFX_WideString sInfo; | 2471 CFX_WideString sInfo; |
| 2474 FX_BOOL bRet = pContext->RunScript(csJS, sInfo); | 2472 FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); |
| 2475 pRuntime->ReleaseContext(pContext); | 2473 pRuntime->ReleaseContext(pContext); |
| 2476 | 2474 |
| 2477 if (bRet) { | 2475 if (bRet) { |
| 2478 if (bRC) { | 2476 if (bRC) { |
| 2479 if (sValue.Compare(sOldValue) != 0) | 2477 if (sValue.Compare(sOldValue) != 0) |
| 2480 pField->SetValue(sValue, TRUE); | 2478 pField->SetValue(sValue, TRUE); |
| 2481 } | 2479 } |
| 2482 } | 2480 } |
| 2483 } | 2481 } |
| 2484 } | 2482 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 CFX_WideString script = action.GetJavaScript(); | 2524 CFX_WideString script = action.GetJavaScript(); |
| 2527 if (!script.IsEmpty()) { | 2525 if (!script.IsEmpty()) { |
| 2528 CFX_WideString Value = sValue; | 2526 CFX_WideString Value = sValue; |
| 2529 | 2527 |
| 2530 IJS_Context* pContext = pRuntime->NewContext(); | 2528 IJS_Context* pContext = pRuntime->NewContext(); |
| 2531 ASSERT(pContext != NULL); | 2529 ASSERT(pContext != NULL); |
| 2532 | 2530 |
| 2533 pContext->OnField_Format(pFormField, Value, TRUE); | 2531 pContext->OnField_Format(pFormField, Value, TRUE); |
| 2534 | 2532 |
| 2535 CFX_WideString sInfo; | 2533 CFX_WideString sInfo; |
| 2536 FX_BOOL bRet = pContext->RunScript(script, sInfo); | 2534 FX_BOOL bRet = pContext->RunScript(script, &sInfo); |
| 2537 pRuntime->ReleaseContext(pContext); | 2535 pRuntime->ReleaseContext(pContext); |
| 2538 | 2536 |
| 2539 if (bRet) { | 2537 if (bRet) { |
| 2540 sValue = Value; | 2538 sValue = Value; |
| 2541 bFormated = TRUE; | 2539 bFormated = TRUE; |
| 2542 } | 2540 } |
| 2543 } | 2541 } |
| 2544 } | 2542 } |
| 2545 } | 2543 } |
| 2546 | 2544 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2824 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields, | 2822 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields, |
| 2825 FX_BOOL bIncludeOrExclude, | 2823 FX_BOOL bIncludeOrExclude, |
| 2826 CFX_ByteTextBuf& textBuf) { | 2824 CFX_ByteTextBuf& textBuf) { |
| 2827 ASSERT(m_pDocument != NULL); | 2825 ASSERT(m_pDocument != NULL); |
| 2828 ASSERT(m_pInterForm != NULL); | 2826 ASSERT(m_pInterForm != NULL); |
| 2829 | 2827 |
| 2830 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( | 2828 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( |
| 2831 m_pDocument->GetPath(), (CFX_PtrArray&)fields, bIncludeOrExclude); | 2829 m_pDocument->GetPath(), (CFX_PtrArray&)fields, bIncludeOrExclude); |
| 2832 if (!pFDF) | 2830 if (!pFDF) |
| 2833 return FALSE; | 2831 return FALSE; |
| 2834 FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;// | 2832 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
| 2835 delete pFDF; | 2833 delete pFDF; |
| 2836 | 2834 |
| 2837 return bRet; | 2835 return bRet; |
| 2838 } | 2836 } |
| 2839 | 2837 |
| 2840 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, | 2838 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, |
| 2841 FX_BOOL bSynchronizeElse) { | 2839 FX_BOOL bSynchronizeElse) { |
| 2842 ASSERT(pFormField != NULL); | 2840 ASSERT(pFormField != NULL); |
| 2843 | 2841 |
| 2844 int x = 0; | 2842 int x = 0; |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3370 ASSERT(pAnnot != NULL); | 3368 ASSERT(pAnnot != NULL); |
| 3371 | 3369 |
| 3372 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 3370 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
| 3373 ASSERT(pPDFAnnot != NULL); | 3371 ASSERT(pPDFAnnot != NULL); |
| 3374 | 3372 |
| 3375 CPDF_Rect rcAnnot; | 3373 CPDF_Rect rcAnnot; |
| 3376 pPDFAnnot->GetRect(rcAnnot); | 3374 pPDFAnnot->GetRect(rcAnnot); |
| 3377 | 3375 |
| 3378 return rcAnnot; | 3376 return rcAnnot; |
| 3379 } | 3377 } |
| OLD | NEW |