[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Nov 5 02:36:00 CET 2013
sc/inc/compiler.hxx | 9 ++++++++-
sc/source/filter/excel/xechart.cxx | 4 +++-
sc/source/filter/oox/formulabuffer.cxx | 2 +-
sc/source/ui/miscdlgs/anyrefdg.cxx | 8 ++++----
sc/source/ui/vba/vbaname.cxx | 6 ++++--
sc/source/ui/vba/vbanames.cxx | 4 +++-
sc/source/ui/vba/vbarange.cxx | 7 +++++--
sc/source/ui/view/tabvwsha.cxx | 4 +++-
sc/source/ui/view/viewfun4.cxx | 9 ++++++---
9 files changed, 37 insertions(+), 16 deletions(-)
New commits:
commit 1b83e42eced4210978ed574d1a71c72a4862fd60
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Mon Nov 4 20:36:53 2013 -0500
Check all call sites of CompileString() and make sure we don't leak.
We *were* leaking quite a bit.
Change-Id: I3f53eff22beab27b34a055a4452311f2e2f771db
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 28e4efe..c16f749 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -431,7 +431,14 @@ public:
bool IsCorrected() { return bCorrected; }
const OUString& GetCorrectedFormula() { return aCorrectedFormula; }
- // Use convention from this->aPos by default
+ /**
+ * Tokenize formula expression string into an array of tokens.
+ *
+ * @param rFormula formula expression to tokenize.
+ *
+ * @return heap allocated token array object. The caller <i>must</i>
+ * manage the life cycle of this object.
+ */
ScTokenArray* CompileString( const OUString& rFormula );
ScTokenArray* CompileString( const OUString& rFormula, const OUString& rFormulaNmsp );
const ScDocument* GetDoc() const { return pDoc; }
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index e25e0d2..26deac3 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -70,6 +70,8 @@
#include "xepage.hxx"
#include "xestyle.hxx"
+#include <boost/scoped_ptr.hpp>
+
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -917,7 +919,7 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > x
OUString aRangeRepr = xDataSeq->getSourceRangeRepresentation();
ScCompiler aComp( GetDocPtr(), ScAddress() );
aComp.SetGrammar( GetDocPtr()->GetGrammar() );
- ScTokenArray* pArray = aComp.CompileString( aRangeRepr );
+ boost::scoped_ptr<ScTokenArray> pArray(aComp.CompileString(aRangeRepr));
if( !pArray )
return nDefCount;
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 6022ae7..cf5b73e 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -211,7 +211,7 @@ void FormulaBuffer::applyArrayFormulas( const std::vector< TokenRangeAddressItem
ScCompiler aComp(&rDocImport.getDoc(), aPos);
aComp.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX);
- ScTokenArray* pArray = aComp.CompileString(it->maTokenAndAddress.maTokenStr);
+ boost::scoped_ptr<ScTokenArray> pArray(aComp.CompileString(it->maTokenAndAddress.maTokenStr));
if (pArray)
rDocImport.setMatrixCells(aRange, *pArray, formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX);
}
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 1ec55dc..16cb4dbb 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -43,6 +43,8 @@
#include "rangeutl.hxx"
#include "tokenarray.hxx"
+#include <boost/scoped_ptr.hpp>
+
ScFormulaReferenceHelper::ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings)
: m_pDlg(_pDlg)
, pRefEdit (NULL)
@@ -186,10 +188,9 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr)
SCTAB nTab = pViewData->GetTabNo();
ScAddress aPos( nCol, nRow, nTab );
- ScTokenArray* pScTokA=pRefComp->CompileString(rStr);
- //pRefComp->CompileTokenArray();
+ boost::scoped_ptr<ScTokenArray> pScTokA(pRefComp->CompileString(rStr));
- if(pTabViewShell!=NULL && pScTokA!=NULL)
+ if (pTabViewShell && pScTokA)
{
pTabViewShell->DoneRefMode( false );
pTabViewShell->ClearHighlightRanges();
@@ -225,7 +226,6 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr)
pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
}
}
- if(pScTokA!=NULL) delete pScTokA;
}
}
}
diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx
index fc5592b..3c3d448 100644
--- a/sc/source/ui/vba/vbaname.cxx
+++ b/sc/source/ui/vba/vbaname.cxx
@@ -34,6 +34,8 @@
#include "compiler.hxx"
#include "tokenarray.hxx"
+#include <boost/scoped_ptr.hpp>
+
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -135,8 +137,8 @@ void ScVbaName::setContent( const OUString& rContent, const formula::FormulaGra
// Shorter way of doing this ?
ScCompiler aComp( pDoc, pOldData->GetPos() );
aComp.SetGrammar( eGrammar );
- ScTokenArray aArray(*aComp.CompileString( sContent ) );
- pOldData->SetCode( aArray );
+ boost::scoped_ptr<ScTokenArray> pArray(aComp.CompileString(sContent));
+ pOldData->SetCode(*pArray);
}
}
}
diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index eb1c4ab..c3001c4 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -34,6 +34,8 @@
#include "tokenarray.hxx"
#include "cellsuno.hxx"
+#include <boost/scoped_ptr.hpp>
+
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -158,7 +160,7 @@ ScVbaNames::Add( const css::uno::Any& Name ,
ScAddress aBlank;
ScCompiler aComp( getScDocument(), aBlank );
aComp.SetGrammar( eGram );
- ScTokenArray* pTokens = aComp.CompileString( sFormula );
+ boost::scoped_ptr<ScTokenArray> pTokens(aComp.CompileString(sFormula));
if ( pTokens )
{
ScRange aRange;
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index b533561..a551780 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -172,6 +172,9 @@
#include <com/sun/star/bridge/oleautomation/Date.hpp>
#include "tokenarray.hxx"
#include "tokenuno.hxx"
+
+#include <boost/scoped_ptr.hpp>
+
using namespace ::ooo::vba;
using namespace ::com::sun::star;
using ::std::vector;
@@ -901,7 +904,7 @@ protected:
ScCompiler aCompiler( m_pDoc, aCellRanges.front()->aStart );
aCompiler.SetGrammar(m_eGrammar);
// compile the string in the format passed in
- aCompiler.CompileString( sFormula );
+ boost::scoped_ptr<ScTokenArray> pArray(aCompiler.CompileString(sFormula));
// set desired convention to that of the document
aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 );
OUString sConverted;
@@ -944,7 +947,7 @@ public:
ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
ScCompiler aCompiler( m_pDoc, aCellRanges.front()->aStart );
aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_DEFAULT);
- aCompiler.CompileString( sVal );
+ boost::scoped_ptr<ScTokenArray> pArray(aCompiler.CompileString(sVal));
// set desired convention
aCompiler.SetGrammar( m_eGrammar );
OUString sConverted;
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index c8917fa..09f482b 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -53,6 +53,8 @@
#include "cellvalue.hxx"
#include "tokenarray.hxx"
+#include <boost/scoped_ptr.hpp>
+
sal_Bool ScTabViewShell::GetFunction( OUString& rFuncStr, sal_uInt16 nErrCode )
{
OUString aStr;
@@ -565,7 +567,7 @@ bool ScTabViewShell::IsRefInputMode() const
ScCompiler aComp( pDoc, aPos );
aComp.SetGrammar(pDoc->GetGrammar());
aComp.SetCloseBrackets( false );
- ScTokenArray* pArr = aComp.CompileString( aString );
+ boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aString));
if ( pArr && pArr->MayReferenceFollow() )
{
return true;
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 8f140c8..e924b34 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -64,6 +64,7 @@
#include "dociter.hxx"
#include "reffind.hxx"
#include "compiler.hxx"
+#include "tokenarray.hxx"
#include <boost/scoped_ptr.hpp>
@@ -257,9 +258,11 @@ void ScViewFunc::DoRefConversion( sal_Bool bRecord )
OUString aNew = aFinder.GetText();
ScCompiler aComp( pDoc, aPos);
aComp.SetGrammar(pDoc->GetGrammar());
- ScTokenArray* pArr = aComp.CompileString( aNew );
- ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aPos,
- pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE );
+ boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aNew));
+ ScFormulaCell* pNewCell =
+ new ScFormulaCell(
+ pDoc, aPos, pArr.get(), formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE);
+
pDoc->SetFormulaCell(aPos, pNewCell);
bOk = true;
}
More information about the Libreoffice-commits
mailing list