Kaydet (Commit) c488f3fc authored tarafından Matteo Casalin's avatar Matteo Casalin

Simplify SvtFileDialog::appendDefaultExtension

Change-Id: I7d2d2aff6e26b66e73b6ccefdecf095c867d4f7d
üst 81d62c5f
...@@ -2839,35 +2839,26 @@ void SvtFileDialog::appendDefaultExtension(OUString& _rFileName, ...@@ -2839,35 +2839,26 @@ void SvtFileDialog::appendDefaultExtension(OUString& _rFileName,
const OUString& _rFilterDefaultExtension, const OUString& _rFilterDefaultExtension,
const OUString& _rFilterExtensions) const OUString& _rFilterExtensions)
{ {
OUString aTemp(_rFileName); const OUString aType(_rFilterExtensions.toAsciiLowerCase());
aTemp = aTemp.toAsciiLowerCase();
OUString aType(_rFilterExtensions);
aType = aType.toAsciiLowerCase();
if ( aType != FILEDIALOG_FILTER_ALL ) if ( aType != FILEDIALOG_FILTER_ALL )
{ {
sal_uInt16 nWildCard = comphelper::string::getTokenCount(aType, FILEDIALOG_DEF_EXTSEP); const OUString aTemp(_rFileName.toAsciiLowerCase());
sal_uInt16 nIndex;
sal_Int32 nPos = 0; sal_Int32 nPos = 0;
for ( nIndex = 0; nIndex < nWildCard; nIndex++ ) do
{ {
OUString aExt(aType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nPos )); if (nPos+1<aType.getLength() && aType[nPos]=='*') // take care of a leading *
// take care of a leading * ++nPos;
sal_Int32 nExtOffset = (aExt[0] == '*' ? 1 : 0); const OUString aExt(aType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
const sal_Unicode* pExt = aExt.getStr() + nExtOffset; if (aExt.isEmpty())
sal_Int32 nExtLen = aExt.getLength() - nExtOffset; continue;
sal_Int32 nOffset = aTemp.getLength() - nExtLen; if (aTemp.endsWith(aExt))
// minimize search by starting at last possible index return;
if ( aTemp.indexOf(pExt, nOffset) == nOffset )
break;
} }
while (nPos>=0);
if ( nIndex >= nWildCard ) _rFileName += "." + _rFilterDefaultExtension;
{
_rFileName += ".";
_rFileName += _rFilterDefaultExtension;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment