summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-11-24 15:45:08 +0100
committerEike Rathke <erack@redhat.com>2017-11-24 21:31:15 +0100
commit28288295aeddf2fe2100af4f60f453a05fe25508 (patch)
treec0d98019a8b9b09d494fd5efaeed882015847760
parent4b98e352e543d0462f2727c5762552e32ef4d76a (diff)
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 <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--basic/source/comp/scanner.cxx18
1 files changed, 14 insertions, 4 deletions
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 <basiccharclass.hxx>
#include <scanner.hxx>
#include <sbintern.hxx>
+#include <runtime.hxx>
#include <i18nlangtag/lang.h>
#include <comphelper/processfactory.hxx>
@@ -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<SvNumberFormatter> 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;
}