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

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2354933002: Rename CPDFXFA_Document::GetPageCount (Closed)
Patch Set: Created 4 years, 2 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
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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->GetIntegerFor("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 if (!pDoc)
528 return 0;
529
530 #ifdef PDF_ENABLE_XFA
531 return pDoc->GetXFAPageCount();
532 #else // PDF_ENABLE_XFA
533 return pDoc->GetPageCount();
534 #endif // PDF_ENABLE_XFA
528 } 535 }
529 536
530 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, 537 DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
531 int page_index) { 538 int page_index) {
532 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 539 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
533 if (!pDoc) 540 if (!pDoc)
534 return nullptr; 541 return nullptr;
535 542
543 #ifdef PDF_ENABLE_XFA
544 if (page_index < 0 || page_index >= pDoc->GetXFAPageCount())
545 return nullptr;
546 return pDoc->GetXFAPage(page_index);
547 #else // PDF_ENABLE_XFA
536 if (page_index < 0 || page_index >= pDoc->GetPageCount()) 548 if (page_index < 0 || page_index >= pDoc->GetPageCount())
537 return nullptr; 549 return nullptr;
538 550
539 #ifdef PDF_ENABLE_XFA
540 return pDoc->GetXFAPage(page_index);
541 #else // PDF_ENABLE_XFA
542 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); 551 CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
543 if (!pDict) 552 if (!pDict)
544 return nullptr; 553 return nullptr;
545 554
546 CPDF_Page* pPage = new CPDF_Page(pDoc, pDict, true); 555 CPDF_Page* pPage = new CPDF_Page(pDoc, pDict, true);
547 pPage->ParseContent(); 556 pPage->ParseContent();
548 return pPage; 557 return pPage;
549 #endif // PDF_ENABLE_XFA 558 #endif // PDF_ENABLE_XFA
550 } 559 }
551 560
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 919
911 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, 920 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
912 int page_index, 921 int page_index,
913 double* width, 922 double* width,
914 double* height) { 923 double* height) {
915 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 924 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
916 if (!pDoc) 925 if (!pDoc)
917 return FALSE; 926 return FALSE;
918 927
919 #ifdef PDF_ENABLE_XFA 928 #ifdef PDF_ENABLE_XFA
920 int count = pDoc->GetPageCount(); 929 int count = pDoc->GetXFAPageCount();
921 if (page_index < 0 || page_index >= count) 930 if (page_index < 0 || page_index >= count)
922 return FALSE; 931 return FALSE;
923 CPDFXFA_Page* pPage = pDoc->GetXFAPage(page_index); 932 CPDFXFA_Page* pPage = pDoc->GetXFAPage(page_index);
924 if (!pPage) 933 if (!pPage)
925 return FALSE; 934 return FALSE;
926 *width = pPage->GetPageWidth(); 935 *width = pPage->GetPageWidth();
927 *height = pPage->GetPageHeight(); 936 *height = pPage->GetPageHeight();
928 #else // PDF_ENABLE_XFA 937 #else // PDF_ENABLE_XFA
929 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); 938 CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
930 if (!pDict) 939 if (!pDict)
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 if (!buffer) { 1138 if (!buffer) {
1130 *buflen = len; 1139 *buflen = len;
1131 } else if (*buflen >= len) { 1140 } else if (*buflen >= len) {
1132 memcpy(buffer, utf16Name.c_str(), len); 1141 memcpy(buffer, utf16Name.c_str(), len);
1133 *buflen = len; 1142 *buflen = len;
1134 } else { 1143 } else {
1135 *buflen = -1; 1144 *buflen = -1;
1136 } 1145 }
1137 return (FPDF_DEST)pDestObj; 1146 return (FPDF_DEST)pDestObj;
1138 } 1147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698