Move extension preparation out of the loop

Change-Id: I6e4b5397e3d0ae9b943e261e9fca95735ccc9a73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132866
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2022-04-13 07:49:32 +01:00
parent 55c7691fad
commit b210c45d19

View File

@@ -652,23 +652,22 @@ std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilter4Extension( const OU
{
if ( m_rImpl.pList )
{
for (const std::shared_ptr<const SfxFilter>& pFilter : *m_rImpl.pList)
if (OUString sExt = ToUpper_Impl(rExt); !sExt.isEmpty())
{
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) )
if (sExt[0] != '.')
sExt = "." + sExt;
for (const std::shared_ptr<const SfxFilter>& pFilter : *m_rImpl.pList)
{
OUString sWildCard = ToUpper_Impl( pFilter->GetWildcard().getGlob() );
OUString sExt = ToUpper_Impl( rExt );
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ((nFlags & nMust) == nMust && !(nFlags & nDont))
{
OUString sWildCard = ToUpper_Impl(pFilter->GetWildcard().getGlob());
if (sExt.isEmpty())
continue;
if (sExt[0] != '.')
sExt = "." + sExt;
WildCard aCheck(sWildCard, ';');
if (aCheck.Matches(sExt))
return pFilter;
WildCard aCheck(sWildCard, ';');
if (aCheck.Matches(sExt))
return pFilter;
}
}
}