summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-14 18:32:57 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-14 18:34:20 -0400
commit625c595fc30d2e6153735dc2ed2359ff4f8a1e3a (patch)
treeb24941adb87381dcb5ef651b593fa4aadd2e3c2f /formula
parentb09426b83c12b0cd27cd909602251cb076ffa4ba (diff)
fdo#76294: Intern strings in AddFormulaToken() as well.
And a whole bunch of changes needed to make that happen. Change-Id: Idd98fbc99322c0d72fb0a7848d89cb1a6abc88b6
Diffstat (limited to 'formula')
-rw-r--r--formula/source/core/api/token.cxx25
1 files changed, 15 insertions, 10 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index ecfb02aa52bb..197d62f1760f 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -29,6 +29,7 @@
#include "formula/tokenarray.hxx"
#include "formula/FormulaCompiler.hxx"
#include <formula/compiler.hrc>
+#include <svl/sharedstringpool.hxx>
namespace formula
{
@@ -297,12 +298,13 @@ FormulaJumpToken::~FormulaJumpToken()
}
-bool FormulaTokenArray::AddFormulaToken(const sheet::FormulaToken& _aToken,ExternalReferenceHelper* /*_pRef*/)
+bool FormulaTokenArray::AddFormulaToken(
+ const sheet::FormulaToken& rToken, svl::SharedStringPool& rSPool, ExternalReferenceHelper* /*pExtRef*/)
{
bool bError = false;
- const OpCode eOpCode = static_cast<OpCode>(_aToken.OpCode); //! assuming equal values for the moment
+ const OpCode eOpCode = static_cast<OpCode>(rToken.OpCode); //! assuming equal values for the moment
- const uno::TypeClass eClass = _aToken.Data.getValueTypeClass();
+ const uno::TypeClass eClass = rToken.Data.getValueTypeClass();
switch ( eClass )
{
case uno::TypeClass_VOID:
@@ -312,14 +314,14 @@ bool FormulaTokenArray::AddFormulaToken(const sheet::FormulaToken& _aToken,Exter
case uno::TypeClass_DOUBLE:
// double is only used for "push"
if ( eOpCode == ocPush )
- AddDouble( _aToken.Data.get<double>() );
+ AddDouble( rToken.Data.get<double>() );
else
bError = true;
break;
case uno::TypeClass_LONG:
{
// long is svIndex, used for name / database area, or "byte" for spaces
- sal_Int32 nValue = _aToken.Data.get<sal_Int32>();
+ sal_Int32 nValue = rToken.Data.get<sal_Int32>();
if ( eOpCode == ocDBArea )
AddToken( formula::FormulaIndexToken( eOpCode, static_cast<sal_uInt16>(nValue) ) );
else if ( eOpCode == ocSpaces )
@@ -330,9 +332,9 @@ bool FormulaTokenArray::AddFormulaToken(const sheet::FormulaToken& _aToken,Exter
break;
case uno::TypeClass_STRING:
{
- OUString aStrVal( _aToken.Data.get<OUString>() );
+ OUString aStrVal( rToken.Data.get<OUString>() );
if ( eOpCode == ocPush )
- AddString( aStrVal );
+ AddString(rSPool.intern(aStrVal));
else if ( eOpCode == ocBad )
AddBad( aStrVal );
else if ( eOpCode == ocStringXML )
@@ -348,13 +350,16 @@ bool FormulaTokenArray::AddFormulaToken(const sheet::FormulaToken& _aToken,Exter
} // switch ( eClass )
return bError;
}
-bool FormulaTokenArray::Fill(const uno::Sequence< sheet::FormulaToken >& _aSequence,ExternalReferenceHelper* _pRef)
+
+bool FormulaTokenArray::Fill(
+ const uno::Sequence<sheet::FormulaToken>& rSequence,
+ svl::SharedStringPool& rSPool, ExternalReferenceHelper* pExtRef )
{
bool bError = false;
- const sal_Int32 nCount = _aSequence.getLength();
+ const sal_Int32 nCount = rSequence.getLength();
for (sal_Int32 nPos=0; nPos<nCount; nPos++)
{
- bool bOneError = AddFormulaToken( _aSequence[nPos] ,_pRef);
+ bool bOneError = AddFormulaToken(rSequence[nPos], rSPool, pExtRef);
if (bOneError)
{
AddOpCode( ocErrName); // add something that indicates an error