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>
This commit is contained in:
Takeshi Abe
2017-02-11 19:06:51 +09:00
parent 258f2f439b
commit ad849f4bda

View File

@@ -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();
}