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/include/fsdk_define.h" | 7 #include "fpdfsdk/include/fsdk_define.h" |
8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "fpdfsdk/include/fsdk_mgr.h" | 9 #include "fpdfsdk/include/fsdk_mgr.h" |
10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" | 10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 return; | 641 return; |
642 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); | 642 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); |
643 if (pRoot == NULL) | 643 if (pRoot == NULL) |
644 return; | 644 return; |
645 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); | 645 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); |
646 if (NULL == pAcroForm) | 646 if (NULL == pAcroForm) |
647 return; | 647 return; |
648 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); | 648 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); |
649 if (pXFA == NULL) | 649 if (pXFA == NULL) |
650 return; | 650 return; |
651 if (pXFA->GetType() != PDFOBJ_ARRAY) | 651 if (!pXFA->IsArray()) |
652 return; | 652 return; |
653 CPDF_Array* pArray = pXFA->GetArray(); | 653 CPDF_Array* pArray = pXFA->GetArray(); |
654 if (NULL == pArray) | 654 if (NULL == pArray) |
655 return; | 655 return; |
656 int size = pArray->GetCount(); | 656 int size = pArray->GetCount(); |
657 for (int i = 1; i < size; i += 2) { | 657 for (int i = 1; i < size; i += 2) { |
658 CPDF_Object* pPDFObj = pArray->GetElement(i); | 658 CPDF_Object* pPDFObj = pArray->GetElement(i); |
659 CPDF_Object* pPrePDFObj = pArray->GetElement(i - 1); | 659 CPDF_Object* pPrePDFObj = pArray->GetElement(i - 1); |
660 if (pPrePDFObj->GetType() != PDFOBJ_STRING) | 660 if (!pPrePDFObj->IsString()) |
661 continue; | 661 continue; |
662 if (pPDFObj->GetType() != PDFOBJ_REFERENCE) | 662 if (!pPDFObj->IsReference()) |
663 continue; | 663 continue; |
664 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); | 664 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); |
665 if (pDirectObj->GetType() != PDFOBJ_STREAM) | 665 if (!pDirectObj->IsStream()) |
666 continue; | 666 continue; |
667 if (pPrePDFObj->GetString() == "form") { | 667 if (pPrePDFObj->GetString() == "form") { |
668 CFX_WideStringC form(L"form"); | 668 CFX_WideStringC form(L"form"); |
669 pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), form, &fileWrite); | 669 pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), form, &fileWrite); |
670 } else if (pPrePDFObj->GetString() == "datasets") { | 670 } else if (pPrePDFObj->GetString() == "datasets") { |
671 CFX_WideStringC datasets(L"datasets"); | 671 CFX_WideStringC datasets(L"datasets"); |
672 pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), datasets, | 672 pXFADocHander->SavePackage(m_pXFADocView->GetDoc(), datasets, |
673 &fileWrite); | 673 &fileWrite); |
674 } else { | 674 } else { |
675 if (i == size - 1) { | 675 if (i == size - 1) { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); | 958 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); |
959 if (NULL == pAcroForm) { | 959 if (NULL == pAcroForm) { |
960 fileStream.Flush(); | 960 fileStream.Flush(); |
961 return FALSE; | 961 return FALSE; |
962 } | 962 } |
963 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); | 963 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); |
964 if (pXFA == NULL) { | 964 if (pXFA == NULL) { |
965 fileStream.Flush(); | 965 fileStream.Flush(); |
966 return FALSE; | 966 return FALSE; |
967 } | 967 } |
968 if (pXFA->GetType() != PDFOBJ_ARRAY) { | 968 if (!pXFA->IsArray()) { |
969 fileStream.Flush(); | 969 fileStream.Flush(); |
970 return FALSE; | 970 return FALSE; |
971 } | 971 } |
972 CPDF_Array* pArray = pXFA->GetArray(); | 972 CPDF_Array* pArray = pXFA->GetArray(); |
973 if (NULL == pArray) { | 973 if (NULL == pArray) { |
974 fileStream.Flush(); | 974 fileStream.Flush(); |
975 return FALSE; | 975 return FALSE; |
976 } | 976 } |
977 int size = pArray->GetCount(); | 977 int size = pArray->GetCount(); |
978 for (int i = 1; i < size; i += 2) { | 978 for (int i = 1; i < size; i += 2) { |
979 CPDF_Object* pPDFObj = pArray->GetElement(i); | 979 CPDF_Object* pPDFObj = pArray->GetElement(i); |
980 CPDF_Object* pPrePDFObj = pArray->GetElement(i - 1); | 980 CPDF_Object* pPrePDFObj = pArray->GetElement(i - 1); |
981 if (pPrePDFObj->GetType() != PDFOBJ_STRING) | 981 if (!pPrePDFObj->IsString()) |
982 continue; | 982 continue; |
983 if (pPDFObj->GetType() != PDFOBJ_REFERENCE) | 983 if (!pPDFObj->IsReference()) |
984 continue; | 984 continue; |
985 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); | 985 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); |
986 if (pDirectObj->GetType() != PDFOBJ_STREAM) | 986 if (!pDirectObj->IsStream()) |
987 continue; | 987 continue; |
988 if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG)) | 988 if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG)) |
989 continue; | 989 continue; |
990 if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE)) | 990 if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE)) |
991 continue; | 991 continue; |
992 if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET)) | 992 if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET)) |
993 continue; | 993 continue; |
994 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS)) | 994 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS)) |
995 continue; | 995 continue; |
996 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA)) | 996 if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA)) |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 } | 1264 } |
1265 | 1265 |
1266 return _GetHValueByName(szPropName, hValue, | 1266 return _GetHValueByName(szPropName, hValue, |
1267 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1267 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
1268 } | 1268 } |
1269 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1269 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
1270 FXJSE_HVALUE hValue, | 1270 FXJSE_HVALUE hValue, |
1271 IJS_Runtime* runTime) { | 1271 IJS_Runtime* runTime) { |
1272 return runTime->GetHValueByName(utf8Name, hValue); | 1272 return runTime->GetHValueByName(utf8Name, hValue); |
1273 } | 1273 } |
OLD | NEW |