[Libreoffice-commits] core.git: starmath/source

Takeshi Abe tabe at fixedpoint.jp
Sat Feb 11 11:15:21 UTC 2017


 starmath/source/format.cxx |   33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

New commits:
commit ad849f4bdad957dae30fa17975d9aac3ab5e8299
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sat Feb 11 19:06:51 2017 +0900

    starmath: Make stricter assertion to prevent out of range
    
    Change-Id: I3ce0712e5095ade35628bad026a91a11dc6b9967
    Reviewed-on: https://gerrit.libreoffice.org/34146
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/source/format.cxx b/starmath/source/format.cxx
index ed0adca..b169d24 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();
 }
 
 


More information about the Libreoffice-commits mailing list