i18nutil/source/utility/paper.cxx |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 6de0be90055c913348e75c44b6c2351eda3f67fc
Author:     Mike Kaganski <[email protected]>
AuthorDate: Wed Feb 11 10:23:17 2026 +0100
Commit:     Mike Kaganski <[email protected]>
CommitDate: Wed Feb 11 17:12:36 2026 +0100

    Avoid multiple divisions when looking for paper
    
    Also use o3tl::convert to convert from mm100 to mm
    
    Change-Id: If42cd5854c01a1609084c5e816c7ece5da76e7f4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199127
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/i18nutil/source/utility/paper.cxx 
b/i18nutil/source/utility/paper.cxx
index 1cdef064b64e..792b04fb3b4d 100644
--- a/i18nutil/source/utility/paper.cxx
+++ b/i18nutil/source/utility/paper.cxx
@@ -319,8 +319,8 @@ PaperInfo PaperInfo::getSystemDefaultPaper()
             freelocale(loc);
 
             //glibc stores sizes as integer mm units
-            w.word *= 100;
-            h.word *= 100;
+            tools::Long nPaperWidth = w.word * 100;
+            tools::Long nPaperHeight = h.word * 100;
 
             for ( size_t i = 0; i < nTabSize; ++i )
             {
@@ -329,18 +329,18 @@ PaperInfo PaperInfo::getSystemDefaultPaper()
                 //glibc stores sizes as integer mm units, and so is inaccurate.
                 //To find a standard paper size we calculate the standard paper
                 //sizes into equally inaccurate mm and compare
-                tools::Long width = (aDinTab[i].m_nWidth + 50) / 100;
-                tools::Long height = (aDinTab[i].m_nHeight + 50) / 100;
+                tools::Long width = o3tl::convert(aDinTab[i].m_nWidth, 
o3tl::Length::mm100, o3tl::Length::mm);
+                tools::Long height = o3tl::convert(aDinTab[i].m_nHeight, 
o3tl::Length::mm100, o3tl::Length::mm);
 
-                if (width == w.word/100 && height == h.word/100)
+                if (width == w.word && height == h.word)
                 {
-                    w.word = aDinTab[i].m_nWidth;
-                    h.word = aDinTab[i].m_nHeight;
+                    nPaperWidth = aDinTab[i].m_nWidth;
+                    nPaperHeight = aDinTab[i].m_nHeight;
                     break;
                 }
             }
 
-            aInstance = PaperInfo(w.word, h.word);
+            aInstance = PaperInfo(nPaperWidth, nPaperHeight);
             bInitialized = true;
             return aInstance;
         }

Reply via email to