[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Nov 12 15:50:38 PST 2013
sc/inc/formulagroup.hxx | 2 --
sc/source/core/data/formulacell.cxx | 6 ++++++
sc/source/core/opencl/formulagroupcl.cxx | 12 ------------
sc/source/core/tool/formulagroup.cxx | 10 ----------
sc/source/filter/oox/formulabuffer.cxx | 4 ++++
sc/source/filter/oox/sheetdatabuffer.cxx | 12 ++++++++++--
6 files changed, 20 insertions(+), 26 deletions(-)
New commits:
commit 30a20743ae17e6e02183a65603d38968253b3ffb
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Nov 12 15:29:36 2013 -0500
Avoid using UNO API formula tokens.
Change-Id: Ide89b06a64405d006ac4b88cd3ae88b696f981f2
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 2b340c5..c4dcc2d 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -53,6 +53,7 @@
#include "docpool.hxx"
#include "paramisc.hxx"
#include "documentimport.hxx"
+#include "formulabuffer.hxx"
namespace oox {
namespace xls {
@@ -199,7 +200,9 @@ void SheetDataBuffer::setDateTimeCell( const CellModel& rModel, const ::com::sun
void SheetDataBuffer::setBooleanCell( const CellModel& rModel, bool bValue )
{
- setCellFormula( rModel.maCellAddr, getFormulaParser().convertBoolToFormula( bValue ) );
+ getFormulaBuffer().setCellFormula(
+ rModel.maCellAddr, bValue ? OUString("TRUE()") : OUString("FALSE()"));
+
// #108770# set 'Standard' number format for all Boolean cells
setCellFormat( rModel, 0 );
}
@@ -211,7 +214,12 @@ void SheetDataBuffer::setErrorCell( const CellModel& rModel, const OUString& rEr
void SheetDataBuffer::setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode )
{
- setCellFormula( rModel.maCellAddr, getFormulaParser().convertErrorToFormula( nErrorCode ) );
+ OUStringBuffer aBuf;
+ aBuf.append(sal_Unicode('{'));
+ aBuf.append(BiffHelper::calcDoubleFromError(nErrorCode));
+ aBuf.append(sal_Unicode('}'));
+
+ getFormulaBuffer().setCellFormula(rModel.maCellAddr, aBuf.makeStringAndClear());
setCellFormat( rModel );
}
commit 177c0adede9ba4b34aa3f4a80cf7021e327c9d20
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Nov 12 14:43:41 2013 -0500
Reduce the amount of RPM token generation.
Change-Id: I03941690114b17d8ab63cfb9b1b23a2ff1741b10
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 24e26d9..fb7692b 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -85,8 +85,6 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
FormulaGroupInterpreter() {}
virtual ~FormulaGroupInterpreter() {}
- static void generateRPNCode(ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rCode);
-
public:
static FormulaGroupInterpreter *getStatic();
static void fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rPlatforms);
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 5e92efa..07f8656 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3468,6 +3468,7 @@ public:
bool convert(ScTokenArray& rCode)
{
+#if 0
{ // debug to start with:
ScCompiler aComp( &mrDoc, mrPos, rCode);
aComp.SetGrammar(formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1);
@@ -3475,6 +3476,7 @@ public:
aComp.CreateStringFromTokenArray(aAsString);
SAL_DEBUG("interpret formula: " << aAsString.makeStringAndClear());
}
+#endif
rCode.Reset();
for (const formula::FormulaToken* p = rCode.First(); p; p = rCode.Next())
@@ -3614,6 +3616,10 @@ public:
}
}
+ ScCompiler aComp(&mrDoc, mrPos, mrGroupTokens);
+ aComp.SetGrammar(mrDoc.GetGrammar());
+ aComp.CompileTokenArray(); // Regenerate RPN tokens.
+
return true;
}
};
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 60b126c..c6ae8e8 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1416,20 +1416,9 @@ public:
virtual ScMatrixRef inverseMatrix( const ScMatrix& rMat );
virtual bool interpret( ScDocument& rDoc, const ScAddress& rTopPos,
const ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode );
- void generateRPNCode(ScDocument& rDoc,
- const ScAddress& rPos, ScTokenArray& rCode);
DynamicKernel *mpKernel;
};
-void FormulaGroupInterpreterOpenCL::generateRPNCode(ScDocument& rDoc,
- const ScAddress& rPos, ScTokenArray& rCode)
-{
- // First, generate an RPN (reverse polish notation) token array.
- ScCompiler aComp(&rDoc, rPos, rCode);
- aComp.SetGrammar(rDoc.GetGrammar());
- aComp.CompileTokenArray(); // Create RPN token array.
-}
-
ScMatrixRef FormulaGroupInterpreterOpenCL::inverseMatrix( const ScMatrix& )
{
return NULL;
@@ -1439,7 +1428,6 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
const ScAddress& rTopPos, const ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode )
{
- generateRPNCode(rDoc, rTopPos, rCode);
// printf("Vector width = %d\n", xGroup->mnLength);
// Constructing "AST"
FormulaTokenIterator aCode = rCode;
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 2573359..8d87e24 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -425,7 +425,6 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
if (!pDest)
return false;
- generateRPNCode(rDoc, aTmpPos, aCode2);
ScInterpreter aInterpreter(pDest, &rDoc, aTmpPos, aCode2);
aInterpreter.Interpret();
aResults.push_back(aInterpreter.GetResultToken());
@@ -676,15 +675,6 @@ void FormulaGroupInterpreter::enableOpenCL(bool bEnable)
ScInterpreter::SetGlobalConfig(aConfig);
}
-void FormulaGroupInterpreter::generateRPNCode(ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rCode)
-{
- // First, generate an RPN (reverse polish notation) token array.
- ScCompiler aComp(&rDoc, rPos, rCode);
- aComp.SetGrammar(rDoc.GetGrammar());
- aComp.CompileTokenArray(); // Create RPN token array.
- // Now, calling FirstRPN() and NextRPN() will return tokens from the RPN token array.
-}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 4bdb6ae..6f0c991 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -135,7 +135,10 @@ void applySharedFormulas(
aComp.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX);
ScTokenArray* pArray = aComp.CompileString(rTokenStr);
if (pArray)
+ {
+ aComp.CompileTokenArray(); // Generate RPN tokens.
aGroups.set(nId, pArray);
+ }
}
}
@@ -222,6 +225,7 @@ void applyCellFormulas(
if (!pCode)
continue;
+ aCompiler.CompileTokenArray(); // Generate RPN tokens.
ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode);
rDoc.setFormulaCell(aPos, pCell);
rCache.store(aPos, pCell);
More information about the Libreoffice-commits
mailing list