diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2017-02-11 19:06:51 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2017-02-11 11:14:59 +0000 |
commit | ad849f4bdad957dae30fa17975d9aac3ab5e8299 (patch) | |
tree | b9c17a807b12013522114bd9767f8cac6ffeb373 /starmath/source | |
parent | 258f2f439be7117d7ca57ec7eeabd3235e641375 (diff) |
starmath: Make stricter assertion to prevent out of range
Change-Id: I3ce0712e5095ade35628bad026a91a11dc6b9967
Reviewed-on: https://gerrit.libreoffice.org/34146
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/format.cxx | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/starmath/source/format.cxx b/starmath/source/format.cxx index ed0adca219b7..b169d24cc090 100644 --- a/starmath/source/format.cxx +++ b/starmath/source/format.cxx @@ -21,6 +21,7 @@ #include <vcl/svapp.hxx> #include <editeng/scripttypeitem.hxx> #include "format.hxx" +#include <cassert> // Latin default-fonts @@ -68,28 +69,20 @@ static const DefaultFontType aCTLDefFnts[FNT_END] = OUString GetDefaultFontName( LanguageType nLang, sal_uInt16 nIdent ) { - OSL_ENSURE( /*FNT_BEGIN <= nIdent &&*/ nIdent <= FNT_END, - "index out opd range" ); - - if (FNT_MATH == nIdent) - return OUString(FNTNAME_MATH); - else + assert(nIdent < FNT_END); + const DefaultFontType *pTable; + switch ( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) ) { - const DefaultFontType *pTable; - switch ( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) ) - { - case SvtScriptType::LATIN : pTable = aLatinDefFnts; break; - case SvtScriptType::ASIAN : pTable = aCJKDefFnts; break; - case SvtScriptType::COMPLEX : pTable = aCTLDefFnts; break; - default : - pTable = aLatinDefFnts; - SAL_WARN("starmath", "unknown script-type"); - } - - return OutputDevice::GetDefaultFont( - pTable[ nIdent ], nLang, - GetDefaultFontFlags::OnlyOne ).GetFamilyName(); + case SvtScriptType::LATIN : pTable = aLatinDefFnts; break; + case SvtScriptType::ASIAN : pTable = aCJKDefFnts; break; + case SvtScriptType::COMPLEX : pTable = aCTLDefFnts; break; + default : + pTable = aLatinDefFnts; + SAL_WARN("starmath", "unknown script-type"); } + + return OutputDevice::GetDefaultFont(pTable[ nIdent ], nLang, + GetDefaultFontFlags::OnlyOne ).GetFamilyName(); } |