canvas/source/directx/dx_devicehelper.cxx |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit 42025cc3072fd4288ccefdf264dec843e23448a3
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Jan 13 07:48:54 2025 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Jan 13 10:58:56 2025 +0100

    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.kagan...@collabora.com>
    Tested-by: Jenkins

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()

Reply via email to