summaryrefslogtreecommitdiff
path: root/sc/source
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
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')
-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
-rw-r--r--sc/source/filter/inc/xeroot.hxx3
-rw-r--r--sc/source/filter/inc/xestream.hxx3
-rw-r--r--sc/source/filter/xcl97/XclExpChangeTrack.cxx2
7 files changed, 19 insertions, 12 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 )
{
diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx
index 35de5c62c52b..698b0e4a49f6 100644
--- a/sc/source/filter/inc/xeroot.hxx
+++ b/sc/source/filter/inc/xeroot.hxx
@@ -52,6 +52,7 @@ class XclExpFilterManager;
class XclExpPivotTableManager;
class XclExpDxfs;
class XclExpXmlPivotTableManager;
+namespace sc { class CompileFormulaContext; }
/** Stores global buffers and data needed for Excel export filter. */
struct XclExpRootData : public XclRootData
@@ -92,6 +93,7 @@ struct XclExpRootData : public XclRootData
XclExpDxfsRef mxDxfs; /// All delta formatting entries
boost::shared_ptr<XclExpXmlPivotTableManager> mxXmlPTableMgr;
+ boost::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt;
ScCompiler::OpCodeMapPtr mxOpCodeMap; /// mapping between op-codes and names
@@ -112,6 +114,7 @@ public:
inline const XclExpRoot& GetRoot() const { return *this; }
/** Returns true, if URLs should be stored relative to the document location. */
inline bool IsRelUrl() const { return mrExpData.mbRelUrl; }
+ sc::CompileFormulaContext& GetCompileFormulaContext() const { return *mrExpData.mpCompileFormulaCxt; }
/** Returns the buffer for Calc->Excel sheet index conversion. */
XclExpTabInfo& GetTabInfo() const;
diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index c705e4547c2c..df1f7a30a17a 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -251,6 +251,7 @@ struct XclAddress;
struct XclFontData;
struct XclRange;
class XclRangeList;
+namespace sc { class CompileFormulaContext; }
class XclXmlUtils
{
@@ -275,7 +276,7 @@ public:
static OUString ToOUString( const char* s );
static OUString ToOUString( const ScfUInt16Vec& rBuffer, sal_Int32 nStart = 0, sal_Int32 nLength = -1 );
- static OUString ToOUString( ScDocument& rDocument, const ScAddress& rAddress, const ScTokenArray* pTokenArray );
+ static OUString ToOUString( sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray );
static OUString ToOUString( const XclExpString& s );
/**
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index 83cdd57a6cc4..04a64eb3d6d0 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -1032,7 +1032,7 @@ static void lcl_WriteCell( XclExpXmlStream& rStrm, sal_Int32 nElement, const ScA
// OOXTODO: other attributes? see XclExpFormulaCell::SaveXml()
FSEND );
pStream->writeEscaped( XclXmlUtils::ToOUString(
- *pData->mpFormulaCell->GetDocument(),
+ rStrm.GetRoot().GetCompileFormulaContext(),
pData->mpFormulaCell->aPos, pData->mpFormulaCell->GetCode()));
pStream->endElement( XML_f );
break;