vcl/source/gdi/CommonSalLayout.cxx | 45 +++++++++---------------------------- 1 file changed, 12 insertions(+), 33 deletions(-)
New commits: commit 0c49ab77067413901f8e2956fbdbc45671384b73 Author: Khaled Hosny <khaledho...@eglug.org> Date: Wed Dec 14 17:51:33 2016 +0200 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 <c...@libreoffice.org> Reviewed-by: Khaled Hosny <khaledho...@eglug.org> diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index af8ebfa..956bad0 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits