[Libreoffice-commits] core.git: sc/source
Eike Rathke
erack at redhat.com
Mon Jun 29 09:26:14 PDT 2015
sc/source/core/tool/interpr1.cxx | 47 +++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
New commits:
commit 30396941dbaa34d3573466a87e435621cfdadab3
Author: Eike Rathke <erack at redhat.com>
Date: Mon Jun 29 18:07:12 2015 +0200
TableRef: can be used in INDIRECT
Change-Id: I8eed87f0e6c0816a7d315f6c5ed039b0b193c322
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index df14604..568ce1f 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7095,6 +7095,53 @@ void ScInterpreter::ScIndirect()
}
while (false);
+ /* TODO: simple named ranges and database ranges could be resolved. */
+
+ // It may be even a TableRef.
+ // Anything else that resolves to one reference could be added
+ // here, but we don't want to compile every arbitrary string. This
+ // is already nasty enough..
+ sal_Int32 nIndex = 0;
+ if ((nIndex = sRefStr.indexOf('[')) >= 0 && sRefStr.indexOf(']',nIndex+1) > nIndex)
+ {
+ do
+ {
+ ScCompiler aComp( pDok, aPos);
+ aComp.SetGrammar( pDok->GetGrammar());
+ aComp.SetRefConvention( eConv); // must be after grammar
+ boost::scoped_ptr<ScTokenArray> pArr( aComp.CompileString( sRefStr));
+
+ // Whatever.. use only the specific case.
+ if (!pArr->HasOpCode( ocTableRef))
+ break;
+
+ aComp.CompileTokenArray();
+
+ // A syntactically valid reference will generate exactly
+ // one RPN token, a reference or error. Discard everything
+ // else as error.
+ if (pArr->GetCodeLen() != 1)
+ break;
+
+ ScTokenRef xTok( pArr->FirstRPN());
+ if (!xTok)
+ break;
+
+ switch (xTok->GetType())
+ {
+ case svSingleRef:
+ case svDoubleRef:
+ case svError:
+ PushTempToken( xTok.get());
+ // success!
+ return;
+ default:
+ ; // nothing
+ }
+ }
+ while (false);
+ }
+
PushError( errNoRef);
}
}
More information about the Libreoffice-commits
mailing list