diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-10 20:24:21 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-11 12:14:27 -0400 |
commit | 7333881bb7b04f7e4e2a28638024ae82a9c14e81 (patch) | |
tree | 97548f94ab918d502b45a5dda40ece5ad4117617 | |
parent | 6255be7ca294d350143290c343673f264f42220c (diff) |
Formula tokens, formula cells and formula interpreters to use shared strings.
Change-Id: I5da99869fc7f61ce698180fa5daa9be9db9ac132
53 files changed, 487 insertions, 424 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 5cd0b829dea2..fda54bdc082e 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1776,9 +1776,9 @@ FormulaToken* FormulaCompiler::CreateStringFromToken( OUStringBuffer& rBuffer, F case svString: if( eOp == ocBad || eOp == ocStringXML ) - rBuffer.append( t->GetString()); + rBuffer.append( t->GetString().getString()); else - AppendString( rBuffer, t->GetString() ); + AppendString( rBuffer, t->GetString().getString() ); break; case svSingleRef: CreateStringFromSingleRef( rBuffer, t); diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index da9c6f873b34..8f0cfa828c5b 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -174,11 +174,10 @@ double & FormulaToken::GetDoubleAsReference() return fVal; } -const OUString& FormulaToken::GetString() const +svl::SharedString FormulaToken::GetString() const { SAL_WARN( "formula.core", "FormulaToken::GetString: virtual dummy called" ); - static OUString aDummyString; - return aDummyString; + return svl::SharedString(); // invalid string } sal_uInt16 FormulaToken::GetIndex() const @@ -1323,18 +1322,45 @@ bool FormulaDoubleToken::operator==( const FormulaToken& r ) const return FormulaToken::operator==( r ) && fDouble == r.GetDouble(); } +FormulaStringToken::FormulaStringToken( const svl::SharedString& r ) : + FormulaToken( svString ), maString( r ) {} +FormulaStringToken::FormulaStringToken( const FormulaStringToken& r ) : + FormulaToken( r ), maString( r.maString ) {} + +FormulaToken* FormulaStringToken::Clone() const +{ + return new FormulaStringToken(*this); +} + +svl::SharedString FormulaStringToken::GetString() const +{ + return maString; +} -const OUString& FormulaStringToken::GetString() const { return aString; } bool FormulaStringToken::operator==( const FormulaToken& r ) const { - return FormulaToken::operator==( r ) && aString == r.GetString(); + return FormulaToken::operator==( r ) && maString == r.GetString(); } +FormulaStringOpToken::FormulaStringOpToken( OpCode e, const svl::SharedString& r ) : + FormulaByteToken( e, 0, svString, false ), maString( r ) {} + +FormulaStringOpToken::FormulaStringOpToken( const FormulaStringOpToken& r ) : + FormulaByteToken( r ), maString( r.maString ) {} + +FormulaToken* FormulaStringOpToken::Clone() const +{ + return new FormulaStringOpToken(*this); +} + +svl::SharedString FormulaStringOpToken::GetString() const +{ + return maString; +} -const OUString& FormulaStringOpToken::GetString() const { return aString; } bool FormulaStringOpToken::operator==( const FormulaToken& r ) const { - return FormulaByteToken::operator==( r ) && aString == r.GetString(); + return FormulaByteToken::operator==( r ) && maString == r.GetString(); } sal_uInt16 FormulaIndexToken::GetIndex() const { return nIndex; } @@ -1364,11 +1390,12 @@ bool FormulaErrorToken::operator==( const FormulaToken& r ) const nError == static_cast< const FormulaErrorToken & >(r).GetError(); } double FormulaMissingToken::GetDouble() const { return 0.0; } -const OUString& FormulaMissingToken::GetString() const + +svl::SharedString FormulaMissingToken::GetString() const { - static OUString aDummyString; - return aDummyString; + return svl::SharedString::getEmptyString(); } + bool FormulaMissingToken::operator==( const FormulaToken& r ) const { return FormulaToken::operator==( r ); diff --git a/include/formula/token.hxx b/include/formula/token.hxx index d9486be9efe9..905be7b5ef90 100644 --- a/include/formula/token.hxx +++ b/include/formula/token.hxx @@ -28,6 +28,7 @@ #include "formula/IFunctionDescription.hxx" #include "formula/formuladllapi.h" #include "formula/types.hxx" +#include "svl/sharedstring.hxx" namespace formula { @@ -136,7 +137,7 @@ public: virtual void SetForceArray( bool b ); virtual double GetDouble() const; virtual double& GetDoubleAsReference(); - virtual const OUString& GetString() const; + virtual svl::SharedString GetString() const; virtual sal_uInt16 GetIndex() const; virtual void SetIndex( sal_uInt16 n ); virtual bool IsGlobal() const; @@ -256,17 +257,14 @@ public: class FORMULA_DLLPUBLIC FormulaStringToken : public FormulaToken { -private: - OUString aString; + svl::SharedString maString; public: - FormulaStringToken( const OUString& r ) : - FormulaToken( svString ), aString( r ) {} - FormulaStringToken( const FormulaStringToken& r ) : - FormulaToken( r ), aString( r.aString ) {} + FormulaStringToken( const svl::SharedString& r ); + FormulaStringToken( const FormulaStringToken& r ); - virtual FormulaToken* Clone() const { return new FormulaStringToken(*this); } - virtual const OUString& GetString() const; - virtual bool operator==( const FormulaToken& rToken ) const; + virtual FormulaToken* Clone() const; + virtual svl::SharedString GetString() const; + virtual bool operator==( const FormulaToken& rToken ) const; DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaStringToken ) }; @@ -276,17 +274,14 @@ public: ocPush, and an optional sal_uInt8 for ocBad tokens. */ class FORMULA_DLLPUBLIC FormulaStringOpToken : public FormulaByteToken { -private: - OUString aString; + svl::SharedString maString; public: - FormulaStringOpToken( OpCode e, const OUString& r ) : - FormulaByteToken( e, 0, svString, false ), aString( r ) {} - FormulaStringOpToken( const FormulaStringOpToken& r ) : - FormulaByteToken( r ), aString( r.aString ) {} + FormulaStringOpToken( OpCode e, const svl::SharedString& r ); + FormulaStringOpToken( const FormulaStringOpToken& r ); - virtual FormulaToken* Clone() const { return new FormulaStringOpToken(*this); } - virtual const OUString& GetString() const; - virtual bool operator==( const FormulaToken& rToken ) const; + virtual FormulaToken* Clone() const; + virtual svl::SharedString GetString() const; + virtual bool operator==( const FormulaToken& rToken ) const; }; class FORMULA_DLLPUBLIC FormulaIndexToken : public FormulaToken @@ -343,7 +338,7 @@ public: virtual FormulaToken* Clone() const { return new FormulaMissingToken(*this); } virtual double GetDouble() const; - virtual const OUString& GetString() const; + virtual svl::SharedString GetString() const; virtual bool operator==( const FormulaToken& rToken ) const; }; diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx index a3650a5e22e7..413717f9da22 100644 --- a/include/svl/sharedstring.hxx +++ b/include/svl/sharedstring.hxx @@ -20,6 +20,9 @@ class SVL_DLLPUBLIC SharedString rtl_uString* mpData; rtl_uString* mpDataIgnoreCase; public: + + static SharedString getEmptyString(); + SharedString(); SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase ); SharedString( const OUString& rStr ); diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index a4947599033d..ea80b1518300 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -244,7 +244,7 @@ public: bool IsValueNoError(); bool IsHybridValueCell(); // for cells after import to deal with inherited number formats double GetValue(); - OUString GetString(); + svl::SharedString GetString(); const ScMatrix* GetMatrix(); bool GetMatrixOrigin( ScAddress& rPos ) const; void GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ); @@ -252,7 +252,7 @@ public: sal_uInt16 GetErrCode(); // interpret first if necessary sal_uInt16 GetRawError(); // don't interpret, just return code or result error bool GetErrorOrValue( sal_uInt16& rErr, double& rVal ); - bool GetErrorOrString( sal_uInt16& rErr, OUString& rStr ); + bool GetErrorOrString( sal_uInt16& rErr, svl::SharedString& rStr ); sal_uInt8 GetMatrixFlag() const; ScTokenArray* GetCode(); const ScTokenArray* GetCode() const; @@ -309,7 +309,7 @@ public: void SetResultToken( const formula::FormulaToken* pToken ); - OUString GetResultString() const; + svl::SharedString GetResultString() const; void SetErrCode( sal_uInt16 n ); bool IsHyperLinkCell() const; diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx index d1c235f5ed74..8a7b36543284 100644 --- a/sc/inc/formularesult.hxx +++ b/sc/inc/formularesult.hxx @@ -135,7 +135,7 @@ public: bool IsMultiline() const; bool GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const; - bool GetErrorOrString( sal_uInt16& rErr, OUString& rStr ) const; + bool GetErrorOrString( sal_uInt16& rErr, svl::SharedString& rStr ) const; /** Get error code if set or GetCellResultType() is formula::svError or svUnknown, else 0. */ @@ -159,7 +159,7 @@ public: /** Return string if type formula::svString or formula::svHybridCell or formula::svMatrixCell and upper left formula::svString, else empty string. */ - const OUString& GetString() const; + svl::SharedString GetString() const; /** Return matrix if type formula::svMatrixCell and ScMatrix present, else NULL. */ ScConstMatrixRef GetMatrix() const; diff --git a/sc/inc/simpleformulacalc.hxx b/sc/inc/simpleformulacalc.hxx index 43ff6eac4acf..4d13c6bd7a3b 100644 --- a/sc/inc/simpleformulacalc.hxx +++ b/sc/inc/simpleformulacalc.hxx @@ -40,7 +40,7 @@ public: bool IsValue(); sal_uInt16 GetErrCode(); double GetValue(); - OUString GetString(); + svl::SharedString GetString(); short GetFormatType() const { return mnFormatType; } sal_uLong GetFormatIndex() const { return mnFormatIndex; } diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx index 7b657e56d26f..0046c44e2262 100644 --- a/sc/inc/token.hxx +++ b/sc/inc/token.hxx @@ -210,19 +210,18 @@ public: class ScExternalSingleRefToken : public ScToken { -private: sal_uInt16 mnFileId; - OUString maTabName; + svl::SharedString maTabName; ScSingleRefData maSingleRef; - ScExternalSingleRefToken(); // disabled + ScExternalSingleRefToken(); // disabled public: - ScExternalSingleRefToken( sal_uInt16 nFileId, const OUString& rTabName, const ScSingleRefData& r ); - ScExternalSingleRefToken( const ScExternalSingleRefToken& r ); - virtual ~ScExternalSingleRefToken(); + ScExternalSingleRefToken( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScSingleRefData& r ); + ScExternalSingleRefToken( const ScExternalSingleRefToken& r ); + virtual ~ScExternalSingleRefToken(); virtual sal_uInt16 GetIndex() const; - virtual const OUString& GetString() const; + virtual svl::SharedString GetString() const; virtual const ScSingleRefData& GetSingleRef() const; virtual ScSingleRefData& GetSingleRef(); virtual bool operator==( const formula::FormulaToken& rToken ) const; @@ -232,19 +231,18 @@ public: class ScExternalDoubleRefToken : public ScToken { -private: sal_uInt16 mnFileId; - OUString maTabName; // name of the first sheet + svl::SharedString maTabName; // name of the first sheet ScComplexRefData maDoubleRef; - ScExternalDoubleRefToken(); // disabled + ScExternalDoubleRefToken(); // disabled public: - ScExternalDoubleRefToken( sal_uInt16 nFileId, const OUString& rTabName, const ScComplexRefData& r ); - ScExternalDoubleRefToken( const ScExternalDoubleRefToken& r ); - virtual ~ScExternalDoubleRefToken(); + ScExternalDoubleRefToken( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScComplexRefData& r ); + ScExternalDoubleRefToken( const ScExternalDoubleRefToken& r ); + virtual ~ScExternalDoubleRefToken(); virtual sal_uInt16 GetIndex() const; - virtual const OUString& GetString() const; + virtual svl::SharedString GetString() const; virtual const ScSingleRefData& GetSingleRef() const; virtual ScSingleRefData& GetSingleRef(); virtual const ScSingleRefData& GetSingleRef2() const; @@ -257,17 +255,17 @@ public: class ScExternalNameToken : public ScToken { -private: sal_uInt16 mnFileId; - OUString maName; -private: - ScExternalNameToken(); // disabled + svl::SharedString maName; + + ScExternalNameToken(); // disabled public: - ScExternalNameToken( sal_uInt16 nFileId, const OUString& rName ); - ScExternalNameToken( const ScExternalNameToken& r ); - virtual ~ScExternalNameToken(); + ScExternalNameToken( sal_uInt16 nFileId, const svl::SharedString& rName ); + ScExternalNameToken( const ScExternalNameToken& r ); + virtual ~ScExternalNameToken(); + virtual sal_uInt16 GetIndex() const; - virtual const OUString& GetString() const; + virtual svl::SharedString GetString() const; virtual bool operator==( const formula::FormulaToken& rToken ) const; virtual FormulaToken* Clone() const { return new ScExternalNameToken(*this); } }; @@ -325,7 +323,7 @@ public: bool IsInherited() const { return bInherited; } bool IsDisplayedAsString() const { return bDisplayedAsString; } virtual double GetDouble() const; - virtual const OUString & GetString() const; + virtual svl::SharedString GetString() const; virtual bool operator==( const formula::FormulaToken& rToken ) const; virtual FormulaToken* Clone() const { return new ScEmptyCellToken(*this); } }; @@ -345,7 +343,7 @@ public: ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ); ScMatrixCellResultToken( const ScMatrixCellResultToken& r ); virtual double GetDouble() const; - virtual const OUString & GetString() const; + virtual svl::SharedString GetString() const; virtual const ScMatrix* GetMatrix() const; virtual bool operator==( const formula::FormulaToken& rToken ) const; virtual FormulaToken* Clone() const; @@ -414,11 +412,11 @@ class SC_DLLPUBLIC ScHybridCellToken : public ScToken { private: double mfDouble; - OUString maString; + svl::SharedString maString; OUString maFormula; public: ScHybridCellToken( double f, - const OUString & rStr, + const svl::SharedString & rStr, const OUString & rFormula ) : ScToken( formula::svHybridCell ), mfDouble( f ), maString( rStr ), @@ -426,7 +424,8 @@ public: const OUString& GetFormula() const { return maFormula; } virtual double GetDouble() const; - virtual const OUString& GetString() const; + + virtual svl::SharedString GetString() const; virtual bool operator==( const formula::FormulaToken& rToken ) const; virtual FormulaToken* Clone() const { return new ScHybridCellToken(*this); } }; diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx index c40fa1f41b07..ba261b17b29a 100644 --- a/sc/source/core/data/autonamecache.cxx +++ b/sc/source/core/data/autonamecache.cxx @@ -66,7 +66,7 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const OUString& aStr = aIter.getString(); break; case CELLTYPE_FORMULA: - aStr = aIter.getFormulaCell()->GetString(); + aStr = aIter.getFormulaCell()->GetString().getString(); break; case CELLTYPE_EDIT: { diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx index af12e19661de..12ef30272e62 100644 --- a/sc/source/core/data/cellvalue.cxx +++ b/sc/source/core/data/cellvalue.cxx @@ -564,7 +564,7 @@ OUString ScRefCellValue::getString( const ScDocument* pDoc ) return ScEditUtil::GetString(*mpEditText, pDoc); break; case CELLTYPE_FORMULA: - return mpFormula->GetString(); + return mpFormula->GetString().getString(); default: ; } diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 5270e4c18eec..c62ff84c66f5 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1507,8 +1507,8 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nRow, rFC.GetValue()); else { - svl::SharedString aSS = pDocument->GetSharedStringPool().intern(rFC.GetString()); - if (aSS.getData()) + svl::SharedString aSS = rFC.GetString(); + if (aSS.isValid()) aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nRow, aSS); } } @@ -1785,7 +1785,7 @@ class CopyByCloneHandler if (bCloneString) { - OUString aStr = rSrcCell.GetString(); + svl::SharedString aStr = rSrcCell.GetString(); if (aStr.isEmpty()) // Don't create empty string cells. return; @@ -1794,18 +1794,14 @@ class CopyByCloneHandler { // Clone as an edit text object. EditEngine& rEngine = mrDestCol.GetDoc().GetEditEngine(); - rEngine.SetText(aStr); + rEngine.SetText(aStr.getString()); maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rEngine.CreateTextObject()); } else { - svl::SharedString aSS = mrDestCol.GetDoc().GetSharedStringPool().intern(aStr); - if (aSS.getData()) - { - maDestPos.miCellPos = - mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aSS); - } + maDestPos.miCellPos = + mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aStr); } setDefaultAttrToDest(nRow); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 62cd53857076..a0ee0462bd53 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1895,7 +1895,7 @@ public: if (rCell.IsValue()) mrMat.PutDouble(rCell.GetValue(), mnMatCol, nRow - mnTopRow); else - mrMat.PutString(mrStrPool.intern(rCell.GetString()), mnMatCol, nRow - mnTopRow); + mrMat.PutString(rCell.GetString(), mnMatCol, nRow - mnTopRow); } void operator() (size_t nRow, const svl::SharedString& rSS) @@ -2050,7 +2050,7 @@ public: continue; } - svl::SharedString aStr = mrPool.intern(rCell.GetString()); + svl::SharedString aStr = rCell.GetString(); if (!aBucket.maStrVals.empty() && nThisRow == nPrevRow + 1) { // Secondary strings. @@ -2216,7 +2216,7 @@ bool appendStrings( getBlockIterators<sc::formula_block>(it, nLenRemain, itData, itDataEnd); sal_uInt16 nErr; - OUString aStr; + svl::SharedString aStr; for (; itData != itDataEnd; ++itData) { ScFormulaCell& rFC = **itData; @@ -2231,7 +2231,7 @@ bool appendStrings( return false; } - rArray.push_back(rPool.intern(aStr).getDataIgnoreCase()); + rArray.push_back(aStr.getDataIgnoreCase()); } } break; diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index c34fa1702e68..02ed182bfbce 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -847,7 +847,7 @@ public: } else if (bString) { - OUString aStr = rSrcCell.GetString(); + svl::SharedString aStr = rSrcCell.GetString(); if (aStr.isEmpty()) // do not clone empty string continue; @@ -858,7 +858,7 @@ public: { // Clone as an edit text object. ScFieldEditEngine& rEngine = mrDestCol.GetDoc().GetEditEngine(); - rEngine.SetText(aStr); + rEngine.SetText(aStr.getString()); mrDestCol.SetEditText(maDestBlockPos, nSrcRow + mnRowOffset, rEngine.CreateTextObject()); } else @@ -2073,19 +2073,16 @@ class FormulaToValueHandler typedef std::vector<Entry> EntriesType; EntriesType maEntries; - svl::SharedStringPool& mrStrPool; public: - FormulaToValueHandler(ScDocument& rDoc) : mrStrPool(rDoc.GetSharedStringPool()) {} - void operator() (size_t nRow, const ScFormulaCell* p) { ScFormulaCell* p2 = const_cast<ScFormulaCell*>(p); if (p2->IsValue()) maEntries.push_back(Entry(nRow, p2->GetValue())); else - maEntries.push_back(Entry(nRow, mrStrPool.intern(p2->GetString()))); + maEntries.push_back(Entry(nRow, p2->GetString())); } void commitCells(ScColumn& rColumn) @@ -2115,7 +2112,7 @@ public: void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow ) { - FormulaToValueHandler aFunc(*pDocument); + FormulaToValueHandler aFunc; sc::CellStoreType::const_iterator itPos = maCells.begin(); ScAttrIterator aAttrIter( pAttrArray, nStartRow, nEndRow ); diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 418b30379e78..3ab133c3ddb7 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -280,7 +280,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, else if ( pToken->GetType() == svString ) { bIsStr1 = true; - aStrVal1 = pToken->GetString(); + aStrVal1 = pToken->GetString().getString(); DELETEZ(pFormula1); // nicht als Formel merken } } @@ -304,7 +304,7 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper, else if ( pToken->GetType() == svString ) { bIsStr2 = true; - aStrVal2 = pToken->GetString(); + aStrVal2 = pToken->GetString().getString(); DELETEZ(pFormula2); // nicht als Formel merken } } @@ -360,7 +360,7 @@ void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2, else if ( pToken->GetType() == svString ) { bIsStr1 = true; - aStrVal1 = pToken->GetString(); + aStrVal1 = pToken->GetString().getString(); DELETEZ(pFormula1); // nicht als Formel merken } } @@ -397,7 +397,7 @@ void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2, else if ( pToken->GetType() == svString ) { bIsStr2 = true; - aStrVal2 = pToken->GetString(); + aStrVal2 = pToken->GetString().getString(); DELETEZ(pFormula2); // nicht als Formel merken } } @@ -649,7 +649,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos ) else { bIsStr1 = true; - aStrVal1 = pEff1->GetString(); + aStrVal1 = pEff1->GetString().getString(); nVal1 = 0.0; } } @@ -678,7 +678,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos ) else { bIsStr2 = true; - aStrVal2 = pEff2->GetString(); + aStrVal2 = pEff2->GetString().getString(); nVal2 = 0.0; } } @@ -717,7 +717,7 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr if (bVal) rArg = rCell.mpFormula->GetValue(); else - rArgStr = rCell.mpFormula->GetString(); + rArgStr = rCell.mpFormula->GetString().getString(); } break; case CELLTYPE_STRING: diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index eaa496ac6ce6..a73b02b90f7f 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -440,7 +440,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) incPos(); else { - rValue.maString = aCell.mpFormula->GetString(); + rValue.maString = aCell.mpFormula->GetString().getString(); rValue.mfValue = 0.0; rValue.mnError = aCell.mpFormula->GetErrCode(); rValue.mbIsNumber = false; diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 53c90db8494d..d5e842942800 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -443,14 +443,14 @@ bool setCacheTableReferenced(ScToken& rToken, ScExternalRefManager& rRefMgr, con { case svExternalSingleRef: return rRefMgr.setCacheTableReferenced( - rToken.GetIndex(), rToken.GetString(), 1); + rToken.GetIndex(), rToken.GetString().getString(), 1); case svExternalDoubleRef: { const ScComplexRefData& rRef = rToken.GetDoubleRef(); ScRange aAbs = rRef.toAbs(rPos); size_t nSheets = aAbs.aEnd.Tab() - aAbs.aStart.Tab() + 1; return rRefMgr.setCacheTableReferenced( - rToken.GetIndex(), rToken.GetString(), nSheets); + rToken.GetIndex(), rToken.GetString().getString(), nSheets); } case svExternalName: /* TODO: external names aren't supported yet, but would diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 51a5c2ef8eb0..8232af15fd8e 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3265,7 +3265,7 @@ sal_uInt16 ScDocument::GetStringForFormula( const ScAddress& rPos, OUString& rSt pFormatter->GetInputLineString(fVal, nIndex, aStr); } else - aStr = pFCell->GetString(); + aStr = pFCell->GetString().getString(); } break; case CELLTYPE_VALUE: diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 498c1aa2b434..f3bf7fcbd059 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1700,7 +1700,7 @@ void ScFormulaCell::SetResultToken( const formula::FormulaToken* pToken ) aResult.SetToken(pToken); } -OUString ScFormulaCell::GetResultString() const +svl::SharedString ScFormulaCell::GetResultString() const { return aResult.GetString(); } @@ -1770,7 +1770,7 @@ void ScFormulaCell::GetURLResult( OUString& rURL, OUString& rCellText ) } else { - aCellString = GetString(); + aCellString = GetString().getString(); pFormatter->GetOutputString( aCellString, nCellFormat, rCellText, &pColor ); } ScConstMatrixRef xMat( aResult.GetMatrix()); @@ -1864,13 +1864,14 @@ double ScFormulaCell::GetValue() return 0.0; } -OUString ScFormulaCell::GetString() +svl::SharedString ScFormulaCell::GetString() { MaybeInterpret(); if ((!pCode->GetCodeError() || pCode->GetCodeError() == errDoubleRef) && !aResult.GetResultError()) return aResult.GetString(); - return OUString(); + + return svl::SharedString::getEmptyString(); } const ScMatrix* ScFormulaCell::GetMatrix() @@ -2082,7 +2083,7 @@ bool ScFormulaCell::GetErrorOrValue( sal_uInt16& rErr, double& rVal ) return aResult.GetErrorOrDouble(rErr, rVal); } -bool ScFormulaCell::GetErrorOrString( sal_uInt16& rErr, OUString& rStr ) +bool ScFormulaCell::GetErrorOrString( sal_uInt16& rErr, svl::SharedString& rStr ) { MaybeInterpret(); diff --git a/sc/source/core/data/simpleformulacalc.cxx b/sc/source/core/data/simpleformulacalc.cxx index 1b2cd35f3b19..8702c3b9e75a 100644 --- a/sc/source/core/data/simpleformulacalc.cxx +++ b/sc/source/core/data/simpleformulacalc.cxx @@ -75,7 +75,7 @@ double ScSimpleFormulaCalculator::GetValue() return 0.0; } -OUString ScSimpleFormulaCalculator::GetString() +svl::SharedString ScSimpleFormulaCalculator::GetString() { Calculate(); @@ -83,7 +83,7 @@ OUString ScSimpleFormulaCalculator::GetString() !maResult.GetResultError()) return maResult.GetString(); - return OUString(); + return svl::SharedString::getEmptyString(); } bool ScSimpleFormulaCalculator::HasColRowName() diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 9c24d966cae6..9cbf6cbfb178 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -199,7 +199,7 @@ bool ScValidationData::DoScript( const ScAddress& rPos, const OUString& rInput, if ( bIsValue ) nValue = pCell->GetValue(); else - aValStr = pCell->GetString(); + aValStr = pCell->GetString().getString(); } if ( bIsValue ) aParams[0] = ::com::sun::star::uno::makeAny( nValue ); @@ -318,7 +318,7 @@ bool ScValidationData::DoMacro( const ScAddress& rPos, const OUString& rInput, if ( bIsValue ) nValue = pCell->GetValue(); else - aValStr = pCell->GetString(); + aValStr = pCell->GetString().getString(); } if ( bIsValue ) refPar->Get(1)->PutDouble( nValue ); @@ -501,7 +501,7 @@ bool ScValidationData::IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos if ( bIsVal ) nVal = pFCell->GetValue(); else - aString = pFCell->GetString(); + aString = pFCell->GetString().getString(); } break; default: // Notizen, Broadcaster @@ -560,27 +560,28 @@ public: mrTokArr( rTokArr ), mbSkipEmpty( bSkipEmpty ), mbOk( true ) {} /** Returns the string of the first string token or NULL on error or empty token array. */ - const OUString* First(); + rtl_uString* First(); /** Returns the string of the next string token or NULL on error or end of token array. */ - const OUString* Next(); + rtl_uString* Next(); /** Returns false, if a wrong token has been found. Does NOT return false on end of token array. */ inline bool Ok() const { return mbOk; } private: + svl::SharedString maCurString; /// Current string. ScTokenArray& mrTokArr; /// The token array for iteration. bool mbSkipEmpty; /// Ignore empty strings. bool mbOk; /// true = correct token or end of token array. }; -const OUString* ScStringTokenIterator::First() +rtl_uString* ScStringTokenIterator::First() { mrTokArr.Reset(); mbOk = true; return Next(); } -const OUString* ScStringTokenIterator::Next() +rtl_uString* ScStringTokenIterator::Next() { if( !mbOk ) return NULL; @@ -591,9 +592,13 @@ const OUString* ScStringTokenIterator::Next() pToken = mrTokArr.NextNoSpaces(); mbOk = !pToken || (pToken->GetType() == formula::svString); - const OUString* pString = (mbOk && pToken) ? &pToken->GetString() : NULL; + + maCurString = svl::SharedString(); // start with invalid string. + if (mbOk && pToken) + maCurString = pToken->GetString(); + // string found but empty -> get next token; otherwise return it - return (mbSkipEmpty && pString && pString->isEmpty()) ? Next() : pString; + return (mbSkipEmpty && maCurString.isValid() && maCurString.isEmpty()) ? Next() : maCurString.getData(); } // ---------------------------------------------------------------------------- @@ -660,8 +665,8 @@ bool ScValidationData::GetSelectionFromFormula( xMatRef->PutDouble( aValidationSrc.GetValue(), 0); else { - OUString aStr = aValidationSrc.GetString(); - xMatRef->PutString(pDocument->GetSharedStringPool().intern(aStr), 0); + svl::SharedString aStr = aValidationSrc.GetString(); + xMatRef->PutString(aStr, 0); } pValues = xMatRef.get(); @@ -805,13 +810,14 @@ bool ScValidationData::FillSelectionList(std::vector<ScTypedStrData>& rStrColl, sal_uInt32 nFormat = lclGetCellFormat( *GetDocument(), rPos ); ScStringTokenIterator aIt( *pTokArr ); - for( const OUString* pString = aIt.First(); pString && aIt.Ok(); pString = aIt.Next() ) + for (rtl_uString* pString = aIt.First(); pString && aIt.Ok(); pString = aIt.Next()) { double fValue; - bool bIsValue = GetDocument()->GetFormatTable()->IsNumberFormat( *pString, nFormat, fValue ); + OUString aStr(pString); + bool bIsValue = GetDocument()->GetFormatTable()->IsNumberFormat(aStr, nFormat, fValue); rStrColl.push_back( ScTypedStrData( - *pString, fValue, bIsValue ? ScTypedStrData::Value : ScTypedStrData::Standard)); + aStr, fValue, bIsValue ? ScTypedStrData::Value : ScTypedStrData::Standard)); } bOk = aIt.Ok(); @@ -861,7 +867,7 @@ bool ScValidationData::IsListValid( ScRefCellValue& rCell, const ScAddress& rPos sal_uInt32 nFormat = lclGetCellFormat( *GetDocument(), rPos ); ScStringTokenIterator aIt( *pTokArr ); - for( const OUString* pString = aIt.First(); pString && aIt.Ok(); pString = aIt.Next() ) + for (rtl_uString* pString = aIt.First(); pString && aIt.Ok(); pString = aIt.Next()) { /* Do not break the loop, if a valid string has been found. This is to find invalid tokens following in the formula. */ @@ -870,10 +876,11 @@ bool ScValidationData::IsListValid( ScRefCellValue& rCell, const ScAddress& rPos // create a formula containing a single string or number ScTokenArray aCondTokArr; double fValue; - if( GetDocument()->GetFormatTable()->IsNumberFormat( *pString, nFormat, fValue ) ) + OUString aStr(pString); + if (GetDocument()->GetFormatTable()->IsNumberFormat(aStr, nFormat, fValue)) aCondTokArr.AddDouble( fValue ); else - aCondTokArr.AddString( *pString ); + aCondTokArr.AddString(aStr); bIsValid = IsEqualToTokenArray(rCell, rPos, aCondTokArr); } diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 975ba25e3461..29c722bdfea5 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -160,7 +160,6 @@ private: const formula::FormulaToken* pCur; // current token - OUString aTempStr; // for GetString() ScTokenStack* pStackObj; // contains the stacks formula::FormulaToken** pStack; // the current stack sal_uInt16 nGlobalError; // global (local to this formula expression) error @@ -200,7 +199,7 @@ double ConvertStringToValue( const OUString& ); double GetCellValue( const ScAddress&, ScRefCellValue& rCell ); double GetCellValueOrZero( const ScAddress&, ScRefCellValue& rCell ); double GetValueCellValue( const ScAddress&, double fOrig ); -void GetCellString( OUString& rStr, ScRefCellValue& rCell ); +void GetCellString( svl::SharedString& rStr, ScRefCellValue& rCell ); sal_uInt16 GetCellErrCode( const ScRefCellValue& rCell ); bool CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, @@ -267,7 +266,7 @@ formula::FormulaTokenRef PopToken(); void Pop(); void PopError(); double PopDouble(); -const OUString& PopString(); +svl::SharedString PopString(); void ValidateRef( const ScSingleRefData & rRef ); void ValidateRef( const ScComplexRefData & rRef ); void ValidateRef( const ScRefList & rRefList ); @@ -317,7 +316,8 @@ void QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_uLong& rRetInde void PushDouble(double nVal); void PushInt( int nVal ); void PushStringBuffer( const sal_Unicode* pString ); -void PushString( const OUString& rString ); +void PushString( const OUString& rStr ); +void PushString( const svl::SharedString& rString ); void PushSingleRef(SCCOL nCol, SCROW nRow, SCTAB nTab); void PushDoubleRef(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2); @@ -343,10 +343,10 @@ double GetDouble(); double GetDoubleWithDefault(double nDefault); bool IsMissing(); bool GetBool() { return GetDouble() != 0.0; } -const OUString& GetString(); -const OUString& GetStringFromMatrix(const ScMatrixRef& pMat); +svl::SharedString GetString(); +svl::SharedString GetStringFromMatrix(const ScMatrixRef& pMat); // pop matrix and obtain one element, upper left or according to jump matrix -ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, OUString& rString ); +ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, svl::SharedString& rString ); ScMatrixRef CreateMatrixFromDoubleRef( const formula::FormulaToken* pToken, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ); @@ -833,7 +833,7 @@ public: sal_uInt16 GetError() const { return nGlobalError; } formula::StackVar GetResultType() const { return xResult->GetType(); } - const OUString& GetStringResult() const { return xResult->GetString(); } + svl::SharedString GetStringResult() const; double GetNumResult() const { return xResult->GetDouble(); } formula::FormulaTokenRef GetResultToken() const { return xResult; } short GetRetFormatType() const { return nRetFmtType; } diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index 1f394f766552..fdeb7f8b8bdb 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -112,13 +112,13 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString if ( !bNullVals && fValue == 0.0 ) rString = OUString(); else if ( pFCell->IsHybridValueCell() ) - rString = pFCell->GetString(); + rString = pFCell->GetString().getString(); else rFormatter.GetOutputString( fValue, nFormat, rString, ppColor, bUseStarFormat ); } else { - OUString aCellString = pFCell->GetString(); + OUString aCellString = pFCell->GetString().getString(); rFormatter.GetOutputString( aCellString, nFormat, rString, ppColor, bUseStarFormat ); } } @@ -205,12 +205,12 @@ OUString ScCellFormat::GetString( { double fValue = pFCell->GetValue(); if (!bNullVals && fValue == 0.0) aString = OUString(); - else if (pFCell->IsHybridValueCell()) aString = pFCell->GetString(); + else if (pFCell->IsHybridValueCell()) aString = pFCell->GetString().getString(); else rFormatter.GetOutputString(fValue, nFormat, aString, ppColor, bUseStarFormat); } else { - OUString aCellString = pFCell->GetString(); + OUString aCellString = pFCell->GetString().getString(); rFormatter.GetOutputString(aCellString, nFormat, aString, ppColor, bUseStarFormat); } } @@ -250,7 +250,7 @@ void ScCellFormat::GetInputString( else if (pFC->IsValue()) rFormatter.GetInputLineString(pFC->GetValue(), nFormat, aString); else - aString = pFC->GetString(); + aString = pFC->GetString().getString(); sal_uInt16 nErrCode = pFC->GetErrCode(); if (nErrCode != 0) diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index c64c98f1c4cd..128cf183f644 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3624,9 +3624,9 @@ void ScCompiler::CreateStringFromXMLTokenArray( OUString& rFormula, OUString& rF { FormulaToken** ppTokens = pArr->GetArray(); // string tokens expected, GetString() will assert if token type is wrong - rFormula = ppTokens[ 0 ]->GetString(); + rFormula = ppTokens[0]->GetString().getString(); if( bExternal ) - rFormulaNmsp = ppTokens[ 1 ]->GetString(); + rFormulaNmsp = ppTokens[1]->GetString().getString(); } } @@ -3985,9 +3985,9 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken) return true; } - const OUString& rName = _aToken.GetString(); + OUString aName = _aToken.GetString().getString(); ScExternalRefCache::TokenArrayRef xNew = pRefMgr->getRangeNameTokens( - _aToken.GetIndex(), rName, &aPos); + _aToken.GetIndex(), aName, &aPos); if (!xNew) { @@ -4111,16 +4111,16 @@ void ScCompiler::CreateStringFromExternal(OUStringBuffer& rBuffer, FormulaToken* { const OUString *pStr = pRefMgr->getExternalFileName(t->GetIndex()); OUString aFileName = pStr ? *pStr : ScGlobal::GetRscString(STR_NO_NAME_REF); - rBuffer.append(pConv->makeExternalNameStr( aFileName, t->GetString())); + rBuffer.append(pConv->makeExternalNameStr( aFileName, t->GetString().getString())); } break; case svExternalSingleRef: pConv->makeExternalRefStr( - rBuffer, *this, t->GetIndex(), t->GetString(), static_cast<ScToken*>(t)->GetSingleRef(), pRefMgr); + rBuffer, *this, t->GetIndex(), t->GetString().getString(), static_cast<ScToken*>(t)->GetSingleRef(), pRefMgr); break; case svExternalDoubleRef: pConv->makeExternalRefStr( - rBuffer, *this, t->GetIndex(), t->GetString(), static_cast<ScToken*>(t)->GetDoubleRef(), pRefMgr); + rBuffer, *this, t->GetIndex(), t->GetString().getString(), static_cast<ScToken*>(t)->GetDoubleRef(), pRefMgr); break; default: // warning, not error, otherwise we may end up with a never diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx index c0876cd16efa..5015a85a36ac 100644 --- a/sc/source/core/tool/formularesult.cxx +++ b/sc/source/core/tool/formularesult.cxx @@ -294,8 +294,8 @@ bool ScFormulaResult::IsMultiline() const { if (meMultiline == MULTILINE_UNKNOWN) { - const OUString& rStr = GetString(); - if (!rStr.isEmpty() && rStr.indexOf( '\n' ) != -1) + svl::SharedString aStr = GetString(); + if (!aStr.isEmpty() && aStr.getString().indexOf('\n') != -1) const_cast<ScFormulaResult*>(this)->meMultiline = MULTILINE_TRUE; else const_cast<ScFormulaResult*>(this)->meMultiline = MULTILINE_FALSE; @@ -336,7 +336,7 @@ bool ScFormulaResult::GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const return true; } -bool ScFormulaResult::GetErrorOrString( sal_uInt16& rErr, OUString& rStr ) const +bool ScFormulaResult::GetErrorOrString( sal_uInt16& rErr, svl::SharedString& rStr ) const { if (mnError) { @@ -440,7 +440,7 @@ double ScFormulaResult::GetDouble() const return mfValue; } -const OUString & ScFormulaResult::GetString() const +svl::SharedString ScFormulaResult::GetString() const { if (mbToken && mpToken) { @@ -462,7 +462,7 @@ const OUString & ScFormulaResult::GetString() const ; // nothing } } - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); } ScConstMatrixRef ScFormulaResult::GetMatrix() const @@ -492,7 +492,7 @@ void ScFormulaResult::SetHybridDouble( double f ) SetDouble(f); else { - OUString aString( GetString()); + svl::SharedString aString = GetString(); OUString aFormula( GetHybridFormula()); mpToken->DecRef(); mpToken = new ScHybridCellToken( f, aString, aFormula); @@ -524,7 +524,7 @@ void ScFormulaResult::SetHybridFormula( const OUString & rFormula ) { // Obtain values before changing anything. double f = GetDouble(); - OUString aStr( GetString()); + svl::SharedString aStr = GetString(); ResetToDefaults(); if (mbToken && mpToken) mpToken->DecRef(); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 4bf9e4a8d430..d1e53df8704e 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -314,7 +314,7 @@ void ScInterpreter::ScIfError( bool bNAonly ) case svExternalDoubleRef: { double fVal; - OUString aStr; + svl::SharedString aStr; // Handles also existing jump matrix case and sets error on // elements. GetDoubleOrStringFromMatrix( fVal, aStr); @@ -592,7 +592,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) break; case svString: { - const OUString& rStr = GetString(); + svl::SharedString aStr = GetString(); if ( nGlobalError ) { pResMat->PutDouble( CreateDoubleError( nGlobalError), @@ -600,7 +600,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) nGlobalError = 0; } else - pResMat->PutString(mrStrPool.intern(rStr), nC, nR); + pResMat->PutString(aStr, nC, nR); } break; case svSingleRef: @@ -632,7 +632,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) } else { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); if ( nGlobalError ) { @@ -641,7 +641,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) nGlobalError = 0; } else - pResMat->PutString(mrStrPool.intern(aStr), nC, nR); + pResMat->PutString(aStr, nC, nR); } } } @@ -699,8 +699,8 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) pResMat->PutDouble( fCellVal, nC, nR ); } else - { - OUString aStr; + { + svl::SharedString aStr; GetCellString(aStr, aCell); if ( nGlobalError ) { @@ -709,7 +709,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) nGlobalError = 0; } else - pResMat->PutString(mrStrPool.intern(aStr), nC, nR); + pResMat->PutString(aStr, nC, nR); } } SCSIZE nParmCols = aRange.aEnd.Col() - aRange.aStart.Col() + 1; @@ -1011,7 +1011,7 @@ double ScInterpreter::Compare() aComp.bVal[ i ] = true; break; case svString: - *aComp.pVal[ i ] = GetString(); + *aComp.pVal[ i ] = GetString().getString(); aComp.bVal[ i ] = false; break; case svDoubleRef : @@ -1026,9 +1026,9 @@ double ScInterpreter::Compare() aComp.bEmpty[i] = true; else if (aCell.hasString()) { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); - *aComp.pVal[i] = aStr; + *aComp.pVal[i] = aStr.getString(); aComp.bVal[i] = false; } else @@ -1102,7 +1102,7 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScCompareOptions* pOptions ) aComp.bVal[ i ] = true; break; case svString: - *aComp.pVal[ i ] = GetString(); + *aComp.pVal[ i ] = GetString().getString(); aComp.bVal[ i ] = false; break; case svSingleRef: @@ -1114,9 +1114,9 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScCompareOptions* pOptions ) aComp.bEmpty[i] = true; else if (aCell.hasString()) { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); - *aComp.pVal[i] = aStr; + *aComp.pVal[i] = aStr.getString(); aComp.bVal[i] = false; } else @@ -2401,7 +2401,7 @@ void ScInterpreter::ScCell() } bError = !PopDoubleRefOrSingleRef( aCellPos ); } - OUString aInfoType( GetString() ); + OUString aInfoType = GetString().getString(); if( bError || nGlobalError ) PushIllegalParameter(); else @@ -2477,7 +2477,7 @@ void ScInterpreter::ScCell() { // contents of the cell, no formatting if (aCell.hasString()) { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); PushString( aStr ); } @@ -2574,7 +2574,7 @@ void ScInterpreter::ScCellExternal() return; } - OUString aInfoType = GetString(); + OUString aInfoType = GetString().getString(); if (nGlobalError) { PushIllegalParameter(); @@ -3135,7 +3135,7 @@ void ScInterpreter::ScN() void ScInterpreter::ScTrim() { // Doesn't only trim but also removes duplicated blanks within! - OUString aVal = comphelper::string::strip(GetString(), ' '); + OUString aVal = comphelper::string::strip(GetString().getString(), ' '); OUStringBuffer aStr; const sal_Unicode* p = aVal.getStr(); const sal_Unicode* const pEnd = p + aVal.getLength(); @@ -3151,7 +3151,7 @@ void ScInterpreter::ScTrim() void ScInterpreter::ScUpper() { - OUString aString = ScGlobal::pCharClass->uppercase(GetString()); + OUString aString = ScGlobal::pCharClass->uppercase(GetString().getString()); PushString(aString); } @@ -3159,7 +3159,7 @@ void ScInterpreter::ScUpper() void ScInterpreter::ScPropper() { //2do: what to do with I18N-CJK ?!? - OUStringBuffer aStr(GetString()); + OUStringBuffer aStr(GetString().getString()); const sal_Int32 nLen = aStr.getLength(); if ( nLen > 0 ) { @@ -3183,15 +3183,14 @@ void ScInterpreter::ScPropper() void ScInterpreter::ScLower() { - OUString aString = ScGlobal::pCharClass->lowercase(GetString()); + OUString aString = ScGlobal::pCharClass->lowercase(GetString().getString()); PushString(aString); } void ScInterpreter::ScLen() { - const OUString& aStr = GetString(); - PushDouble( aStr.getLength() ); + PushDouble(GetString().getLength()); } @@ -3230,8 +3229,9 @@ void ScInterpreter::ScT() else { // like GetString() - GetCellString(aTempStr, aCell); - PushString( aTempStr ); + svl::SharedString aStr; + GetCellString(aStr, aCell); + PushString(aStr); } } break; @@ -3240,10 +3240,10 @@ void ScInterpreter::ScT() case svExternalDoubleRef: { double fVal; - OUString aStr; + svl::SharedString aStr; ScMatValType nMatValType = GetDoubleOrStringFromMatrix( fVal, aStr); if (ScMatrix::IsValueType( nMatValType)) - PushString( EMPTY_STRING); + PushString(svl::SharedString::getEmptyString()); else PushString( aStr); } @@ -3291,7 +3291,11 @@ void ScInterpreter::ScValue() ScRefCellValue aCell; aCell.assign(*pDok, aAdr); if (aCell.hasString()) - GetCellString(aInputString, aCell); + { + svl::SharedString aSS; + GetCellString(aSS, aCell); + aInputString = aSS.getString(); + } else if (aCell.hasNumeric()) { PushDouble( GetCellValue(aAdr, aCell) ); @@ -3306,8 +3310,10 @@ void ScInterpreter::ScValue() break; case svMatrix: { + svl::SharedString aSS; ScMatValType nType = GetDoubleOrStringFromMatrix( fVal, - aInputString); + aSS); + aInputString = aSS.getString(); switch (nType) { case SC_MATVAL_EMPTY: @@ -3327,7 +3333,7 @@ void ScInterpreter::ScValue() } break; default: - aInputString = GetString(); + aInputString = GetString().getString(); break; } @@ -3352,11 +3358,11 @@ void ScInterpreter::ScNumberValue() sal_Unicode cDecimalSeparator = 0; if ( nParamCount == 3 ) - aGroupSeparator = GetString(); + aGroupSeparator = GetString().getString(); if ( nParamCount >= 2 ) { - aDecimalSeparator = GetString(); + aDecimalSeparator = GetString().getString(); if ( aDecimalSeparator.getLength() == 1 ) cDecimalSeparator = aDecimalSeparator[ 0 ]; else @@ -3377,7 +3383,7 @@ void ScInterpreter::ScNumberValue() case svDouble: return; // leave on stack default: - aInputString = GetString(); + aInputString = GetString().getString(); } if ( nGlobalError ) { @@ -3444,7 +3450,7 @@ static inline bool lcl_ScInterpreter_IsPrintable( sal_Unicode c ) void ScInterpreter::ScClean() { - OUString aStr( GetString() ); + OUString aStr = GetString().getString(); for ( xub_StrLen i = 0; i < aStr.getLength(); i++ ) { if ( !lcl_ScInterpreter_IsPrintable( aStr[i] ) ) @@ -3457,7 +3463,7 @@ void ScInterpreter::ScClean() void ScInterpreter::ScCode() { //2do: make it full range unicode? - OUString aStr = GetString(); + OUString aStr = GetString().getString(); //"classic" ByteString conversion flags const sal_uInt32 convertFlags = RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE | @@ -3538,7 +3544,7 @@ static OUString lcl_convertIntoFullWidth( const OUString & rStr ) void ScInterpreter::ScJis() { if (MustHaveParamCount( GetByte(), 1)) - PushString( lcl_convertIntoFullWidth( GetString())); + PushString( lcl_convertIntoFullWidth( GetString().getString())); } @@ -3551,20 +3557,20 @@ void ScInterpreter::ScJis() void ScInterpreter::ScAsc() { if (MustHaveParamCount( GetByte(), 1)) - PushString( lcl_convertIntoHalfWidth( GetString())); + PushString( lcl_convertIntoHalfWidth( GetString().getString())); } void ScInterpreter::ScUnicode() { if ( MustHaveParamCount( GetByte(), 1 ) ) { - const OUString& rStr = GetString(); - if (rStr.isEmpty()) + OUString aStr = GetString().getString(); + if (aStr.isEmpty()) PushIllegalParameter(); else { sal_Int32 i = 0; - PushDouble( rStr.iterateCodePoints(&i) ); + PushDouble(aStr.iterateCodePoints(&i)); } } } @@ -4299,8 +4305,8 @@ void ScInterpreter::ScTable() { case svString : { - OUString aStr( PopString() ); - if ( pDok->GetTable( aStr, nVal ) ) + svl::SharedString aStr = PopString(); + if ( pDok->GetTable(aStr.getString(), nVal)) ++nVal; else SetError( errIllegalArgument ); @@ -4541,9 +4547,7 @@ void ScInterpreter::ScMatch() if (nGlobalError == 0) { - svl::SharedStringPool& rPool = pDok->GetSharedStringPool(); double fVal; - OUString sStr; ScQueryParam rParam; rParam.nCol1 = nCol1; rParam.nRow1 = nRow1; @@ -4568,9 +4572,8 @@ void ScInterpreter::ScMatch() break; case svString: { - sStr = GetString(); rItem.meType = ScQueryEntry::ByString; - rItem.maString = rPool.intern(sStr); + rItem.maString = GetString(); } break; case svDoubleRef : @@ -4592,9 +4595,8 @@ void ScInterpreter::ScMatch() } else { - GetCellString(sStr, aCell); + GetCellString(rItem.maString, aCell); rItem.meType = ScQueryEntry::ByString; - rItem.maString = rPool.intern(sStr); } } break; @@ -4615,7 +4617,7 @@ void ScInterpreter::ScMatch() else { rItem.meType = ScQueryEntry::ByString; - rItem.maString = rPool.intern(pToken->GetString()); + rItem.maString = pToken->GetString(); } } break; @@ -4626,10 +4628,10 @@ void ScInterpreter::ScMatch() break; case svMatrix : { - OUString aStr; + svl::SharedString aStr; ScMatValType nType = GetDoubleOrStringFromMatrix( rItem.mfVal, aStr); - rItem.maString = rPool.intern(aStr); + rItem.maString = aStr; rItem.meType = ScMatrix::IsNonValueType(nType) ? ScQueryEntry::ByString : ScQueryEntry::ByValue; } @@ -4899,7 +4901,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) if (pToken->GetType() == svDouble) pSumExtraMatrix->PutDouble(pToken->GetDouble(), 0, 0); else - pSumExtraMatrix->PutString(mrStrPool.intern(pToken->GetString()), 0, 0); + pSumExtraMatrix->PutString(pToken->GetString(), 0, 0); } break; case svExternalDoubleRef: @@ -4911,7 +4913,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) } } - OUString aString; + svl::SharedString aString; double fVal = 0.0; bool bIsString = true; switch ( GetStackType() ) @@ -5112,7 +5114,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) } else { - rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString, 0); + rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString.getString(), 0); sal_uInt32 nIndex = 0; bool bNumber = pFormatter->IsNumberFormat( rItem.maString.getString(), nIndex, rItem.mfVal); @@ -5274,7 +5276,7 @@ void ScInterpreter::ScCountIf() { if ( MustHaveParamCount( GetByte(), 2 ) ) { - OUString aString; + svl::SharedString aString; double fVal = 0.0; bool bIsString = true; switch ( GetStackType() ) @@ -5319,8 +5321,7 @@ void ScInterpreter::ScCountIf() case svExternalSingleRef: case svExternalDoubleRef: { - ScMatValType nType = GetDoubleOrStringFromMatrix( fVal, - aString); + ScMatValType nType = GetDoubleOrStringFromMatrix(fVal, aString); bIsString = ScMatrix::IsNonValueType( nType); } break; @@ -5412,7 +5413,7 @@ void ScInterpreter::ScCountIf() } else { - rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString, 0); + rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString.getString(), 0); sal_uInt32 nIndex = 0; bool bNumber = pFormatter->IsNumberFormat( rItem.maString.getString(), nIndex, rItem.mfVal); @@ -5497,7 +5498,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) while (nParamCount > 1 && !nGlobalError) { // take criteria - OUString aString; + svl::SharedString aString; fVal = 0.0; bool bIsString = true; switch ( GetStackType() ) @@ -5664,7 +5665,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) } else { - rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString, 0); + rParam.FillInExcelSyntax(pDok->GetSharedStringPool(), aString.getString(), 0); sal_uInt32 nIndex = 0; bool bNumber = pFormatter->IsNumberFormat( rItem.maString.getString(), nIndex, rItem.mfVal); @@ -5902,7 +5903,7 @@ void ScInterpreter::ScLookup() // The third parameter, result array, for double, string and single reference. double fResVal = 0.0; - OUString aResStr; + svl::SharedString aResStr; ScAddress aResAdr; StackVar eResArrayType = svUnknown; @@ -5962,7 +5963,7 @@ void ScInterpreter::ScLookup() // For double, string and single reference. double fDataVal = 0.0; - OUString aDataStr; + svl::SharedString aDataStr; ScAddress aDataAdr; bool bValueData = false; @@ -6074,7 +6075,7 @@ void ScInterpreter::ScLookup() if (rItem.meType != ScQueryEntry::ByString) bFound = false; else - bFound = (ScGlobal::GetCollator()->compareString(aDataStr, rItem.maString.getString()) <= 0); + bFound = (ScGlobal::GetCollator()->compareString(aDataStr.getString(), rItem.maString.getString()) <= 0); } if (!bFound) @@ -6088,7 +6089,7 @@ void ScInterpreter::ScLookup() if (pResMat->IsValue( 0, 0 )) PushDouble(pResMat->GetDouble( 0, 0 )); else - PushString(pResMat->GetString(0, 0).getString()); + PushString(pResMat->GetString(0, 0)); } else if (nParamCount == 3) { @@ -6293,14 +6294,14 @@ void ScInterpreter::ScLookup() if (pDataMat->IsValue(nC-1, nDelta)) PushDouble(pDataMat->GetDouble(nC-1, nDelta)); else - PushString(pDataMat->GetString(nC-1, nDelta).getString()); + PushString(pDataMat->GetString(nC-1, nDelta)); } else { if (pDataMat->IsValue(nDelta, nR-1)) PushDouble(pDataMat->GetDouble(nDelta, nR-1)); else - PushString(pDataMat->GetString(nDelta, nR-1).getString()); + PushString(pDataMat->GetString(nDelta, nR-1)); } } @@ -6705,7 +6706,6 @@ void ScInterpreter::CalculateLookup(bool bHLookup) bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) { ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); - svl::SharedStringPool& rPool = pDok->GetSharedStringPool(); switch ( GetStackType() ) { case svDouble: @@ -6716,9 +6716,8 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) break; case svString: { - const OUString& sStr = GetString(); rItem.meType = ScQueryEntry::ByString; - rItem.maString = rPool.intern(sStr); + rItem.maString = GetString(); } break; case svDoubleRef : @@ -6739,18 +6738,16 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) } else { - OUString aStr; - GetCellString(aStr, aCell); + GetCellString(rItem.maString, aCell); rItem.meType = ScQueryEntry::ByString; - rItem.maString = rPool.intern(aStr); } } break; case svMatrix : { - OUString aStr; + svl::SharedString aStr; const ScMatValType nType = GetDoubleOrStringFromMatrix(rItem.mfVal, aStr); - rItem.maString = rPool.intern(aStr); + rItem.maString = aStr; rItem.meType = ScMatrix::IsNonValueType(nType) ? ScQueryEntry::ByString : ScQueryEntry::ByValue; } @@ -6836,7 +6833,7 @@ ScDBQueryParamBase* ScInterpreter::GetDBParams( bool& rMissingField ) bool bByVal = true; double nVal = 0.0; - OUString aStr; + svl::SharedString aStr; ScRange aMissingRange; bool bRangeFake = false; switch (GetStackType()) @@ -6919,7 +6916,7 @@ ScDBQueryParamBase* ScInterpreter::GetDBParams( bool& rMissingField ) else { sal_uInt16 nErr = 0; - nField = pDBRef->findFieldColumn(aStr, &nErr); + nField = pDBRef->findFieldColumn(aStr.getString(), &nErr); SetError(nErr); } @@ -7248,7 +7245,7 @@ void ScInterpreter::ScIndirect() } const ScAddress::Details aDetails( eConv, aPos ); SCTAB nTab = aPos.Tab(); - OUString sRefStr( GetString() ); + OUString sRefStr = GetString().getString(); ScRefAddress aRefAd, aRefAd2; ScAddress::ExternalInfo aExtInfo; if (ConvertDoubleRef(pDok, sRefStr, nTab, aRefAd, aRefAd2, aDetails, &aExtInfo)) @@ -7320,7 +7317,7 @@ void ScInterpreter::ScAddressFunc() return; if( nParamCount >= 5 ) - sTabStr = GetString(); + sTabStr = GetString().getString(); FormulaGrammar::AddressConvention eConv = FormulaGrammar::CONV_OOO; // default if( nParamCount >= 4 && 0.0 == ::rtl::math::approxFloor( GetDoubleWithDefault( 1.0))) @@ -7870,10 +7867,10 @@ void ScInterpreter::ScReplace() { if ( MustHaveParamCount( GetByte(), 4 ) ) { - OUString aNewStr( GetString() ); + OUString aNewStr = GetString().getString(); double fCount = ::rtl::math::approxFloor( GetDouble()); double fPos = ::rtl::math::approxFloor( GetDouble()); - OUString aOldStr( GetString() ); + OUString aOldStr = GetString().getString(); if (fPos < 1.0 || fPos > static_cast<double>(STRING_MAXLEN) || fCount < 0.0 || fCount > static_cast<double>(STRING_MAXLEN)) PushIllegalArgument(); @@ -7963,12 +7960,12 @@ void ScInterpreter::ScFind() fAnz = GetDouble(); else fAnz = 1.0; - OUString sStr = GetString(); + OUString sStr = GetString().getString(); if( fAnz < 1.0 || fAnz > (double) sStr.getLength() ) PushNoValue(); else { - sal_Int32 nPos = sStr.indexOf( GetString(), (xub_StrLen) fAnz - 1 ); + sal_Int32 nPos = sStr.indexOf(GetString().getString(), static_cast<sal_Int32>(fAnz - 1)); if (nPos == -1) PushNoValue(); else @@ -7983,9 +7980,9 @@ void ScInterpreter::ScExact() nFuncFmtType = NUMBERFORMAT_LOGICAL; if ( MustHaveParamCount( GetByte(), 2 ) ) { - OUString s1( GetString() ); - OUString s2( GetString() ); - PushInt( s1 == s2 ); + svl::SharedString s1 = GetString(); + svl::SharedString s2 = GetString(); + PushInt( s1.getData() == s2.getData() ); } } @@ -8009,7 +8006,7 @@ void ScInterpreter::ScLeft() } else n = 1; - OUString aStr( GetString() ); + OUString aStr = GetString().getString(); aStr = aStr.copy( 0, n ); PushString( aStr ); } @@ -8067,7 +8064,7 @@ sal_Int32 getLengthB(const OUString &str) } void ScInterpreter::ScLenB() { - PushDouble( getLengthB(GetString()) ); + PushDouble( getLengthB(GetString().getString()) ); } OUString lcl_RightB(const OUString &rStr, sal_Int32 n) { @@ -8116,7 +8113,7 @@ void ScInterpreter::ScRightB() } else n = 1; - OUString aStr(lcl_RightB(GetString(), n)); + OUString aStr(lcl_RightB(GetString().getString(), n)); PushString( aStr ); } } @@ -8167,7 +8164,7 @@ void ScInterpreter::ScLeftB() } else n = 1; - OUString aStr(lcl_LeftB(GetString(), n)); + OUString aStr(lcl_LeftB(GetString().getString(), n)); PushString( aStr ); } } @@ -8177,7 +8174,7 @@ void ScInterpreter::ScMidB() { double fAnz = ::rtl::math::approxFloor(GetDouble()); double fAnfang = ::rtl::math::approxFloor(GetDouble()); - OUString aStr( GetString() ); + OUString aStr = GetString().getString(); if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(STRING_MAXLEN) || fAnz > double(STRING_MAXLEN)) PushIllegalArgument(); else @@ -8210,7 +8207,7 @@ void ScInterpreter::ScRight() } else n = 1; - OUString aStr( GetString() ); + OUString aStr = GetString().getString(); if( n < aStr.getLength() ) aStr = aStr.copy( aStr.getLength() - n ); PushString( aStr ); @@ -8235,8 +8232,8 @@ void ScInterpreter::ScSearch() } else fAnz = 1.0; - OUString sStr = GetString(); - OUString SearchStr = GetString(); + OUString sStr = GetString().getString(); + OUString SearchStr = GetString().getString(); sal_Int32 nPos = fAnz - 1; sal_Int32 nEndPos = sStr.getLength(); if( nPos >= nEndPos ) @@ -8264,11 +8261,11 @@ void ScInterpreter::ScMid() { double fAnz = ::rtl::math::approxFloor(GetDouble()); double fAnfang = ::rtl::math::approxFloor(GetDouble()); - OUString aStr = GetString(); + OUString aStr = GetString().getString(); if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(STRING_MAXLEN) || fAnz > double(STRING_MAXLEN)) PushIllegalArgument(); else - PushString(aStr.copy( (xub_StrLen) fAnfang - 1, (xub_StrLen) fAnz )); + PushString(aStr.copy(static_cast<sal_Int32>(fAnfang-1), static_cast<sal_Int32>(fAnz))); } } @@ -8277,8 +8274,8 @@ void ScInterpreter::ScText() { if ( MustHaveParamCount( GetByte(), 2 ) ) { - const OUString& sFormatString = GetString(); - OUString aStr; + OUString sFormatString = GetString().getString(); + svl::SharedString aStr; bool bString = false; double fVal = 0.0; switch (GetStackType()) @@ -8328,7 +8325,7 @@ void ScInterpreter::ScText() eCellLang = ScGlobal::eLnge; if (bString) { - if (!pFormatter->GetPreviewString( sFormatString, aStr, + if (!pFormatter->GetPreviewString( sFormatString, aStr.getString(), aResult, &pColor, eCellLang)) PushIllegalArgument(); else @@ -8366,9 +8363,9 @@ void ScInterpreter::ScSubstitute() } else nAnz = 0; - OUString sNewStr = GetString(); - OUString sOldStr = GetString(); - OUString sStr = GetString(); + OUString sNewStr = GetString().getString(); + OUString sOldStr = GetString().getString(); + OUString sStr = GetString().getString(); sal_Int32 nPos = 0; xub_StrLen nCount = 0; xub_StrLen nNewLen = sNewStr.getLength(); @@ -8406,7 +8403,7 @@ void ScInterpreter::ScRept() if ( MustHaveParamCount( GetByte(), 2 ) ) { double fAnz = ::rtl::math::approxFloor(GetDouble()); - OUString aStr( GetString() ); + OUString aStr = GetString().getString(); if ( fAnz < 0.0 ) PushIllegalArgument(); else if ( fAnz * aStr.getLength() > STRING_MAXLEN ) @@ -8434,8 +8431,8 @@ void ScInterpreter::ScConcat() OUString aRes; while( nParamCount-- > 0) { - const OUString& rStr = GetString(); - aRes = rStr + aRes; + OUString aStr = GetString().getString(); + aRes = aStr + aRes; } PushString( aRes ); } diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 3797c42ddcbe..3d13382aecd8 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -163,7 +163,7 @@ void ScInterpreter::ScGetHour() void ScInterpreter::ScGetDateValue() { - const OUString& aInputString = GetString(); + OUString aInputString = GetString().getString(); sal_uInt32 nFIndex = 0; // damit default Land/Spr. double fVal; if (pFormatter->IsNumberFormat(aInputString, nFIndex, fVal)) @@ -389,7 +389,7 @@ void ScInterpreter::ScGetDateDif() { if ( MustHaveParamCount( GetByte(), 3 ) ) { - const OUString& aInterval = GetString(); + OUString aInterval = GetString().getString(); double nDate2 = GetDouble(); double nDate1 = GetDouble(); @@ -532,7 +532,7 @@ void ScInterpreter::ScGetDateDif() void ScInterpreter::ScGetTimeValue() { - OUString aInputString = GetString(); + OUString aInputString = GetString().getString(); sal_uInt32 nFIndex = 0; // damit default Land/Spr. double fVal; if (pFormatter->IsNumberFormat(aInputString, nFIndex, fVal)) @@ -1941,11 +1941,11 @@ void ScInterpreter::ScStyle() { OUString aStyle2; // Vorlage nach Timer if (nParamCount >= 3) - aStyle2 = GetString(); + aStyle2 = GetString().getString(); long nTimeOut = 0; // Timeout if (nParamCount >= 2) nTimeOut = (long)(GetDouble()*1000.0); - OUString aStyle1 = GetString(); // Vorlage fuer sofort + OUString aStyle1 = GetString().getString(); // Vorlage fuer sofort if (nTimeOut < 0) nTimeOut = 0; @@ -2005,9 +2005,9 @@ void ScInterpreter::ScDde() sal_uInt8 nMode = SC_DDE_DEFAULT; if (nParamCount == 4) nMode = (sal_uInt8) ::rtl::math::approxFloor(GetDouble()); - OUString aItem = GetString(); - OUString aTopic = GetString(); - OUString aAppl = GetString(); + OUString aItem = GetString().getString(); + OUString aTopic = GetString().getString(); + OUString aAppl = GetString().getString(); if (nMode > SC_DDE_TEXT) nMode = SC_DDE_DEFAULT; @@ -2226,7 +2226,7 @@ void ScInterpreter::ScDecimal() if ( MustHaveParamCount( GetByte(), 2 ) ) { double fBase = ::rtl::math::approxFloor( GetDouble() ); - OUString aStr( GetString() ); + OUString aStr = GetString().getString(); if ( !nGlobalError && 2 <= fBase && fBase <= 36 ) { double fVal = 0.0; @@ -2281,8 +2281,8 @@ void ScInterpreter::ScConvert() { // Value, FromUnit, ToUnit if ( MustHaveParamCount( GetByte(), 3 ) ) { - OUString aToUnit( GetString() ); - OUString aFromUnit( GetString() ); + OUString aToUnit = GetString().getString(); + OUString aFromUnit = GetString().getString(); double fVal = GetDouble(); if ( nGlobalError ) PushError( nGlobalError); @@ -2388,7 +2388,7 @@ static bool lcl_GetArabicValue( sal_Unicode cChar, sal_uInt16& rnValue, bool& rb void ScInterpreter::ScArabic() { - OUString aRoman( GetString() ); + OUString aRoman = GetString().getString(); if( nGlobalError ) PushError( nGlobalError); else @@ -2449,7 +2449,7 @@ void ScInterpreter::ScHyperLink() if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { double fVal = 0.0; - OUString aStr; + svl::SharedString aStr; ScMatValType nResultType = SC_MATVAL_STRING; if ( nParamCount == 2 ) @@ -2504,7 +2504,7 @@ void ScInterpreter::ScHyperLink() SetError( errIllegalArgument); } } - OUString aUrl = GetString(); + svl::SharedString aUrl = GetString(); ScMatrixRef pResMat = GetNewMat( 1, 2); if (nGlobalError) { @@ -2516,13 +2516,13 @@ void ScInterpreter::ScHyperLink() if (ScMatrix::IsValueType( nResultType)) pResMat->PutDouble( fVal, 0); else if (ScMatrix::IsRealStringType( nResultType)) - pResMat->PutString(mrStrPool.intern(aStr), 0); + pResMat->PutString(aStr, 0); else // EmptyType, EmptyPathType, mimic xcl pResMat->PutDouble( 0.0, 0 ); } else - pResMat->PutString(mrStrPool.intern(aUrl), 0); - pResMat->PutString(mrStrPool.intern(aUrl), 1); + pResMat->PutString(aUrl, 0); + pResMat->PutString(aUrl, 1); bMatrixFormula = true; PushMatrix(pResMat); } @@ -2585,8 +2585,8 @@ void ScInterpreter::ScEuroConvert() bool bFullPrecision = false; if ( nParamCount >= 4 ) bFullPrecision = GetBool(); - OUString aToUnit( GetString() ); - OUString aFromUnit( GetString() ); + OUString aToUnit = GetString().getString(); + OUString aFromUnit = GetString().getString(); double fVal = GetDouble(); if ( nGlobalError ) PushError( nGlobalError); @@ -2829,7 +2829,7 @@ void ScInterpreter::ScGetPivotData() } std::vector<sheet::DataPilotFieldFilter> aFilters; - OUString aDataFieldName; + svl::SharedString aDataFieldName; ScRange aBlock; if (bOldSyntax) @@ -2864,8 +2864,8 @@ void ScInterpreter::ScGetPivotData() while (i-- > 0) { //! should allow numeric constraint values - aFilters[i].MatchValue = GetString(); - aFilters[i].FieldName = GetString(); + aFilters[i].MatchValue = GetString().getString(); + aFilters[i].FieldName = GetString().getString(); } switch (GetStackType()) @@ -2898,7 +2898,7 @@ void ScInterpreter::ScGetPivotData() return; } - double fVal = pDPObj->GetPivotData(aDataFieldName, aFilters); + double fVal = pDPObj->GetPivotData(aDataFieldName.getString(), aFilters); if (rtl::math::isNan(fVal)) { PushError(errNoRef); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 443590797682..4e836026a4c2 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -461,8 +461,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& } else { - OUString aStr = pFCell->GetString(); - fValue = ConvertStringToValue( aStr ); + fValue = ConvertStringToValue(pFCell->GetString().getString()); } } else @@ -498,7 +497,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& return fValue; } -void ScInterpreter::GetCellString( OUString& rStr, ScRefCellValue& rCell ) +void ScInterpreter::GetCellString( svl::SharedString& rStr, ScRefCellValue& rCell ) { sal_uInt16 nErr = 0; @@ -506,7 +505,7 @@ void ScInterpreter::GetCellString( OUString& rStr, ScRefCellValue& rCell ) { case CELLTYPE_STRING: case CELLTYPE_EDIT: - rStr = rCell.getString(pDok); + rStr = mrStrPool.intern(rCell.getString(pDok)); break; case CELLTYPE_FORMULA: { @@ -518,7 +517,9 @@ void ScInterpreter::GetCellString( OUString& rStr, ScRefCellValue& rCell ) sal_uLong nIndex = pFormatter->GetStandardFormat( NUMBERFORMAT_NUMBER, ScGlobal::eLnge); - pFormatter->GetInputLineString(fVal, nIndex, rStr); + OUString aStr; + pFormatter->GetInputLineString(fVal, nIndex, aStr); + rStr = mrStrPool.intern(aStr); } else rStr = pFCell->GetString(); @@ -530,11 +531,13 @@ void ScInterpreter::GetCellString( OUString& rStr, ScRefCellValue& rCell ) sal_uLong nIndex = pFormatter->GetStandardFormat( NUMBERFORMAT_NUMBER, ScGlobal::eLnge); - pFormatter->GetInputLineString(fVal, nIndex, rStr); + OUString aStr; + pFormatter->GetInputLineString(fVal, nIndex, aStr); + rStr = mrStrPool.intern(aStr); } break; default: - rStr = ScGlobal::GetEmptyString(); + rStr = svl::SharedString::getEmptyString(); break; } @@ -676,7 +679,7 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, if (!aCell.mpFormula->IsValue()) { nErr = aCell.mpFormula->GetErrCode(); - aStr = aCell.mpFormula->GetString(); + aStr = aCell.mpFormula->GetString().getString(); } else bOk = false; @@ -785,7 +788,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, if (aCell.mpFormula->IsValue()) nVal = aCell.mpFormula->GetValue(); else - aStr = aCell.mpFormula->GetString(); + aStr = aCell.mpFormula->GetString().getString(); break; default : bOk = false; @@ -978,7 +981,7 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, } else if (aCell.hasString()) { - OUString aRes; + svl::SharedString aRes; GetCellString( aRes, aCell); PushString( aRes); if (pRetTypeExpr) @@ -1068,7 +1071,7 @@ double ScInterpreter::PopDouble() } -const OUString& ScInterpreter::PopString() +svl::SharedString ScInterpreter::PopString() { nCurFmtType = NUMBERFORMAT_TEXT; nCurFmtIndex = 0; @@ -1082,18 +1085,18 @@ const OUString& ScInterpreter::PopString() nGlobalError = p->GetError(); break; case svString: - aTempStr = p->GetString(); - return aTempStr; + return p->GetString(); case svEmptyCell: case svMissing: - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); default: SetError( errIllegalArgument); } } else SetError( errUnknownStackVariable); - return EMPTY_OUSTRING; + + return svl::SharedString::getEmptyString(); } @@ -1401,7 +1404,7 @@ void ScInterpreter::PopExternalSingleRef(sal_uInt16& rFileId, OUString& rTabName } rFileId = p->GetIndex(); - rTabName = p->GetString(); + rTabName = p->GetString().getString(); rRef = static_cast<ScToken*>(p)->GetSingleRef(); } @@ -1477,7 +1480,7 @@ void ScInterpreter::PopExternalDoubleRef(sal_uInt16& rFileId, OUString& rTabName } rFileId = p->GetIndex(); - rTabName = p->GetString(); + rTabName = p->GetString().getString(); rRef = static_cast<ScToken*>(p)->GetDoubleRef(); } @@ -1689,10 +1692,10 @@ bool ScInterpreter::ConvertMatrixParameters() if (eType == ScParameterClassification::Array) { sal_uInt16 nFileId = p->GetIndex(); - const OUString& rTabName = p->GetString(); + OUString aTabName = p->GetString().getString(); const ScComplexRefData& rRef = static_cast<ScToken*>(p)->GetDoubleRef(); ScExternalRefCache::TokenArrayRef pArray; - GetExternalDoubleRef(nFileId, rTabName, rRef, pArray); + GetExternalDoubleRef(nFileId, aTabName, rRef, pArray); if (nGlobalError) break; @@ -1896,13 +1899,20 @@ void ScInterpreter::PushInt(int nVal) void ScInterpreter::PushStringBuffer( const sal_Unicode* pString ) { if ( pString ) - PushString( OUString(pString) ); + { + svl::SharedString aSS = pDok->GetSharedStringPool().intern(OUString(pString)); + PushString(aSS); + } else - PushString( EMPTY_STRING ); + PushString(svl::SharedString::getEmptyString()); } +void ScInterpreter::PushString( const OUString& rStr ) +{ + PushString(pDok->GetSharedStringPool().intern(rStr)); +} -void ScInterpreter::PushString( const OUString& rString ) +void ScInterpreter::PushString( const svl::SharedString& rString ) { if (!IfErrorPushError()) PushTempTokenWithoutError( new FormulaStringToken( rString ) ); @@ -2187,7 +2197,7 @@ double ScInterpreter::GetDouble() nVal = PopDouble(); break; case svString: - nVal = ConvertStringToValue( PopString()); + nVal = ConvertStringToValue( PopString().getString()); break; case svSingleRef: { @@ -2267,25 +2277,26 @@ double ScInterpreter::GetDoubleWithDefault(double nDefault) } -const OUString& ScInterpreter::GetString() +svl::SharedString ScInterpreter::GetString() { switch (GetRawStackType()) { case svError: PopError(); - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); case svMissing: case svEmptyCell: Pop(); - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); case svDouble: { double fVal = PopDouble(); sal_uLong nIndex = pFormatter->GetStandardFormat( NUMBERFORMAT_NUMBER, ScGlobal::eLnge); - pFormatter->GetInputLineString(fVal, nIndex, aTempStr); - return aTempStr; + OUString aStr; + pFormatter->GetInputLineString(fVal, nIndex, aStr); + return mrStrPool.intern(aStr); } case svString: return PopString(); @@ -2297,11 +2308,12 @@ const OUString& ScInterpreter::GetString() { ScRefCellValue aCell; aCell.assign(*pDok, aAdr); - GetCellString(aTempStr, aCell); - return aTempStr; + svl::SharedString aSS; + GetCellString(aSS, aCell); + return aSS; } else - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); } case svDoubleRef: { // generate position dependent SingleRef @@ -2312,21 +2324,21 @@ const OUString& ScInterpreter::GetString() { ScRefCellValue aCell; aCell.assign(*pDok, aAdr); - GetCellString(aTempStr, aCell); - return aTempStr; + svl::SharedString aSS; + GetCellString(aSS, aCell); + return aSS; } else - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); } case svExternalSingleRef: { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); if (nGlobalError) - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); - aTempStr = pToken->GetString(); - return aTempStr; + return pToken->GetString(); } case svExternalDoubleRef: { @@ -2344,17 +2356,16 @@ const OUString& ScInterpreter::GetString() PopError(); SetError( errIllegalArgument); } - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); } -const OUString& ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat) +svl::SharedString ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat) { if ( !pMat ) ; // nothing else if ( !pJumpMatrix ) { - aTempStr = pMat->GetString( *pFormatter, 0, 0).getString(); - return aTempStr; + return pMat->GetString( *pFormatter, 0, 0); } else { @@ -2363,21 +2374,20 @@ const OUString& ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat) pJumpMatrix->GetPos( nC, nR); if ( nC < nCols && nR < nRows ) { - aTempStr = pMat->GetString( *pFormatter, nC, nR).getString(); - return aTempStr; + return pMat->GetString( *pFormatter, nC, nR); } else SetError( errNoValue); } - return EMPTY_OUSTRING; + return svl::SharedString::getEmptyString(); } ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( - double& rDouble, OUString& rString ) + double& rDouble, svl::SharedString& rString ) { rDouble = 0.0; - rString = EMPTY_OUSTRING; + rString = svl::SharedString::getEmptyString(); ScMatValType nMatValType = SC_MATVAL_EMPTY; ScMatrixRef pMat; @@ -2517,7 +2527,7 @@ void ScInterpreter::ScExternal() break; case PTR_STRING : { - OString aStr(OUStringToOString(GetString(), + OString aStr(OUStringToOString(GetString().getString(), osl_getThreadTextEncoding())); if ( aStr.getLength() >= ADDIN_MAXSTRLEN ) SetError( errStringOverflow ); @@ -2727,7 +2737,7 @@ void ScInterpreter::ScExternal() break; case SC_ADDINARG_STRING: - aParam <<= GetString(); + aParam <<= GetString().getString(); break; case SC_ADDINARG_INTEGER_ARRAY: @@ -2807,7 +2817,7 @@ void ScInterpreter::ScExternal() case svString: case svSingleRef: { - const OUString& aString = GetString(); + OUString aString = GetString().getString(); uno::Sequence<OUString> aInner( &aString, 1 ); uno::Sequence< uno::Sequence<OUString> > aOuter( &aInner, 1 ); aParam <<= aOuter; @@ -2842,7 +2852,7 @@ void ScInterpreter::ScExternal() if ( nStackType == svDouble ) aElem <<= (double) GetDouble(); else if ( nStackType == svString ) - aElem <<= GetString(); + aElem <<= GetString().getString(); else { ScAddress aAdr; @@ -2852,9 +2862,9 @@ void ScInterpreter::ScExternal() aCell.assign(*pDok, aAdr); if (aCell.hasString()) { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); - aElem <<= aStr; + aElem <<= aStr.getString(); } else aElem <<= GetCellValue(aAdr, aCell); @@ -2892,7 +2902,7 @@ void ScInterpreter::ScExternal() aParam <<= (double) GetDouble(); break; case svString: - aParam <<= GetString(); + aParam <<= GetString().getString(); break; case svSingleRef: { @@ -2903,9 +2913,9 @@ void ScInterpreter::ScExternal() aCell.assign(*pDok, aAdr); if (aCell.hasString()) { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); - aParam <<= aStr; + aParam <<= aStr.getString(); } else aParam <<= GetCellValue(aAdr, aCell); @@ -3179,14 +3189,14 @@ void ScInterpreter::ScMacro() pPar->PutDouble( GetDouble() ); break; case svString: - pPar->PutString( GetString() ); + pPar->PutString( GetString().getString() ); break; case svExternalSingleRef: { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); if ( pToken->GetType() == svString ) - pPar->PutString( pToken->GetString() ); + pPar->PutString( pToken->GetString().getString() ); else if ( pToken->GetType() == svDouble ) pPar->PutDouble( pToken->GetDouble() ); else @@ -3436,7 +3446,7 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos ) pVar->PutDouble(aCell.mpFormula->GetValue()); } else - pVar->PutString(aCell.mpFormula->GetString()); + pVar->PutString(aCell.mpFormula->GetString().getString()); } else SetError( nErr ), bOk = false; @@ -3523,7 +3533,7 @@ void ScInterpreter::ScTableOp() } else { - OUString aCellString; + svl::SharedString aCellString; GetCellString(aCellString, aCell); PushString( aCellString ); } @@ -4437,4 +4447,9 @@ StackVar ScInterpreter::Interpret() return eType; } +svl::SharedString ScInterpreter::GetStringResult() const +{ + return xResult->GetString(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index ee34828157bc..d8b97c03ed5f 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -399,9 +399,9 @@ ScMatrixRef ScInterpreter::GetMatrix() pMat->PutDouble(GetCellValue(aAdr, aCell), 0); else { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); - pMat->PutString(mrStrPool.intern(aStr), 0); + pMat->PutString(aStr, 0); } } } @@ -439,7 +439,7 @@ ScMatrixRef ScInterpreter::GetMatrix() break; case svString : { - OUString aStr = GetString(); + svl::SharedString aStr = GetString(); pMat = GetNewMat( 1, 1); if ( pMat ) { @@ -450,7 +450,7 @@ ScMatrixRef ScInterpreter::GetMatrix() nGlobalError = 0; } else - pMat->PutString(mrStrPool.intern(aStr), 0); + pMat->PutString(aStr, 0); } } break; @@ -472,7 +472,7 @@ ScMatrixRef ScInterpreter::GetMatrix() else if (pToken->GetType() == svString) { pMat = new ScMatrix(1, 1, 0.0); - pMat->PutString(mrStrPool.intern(pToken->GetString()), 0, 0); + pMat->PutString(pToken->GetString(), 0, 0); } else { @@ -556,7 +556,7 @@ void ScInterpreter::ScMatValue() PushDouble(GetCellValue(aAdr, aCell)); else { - OUString aStr; + svl::SharedString aStr; GetCellString(aStr, aCell); PushString(aStr); } @@ -1265,11 +1265,11 @@ void ScInterpreter::ScAmpersand() if ( GetStackType() == svMatrix ) pMat2 = GetMatrix(); else - sStr2 = GetString(); + sStr2 = GetString().getString(); if ( GetStackType() == svMatrix ) pMat1 = GetMatrix(); else - sStr1 = GetString(); + sStr1 = GetString().getString(); if (pMat1 && pMat2) { ScMatrixRef pResMat = MatConcat(pMat1, pMat2); @@ -3173,7 +3173,7 @@ void ScInterpreter::ScMatRef() PushDouble(aCell.mpFormula->GetValue()); else { - OUString aVal = aCell.mpFormula->GetString(); + svl::SharedString aVal = aCell.mpFormula->GetString(); PushString( aVal ); } pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr); @@ -3186,7 +3186,7 @@ void ScInterpreter::ScInfo() { if( MustHaveParamCount( GetByte(), 1 ) ) { - OUString aStr = GetString(); + OUString aStr = GetString().getString(); ScCellKeywordTranslator::transKeyword(aStr, ScGlobal::GetLocale(), ocInfo); if( aStr.equalsAscii( "SYSTEM" ) ) PushString( OUString( SC_INFO_OSVERSION ) ); diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 35bb95e4e580..c8b417a8788f 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -398,7 +398,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { if( eFunc == ifCOUNT ) { - OUString aStr( PopString() ); + OUString aStr = PopString().getString(); sal_uInt32 nFIndex = 0; // damit default Land/Spr. if ( bTextAsZero || pFormatter->IsNumberFormat(aStr, nFIndex, fVal)) nCount++; @@ -884,7 +884,7 @@ void ScInterpreter::ScCount() { case svString: { - OUString aStr( PopString() ); + OUString aStr = PopString().getString(); sal_uInt32 nFIndex = 0; // damit default Land/Spr. if (pFormatter->IsNumberFormat(aStr, nFIndex, fVal)) nCount++; diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx index dd52e38c2036..d714057bf10b 100644 --- a/sc/source/core/tool/interpr7.cxx +++ b/sc/source/core/tool/interpr7.cxx @@ -28,8 +28,8 @@ void ScInterpreter::ScFilterXML() sal_uInt8 nParamCount = GetByte(); if (MustHaveParamCount( nParamCount, 2 ) ) { - OUString aXPathExpression = GetString(); - OUString aString = GetString(); + OUString aXPathExpression = GetString().getString(); + OUString aString = GetString().getString(); if(aString.isEmpty() || aXPathExpression.isEmpty()) { PushError( errNoValue ); @@ -152,7 +152,7 @@ void ScInterpreter::ScWebservice() sal_uInt8 nParamCount = GetByte(); if (MustHaveParamCount( nParamCount, 1 ) ) { - OUString aURI = GetString(); + OUString aURI = GetString().getString(); if(aURI.isEmpty()) { diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx index 3925a18f7d96..a02f02be118c 100644 --- a/sc/source/core/tool/reftokenhelper.cxx +++ b/sc/source/core/tool/reftokenhelper.cxx @@ -320,7 +320,7 @@ private: // Get the information of the new token. bool bExternal = ScRefTokenHelper::isExternalRef(pToken); sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0; - OUString aTabName = bExternal ? pToken->GetString() : OUString(); + OUString aTabName = bExternal ? pToken->GetString().getString() : OUString(); bool bJoined = false; vector<ScTokenRef>::iterator itr = rTokens.begin(), itrEnd = rTokens.end(); @@ -343,7 +343,7 @@ private: // Different external files. continue; - if (aTabName != pOldToken->GetString()) + if (aTabName != pOldToken->GetString().getString()) // Different table names. continue; } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index e519455b139b..c5a7f8e619ce 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -855,7 +855,7 @@ FormulaToken* ScMatrixRangeToken::Clone() const // ============================================================================ -ScExternalSingleRefToken::ScExternalSingleRefToken( sal_uInt16 nFileId, const OUString& rTabName, const ScSingleRefData& r ) : +ScExternalSingleRefToken::ScExternalSingleRefToken( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScSingleRefData& r ) : ScToken( svExternalSingleRef, ocPush), mnFileId(nFileId), maTabName(rTabName), @@ -880,7 +880,7 @@ sal_uInt16 ScExternalSingleRefToken::GetIndex() const return mnFileId; } -const OUString& ScExternalSingleRefToken::GetString() const +svl::SharedString ScExternalSingleRefToken::GetString() const { return maTabName; } @@ -911,7 +911,7 @@ bool ScExternalSingleRefToken::operator ==( const FormulaToken& r ) const // ============================================================================ -ScExternalDoubleRefToken::ScExternalDoubleRefToken( sal_uInt16 nFileId, const OUString& rTabName, const ScComplexRefData& r ) : +ScExternalDoubleRefToken::ScExternalDoubleRefToken( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScComplexRefData& r ) : ScToken( svExternalDoubleRef, ocPush), mnFileId(nFileId), maTabName(rTabName), @@ -936,7 +936,7 @@ sal_uInt16 ScExternalDoubleRefToken::GetIndex() const return mnFileId; } -const OUString& ScExternalDoubleRefToken::GetString() const +svl::SharedString ScExternalDoubleRefToken::GetString() const { return maTabName; } @@ -987,7 +987,7 @@ bool ScExternalDoubleRefToken::operator ==( const FormulaToken& r ) const // ============================================================================ -ScExternalNameToken::ScExternalNameToken( sal_uInt16 nFileId, const OUString& rName ) : +ScExternalNameToken::ScExternalNameToken( sal_uInt16 nFileId, const svl::SharedString& rName ) : ScToken( svExternalName, ocPush), mnFileId(nFileId), maName(rName) @@ -1008,7 +1008,7 @@ sal_uInt16 ScExternalNameToken::GetIndex() const return mnFileId; } -const OUString& ScExternalNameToken::GetString() const +svl::SharedString ScExternalNameToken::GetString() const { return maName; } @@ -1021,8 +1021,7 @@ bool ScExternalNameToken::operator==( const FormulaToken& r ) const if (mnFileId != r.GetIndex()) return false; - const OUString& rName = r.GetString(); - return maName == rName; + return maName.getData() == r.GetString().getData(); } // ============================================================================ @@ -1038,11 +1037,12 @@ ScJumpMatrixToken::~ScJumpMatrixToken() } double ScEmptyCellToken::GetDouble() const { return 0.0; } -const OUString & ScEmptyCellToken::GetString() const + +svl::SharedString ScEmptyCellToken::GetString() const { - static OUString aDummyString; - return aDummyString; + return svl::SharedString::getEmptyString(); } + bool ScEmptyCellToken::operator==( const FormulaToken& r ) const { return FormulaToken::operator==( r ) && @@ -1057,7 +1057,12 @@ ScMatrixCellResultToken::ScMatrixCellResultToken( const ScMatrixCellResultToken& ScToken(r), xMatrix(r.xMatrix), xUpperLeft(r.xUpperLeft) {} double ScMatrixCellResultToken::GetDouble() const { return xUpperLeft->GetDouble(); } -const OUString & ScMatrixCellResultToken::GetString() const { return xUpperLeft->GetString(); } + +svl::SharedString ScMatrixCellResultToken::GetString() const +{ + return xUpperLeft->GetString(); +} + const ScMatrix* ScMatrixCellResultToken::GetMatrix() const { return xMatrix.get(); } // Non-const GetMatrix() is private and unused but must be implemented to // satisfy vtable linkage. @@ -1164,7 +1169,12 @@ void ScMatrixFormulaCellToken::ResetResult() double ScHybridCellToken::GetDouble() const { return mfDouble; } -const OUString& ScHybridCellToken::GetString() const { return maString; } + +svl::SharedString ScHybridCellToken::GetString() const +{ + return maString; +} + bool ScHybridCellToken::operator==( const FormulaToken& r ) const { return FormulaToken::operator==( r ) && @@ -1469,8 +1479,8 @@ void ScTokenArray::GenHash() case svString: { // Constant string. - const OUString& rStr = p->GetString(); - nHash += aHasher(rStr); + OUString aStr = p->GetString().getString(); + nHash += aHasher(aStr); } break; case svSingleRef: diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx index 44a89bcdff12..fce42c27fc05 100644 --- a/sc/source/filter/dif/difexp.cxx +++ b/sc/source/filter/dif/difexp.cxx @@ -207,7 +207,7 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc } else { - aString = aCell.mpFormula->GetString(); + aString = aCell.mpFormula->GetString().getString(); bWriteStringData = true; } diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx index 2599c9e0aaed..e25e0d2cfc45 100644 --- a/sc/source/filter/excel/xechart.cxx +++ b/sc/source/filter/excel/xechart.cxx @@ -886,7 +886,8 @@ void lclAddDoubleRefData( OSL_ENSURE( (rToken.GetType() == ::formula::svDoubleRef) || (rToken.GetType() == ::formula::svExternalDoubleRef), "lclAddDoubleRefData - double reference token expected"); if( rToken.GetType() == ::formula::svExternalDoubleRef ) - orArray.AddExternalDoubleReference( rToken.GetIndex(), rToken.GetString(), aComplexRef ); + orArray.AddExternalDoubleReference( + rToken.GetIndex(), rToken.GetString().getString(), aComplexRef); else orArray.AddDoubleReference( aComplexRef ); } diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 094e5009963f..9132b48d1b96 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -920,7 +920,7 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm ) // the token array for that boost::scoped_ptr<ScTokenArray> pTokenArray(mrFormatEntry.CreateTokenArry(0)); if(pTokenArray->GetLen()) - aText = XclXmlUtils::ToOString(pTokenArray->First()->GetString()); + aText = XclXmlUtils::ToOString(pTokenArray->First()->GetString().getString()); } sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 2c4f64b38ec1..a11c3b2db6e9 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -1196,7 +1196,7 @@ void XclExpFmlaCompImpl::ProcessDouble( const XclExpScToken& rTokData ) void XclExpFmlaCompImpl::ProcessString( const XclExpScToken& rTokData ) { AppendOperandTokenId( EXC_TOKID_STR, rTokData.mnSpaces ); - Append( rTokData.mpScToken->GetString() ); + Append( rTokData.mpScToken->GetString().getString() ); } void XclExpFmlaCompImpl::ProcessMissing( const XclExpScToken& rTokData ) @@ -1230,7 +1230,7 @@ inline bool lclGetTokenString( OUString& rString, const XclExpScToken& rTokData { bool bIsStr = (rTokData.GetType() == svString) && (rTokData.GetOpCode() == ocPush); if( bIsStr ) - rString = rTokData.mpScToken->GetString(); + rString = rTokData.mpScToken->GetString().getString(); return bIsStr; } @@ -2017,13 +2017,13 @@ void XclExpFmlaCompImpl::ProcessExternalCellRef( const XclExpScToken& rTokData ) // store external cell contents in CRN records sal_uInt16 nFileId = rTokData.mpScToken->GetIndex(); - const OUString& rTabName = rTokData.mpScToken->GetString(); + OUString aTabName = rTokData.mpScToken->GetString().getString(); if( mxData->mrCfg.mbFromCell && mxData->mpScBasePos ) - mxData->mpLinkMgr->StoreCell(nFileId, rTabName, aRefData.toAbs(*mxData->mpScBasePos)); + mxData->mpLinkMgr->StoreCell(nFileId, aTabName, aRefData.toAbs(*mxData->mpScBasePos)); // 1-based EXTERNSHEET index and 0-based Excel sheet indexes sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab; - mxData->mpLinkMgr->FindExtSheet( nFileId, rTabName, 1, nExtSheet, nFirstSBTab, nLastSBTab, GetNewRefLogEntry() ); + mxData->mpLinkMgr->FindExtSheet( nFileId, aTabName, 1, nExtSheet, nFirstSBTab, nLastSBTab, GetNewRefLogEntry() ); // write the token sal_uInt8 nBaseId = lclIsRefDel2D( aRefData ) ? EXC_TOKID_REFERR3D : EXC_TOKID_REF3D; AppendOperandTokenId( GetTokenId( nBaseId, EXC_TOKCLASS_REF ), rTokData.mnSpaces ); @@ -2053,14 +2053,15 @@ void XclExpFmlaCompImpl::ProcessExternalRangeRef( const XclExpScToken& rTokData // store external cell contents in CRN records sal_uInt16 nFileId = rTokData.mpScToken->GetIndex(); - const OUString& rTabName = rTokData.mpScToken->GetString(); + OUString aTabName = rTokData.mpScToken->GetString().getString(); if( mxData->mrCfg.mbFromCell && mxData->mpScBasePos ) - mxData->mpLinkMgr->StoreCellRange(nFileId, rTabName, aRefData.toAbs(*mxData->mpScBasePos)); + mxData->mpLinkMgr->StoreCellRange(nFileId, aTabName, aRefData.toAbs(*mxData->mpScBasePos)); // 1-based EXTERNSHEET index and 0-based Excel sheet indexes sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab; sal_uInt16 nTabSpan = static_cast<sal_uInt16>(aRefData.Ref2.Tab() - aRefData.Ref1.Tab() + 1); - mxData->mpLinkMgr->FindExtSheet( nFileId, rTabName, nTabSpan, nExtSheet, nFirstSBTab, nLastSBTab, GetNewRefLogEntry() ); + mxData->mpLinkMgr->FindExtSheet( + nFileId, aTabName, nTabSpan, nExtSheet, nFirstSBTab, nLastSBTab, GetNewRefLogEntry()); // write the token sal_uInt8 nBaseId = lclIsRefDel2D( aRefData ) ? EXC_TOKID_AREAERR3D : EXC_TOKID_AREA3D; AppendOperandTokenId( GetTokenId( nBaseId, EXC_TOKCLASS_REF ), rTokData.mnSpaces ); @@ -2117,8 +2118,8 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpScToken& rTokData ) { ScExternalRefManager& rExtRefMgr = *GetDoc().GetExternalRefManager(); sal_uInt16 nFileId = rTokData.mpScToken->GetIndex(); - const OUString& rName = rTokData.mpScToken->GetString(); - ScExternalRefCache::TokenArrayRef xArray = rExtRefMgr.getRangeNameTokens( nFileId, rName ); + OUString aName = rTokData.mpScToken->GetString().getString(); + ScExternalRefCache::TokenArrayRef xArray = rExtRefMgr.getRangeNameTokens( nFileId, aName ); if( xArray.get() ) { // store external cell contents in CRN records @@ -2134,14 +2135,14 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpScToken& rTokData ) { ScSingleRefData aRefData = static_cast< ScToken* >( pScToken )->GetSingleRef(); mxData->mpLinkMgr->StoreCell( - nFileId, pScToken->GetString(), aRefData.toAbs(*mxData->mpScBasePos)); + nFileId, pScToken->GetString().getString(), aRefData.toAbs(*mxData->mpScBasePos)); } break; case svExternalDoubleRef: { ScComplexRefData aRefData = static_cast< ScToken* >( pScToken )->GetDoubleRef(); mxData->mpLinkMgr->StoreCellRange( - nFileId, pScToken->GetString(), aRefData.toAbs(*mxData->mpScBasePos)); + nFileId, pScToken->GetString().getString(), aRefData.toAbs(*mxData->mpScBasePos)); } default: ; // nothing, avoid compiler warning @@ -2153,7 +2154,7 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpScToken& rTokData ) // insert the new external name and create the tNameX token sal_uInt16 nExtSheet = 0, nExtName = 0; const OUString* pFile = rExtRefMgr.getExternalFileName( nFileId ); - if( pFile && mxData->mpLinkMgr->InsertExtName( nExtSheet, nExtName, *pFile, rName, xArray ) ) + if( pFile && mxData->mpLinkMgr->InsertExtName( nExtSheet, nExtName, *pFile, aName, xArray ) ) { AppendNameXToken( nExtSheet, nExtName, rTokData.mnSpaces ); return; diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 64d44679e3b6..29515505e54d 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -970,8 +970,8 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm ) if (bColRel) nCol |= 0x4000; if (bRowRel) nCol |= 0x8000; - const OUString& rTabName = p->GetString(); - sal_uInt16 nSBTab = mrSupbook.GetTabIndex(rTabName); + OUString aTabName = p->GetString().getString(); + sal_uInt16 nSBTab = mrSupbook.GetTabIndex(aTabName); // size is always 9 rStrm << static_cast<sal_uInt16>(9); @@ -1005,8 +1005,8 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm ) if (bCol2Rel) nCol2 |= 0x4000; if (bRow2Rel) nCol2 |= 0x8000; - const OUString& rTabName = p->GetString(); - sal_uInt16 nSBTab = mrSupbook.GetTabIndex(rTabName); + OUString aTabName = p->GetString().getString(); + sal_uInt16 nSBTab = mrSupbook.GetTabIndex(aTabName); // size is always 13 (0x0D) rStrm << static_cast<sal_uInt16>(13); @@ -1282,7 +1282,7 @@ void XclExpXct::Save( XclExpStream& rStrm ) case svString: // do not save empty strings (empty cells) to cache if( !xToken->GetString().isEmpty() ) - bValid = aCrnRecs.InsertValue( nScCol, nScRow, Any( OUString( xToken->GetString() ) ) ); + bValid = aCrnRecs.InsertValue( nScCol, nScRow, Any( xToken->GetString().getString() ) ); break; default: break; diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index f8de9377f725..2232f2cc1ef3 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -696,7 +696,7 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& rsT case NUMBERFORMAT_TEXT: { rsType = "str"; - rsValue = rCell.GetString(); + rsValue = rCell.GetString().getString(); } break; @@ -710,7 +710,7 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& rsT default: { rsType = "inlineStr"; - rsValue = rCell.GetString(); + rsValue = rCell.GetString().getString(); } break; } diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 42273bc96520..be28b5824a83 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -806,7 +806,7 @@ XclExpFormulaCell::XclExpFormulaCell( bool bForceLineBreak = false; if( nFormatType == NUMBERFORMAT_TEXT ) { - OUString aResult = mrScFmlaCell.GetString(); + OUString aResult = mrScFmlaCell.GetString().getString(); bForceLineBreak = mrScFmlaCell.IsMultilineResult(); nScript = XclExpStringHelper::GetLeadingScriptType( rRoot, aResult ); } @@ -955,7 +955,7 @@ void XclExpFormulaCell::WriteContents( XclExpStream& rStrm ) case NUMBERFORMAT_TEXT: { - OUString aResult = mrScFmlaCell.GetString(); + OUString aResult = mrScFmlaCell.GetString().getString(); if( !aResult.isEmpty() || (rStrm.GetRoot().GetBiff() <= EXC_BIFF5) ) { rStrm << EXC_FORMULA_RES_STRING; diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index 31d5a3cf71f6..8c4373941d43 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -706,7 +706,7 @@ void XclTokenArrayIterator::SkipSpaces() bool XclTokenArrayHelper::GetTokenString( OUString& rString, const FormulaToken& rScToken ) { bool bIsStr = (rScToken.GetType() == svString) && (rScToken.GetOpCode() == ocPush); - if( bIsStr ) rString = rScToken.GetString(); + if( bIsStr ) rString = rScToken.GetString().getString(); return bIsStr; } diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx index e7f568c34e03..624fea230d84 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx @@ -374,7 +374,7 @@ void ScChangeTrackingExportHelper::WriteFormulaCell(const ScCellValue& rCell, co else { rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING); - OUString sCellValue = pFormulaCell->GetString(); + OUString sCellValue = pFormulaCell->GetString().getString(); SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, true, true); if (!sCellValue.isEmpty()) { diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 28917bf1d96b..08a38fc59475 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3383,7 +3383,7 @@ void ScXMLExport::WriteMultiLineFormulaResult(const ScFormulaCell* pCell) { OUString aElemName = GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TEXT, GetXMLToken(XML_P)); - OUString aResStr = pCell->GetResultString(); + OUString aResStr = pCell->GetResultString().getString(); const sal_Unicode* p = aResStr.getStr(); const sal_Unicode* pEnd = p + static_cast<size_t>(aResStr.getLength()); const sal_Unicode* pPara = p; // paragraph head. @@ -4684,7 +4684,7 @@ void ScXMLExport::WriteExternalRefCaches() case svString: { AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING); - aStrVal = pToken->GetString(); + aStrVal = pToken->GetString().getString(); } break; default: diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 46a07b93767c..72bfec865a47 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1346,7 +1346,7 @@ static OUString lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const } else { - OUString aStr = pCalc->GetString(); + OUString aStr = pCalc->GetString().getString(); sal_uLong nFormat = aFormatter.GetStandardFormat( pCalc->GetFormatType(), ScGlobal::eLnge); { diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index a961cbe61c24..5306c954c3db 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -823,7 +823,7 @@ void ScTransferObj::StripRefs( ScDocument* pDoc, } else { - OUString aStr = pFCell->GetString(); + OUString aStr = pFCell->GetString().getString(); if ( pFCell->IsMultilineResult() ) { ScFieldEditEngine& rEngine = pDestDoc->GetEditEngine(); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 0b15f2d81dd8..386eddb49650 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1948,7 +1948,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter); } else - aString = pCell->mpFormula->GetString(); + aString = pCell->mpFormula->GetString().getString(); bString = true; } } diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 00b28b779d4b..302d17c6665c 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -184,7 +184,7 @@ public: // string cell otherwise. ScSetStringParam aParam; aParam.setTextInput(); - mpDoc->SetString(aPos, pCell->GetString(), &aParam); + mpDoc->SetString(aPos, pCell->GetString().getString(), &aParam); } } private: @@ -643,7 +643,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData( xMat->PutDouble(pToken->GetDouble(), nC, nR); break; case svString: - xMat->PutString(mrStrPool.intern(pToken->GetString()), nC, nR); + xMat->PutString(pToken->GetString(), nC, nR); break; default: ; @@ -1298,7 +1298,7 @@ static FormulaToken* convertToToken( ScRefCellValue& rCell ) } else { - OUString aStr = pFCell->GetString(); + svl::SharedString aStr = pFCell->GetString(); return new formula::FormulaStringToken(aStr); } } @@ -1372,8 +1372,7 @@ inline void ColumnBatch<T>::putValues(ScMatrixRef& xMat, const SCCOL nCol) const } static ScTokenArray* convertToTokenArray( - ScDocument* pSrcDoc, svl::SharedStringPool& rStrPool, ScRange& rRange, - vector<ScExternalRefCache::SingleRangeData>& rCacheData ) + ScDocument* pSrcDoc, ScRange& rRange, vector<ScExternalRefCache::SingleRangeData>& rCacheData ) { ScAddress& s = rRange.aStart; ScAddress& e = rRange.aEnd; @@ -1453,8 +1452,8 @@ static ScTokenArray* convertToTokenArray( } else { - OUString aStr = pFCell->GetString(); - xMat->PutString(rStrPool.intern(aStr), nC, nR); + svl::SharedString aStr = pFCell->GetString(); + xMat->PutString(aStr, nC, nR); } } break; @@ -2024,7 +2023,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokensFromSr aRange.aStart.SetTab(nTab1); aRange.aEnd.SetTab(nTab1 + nTabSpan); - pArray.reset(convertToTokenArray(pSrcDoc, mpDoc->GetSharedStringPool(), aRange, aCacheData)); + pArray.reset(convertToTokenArray(pSrcDoc, aRange, aCacheData)); rRange = aRange; rCacheData.swap(aCacheData); return pArray; diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index f5bfc003cdb3..ad0bbabf62d9 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -351,7 +351,7 @@ bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult } else { - OUString aStr = pFCell->GetString(); + OUString aStr = pFCell->GetString().getString(); OUString sTempOut(rStrResult); sal_uLong nFormat = aFormatter.GetStandardFormat( pFCell->GetFormatType(), ScGlobal::eLnge); diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 59d877e368eb..a39fed4a2a2c 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -733,7 +733,9 @@ void Chart2Positioner::createPositionMap() bool bExternal = ScRefTokenHelper::isExternalRef(pToken); sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0; - OUString aTabName = bExternal ? pToken->GetString() : OUString(); + svl::SharedString aTabName = svl::SharedString::getEmptyString(); + if (bExternal) + aTabName = pToken->GetString(); ScComplexRefData aData; if( !ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr) ) @@ -961,7 +963,9 @@ private: return false; bool bExternal = ScRefTokenHelper::isExternalRef(pToken); sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0; - OUString aTabName = bExternal ? pToken->GetString() : OUString(); + svl::SharedString aTabName = svl::SharedString::getEmptyString(); + if (bExternal) + aTabName = pToken->GetString(); // In saving to XML, we don't prepend address with '$'. setRelative(aData.Ref1); @@ -1124,7 +1128,7 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens, SCTAB nTab = 0; sal_uInt16 nFileId = 0; - OUString aExtTabName; + svl::SharedString aExtTabName; bool bExternal = false; vector<ScTokenRef>::const_iterator itr = rRefTokens.begin(), itrEnd = rRefTokens.end(); @@ -2660,8 +2664,8 @@ sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScTokenRef& pToke return 0; sal_uInt16 nFileId = pToken->GetIndex(); - const OUString& rTabName = pToken->GetString(); - ScExternalRefCache::TokenArrayRef pArray = pRefMgr->getDoubleRefTokens(nFileId, rTabName, aRange, NULL); + OUString aTabName = pToken->GetString().getString(); + ScExternalRefCache::TokenArrayRef pArray = pRefMgr->getDoubleRefTokens(nFileId, aTabName, aRange, NULL); if (!pArray) // no external data exists for this range. return 0; @@ -2671,7 +2675,7 @@ sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScTokenRef& pToke pRefMgr->addLinkListener(nFileId, pExtRefListener); pExtRefListener->addFileId(nFileId); - ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, rTabName, false, NULL); + ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, aTabName, false, NULL); sal_Int32 nDataCount = 0; for (FormulaToken* p = pArray->First(); p; p = pArray->Next()) { @@ -3075,7 +3079,7 @@ uno::Sequence< OUString > SAL_CALL ScChart2DataSequence::getTextualData( ) thro if( m_pTokens->front()->GetType() == svString ) { aSeq = uno::Sequence<OUString>(1); - aSeq[0] = m_pTokens->front()->GetString(); + aSeq[0] = m_pTokens->front()->GetString().getString(); } } diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 7d63cf2e3702..7bf321ad77ac 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -667,7 +667,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName, else { // string result - OUString aStrVal = pFormula->GetString(); + OUString aStrVal = pFormula->GetString().getString(); aRet <<= aStrVal; } } diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 2f78d3ff9c8b..98ce4589fff4 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -1522,7 +1522,7 @@ Any SAL_CALL ScExternalSheetCacheObj::getCellValue(sal_Int32 nCol, sal_Int32 nRo break; case svString: { - OUString aVal = pToken->GetString(); + OUString aVal = pToken->GetString().getString(); aValue <<= aVal; } break; diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index 19b1237c7eba..16949817d0f9 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -402,7 +402,7 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, rAPI.Data <<= rToken.GetDouble(); break; case formula::svString: - rAPI.Data <<= OUString( rToken.GetString() ); + rAPI.Data <<= rToken.GetString().getString(); break; case svExternal: // Function name is stored as string. @@ -441,7 +441,8 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, sheet::SingleReference aSingleRef; lcl_ExternalRefToApi( aSingleRef, static_cast<const ScToken&>(rToken).GetSingleRef() ); size_t nCacheId; - rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString(), false, &nCacheId ); + rDoc.GetExternalRefManager()->getCacheTable( + rToken.GetIndex(), rToken.GetString().getString(), false, &nCacheId); aSingleRef.Sheet = static_cast< sal_Int32 >( nCacheId ); sheet::ExternalReference aExtRef; aExtRef.Index = rToken.GetIndex(); @@ -456,7 +457,8 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, lcl_ExternalRefToApi( aComplRef.Reference1, static_cast<const ScToken&>(rToken).GetSingleRef() ); lcl_ExternalRefToApi( aComplRef.Reference2, static_cast<const ScToken&>(rToken).GetSingleRef2() ); size_t nCacheId; - rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString(), false, &nCacheId ); + rDoc.GetExternalRefManager()->getCacheTable( + rToken.GetIndex(), rToken.GetString().getString(), false, &nCacheId); aComplRef.Reference1.Sheet = static_cast< sal_Int32 >( nCacheId ); // NOTE: This assumes that cached sheets are in consecutive order! aComplRef.Reference2.Sheet = @@ -473,7 +475,7 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc, { sheet::ExternalReference aExtRef; aExtRef.Index = rToken.GetIndex(); - aExtRef.Reference <<= OUString( rToken.GetString() ); + aExtRef.Reference <<= rToken.GetString().getString(); rAPI.Data <<= aExtRef; eOpCode = ocPush; } diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx index 08ab7db6c3ec..16fa92c04645 100644 --- a/sc/source/ui/view/viewfun6.cxx +++ b/sc/source/ui/view/viewfun6.cxx @@ -181,11 +181,11 @@ void ScViewFunc::DetectiveMarkPred() ScRange aRange; if (pPath && ScRefTokenHelper::getRangeFromToken(aRange, p, aCurPos, true)) { - const OUString& rTabName = p->GetString(); + OUString aTabName = p->GetString().getString(); OUStringBuffer aBuf; aBuf.append(*pPath); aBuf.append(sal_Unicode('#')); - aBuf.append(rTabName); + aBuf.append(aTabName); aBuf.append(sal_Unicode('.')); OUString aRangeStr(aRange.Format(SCA_VALID)); diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx index 0438421b2efc..8389ff836c8f 100644 --- a/svl/source/misc/sharedstring.cxx +++ b/svl/source/misc/sharedstring.cxx @@ -11,6 +11,15 @@ namespace svl { +SharedString SharedString::getEmptyString() +{ + // unicode string array for empty string is globally shared in OUString. + // Let's take advantage of that. + rtl_uString* pData = NULL; + rtl_uString_new(&pData); + return SharedString(pData, pData); +} + SharedString::SharedString() : mpData(NULL), mpDataIgnoreCase(NULL) {} SharedString::SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase ) : |