From 2206aaa72cc678ab3f04ad318dc5049f580c8d09 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Fri, 9 Nov 2018 19:54:57 +0100 Subject: Loop only if string length is the desired one Change-Id: I5e03fceb83a22b590a62b605c4ada279b937730a --- dbaccess/source/ui/dlg/TextConnectionHelper.cxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'dbaccess/source/ui') diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx index 55c8e227eebb..6abb1cddb698 100644 --- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx @@ -389,19 +389,21 @@ namespace dbaui void OTextConnectionHelper::SetSeparator( weld::ComboBox& rBox, const OUString& rList, const OUString& rVal ) { - for(sal_Int32 nIdx {0}; nIdx>=0;) + if (rVal.getLength()==1) { - sal_Int32 nPrevIdx {nIdx}; - OUString sTVal {static_cast< sal_Unicode >( rList.getToken(1, '\t', nIdx).toInt32() )}; - - if( sTVal == rVal ) + const sal_Unicode nVal {rVal[0]}; + for(sal_Int32 nIdx {0}; nIdx>=0;) { - rBox.set_entry_text(rList.getToken(0, '\t', nPrevIdx)); - return; + sal_Int32 nPrevIdx {nIdx}; + if (static_cast(rList.getToken(1, '\t', nIdx).toInt32()) == nVal) + { + rBox.set_entry_text(rList.getToken(0, '\t', nPrevIdx)); + return; + } } + rBox.set_entry_text( rVal ); } - - if ( m_xTextSeparator.get() == &rBox && rVal.isEmpty() ) + else if ( m_xTextSeparator.get() == &rBox && rVal.isEmpty() ) rBox.set_entry_text(m_aTextNone); else rBox.set_entry_text(rVal.copy(0, 1)); -- cgit