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

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2334323005: Rename dictionary set and get methods (Closed)
Patch Set: Created 4 years, 3 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/fpdfsave.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 CPDF_Document* pdfDoc = 390 CPDF_Document* pdfDoc =
391 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); 391 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc();
392 if (!pdfDoc) 392 if (!pdfDoc)
393 return FALSE; 393 return FALSE;
394 394
395 CPDF_Dictionary* pRoot = pdfDoc->GetRoot(); 395 CPDF_Dictionary* pRoot = pdfDoc->GetRoot();
396 if (!pRoot) 396 if (!pRoot)
397 return FALSE; 397 return FALSE;
398 398
399 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); 399 CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
400 if (!pAcroForm) 400 if (!pAcroForm)
401 return FALSE; 401 return FALSE;
402 402
403 CPDF_Object* pXFA = pAcroForm->GetObjectBy("XFA"); 403 CPDF_Object* pXFA = pAcroForm->GetObjectFor("XFA");
404 if (!pXFA) 404 if (!pXFA)
405 return FALSE; 405 return FALSE;
406 406
407 bool bDynamicXFA = pRoot->GetBooleanBy("NeedsRendering", false); 407 bool bDynamicXFA = pRoot->GetBooleanFor("NeedsRendering", false);
408 *docType = bDynamicXFA ? DOCTYPE_DYNAMIC_XFA : DOCTYPE_STATIC_XFA; 408 *docType = bDynamicXFA ? DOCTYPE_DYNAMIC_XFA : DOCTYPE_STATIC_XFA;
409 return TRUE; 409 return TRUE;
410 } 410 }
411 411
412 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) { 412 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) {
413 return document && (static_cast<CPDFXFA_Document*>(document))->LoadXFADoc(); 413 return document && (static_cast<CPDFXFA_Document*>(document))->LoadXFADoc();
414 } 414 }
415 #endif // PDF_ENABLE_XFA 415 #endif // PDF_ENABLE_XFA
416 416
417 class CMemFile final : public IFX_FileRead { 417 class CMemFile final : public IFX_FileRead {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 512
513 return pDoc->GetUserPermissions(); 513 return pDoc->GetUserPermissions();
514 } 514 }
515 515
516 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) { 516 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) {
517 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 517 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
518 if (!pDoc || !pDoc->GetParser()) 518 if (!pDoc || !pDoc->GetParser())
519 return -1; 519 return -1;
520 520
521 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); 521 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict();
522 return pDict ? pDict->GetIntegerBy("R") : -1; 522 return pDict ? pDict->GetIntegerFor("R") : -1;
523 } 523 }
524 524
525 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) { 525 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) {
526 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 526 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
527 return pDoc ? pDoc->GetPageCount() : 0; 527 return pDoc ? pDoc->GetPageCount() : 0;
528 } 528 }
529 529
530 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, 530 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
531 int page_index) { 531 int page_index) {
532 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 532 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 984 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
985 if (!pDoc) 985 if (!pDoc)
986 return 0; 986 return 0;
987 987
988 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 988 CPDF_Dictionary* pRoot = pDoc->GetRoot();
989 if (!pRoot) 989 if (!pRoot)
990 return 0; 990 return 0;
991 991
992 CPDF_NameTree nameTree(pDoc, "Dests"); 992 CPDF_NameTree nameTree(pDoc, "Dests");
993 pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount(); 993 pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount();
994 CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests"); 994 CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests");
995 if (pDest) 995 if (pDest)
996 count += pDest->GetCount(); 996 count += pDest->GetCount();
997 997
998 if (!count.IsValid()) 998 if (!count.IsValid())
999 return 0; 999 return 0;
1000 1000
1001 return count.ValueOrDie(); 1001 return count.ValueOrDie();
1002 } 1002 }
1003 1003
1004 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, 1004 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1083
1084 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 1084 CPDF_Dictionary* pRoot = pDoc->GetRoot();
1085 if (!pRoot) 1085 if (!pRoot)
1086 return nullptr; 1086 return nullptr;
1087 1087
1088 CPDF_Object* pDestObj = nullptr; 1088 CPDF_Object* pDestObj = nullptr;
1089 CFX_ByteString bsName; 1089 CFX_ByteString bsName;
1090 CPDF_NameTree nameTree(pDoc, "Dests"); 1090 CPDF_NameTree nameTree(pDoc, "Dests");
1091 int count = nameTree.GetCount(); 1091 int count = nameTree.GetCount();
1092 if (index >= count) { 1092 if (index >= count) {
1093 CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests"); 1093 CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests");
1094 if (!pDest) 1094 if (!pDest)
1095 return nullptr; 1095 return nullptr;
1096 1096
1097 pdfium::base::CheckedNumeric<int> checked_count = count; 1097 pdfium::base::CheckedNumeric<int> checked_count = count;
1098 checked_count += pDest->GetCount(); 1098 checked_count += pDest->GetCount();
1099 if (!checked_count.IsValid() || index >= checked_count.ValueOrDie()) 1099 if (!checked_count.IsValid() || index >= checked_count.ValueOrDie())
1100 return nullptr; 1100 return nullptr;
1101 1101
1102 index -= count; 1102 index -= count;
1103 int i = 0; 1103 int i = 0;
1104 for (const auto& it : *pDest) { 1104 for (const auto& it : *pDest) {
1105 bsName = it.first; 1105 bsName = it.first;
1106 pDestObj = it.second; 1106 pDestObj = it.second;
1107 if (!pDestObj) 1107 if (!pDestObj)
1108 continue; 1108 continue;
1109 if (i == index) 1109 if (i == index)
1110 break; 1110 break;
1111 i++; 1111 i++;
1112 } 1112 }
1113 } else { 1113 } else {
1114 pDestObj = nameTree.LookupValue(index, bsName); 1114 pDestObj = nameTree.LookupValue(index, bsName);
1115 } 1115 }
1116 if (!pDestObj) 1116 if (!pDestObj)
1117 return nullptr; 1117 return nullptr;
1118 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { 1118 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) {
1119 pDestObj = pDict->GetArrayBy("D"); 1119 pDestObj = pDict->GetArrayFor("D");
1120 if (!pDestObj) 1120 if (!pDestObj)
1121 return nullptr; 1121 return nullptr;
1122 } 1122 }
1123 if (!pDestObj->IsArray()) 1123 if (!pDestObj->IsArray())
1124 return nullptr; 1124 return nullptr;
1125 1125
1126 CFX_WideString wsName = PDF_DecodeText(bsName); 1126 CFX_WideString wsName = PDF_DecodeText(bsName);
1127 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); 1127 CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
1128 int len = utf16Name.GetLength(); 1128 int len = utf16Name.GetLength();
1129 if (!buffer) { 1129 if (!buffer) {
1130 *buflen = len; 1130 *buflen = len;
1131 } else if (*buflen >= len) { 1131 } else if (*buflen >= len) {
1132 memcpy(buffer, utf16Name.c_str(), len); 1132 memcpy(buffer, utf16Name.c_str(), len);
1133 *buflen = len; 1133 *buflen = len;
1134 } else { 1134 } else {
1135 *buflen = -1; 1135 *buflen = -1;
1136 } 1136 }
1137 return (FPDF_DEST)pDestObj; 1137 return (FPDF_DEST)pDestObj;
1138 } 1138 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfsave.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698