diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2019-02-10 15:51:37 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2019-02-17 18:57:24 +0100 |
commit | e81ee9289b818ffca76a52a3b37e0ea091f2d8f3 (patch) | |
tree | b648e8d486f6d8d708385c6e906e8e613c09f02f /sfx2 | |
parent | 9599f5eda7187567dbf8b198aa63b7421d5e9a17 (diff) |
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 <matteo.casalin@yahoo.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/docfilt.cxx | 25 |
1 files changed, 16 insertions, 9 deletions
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<aExts.getLength()) + aWildCard.setGlob(aExts.copy(0, nLen)); } - aWildCard.setGlob(glob.makeStringAndClear()); } SfxFilter::~SfxFilter() |