[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - sc/inc sc/source
Michael Meeks
michael.meeks at suse.com
Tue Jul 2 14:22:47 PDT 2013
sc/inc/formulagroup.hxx | 5 +--
sc/source/core/tool/formulagroup.cxx | 51 ++++++++++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 4 deletions(-)
New commits:
commit 0da704e16a8c21a2d5e178b00af97774be5ef820
Author: Michael Meeks <michael.meeks at suse.com>
Date: Tue Jul 2 22:01:01 2013 +0100
Dummy formula group interpreter for testing.
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 1c573c4..e645968 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -30,9 +30,8 @@ struct FormulaGroupContext : boost::noncopyable
};
/**
- * All the vectorized formula calculation code should be collected here.
- *
- * Abstract base class for formula group interpreters, and a factory.
+ * Abstract base class for vectorised formula group interpreters,
+ * plus a global instance factory.
*/
class SC_DLLPUBLIC FormulaGroupInterpreter
{
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 3dd43e3..ae0b0d6 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -20,6 +20,8 @@
#include <vector>
+#define USE_DUMMY_INTERPRETER 1
+
namespace sc {
ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& /*rMat*/)
@@ -108,14 +110,61 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
namespace opencl {
extern sc::FormulaGroupInterpreter *createFormulaGroupInterpreter();
}
-
FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL;
+#if USE_DUMMY_INTERPRETER
+class FormulaGroupInterpreterDummy : public FormulaGroupInterpreter
+{
+ enum Mode {
+ WRITE_OUTPUT = 0
+ };
+ Mode meMode;
+public:
+ FormulaGroupInterpreterDummy()
+ {
+ const char *pValue = getenv("FORMULA_GROUP_DUMMY");
+ meMode = static_cast<Mode>(OString(pValue, strlen(pValue)).toInt32());
+ fprintf(stderr, "Using Dummy Formula Group interpreter mode %d\n", (int)meMode);
+ }
+
+ virtual ScMatrixRef inverseMatrix(const ScMatrix& /*rMat*/)
+ {
+ return ScMatrixRef();
+ }
+
+ virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos,
+ const ScFormulaCellGroupRef& xGroup,
+ ScTokenArray& rCode)
+ {
+ (void)rCode;
+
+ // Write simple data back into the sheet
+ if (meMode == WRITE_OUTPUT)
+ {
+ double *pDoubles = new double[xGroup->mnLength];
+ for (sal_Int32 i = 0; i < xGroup->mnLength; i++)
+ pDoubles[i] = 42.0 + i;
+ rDoc.SetFormulaResults(rTopPos, pDoubles, xGroup->mnLength);
+ delete [] pDoubles;
+ }
+ return true;
+ }
+};
+#endif
+
/// load and/or configure the correct formula group interpreter
FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
{
static bool bOpenCLEnabled = false;
+#if USE_DUMMY_INTERPRETER
+ if (getenv("FORMULA_GROUP_DUMMY"))
+ {
+ delete msInstance;
+ return msInstance = new sc::FormulaGroupInterpreterDummy();
+ }
+#endif
+
if ( msInstance &&
bOpenCLEnabled != ScInterpreter::GetGlobalConfig().mbOpenCLEnabled )
{
More information about the Libreoffice-commits
mailing list