fix text direction

This commit is contained in:
Dmitry Okunev
2025-12-25 12:30:33 +03:00
parent 0e02919540
commit 75477e8c03
7 changed files with 23 additions and 23 deletions

View File

@ -24,7 +24,7 @@ SOURCES += $$PWD/cconversionsmtoooxml.cpp \
$$PWD/cstarmathpars.cpp
HEADERS += \
$$PWD/TypeLanguage.h \
$$PWD/TextDirection.h \
$$PWD/cconversionsmtoooxml.h \
$$CORE_ROOT_DIR\OOXML\Base\Unit.h \
$$PWD/conversionmathformula.h \

View File

@ -0,0 +1,8 @@
namespace StarMath
{
enum class TextDirection
{
LeftToRight,
RightToLeft,
};
}

View File

@ -1,8 +0,0 @@
namespace StarMath
{
enum class TypeLanguage
{
Russian,
Arabic,
};
}

View File

@ -105,7 +105,7 @@ namespace StarMath {
m_pXmlWrite->WriteNodeEnd(L"m:oMath",false,false);
m_pXmlWrite->WriteNodeEnd(L"m:oMathPara",false,false);
}
void CConversionSMtoOOXML::StandartProperties(XmlUtils::CXmlWriter* pXmlWrite, CAttribute* pAttribute, const TypeConversion &enTypeConversion, const TypeLanguage &enTypeLang)
void CConversionSMtoOOXML::StandartProperties(XmlUtils::CXmlWriter* pXmlWrite, CAttribute* pAttribute, const TypeConversion &enTypeConversion, const TextDirection &enTypeLang)
{
if(TypeConversion::docx == enTypeConversion || TypeConversion::undefine == enTypeConversion)
{
@ -188,10 +188,10 @@ namespace StarMath {
pXmlWrite->WriteNodeBegin(L"w:strike",true);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
if(enTypeLang != TypeLanguage::Russian)
if(enTypeLang == TextDirection::RightToLeft)
{
switch (enTypeLang) {
case StarMath::TypeLanguage::Arabic:
case StarMath::TextDirection::RightToLeft:
{
pXmlWrite->WriteNodeBegin(L"w:rtl",true);
pXmlWrite->WriteNodeEnd(L"w",true,true);

View File

@ -40,7 +40,7 @@ namespace StarMath {
CConversionSMtoOOXML();
~CConversionSMtoOOXML();
void StartConversion(const std::vector<CElement*> arPars, const unsigned int& iAlignment = 1);
static void StandartProperties(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute,const TypeConversion& enTypeConversion, const TypeLanguage& enTypeLang = TypeLanguage::Russian);
static void StandartProperties(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute,const TypeConversion& enTypeConversion, const TextDirection& enTypeLang = TextDirection::LeftToRight);
static void PropertiesMFPR(const std::wstring& wsType,XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute,const TypeConversion &enTypeConversion);
static void PropertiesNaryPr(const TypeElement& enTypeOp,bool bEmptySub,bool bEmptySup,XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute,const TypeConversion &enTypeConversion,const bool& bEQN = false);
static void PropertiesFuncPr(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute,const TypeConversion &enTypeConversion);

View File

@ -915,7 +915,7 @@ namespace StarMath
}
//class methods CElementString
CElementString::CElementString(const std::wstring& wsTokenString,const TypeConversion &enTypeConversion)
:CElement(TypeElement::String,enTypeConversion),m_enTypeLang(TypeLanguage::Russian),m_wsString(wsTokenString)
:CElement(TypeElement::String,enTypeConversion),m_enTypeLang(TextDirection::LeftToRight),m_wsString(wsTokenString)
{
}
CElementString::~CElementString()
@ -939,21 +939,21 @@ namespace StarMath
break;
}
}
CheckingForArabicCharacters();
CheckingTextDirection();
pReader->ClearReader();
}
void CElementString::CheckingForArabicCharacters()
void CElementString::CheckingTextDirection()
{
bool bArabic;
bool bRightToLeft;
for(wchar_t cOneElement:m_wsString)
{
if(cOneElement <= 1791 && cOneElement >= 1536)
bArabic = true;
bRightToLeft = true;
else
return;
}
if(bArabic)
m_enTypeLang = TypeLanguage::Arabic;
if(bRightToLeft)
m_enTypeLang = TextDirection::RightToLeft;
}
void CElementString::ParseEQN(CStarMathReader *pReader)
{}

View File

@ -34,7 +34,7 @@
#define CSTARMATHPARS_H
#include "typeselements.h"
#include "typeConversion.h"
#include "TypeLanguage.h"
#include "TextDirection.h"
#include "TFormulaSize.h"
#include <iostream>
#include <vector>
@ -232,9 +232,9 @@ namespace StarMath
void Parse(CStarMathReader* pReader) override;
void ParseEQN(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
void CheckingForArabicCharacters();
void CheckingTextDirection();
TFormulaSize GetSize() override;
TypeLanguage m_enTypeLang;
TextDirection m_enTypeLang;
std::wstring m_wsString;
};