String to OUString + helper function
Change-Id: I9a318c50bc2427f55f58a13f96cbcb68fbc66f21
This commit is contained in:
@@ -1922,35 +1922,39 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames,
|
|||||||
SetModified();
|
SetModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
inline OUString lcl_CutOffDBCommandType(const OUString& rName)
|
||||||
|
{
|
||||||
|
return rName.replaceFirst(OUString(DB_DELIM), ".").getToken(0, DB_DELIM);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
|
void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames,
|
||||||
const String& rNewName, OUString& rFormel )
|
const String& rNewName, OUString& rFormel )
|
||||||
{
|
{
|
||||||
const CharClass& rCC = GetAppCharClass();
|
const CharClass& rCC = GetAppCharClass();
|
||||||
String sNewName( rNewName );
|
const OUString sNewName( lcl_CutOffDBCommandType(rNewName) );
|
||||||
sNewName.SearchAndReplace( DB_DELIM, '.');
|
|
||||||
//the command type is not part of the condition
|
|
||||||
sNewName = sNewName.GetToken(0, DB_DELIM);
|
|
||||||
|
|
||||||
for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i )
|
for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i )
|
||||||
{
|
{
|
||||||
String sDBName( rUsedDBNames[i] );
|
const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBNames[i]) );
|
||||||
|
|
||||||
sDBName.SearchAndReplace( DB_DELIM, '.');
|
if (sDBName!=sNewName)
|
||||||
//cut off command type
|
|
||||||
sDBName = sDBName.GetToken(0, DB_DELIM);
|
|
||||||
if( !sDBName.Equals( sNewName ))
|
|
||||||
{
|
{
|
||||||
sal_Int32 nPos = 0;
|
sal_Int32 nPos = 0;
|
||||||
while ((nPos = rFormel.indexOf(sDBName, nPos))>=0)
|
while ((nPos = rFormel.indexOf(sDBName, nPos))>=0)
|
||||||
{
|
{
|
||||||
if( rFormel[nPos + sDBName.Len()] == '.' &&
|
if( rFormel[nPos + sDBName.getLength()] == '.' &&
|
||||||
(!nPos || !rCC.isLetterNumeric( rFormel, nPos - 1 )))
|
(!nPos || !rCC.isLetterNumeric( rFormel, nPos - 1 )))
|
||||||
{
|
{
|
||||||
rFormel = rFormel.replaceAt(nPos, sDBName.Len(), sNewName);
|
rFormel = rFormel.replaceAt(nPos, sDBName.getLength(), sNewName);
|
||||||
//prevent re-searching - this is useless and provokes
|
//prevent re-searching - this is useless and provokes
|
||||||
//endless loops when names containing each other and numbers are exchanged
|
//endless loops when names containing each other and numbers are exchanged
|
||||||
//e.g.: old ?12345.12345 new: i12345.12345
|
//e.g.: old ?12345.12345 new: i12345.12345
|
||||||
nPos = nPos + sNewName.Len();
|
nPos = nPos + sNewName.getLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user