diff --git a/starmath/CppunitTest_starmath_export.mk b/starmath/CppunitTest_starmath_export.mk index 442a90718352..b59df8c35d6c 100644 --- a/starmath/CppunitTest_starmath_export.mk +++ b/starmath/CppunitTest_starmath_export.mk @@ -17,6 +17,7 @@ $(eval $(call gb_CppunitTest_set_include,starmath_export,\ $(eval $(call gb_CppunitTest_use_externals,starmath_export,\ boost_headers \ libxml2 \ + icuuc \ )) $(eval $(call gb_CppunitTest_use_sdk_api,starmath_export)) diff --git a/starmath/CppunitTest_starmath_qa_cppunit.mk b/starmath/CppunitTest_starmath_qa_cppunit.mk index 6a5cf437a6e1..87ebe58083dd 100644 --- a/starmath/CppunitTest_starmath_qa_cppunit.mk +++ b/starmath/CppunitTest_starmath_qa_cppunit.mk @@ -14,7 +14,10 @@ $(eval $(call gb_CppunitTest_set_include,starmath_qa_cppunit,\ -I$(SRCDIR)/starmath/inc \ )) -$(eval $(call gb_CppunitTest_use_external,starmath_qa_cppunit,boost_headers)) +$(eval $(call gb_CppunitTest_use_externals,starmath_qa_cppunit,\ + boost_headers \ + icuuc \ +)) $(eval $(call gb_CppunitTest_use_sdk_api,starmath_qa_cppunit)) diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index aa824cee5890..b50cef47e3dd 100644 --- a/starmath/Library_sm.mk +++ b/starmath/Library_sm.mk @@ -29,6 +29,7 @@ $(eval $(call gb_Library_add_defs,sm,\ $(eval $(call gb_Library_use_externals,sm, \ boost_headers \ icu_headers \ + icuuc \ )) $(eval $(call gb_Library_use_custom_headers,sm,\ diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index e0b597306509..b637fea76d6a 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -876,8 +876,6 @@ public: */ class SmSpecialNode : public SmTextNode { - bool mbIsFromGreekSymbolSet; - protected: SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 _nFontDesc); diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index b0b91dabe99e..695e1b4e3a8c 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -28,6 +28,8 @@ #include #include #include +#include +#include namespace { @@ -2148,32 +2150,14 @@ void SmMathSymbolNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat) /**************************************************************************/ -static bool lcl_IsFromGreekSymbolSet( std::u16string_view aTokenText ) -{ - bool bRes = false; - - // valid symbol name needs to have a '%' at pos 0 and at least an additional char - if (aTokenText.size() > 2 && aTokenText[0] == u'%') - { - SmSym *pSymbol = SM_MOD()->GetSymbolManager().GetSymbolByName(aTokenText.substr(1)); - if (pSymbol && SmLocalizedSymbolData::GetExportSymbolSetName(pSymbol->GetSymbolSetName()) == "Greek") - bRes = true; - } - - return bRes; -} - - SmSpecialNode::SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 _nFontDesc) : SmTextNode(eNodeType, rNodeToken, _nFontDesc) - , mbIsFromGreekSymbolSet(lcl_IsFromGreekSymbolSet( rNodeToken.aText )) { } SmSpecialNode::SmSpecialNode(const SmToken &rNodeToken) - : SmTextNode(SmNodeType::Special, rNodeToken, FNT_MATH) // default Font isn't always correct! - , mbIsFromGreekSymbolSet(lcl_IsFromGreekSymbolSet( rNodeToken.aText )) + : SmTextNode(SmNodeType::Special, rNodeToken, FNT_VARIABLE) // default Font isn't always correct! { } @@ -2185,12 +2169,24 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell const SmSym *pSym; SmModule *pp = SM_MOD(); + bool bIsGreekSymbol = false; + bool bIsSpecialSymbol = false; + bool bIsArabic = false; + if (nullptr != (pSym = pp->GetSymbolManager().GetSymbolByName(GetToken().aText.subView(1)))) { sal_UCS4 cChar = pSym->GetCharacter(); OUString aTmp( &cChar, 1 ); SetText( aTmp ); GetFont() = pSym->GetFace(&rFormat); + + OUString aSymbolSetName = SmLocalizedSymbolData::GetExportSymbolSetName(pSym->GetSymbolSetName()); + if (aSymbolSetName == "Greek") + bIsGreekSymbol = true; + else if (aSymbolSetName == "Special") + bIsSpecialSymbol = true; + else if (aSymbolSetName == "Arabic") + bIsArabic = true; } else { @@ -2212,23 +2208,31 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell Flags() |= FontChangeMask::Face; - if (!mbIsFromGreekSymbolSet) + sal_uInt32 cChar = 0; + if (!GetText().isEmpty()) + { + sal_Int32 nIndex = 0; + cChar = GetText().iterateCodePoints(&nIndex); + if (!bIsArabic) + bIsArabic = u_getIntPropertyValue(cChar, UCHAR_SCRIPT) == USCRIPT_ARABIC; + } + + if (!bIsGreekSymbol && !bIsSpecialSymbol && !bIsArabic) return; - OSL_ENSURE( GetText().getLength() == 1, "a symbol should only consist of 1 char!" ); + // Arabic and special symbols should not be italic, + // Greek is italic only in some cases. bool bItalic = false; - sal_Int16 nStyle = rFormat.GetGreekCharStyle(); - OSL_ENSURE( nStyle >= 0 && nStyle <= 2, "unexpected value for GreekCharStyle" ); - if (nStyle == 1) - bItalic = true; - else if (nStyle == 2) + if (bIsGreekSymbol) { - const OUString& rTmp(GetText()); - if (!rTmp.isEmpty()) + sal_Int16 nStyle = rFormat.GetGreekCharStyle(); + OSL_ENSURE( nStyle >= 0 && nStyle <= 2, "unexpected value for GreekCharStyle" ); + if (nStyle == 1) + bItalic = true; + else if (nStyle == 2) { static const sal_Unicode cUppercaseAlpha = 0x0391; static const sal_Unicode cUppercaseOmega = 0x03A9; - sal_Unicode cChar = rTmp[0]; // uppercase letters should be straight and lowercase letters italic bItalic = cUppercaseAlpha > cChar || cChar > cUppercaseOmega; }