summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/outdev.hxx2
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx6
-rw-r--r--vcl/source/outdev/map.cxx19
3 files changed, 24 insertions, 3 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 3f00d9dcde12..17d5d87289e9 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1720,6 +1720,8 @@ public:
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel( tools::Long nHeight ) const;
SAL_DLLPRIVATE double ImplLogicHeightToDeviceSubPixel(tools::Long nHeight) const;
+ SAL_DLLPRIVATE Point SubPixelToLogic(const DevicePoint& rDevicePt) const;
+
/** Convert device pixels to a width in logical units.
To get the logical width, it must calculate the X-DPI of the device and the
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 1881562cc08f..48a8b472df03 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -6344,7 +6344,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
// ascent / descent to match the on-screen rendering.
// This is the top left of the text without ascent / descent.
DevicePoint aDrawPosition(rLayout.GetDrawPosition());
- tools::Rectangle aRectangle(PixelToLogic(Point(aDrawPosition.getX(), aDrawPosition.getY())),
+ tools::Rectangle aRectangle(SubPixelToLogic(aDrawPosition),
Size(ImplDevicePixelToLogicWidth(rLayout.GetTextWidth()), 0));
aRectangle.AdjustTop(-aRefDevFontMetric.GetAscent());
// This includes ascent / descent.
@@ -6355,7 +6355,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
{
// Adapt rectangle for rotated text.
tools::Polygon aPolygon(aRectangle);
- aPolygon.Rotate(PixelToLogic(Point(aDrawPosition.getX(), aDrawPosition.getY())), pFontInstance->mnOrientation);
+ aPolygon.Rotate(SubPixelToLogic(aDrawPosition), pFontInstance->mnOrientation);
drawPolygon(aPolygon);
}
else
@@ -6476,7 +6476,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
{
DevicePoint aStartPt = rLayout.GetDrawPosition();
int nWidth = rLayout.GetTextWidth() / rLayout.GetUnitsPerPixel();
- drawTextLine( PixelToLogic(Point(aStartPt.getX(), aStartPt.getY()) ),
+ drawTextLine( SubPixelToLogic(aStartPt),
ImplDevicePixelToLogicWidth( nWidth ),
eStrikeout, eUnderline, eOverline, bUnderlineAbove );
}
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index c184b255af2b..a073b1b029bf 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -278,6 +278,14 @@ static double ImplLogicToSubPixel(tools::Long n, tools::Long nDPI, tools::Long n
return static_cast<double>(n) * nMapNum * nDPI / nMapDenom;
}
+static tools::Long ImplSubPixelToLogic(double n, tools::Long nDPI, tools::Long nMapNum,
+ tools::Long nMapDenom)
+{
+ assert(nDPI > 0);
+ assert(nMapNum != 0);
+ return std::round(n * nMapDenom / nMapNum / nDPI);
+}
+
static tools::Long ImplPixelToLogic(tools::Long n, tools::Long nDPI, tools::Long nMapNum,
tools::Long nMapDenom)
{
@@ -1165,6 +1173,17 @@ Point OutputDevice::PixelToLogic( const Point& rDevicePt ) const
maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY ) - maMapRes.mnMapOfsY - mnOutOffLogicY );
}
+Point OutputDevice::SubPixelToLogic(const DevicePoint& rDevicePt) const
+{
+ if (!mbMap)
+ return Point(rDevicePt.getX(), rDevicePt.getY());
+
+ return Point(ImplSubPixelToLogic(rDevicePt.getX(), mnDPIX,
+ maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX) - maMapRes.mnMapOfsX - mnOutOffLogicX,
+ ImplSubPixelToLogic(rDevicePt.getY(), mnDPIY,
+ maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY) - maMapRes.mnMapOfsY - mnOutOffLogicY);
+}
+
Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const
{