split out the code that extracts a lower-ascii version of a fontname

Change-Id: I77778ecd075712c41bd29324be090ab4a8351ab9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135677
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2022-06-12 10:34:43 +01:00
parent ab37d64477
commit 55eeffe768

View file

@ -226,6 +226,25 @@ OUString StripScriptFromName(const OUString& _aName)
return aName;
}
//return true if the character is stripped from the string
static bool toOnlyLowerAscii(sal_Unicode c, OUStringBuffer &rName, sal_Int32 nIndex, sal_Int32& rLen)
{
// To Lowercase-Ascii
if ( (c >= 'A') && (c <= 'Z') )
{
c += 'a' - 'A';
rName[nIndex] = c;
}
else if( ((c < '0') || (c > '9')) && (c != ';') && (c != '(') && (c != ')') ) // not 0-9, semicolon, or brackets
{
// Remove white spaces and special characters
rName.remove(nIndex, 1);
rLen--;
return true;
}
return false;
}
OUString GetEnglishSearchFontName(std::u16string_view rInName)
{
OUStringBuffer rName(rInName);
@ -270,19 +289,8 @@ OUString GetEnglishSearchFontName(std::u16string_view rInName)
// not lowercase Ascii
else if ( (c < 'a') || (c > 'z') )
{
// To Lowercase-Ascii
if ( (c >= 'A') && (c <= 'Z') )
{
c += 'a' - 'A';
rName[ i ] = c;
}
else if( ((c < '0') || (c > '9')) && (c != ';') && (c != '(') && (c != ')') ) // not 0-9, semicolon, or brackets
{
// Remove white spaces and special characters
rName.remove(i,1);
nLen--;
continue;
}
if (toOnlyLowerAscii(c, rName, i, nLen))
continue;
}
i++;