summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2016-12-14 17:51:33 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2016-12-16 14:58:30 +0000
commit0c49ab77067413901f8e2956fbdbc45671384b73 (patch)
tree7eedfad2bc3121a225ac52f29923f7f2d14b8013
parentab291ac3b8576a086cab60ffb64d60b046a271a2 (diff)
Simplify CommonSalLayout::ParseFeatures()
Use OString::getToken() instead of manually tokenizing the string. Change-Id: I2647dc2be1343de8ae0adf581260f5e06364ef79 Reviewed-on: https://gerrit.libreoffice.org/32015 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx45
1 files changed, 12 insertions, 33 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index af8ebfa55898..956bad0dbbe4 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -131,50 +131,29 @@ static hb_unicode_funcs_t* getUnicodeFuncs()
}
#endif
-void CommonSalLayout::ParseFeatures(const OUString& name)
+void CommonSalLayout::ParseFeatures(const OUString& aName)
{
- int nFeatures = 0;
- int nStart = name.indexOf(FontSelectPatternAttributes::FEAT_PREFIX);
- if (nStart < 0)
+ if (aName.indexOf(FontSelectPatternAttributes::FEAT_PREFIX) < 0)
return;
- OString oName = OUStringToOString(name, RTL_TEXTENCODING_ASCII_US);
- for (int nNext = nStart; nNext > 0; nNext = name.indexOf(FontSelectPatternAttributes::FEAT_SEPARATOR, nNext + 1))
+
+ OString sName = OUStringToOString(aName, RTL_TEXTENCODING_ASCII_US);
+ sName = sName.getToken(1, FontSelectPatternAttributes::FEAT_PREFIX);
+ sal_Int32 nIndex = 0;
+ do
{
- if (name.match("lang=", nNext + 1))
+ OString sToken = sName.getToken(0, FontSelectPatternAttributes::FEAT_SEPARATOR, nIndex);
+ if (sToken.startsWith("lang="))
{
- int endamp = name.indexOf(FontSelectPatternAttributes::FEAT_SEPARATOR, nNext+1);
- int enddelim = name.indexOf(' ', nNext+1);
- int end = name.getLength();
- if (endamp < 0)
- {
- if (enddelim > 0)
- end = enddelim;
- }
- else if (enddelim < 0 || endamp < enddelim)
- end = endamp;
- else
- end = enddelim;
- msLanguage = oName.copy(nNext + 6, end - nNext - 6);
+ msLanguage = sToken.getToken(1, '=');
}
else
- ++nFeatures;
- }
- if (nFeatures == 0)
- return;
-
- maFeatures.reserve(nFeatures);
- for (int nThis = nStart, nNext = name.indexOf(FontSelectPatternAttributes::FEAT_SEPARATOR, nStart + 1);
- nThis > 0;
- nThis = nNext, nNext = name.indexOf(FontSelectPatternAttributes::FEAT_SEPARATOR, nNext + 1))
- {
- if (!name.match("lang=", nThis + 1))
{
- int end = nNext > 0 ? nNext : name.getLength();
hb_feature_t aFeature;
- if (hb_feature_from_string(oName.getStr() + nThis + 1, end - nThis - 1, &aFeature))
+ if (hb_feature_from_string(sToken.getStr(), sToken.getLength(), &aFeature))
maFeatures.push_back(aFeature);
}
}
+ while (nIndex >= 0);
}
#if defined(_WIN32)