mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-16 00:59:02 +08:00
Сhange of architecture
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#include "cconversionsmtoooxml.h"
|
||||
#include "../../../../DesktopEditor/common/File.h"
|
||||
#include <fstream>
|
||||
namespace StarMath {
|
||||
/*namespace StarMath {
|
||||
CConversionSMtoOOXML::CConversionSMtoOOXML()
|
||||
{
|
||||
}
|
||||
@ -14,17 +14,17 @@ namespace StarMath {
|
||||
ConversionOneElement(m_oTempElement);
|
||||
}
|
||||
EndConversion();
|
||||
// NSFile::CFileBinary oFile;
|
||||
// oFile.CreateFileW(L"Test.txt");
|
||||
// oFile.WriteStringUTF8(m_oXmlWrite.GetXmlString());
|
||||
// oFile.CloseFile();
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(L"Test.txt");
|
||||
oFile.WriteStringUTF8(m_oXmlWrite.GetXmlString());
|
||||
oFile.CloseFile();
|
||||
}
|
||||
void CConversionSMtoOOXML::ConversionOneElement(CElement *m_oElement)
|
||||
{
|
||||
switch (m_oElement->GetType())
|
||||
{
|
||||
case Number:
|
||||
ConversNumber(dynamic_cast<CNumber*>(m_oElement));
|
||||
case Text:
|
||||
ConversText(dynamic_cast<CText*>(m_oElement));
|
||||
break;
|
||||
case BinOperator:
|
||||
ConversBinOperator(dynamic_cast<CBinaryOperator*> (m_oElement));
|
||||
@ -40,7 +40,7 @@ namespace StarMath {
|
||||
{
|
||||
if(m_oElement->GetTypeBin() == plus || m_oElement->GetTypeBin() == minus || m_oElement->GetTypeBin() == multipl || m_oElement->GetTypeBin() == cdot || m_oElement->GetTypeBin() == times || m_oElement->GetTypeBin() == div || m_oElement->GetTypeBin() == odivide || m_oElement->GetTypeBin() == oplus || m_oElement->GetTypeBin() == ominus || m_oElement->GetTypeBin() == odot || m_oElement->GetTypeBin() == otimes)
|
||||
{
|
||||
ConversionOneElement(m_oElement->GetLeftArg());
|
||||
ConversionOneElement(m_oElement->GetFirstElement());
|
||||
m_oXmlWrite.WriteNodeBegin(L"m:r",false);
|
||||
StandartProperties();
|
||||
m_oXmlWrite.WriteNodeBegin(L"m:t",false);
|
||||
@ -80,9 +80,9 @@ namespace StarMath {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(m_oElement->GetTypeRight() == Number)
|
||||
if(m_oElement->GetTypeSecondElement() == Text)
|
||||
{
|
||||
CNumber* m_oNumber = dynamic_cast<CNumber*> (m_oElement->GetRightArg());
|
||||
CText* m_oNumber = dynamic_cast<CText*> (m_oElement->GetSecondElement());
|
||||
m_oXmlWrite.WriteString(m_oNumber->GetValue());
|
||||
m_oXmlWrite.WriteNodeEnd(L"m:t",false,false);
|
||||
m_oXmlWrite.WriteNodeEnd(L"m:r",false,false);
|
||||
@ -91,7 +91,7 @@ namespace StarMath {
|
||||
{
|
||||
m_oXmlWrite.WriteNodeEnd(L"m:t",false,false);
|
||||
m_oXmlWrite.WriteNodeEnd(L"m:r",false,false);
|
||||
ConversionOneElement(m_oElement->GetRightArg());
|
||||
ConversionOneElement(m_oElement->GetSecondElement());
|
||||
}
|
||||
|
||||
}
|
||||
@ -100,12 +100,12 @@ namespace StarMath {
|
||||
m_oXmlWrite.WriteNodeBegin(L"m:f",false);
|
||||
if(m_oElement->GetTypeBin() == division) PropertiesMFPR(true,L"lin");
|
||||
else PropertiesMFPR(false,L"");
|
||||
BlockRecording(L"m:num",m_oElement->GetLeftArg());
|
||||
BlockRecording(L"m:den",m_oElement->GetRightArg());
|
||||
BlockRecording(L"m:num",m_oElement->GetFirstElement());
|
||||
BlockRecording(L"m:den",m_oElement->GetSecondElement());
|
||||
m_oXmlWrite.WriteNodeEnd(L"m:f",false,false);
|
||||
}
|
||||
}
|
||||
void CConversionSMtoOOXML::ConversNumber(CNumber *m_oElement)
|
||||
void CConversionSMtoOOXML::ConversText(CText *m_oElement)
|
||||
{
|
||||
m_oXmlWrite.WriteNodeBegin(L"m:r",false);
|
||||
StandartProperties();
|
||||
@ -225,3 +225,4 @@ namespace StarMath {
|
||||
m_oXmlWrite.WriteNodeEnd(L"m:oMathPara",false,false);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@ -5,25 +5,25 @@
|
||||
|
||||
|
||||
|
||||
namespace StarMath {
|
||||
class CConversionSMtoOOXML
|
||||
{
|
||||
public:
|
||||
CConversionSMtoOOXML();
|
||||
//friend class StarMath::CStarMathPars;
|
||||
void StartConversion(std::vector<CElement*> arPars);
|
||||
void StandartProperties();
|
||||
void PropertiesMFPR(bool bType,const std::wstring& wsType);
|
||||
void PropertiesNaryPr(const std::wstring& wsTypeOperator,bool bEmptySub,bool bEmptySup);
|
||||
void ConversionOneElement(CElement* m_oElement);
|
||||
void ConversBinOperator(CBinaryOperator* m_oElement);
|
||||
void ConversNumber(CNumber* m_oElement);
|
||||
void ConversOperator(COperator* m_oElement);
|
||||
void BlockRecording(const std::wstring& wsNameBlock,CElement* CValueBlock);
|
||||
void EndConversion();
|
||||
std::wstring GetOOXML() ;
|
||||
private:
|
||||
XmlUtils::CXmlWriter m_oXmlWrite;
|
||||
};
|
||||
}
|
||||
//namespace StarMath {
|
||||
// class CConversionSMtoOOXML
|
||||
// {
|
||||
// public:
|
||||
// CConversionSMtoOOXML();
|
||||
// //friend class StarMath::CStarMathPars;
|
||||
// void StartConversion(std::vector<CElement*> arPars);
|
||||
// void StandartProperties();
|
||||
// void PropertiesMFPR(bool bType,const std::wstring& wsType);
|
||||
// void PropertiesNaryPr(const std::wstring& wsTypeOperator,bool bEmptySub,bool bEmptySup);
|
||||
// void ConversionOneElement(CElement* m_oElement);
|
||||
// void ConversBinOperator(CBinaryOperator* m_oElement);
|
||||
// void ConversText(CText* m_oElement);
|
||||
// void ConversOperator(COperator* m_oElement);
|
||||
// void BlockRecording(const std::wstring& wsNameBlock,CElement* CValueBlock);
|
||||
// void EndConversion();
|
||||
// std::wstring GetOOXML() ;
|
||||
// private:
|
||||
// XmlUtils::CXmlWriter m_oXmlWrite;
|
||||
// };
|
||||
//}
|
||||
#endif // CCONVERSIONSMTOOOXML_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -11,203 +11,82 @@ namespace StarMath
|
||||
class CAttribute
|
||||
{
|
||||
public:
|
||||
CAttribute();
|
||||
CAttribute(const TypeAttributeTop& enType);
|
||||
virtual ~CAttribute();
|
||||
void SetTypeAtt(const std::wstring& wsCheckToken);
|
||||
TypeAttributeTop GetTypeAtt();
|
||||
CAttribute(const TypeElement& enType);
|
||||
~CAttribute();
|
||||
static TypeElement IsAttribute(const std::wstring& wsToken);
|
||||
TypeElement GetType();
|
||||
private:
|
||||
TypeAttributeTop enTypeTop{noneTop};
|
||||
TypeAttributeColor enTypeColor{noneColor};
|
||||
bool bBold{false};
|
||||
bool bItal{false};
|
||||
bool bPhantom{false};
|
||||
TypeElement enTypeAttr;
|
||||
};
|
||||
|
||||
class CElement
|
||||
{
|
||||
public:
|
||||
CElement();
|
||||
virtual ~CElement();
|
||||
virtual std::wstring GetValue() = 0;
|
||||
virtual TypeElement GetType() = 0;
|
||||
void SetAttribute(CAttribute* m_oCAttribute);
|
||||
TypeAttributeTop GetTypeAttribute();
|
||||
virtual void Pars(std::wstring::iterator& itStart,std::wstring::iterator& itEnd) = 0;
|
||||
//принимает подтип (over, frac и т.д) и создает нужный нам класс(внутри уже идет проверка по классам)
|
||||
static CElement* CreateElement(const std::wstring& wsToken);
|
||||
//static TypeElement GetTypeElement(const std::wstring& wsToken);
|
||||
void SetAttribute(const std::vector<CAttribute*> arAttr);
|
||||
private:
|
||||
CAttribute* oCAttribute;
|
||||
};
|
||||
class CSpecialSymbol: public CElement
|
||||
{
|
||||
public:
|
||||
CSpecialSymbol(const std::wstring& wsToken);
|
||||
virtual ~CSpecialSymbol();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
private:
|
||||
TypeSymbol enTypeSpecial;
|
||||
};
|
||||
class CNumber: public CElement
|
||||
{
|
||||
public:
|
||||
CNumber();
|
||||
CNumber(const std::wstring& wsValue);
|
||||
virtual ~CNumber();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override ;
|
||||
private:
|
||||
std::wstring m_wsValueNumber;
|
||||
std::vector<CAttribute*> arElementAttributes;
|
||||
};
|
||||
|
||||
class CUnarySign: public CElement
|
||||
class CElementString: public CElement
|
||||
{
|
||||
public:
|
||||
CUnarySign();
|
||||
~CUnarySign();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
CUnarySign* GetUnarSign(const std::wstring& wsUnarToken);
|
||||
CElementString(const std::wstring& wsTokenString);
|
||||
virtual ~CElementString();
|
||||
void SetString(const std::wstring& wsTokenString);
|
||||
void Pars(std::wstring::iterator& itStart,std::wstring::iterator& itEnd) override;
|
||||
std::wstring GetString();
|
||||
static bool IsDigit(const std::wstring& wsCheckToken);
|
||||
private:
|
||||
std::wstring m_wsUnar;
|
||||
TypeElement m_enUnarType = UnarSign;
|
||||
std::wstring wsString;
|
||||
};
|
||||
|
||||
class CArgumentContainer: public CElement
|
||||
class CElementBinOperator: public CElement
|
||||
{
|
||||
public:
|
||||
CArgumentContainer();
|
||||
virtual ~CArgumentContainer();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
void SetArgument(CElement* oValue);
|
||||
CElement* GetArgument();
|
||||
private:
|
||||
CElement* oArgument;
|
||||
};
|
||||
|
||||
class CBinaryOperator: public CArgumentContainer
|
||||
{
|
||||
public:
|
||||
CBinaryOperator();
|
||||
CBinaryOperator(const std::wstring& wsToken);
|
||||
virtual ~CBinaryOperator();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
TypeBinOperator GetTypeBin();
|
||||
void SetRightArg(CElement* oArgument);
|
||||
void SetTypeBin(const TypeBinOperator& enType);
|
||||
CElementBinOperator(const TypeElement& enType);
|
||||
virtual ~CElementBinOperator();
|
||||
void Pars(std::wstring::iterator& itStart,std::wstring::iterator& itEnd) override;
|
||||
void SetLeftArg(CElement* pElement);
|
||||
void SetRightArg(CElement* pElement);
|
||||
void SetTypeBinOP(const TypeElement& enType);
|
||||
CElement* GetRightArg();
|
||||
TypeElement GetTypeRight();
|
||||
CElement* GetLeftArg();
|
||||
static bool IsBinOperator(const TypeElement& enCheckType);
|
||||
private:
|
||||
CElement* oRightArg;
|
||||
TypeBinOperator enTypeBinOp;
|
||||
bool IsLowPriorityBinOp(const TypeElement& enType);
|
||||
bool IsHighPriorityBinOp(const TypeElement& enType);
|
||||
CElement* pLeftArgument;
|
||||
CElement* pRightArgument;
|
||||
TypeElement enTypeBinOp;
|
||||
};
|
||||
class COperator: public CElement
|
||||
|
||||
class CElementBracket: public CElement
|
||||
{
|
||||
public:
|
||||
COperator();
|
||||
COperator(const std::wstring& wsToken);
|
||||
virtual ~COperator();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
TypeOperator GetTypeOp();
|
||||
void SetTypeOp(const TypeOperator& enType);
|
||||
void SetFrom(CElement* oFrom);
|
||||
void SetTo(CElement* oTo);
|
||||
void SetValueOp(CElement* oValue);
|
||||
CElement* GetValueOp();
|
||||
CElement* GetFrom();
|
||||
CElement* GetTo();
|
||||
CElementBracket(const TypeElement& enType);
|
||||
virtual ~CElementBracket();
|
||||
void SetBracketValue(const std::vector<CElement*>& arValue);
|
||||
void Pars(std::wstring::iterator& itStart,std::wstring::iterator& itEnd) override;
|
||||
private:
|
||||
TypeOperator enTypeOp;
|
||||
CElement* oFromValue{nullptr};
|
||||
CElement* oToValue{nullptr};
|
||||
CElement* oValueOp{nullptr};
|
||||
static bool IsBracketClose(const std::wstring& wsToken);
|
||||
TypeElement enTypeBracket;
|
||||
std::vector<CElement*> arBrecketValue;
|
||||
};
|
||||
class CBracket: public CElement
|
||||
|
||||
class CParseStarMathString
|
||||
{
|
||||
public:
|
||||
CBracket();
|
||||
CBracket(const std::vector<CElement*>& arValue,const std::wstring& wsCheckToken);
|
||||
virtual ~CBracket();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
void SetScalable();
|
||||
void SetBracketVal(const std::vector<CElement*>& arBrecketValue);
|
||||
void SetTypeBracket(const std::wstring& wsCheckToken);
|
||||
std::vector<CElement*> Parse(std::wstring& wsParseString);
|
||||
static CElement* ParsElement(std::wstring::iterator& itStart, std::wstring::iterator& itEnd);
|
||||
static std::wstring GetElement(std::wstring::iterator& itStart,std::wstring::iterator& itEnd);
|
||||
static bool CheckingTheNextElement(std::wstring::iterator& itStart,std::wstring::iterator& itEnd, bool (&func)(const std::wstring&));
|
||||
private:
|
||||
bool bScalable{false};
|
||||
TypeBracket enTypeBracket;
|
||||
std::vector<CElement*> arBrecketVal;
|
||||
};
|
||||
class CFunction: public CArgumentContainer
|
||||
{
|
||||
public:
|
||||
CFunction();
|
||||
virtual ~CFunction();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
TypeFunction GetTypeFun();
|
||||
void SetTypeFunction(const std::wstring& wsCheckToken);
|
||||
private:
|
||||
TypeFunction enTypeFun;
|
||||
};
|
||||
class CIndex: public CArgumentContainer
|
||||
{
|
||||
public:
|
||||
CIndex(const std::wstring& wsToken);
|
||||
virtual ~CIndex();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
void SetIndex(CElement* oValueIndex);
|
||||
CElement* GetIndex();
|
||||
private:
|
||||
TypeIndex enTypeIn;
|
||||
CElement* oIndex;
|
||||
};
|
||||
class CMatrix: public CArgumentContainer
|
||||
{
|
||||
public:
|
||||
CMatrix(const std::wstring& wsToken);
|
||||
virtual ~CMatrix();
|
||||
std::wstring GetValue() override;
|
||||
TypeElement GetType() override;
|
||||
private:
|
||||
TypeMatrix enTypeMatrix;
|
||||
};
|
||||
class CStarMathPars
|
||||
{
|
||||
public:
|
||||
CStarMathPars();
|
||||
virtual ~CStarMathPars();
|
||||
std::vector<CElement*> GetVector();
|
||||
void Pars(std::wstring& wsStarMathLine);
|
||||
std::wstring GetElement(std::wstring::iterator& itFirst,std::wstring::iterator& itEnd);
|
||||
CElement* ParsElement(std::wstring::iterator& itFirst, std::wstring::iterator& itEnd, std::vector<CElement*>& arParsLine);
|
||||
CElement* ReadWithoutBrackets(std::wstring::iterator& itFirst, std::wstring::iterator& itEnd,std::vector<CElement*>& arParsLine);
|
||||
bool CheckDigit(const std::wstring& wsCheckToken);
|
||||
//bool CheckUnarSign(std::wstring& wsCheckToken,CUnarySign& oUnarSign);
|
||||
static bool CheckBinOperator(const std::wstring& wsCheckToken);
|
||||
static bool CheckBinOperatorLowPriority(const std::wstring& wsCheckToken);
|
||||
static bool CheckPlusOrMinus(const std::wstring& wsCheckToken);
|
||||
bool CheckOperator(const std::wstring& wsCheckToken);
|
||||
static bool CheckIndex(const std::wstring& wsCheckToken);
|
||||
bool CheckIndexOp(const std::wstring& wsCheckToken);
|
||||
bool CheckBracketOpen(const std::wstring& wsCheckToken);
|
||||
static bool CheckBracketClose(const std::wstring& wsCheckToken);
|
||||
static bool CheckScalable_NotScalableBracketLeft(const std::wstring& wsCheckToken);
|
||||
static bool CheckScalable_NotScalableBracketRight(const std::wstring& wsCheckToken);
|
||||
bool CheckTopAttribute(const std::wstring& wsCheckToken);
|
||||
bool CheckPropertiesAttribute(const std::wstring& wsCheckToken);
|
||||
static bool CheckColorAttribute(const std::wstring& wsCheckToken);
|
||||
bool CheckSpecialCharacter(const std::wstring& wsCheckToken);
|
||||
bool CheckSpecialOperation(const std::wstring& wsCheckToken);//doing first
|
||||
bool CheckSpecialConnection(const std::wstring& wsCheckToken);// doint first
|
||||
bool CheckingTheNextElement(std::wstring::iterator& itFirst, std::wstring::iterator& itEnd,bool (&func)(const std::wstring& wsCheckToken));
|
||||
bool CheckFunction(const std::wstring& wsCheckToken);
|
||||
bool CheckOperation(const std::wstring& wsCheckToken);
|
||||
bool CheckMatrix(const std::wstring& wsCheckToken);
|
||||
void PrintAr();
|
||||
private:
|
||||
std::vector<CElement*> m_arParsLine;
|
||||
std::vector<CElement*> arEquation;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
#define TYPESELEMENTS_H
|
||||
namespace StarMath
|
||||
{
|
||||
enum TypeElement{
|
||||
Number,
|
||||
enum class TypeElement{
|
||||
undefine,
|
||||
//global
|
||||
String,
|
||||
BinOperator,
|
||||
Operator,
|
||||
Bracket,
|
||||
@ -15,9 +17,7 @@ enum TypeElement{
|
||||
Operation,
|
||||
Index,
|
||||
Matrix,
|
||||
};
|
||||
enum TypeBinOperator
|
||||
{
|
||||
//binoop
|
||||
cdot,
|
||||
times,
|
||||
over,
|
||||
@ -35,14 +35,10 @@ enum TypeBinOperator
|
||||
circ,
|
||||
wideslash,
|
||||
widebslash,
|
||||
};
|
||||
enum TypeOperator
|
||||
{
|
||||
//op
|
||||
lim,
|
||||
sum,
|
||||
};
|
||||
enum TypeBracket
|
||||
{
|
||||
//brace
|
||||
brace,
|
||||
round,
|
||||
square,
|
||||
@ -53,10 +49,10 @@ enum TypeBracket
|
||||
lfloor,
|
||||
lline,
|
||||
ldline,
|
||||
};
|
||||
enum TypeAttributeTop
|
||||
{
|
||||
noneTop,
|
||||
//attribute
|
||||
ital,
|
||||
bold,
|
||||
//top element
|
||||
acute,
|
||||
breve,
|
||||
dot,
|
||||
@ -77,10 +73,7 @@ enum TypeAttributeTop
|
||||
wideharpoon,
|
||||
widehat,
|
||||
underline,//top elements
|
||||
};
|
||||
enum TypeAttributeColor
|
||||
{
|
||||
noneColor,
|
||||
color,
|
||||
black,
|
||||
green,
|
||||
aqua,
|
||||
@ -99,10 +92,14 @@ enum TypeAttributeColor
|
||||
coral,
|
||||
midnightblue,
|
||||
crimson,
|
||||
violet,//color(without rgb and hex)
|
||||
};
|
||||
enum TypeSymbol
|
||||
{
|
||||
violet,
|
||||
orange,
|
||||
seagreen,
|
||||
hotpink,
|
||||
orangered,
|
||||
indigo,
|
||||
lavender,
|
||||
//color(without rgb and hex)
|
||||
mline,
|
||||
grid,
|
||||
dlgrid,
|
||||
@ -155,9 +152,27 @@ enum TypeSymbol
|
||||
dlarrow,
|
||||
dlrarrow,
|
||||
drarrow,
|
||||
};
|
||||
enum TypeFunction
|
||||
{
|
||||
emptyset,
|
||||
aleph,
|
||||
setN,
|
||||
setZ,
|
||||
setQ,
|
||||
setR,
|
||||
setC,
|
||||
infinity,
|
||||
partial,
|
||||
nabla,
|
||||
exists,
|
||||
notexists,
|
||||
forall,
|
||||
hbar,
|
||||
lambdabar,
|
||||
Re,
|
||||
Im,
|
||||
wp,
|
||||
laplace,
|
||||
fourier,
|
||||
backepsilon,
|
||||
abs,
|
||||
fact,
|
||||
sqrt,
|
||||
@ -181,18 +196,12 @@ enum TypeFunction
|
||||
ln,
|
||||
exp,
|
||||
log,
|
||||
};
|
||||
enum TypeIndex
|
||||
{
|
||||
upper,
|
||||
lower,
|
||||
lsup,
|
||||
lsub,
|
||||
csup,
|
||||
csub,
|
||||
};
|
||||
enum TypeMatrix
|
||||
{
|
||||
binom,
|
||||
stack,
|
||||
matrix,
|
||||
|
||||
Reference in New Issue
Block a user