| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/include/cpdfsdk_interform.h" | 7 #include "fpdfsdk/include/cpdfsdk_interform.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> |
| 11 | 12 |
| 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 13 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 13 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" |
| 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
| 17 #include "core/fpdfdoc/include/cpdf_actionfields.h" | 18 #include "core/fpdfdoc/include/cpdf_actionfields.h" |
| 18 #include "core/fpdfdoc/include/cpdf_interform.h" | 19 #include "core/fpdfdoc/include/cpdf_interform.h" |
| 19 #include "core/fxge/include/cfx_graphstatedata.h" | 20 #include "core/fxge/include/cfx_graphstatedata.h" |
| 20 #include "core/fxge/include/cfx_pathdata.h" | 21 #include "core/fxge/include/cfx_pathdata.h" |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 pBuf = FX_Alloc(uint8_t, nBufSize); | 518 pBuf = FX_Alloc(uint8_t, nBufSize); |
| 518 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 519 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); |
| 519 return TRUE; | 520 return TRUE; |
| 520 } | 521 } |
| 521 | 522 |
| 522 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( | 523 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( |
| 523 const std::vector<CPDF_FormField*>& fields, | 524 const std::vector<CPDF_FormField*>& fields, |
| 524 bool bIncludeOrExclude, | 525 bool bIncludeOrExclude, |
| 525 CFX_ByteTextBuf& textBuf) { | 526 CFX_ByteTextBuf& textBuf) { |
| 526 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( | 527 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( |
| 527 m_pDocument->GetPath().AsStringC(), fields, bIncludeOrExclude)); | 528 m_pDocument->GetPath().AsStringC(), fields, bIncludeOrExclude, false)); |
| 528 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; | 529 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; |
| 529 } | 530 } |
| 530 | 531 |
| 531 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( | 532 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
| 532 const CFX_WideString& sFileExt) { | 533 const CFX_WideString& sFileExt) { |
| 533 return L""; | 534 return L""; |
| 534 } | 535 } |
| 535 | 536 |
| 536 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, | 537 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, |
| 537 FX_BOOL bUrlEncoded) { | 538 FX_BOOL bUrlEncoded) { |
| 538 if (sDestination.IsEmpty()) | 539 if (sDestination.IsEmpty()) |
| 539 return FALSE; | 540 return FALSE; |
| 540 | 541 |
| 541 if (!m_pDocument || !m_pInterForm) | 542 if (!m_pDocument || !m_pInterForm) |
| 542 return FALSE; | 543 return FALSE; |
| 543 | 544 |
| 544 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); | 545 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); |
| 545 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); | 546 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); |
| 546 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC()); | 547 CFDF_Document* pFDFDoc = |
| 548 m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC(), false); |
| 547 if (!pFDFDoc) | 549 if (!pFDFDoc) |
| 548 return FALSE; | 550 return FALSE; |
| 549 | 551 |
| 550 CFX_ByteTextBuf FdfBuffer; | 552 CFX_ByteTextBuf FdfBuffer; |
| 551 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 553 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); |
| 552 delete pFDFDoc; | 554 delete pFDFDoc; |
| 553 if (!bRet) | 555 if (!bRet) |
| 554 return FALSE; | 556 return FALSE; |
| 555 | 557 |
| 556 uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 558 uint8_t* pBuffer = FdfBuffer.GetBuffer(); |
| 557 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 559 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
| 558 | 560 |
| 559 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) | 561 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) |
| 560 return FALSE; | 562 return FALSE; |
| 561 | 563 |
| 562 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 564 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); |
| 563 | 565 |
| 564 if (bUrlEncoded) | 566 if (bUrlEncoded) |
| 565 FX_Free(pBuffer); | 567 FX_Free(pBuffer); |
| 566 | 568 |
| 567 return TRUE; | 569 return TRUE; |
| 568 } | 570 } |
| 569 | 571 |
| 570 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { | 572 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { |
| 571 CFDF_Document* pFDF = | 573 CFDF_Document* pFDF = |
| 572 m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsStringC()); | 574 m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsStringC(), false); |
| 573 if (!pFDF) | 575 if (!pFDF) |
| 574 return FALSE; | 576 return FALSE; |
| 575 | 577 |
| 576 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 578 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
| 577 delete pFDF; | 579 delete pFDF; |
| 578 | 580 |
| 579 return bRet; | 581 return bRet; |
| 580 } | 582 } |
| 581 | 583 |
| 582 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { | 584 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 } | 721 } |
| 720 } | 722 } |
| 721 | 723 |
| 722 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { | 724 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { |
| 723 if (nFieldType < 0 || nFieldType > kNumFieldTypes) | 725 if (nFieldType < 0 || nFieldType > kNumFieldTypes) |
| 724 return FXSYS_RGB(255, 255, 255); | 726 return FXSYS_RGB(255, 255, 255); |
| 725 if (nFieldType == 0) | 727 if (nFieldType == 0) |
| 726 return m_aHighlightColor[0]; | 728 return m_aHighlightColor[0]; |
| 727 return m_aHighlightColor[nFieldType - 1]; | 729 return m_aHighlightColor[nFieldType - 1]; |
| 728 } | 730 } |
| OLD | NEW |