vcl: simplify LogicToPixel(Polygon) with new mapper wrappers

This commit continues the cleanup of map.cxx by refactoring the
Polygon overload of OutputDevice::LogicToPixel to use the new
explicit ImplMapRes wrappers.

Key changes:
- Replaced the nested ViewToWindowUnits(LogicUnitsToViewUnits(...))
  calls with the much cleaner LogicToWindowUnitsX/Y(..., aMapRes)
  master wrappers.
- Removed legacy C-style pointer arithmetic (GetConstPointAry) in
  favor of directly accessing and assigning to the polygon via the
  overloaded operator[].
- Eliminated the temporary Point allocation and sequential setX/setY
  calls, replacing them with a direct inline Point constructor.
- This dramatically improves the readability of the loop while
  maintaining identical coordinate transformation behavior.

Change-Id: I25252b99f5fc8e1b7097d766cd74ac6e7e8f3e80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203669
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit is contained in:
Christopher Sherlock
2026-08-24 18:54:37 +02:00
committed by Dan Williams
parent 726c525f1e
commit 770ef72c44
+7 -12
View File
@@ -647,27 +647,22 @@ tools::Rectangle OutputDevice::LogicToPixel( const tools::Rectangle& rLogicRect,
tools::Polygon OutputDevice::LogicToPixel( const tools::Polygon& rLogicPoly,
const MapMode& rMapMode ) const
{
if ( rMapMode.IsDefault() )
return rLogicPoly;
// convert MapMode resolution and convert
ImplMapRes aMapRes;
ImplMapRes aMapRes;
aMapRes.CalcMapResolution(rMapMode, mpMapper->GetDPIX(), mpMapper->GetDPIY());
const sal_uInt16 nPoints = rLogicPoly.GetSize();
tools::Polygon aPoly( rLogicPoly );
// get pointer to Point-array (copy data)
const Point* pPointAry = aPoly.GetConstPointAry();
for (sal_uInt16 i = 0; i < nPoints; i++)
// Apply the custom mapping resolution to each point in the polygon
for (sal_uInt16 i = 0; i < nPoints; ++i)
{
const Point* pPt = &(pPointAry[i]);
Point aPt;
aPt.setX(mpMapper->ViewToWindowUnitsX(mpMapper->LogicUnitsToViewUnitsX(pPt->X(), aMapRes)));
aPt.setY(mpMapper->ViewToWindowUnitsY(mpMapper->LogicUnitsToViewUnitsY(pPt->Y(), aMapRes)));
aPoly[i] = aPt;
aPoly[i] = Point(
mpMapper->LogicToWindowUnitsX(aPoly[i].X(), aMapRes),
mpMapper->LogicToWindowUnitsY(aPoly[i].Y(), aMapRes)
);
}
return aPoly;