summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdf_view.cpp17
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.cpp24
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.h16
3 files changed, 17 insertions, 40 deletions
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index b04276ee51..51cfd8976b 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -743,12 +743,13 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page,
double* page_y) {
if (!page || !page_x || !page_y)
return;
+
UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
#ifdef PDF_ENABLE_XFA
- pPage->DeviceToPage(start_x, start_y, size_x, size_y, rotate, device_x,
- device_y, page_x, page_y);
+ pPage->DeviceToPage(rect, rotate, CFX_PointF(device_x, device_y), page_x,
+ page_y);
#else // PDF_ENABLE_XFA
- const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
CFX_Matrix page2device = pPage->GetDisplayMatrix(rect, rotate);
CFX_PointF pos = page2device.GetInverse().Transform(
@@ -769,16 +770,14 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page,
double page_y,
int* device_x,
int* device_y) {
- if (!device_x || !device_y)
+ if (!page || !device_x || !device_y)
return;
+
UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
- if (!pPage)
- return;
+ const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
#ifdef PDF_ENABLE_XFA
- pPage->PageToDevice(start_x, start_y, size_x, size_y, rotate, page_x, page_y,
- device_x, device_y);
+ pPage->PageToDevice(rect, rotate, page_x, page_y, device_x, device_y);
#else // PDF_ENABLE_XFA
- const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
CFX_Matrix page2device = pPage->GetDisplayMatrix(rect, rotate);
CFX_PointF pos = page2device.Transform(
CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)));
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index a43707a9cf..c3d5e18707 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -126,32 +126,21 @@ float CPDFXFA_Page::GetPageHeight() const {
return 0.0f;
}
-void CPDFXFA_Page::DeviceToPage(int start_x,
- int start_y,
- int size_x,
- int size_y,
+void CPDFXFA_Page::DeviceToPage(const FX_RECT& rect,
int rotate,
- int device_x,
- int device_y,
+ const CFX_PointF& device_point,
double* page_x,
double* page_y) {
if (!m_pPDFPage && !m_pXFAPageView)
return;
- const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
- CFX_PointF pos = GetDisplayMatrix(rect, rotate)
- .GetInverse()
- .Transform(CFX_PointF(static_cast<float>(device_x),
- static_cast<float>(device_y)));
-
+ CFX_PointF pos =
+ GetDisplayMatrix(rect, rotate).GetInverse().Transform(device_point);
*page_x = pos.x;
*page_y = pos.y;
}
-void CPDFXFA_Page::PageToDevice(int start_x,
- int start_y,
- int size_x,
- int size_y,
+void CPDFXFA_Page::PageToDevice(const FX_RECT& rect,
int rotate,
double page_x,
double page_y,
@@ -160,12 +149,9 @@ void CPDFXFA_Page::PageToDevice(int start_x,
if (!m_pPDFPage && !m_pXFAPageView)
return;
- const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
CFX_Matrix page2device = GetDisplayMatrix(rect, rotate);
-
CFX_PointF pos = 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);
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
index bdb4791c87..0acec981c6 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
@@ -9,16 +9,15 @@
#include <memory>
+#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
-class CFX_Matrix;
class CPDFXFA_Context;
class CPDF_Dictionary;
class CPDF_Page;
class CXFA_FFPageView;
-struct FX_RECT;
class CPDFXFA_Page : public Retainable {
public:
@@ -39,19 +38,12 @@ class CPDFXFA_Page : public Retainable {
float GetPageWidth() const;
float GetPageHeight() const;
- void DeviceToPage(int start_x,
- int start_y,
- int size_x,
- int size_y,
+ void DeviceToPage(const FX_RECT& rect,
int rotate,
- int device_x,
- int device_y,
+ const CFX_PointF& device_point,
double* page_x,
double* page_y);
- void PageToDevice(int start_x,
- int start_y,
- int size_x,
- int size_y,
+ void PageToDevice(const FX_RECT& rect,
int rotate,
double page_x,
double page_y,