summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.cpp30
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.h19
2 files changed, 20 insertions, 29 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,
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
index aef1b0b539..131e811b66 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
@@ -13,6 +13,7 @@
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "third_party/base/optional.h"
class CPDFXFA_Context;
class CPDF_Dictionary;
@@ -38,17 +39,13 @@ class CPDFXFA_Page : public Retainable {
float GetPageWidth() const;
float GetPageHeight() const;
- void DeviceToPage(const FX_RECT& rect,
- int rotate,
- const CFX_PointF& device_point,
- double* page_x,
- double* page_y) const;
- void PageToDevice(const FX_RECT& rect,
- int rotate,
- double page_x,
- double page_y,
- int* device_x,
- int* device_y) const;
+ Optional<CFX_PointF> DeviceToPage(const FX_RECT& rect,
+ int rotate,
+ const CFX_PointF& device_point) const;
+ Optional<CFX_PointF> PageToDevice(const FX_RECT& rect,
+ int rotate,
+ double page_x,
+ double page_y) const;
CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const;