fix conversion overstrike

This commit is contained in:
Dmitry Okunev
2025-05-30 16:13:13 +03:00
parent bed33af917
commit d044959b0d
3 changed files with 28 additions and 24 deletions

View File

@ -324,21 +324,17 @@ namespace StarMath
m_pXmlWrite->WriteNodeBegin(L"mtable",false);
m_pXmlWrite->WriteNodeBegin(L"mtr",false);
m_pXmlWrite->WriteNodeBegin(L"mtd",false);
m_wsAnnotationStarMath += L"{ ";
ConversionVectorWritingElement(pMf->m_oNum.GetPointer()->m_arrItems);
CheckVectorElementsForMf(pMf->m_oNum.GetPointer()->m_arrItems);
COOXml2Odf::ComparisonSizeByWidth(stFrac,m_stSize);
m_stSize.Zeroing();
m_wsAnnotationStarMath += L"} ";
m_pXmlWrite->WriteNodeEnd(L"mtd",false,false);
m_pXmlWrite->WriteNodeEnd(L"mtr",false,false);
m_pXmlWrite->WriteNodeBegin(L"mtr",false);
m_pXmlWrite->WriteNodeBegin(L"mtd",false);
m_wsAnnotationStarMath += L"{ ";
ConversionVectorWritingElement(pMf->m_oDen.GetPointer()->m_arrItems);
CheckVectorElementsForMf(pMf->m_oDen.GetPointer()->m_arrItems);
COOXml2Odf::ComparisonSizeByWidth(stFrac,m_stSize);
COOXml2Odf::ComparisonSizeByHeight(stStart,stFrac);
m_stSize = stStart;
m_wsAnnotationStarMath += L"} ";
m_pXmlWrite->WriteNodeEnd(L"mtd",false,false);
m_pXmlWrite->WriteNodeEnd(L"mtr",false,false);
m_pXmlWrite->WriteNodeEnd(L"mtable",false,false);
@ -349,41 +345,37 @@ namespace StarMath
if(stPr.m_wsTypeName == L"skw")
{
m_pXmlWrite->WriteAttribute(L"bevelled",L"true");
m_pXmlWrite->WriteNodeEnd(L"w",true,true);
m_wsAnnotationStarMath += L"{ ";
ConversionVectorWritingElement(pMf->m_oNum.GetPointer()->m_arrItems);
m_pXmlWrite->WriteNodeEnd(L"w",true,false);
CheckVectorElementsForMf(pMf->m_oNum.GetPointer()->m_arrItems);
COOXml2Odf::ComparisonSizeByWidth(stFrac,m_stSize);
m_stSize.Zeroing();
m_wsAnnotationStarMath += L"} wideslash { ";
ConversionVectorWritingElement(pMf->m_oDen.GetPointer()->m_arrItems);
m_wsAnnotationStarMath += L"wideslash ";
CheckVectorElementsForMf(pMf->m_oDen.GetPointer()->m_arrItems);
COOXml2Odf::ComparisonSizeByWidth(stFrac,m_stSize);
COOXml2Odf::ComparisonSizeByHeight(stStart,stFrac);
m_stSize = stStart;
m_wsAnnotationStarMath += L"} ";
}
else
{
m_pXmlWrite->WriteNodeEnd(L"w",true,false);
m_wsAnnotationStarMath += L"{ ";
ConversionVectorWritingElement(pMf->m_oNum.GetPointer()->m_arrItems);
CheckVectorElementsForMf(pMf->m_oNum.GetPointer()->m_arrItems);
COOXml2Odf::ComparisonSizeByWidth(stFrac,m_stSize);
m_stSize.Zeroing();
m_wsAnnotationStarMath += L"} over { ";
ConversionVectorWritingElement(pMf->m_oDen.GetPointer()->m_arrItems);
m_wsAnnotationStarMath += L"over ";
CheckVectorElementsForMf(pMf->m_oDen.GetPointer()->m_arrItems);
COOXml2Odf::ComparisonSizeByWidth(stFrac,m_stSize);
COOXml2Odf::ComparisonSizeByHeight(stStart,stFrac);
m_stSize = stStart;
m_wsAnnotationStarMath += L"} ";
}
m_pXmlWrite->WriteNodeEnd(L"mfrac",false,false);
}
else
{
m_pXmlWrite->WriteNodeBegin(L"mrow",false);
ConversionVectorWritingElement(pMf->m_oNum.GetPointer()->m_arrItems);
CheckVectorElementsForMf(pMf->m_oNum.GetPointer()->m_arrItems);
RecordingMoNode(L"/",m_pXmlWrite);
m_wsAnnotationStarMath += L"/ ";
ConversionVectorWritingElement(pMf->m_oDen.GetPointer()->m_arrItems);
CheckVectorElementsForMf(pMf->m_oDen.GetPointer()->m_arrItems);
COOXml2Odf::ComparisonSizeByHeight(m_stSize,stStart);
m_pXmlWrite->WriteNodeEnd(L"mrow",false,false);
}
@ -1050,6 +1042,17 @@ namespace StarMath
else
return false;
}
void COOXml2Odf::CheckVectorElementsForMf(std::vector<OOX::WritingElement*> arWrElement)
{
if(!arWrElement.empty())
{
m_wsAnnotationStarMath += L"{ ";
ConversionVectorWritingElement(arWrElement);
m_wsAnnotationStarMath += L"} ";
}
else
COOXml2Odf::EmptyBlock(m_pXmlWrite,m_wsAnnotationStarMath,m_stSize);
}
TFormulaSize COOXml2Odf::GetFormulaSize()
{
return m_stSize;
@ -1655,8 +1658,6 @@ namespace StarMath
}
void COOXml2Odf::StyleClosing(const StStyleMenClose &stStyle, XmlUtils::CXmlWriter *pXmlWrite)
{
if(stStyle.m_bMenClose)
pXmlWrite->WriteNodeEnd(L"menclose",false,false);
if(stStyle.m_bUnderlineClose)
{
pXmlWrite->WriteNodeBegin(L"mo",false);
@ -1664,6 +1665,8 @@ namespace StarMath
pXmlWrite->WriteNodeEnd(L"mo",false,false);
pXmlWrite->WriteNodeEnd(L"munder",false,false);
}
if(stStyle.m_bMenClose)
pXmlWrite->WriteNodeEnd(L"menclose",false,false);
if(stStyle.m_iStyle != 0)
{
unsigned int k(0);

View File

@ -146,6 +146,7 @@ namespace StarMath
void CreateAttribute(StValuePr*& pAttribute);
StarMath::TypeFont FontCheck(const std::wstring& wsFont, bool& bAttribute);
static bool ColorCheck(const std::wstring& wsColor,std::wstring& wsRecordColor);
void CheckVectorElementsForMf(std::vector<OOX::WritingElement*> arWrElement);
TFormulaSize GetFormulaSize();
void EndOdf();
std::wstring GetOdf();

View File

@ -112,7 +112,7 @@ TEST(OOXml2OdfTest,FractionWideslash)
StMath StCorrect,StResult;
StResult.m_wsSemantic = oTest.GetOdf();
StResult.m_wsAnnotation = oTest.GetAnnotation();
StCorrect.m_wsSemantic = L"<mfrac bevelled=\"true\" /><mn>1</mn><mn>2</mn></mfrac>";
StCorrect.m_wsSemantic = L"<mfrac bevelled=\"true\"><mn>1</mn><mn>2</mn></mfrac>";
StCorrect.m_wsAnnotation = L"{ 1 } wideslash { 2 } ";
EXPECT_EQ(StResult,StCorrect);
}
@ -128,7 +128,7 @@ TEST(OOXml2OdfTest,FractionSlash)
StResult.m_wsSemantic = oTest.GetOdf();
StResult.m_wsAnnotation = oTest.GetAnnotation();
StCorrect.m_wsSemantic = L"<mrow><mn>1</mn><mo stretchy=\"false\">/</mo><mn>2</mn></mrow>";
StCorrect.m_wsAnnotation = L"1 / 2 ";
StCorrect.m_wsAnnotation = L"{ 1 } / { 2 } ";
EXPECT_EQ(StResult,StCorrect);
}
TEST(OOXml2OdfTest,Delimiter)
@ -549,7 +549,7 @@ TEST(OOXml2OdfTest,EmptyNumerator)
pElement->fromXML(oReader);
StarMath::COOXml2Odf oTest;
oTest.StartConversion(pElement);
std::wstring wsOdf = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mfrac><mn>2</mn></mfrac><annotation encoding=\"StarMath 5.0\">{ } over { 2 } </annotation></semantics></math>";
std::wstring wsOdf = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mfrac><mi mathvariant=\"normal\">\u2751</mi><mn>2</mn></mfrac><annotation encoding=\"StarMath 5.0\">{\u0026lt;\u003F\u0026gt;} over { 2 } </annotation></semantics></math>";
EXPECT_EQ(oTest.GetOdf(),wsOdf);
}
TEST(OOXml2OdfTest,IdentityMatrixDiagonally)