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

Side by Side Diff: fpdfsdk/src/fpdfview.cpp

Issue 1648233002: Merge to XFA: Member function name refactoring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: more xfa changes Created 4 years, 10 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/src/fpdfsave.cpp ('k') | fpdfsdk/src/fpdfxfa/fpdfxfa_doc.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/fpdfview.h" 7 #include "public/fpdfview.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 CPDF_Document* pdfDoc = 341 CPDF_Document* pdfDoc =
342 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); 342 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc();
343 if (!pdfDoc) 343 if (!pdfDoc)
344 return FALSE; 344 return FALSE;
345 345
346 CPDF_Dictionary* pRoot = pdfDoc->GetRoot(); 346 CPDF_Dictionary* pRoot = pdfDoc->GetRoot();
347 if (!pRoot) 347 if (!pRoot)
348 return FALSE; 348 return FALSE;
349 349
350 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); 350 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
351 if (!pAcroForm) 351 if (!pAcroForm)
352 return FALSE; 352 return FALSE;
353 353
354 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); 354 CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
355 if (!pXFA) 355 if (!pXFA)
356 return FALSE; 356 return FALSE;
357 357
358 FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE); 358 FX_BOOL bDynamicXFA = pRoot->GetBooleanBy("NeedsRendering", FALSE);
359 359
360 if (bDynamicXFA) 360 if (bDynamicXFA)
361 *docType = DOCTYPE_DYNAMIC_XFA; 361 *docType = DOCTYPE_DYNAMIC_XFA;
362 else 362 else
363 *docType = DOCTYPE_STATIC_XFA; 363 *docType = DOCTYPE_STATIC_XFA;
364 364
365 return TRUE; 365 return TRUE;
366 } 366 }
367 367
368 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) { 368 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) { 456 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) {
457 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 457 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
458 if (!pDoc) 458 if (!pDoc)
459 #ifndef PDF_ENABLE_XFA 459 #ifndef PDF_ENABLE_XFA
460 return 0; 460 return 0;
461 #else // PDF_ENABLE_XFA 461 #else // PDF_ENABLE_XFA
462 return (FX_DWORD)-1; 462 return (FX_DWORD)-1;
463 #endif // PDF_ENABLE_XFA 463 #endif // PDF_ENABLE_XFA
464 464
465 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); 465 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict();
466 return pDict ? pDict->GetInteger("P") : (FX_DWORD)-1; 466 return pDict ? pDict->GetIntegerBy("P") : (FX_DWORD)-1;
467 } 467 }
468 468
469 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) { 469 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) {
470 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 470 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
471 if (!pDoc) 471 if (!pDoc)
472 return -1; 472 return -1;
473 473
474 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); 474 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict();
475 return pDict ? pDict->GetInteger("R") : -1; 475 return pDict ? pDict->GetIntegerBy("R") : -1;
476 } 476 }
477 477
478 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) { 478 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) {
479 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 479 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
480 return pDoc ? pDoc->GetPageCount() : 0; 480 return pDoc ? pDoc->GetPageCount() : 0;
481 } 481 }
482 482
483 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, 483 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
484 int page_index) { 484 int page_index) {
485 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 485 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 1047 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
1048 if (!pDoc) 1048 if (!pDoc)
1049 return 0; 1049 return 0;
1050 1050
1051 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 1051 CPDF_Dictionary* pRoot = pDoc->GetRoot();
1052 if (!pRoot) 1052 if (!pRoot)
1053 return 0; 1053 return 0;
1054 1054
1055 CPDF_NameTree nameTree(pDoc, "Dests"); 1055 CPDF_NameTree nameTree(pDoc, "Dests");
1056 pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount(); 1056 pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount();
1057 CPDF_Dictionary* pDest = pRoot->GetDict("Dests"); 1057 CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests");
1058 if (pDest) 1058 if (pDest)
1059 count += pDest->GetCount(); 1059 count += pDest->GetCount();
1060 1060
1061 if (!count.IsValid()) 1061 if (!count.IsValid())
1062 return 0; 1062 return 0;
1063 1063
1064 return count.ValueOrDie(); 1064 return count.ValueOrDie();
1065 } 1065 }
1066 1066
1067 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, 1067 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1147
1148 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 1148 CPDF_Dictionary* pRoot = pDoc->GetRoot();
1149 if (!pRoot) 1149 if (!pRoot)
1150 return nullptr; 1150 return nullptr;
1151 1151
1152 CPDF_Object* pDestObj = nullptr; 1152 CPDF_Object* pDestObj = nullptr;
1153 CFX_ByteString bsName; 1153 CFX_ByteString bsName;
1154 CPDF_NameTree nameTree(pDoc, "Dests"); 1154 CPDF_NameTree nameTree(pDoc, "Dests");
1155 int count = nameTree.GetCount(); 1155 int count = nameTree.GetCount();
1156 if (index >= count) { 1156 if (index >= count) {
1157 CPDF_Dictionary* pDest = pRoot->GetDict("Dests"); 1157 CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests");
1158 if (!pDest) 1158 if (!pDest)
1159 return nullptr; 1159 return nullptr;
1160 1160
1161 pdfium::base::CheckedNumeric<int> checked_count = count; 1161 pdfium::base::CheckedNumeric<int> checked_count = count;
1162 checked_count += pDest->GetCount(); 1162 checked_count += pDest->GetCount();
1163 if (!checked_count.IsValid() || index >= checked_count.ValueOrDie()) 1163 if (!checked_count.IsValid() || index >= checked_count.ValueOrDie())
1164 return nullptr; 1164 return nullptr;
1165 1165
1166 index -= count; 1166 index -= count;
1167 int i = 0; 1167 int i = 0;
1168 for (const auto& it : *pDest) { 1168 for (const auto& it : *pDest) {
1169 bsName = it.first; 1169 bsName = it.first;
1170 pDestObj = it.second; 1170 pDestObj = it.second;
1171 if (!pDestObj) 1171 if (!pDestObj)
1172 continue; 1172 continue;
1173 if (i == index) 1173 if (i == index)
1174 break; 1174 break;
1175 i++; 1175 i++;
1176 } 1176 }
1177 } else { 1177 } else {
1178 pDestObj = nameTree.LookupValue(index, bsName); 1178 pDestObj = nameTree.LookupValue(index, bsName);
1179 } 1179 }
1180 if (!pDestObj) 1180 if (!pDestObj)
1181 return nullptr; 1181 return nullptr;
1182 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { 1182 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) {
1183 pDestObj = pDict->GetArray("D"); 1183 pDestObj = pDict->GetArrayBy("D");
1184 if (!pDestObj) 1184 if (!pDestObj)
1185 return nullptr; 1185 return nullptr;
1186 } 1186 }
1187 if (!pDestObj->IsArray()) 1187 if (!pDestObj->IsArray())
1188 return nullptr; 1188 return nullptr;
1189 1189
1190 CFX_WideString wsName = PDF_DecodeText(bsName); 1190 CFX_WideString wsName = PDF_DecodeText(bsName);
1191 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); 1191 CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
1192 unsigned int len = utf16Name.GetLength(); 1192 unsigned int len = utf16Name.GetLength();
1193 if (!buffer) { 1193 if (!buffer) {
1194 *buflen = len; 1194 *buflen = len;
1195 } else if (*buflen >= len) { 1195 } else if (*buflen >= len) {
1196 memcpy(buffer, utf16Name.c_str(), len); 1196 memcpy(buffer, utf16Name.c_str(), len);
1197 *buflen = len; 1197 *buflen = len;
1198 } else { 1198 } else {
1199 *buflen = -1; 1199 *buflen = -1;
1200 } 1200 }
1201 return (FPDF_DEST)pDestObj; 1201 return (FPDF_DEST)pDestObj;
1202 } 1202 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfsave.cpp ('k') | fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698