mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
fix text direction
This commit is contained in:
@ -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 \
|
||||
|
||||
8
OdfFile/Reader/Converter/StarMath2OOXML/TextDirection.h
Normal file
8
OdfFile/Reader/Converter/StarMath2OOXML/TextDirection.h
Normal file
@ -0,0 +1,8 @@
|
||||
namespace StarMath
|
||||
{
|
||||
enum class TextDirection
|
||||
{
|
||||
LeftToRight,
|
||||
RightToLeft,
|
||||
};
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
namespace StarMath
|
||||
{
|
||||
enum class TypeLanguage
|
||||
{
|
||||
Russian,
|
||||
Arabic,
|
||||
};
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
{}
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user