Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp

Issue 2051233002: Remove more casts, part 7. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | fpdfsdk/fsdk_annothandler.cpp » ('j') | xfa/fxfa/include/xfa_checksum.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 return; 670 return;
671 671
672 int size = pArray->GetCount(); 672 int size = pArray->GetCount();
673 for (int i = 1; i < size; i += 2) { 673 for (int i = 1; i < size; i += 2) {
674 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); 674 CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
675 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); 675 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
676 if (!pPrePDFObj->IsString()) 676 if (!pPrePDFObj->IsString())
677 continue; 677 continue;
678 if (!pPDFObj->IsReference()) 678 if (!pPDFObj->IsReference())
679 continue; 679 continue;
680 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); 680 CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect());
681 if (!pDirectObj->IsStream()) 681 if (!pStream)
682 continue; 682 continue;
683 if (pPrePDFObj->GetString() == "form") { 683 if (pPrePDFObj->GetString() == "form") {
684 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, &fileWrite, 684 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, &fileWrite,
685 nullptr); 685 nullptr);
686 } else if (pPrePDFObj->GetString() == "datasets") { 686 } else if (pPrePDFObj->GetString() == "datasets") {
687 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, &fileWrite, 687 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, &fileWrite,
688 nullptr); 688 nullptr);
689 } else { 689 } else {
690 if (i == size - 1) { 690 if (i == size - 1) {
691 CFX_WideString wPath = CFX_WideString::FromUTF16LE( 691 CFX_WideString wPath = CFX_WideString::FromUTF16LE(
692 reinterpret_cast<const unsigned short*>(bs.c_str()), 692 reinterpret_cast<const unsigned short*>(bs.c_str()),
693 bs.GetLength() / sizeof(unsigned short)); 693 bs.GetLength() / sizeof(unsigned short));
694 CFX_ByteString bPath = wPath.UTF8Encode(); 694 CFX_ByteString bPath = wPath.UTF8Encode();
695 const char* szFormat = 695 const char* szFormat =
696 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; 696 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
697 content.Format(szFormat, bPath.c_str()); 697 content.Format(szFormat, bPath.c_str());
698 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), 698 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
699 content.GetLength()); 699 content.GetLength());
700 } 700 }
701 701 std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc);
702 CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj;
703 CPDF_StreamAcc* pAcc = new CPDF_StreamAcc;
704 pAcc->LoadAllData(pStream); 702 pAcc->LoadAllData(pStream);
705 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), 703 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(),
706 pAcc->GetSize()); 704 pAcc->GetSize());
707 delete pAcc;
708 } 705 }
709 } 706 }
710 } 707 }
711 if (!fileWrite.Flush()) { 708 if (!fileWrite.Flush()) {
712 // Ignoring flush error. 709 // Ignoring flush error.
713 } 710 }
714 } 711 }
715 void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, 712 void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc,
716 const CFX_WideString& wsFilePath) {} 713 const CFX_WideString& wsFilePath) {}
717 714
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 return FALSE; 1235 return FALSE;
1239 1236
1240 if (!m_pJSContext) { 1237 if (!m_pJSContext) {
1241 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc); 1238 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc);
1242 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); 1239 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext();
1243 } 1240 }
1244 1241
1245 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, 1242 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName,
1246 pValue); 1243 pValue);
1247 } 1244 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/fsdk_annothandler.cpp » ('j') | xfa/fxfa/include/xfa_checksum.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698