summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdpdf.hxx
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-14 19:57:15 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-04 12:36:28 -0400
commita735d3a731263721e3a067b67e3f66122d7c9f1c (patch)
tree7fe5af4784f35bcdda00fcaf1dffa8fe4da40a12 /svx/source/svdraw/svdpdf.hxx
parent397aa7177e23d848ae7db5e8db32fd05da838660 (diff)
svx: transform PDF text rectangles while importing
Change-Id: I7675a183bfb691a8783950f33dc34826f91cb768 (cherry picked from commit 02d15d96fe42f7c5e1857f52ab6c0620017ac06f)
Diffstat (limited to 'svx/source/svdraw/svdpdf.hxx')
-rw-r--r--svx/source/svdraw/svdpdf.hxx54
1 files changed, 53 insertions, 1 deletions
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 4b2fba1bf8cd..a41f62872bea 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -87,6 +87,7 @@ class ImpSdrPdfImport final
double d() const { return md; }
double e() const { return me; }
double f() const { return mf; }
+
/// Mutliply this * other.
void Concatinate(const Matrix& other)
{
@@ -99,12 +100,63 @@ class ImpSdrPdfImport final
}
/// Transform the point (x, y) by this Matrix.
- void Transform(double& x, double& y)
+ template <typename T> void Transform(T& x, T& y)
{
x = ma * x + mc * y + me;
y = mb * x + md * y + mf;
}
+ /// Transform the rectangle (left, right, top, bottom) by this Matrix.
+ template <typename T> void Transform(T& left, T& right, T& top, T& bottom)
+ {
+ SAL_WARN("sd.filter",
+ "Transforming: " << left << ", " << right << ", " << top << ", " << bottom);
+ T leftTopX = left;
+ T leftTopY = top;
+ Transform(leftTopX, leftTopY);
+ SAL_WARN("sd.filter", "Left-Top: " << leftTopX << ", " << leftTopY);
+
+ T leftBottomX = left;
+ T leftBottomY = bottom;
+ Transform(leftBottomX, leftBottomY);
+ SAL_WARN("sd.filter", "Left-Bottom: " << leftBottomX << ", " << leftBottomY);
+
+ T rightTopX = right;
+ T rightTopY = top;
+ Transform(rightTopX, rightTopY);
+ SAL_WARN("sd.filter", "Right-Top: " << rightTopX << ", " << rightTopY);
+
+ T rightBottomX = right;
+ T rightBottomY = bottom;
+ Transform(rightBottomX, rightBottomY);
+ SAL_WARN("sd.filter", "Right-Bottom: " << rightBottomX << ", " << rightBottomY);
+
+ left = std::min(leftTopX, leftBottomX);
+ SAL_WARN("sd.filter", "left: " << left);
+ right = std::max(rightTopX, rightBottomX);
+ SAL_WARN("sd.filter", "right: " << right);
+
+ if (top > bottom)
+ top = std::max(leftTopY, rightTopY);
+ else
+ top = std::min(leftTopY, rightTopY);
+ SAL_WARN("sd.filter", "top: " << top);
+
+ if (top > bottom)
+ bottom = std::max(leftBottomY, rightBottomY);
+ else
+ bottom = std::max(leftBottomY, rightBottomY);
+ SAL_WARN("sd.filter", "bottom: " << bottom);
+ }
+
+ std::string toString() const
+ {
+ std::ostringstream oss;
+ oss << '(' << ma << ", " << mb << ", " << mc << ", " << md << ", " << me << ", " << mf
+ << ')';
+ return oss.str();
+ }
+
private:
double ma, mb, mc, md, me, mf;
};