vcl: add explicit map resolution overloads for LogicToWindowUnits
This commit improves the encapsulation of custom MapMode conversions by adding ImplMapRes overloads to the LogicToWindowUnits master wrappers in CoordinateMapper. Previously, when OutputDevice::LogicToPixel was called with an explicit custom MapMode, it had to bypass the standard wrappers and manually chain the LogicUnitsToViewUnits and ViewToWindowUnits pipeline stages inline. This resulted in highly verbose and difficult- to-read rectangle initialization. Key changes: - Added LogicToWindowUnitsX(nX, rRes) and LogicToWindowUnitsY to CoordinateMapper to safely encapsulate custom resolution scaling while still applying the correct internal window offsets. - Refactored OutputDevice::LogicToPixel(Rectangle, MapMode) in map.cxx to use these new wrappers, drastically improving the readability of the coordinate mapping logic. Change-Id: Ib3af5314ad11653395b08c2ca722d66360baeb99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203668 Tested-by: Jenkins Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit is contained in:
committed by
Dan Williams
parent
adf3a4e560
commit
726c525f1e
@@ -209,6 +209,8 @@ public:
|
||||
// Logic -> Window units (Commonly used in OutputDevice::LogicToPixel)
|
||||
tools::Long LogicToWindowUnitsX(tools::Long nX) const;
|
||||
tools::Long LogicToWindowUnitsY(tools::Long nY) const;
|
||||
tools::Long LogicToWindowUnitsX(tools::Long nX, const ImplMapRes& rRes) const;
|
||||
tools::Long LogicToWindowUnitsY(tools::Long nY, const ImplMapRes& rRes) const;
|
||||
|
||||
// ========================================================================
|
||||
// DISTANCE SCALING (Raw Scalar Conversion, NO offsets applied)
|
||||
|
||||
@@ -362,6 +362,16 @@ tools::Long CoordinateMapper::LogicToWindowUnitsY(tools::Long nY) const
|
||||
return ViewToWindowUnitsY(LogicUnitsToViewUnitsY(nY));
|
||||
}
|
||||
|
||||
tools::Long CoordinateMapper::LogicToWindowUnitsX(tools::Long nX, const ImplMapRes& rRes) const
|
||||
{
|
||||
return ViewToWindowUnitsX(LogicUnitsToViewUnitsX(nX, rRes));
|
||||
}
|
||||
|
||||
tools::Long CoordinateMapper::LogicToWindowUnitsY(tools::Long nY, const ImplMapRes& rRes) const
|
||||
{
|
||||
return ViewToWindowUnitsY(LogicUnitsToViewUnitsY(nY, rRes));
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// DISTANCE SCALING (Raw Scalar Conversion)
|
||||
// ========================================================================
|
||||
|
||||
@@ -618,21 +618,21 @@ Size OutputDevice::LogicToPixel( const Size& rLogicSize,
|
||||
}
|
||||
|
||||
tools::Rectangle OutputDevice::LogicToPixel( const tools::Rectangle& rLogicRect,
|
||||
const MapMode& rMapMode ) const
|
||||
const MapMode& rMapMode ) const
|
||||
{
|
||||
// tdf#141761 see comments above, IsEmpty() removed
|
||||
if ( rMapMode.IsDefault() )
|
||||
return rLogicRect;
|
||||
|
||||
// convert MapMode resolution and convert
|
||||
ImplMapRes aMapRes;
|
||||
// convert MapMode resolution
|
||||
ImplMapRes aMapRes;
|
||||
aMapRes.CalcMapResolution(rMapMode, mpMapper->GetDPIX(), mpMapper->GetDPIY());
|
||||
|
||||
tools::Rectangle aRetval(
|
||||
mpMapper->ViewToWindowUnitsX(mpMapper->LogicUnitsToViewUnitsX(rLogicRect.Left(), aMapRes)),
|
||||
mpMapper->ViewToWindowUnitsY(mpMapper->LogicUnitsToViewUnitsY(rLogicRect.Top(), aMapRes)),
|
||||
rLogicRect.IsWidthEmpty() ? 0 : mpMapper->ViewToWindowUnitsX(mpMapper->LogicUnitsToViewUnitsX(rLogicRect.Right(), aMapRes)),
|
||||
rLogicRect.IsHeightEmpty() ? 0 : mpMapper->ViewToWindowUnitsY(mpMapper->LogicUnitsToViewUnitsY(rLogicRect.Bottom(), aMapRes))
|
||||
mpMapper->LogicToWindowUnitsX(rLogicRect.Left(), aMapRes),
|
||||
mpMapper->LogicToWindowUnitsY(rLogicRect.Top(), aMapRes),
|
||||
rLogicRect.IsWidthEmpty() ? 0 : mpMapper->LogicToWindowUnitsX(rLogicRect.Right(), aMapRes),
|
||||
rLogicRect.IsHeightEmpty() ? 0 : mpMapper->LogicToWindowUnitsY(rLogicRect.Bottom(), aMapRes)
|
||||
);
|
||||
|
||||
if (rLogicRect.IsWidthEmpty())
|
||||
|
||||
Reference in New Issue
Block a user