summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2018-11-09 19:10:55 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2018-11-10 22:04:06 +0100
commit9d2bf6f6d62c8e99b2bffe45d2d9aa05f29d625e (patch)
tree84c744f466d2c02a1fbdb81c1c26382af704aff4 /dbaccess
parent030c27a0f35ad1515d22c386b2a343c4de1760df (diff)
Avoid getTokenCount()
Change-Id: Ia71e4822ce863a296c7c0eb137c164538f9a0d27
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/dlg/TextConnectionHelper.cxx30
1 files changed, 22 insertions, 8 deletions
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
index 1c8051852a91..22f3bd5c5eff 100644
--- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
@@ -51,8 +51,26 @@
#include <unotools/pathoptions.hxx>
#include <svtools/roadmapwizard.hxx>
+namespace
+{
+
+OUString lcl_getListEntry(const OUString& rStr, sal_Int32& rIdx)
+{
+ const OUString sTkn {rStr.getToken( 0, '\t', rIdx )};
+ if (rIdx>=0)
+ {
+ rIdx = rStr.indexOf('\t', rIdx);
+ if (rIdx>=0 && ++rIdx>=rStr.getLength())
+ rIdx = -1;
+ }
+ return sTkn;
+}
+
+}
+
namespace dbaui
{
+
OTextConnectionHelper::OTextConnectionHelper(weld::Widget* pParent, const short _nAvailableSections)
: m_aFieldSeparatorList (DBA_RES(STR_AUTOFIELDSEPARATORLIST))
, m_aTextSeparatorList (STR_AUTOTEXTSEPARATORLIST)
@@ -80,15 +98,11 @@ namespace dbaui
, m_xCharSetLabel(m_xBuilder->weld_label("charsetlabel"))
, m_xCharSet(new CharSetListBox(m_xBuilder->weld_combo_box("charset")))
{
- sal_Int32 nCnt = comphelper::string::getTokenCount(m_aFieldSeparatorList, '\t');
- sal_Int32 i;
-
- for( i = 0 ; i < nCnt ; i += 2 )
- m_xFieldSeparator->append_text( m_aFieldSeparatorList.getToken( i, '\t' ) );
+ for(sal_Int32 nIdx {0}; nIdx>=0;)
+ m_xFieldSeparator->append_text( lcl_getListEntry(m_aFieldSeparatorList, nIdx) );
- nCnt = comphelper::string::getTokenCount(m_aTextSeparatorList, '\t');
- for( i=0 ; i<nCnt ; i+=2 )
- m_xTextSeparator->append_text( m_aTextSeparatorList.getToken( i, '\t' ) );
+ for(sal_Int32 nIdx {0}; nIdx>=0;)
+ m_xTextSeparator->append_text( lcl_getListEntry(m_aTextSeparatorList, nIdx) );
m_xTextSeparator->append_text(m_aTextNone);
m_xOwnExtension->connect_changed(LINK(this, OTextConnectionHelper, OnEditModified));