summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-03 13:03:30 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-05-04 12:33:33 +0200
commitdba50d5e6c1b4d3d16690ee5b8a9648c652f41e7 (patch)
tree4a4e4948e07b2ab057ce3b7a0f00cb41b46edacc /svx
parent305dab19f8a5ae320f0772829d1be73a62c9bb48 (diff)
SdrPdfImport: use convertPointToMm100 for all unit conversion
Change-Id: I78b3512cc0b9aea1fa4e9a810ec71eadd00b7635 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93391 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdpdf.cxx46
1 files changed, 9 insertions, 37 deletions
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index ad3a89ed9c02..5394c3c261d1 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -79,27 +79,8 @@
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); }
-}
-namespace
-{
struct FPDFBitmapDeleter
{
void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); }
@@ -248,8 +229,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()))
{
@@ -815,10 +795,9 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
double dFontSizeH = fabs(sqrt2(matrix.a, matrix.c) * dFontSize);
double dFontSizeV = fabs(sqrt2(matrix.b, matrix.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();
@@ -1120,7 +1099,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.
@@ -1160,10 +1139,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;
}
@@ -1173,15 +1150,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