From c488f3fc0c07a5c9ef0aed7f9d4e6447fc397292 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 13 Sep 2015 03:49:52 +0200 Subject: Simplify SvtFileDialog::appendDefaultExtension Change-Id: I7d2d2aff6e26b66e73b6ccefdecf095c867d4f7d --- fpicker/source/office/iodlg.cxx | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'fpicker') diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index 43666b1274f6..960579e7ea04 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -2839,35 +2839,26 @@ void SvtFileDialog::appendDefaultExtension(OUString& _rFileName, const OUString& _rFilterDefaultExtension, const OUString& _rFilterExtensions) { - OUString aTemp(_rFileName); - aTemp = aTemp.toAsciiLowerCase(); - OUString aType(_rFilterExtensions); - aType = aType.toAsciiLowerCase(); + const OUString aType(_rFilterExtensions.toAsciiLowerCase()); if ( aType != FILEDIALOG_FILTER_ALL ) { - sal_uInt16 nWildCard = comphelper::string::getTokenCount(aType, FILEDIALOG_DEF_EXTSEP); - sal_uInt16 nIndex; + const OUString aTemp(_rFileName.toAsciiLowerCase()); sal_Int32 nPos = 0; - for ( nIndex = 0; nIndex < nWildCard; nIndex++ ) + do { - OUString aExt(aType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nPos )); - // take care of a leading * - sal_Int32 nExtOffset = (aExt[0] == '*' ? 1 : 0); - const sal_Unicode* pExt = aExt.getStr() + nExtOffset; - sal_Int32 nExtLen = aExt.getLength() - nExtOffset; - sal_Int32 nOffset = aTemp.getLength() - nExtLen; - // minimize search by starting at last possible index - if ( aTemp.indexOf(pExt, nOffset) == nOffset ) - break; + if (nPos+1=0); - if ( nIndex >= nWildCard ) - { - _rFileName += "."; - _rFileName += _rFilterDefaultExtension; - } + _rFileName += "." + _rFilterDefaultExtension; } } -- cgit v1.2.3