Commit 71e86272859aa2794263cc59446a20a826d6d3aa

Authored by Jay Berkenbilt
1 parent de8929a4

Add const versions of QPDFMatrix::transform*

include/qpdf/QPDFMatrix.hh
... ... @@ -74,6 +74,9 @@ class QPDFMatrix
74 74 // [x y 1] * this
75 75 // and take the first and second rows of the result as xp and yp.
76 76 QPDF_DLL
  77 + void transform(double x, double y, double& xp, double& yp) const;
  78 + // ABI: delete non-const version
  79 + QPDF_DLL
77 80 void transform(double x, double y, double& xp, double& yp);
78 81  
79 82 // Transform a rectangle by creating a new rectangle that tightly
... ... @@ -81,6 +84,10 @@ class QPDFMatrix
81 84 // corners.
82 85 QPDF_DLL
83 86 QPDFObjectHandle::Rectangle transformRectangle(
  87 + QPDFObjectHandle::Rectangle r) const;
  88 + // ABI: delete non-const version
  89 + QPDF_DLL
  90 + QPDFObjectHandle::Rectangle transformRectangle(
84 91 QPDFObjectHandle::Rectangle r);
85 92  
86 93 private:
... ...
libqpdf/QPDFMatrix.cc
... ... @@ -111,6 +111,12 @@ QPDFMatrix::rotatex90(int angle)
111 111 void
112 112 QPDFMatrix::transform(double x, double y, double& xp, double& yp)
113 113 {
  114 + const_cast<QPDFMatrix const*>(this)->transform(x, y, xp, yp);
  115 +}
  116 +
  117 +void
  118 +QPDFMatrix::transform(double x, double y, double& xp, double& yp) const
  119 +{
114 120 xp = (this->a * x) + (this->c * y) + this->e;
115 121 yp = (this->b * x) + (this->d * y) + this->f;
116 122 }
... ... @@ -118,6 +124,12 @@ QPDFMatrix::transform(double x, double y, double&amp; xp, double&amp; yp)
118 124 QPDFObjectHandle::Rectangle
119 125 QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r)
120 126 {
  127 + return const_cast<QPDFMatrix const*>(this)->transformRectangle(r);
  128 +}
  129 +
  130 +QPDFObjectHandle::Rectangle
  131 +QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const
  132 +{
121 133 std::vector<double> tx(4);
122 134 std::vector<double> ty(4);
123 135 transform(r.llx, r.lly, tx.at(0), ty.at(0));
... ...