From 71e86272859aa2794263cc59446a20a826d6d3aa Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 18 Feb 2021 11:27:25 -0500 Subject: Add const versions of QPDFMatrix::transform* --- include/qpdf/QPDFMatrix.hh | 7 +++++++ libqpdf/QPDFMatrix.cc | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/qpdf/QPDFMatrix.hh b/include/qpdf/QPDFMatrix.hh index 85f42af7..8a8bff60 100644 --- a/include/qpdf/QPDFMatrix.hh +++ b/include/qpdf/QPDFMatrix.hh @@ -74,12 +74,19 @@ class QPDFMatrix // [x y 1] * this // and take the first and second rows of the result as xp and yp. QPDF_DLL + void transform(double x, double y, double& xp, double& yp) const; + // ABI: delete non-const version + QPDF_DLL void transform(double x, double y, double& xp, double& yp); // Transform a rectangle by creating a new rectangle that tightly // bounds the polygon resulting from transforming the four // corners. QPDF_DLL + QPDFObjectHandle::Rectangle transformRectangle( + QPDFObjectHandle::Rectangle r) const; + // ABI: delete non-const version + QPDF_DLL QPDFObjectHandle::Rectangle transformRectangle( QPDFObjectHandle::Rectangle r); diff --git a/libqpdf/QPDFMatrix.cc b/libqpdf/QPDFMatrix.cc index 18122d72..2b269099 100644 --- a/libqpdf/QPDFMatrix.cc +++ b/libqpdf/QPDFMatrix.cc @@ -110,6 +110,12 @@ QPDFMatrix::rotatex90(int angle) void QPDFMatrix::transform(double x, double y, double& xp, double& yp) +{ + const_cast(this)->transform(x, y, xp, yp); +} + +void +QPDFMatrix::transform(double x, double y, double& xp, double& yp) const { xp = (this->a * x) + (this->c * y) + this->e; yp = (this->b * x) + (this->d * y) + this->f; @@ -117,6 +123,12 @@ QPDFMatrix::transform(double x, double y, double& xp, double& yp) QPDFObjectHandle::Rectangle QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) +{ + return const_cast(this)->transformRectangle(r); +} + +QPDFObjectHandle::Rectangle +QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const { std::vector tx(4); std::vector ty(4); -- cgit v1.2.3-54-g00ecf