diff --git a/vcl/inc/CoordinateMapper.hxx b/vcl/inc/CoordinateMapper.hxx index 97e52d3ebb7b..4e75c6706547 100644 --- a/vcl/inc/CoordinateMapper.hxx +++ b/vcl/inc/CoordinateMapper.hxx @@ -167,6 +167,8 @@ public: // View <-> LogicUnits (Sub-pixel) double ViewSubPixelToLogicUnitsX(double fX) const; double ViewSubPixelToLogicUnitsY(double fY) const; + tools::Long ViewSubPixelToLogicUnitsIntX(double fX) const; + tools::Long ViewSubPixelToLogicUnitsIntY(double fY) const; double LogicUnitsToViewSubPixelX(double fX) const; double LogicUnitsToViewSubPixelY(double fY) const; @@ -203,6 +205,10 @@ public: // To resolve the return-type conflict, these now return double double ViewSubPixelToLogicX(double fX) const; double ViewSubPixelToLogicY(double fY) const; + // View (Sub-pixel) -> Absolute Logic (Integer) + // Note: This rounds the distance before stripping offsets to satisfy legacy test parity. + tools::Long ViewSubPixelToLogicIntX(double fX) const; + tools::Long ViewSubPixelToLogicIntY(double fY) const; double LogicToViewSubPixelX(double fX) const; double LogicToViewSubPixelY(double fY) const; diff --git a/vcl/source/outdev/CoordinateMapper.cxx b/vcl/source/outdev/CoordinateMapper.cxx index 1d148aa91159..be2ae5a5ad20 100644 --- a/vcl/source/outdev/CoordinateMapper.cxx +++ b/vcl/source/outdev/CoordinateMapper.cxx @@ -260,6 +260,18 @@ double CoordinateMapper::ViewSubPixelToLogicUnitsY(double fY) const return ViewToLogicDistanceDoubleY(fY, maMapRes.mfMapScY) - maMapRes.mnMapOfsY; } +tools::Long CoordinateMapper::ViewSubPixelToLogicUnitsIntX(double fX) const +{ + // Uses the version that rounds the distance BEFORE the offset shift + return ViewSubPixelToLogicDistanceX(fX) - maMapRes.mnMapOfsX; +} + +tools::Long CoordinateMapper::ViewSubPixelToLogicUnitsIntY(double fY) const +{ + // Uses the version that rounds the distance BEFORE the offset shift + return ViewSubPixelToLogicDistanceY(fY) - maMapRes.mnMapOfsY; +} + double CoordinateMapper::LogicUnitsToViewSubPixelX(double fX) const { return LogicToViewDistanceSubPixelX(std::llround(fX + maMapRes.mnMapOfsX), maMapRes.mfMapScX); @@ -582,6 +594,22 @@ double CoordinateMapper::ViewSubPixelToLogicY(double fY) const return fLogicUnits - static_cast(mnOutOffLogicY); } +tools::Long CoordinateMapper::ViewSubPixelToLogicIntX(double fX) const +{ + // Move from View to Logic Units (Rounds distance, then strips mnMapOfs) + const tools::Long nLogicUnits = ViewSubPixelToLogicUnitsIntX(fX); + + return nLogicUnits - mnOutOffLogicX; +} + +tools::Long CoordinateMapper::ViewSubPixelToLogicIntY(double fY) const +{ + // Move from View to Logic Units (Rounds distance, then strips mnMapOfs) + const tools::Long nLogicUnits = ViewSubPixelToLogicUnitsIntY(fY); + + return nLogicUnits - mnOutOffLogicY; +} + // Absolute Logic -> View (Forward: Add Logical -> Add Mapping/Scale) double CoordinateMapper::LogicToViewSubPixelX(double fX) const { diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index ab16ff5d497c..d4d9482eb2a1 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -696,8 +696,8 @@ Point OutputDevice::SubPixelToLogic(const basegfx::B2DPoint& rDevicePt) const return Point(rDevicePt.getX(), rDevicePt.getY()); } - return Point(mpMapper->ViewSubPixelToLogicDistanceX(rDevicePt.getX()) - mpMapper->GetMappingXOffset() - mpMapper->GetLogicalXOffset(), - mpMapper->ViewSubPixelToLogicDistanceY(rDevicePt.getY()) - mpMapper->GetMappingYOffset() - mpMapper->GetLogicalYOffset()); + return Point(mpMapper->ViewSubPixelToLogicIntX(rDevicePt.getX()), + mpMapper->ViewSubPixelToLogicIntY(rDevicePt.getY())); } Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const