| 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 "xfa/fxfa/include/xfa_ffdoc.h" | 7 #include "xfa/fxfa/include/xfa_ffdoc.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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (pAcroForm == NULL) { | 235 if (pAcroForm == NULL) { |
| 236 return FALSE; | 236 return FALSE; |
| 237 } | 237 } |
| 238 CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectBy("XFA"); | 238 CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectBy("XFA"); |
| 239 if (pElementXFA == NULL) { | 239 if (pElementXFA == NULL) { |
| 240 return FALSE; | 240 return FALSE; |
| 241 } | 241 } |
| 242 CFX_ArrayTemplate<CPDF_Stream*> xfaStreams; | 242 CFX_ArrayTemplate<CPDF_Stream*> xfaStreams; |
| 243 if (pElementXFA->IsArray()) { | 243 if (pElementXFA->IsArray()) { |
| 244 CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; | 244 CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; |
| 245 uint32_t count = pXFAArray->GetCount() / 2; | 245 for (size_t i = 0; i < pXFAArray->GetCount() / 2; i++) { |
| 246 for (uint32_t i = 0; i < count; i++) { | |
| 247 if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) | 246 if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) |
| 248 xfaStreams.Add(pStream); | 247 xfaStreams.Add(pStream); |
| 249 } | 248 } |
| 250 } else if (pElementXFA->IsStream()) { | 249 } else if (pElementXFA->IsStream()) { |
| 251 xfaStreams.Add((CPDF_Stream*)pElementXFA); | 250 xfaStreams.Add((CPDF_Stream*)pElementXFA); |
| 252 } | 251 } |
| 253 if (xfaStreams.GetSize() < 1) { | 252 if (xfaStreams.GetSize() < 1) { |
| 254 return FALSE; | 253 return FALSE; |
| 255 } | 254 } |
| 256 IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams); | 255 IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 return nullptr; | 343 return nullptr; |
| 345 | 344 |
| 346 CPDF_Dictionary* pXFAImages = pNames->GetDictBy("XFAImages"); | 345 CPDF_Dictionary* pXFAImages = pNames->GetDictBy("XFAImages"); |
| 347 if (!pXFAImages) | 346 if (!pXFAImages) |
| 348 return nullptr; | 347 return nullptr; |
| 349 | 348 |
| 350 CPDF_NameTree nametree(pXFAImages); | 349 CPDF_NameTree nametree(pXFAImages); |
| 351 CFX_ByteString bsName = PDF_EncodeText(wsName.c_str(), wsName.GetLength()); | 350 CFX_ByteString bsName = PDF_EncodeText(wsName.c_str(), wsName.GetLength()); |
| 352 CPDF_Object* pObject = nametree.LookupValue(bsName); | 351 CPDF_Object* pObject = nametree.LookupValue(bsName); |
| 353 if (!pObject) { | 352 if (!pObject) { |
| 354 int32_t iCount = nametree.GetCount(); | 353 for (size_t i = 0; i < nametree.GetCount(); i++) { |
| 355 for (int32_t i = 0; i < iCount; i++) { | |
| 356 CFX_ByteString bsTemp; | 354 CFX_ByteString bsTemp; |
| 357 CPDF_Object* pTempObject = nametree.LookupValue(i, bsTemp); | 355 CPDF_Object* pTempObject = nametree.LookupValue(i, bsTemp); |
| 358 if (bsTemp == bsName) { | 356 if (bsTemp == bsName) { |
| 359 pObject = pTempObject; | 357 pObject = pTempObject; |
| 360 break; | 358 break; |
| 361 } | 359 } |
| 362 } | 360 } |
| 363 } | 361 } |
| 364 | 362 |
| 365 if (!pObject || !pObject->IsStream()) | 363 if (!pObject || !pObject->IsStream()) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 420 } |
| 423 pExport->Release(); | 421 pExport->Release(); |
| 424 return bFlags; | 422 return bFlags; |
| 425 } | 423 } |
| 426 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { | 424 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { |
| 427 std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>> | 425 std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>> |
| 428 importer(new CXFA_DataImporter(m_pDocument)); | 426 importer(new CXFA_DataImporter(m_pDocument)); |
| 429 | 427 |
| 430 return importer->ImportData(pStream); | 428 return importer->ImportData(pStream); |
| 431 } | 429 } |
| OLD | NEW |