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 "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 649 bs.ReleaseBuffer(len * sizeof(unsigned short)); |
650 | 650 |
651 if (pFileHandler == NULL) | 651 if (pFileHandler == NULL) |
652 return; | 652 return; |
653 | 653 |
654 CFPDF_FileStream fileWrite(pFileHandler); | 654 CFPDF_FileStream fileWrite(pFileHandler); |
655 | 655 |
656 CFX_ByteString content; | 656 CFX_ByteString content; |
657 if (fileType == FXFA_SAVEAS_XML) { | 657 if (fileType == FXFA_SAVEAS_XML) { |
658 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 658 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
659 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(), | 659 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
660 content.GetLength()); | 660 content.GetLength()); |
661 CFX_WideStringC data(L"data"); | 661 CFX_WideStringC data(L"data"); |
662 if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) { | 662 if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) { |
663 // Ignoring error. | 663 // Ignoring error. |
664 } | 664 } |
665 } else if (fileType == FXFA_SAVEAS_XDP) { | 665 } else if (fileType == FXFA_SAVEAS_XDP) { |
666 if (m_pPDFDoc == NULL) | 666 if (m_pPDFDoc == NULL) |
667 return; | 667 return; |
668 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); | 668 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); |
669 if (pRoot == NULL) | 669 if (pRoot == NULL) |
(...skipping 22 matching lines...) Expand all Loading... | |
692 continue; | 692 continue; |
693 if (pPrePDFObj->GetString() == "form") { | 693 if (pPrePDFObj->GetString() == "form") { |
694 CFX_WideStringC form(L"form"); | 694 CFX_WideStringC form(L"form"); |
695 m_pXFADocView->GetDoc()->SavePackage(form, &fileWrite); | 695 m_pXFADocView->GetDoc()->SavePackage(form, &fileWrite); |
696 } else if (pPrePDFObj->GetString() == "datasets") { | 696 } else if (pPrePDFObj->GetString() == "datasets") { |
697 CFX_WideStringC datasets(L"datasets"); | 697 CFX_WideStringC datasets(L"datasets"); |
698 m_pXFADocView->GetDoc()->SavePackage(datasets, &fileWrite); | 698 m_pXFADocView->GetDoc()->SavePackage(datasets, &fileWrite); |
699 } else { | 699 } else { |
700 if (i == size - 1) { | 700 if (i == size - 1) { |
701 CFX_WideString wPath = CFX_WideString::FromUTF16LE( | 701 CFX_WideString wPath = CFX_WideString::FromUTF16LE( |
702 (unsigned short*)(const FX_CHAR*)bs, | 702 reinterpret_cast<const unsigned short*>(bs.c_str()), |
703 bs.GetLength() / sizeof(unsigned short)); | 703 bs.GetLength() / sizeof(unsigned short)); |
704 CFX_ByteString bPath = wPath.UTF8Encode(); | 704 CFX_ByteString bPath = wPath.UTF8Encode(); |
705 CFX_ByteString szFormat = | 705 const char* szFormat = |
Lei Zhang
2016/04/13 21:54:58
const char szFormat[] ?
Ditto for line 958.
Tom Sepez
2016/04/13 22:25:19
No, wouldn't that imply a copy into an local aggre
| |
706 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; | 706 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; |
707 content.Format(szFormat, (char*)(const FX_CHAR*)bPath); | 707 content.Format(szFormat, bPath.c_str()); |
708 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(), | 708 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
709 content.GetLength()); | 709 content.GetLength()); |
710 } | 710 } |
711 | 711 |
712 CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj; | 712 CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj; |
713 CPDF_StreamAcc* pAcc = new CPDF_StreamAcc; | 713 CPDF_StreamAcc* pAcc = new CPDF_StreamAcc; |
714 pAcc->LoadAllData(pStream); | 714 pAcc->LoadAllData(pStream); |
715 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), | 715 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), |
716 pAcc->GetSize()); | 716 pAcc->GetSize()); |
717 delete pAcc; | 717 delete pAcc; |
718 } | 718 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 CFX_ByteString content; | 948 CFX_ByteString content; |
949 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 949 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
950 if (!pEnv) | 950 if (!pEnv) |
951 return FALSE; | 951 return FALSE; |
952 | 952 |
953 CFPDF_FileStream fileStream(pFileHandler); | 953 CFPDF_FileStream fileStream(pFileHandler); |
954 | 954 |
955 if (fileType == FXFA_SAVEAS_XML) { | 955 if (fileType == FXFA_SAVEAS_XML) { |
956 CFX_WideString ws; | 956 CFX_WideString ws; |
957 ws.FromLocal("data"); | 957 ws.FromLocal("data"); |
958 CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 958 const char* content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
959 fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength()); | 959 fileStream.WriteBlock(content, 0, strlen(content)); |
960 m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream); | 960 m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream); |
961 } else if (fileType == FXFA_SAVEAS_XDP) { | 961 } else if (fileType == FXFA_SAVEAS_XDP) { |
962 if (flag == 0) | 962 if (flag == 0) |
963 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | | 963 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | |
964 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; | 964 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; |
965 if (m_pPDFDoc == NULL) { | 965 if (m_pPDFDoc == NULL) { |
966 fileStream.Flush(); | 966 fileStream.Flush(); |
967 return FALSE; | 967 return FALSE; |
968 } | 968 } |
969 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); | 969 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 } | 1272 } |
1273 | 1273 |
1274 return _GetHValueByName(szPropName, hValue, | 1274 return _GetHValueByName(szPropName, hValue, |
1275 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1275 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
1276 } | 1276 } |
1277 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1277 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
1278 FXJSE_HVALUE hValue, | 1278 FXJSE_HVALUE hValue, |
1279 IJS_Runtime* runTime) { | 1279 IJS_Runtime* runTime) { |
1280 return runTime->GetHValueByName(utf8Name, hValue); | 1280 return runTime->GetHValueByName(utf8Name, hValue); |
1281 } | 1281 } |
OLD | NEW |