summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2013-09-28 12:26:23 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2013-09-29 10:46:58 +0200
commitd614742057077236e3c12e7b0c26f689a81c1ee9 (patch)
tree931025244053ffc59c23fcffeedc379fde4d85f5 /sw
parent571e8eba65808336870faf593148f42ea2f9571c (diff)
Prefer return value to reference argument
Change-Id: I1ba2f9abfad6c8a8e48f62e6cf69c7c36b6e1ace
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/doc.hxx4
-rw-r--r--sw/source/core/doc/docfld.cxx30
2 files changed, 13 insertions, 21 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index daefef0a293d..d98ede9194ef 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -655,8 +655,8 @@ private:
void AddUsedDBToList( std::vector<String>& rDBNameList, const String& rDBName );
bool IsNameInArray( const std::vector<String>& rOldNames, const String& rName );
void GetAllDBNames( std::vector<String>& rAllDBNames );
- void ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
- const String& rNewName, OUString& rFormel );
+ OUString ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
+ const OUString& rNewName, const OUString& rFormel );
std::vector<String>& FindUsedDBs( const std::vector<String>& rAllDBNames,
const String& rFormel,
std::vector<String>& rUsedDBNames );
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 636b68e4da69..ef38437c7ac3 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -1833,9 +1833,7 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames,
if( pSect )
{
- OUString sFormel = pSect->GetCondition();
- ReplaceUsedDBs( rOldNames, rNewName, sFormel);
- pSect->SetCondition(sFormel);
+ pSect->SetCondition(ReplaceUsedDBs(rOldNames, rNewName, pSect->GetCondition()));
}
}
@@ -1896,24 +1894,16 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames,
// no break;
case RES_HIDDENTXTFLD:
case RES_HIDDENPARAFLD:
- {
- OUString sFormel = pFld->GetPar1();
- ReplaceUsedDBs( rOldNames, rNewName, sFormel);
- pFld->SetPar1( sFormel );
+ pFld->SetPar1( ReplaceUsedDBs(rOldNames, rNewName, pFld->GetPar1()) );
bExpand = true;
break;
- }
case RES_SETEXPFLD:
case RES_GETEXPFLD:
case RES_TABLEFLD:
- {
- OUString sFormel = pFld->GetFormula();
- ReplaceUsedDBs( rOldNames, rNewName, sFormel);
- pFld->SetPar2( sFormel );
+ pFld->SetPar2( ReplaceUsedDBs(rOldNames, rNewName, pFld->GetFormula()) );
bExpand = true;
break;
- }
}
if (bExpand)
@@ -1932,11 +1922,12 @@ inline OUString lcl_CutOffDBCommandType(const OUString& rName)
}
-void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
- const String& rNewName, OUString& rFormel )
+OUString SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
+ const OUString& rNewName, const OUString& rFormel )
{
const CharClass& rCC = GetAppCharClass();
const OUString sNewName( lcl_CutOffDBCommandType(rNewName) );
+ OUString sFormula(rFormel);
for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i )
{
@@ -1945,12 +1936,12 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
if (sDBName!=sNewName)
{
sal_Int32 nPos = 0;
- while ((nPos = rFormel.indexOf(sDBName, nPos))>=0)
+ while ((nPos = sFormula.indexOf(sDBName, nPos))>=0)
{
- if( rFormel[nPos + sDBName.getLength()] == '.' &&
- (!nPos || !rCC.isLetterNumeric( rFormel, nPos - 1 )))
+ if( sFormula[nPos + sDBName.getLength()] == '.' &&
+ (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 )))
{
- rFormel = rFormel.replaceAt(nPos, sDBName.getLength(), sNewName);
+ sFormula = sFormula.replaceAt(nPos, sDBName.getLength(), sNewName);
//prevent re-searching - this is useless and provokes
//endless loops when names containing each other and numbers are exchanged
//e.g.: old ?12345.12345 new: i12345.12345
@@ -1959,6 +1950,7 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
}
}
}
+ return sFormula;
}
bool SwDoc::IsNameInArray( const std::vector<String>& rArr, const String& rName )