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 "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc, | 618 void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc, |
619 const CFX_WideString& wsTitle) { | 619 const CFX_WideString& wsTitle) { |
620 if (hDoc != m_pXFADoc || !m_pPDFDoc) | 620 if (hDoc != m_pXFADoc || !m_pPDFDoc) |
621 return; | 621 return; |
622 | 622 |
623 if (CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo()) | 623 if (CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo()) |
624 pInfoDict->SetAt("Title", new CPDF_String(wsTitle)); | 624 pInfoDict->SetAt("Title", new CPDF_String(wsTitle)); |
625 } | 625 } |
626 | 626 |
627 void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, | 627 void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, |
628 const CFX_WideStringC& wsFilePath, | 628 const CFX_WideString& wsFilePath, |
629 FX_BOOL bXDP) { | 629 FX_BOOL bXDP) { |
630 if (hDoc != m_pXFADoc) | 630 if (hDoc != m_pXFADoc) |
631 return; | 631 return; |
| 632 |
632 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) | 633 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) |
633 return; | 634 return; |
| 635 |
634 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 636 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
635 if (pEnv == NULL) | 637 if (!pEnv) |
636 return; | 638 return; |
| 639 |
637 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; | 640 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; |
638 CFX_ByteString bs = CFX_WideString(wsFilePath).UTF16LE_Encode(); | 641 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); |
639 | |
640 if (wsFilePath.IsEmpty()) { | 642 if (wsFilePath.IsEmpty()) { |
641 if (!pEnv->GetFormFillInfo() || | 643 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) |
642 pEnv->GetFormFillInfo()->m_pJsPlatform == NULL) | |
643 return; | 644 return; |
644 CFX_WideString filepath = pEnv->JS_fieldBrowse(); | 645 CFX_WideString filepath = pEnv->JS_fieldBrowse(); |
645 bs = filepath.UTF16LE_Encode(); | 646 bs = filepath.UTF16LE_Encode(); |
646 } | 647 } |
647 int len = bs.GetLength() / sizeof(unsigned short); | 648 int len = bs.GetLength() / sizeof(unsigned short); |
648 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( | 649 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( |
649 bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, | 650 bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, |
650 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb"); | 651 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb"); |
651 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 652 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
652 | 653 if (!pFileHandler) |
653 if (pFileHandler == NULL) | |
654 return; | 654 return; |
655 | 655 |
656 CFPDF_FileStream fileWrite(pFileHandler); | 656 CFPDF_FileStream fileWrite(pFileHandler); |
657 | |
658 CFX_ByteString content; | 657 CFX_ByteString content; |
659 if (fileType == FXFA_SAVEAS_XML) { | 658 if (fileType == FXFA_SAVEAS_XML) { |
660 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 659 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
661 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), | 660 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
662 content.GetLength()); | 661 content.GetLength()); |
663 CFX_WideStringC data(L"data"); | 662 CFX_WideStringC data(L"data"); |
664 if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) { | 663 if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) { |
665 // Ignoring error. | 664 // Ignoring error. |
666 } | 665 } |
667 } else if (fileType == FXFA_SAVEAS_XDP) { | 666 } else if (fileType == FXFA_SAVEAS_XDP) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 pAcc->GetSize()); | 717 pAcc->GetSize()); |
719 delete pAcc; | 718 delete pAcc; |
720 } | 719 } |
721 } | 720 } |
722 } | 721 } |
723 if (!fileWrite.Flush()) { | 722 if (!fileWrite.Flush()) { |
724 // Ignoring flush error. | 723 // Ignoring flush error. |
725 } | 724 } |
726 } | 725 } |
727 void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, | 726 void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, |
728 const CFX_WideStringC& wsFilePath) {} | 727 const CFX_WideString& wsFilePath) {} |
729 | 728 |
730 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, | 729 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, |
731 const CFX_WideStringC& bsURL, | 730 const CFX_WideString& bsURL, |
732 FX_BOOL bAppend) { | 731 FX_BOOL bAppend) { |
733 if (hDoc != m_pXFADoc) | 732 if (hDoc != m_pXFADoc) |
734 return; | 733 return; |
735 | 734 |
736 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 735 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
737 return; | 736 return; |
738 | 737 |
739 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 738 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
740 if (pEnv == NULL) | 739 if (pEnv == NULL) |
741 return; | 740 return; |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 } | 1273 } |
1275 | 1274 |
1276 return _GetHValueByName(szPropName, hValue, | 1275 return _GetHValueByName(szPropName, hValue, |
1277 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1276 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
1278 } | 1277 } |
1279 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1278 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
1280 FXJSE_HVALUE hValue, | 1279 FXJSE_HVALUE hValue, |
1281 IJS_Runtime* runTime) { | 1280 IJS_Runtime* runTime) { |
1282 return runTime->GetHValueByName(utf8Name, hValue); | 1281 return runTime->GetHValueByName(utf8Name, hValue); |
1283 } | 1282 } |
OLD | NEW |