include/vcl/outdev.hxx     |    4 ++--
 vcl/source/outdev/map.cxx  |   17 ++++++++++-------
 vcl/source/outdev/text.cxx |   11 ++++++-----
 3 files changed, 18 insertions(+), 14 deletions(-)

New commits:
commit 95ade11df658d73e90d196f041d0839895aca3f0
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Jan 16 17:27:26 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Jan 16 20:22:45 2022 +0100

    tdf#146453 retain precise vertical base pos with ResolutionIndependentLayout
    
    Change-Id: Ied157d8d4bc9b57cfa17716453189ddf48cba641
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128485
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 4b9d1e7e626a..7e1a0fad7dcd 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1685,6 +1685,7 @@ public:
      @returns Physical point on the device.
      */
     SAL_DLLPRIVATE Point        ImplLogicToDevicePixel( const Point& rLogicPt 
) const;
+    SAL_DLLPRIVATE DevicePoint  ImplLogicToDeviceFontCoordinate(const Point& 
rLogicPt) const;
 
     /** Convert a logical width to a width in units of device pixels.
 
@@ -1697,9 +1698,9 @@ public:
      @returns Width in units of device pixels.
      */
     SAL_DLLPRIVATE tools::Long         ImplLogicWidthToDevicePixel( 
tools::Long nWidth ) const;
+    SAL_DLLPRIVATE double              
ImplLogicWidthToDeviceFontWidth(tools::Long nWidth) const;
 
     SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate( tools::Long 
nWidth ) const;
-    SAL_DLLPRIVATE double LogicWidthToDeviceFontCoordinate( tools::Long nWidth 
) const;
 
     /** Convert a logical X coordinate to a device pixel's X coordinate.
 
@@ -1713,7 +1714,6 @@ public:
      @returns Device's X pixel coordinate
      */
     SAL_DLLPRIVATE tools::Long         ImplLogicXToDevicePixel( tools::Long nX 
) const;
-    SAL_DLLPRIVATE double LogicXToDeviceFontCoordinate( tools::Long nWidth ) 
const;
 
     /** Convert a logical Y coordinate to a device pixel's Y coordinate.
 
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index 5144f0f89f9f..918d8a5a77df 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -1830,7 +1830,7 @@ DeviceCoordinate 
OutputDevice::LogicWidthToDeviceCoordinate( tools::Long nWidth
 #endif
 }
 
-double OutputDevice::LogicWidthToDeviceFontCoordinate(tools::Long nWidth) const
+double OutputDevice::ImplLogicWidthToDeviceFontWidth(tools::Long nWidth) const
 {
     if (!mbMap)
         return nWidth;
@@ -1839,14 +1839,17 @@ double 
OutputDevice::LogicWidthToDeviceFontCoordinate(tools::Long nWidth) const
                             maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX);
 }
 
-double OutputDevice::LogicXToDeviceFontCoordinate(tools::Long nX) const
+DevicePoint OutputDevice::ImplLogicToDeviceFontCoordinate(const Point& rPoint) 
const
 {
     if (!mbMap)
-        return nX + mnOutOffX;
-
-    return ImplLogicToPixel(static_cast<double>(nX + maMapRes.mnMapOfsX), 
mnDPIX,
-                            maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX)
-                            + mnOutOffX + mnOutOffOrigX;
+        return DevicePoint(rPoint.X() + mnOutOffX, rPoint.Y() + mnOutOffY);
+
+    return DevicePoint(ImplLogicToPixel(static_cast<double>(rPoint.X() + 
maMapRes.mnMapOfsX), mnDPIX,
+                                        maMapRes.mnMapScNumX, 
maMapRes.mnMapScDenomX)
+                                        + mnOutOffX + mnOutOffOrigX,
+                       ImplLogicToPixel(static_cast<double>(rPoint.Y() + 
maMapRes.mnMapOfsY), mnDPIY,
+                                        maMapRes.mnMapScNumY, 
maMapRes.mnMapScDenomY)
+                                        + mnOutOffY + mnOutOffOrigY);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 49ca790b8aec..3d773e56d488 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1359,7 +1359,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const 
OUString& rOrigStr,
                 xNaturalDXPixelArray.reset(new double[nLen]);
 
                 for (int i = 0; i < nLen; ++i)
-                    xNaturalDXPixelArray[i] = 
LogicWidthToDeviceFontCoordinate(pDXArray[i]);
+                    xNaturalDXPixelArray[i] = 
ImplLogicWidthToDeviceFontWidth(pDXArray[i]);
 
                 aLayoutArgs.SetAltNaturalDXArray(xNaturalDXPixelArray.get());
                 nEndGlyphCoord = std::lround(xNaturalDXPixelArray[nLen - 1]);
@@ -1426,12 +1426,13 @@ std::unique_ptr<SalLayout> 
OutputDevice::ImplLayout(const OUString& rOrigStr,
     // position, justify, etc. the layout
     pSalLayout->AdjustLayout( aLayoutArgs );
 
-    Point aDevicePos = ImplLogicToDevicePixel(rLogicalPos);
     if (bTextRenderModeForResolutionIndependentLayout)
-        
pSalLayout->DrawBase().setX(LogicXToDeviceFontCoordinate(rLogicalPos.X()));
+        pSalLayout->DrawBase() = ImplLogicToDeviceFontCoordinate(rLogicalPos);
     else
-        pSalLayout->DrawBase().setX(aDevicePos.X());
-    pSalLayout->DrawBase().setY(aDevicePos.Y());
+    {
+        Point aDevicePos = ImplLogicToDevicePixel(rLogicalPos);
+        pSalLayout->DrawBase() = DevicePoint(aDevicePos.X(), aDevicePos.Y());
+    }
 
     // adjust to right alignment if necessary
     if( aLayoutArgs.mnFlags & SalLayoutFlags::RightAlign )

Reply via email to