diff options
author | Eike Rathke <erack@redhat.com> | 2016-06-14 13:28:47 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-06-14 13:33:35 +0200 |
commit | 478613c550236d19b8254c49e5886dca1f0b8aac (patch) | |
tree | 04995256bc40fb31a03682818acdc280e5d3e230 /sc | |
parent | c44d5589dfc4312ab98408dec68c8577240dd7d3 (diff) |
explicit svl::SharedString(const OUString&) ctor
... to prevent accidental surprises. Not interned shared strings
constructed from OUString have mpDataIgnoreCase=nullptr so can't be used
for case insensitive comparison.
Change-Id: I03323354298a73e93b18d2796ec447c072fdefa5
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/tokenarray.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/simpleformulacalc.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/reftokenhelper.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 31 | ||||
-rw-r--r-- | sc/source/filter/excel/tokstack.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/excel/xechart.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xilink.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 6 |
13 files changed, 50 insertions, 37 deletions
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index 760643178011..061d044f093a 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -98,9 +98,9 @@ public: formula::FormulaToken* AddDoubleReference( const ScComplexRefData& rRef ); void AddRangeName( sal_uInt16 n, sal_Int16 nSheet ); formula::FormulaToken* AddDBRange( sal_uInt16 n ); - formula::FormulaToken* AddExternalName( sal_uInt16 nFileId, const OUString& rName ); - void AddExternalSingleReference( sal_uInt16 nFileId, const OUString& rTabName, const ScSingleRefData& rRef ); - formula::FormulaToken* AddExternalDoubleReference( sal_uInt16 nFileId, const OUString& rTabName, const ScComplexRefData& rRef ); + formula::FormulaToken* AddExternalName( sal_uInt16 nFileId, const svl::SharedString& rName ); + void AddExternalSingleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScSingleRefData& rRef ); + formula::FormulaToken* AddExternalDoubleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScComplexRefData& rRef ); formula::FormulaToken* AddMatrix( const ScMatrixRef& p ); /** ScSingleRefOpToken with ocColRowName. */ formula::FormulaToken* AddColRowName( const ScSingleRefData& rRef ); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index a32b2f77fc04..eccb7dcac668 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2026,13 +2026,14 @@ formula::FormulaTokenRef ScColumn::ResolveStaticReference( SCROW nRow ) case sc::element_type_string: { const svl::SharedString& rSS = sc::string_block::at(*it->data, aPos.second); - return formula::FormulaTokenRef(new formula::FormulaStringToken(rSS.getString())); + return formula::FormulaTokenRef(new formula::FormulaStringToken(rSS)); } case sc::element_type_edittext: { const EditTextObject* pText = sc::edittext_block::at(*it->data, aPos.second); OUString aStr = ScEditUtil::GetString(*pText, pDocument); - return formula::FormulaTokenRef(new formula::FormulaStringToken(aStr)); + svl::SharedString aSS( pDocument->GetSharedStringPool().intern(aStr)); + return formula::FormulaTokenRef(new formula::FormulaStringToken(aSS)); } case sc::element_type_empty: default: diff --git a/sc/source/core/data/simpleformulacalc.cxx b/sc/source/core/data/simpleformulacalc.cxx index b573544ac7e5..df2755f41280 100644 --- a/sc/source/core/data/simpleformulacalc.cxx +++ b/sc/source/core/data/simpleformulacalc.cxx @@ -125,7 +125,7 @@ svl::SharedString ScSimpleFormulaCalculator::GetString() Calculate(); if (mbMatrixResult) - return maMatrixFormulaResult; + return svl::SharedString( maMatrixFormulaResult); // string not interned if ((!mpCode->GetCodeError() || mpCode->GetCodeError() == formula::errDoubleRef) && !maResult.GetResultError()) diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index bb1ad0e7a87a..6e78b880c0c3 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2356,7 +2356,7 @@ void ScInterpreter::ScCellExternal() { // ODF 1.2 says we need to always display address using the ODF A1 grammar. ScTokenArray aArray; - aArray.AddExternalSingleReference(nFileId, aTabName, aRef); + aArray.AddExternalSingleReference(nFileId, svl::SharedString( aTabName), aRef); // string not interned ScCompiler aComp(pDok, aPos, aArray); aComp.SetGrammar(formula::FormulaGrammar::GRAM_ODFF_A1); OUString aStr; diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 343cb90e923b..eff287105e86 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -1737,7 +1737,8 @@ void ScInterpreter::PushExternalSingleRef( { ScSingleRefData aRef; aRef.InitAddress(ScAddress(nCol,nRow,nTab)); - PushTempTokenWithoutError( new ScExternalSingleRefToken(nFileId, rTabName, aRef)) ; + PushTempTokenWithoutError( new ScExternalSingleRefToken(nFileId, + pDok->GetSharedStringPool().intern( rTabName), aRef)) ; } } @@ -1749,7 +1750,8 @@ void ScInterpreter::PushExternalDoubleRef( { ScComplexRefData aRef; aRef.InitRange(ScRange(nCol1,nRow1,nTab1,nCol2,nRow2,nTab2)); - PushTempTokenWithoutError( new ScExternalDoubleRefToken(nFileId, rTabName, aRef) ); + PushTempTokenWithoutError( new ScExternalDoubleRefToken(nFileId, + pDok->GetSharedStringPool().intern( rTabName), aRef) ); } } diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx index 70b2faa0e3a1..8e90b038cc61 100644 --- a/sc/source/core/tool/reftokenhelper.cxx +++ b/sc/source/core/tool/reftokenhelper.cxx @@ -321,7 +321,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().getString() : OUString(); + svl::SharedString aTabName = bExternal ? pToken->GetString() : svl::SharedString::getEmptyString(); bool bJoined = false; vector<ScTokenRef>::iterator itr = rTokens.begin(), itrEnd = rTokens.end(); @@ -344,7 +344,7 @@ private: // Different external files. continue; - if (aTabName != pOldToken->GetString().getString()) + if (aTabName != pOldToken->GetString()) // Different table names. continue; } diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 4aa0993f365a..a693aba55d68 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -600,7 +600,7 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE if (!ValidColRowOrReplicated( nC, nR )) { OSL_FAIL("ScMatrixImpl::GetString: dimension error"); - return OUString(); + return svl::SharedString::getEmptyString(); } double fVal = 0.0; @@ -608,7 +608,7 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE switch (maMat.get_type(aPos)) { case mdds::mtm::element_string: - return maMat.get_string(aPos).getString(); + return maMat.get_string(aPos); case mdds::mtm::element_empty: { if (maMatFlag.get_numeric(nR, nC) != SC_MATFLAG_EMPTYPATH) @@ -621,7 +621,7 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE OUString aStr; Color* pColor = nullptr; rFormatter.GetOutputString( 0.0, nKey, aStr, &pColor); - return aStr; + return svl::SharedString( aStr); // string not interned } case mdds::mtm::element_numeric: case mdds::mtm::element_boolean: @@ -635,14 +635,14 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE if (nError) { SetErrorAtInterpreter( nError); - return ScGlobal::GetErrorString( nError); + return svl::SharedString( ScGlobal::GetErrorString( nError)); // string not interned } sal_uLong nKey = rFormatter.GetStandardFormat( css::util::NumberFormat::NUMBER, ScGlobal::eLnge); OUString aStr; rFormatter.GetInputLineString( fVal, nKey, aStr); - return aStr; + return svl::SharedString( aStr); // string not interned } ScMatrixValue ScMatrixImpl::Get(SCSIZE nC, SCSIZE nR) const diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index d9c2505c6f81..c7f03f2b6f56 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -418,17 +418,17 @@ FormulaToken* ScRawToken::CreateToken() const return new FormulaIndexToken( eOp, name.nIndex, name.nSheet); case svExternalSingleRef: { - OUString aTabName(extref.cTabName); + svl::SharedString aTabName( OUString( extref.cTabName)); // string not interned return new ScExternalSingleRefToken(extref.nFileId, aTabName, extref.aRef.Ref1); } case svExternalDoubleRef: { - OUString aTabName(extref.cTabName); + svl::SharedString aTabName( OUString( extref.cTabName)); // string not interned return new ScExternalDoubleRefToken(extref.nFileId, aTabName, extref.aRef); } case svExternalName: { - OUString aName(extname.cName); + svl::SharedString aName( OUString( extname.cName)); // string not interned return new ScExternalNameToken( extname.nFileId, aName ); } case svJump : @@ -1251,7 +1251,7 @@ bool ScTokenArray::AddFormulaToken( ScSingleRefData aSingleRef; // convert column/row settings, set sheet index to absolute lcl_ExternalRefToCalc( aSingleRef, aApiSRef ); - AddExternalSingleReference( nFileId, aTabName, aSingleRef ); + AddExternalSingleReference( nFileId, rSPool.intern( aTabName), aSingleRef ); } else bError = true; @@ -1270,7 +1270,7 @@ bool ScTokenArray::AddFormulaToken( // NOTE: This assumes that cached sheets are in consecutive order! aComplRef.Ref2.SetAbsTab( aComplRef.Ref1.Tab() + static_cast<SCTAB>(aApiCRef.Reference2.Sheet - aApiCRef.Reference1.Sheet)); - AddExternalDoubleReference( nFileId, aTabName, aComplRef ); + AddExternalDoubleReference( nFileId, rSPool.intern( aTabName), aComplRef ); } else bError = true; @@ -1278,7 +1278,7 @@ bool ScTokenArray::AddFormulaToken( else if( aApiExtRef.Reference >>= aName ) { if( !aName.isEmpty() ) - AddExternalName( nFileId, aName ); + AddExternalName( nFileId, rSPool.intern( aName) ); else bError = true; } @@ -2080,17 +2080,19 @@ FormulaToken* ScTokenArray::AddDBRange( sal_uInt16 n ) return Add( new FormulaIndexToken( ocDBArea, n)); } -FormulaToken* ScTokenArray::AddExternalName( sal_uInt16 nFileId, const OUString& rName ) +FormulaToken* ScTokenArray::AddExternalName( sal_uInt16 nFileId, const svl::SharedString& rName ) { return Add( new ScExternalNameToken(nFileId, rName) ); } -void ScTokenArray::AddExternalSingleReference( sal_uInt16 nFileId, const OUString& rTabName, const ScSingleRefData& rRef ) +void ScTokenArray::AddExternalSingleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, + const ScSingleRefData& rRef ) { Add( new ScExternalSingleRefToken(nFileId, rTabName, rRef) ); } -FormulaToken* ScTokenArray::AddExternalDoubleReference( sal_uInt16 nFileId, const OUString& rTabName, const ScComplexRefData& rRef ) +FormulaToken* ScTokenArray::AddExternalDoubleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, + const ScComplexRefData& rRef ) { return Add( new ScExternalDoubleRefToken(nFileId, rTabName, rRef) ); } @@ -2105,9 +2107,10 @@ void ScTokenArray::AssignXMLString( const OUString &rText, const OUString &rForm sal_uInt16 nTokens = 1; FormulaToken *aTokens[2]; - aTokens[0] = new FormulaStringOpToken( ocStringXML, rText ); + aTokens[0] = new FormulaStringOpToken( ocStringXML, svl::SharedString( rText) ); // string not interned if( !rFormulaNmsp.isEmpty() ) - aTokens[ nTokens++ ] = new FormulaStringOpToken( ocStringXML, rFormulaNmsp ); + aTokens[ nTokens++ ] = new FormulaStringOpToken( ocStringXML, + svl::SharedString( rFormulaNmsp) ); // string not interned Assign( nTokens, aTokens ); } @@ -2400,7 +2403,8 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons OUString aTabName; sal_uInt16 nFileId; GetExternalTableData(pOldDoc, pNewDoc, rRef1.Tab(), aTabName, nFileId); - ReplaceToken( j, new ScExternalDoubleRefToken(nFileId, aTabName, rRef), CODE_AND_RPN); + ReplaceToken( j, new ScExternalDoubleRefToken(nFileId, svl::SharedString( aTabName), rRef), + CODE_AND_RPN); // string not interned (pNewDoc would have to be non-const) // ATTENTION: rRef can't be used after this point } } @@ -2417,7 +2421,8 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons OUString aTabName; sal_uInt16 nFileId; GetExternalTableData(pOldDoc, pNewDoc, rRef.Tab(), aTabName, nFileId); - ReplaceToken( j, new ScExternalSingleRefToken(nFileId, aTabName, rRef), CODE_AND_RPN); + ReplaceToken( j, new ScExternalSingleRefToken(nFileId, svl::SharedString( aTabName), rRef), + CODE_AND_RPN); // string not interned (pNewDoc would have to be non-const) // ATTENTION: rRef can't be used after this point } } diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx index 9323f93572c2..edd22896cef1 100644 --- a/sc/source/filter/excel/tokstack.cxx +++ b/sc/source/filter/excel/tokstack.cxx @@ -473,7 +473,7 @@ bool TokenPool::GetElement( const sal_uInt16 nId ) if (n < maExtNames.size()) { const ExtName& r = maExtNames[n]; - pScToken->AddExternalName(r.mnFileId, r.maName); + pScToken->AddExternalName(r.mnFileId, svl::SharedString( r.maName)); // string not interned } else bRet = false; @@ -485,7 +485,8 @@ bool TokenPool::GetElement( const sal_uInt16 nId ) if (n < maExtCellRefs.size()) { const ExtCellRef& r = maExtCellRefs[n]; - pScToken->AddExternalSingleReference(r.mnFileId, r.maTabName, r.maRef); + pScToken->AddExternalSingleReference(r.mnFileId, svl::SharedString( r.maTabName), + r.maRef); // string not interned } else bRet = false; @@ -497,7 +498,8 @@ bool TokenPool::GetElement( const sal_uInt16 nId ) if (n < maExtAreaRefs.size()) { const ExtAreaRef& r = maExtAreaRefs[n]; - pScToken->AddExternalDoubleReference(r.mnFileId, r.maTabName, r.maRef); + pScToken->AddExternalDoubleReference(r.mnFileId, svl::SharedString( r.maTabName), + r.maRef); // string not interned } else bRet = false; diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx index 6e98086408b7..2b2c3a6e7214 100644 --- a/sc/source/filter/excel/xechart.cxx +++ b/sc/source/filter/excel/xechart.cxx @@ -871,7 +871,7 @@ void lclAddDoubleRefData( "lclAddDoubleRefData - double reference token expected"); if( rToken.GetType() == ::formula::svExternalDoubleRef ) orArray.AddExternalDoubleReference( - rToken.GetIndex(), rToken.GetString().getString(), aComplexRef); + rToken.GetIndex(), rToken.GetString(), aComplexRef); else orArray.AddDoubleReference( aComplexRef ); } diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx index 467cc99a5208..f527b8b4b4c1 100644 --- a/sc/source/filter/excel/xilink.cxx +++ b/sc/source/filter/excel/xilink.cxx @@ -609,7 +609,7 @@ void XclImpSupbookTab::LoadCachedValues(const ScExternalRefCache::TableTypeRef& case EXC_CACHEDVAL_STRING: { const OUString& rStr = pCrn->GetString(); - ScExternalRefCache::TokenRef pToken(new formula::FormulaStringToken(rStr)); + ScExternalRefCache::TokenRef pToken(new formula::FormulaStringToken( svl::SharedString( rStr))); // string not interned pCacheTable->setCell(rAddr.mnCol, rAddr.mnRow, pToken, 0, false); } break; diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index eac311dfe17d..149435ec3766 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1444,7 +1444,8 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) if (!IsPossibleErrorString()) { pFCell->SetResultMatrix( - nMatrixCols, nMatrixRows, pMat, new formula::FormulaStringToken(*maStringValue)); + nMatrixCols, nMatrixRows, pMat, new formula::FormulaStringToken( + rXMLImport.GetDocument()->GetSharedStringPool().intern( *maStringValue))); pFCell->ResetDirty(); } } diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index f703b6798ee1..d97d54705263 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -2342,7 +2342,8 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSr const ScSingleRefData& rRef = *pToken->GetSingleRef(); OUString aTabName; pSrcDoc->GetName(rRef.Tab(), aTabName); - ScExternalSingleRefToken aNewToken(nFileId, aTabName, *pToken->GetSingleRef()); + ScExternalSingleRefToken aNewToken(nFileId, svl::SharedString( aTabName), // string not interned + *pToken->GetSingleRef()); pNew->AddToken(aNewToken); bTokenAdded = true; } @@ -2352,7 +2353,8 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSr const ScSingleRefData& rRef = *pToken->GetSingleRef(); OUString aTabName; pSrcDoc->GetName(rRef.Tab(), aTabName); - ScExternalDoubleRefToken aNewToken(nFileId, aTabName, *pToken->GetDoubleRef()); + ScExternalDoubleRefToken aNewToken(nFileId, svl::SharedString( aTabName), // string not interned + *pToken->GetDoubleRef()); pNew->AddToken(aNewToken); bTokenAdded = true; } |