summaryrefslogtreecommitdiff
path: root/sc/source/filter/excel
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-10-01 17:39:00 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-10-23 13:24:26 +0200
commit5ed4c11534ba431097da1abb5d600d21b5f68a9a (patch)
treedcbd3c1e0d797177bade3c2ee34ff3a6e734893b /sc/source/filter/excel
parentd8af144254b8f10fe1faa40f9072aad043ca35fe (diff)
Use sc::CompileFormulaContext for faster export
It's a cache for maTabNames (sheet names mangled for the current grammar for output) which ScCompiler needs and is expensive to get. Change-Id: I7e2954104427a3c220f0f097be6cd45a66485b56
Diffstat (limited to 'sc/source/filter/excel')
-rw-r--r--sc/source/filter/excel/xecontent.cxx12
-rw-r--r--sc/source/filter/excel/xeextlst.cxx2
-rw-r--r--sc/source/filter/excel/xestream.cxx7
-rw-r--r--sc/source/filter/excel/xetable.cxx2
4 files changed, 13 insertions, 10 deletions
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 5e5f9cd074cb..b7d5f3675bac 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -937,13 +937,13 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
if(!IsTextRule(eOperation) && !IsTopBottomRule(eOperation))
{
rWorksheet->startElement( XML_formula, FSEND );
- rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(),
+ rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetCompileFormulaContext(), mrFormatEntry.GetValidSrcPos(),
mrFormatEntry.CreateTokenArry(0)));
rWorksheet->endElement( XML_formula );
if (bFmla2)
{
rWorksheet->startElement( XML_formula, FSEND );
- rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(),
+ rWorksheet->writeEscaped(XclXmlUtils::ToOUString( GetCompileFormulaContext(), mrFormatEntry.GetValidSrcPos(),
mrFormatEntry.CreateTokenArry(1)));
rWorksheet->endElement( XML_formula );
}
@@ -1082,7 +1082,7 @@ void XclExpCfvo::SaveXml( XclExpXmlStream& rStrm )
OString aValue;
if(mrEntry.GetType() == COLORSCALE_FORMULA)
{
- OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), maSrcPos,
+ OUString aFormula = XclXmlUtils::ToOUString( GetCompileFormulaContext(), maSrcPos,
mrEntry.GetFormula()->Clone());
aValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
}
@@ -1583,7 +1583,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) :
Formula compiler supports this by offering two different functions
CreateDataValFormula() and CreateListValFormula(). */
mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_LISTVAL, *xScTokArr );
- msFormula1 = XclXmlUtils::ToOUString( GetDoc(), pValData->GetSrcPos(),
+ msFormula1 = XclXmlUtils::ToOUString( GetCompileFormulaContext(), pValData->GetSrcPos(),
xScTokArr.get());
}
}
@@ -1591,7 +1591,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) :
{
// no list validation -> convert the formula
mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, *xScTokArr );
- msFormula1 = XclXmlUtils::ToOUString( GetDoc(), pValData->GetSrcPos(),
+ msFormula1 = XclXmlUtils::ToOUString( GetCompileFormulaContext(), pValData->GetSrcPos(),
xScTokArr.get());
}
}
@@ -1601,7 +1601,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) :
if( xScTokArr.get() )
{
mxTokArr2 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, *xScTokArr );
- msFormula2 = XclXmlUtils::ToOUString( GetDoc(), pValData->GetSrcPos(),
+ msFormula2 = XclXmlUtils::ToOUString( GetCompileFormulaContext(), pValData->GetSrcPos(),
xScTokArr.get());
}
}
diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx
index 852647c33cfc..bb96e2753acc 100644
--- a/sc/source/filter/excel/xeextlst.cxx
+++ b/sc/source/filter/excel/xeextlst.cxx
@@ -62,7 +62,7 @@ XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry&
OUString aFormula;
if(pArr)
{
- aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos,
+ aFormula = XclXmlUtils::ToOUString( GetCompileFormulaContext(), rSrcPos,
pArr->Clone());
}
maValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 31e39c7d3e47..9d1adb00f8f2 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -39,6 +39,7 @@
#include "compiler.hxx"
#include "formulacell.hxx"
#include "tokenarray.hxx"
+#include "tokenstringcontext.hxx"
#include "refreshtimerprotector.hxx"
#include "globstr.hrc"
@@ -810,9 +811,10 @@ OUString XclXmlUtils::ToOUString( const ScfUInt16Vec& rBuf, sal_Int32 nStart, sa
}
OUString XclXmlUtils::ToOUString(
- ScDocument& rDocument, const ScAddress& rAddress, const ScTokenArray* pTokenArray )
+ sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray )
{
- ScCompiler aCompiler( &rDocument, rAddress, const_cast<ScTokenArray&>(*pTokenArray));
+ ScCompiler aCompiler( rCtx, rAddress, const_cast<ScTokenArray&>(*pTokenArray));
+
aCompiler.SetGrammar(FormulaGrammar::GRAM_OOXML);
OUStringBuffer aBuffer( pTokenArray->GetLen() * 5 );
@@ -1077,6 +1079,7 @@ bool XclExpXmlStream::exportDocument()
aData.maMaxPos.SetCol( ::std::min( aData.maScMaxPos.Col(), aData.maXclMaxPos.Col() ) );
aData.maMaxPos.SetRow( ::std::min( aData.maScMaxPos.Row(), aData.maXclMaxPos.Row() ) );
aData.maMaxPos.SetTab( ::std::min( aData.maScMaxPos.Tab(), aData.maXclMaxPos.Tab() ) );
+ aData.mpCompileFormulaCxt.reset( new sc::CompileFormulaContext(&rDoc) );
XclExpRoot aRoot( aData );
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 97a31c693eb1..cae6460d61ff 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -946,7 +946,7 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
// OOXTODO: XML_bx bool
FSEND );
rWorksheet->writeEscaped( XclXmlUtils::ToOUString(
- *mrScFmlaCell.GetDocument(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode()));
+ rStrm.GetRoot().GetCompileFormulaContext(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode()));
rWorksheet->endElement( XML_f );
if( strcmp( sType, "inlineStr" ) == 0 )
{