svx/source/svdraw/svdpdf.cxx |   45 +++++++++----------------------------------
 1 file changed, 10 insertions(+), 35 deletions(-)

New commits:
commit 26e52703188d1301f8cac335975bafff58c37ee4
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun May 3 13:03:30 2020 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Jun 8 13:44:36 2020 +0200

    SdrPdfImport: use convertPointToMm100 for all unit conversion
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93391
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit dba50d5e6c1b4d3d16690ee5b8a9648c652f41e7)
    
    Change-Id: I78b3512cc0b9aea1fa4e9a810ec71eadd00b7635
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95784
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 78bb7131ae13..4d973c433711 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -93,29 +93,13 @@
 
 namespace
 {
-/// Convert from DPI to pixels.
-/// PDFs don't have resolution, rather,
-/// dimensions are in inches, with 72 points / inch.
-/// Here we effectively render at 96 DPI (to match
-/// the image rendered in vcl::ImportPDF in pdfread.cxx).
-double lcl_PointToPixel(double fPoint) { return fPoint * 96. / 72.; }
-
-/// Convert from pixels to logic (twips).
-long lcl_ToLogic(double value)
-{
-    // Convert to integral preserving two dp.
-    const long in = static_cast<long>(value * 100.);
-    const long out = OutputDevice::LogicToLogic(in, MapUnit::MapPixel, 
MapUnit::Map100thMM);
-    return out / 100;
-}
-
 double sqrt2(double a, double b) { return sqrt(a * a + b * b); }
-}
 
 struct FPDFBitmapDeleter
 {
     void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); }
 };
+}
 
 using namespace com::sun::star;
 
@@ -260,8 +244,7 @@ void ImpSdrPdfImport::SetupPageScale(const double 
dPageWidth, const double dPage
     mdPageWidthPts = dPageWidth;
     mdPageHeightPts = dPageHeight;
 
-    Size aPageSize(lcl_ToLogic(lcl_PointToPixel(dPageWidth)),
-                   lcl_ToLogic(lcl_PointToPixel(dPageHeight)));
+    Size aPageSize(convertPointToMm100(dPageWidth), 
convertPointToMm100(dPageHeight));
 
     if (aPageSize.Width() && aPageSize.Height() && (!maScaleRect.IsEmpty()))
     {
@@ -827,10 +810,9 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
     const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
     double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
     double dFontSizeV = fabs(sqrt2(b, d) * dFontSize);
-    dFontSizeH = lcl_PointToPixel(dFontSizeH);
-    dFontSizeV = lcl_PointToPixel(dFontSizeV);
-    dFontSizeH = lcl_ToLogic(dFontSizeH);
-    dFontSizeV = lcl_ToLogic(dFontSizeV);
+
+    dFontSizeH = convertPointToMm100(dFontSizeH);
+    dFontSizeV = convertPointToMm100(dFontSizeV);
 
     const Size aFontSize(dFontSizeH, dFontSizeV);
     vcl::Font aFnt = mpVD->GetFont();
@@ -1129,7 +1111,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT 
pPageObject, int /*nPageObjectI
     float fWidth = 1;
     FPDFPageObj_GetStrokeWidth(pPageObject, &fWidth);
     const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * 
fWidth);
-    mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
+    mnLineWidth = convertPointToMm100(dWidth);
 
     int nFillMode = FPDF_FILLMODE_ALTERNATE;
     FPDF_BOOL bStroke = 1; // Assume we have to draw, unless told otherwise.
@@ -1169,10 +1151,8 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT 
pPageObject, int /*nPageObjectI
 Point ImpSdrPdfImport::PointsToLogic(double x, double y) const
 {
     y = correctVertOrigin(y);
-    x = lcl_PointToPixel(x);
-    y = lcl_PointToPixel(y);
 
-    Point aPos(lcl_ToLogic(x), lcl_ToLogic(y));
+    Point aPos(convertPointToMm100(x), convertPointToMm100(y));
     return aPos;
 }
 
@@ -1182,15 +1162,10 @@ tools::Rectangle ImpSdrPdfImport::PointsToLogic(double 
left, double right, doubl
     top = correctVertOrigin(top);
     bottom = correctVertOrigin(bottom);
 
-    left = lcl_PointToPixel(left);
-    right = lcl_PointToPixel(right);
-    top = lcl_PointToPixel(top);
-    bottom = lcl_PointToPixel(bottom);
+    Point aPos(convertPointToMm100(left), convertPointToMm100(top));
+    Size aSize(convertPointToMm100(right - left), convertPointToMm100(bottom - 
top));
 
-    Point aPos(lcl_ToLogic(left), lcl_ToLogic(top));
-    Size aSize(lcl_ToLogic(right - left), lcl_ToLogic(bottom - top));
-    tools::Rectangle aRect(aPos, aSize);
-    return aRect;
+    return tools::Rectangle(aPos, aSize);
 }
 
 #endif // HAVE_FEATURE_PDFIUM
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to