diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-04-14 00:04:40 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-04-18 07:36:49 +0200 |
commit | d77e8348f372bd069aa8adccabb65a3722539323 (patch) | |
tree | 4b643572fbc2597e79581a548f48b4a90ea9db46 | |
parent | 4e69f4d4ec6e52189d2bcc31a01c31d626e6c394 (diff) |
Simplify generation of unique name
Change-Id: Ifed55197ed6836dfb16d958c7dd34afad6c4aca7
-rw-r--r-- | sw/source/ui/dbui/dbinsdlg.cxx | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index ee12e1f83fa9..dae0b0f5d91d 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -1492,26 +1492,20 @@ static Sequence<OUString> lcl_CreateSubNames(const OUString& rSubNodeName) static OUString lcl_CreateUniqueName(const Sequence<OUString>& aNames) { - sal_Int32 nIdx = aNames.getLength(); + const sal_Int32 nNames = aNames.getLength(); + sal_Int32 nIdx = nNames; const OUString* pNames = aNames.getConstArray(); - OUString sTest("_"); - OUString sRet; while(true) { - sRet = sTest; sRet += OUString::number(nIdx++); - bool bFound = false; - for(sal_Int32 i = 0; i < aNames.getLength(); i++) + const OUString sRet = "_" + OUString::number(nIdx++); + sal_Int32 i = 0; + while ( i < nNames && pNames[i] != sRet ) { - if(pNames[i] == sRet) - { - bFound = true; - break; - } + ++i; } - if(!bFound) - break; + if ( i >= nNames ) + return sRet; // No match found, return unique name } - return sRet; } void SwInsertDBColAutoPilot::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {} |