summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-06-12 10:34:43 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-06-12 18:31:22 +0200
commit55eeffe768c6a80c97ee4f2a58fb467872ddeb1d (patch)
tree71a45a5b412a1098599a3258a0c0965899e63fb7 /unotools
parentab37d644773fe08d908a35fff14b9e6eefebbc55 (diff)
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>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/misc/fontdefs.cxx34
1 files changed, 21 insertions, 13 deletions
diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx
index 568110315f33..44147ffd0927 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -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++;