summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-10-05 18:11:52 -0400
committerKohei Yoshida <kyoshida@novell.com>2010-10-05 18:11:52 -0400
commit0501bf2bf452be015521b87620d82c69ff968db2 (patch)
tree4494580ca4ce2285059b9703202b892514c60004 /formula
parent821760ef8c4b8bbbd854825ee61600246c02cb72 (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')
-rw-r--r--formula/inc/formula/token.hxx1
-rw-r--r--formula/inc/formula/tokenarray.hxx1
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx6
-rw-r--r--formula/source/core/api/token.cxx22
4 files changed, 27 insertions, 3 deletions
diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx
index eafb2480af8e..f7c53ec93c19 100644
--- a/formula/inc/formula/token.hxx
+++ b/formula/inc/formula/token.hxx
@@ -113,6 +113,7 @@ public:
inline StackVar GetType() const { return eType; }
BOOL IsFunction() const; // pure functions, no operators
BOOL IsMatrixFunction() const; // if a function _always_ returns a Matrix
+ bool IsExternalRef() const;
BYTE GetParamCount() const;
inline void IncRef() const { nRefCnt++; }
inline void DecRef() const
diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx
index fc379fc4bb05..da1bdb357802 100644
--- a/formula/inc/formula/tokenarray.hxx
+++ b/formula/inc/formula/tokenarray.hxx
@@ -125,6 +125,7 @@ public:
FormulaToken* LastRPN() { nIndex = nRPN; return PrevRPN(); }
FormulaToken* PrevRPN();
+ bool HasExternalRef() const;
BOOL HasOpCode( OpCode ) const;
BOOL HasOpCodeRPN( OpCode ) const;
/// Token of type svIndex or opcode ocColRowName
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index d2ede5596cf9..7e3423fd8fe8 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 f10ecf4eb022..84f09add4a0c 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++ )