[Libreoffice-commits] core.git: basic/source

Eike Rathke erack at redhat.com
Fri Nov 24 20:32:49 UTC 2017


 basic/source/runtime/methods.cxx |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

New commits:
commit 2f8174594da56e6feb0c339993f673afdd859794
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Nov 24 16:25:41 2017 +0100

    Aaand another one.. SvNumberFormatter instance
    
    ... just to parse with LANGUAGE_ENGLISH_US if system locale failed..
    
    Change-Id: Id9b7cfb5b5f21c46789f30e8e8c72a7524491e95
    Reviewed-on: https://gerrit.libreoffice.org/45238
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 6b47d8b2a78f..e91893d76d50 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -2043,24 +2043,22 @@ void SbRtl_DateValue(StarBASIC *, SbxArray & rPar, bool)
             pFormatter = SbiInstance::PrepareNumberFormatter( n, n, n );
         }
 
-        sal_uInt32 nIndex = 0;
+        LanguageType eLangType = Application::GetSettings().GetLanguageTag().getLanguageType();
+        sal_uInt32 nIndex = pFormatter->GetStandardIndex( eLangType);
         double fResult;
         OUString aStr( rPar.Get(1)->GetOUString() );
         bool bSuccess = pFormatter->IsNumberFormat( aStr, nIndex, fResult );
         short nType = pFormatter->GetType( nIndex );
 
         // DateValue("February 12, 1969") raises error if the system locale is not en_US
-        // by using SbiInstance::GetNumberFormatter.
-        // It seems that both locale number formatter and English number formatter
-        // are supported in Visual Basic.
-        LanguageType eLangType = Application::GetSettings().GetLanguageTag().getLanguageType();
+        // It seems that both locale number formatter and English number
+        // formatter are supported in Visual Basic.
         if( !bSuccess && ( eLangType != LANGUAGE_ENGLISH_US ) )
         {
-            // Create a new SvNumberFormatter by using LANGUAGE_ENGLISH to get the date value;
-            SvNumberFormatter aFormatter( comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US );
-            nIndex = 0;
-            bSuccess = aFormatter.IsNumberFormat( aStr, nIndex, fResult );
-            nType = aFormatter.GetType( nIndex );
+            // Try using LANGUAGE_ENGLISH_US to get the date value.
+            nIndex = pFormatter->GetStandardIndex( LANGUAGE_ENGLISH_US);
+            bSuccess = pFormatter->IsNumberFormat( aStr, nIndex, fResult );
+            nType = pFormatter->GetType( nIndex );
         }
 
         if(bSuccess && (nType==css::util::NumberFormat::DATE || nType==css::util::NumberFormat::DATETIME))


More information about the Libreoffice-commits mailing list