summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-03-29 23:05:25 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-04-01 20:54:34 +0200
commitfb68f37251a3203e558e11fc83fc2b0e00ae73f9 (patch)
tree9cf420218ea744b1a79024ef35c7368fe82bcb2c
parentb0cc614b7119c6933426b5e0cde9628596671bd5 (diff)
replace usage of Matrix for B2DHomMatrix in ImpSdrPdfImport
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91341 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit c20fa884cf20959dbd65814274e450e1f49cf45e) Change-Id: I366ee435ddf217c7c078d58f882610df12bec276 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91453 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--svx/source/svdraw/svdpdf.cxx38
-rw-r--r--svx/source/svdraw/svdpdf.hxx4
2 files changed, 22 insertions, 20 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index d24d85b2205d..6d89c4bf5390 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -768,11 +768,11 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
int /*nPageObjectIndex*/)
{
// Get the form matrix to perform correct translation/scaling of the form sub-objects.
- const Matrix aOldMatrix = mCurMatrix;
+ const basegfx::B2DHomMatrix aOldMatrix = maCurrentMatrix;
double a, b, c, d, e, f;
FPDFFormObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- mCurMatrix = Matrix(a, b, c, d, e, f);
+ maCurrentMatrix = basegfx::B2DHomMatrix::abcdef(a, b, c, d, e, f);
const int nCount = FPDFFormObj_CountObjects(pPageObject);
for (int nIndex = 0; nIndex < nCount; ++nIndex)
@@ -782,7 +782,7 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
}
// Restore the old one.
- mCurMatrix = aOldMatrix;
+ maCurrentMatrix = aOldMatrix;
}
void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
@@ -802,10 +802,11 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
double a, b, c, d, e, f;
FPDFText_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- Matrix aTextMatrix(mCurMatrix);
-
- aTextMatrix.Transform(left, right, top, bottom);
- const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
+ basegfx::B2DHomMatrix aTextMatrix(maCurrentMatrix);
+ basegfx::B2DRange aTextRect(left, top, right, bottom);
+ aTextRect *= aTextMatrix;
+ const tools::Rectangle aRect = PointsToLogic(aTextRect.getMinX(), aTextRect.getMaxX(),
+ aTextRect.getMinY(), aTextRect.getMaxY());
const int nChars = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0);
std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars]);
@@ -1037,8 +1038,9 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
{
double a, b, c, d, e, f;
FPDFPath_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- Matrix aPathMatrix(a, b, c, d, e, f);
- aPathMatrix.Concatinate(mCurMatrix);
+
+ auto aPathMatrix = basegfx::B2DHomMatrix::abcdef(a, b, c, d, e, f);
+ aPathMatrix *= maCurrentMatrix;
basegfx::B2DPolyPolygon aPolyPoly;
basegfx::B2DPolygon aPoly;
@@ -1057,26 +1059,26 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
continue;
}
- double x = fx;
- double y = fy;
- aPathMatrix.Transform(x, y);
+ basegfx::B2DPoint aB2DPoint(fx, fy);
+ aB2DPoint *= aPathMatrix;
+
const bool bClose = FPDFPathSegment_GetClose(pPathSegment);
if (bClose)
aPoly.setClosed(bClose); // TODO: Review
- Point aPoint = PointsToLogic(x, y);
- x = aPoint.X();
- y = aPoint.Y();
+ Point aPoint = PointsToLogic(aB2DPoint.getX(), aB2DPoint.getY());
+ aB2DPoint.setX(aPoint.X());
+ aB2DPoint.setY(aPoint.Y());
const int nSegmentType = FPDFPathSegment_GetType(pPathSegment);
switch (nSegmentType)
{
case FPDF_SEGMENT_LINETO:
- aPoly.append(basegfx::B2DPoint(x, y));
+ aPoly.append(aB2DPoint);
break;
case FPDF_SEGMENT_BEZIERTO:
- aBezier.emplace_back(x, y);
+ aBezier.emplace_back(aB2DPoint.getX(), aB2DPoint.getY());
if (aBezier.size() == 3)
{
aPoly.appendBezierSegment(aBezier[0], aBezier[1], aBezier[2]);
@@ -1092,7 +1094,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
aPoly.clear();
}
- aPoly.append(basegfx::B2DPoint(x, y));
+ aPoly.append(aB2DPoint);
break;
case FPDF_SEGMENT_UNKNOWN:
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 40e835bb67a4..9dd6626d3318 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -37,7 +37,7 @@
#include <svx/xdash.hxx>
#include <com/sun/star/uno/Sequence.hxx>
-#include <basegfx/matrix/Matrix.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
// Prevent workdir/UnpackedTarball/pdfium/public/fpdfview.h from including windows.h in a way that
// it will define e.g. Yield as a macro:
@@ -95,7 +95,7 @@ class ImpSdrPdfImport final
double mdPageWidthPts;
double mdPageHeightPts;
/// The current transformation matrix, typically used with Form objects.
- Matrix mCurMatrix;
+ basegfx::B2DHomMatrix maCurrentMatrix;
/// Correct the vertical coordinate to start at the top.
/// PDF coordinate system has origin at the bottom right.