summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/svdraw/svdpdf.cxx26
-rw-r--r--svx/source/svdraw/svdpdf.hxx54
2 files changed, 69 insertions, 11 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 90d2ba45ed54..80383bb39242 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1073,17 +1073,23 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
return;
}
- const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
-
double a, b, c, d, e, f;
FPDFTextObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- Matrix aTextMatrix(a, b, c, d, e, f);
- aTextMatrix.Concatinate(mCurMatrix);
- SAL_WARN("sd.filter", "Got font scale matrix (" << a << ", " << b << ", " << c << ", " << d
- << ", " << e << ", " << f << ')');
- Point aPos = PointsToLogic(e, f);
+ // Matrix aTextMatrix(a, b, c, d, e, f);
+ Matrix aTextMatrix(mCurMatrix);
+ SAL_WARN("sd.filter", "Got text matrix " << aTextMatrix.toString());
+ SAL_WARN("sd.filter", "Context matrix " << mCurMatrix.toString());
+ // aTextMatrix.Concatinate(mCurMatrix);
+ // SAL_WARN("sd.filter", "Got text matrix concat " << aTextMatrix.toString());
+
+ Point aPos = PointsToLogic(aTextMatrix.e(), aTextMatrix.f());
SAL_WARN("sd.filter", "Got TEXT origin: " << aPos);
- SAL_WARN("sd.filter", "Got TEXT Bounds: " << aRect);
+
+ const tools::Rectangle aRect2 = PointsToLogic(left, right, top, bottom);
+ SAL_WARN("sd.filter", "Untransformed TEXT Bounds: " << aRect2);
+ aTextMatrix.Transform(left, right, top, bottom);
+ const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
+ SAL_WARN("sd.filter", "Transformed TEXT Bounds: " << aRect);
const int nChars = FPDFTextObj_CountChars(pPageObject) * 2;
std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
@@ -1417,9 +1423,9 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
float fWidth = 1;
FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
- const double dWidth = 0.5 * fabs(sqrt2(mCurMatrix.a(), mCurMatrix.c()) * fWidth);
+ const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
- mnLineWidth /= 2;
+ // mnLineWidth /= 2;
SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ", scaled: " << dWidth
<< ", Logical: " << mnLineWidth);
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;
};