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

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

Issue 1644633003: Member function name refactoring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 11 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/fpdfppo.cpp ('k') | fpdfsdk/src/fsdk_actionhandler.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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 264
265 // jabdelmalek: changed return type from FX_DWORD to build on Linux (and match 265 // jabdelmalek: changed return type from FX_DWORD to build on Linux (and match
266 // header). 266 // header).
267 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) { 267 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) {
268 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 268 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
269 if (!pDoc) 269 if (!pDoc)
270 return 0; 270 return 0;
271 271
272 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); 272 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict();
273 return pDict ? pDict->GetInteger("P") : (FX_DWORD)-1; 273 return pDict ? pDict->GetIntegerBy("P") : (FX_DWORD)-1;
274 } 274 }
275 275
276 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) { 276 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) {
277 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 277 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
278 if (!pDoc) 278 if (!pDoc)
279 return -1; 279 return -1;
280 280
281 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); 281 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict();
282 return pDict ? pDict->GetInteger("R") : -1; 282 return pDict ? pDict->GetIntegerBy("R") : -1;
283 } 283 }
284 284
285 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) { 285 DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document) {
286 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 286 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
287 return pDoc ? pDoc->GetPageCount() : 0; 287 return pDoc ? pDoc->GetPageCount() : 0;
288 } 288 }
289 289
290 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, 290 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
291 int page_index) { 291 int page_index) {
292 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 292 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 825 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
826 if (!pDoc) 826 if (!pDoc)
827 return 0; 827 return 0;
828 828
829 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 829 CPDF_Dictionary* pRoot = pDoc->GetRoot();
830 if (!pRoot) 830 if (!pRoot)
831 return 0; 831 return 0;
832 832
833 CPDF_NameTree nameTree(pDoc, "Dests"); 833 CPDF_NameTree nameTree(pDoc, "Dests");
834 pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount(); 834 pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount();
835 CPDF_Dictionary* pDest = pRoot->GetDict("Dests"); 835 CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests");
836 if (pDest) 836 if (pDest)
837 count += pDest->GetCount(); 837 count += pDest->GetCount();
838 838
839 if (!count.IsValid()) 839 if (!count.IsValid())
840 return 0; 840 return 0;
841 841
842 return count.ValueOrDie(); 842 return count.ValueOrDie();
843 } 843 }
844 844
845 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, 845 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
(...skipping 25 matching lines...) Expand all
871 871
872 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 872 CPDF_Dictionary* pRoot = pDoc->GetRoot();
873 if (!pRoot) 873 if (!pRoot)
874 return nullptr; 874 return nullptr;
875 875
876 CPDF_Object* pDestObj = nullptr; 876 CPDF_Object* pDestObj = nullptr;
877 CFX_ByteString bsName; 877 CFX_ByteString bsName;
878 CPDF_NameTree nameTree(pDoc, "Dests"); 878 CPDF_NameTree nameTree(pDoc, "Dests");
879 int count = nameTree.GetCount(); 879 int count = nameTree.GetCount();
880 if (index >= count) { 880 if (index >= count) {
881 CPDF_Dictionary* pDest = pRoot->GetDict("Dests"); 881 CPDF_Dictionary* pDest = pRoot->GetDictBy("Dests");
882 if (!pDest) 882 if (!pDest)
883 return nullptr; 883 return nullptr;
884 884
885 pdfium::base::CheckedNumeric<int> checked_count = count; 885 pdfium::base::CheckedNumeric<int> checked_count = count;
886 checked_count += pDest->GetCount(); 886 checked_count += pDest->GetCount();
887 if (!checked_count.IsValid() || index >= checked_count.ValueOrDie()) 887 if (!checked_count.IsValid() || index >= checked_count.ValueOrDie())
888 return nullptr; 888 return nullptr;
889 889
890 index -= count; 890 index -= count;
891 int i = 0; 891 int i = 0;
892 for (const auto& it : *pDest) { 892 for (const auto& it : *pDest) {
893 bsName = it.first; 893 bsName = it.first;
894 pDestObj = it.second; 894 pDestObj = it.second;
895 if (!pDestObj) 895 if (!pDestObj)
896 continue; 896 continue;
897 if (i == index) 897 if (i == index)
898 break; 898 break;
899 i++; 899 i++;
900 } 900 }
901 } else { 901 } else {
902 pDestObj = nameTree.LookupValue(index, bsName); 902 pDestObj = nameTree.LookupValue(index, bsName);
903 } 903 }
904 if (!pDestObj) 904 if (!pDestObj)
905 return nullptr; 905 return nullptr;
906 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) { 906 if (CPDF_Dictionary* pDict = pDestObj->AsDictionary()) {
907 pDestObj = pDict->GetArray("D"); 907 pDestObj = pDict->GetArrayBy("D");
908 if (!pDestObj) 908 if (!pDestObj)
909 return nullptr; 909 return nullptr;
910 } 910 }
911 if (!pDestObj->IsArray()) 911 if (!pDestObj->IsArray())
912 return nullptr; 912 return nullptr;
913 913
914 CFX_WideString wsName = PDF_DecodeText(bsName); 914 CFX_WideString wsName = PDF_DecodeText(bsName);
915 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); 915 CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
916 unsigned int len = utf16Name.GetLength(); 916 unsigned int len = utf16Name.GetLength();
917 if (!buffer) { 917 if (!buffer) {
918 *buflen = len; 918 *buflen = len;
919 } else if (*buflen >= len) { 919 } else if (*buflen >= len) {
920 memcpy(buffer, utf16Name.c_str(), len); 920 memcpy(buffer, utf16Name.c_str(), len);
921 *buflen = len; 921 *buflen = len;
922 } else { 922 } else {
923 *buflen = -1; 923 *buflen = -1;
924 } 924 }
925 return (FPDF_DEST)pDestObj; 925 return (FPDF_DEST)pDestObj;
926 } 926 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfppo.cpp ('k') | fpdfsdk/src/fsdk_actionhandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698