svx/source/svdraw/svdpdf.cxx |   38 ++++++++++++++++++++------------------
 svx/source/svdraw/svdpdf.hxx |    4 ++--
 2 files changed, 22 insertions(+), 20 deletions(-)

New commits:
commit ca006ba55cceb0a4c97e9c9f9d59be3fc1727765
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Mar 29 23:05:25 2020 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sun Jun 7 21:17:07 2020 +0200

    replace usage of Matrix for B2DHomMatrix in ImpSdrPdfImport
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91341
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit c20fa884cf20959dbd65814274e450e1f49cf45e)
    
    Change-Id: I366ee435ddf217c7c078d58f882610df12bec276
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95698
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 415c6e3dc7df..820832265aa0 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);
+    FPDFTextObj_GetMatrix(pPageObject, &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,12 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 
     double a, b, c, d, e, f;
     FPDFTextObj_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 +1039,8 @@ 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.
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to