[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Nov 8 20:18:24 CET 2013
sc/source/filter/oox/formulabuffer.cxx | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
New commits:
commit 900258ac9dde75f53ac8bda643cbcba80ce6510e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Nov 8 14:19:19 2013 -0500
Create formula cells there...
Change-Id: Idfd4081245905cdc88ad0da195b81be7e34ebf21
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 86c9e6c..d9c164a 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -46,6 +46,8 @@ namespace {
*/
class CachedTokenArray : boost::noncopyable
{
+public:
+
struct Item : boost::noncopyable
{
SCROW mnRow;
@@ -55,11 +57,6 @@ class CachedTokenArray : boost::noncopyable
Item( SCROW nRow, ScTokenArray* p ) : mnRow(nRow), mpCode(p) {}
};
- typedef boost::unordered_map<SCCOL, Item*> ColCacheType;
- ColCacheType maCache;
- ScDocument& mrDoc;
-
-public:
CachedTokenArray( ScDocument& rDoc ) : mrDoc(rDoc) {}
~CachedTokenArray()
@@ -69,21 +66,21 @@ public:
delete it->second;
}
- const ScTokenArray* get( const ScAddress& rPos, const OUString& rFormula ) const
+ Item* get( const ScAddress& rPos, const OUString& rFormula )
{
// Check if a token array is cached for this column.
- ColCacheType::const_iterator it = maCache.find(rPos.Col());
+ ColCacheType::iterator it = maCache.find(rPos.Col());
if (it == maCache.end())
return NULL;
- const Item& rCached = *it->second;
+ Item& rCached = *it->second;
ScCompiler aComp(&mrDoc, rPos, *rCached.mpCode);
aComp.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX);
OUStringBuffer aBuf;
aComp.CreateStringFromTokenArray(aBuf);
OUString aPredicted = aBuf.makeStringAndClear();
if (rFormula == aPredicted)
- return rCached.mpCode.get();
+ return &rCached;
return NULL;
}
@@ -106,6 +103,11 @@ public:
it->second->mnRow = rPos.Row();
it->second->mpCode.reset(rArray.Clone());
}
+
+private:
+ typedef boost::unordered_map<SCCOL, Item*> ColCacheType;
+ ColCacheType maCache;
+ ScDocument& mrDoc;
};
void applySharedFormulas(
@@ -181,11 +183,12 @@ void applyCellFormulas(
{
ScAddress aPos;
ScUnoConversion::FillScAddress(aPos, it->maCellAddress);
- const ScTokenArray* p = rCache.get(aPos, it->maTokenStr);
+ CachedTokenArray::Item* p = rCache.get(aPos, it->maTokenStr);
if (p)
{
// Use the cached version to avoid re-compilation.
- rDoc.setFormulaCell(aPos, p->Clone());
+ ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, p->mpCode->Clone());
+ rDoc.setFormulaCell(aPos, pCell);
continue;
}
@@ -196,7 +199,8 @@ void applyCellFormulas(
if (!pCode)
continue;
- rDoc.setFormulaCell(aPos, pCode);
+ ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode);
+ rDoc.setFormulaCell(aPos, pCell);
rCache.store(aPos, *pCode);
}
}
More information about the Libreoffice-commits
mailing list