diff options
author | Lei Zhang <thestig@chromium.org> | 2018-04-12 17:24:45 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-12 17:24:45 +0000 |
commit | 822886b0c4478eb339fc5e2ec89f3fbdd78d57be (patch) | |
tree | b51a1b4748fd8503beb05b4a22dd2d9d4740908a /fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | |
parent | 56cc5c12a7f569f218c44a6186cdc3676ea0793b (diff) | |
download | pdfium-822886b0c4478eb339fc5e2ec89f3fbdd78d57be.tar.xz |
Add return value to FPDF_DeviceToPage().
Do the same for FPDF_PageToDevice(). Clean up the internal
implementation as well.
Change-Id: Ia207bfa779d144cb9f0310e768750ab10e603b8f
Reviewed-on: https://pdfium-review.googlesource.com/17370
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfxfa/cpdfxfa_page.cpp')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index d4a6d95574..8fea85d72b 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -126,34 +126,28 @@ float CPDFXFA_Page::GetPageHeight() const { return 0.0f; } -void CPDFXFA_Page::DeviceToPage(const FX_RECT& rect, - int rotate, - const CFX_PointF& device_point, - double* page_x, - double* page_y) const { +Optional<CFX_PointF> CPDFXFA_Page::DeviceToPage( + const FX_RECT& rect, + int rotate, + const CFX_PointF& device_point) const { if (!m_pPDFPage && !m_pXFAPageView) - return; + return {}; CFX_PointF pos = GetDisplayMatrix(rect, rotate).GetInverse().Transform(device_point); - *page_x = pos.x; - *page_y = pos.y; + return pos; } -void CPDFXFA_Page::PageToDevice(const FX_RECT& rect, - int rotate, - double page_x, - double page_y, - int* device_x, - int* device_y) const { +Optional<CFX_PointF> CPDFXFA_Page::PageToDevice(const FX_RECT& rect, + int rotate, + double page_x, + double page_y) const { if (!m_pPDFPage && !m_pXFAPageView) - return; + return {}; CFX_Matrix page2device = GetDisplayMatrix(rect, rotate); - CFX_PointF pos = page2device.Transform( + return page2device.Transform( CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y))); - *device_x = FXSYS_round(pos.x); - *device_y = FXSYS_round(pos.y); } CFX_Matrix CPDFXFA_Page::GetDisplayMatrix(const FX_RECT& rect, |