summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--formula/source/core/api/token.cxx18
-rw-r--r--include/formula/tokenarray.hxx1
-rw-r--r--sc/inc/tokenarray.hxx3
-rw-r--r--sc/source/core/tool/token.cxx12
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx13
5 files changed, 41 insertions, 6 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index c5d7da7ee28c..30b0e162d97c 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -687,6 +687,24 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r )
}
}
+/// Optimisiation for efficiently creating StringXML placeholders
+void FormulaTokenArray::Assign( sal_uInt16 nCode, FormulaToken **pTokens )
+{
+ assert( nLen = 0 );
+ assert( pCode == NULL );
+
+ nLen = nCode;
+ pCode = new FormulaToken*[ nLen ];
+
+ for( sal_uInt16 i = 0; i < nLen; i++ )
+ {
+ FormulaToken *t = pTokens[ i ];
+ assert( t->GetOpCode() == ocStringXML );
+ pCode[ i ] = t;
+ t->IncRef();
+ }
+}
+
FormulaTokenArray& FormulaTokenArray::operator=( const FormulaTokenArray& rArr )
{
Clear();
diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx
index 5654a3150f82..dcc8dc9200ef 100644
--- a/include/formula/tokenarray.hxx
+++ b/include/formula/tokenarray.hxx
@@ -82,6 +82,7 @@ protected:
protected:
void Assign( const FormulaTokenArray& );
+ void Assign( sal_uInt16 nCode, FormulaToken **pTokens );
/// Also used by the compiler. The token MUST had been allocated with new!
FormulaToken* Add( FormulaToken* );
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index c2191a8a934c..9538819e7733 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -110,6 +110,9 @@ public:
NULL if there is no pCode (which actually would be caller's fault). */
formula::FormulaToken* MergeRangeReference( const ScAddress & rPos );
+ /// Assign XML string placeholder to the array
+ void AssignXMLString( const OUString &rText, const OUString &rFormulaNmsp );
+
/// Assignment with references to ScToken entries (not copied!)
ScTokenArray& operator=( const ScTokenArray& );
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4f4cbf6939ad..4ac537f45155 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2083,6 +2083,18 @@ FormulaToken* ScTokenArray::AddColRowName( const ScSingleRefData& rRef )
return Add( new ScSingleRefToken( rRef, ocColRowName ) );
}
+void ScTokenArray::AssignXMLString( const OUString &rText, const OUString &rFormulaNmsp )
+{
+ sal_uInt16 nTokens = 1;
+ FormulaToken *aTokens[2];
+
+ aTokens[0] = new FormulaStringOpToken( ocStringXML, rText );
+ if( !rFormulaNmsp.isEmpty() )
+ aTokens[ nTokens++ ] = new FormulaStringOpToken( ocStringXML, rFormulaNmsp );
+
+ Assign( nTokens, aTokens );
+}
+
bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
const ScAddress& rPos, ScDirection eDir )
{
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index b09f90c34e61..4e4c5526b092 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1362,7 +1362,6 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
ScDocumentImport& rDoc = rXMLImport.GetDoc();
OUString aText = maFormula->first;
- OUString aFormulaNmsp = maFormula->second;
::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard (
new ScExternalRefManager::ApiGuard(pDoc));
@@ -1372,13 +1371,15 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
if ( aText[0] == '=' && aText.getLength() > 1 )
{
// temporary formula string as string tokens
- boost::scoped_ptr<ScTokenArray> pCode(new ScTokenArray);
- pCode->AddStringXML( aText );
- if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && !aFormulaNmsp.isEmpty() )
- pCode->AddStringXML( aFormulaNmsp );
+ ScTokenArray *pCode = new ScTokenArray();
+
+ OUString aFormulaNmsp = maFormula->second;
+ if( eGrammar != formula::FormulaGrammar::GRAM_EXTERNAL )
+ aFormulaNmsp = OUString();
+ pCode->AssignXMLString( aText, aFormulaNmsp );
rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() );
- ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, *pCode, eGrammar, MM_NONE);
+ ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode, eGrammar, MM_NONE);
SetFormulaCell(pNewCell);
rDoc.setFormulaCell(rCellPos, pNewCell);