From e81ee9289b818ffca76a52a3b37e0ea091f2d8f3 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 10 Feb 2019 15:51:37 +0100 Subject: SfxFilter: truncate extensions list at first empty one... ... instead of rebuilding such list token by token until an empty extension is found Change-Id: Ib084b3064dccd1cf820bbb62ed47db03224b2161 Reviewed-on: https://gerrit.libreoffice.org/67631 Tested-by: Jenkins Reviewed-by: Matteo Casalin --- sfx2/source/doc/docfilt.cxx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx index 500b0ad224fc..ef1bef3235d6 100644 --- a/sfx2/source/doc/docfilt.cxx +++ b/sfx2/source/doc/docfilt.cxx @@ -67,17 +67,24 @@ SfxFilter::SfxFilter( const OUString &rName, lFormat(lFmt), mbEnabled(bEnabled) { - OUString aExts = GetWildcard().getGlob(); - OUStringBuffer glob; - OUString aRet; - sal_uInt16 nPos = 0; - while (!(aRet = aExts.getToken(nPos++, ';')).isEmpty() ) + const OUString aExts = GetWildcard().getGlob(); + sal_Int32 nLen{ aExts.getLength() }; + if (nLen>0) { - if (!glob.isEmpty()) - glob.append(";"); - glob.append(aRet); + // truncate to first empty extension + if (aExts[0]==';') + { + aWildCard.setGlob(""); + return; + } + const sal_Int32 nIdx{ aExts.indexOf(";;") }; + if (nIdx>0) + nLen = nIdx; + else if (aExts[nLen-1]==';') + --nLen; + if (nLen