From 28288295aeddf2fe2100af4f60f453a05fe25508 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 24 Nov 2017 15:45:08 +0100 Subject: Get rid of a temporary SvNumberFormatter instance ... in case we have a runtime instance already. Only used for scanning date literals in source so not frequently used, otherwise we could remember a non-runtime instance formatter somewhere. Change-Id: I1146860c4b0aa4091708c22e498a6f720d6c7a13 Reviewed-on: https://gerrit.libreoffice.org/45232 Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- basic/source/comp/scanner.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'basic') diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 07d739f29bc0..67177b7d9f44 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -560,12 +561,21 @@ bool SbiScanner::NextSym() aSym = aLine.copy( n, nCol - n - 1 ); // parse date literal - SvNumberFormatter aFormatter(comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US); - sal_uInt32 nIndex = 0; - bool bSuccess = aFormatter.IsNumberFormat(aSym, nIndex, nVal); + std::shared_ptr pFormatter; + if (GetSbData()->pInst) + { + pFormatter = GetSbData()->pInst->GetNumberFormatter(); + } + else + { + sal_uInt32 nDummy; + pFormatter = SbiInstance::PrepareNumberFormatter( nDummy, nDummy, nDummy ); + } + sal_uInt32 nIndex = pFormatter->GetStandardIndex( LANGUAGE_ENGLISH_US); + bool bSuccess = pFormatter->IsNumberFormat(aSym, nIndex, nVal); if( bSuccess ) { - short nType_ = aFormatter.GetType(nIndex); + short nType_ = pFormatter->GetType(nIndex); if( !(nType_ & css::util::NumberFormat::DATE) ) bSuccess = false; } -- cgit