diff options
author | Lei Zhang <thestig@chromium.org> | 2018-06-09 00:06:06 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-09 00:06:06 +0000 |
commit | 9bc7a213b95439ab91183ac6684bf01e09ae60c1 (patch) | |
tree | 09bc35da1185be91bea4c2dc9903569b612247b6 | |
parent | 821ae927144152a5122d602753907bd423aa06d0 (diff) | |
download | pdfium-chromium/3455.tar.xz |
Consolidate bounding box logic.chromium/3455chromium/3454
Move all the checks into the shared helper functions for getting/setting
bounding boxes.
Change-Id: I6f597f478fd3510e0528d20a0a7820949600fd2a
Reviewed-on: https://pdfium-review.googlesource.com/34692
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | fpdfsdk/fpdf_transformpage.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index af6ac792fb..267b582a47 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -28,7 +28,8 @@ namespace { void SetBoundingBox(CPDF_Page* page, const ByteString& key, const CFX_FloatRect& rect) { - page->GetDict()->SetRectFor(key, rect); + if (page) + page->GetDict()->SetRectFor(key, rect); } bool GetBoundingBox(CPDF_Page* page, @@ -37,7 +38,7 @@ bool GetBoundingBox(CPDF_Page* page, float* bottom, float* right, float* top) { - if (!left || !bottom || !right || !top) + if (!page || !left || !bottom || !right || !top) return false; CPDF_Array* pArray = page->GetDict()->GetArrayFor(key); @@ -64,11 +65,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page, float bottom, float right, float top) { - CPDF_Page* pPage = CPDFPageFromFPDFPage(page); - if (!pPage) - return; - - SetBoundingBox(pPage, pdfium::page_object::kMediaBox, + SetBoundingBox(CPDFPageFromFPDFPage(page), pdfium::page_object::kMediaBox, CFX_FloatRect(left, bottom, right, top)); } @@ -77,11 +74,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page, float bottom, float right, float top) { - CPDF_Page* pPage = CPDFPageFromFPDFPage(page); - if (!pPage) - return; - - SetBoundingBox(pPage, pdfium::page_object::kCropBox, + SetBoundingBox(CPDFPageFromFPDFPage(page), pdfium::page_object::kCropBox, CFX_FloatRect(left, bottom, right, top)); } @@ -90,9 +83,9 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page, float* bottom, float* right, float* top) { - CPDF_Page* pPage = CPDFPageFromFPDFPage(page); - return pPage && GetBoundingBox(pPage, pdfium::page_object::kMediaBox, left, - bottom, right, top); + return GetBoundingBox(CPDFPageFromFPDFPage(page), + pdfium::page_object::kMediaBox, left, bottom, right, + top); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page, @@ -100,9 +93,9 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page, float* bottom, float* right, float* top) { - CPDF_Page* pPage = CPDFPageFromFPDFPage(page); - return pPage && GetBoundingBox(pPage, pdfium::page_object::kCropBox, left, - bottom, right, top); + return GetBoundingBox(CPDFPageFromFPDFPage(page), + pdfium::page_object::kCropBox, left, bottom, right, + top); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |