svx/source/items/numfmtsh.cxx |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 4f2a44849e74074b5c2741a8dec52229cf7d45e4
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Thu Sep 5 06:27:26 2024 -0400
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Sep 9 18:22:04 2024 +0200

    Resolves: tdf#162819 fix "NatNum12" preview string format
    
    The default value 0.00 does not translate the appropriative
    number literals.
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I6577def4ccc7ff04c6b891a4df9384d1d58f4e8a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172909
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit a54bedd7924445abe74748110e54f3901380d469)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173086
    Tested-by: Jenkins

diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 61e473d45cd0..740429aa6995 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -20,6 +20,7 @@
 #include <tools/color.hxx>
 
 #include <tools/debug.hxx>
+#include <unotools/localedatawrapper.hxx>
 #include <i18nlangtag/mslangid.hxx>
 #include <o3tl/safeint.hxx>
 #include <svl/numformat.hxx>
@@ -1101,7 +1102,20 @@ void 
SvxNumberFormatShell::GetPreviewString_Impl(OUString& rString, const Color*
     }
     else
     {
-        pFormatter->GetOutputString(nValNum, nCurFormatKey, rString, &rpColor, 
bUseStarFormat);
+        double nVal = nValNum;
+        const SvNumberformat* pEntry = pFormatter->GetEntry(nCurFormatKey);
+        if (nVal == 0.0 && pEntry && 
pEntry->GetFormatstring().indexOf("NatNum12") >= 0)
+        {
+            sal_Int32 nEnd;
+            rtl_math_ConversionStatus eStatus;
+            LocaleDataWrapper aLocale(LanguageTag(pEntry->GetLanguage()));
+
+            nVal = aLocale.stringToDouble(aValStr, true, &eStatus, &nEnd);
+            if (rtl_math_ConversionStatus_Ok != eStatus || nEnd == 0)
+                nVal = GetDefaultValNum(pFormatter->GetType(nCurFormatKey));
+        }
+
+        pFormatter->GetOutputString(nVal, nCurFormatKey, rString, &rpColor, 
bUseStarFormat);
     }
 }
 

Reply via email to