diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-06 18:41:18 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-06 20:40:26 -0500 |
commit | db9a73d51823a0c8392cc426da8f96ff69209832 (patch) | |
tree | cbca07e51feaca98df7916910dbc8579a51bccfe /sc | |
parent | 4efc5fa37681e1e0ff3cfffab8a4ea33f24b5ba0 (diff) |
Allow non-pooled instance of SvNumberFormatter inside ScCompiler.
Change-Id: I645079254621c2f2684a69116b094e37e46f46f4
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/compiler.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 62 |
2 files changed, 36 insertions, 29 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index c16f749cbeec..0cd47c514340 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -312,6 +312,8 @@ private: ScDocument* pDoc; ScAddress aPos; + SvNumberFormatter* mpFormatter; + // For CONV_XL_OOX, may be set via API by MOOXML filter. ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks; @@ -400,6 +402,7 @@ public: void SetGrammar( const formula::FormulaGrammar::Grammar eGrammar ); + void SetNumberFormatter( SvNumberFormatter* pFormatter ); EncodeUrlMode GetEncodeUrlMode() const; private: /** Set grammar and reference convention from within SetFormulaLanguage() diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 6b6d0111428c..9b77a7df1435 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -239,6 +239,11 @@ void ScCompiler::SetGrammar( const FormulaGrammar::Grammar eGrammar ) } } +void ScCompiler::SetNumberFormatter( SvNumberFormatter* pFormatter ) +{ + mpFormatter = pFormatter; +} + ScCompiler::EncodeUrlMode ScCompiler::GetEncodeUrlMode() const { return meEncodeUrlMode; @@ -1640,6 +1645,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,ScTokenArra : FormulaCompiler(rArr), pDoc( pDocument ), aPos( rPos ), + mpFormatter(pDoc->GetFormatTable()), pCharClass( ScGlobal::pCharClass ), mnPredetectedReference(0), mnRangeOpPosInSymbol(-1), @@ -1656,6 +1662,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos) : pDoc( pDocument ), aPos( rPos ), + mpFormatter(pDoc->GetFormatTable()), pCharClass( ScGlobal::pCharClass ), mnPredetectedReference(0), mnRangeOpPosInSymbol(-1), @@ -2517,40 +2524,37 @@ bool ScCompiler::IsOpCode2( const OUString& rName ) bool ScCompiler::IsValue( const OUString& rSym ) { double fVal; - sal_uInt32 nIndex = ( mxSymbols->isEnglish() ? - pDoc->GetFormatTable()->GetStandardIndex( LANGUAGE_ENGLISH_US ) : 0 ); + sal_uInt32 nIndex = mxSymbols->isEnglish() ? mpFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US) : 0; - if (pDoc->GetFormatTable()->IsNumberFormat( rSym, nIndex, fVal ) ) - { - sal_uInt16 nType = pDoc->GetFormatTable()->GetType(nIndex); + if (!mpFormatter->IsNumberFormat(rSym, nIndex, fVal)) + return false; - // Don't accept 3:3 as time, it is a reference to entire row 3 instead. - // Dates should never be entered directly and automatically converted - // to serial, because the serial would be wrong if null-date changed. - // Usually it wouldn't be accepted anyway because the date separator - // clashed with other separators or operators. - if (nType & (NUMBERFORMAT_TIME | NUMBERFORMAT_DATE)) - return false; + sal_uInt16 nType = mpFormatter->GetType(nIndex); - if (nType == NUMBERFORMAT_LOGICAL) - { - const sal_Unicode* p = aFormula.getStr() + nSrcPos; - while( *p == ' ' ) - p++; - if (*p == '(') - return false; // Boolean function instead. - } + // Don't accept 3:3 as time, it is a reference to entire row 3 instead. + // Dates should never be entered directly and automatically converted + // to serial, because the serial would be wrong if null-date changed. + // Usually it wouldn't be accepted anyway because the date separator + // clashed with other separators or operators. + if (nType & (NUMBERFORMAT_TIME | NUMBERFORMAT_DATE)) + return false; - if( nType == NUMBERFORMAT_TEXT ) - // HACK: number too big! - SetError( errIllegalArgument ); - ScRawToken aToken; - aToken.SetDouble( fVal ); - pRawToken = aToken.Clone(); - return true; + if (nType == NUMBERFORMAT_LOGICAL) + { + const sal_Unicode* p = aFormula.getStr() + nSrcPos; + while( *p == ' ' ) + p++; + if (*p == '(') + return false; // Boolean function instead. } - else - return false; + + if( nType == NUMBERFORMAT_TEXT ) + // HACK: number too big! + SetError( errIllegalArgument ); + ScRawToken aToken; + aToken.SetDouble( fVal ); + pRawToken = aToken.Clone(); + return true; } bool ScCompiler::IsString() |