diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-10-05 18:11:52 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-10-05 18:11:52 -0400 |
commit | 8c2dbf6048cfe7f6e53f5953ede7e263e0d94ced (patch) | |
tree | d09462f7cc468013f81d7662ea9928e4d19d1432 /formula/source | |
parent | da7a5dc29cc18ca5ed2a4a5e254983c225dca397 (diff) |
Ported calc-extref-interpreter-rework-*.diff from ooo-build.
Re-structured the interpreter code to handle external references with
ocPush, instead of ocExternalRef. This is necessary in order to
support shifting of references in the same way you can with internal
references.
In addition, this change allows re-using of document instances already
loaded when accessing external references that point to one of already
loaded documents. Previously, Calc would load the same document from
disk even when the document was already loaded.
(n#628876)
Diffstat (limited to 'formula/source')
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 6 | ||||
-rw-r--r-- | formula/source/core/api/token.cxx | 22 |
2 files changed, 25 insertions, 3 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 2cd662d18d..3c87ce3855 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -881,7 +881,7 @@ BOOL FormulaCompiler::GetToken() } if( pToken->GetOpCode() == ocSubTotal ) glSubTotal = TRUE; - else if ( pToken->GetOpCode() == ocExternalRef ) + else if ( pToken->IsExternalRef() ) { return HandleExternalReference(*pToken); } @@ -1175,7 +1175,7 @@ void FormulaCompiler::Factor() bCorrected = TRUE; } } - else if ( eOp == ocExternalRef ) + else if ( pToken->IsExternalRef() ) { PutCode(pToken); eOp = NextToken(); @@ -1595,7 +1595,7 @@ FormulaToken* FormulaCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuff } if( bNext ) { - if (eOp == ocExternalRef) + if (t->IsExternalRef()) { CreateStringFromExternal(rBuffer, pTokenP); } diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index ccc740633c..028197c1d5 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -145,6 +145,18 @@ BOOL FormulaToken::IsMatrixFunction() const return formula::FormulaCompiler::IsMatrixFunction(GetOpCode()); } +bool FormulaToken::IsExternalRef() const +{ + switch (eType) + { + case svExternalSingleRef: + case svExternalDoubleRef: + case svExternalName: + return true; + } + return false; +} + BOOL FormulaToken::operator==( const FormulaToken& rToken ) const { // don't compare reference count! @@ -550,6 +562,16 @@ FormulaToken* FormulaTokenArray::PeekPrevNoSpaces() return NULL; } +bool FormulaTokenArray::HasExternalRef() const +{ + for ( USHORT j=0; j < nLen; j++ ) + { + if (pCode[j]->IsExternalRef()) + return true; + } + return false; +} + BOOL FormulaTokenArray::HasOpCode( OpCode eOp ) const { for ( USHORT j=0; j < nLen; j++ ) |