diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-08 14:30:03 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-11 16:17:29 -0500 |
commit | a70c324daf1f4ef8562dd283b84e72eeee60a585 (patch) | |
tree | 44d0579d3f3f12efa992f3865de741c1e60b55ab /sc | |
parent | 454ea7a80b14707df8164de6e09c3f8ec9893e71 (diff) |
Store the formula cell instance in cache rather than the token array.
Change-Id: I1c4a0897c46458d6ee086e7f72ab8a03aa54c9e0
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/oox/formulabuffer.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index d9c164ab2043..eb1892ba98da 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -51,10 +51,11 @@ public: struct Item : boost::noncopyable { SCROW mnRow; - boost::scoped_ptr<ScTokenArray> mpCode; + ScFormulaCell* mpCell; - Item() : mnRow(-1), mpCode(NULL) {} - Item( SCROW nRow, ScTokenArray* p ) : mnRow(nRow), mpCode(p) {} + Item() : mnRow(-1), mpCell(NULL) {} + Item( SCROW nRow, ScFormulaCell* pCell ) : + mnRow(nRow), mpCell(pCell) {} }; CachedTokenArray( ScDocument& rDoc ) : mrDoc(rDoc) {} @@ -74,7 +75,7 @@ public: return NULL; Item& rCached = *it->second; - ScCompiler aComp(&mrDoc, rPos, *rCached.mpCode); + ScCompiler aComp(&mrDoc, rPos, *rCached.mpCell->GetCode()); aComp.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX); OUStringBuffer aBuf; aComp.CreateStringFromTokenArray(aBuf); @@ -85,7 +86,7 @@ public: return NULL; } - void store( const ScAddress& rPos, const ScTokenArray& rArray ) + void store( const ScAddress& rPos, ScFormulaCell* pCell ) { ColCacheType::iterator it = maCache.find(rPos.Col()); if (it == maCache.end()) @@ -100,8 +101,9 @@ public: it = r.first; } - it->second->mnRow = rPos.Row(); - it->second->mpCode.reset(rArray.Clone()); + Item& rItem = *it->second; + rItem.mnRow = rPos.Row(); + rItem.mpCell = pCell; } private: @@ -187,8 +189,12 @@ void applyCellFormulas( if (p) { // Use the cached version to avoid re-compilation. - ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, p->mpCode->Clone()); + ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, p->mpCell->GetCode()->Clone()); rDoc.setFormulaCell(aPos, pCell); + + // Update the cache. + p->mnRow = aPos.Row(); + p->mpCell = pCell; continue; } @@ -201,7 +207,7 @@ void applyCellFormulas( ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode); rDoc.setFormulaCell(aPos, pCell); - rCache.store(aPos, *pCode); + rCache.store(aPos, pCell); } } |