Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 return nullptr; | 495 return nullptr; |
| 496 | 496 |
| 497 if (page_index < 0 || page_index >= pDoc->GetPageCount()) | 497 if (page_index < 0 || page_index >= pDoc->GetPageCount()) |
| 498 return nullptr; | 498 return nullptr; |
| 499 | 499 |
| 500 #ifdef PDF_ENABLE_XFA | 500 #ifdef PDF_ENABLE_XFA |
| 501 return pDoc->GetPage(page_index); | 501 return pDoc->GetPage(page_index); |
| 502 #else // PDF_ENABLE_XFA | 502 #else // PDF_ENABLE_XFA |
| 503 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); | 503 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); |
| 504 if (!pDict) | 504 if (!pDict) |
| 505 return NULL; | 505 return nullptr; |
| 506 CPDF_Page* pPage = new CPDF_Page; | 506 |
| 507 pPage->Load(pDoc, pDict); | 507 CPDF_Page* pPage = new CPDF_Page(pDoc, pDict, true); |
| 508 pPage->ParseContent(nullptr); | 508 pPage->ParseContent(); |
| 509 return pPage; | 509 return pPage; |
| 510 #endif // PDF_ENABLE_XFA | 510 #endif // PDF_ENABLE_XFA |
| 511 } | 511 } |
| 512 | 512 |
| 513 DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) { | 513 DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) { |
| 514 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); | 514 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); |
| 515 return pPage ? pPage->GetPageWidth() : 0.0; | 515 return pPage ? pPage->GetPageWidth() : 0.0; |
| 516 } | 516 } |
| 517 | 517 |
| 518 DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) { | 518 DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) { |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 if (page_index < 0 || page_index >= count) | 950 if (page_index < 0 || page_index >= count) |
| 951 return FALSE; | 951 return FALSE; |
| 952 CPDFXFA_Page* pPage = pDoc->GetPage(page_index); | 952 CPDFXFA_Page* pPage = pDoc->GetPage(page_index); |
| 953 if (!pPage) | 953 if (!pPage) |
| 954 return FALSE; | 954 return FALSE; |
| 955 *width = pPage->GetPageWidth(); | 955 *width = pPage->GetPageWidth(); |
| 956 *height = pPage->GetPageHeight(); | 956 *height = pPage->GetPageHeight(); |
| 957 #else // PDF_ENABLE_XFA | 957 #else // PDF_ENABLE_XFA |
| 958 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); | 958 CPDF_Dictionary* pDict = pDoc->GetPage(page_index); |
| 959 if (!pDict) | 959 if (!pDict) |
| 960 return FALSE; | 960 return false; |
|
dsinclair
2016/04/26 02:42:26
Should this be FALSE for consistency?
nit: blank
Lei Zhang
2016/04/26 04:24:45
Whoops, reverted.
| |
| 961 CPDF_Page page; | 961 CPDF_Page page(pDoc, pDict, true); |
|
Lei Zhang
2016/04/26 01:22:21
This is the only instance that does not call Parse
| |
| 962 page.Load(pDoc, pDict); | |
| 963 *width = page.GetPageWidth(); | 962 *width = page.GetPageWidth(); |
| 964 *height = page.GetPageHeight(); | 963 *height = page.GetPageHeight(); |
| 965 #endif // PDF_ENABLE_XFA | 964 #endif // PDF_ENABLE_XFA |
| 966 | 965 |
| 967 return TRUE; | 966 return TRUE; |
| 968 } | 967 } |
| 969 | 968 |
| 970 DLLEXPORT FPDF_BOOL STDCALL | 969 DLLEXPORT FPDF_BOOL STDCALL |
| 971 FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document) { | 970 FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document) { |
| 972 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 971 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1161 if (!buffer) { | 1160 if (!buffer) { |
| 1162 *buflen = len; | 1161 *buflen = len; |
| 1163 } else if (*buflen >= len) { | 1162 } else if (*buflen >= len) { |
| 1164 memcpy(buffer, utf16Name.c_str(), len); | 1163 memcpy(buffer, utf16Name.c_str(), len); |
| 1165 *buflen = len; | 1164 *buflen = len; |
| 1166 } else { | 1165 } else { |
| 1167 *buflen = -1; | 1166 *buflen = -1; |
| 1168 } | 1167 } |
| 1169 return (FPDF_DEST)pDestObj; | 1168 return (FPDF_DEST)pDestObj; |
| 1170 } | 1169 } |
| OLD | NEW |