summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2025-01-13 07:48:54 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2025-01-13 10:58:56 +0100
commit42025cc3072fd4288ccefdf264dec843e23448a3 (patch)
treea0eb527b8d83a4ac40efca87fd953855e0ba85a0
parentdb6a6efdc49df054826e9019ebe955282de929a7 (diff)
Fix dxcanvas::DeviceHelper::getPhysicalResolution
XGraphicDevice::getPhysicalResolution returns pixel per millimeter (offapi/com/sun/star/rendering/XGraphicDevice.idl). The claculation was wrong (multiplying by 25.4 instead of dividing) since commit 3161cf3741e045092d342f9752b61b9b36eee056 (INTEGRATION: CWS dxliberate01 (1.1.2); FILE ADDED, 2027-11-01). Change-Id: I92f33347d48c48c37d02c767fcadcf35d1271e3f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180152 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
-rw-r--r--canvas/source/directx/dx_devicehelper.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/canvas/source/directx/dx_devicehelper.cxx b/canvas/source/directx/dx_devicehelper.cxx
index dada6238e0eb..3ead660b4ab6 100644
--- a/canvas/source/directx/dx_devicehelper.cxx
+++ b/canvas/source/directx/dx_devicehelper.cxx
@@ -76,13 +76,12 @@ namespace dxcanvas
ENSURE_OR_THROW( hDC,
"DeviceHelper::getPhysicalResolution(): cannot retrieve HDC from window" );
- const int nHorzRes( GetDeviceCaps( hDC,
- LOGPIXELSX ) );
- const int nVertRes( GetDeviceCaps( hDC,
- LOGPIXELSY ) );
+ const double nHorzRes(GetDeviceCaps(hDC, LOGPIXELSX));
+ const double nVertRes(GetDeviceCaps(hDC, LOGPIXELSY));
- return geometry::RealSize2D( nHorzRes*25.4,
- nVertRes*25.4 );
+ // Converted units are in the denominator in px/in -> px/mm => conversion is inverted
+ return geometry::RealSize2D(o3tl::convert(nHorzRes, o3tl::Length::mm, o3tl::Length::in),
+ o3tl::convert(nVertRes, o3tl::Length::mm, o3tl::Length::in));
}
geometry::RealSize2D DeviceHelper::getPhysicalSize()