summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2015-09-13 03:49:52 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2015-09-13 11:05:27 +0200
commitc488f3fc0c07a5c9ef0aed7f9d4e6447fc397292 (patch)
treedc872666e4568ee615738a8fa944b708bbb285ce /fpicker
parent81d62c5f48f3bf341c4c7bdaef5a5ce5941f3e62 (diff)
Simplify SvtFileDialog::appendDefaultExtension
Change-Id: I7d2d2aff6e26b66e73b6ccefdecf095c867d4f7d
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/office/iodlg.cxx33
1 files changed, 12 insertions, 21 deletions
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<aType.getLength() && aType[nPos]=='*') // take care of a leading *
+ ++nPos;
+ const OUString aExt(aType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
+ if (aExt.isEmpty())
+ continue;
+ if (aTemp.endsWith(aExt))
+ return;
}
+ while (nPos>=0);
- if ( nIndex >= nWildCard )
- {
- _rFileName += ".";
- _rFileName += _rFilterDefaultExtension;
- }
+ _rFileName += "." + _rFilterDefaultExtension;
}
}