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

Side by Side Diff: fpdfsdk/fpdfsave.cpp

Issue 1841173002: Rename GetElementValue() to GetDirectObject{By,At}(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix test name Created 4 years, 8 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 | « fpdfsdk/fpdfppo.cpp ('k') | fpdfsdk/fpdfview.cpp » ('j') | no next file with comments »
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 "public/fpdf_save.h" 7 #include "public/fpdf_save.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return false; 94 return false;
95 95
96 CPDF_Dictionary* pRoot = pPDFDocument->GetRoot(); 96 CPDF_Dictionary* pRoot = pPDFDocument->GetRoot();
97 if (!pRoot) 97 if (!pRoot)
98 return false; 98 return false;
99 99
100 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); 100 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
101 if (!pAcroForm) 101 if (!pAcroForm)
102 return false; 102 return false;
103 103
104 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); 104 CPDF_Object* pXFA = pAcroForm->GetObjectBy("XFA");
105 if (!pXFA) 105 if (!pXFA)
106 return true; 106 return true;
107 107
108 if (!pXFA->IsArray()) 108 if (!pXFA->IsArray())
109 return false; 109 return false;
110 110
111 CPDF_Array* pArray = pXFA->GetArray(); 111 CPDF_Array* pArray = pXFA->GetArray();
112 if (!pArray) 112 if (!pArray)
113 return false; 113 return false;
114 114
115 int size = pArray->GetCount(); 115 int size = pArray->GetCount();
116 int iFormIndex = -1; 116 int iFormIndex = -1;
117 int iDataSetsIndex = -1; 117 int iDataSetsIndex = -1;
118 int iTemplate = -1; 118 int iTemplate = -1;
119 int iLast = size - 2; 119 int iLast = size - 2;
120 for (int i = 0; i < size - 1; i++) { 120 for (int i = 0; i < size - 1; i++) {
121 CPDF_Object* pPDFObj = pArray->GetElement(i); 121 CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
122 if (!pPDFObj->IsString()) 122 if (!pPDFObj->IsString())
123 continue; 123 continue;
124 if (pPDFObj->GetString() == "form") 124 if (pPDFObj->GetString() == "form")
125 iFormIndex = i + 1; 125 iFormIndex = i + 1;
126 else if (pPDFObj->GetString() == "datasets") 126 else if (pPDFObj->GetString() == "datasets")
127 iDataSetsIndex = i + 1; 127 iDataSetsIndex = i + 1;
128 else if (pPDFObj->GetString() == "template") 128 else if (pPDFObj->GetString() == "template")
129 iTemplate = i + 1; 129 iTemplate = i + 1;
130 } 130 }
131 std::unique_ptr<IXFA_ChecksumContext, ReleaseDeleter<IXFA_ChecksumContext>> 131 std::unique_ptr<IXFA_ChecksumContext, ReleaseDeleter<IXFA_ChecksumContext>>
132 pContext(XFA_Checksum_Create()); 132 pContext(XFA_Checksum_Create());
133 pContext->StartChecksum(); 133 pContext->StartChecksum();
134 134
135 // template 135 // template
136 if (iTemplate > -1) { 136 if (iTemplate > -1) {
137 CPDF_Stream* pTemplateStream = pArray->GetStreamAt(iTemplate); 137 CPDF_Stream* pTemplateStream = pArray->GetStreamAt(iTemplate);
138 CPDF_StreamAcc streamAcc; 138 CPDF_StreamAcc streamAcc;
139 streamAcc.LoadAllData(pTemplateStream); 139 streamAcc.LoadAllData(pTemplateStream);
140 uint8_t* pData = (uint8_t*)streamAcc.GetData(); 140 uint8_t* pData = (uint8_t*)streamAcc.GetData();
141 uint32_t dwSize2 = streamAcc.GetSize(); 141 uint32_t dwSize2 = streamAcc.GetSize();
142 ScopedFileStream pTemplate(FX_CreateMemoryStream(pData, dwSize2)); 142 ScopedFileStream pTemplate(FX_CreateMemoryStream(pData, dwSize2));
143 pContext->UpdateChecksum(pTemplate.get()); 143 pContext->UpdateChecksum(pTemplate.get());
144 } 144 }
145 CPDF_Stream* pFormStream = NULL; 145 CPDF_Stream* pFormStream = NULL;
146 CPDF_Stream* pDataSetsStream = NULL; 146 CPDF_Stream* pDataSetsStream = NULL;
147 if (iFormIndex != -1) { 147 if (iFormIndex != -1) {
148 // Get form CPDF_Stream 148 // Get form CPDF_Stream
149 CPDF_Object* pFormPDFObj = pArray->GetElement(iFormIndex); 149 CPDF_Object* pFormPDFObj = pArray->GetObjectAt(iFormIndex);
150 if (pFormPDFObj->IsReference()) { 150 if (pFormPDFObj->IsReference()) {
151 CPDF_Object* pFormDirectObj = pFormPDFObj->GetDirect(); 151 CPDF_Object* pFormDirectObj = pFormPDFObj->GetDirect();
152 if (pFormDirectObj && pFormDirectObj->IsStream()) { 152 if (pFormDirectObj && pFormDirectObj->IsStream()) {
153 pFormStream = (CPDF_Stream*)pFormDirectObj; 153 pFormStream = (CPDF_Stream*)pFormDirectObj;
154 } 154 }
155 } else if (pFormPDFObj->IsStream()) { 155 } else if (pFormPDFObj->IsStream()) {
156 pFormStream = (CPDF_Stream*)pFormPDFObj; 156 pFormStream = (CPDF_Stream*)pFormPDFObj;
157 } 157 }
158 } 158 }
159 159
160 if (iDataSetsIndex != -1) { 160 if (iDataSetsIndex != -1) {
161 // Get datasets CPDF_Stream 161 // Get datasets CPDF_Stream
162 CPDF_Object* pDataSetsPDFObj = pArray->GetElement(iDataSetsIndex); 162 CPDF_Object* pDataSetsPDFObj = pArray->GetObjectAt(iDataSetsIndex);
163 if (pDataSetsPDFObj->IsReference()) { 163 if (pDataSetsPDFObj->IsReference()) {
164 CPDF_Reference* pDataSetsRefObj = (CPDF_Reference*)pDataSetsPDFObj; 164 CPDF_Reference* pDataSetsRefObj = (CPDF_Reference*)pDataSetsPDFObj;
165 CPDF_Object* pDataSetsDirectObj = pDataSetsRefObj->GetDirect(); 165 CPDF_Object* pDataSetsDirectObj = pDataSetsRefObj->GetDirect();
166 if (pDataSetsDirectObj && pDataSetsDirectObj->IsStream()) { 166 if (pDataSetsDirectObj && pDataSetsDirectObj->IsStream()) {
167 pDataSetsStream = (CPDF_Stream*)pDataSetsDirectObj; 167 pDataSetsStream = (CPDF_Stream*)pDataSetsDirectObj;
168 } 168 }
169 } else if (pDataSetsPDFObj->IsStream()) { 169 } else if (pDataSetsPDFObj->IsStream()) {
170 pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj; 170 pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj;
171 } 171 }
172 } 172 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 FPDF_DWORD flags) { 320 FPDF_DWORD flags) {
321 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); 321 return FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0);
322 } 322 }
323 323
324 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, 324 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,
325 FPDF_FILEWRITE* pFileWrite, 325 FPDF_FILEWRITE* pFileWrite,
326 FPDF_DWORD flags, 326 FPDF_DWORD flags,
327 int fileVersion) { 327 int fileVersion) {
328 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); 328 return FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion);
329 } 329 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfppo.cpp ('k') | fpdfsdk/fpdfview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698