Merge commit '835f4ba89db4bf52993519a88948923821db17be' into feature/odf-math-2

This commit is contained in:
Elena.Subbotina
2024-04-01 10:45:07 +03:00
15 changed files with 5457 additions and 18 deletions

View File

@ -19,6 +19,8 @@ include(../../../Common/base.pri)
#BOOST
include($$PWD/../../../Common/3dParty/boost/boost.pri)
include($$PWD/../../Reader/Converter/StarMath2OOXML/StarMath2OOXML.pri)
DEFINES += UNICODE \
_UNICODE \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -282,6 +282,8 @@
<ClCompile Include="..\..\Reader\Converter\pptx_text_context.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<ClCompile Include="..\..\Reader\Converter\StarMath2OOXML\cconversionsmtoooxml.cpp" />
<ClCompile Include="..\..\Reader\Converter\StarMath2OOXML\cstarmathpars.cpp" />
<ClCompile Include="..\..\Reader\Converter\xlsxconversioncontext.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
@ -675,6 +677,9 @@
<ClInclude Include="..\..\Reader\Converter\pptx_slide_context.h" />
<ClInclude Include="..\..\Reader\Converter\pptx_table_context.h" />
<ClInclude Include="..\..\Reader\Converter\pptx_text_context.h" />
<ClInclude Include="..\..\Reader\Converter\StarMath2OOXML\cconversionsmtoooxml.h" />
<ClInclude Include="..\..\Reader\Converter\StarMath2OOXML\cstarmathpars.h" />
<ClInclude Include="..\..\Reader\Converter\StarMath2OOXML\typeselements.h" />
<ClInclude Include="..\..\Reader\Converter\xlsxconversioncontext.h" />
<ClInclude Include="..\..\Reader\Converter\xlsx_alignment.h" />
<ClInclude Include="..\..\Reader\Converter\xlsx_border.h" />

View File

@ -25,6 +25,9 @@
<Filter Include="elements">
<UniqueIdentifier>{67b2bf43-5673-4a6f-82cb-fe4be01aee5f}</UniqueIdentifier>
</Filter>
<Filter Include="starmath">
<UniqueIdentifier>{7d3e34d2-a224-4d68-9144-4889bbcc3698}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\Reader\Format\abstract_xml.cpp">
@ -481,6 +484,12 @@
<ClCompile Include="..\..\Reader\Converter\pptx_animation_context.cpp">
<Filter>oox\pptx</Filter>
</ClCompile>
<ClCompile Include="..\..\Reader\Converter\StarMath2OOXML\cconversionsmtoooxml.cpp">
<Filter>starmath</Filter>
</ClCompile>
<ClCompile Include="..\..\Reader\Converter\StarMath2OOXML\cstarmathpars.cpp">
<Filter>starmath</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Reader\Format\abstract_xml.h">
@ -934,5 +943,14 @@
<ClInclude Include="..\..\Reader\Converter\pptx_animation_context.h">
<Filter>oox\pptx</Filter>
</ClInclude>
<ClInclude Include="..\..\Reader\Converter\StarMath2OOXML\cconversionsmtoooxml.h">
<Filter>starmath</Filter>
</ClInclude>
<ClInclude Include="..\..\Reader\Converter\StarMath2OOXML\cstarmathpars.h">
<Filter>starmath</Filter>
</ClInclude>
<ClInclude Include="..\..\Reader\Converter\StarMath2OOXML\typeselements.h">
<Filter>starmath</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,74 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
CMakeLists.txt.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe

View File

@ -0,0 +1,16 @@
CORE_ROOT_DIR = $$PWD/../../../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
ADD_DEPENDENCY(UnicodeConverter, kernel)
SOURCES += $$PWD/cconversionsmtoooxml.cpp \
$$PWD/cstarmathpars.cpp
HEADERS += \
$$PWD/cconversionsmtoooxml.h \
$$PWD/cstarmathpars.h \
$$PWD/typeselements.h

View File

@ -0,0 +1,11 @@
#include "cstarmathpars.h"
#include "cconversionsmtoooxml.h"
//int main()
//{
// std::wstring Temp = L"1 + 2 over 3";
// StarMath::CStarMathPars TempO;
// TempO.Pars(Temp);
// StarMath::CConversionSMtoOOXML m_oTest;
// m_oTest.StartConversion(TempO.GetVector());
//}

View File

@ -0,0 +1,18 @@
QT -= core gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CORE_ROOT_DIR = $$PWD/../../../../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/OdfFile/Reader/Converter/StarMath2OOXML/StarMath2OOXML.pri)
include($$CORE_ROOT_DIR/Common/3dParty/googletest/googletest.pri)
SOURCES += main.cpp
DESTDIR = $$PWD/build

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,410 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "cconversionsmtoooxml.h"
#include "../../../../DesktopEditor/common/File.h"
#include <fstream>
namespace StarMath {
CConversionSMtoOOXML::CConversionSMtoOOXML(): m_pXmlWrite(nullptr)
{
}
//check XMLWrite(if not nullptr == delete)
void CConversionSMtoOOXML::StartConversion(std::vector<StarMath::CElement*> arPars)
{
m_pXmlWrite = new XmlUtils::CXmlWriter;
m_pXmlWrite->WriteNodeBegin(L"m:oMathPara",false);
m_pXmlWrite->WriteNodeBegin(L"m:oMath",false);
for(CElement* oTempElement:arPars)
{
if(oTempElement != nullptr)
oTempElement->ConversionToOOXML(m_pXmlWrite);
}
EndConversion();
}
void CConversionSMtoOOXML::StandartProperties(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute)
{
if(pAttribute == nullptr)
{
//тут должны быть базовые свойства шрифта, задаваемые выше
pXmlWrite->WriteNodeBegin(L"w:rPr",false);
pXmlWrite->WriteNodeBegin(L"w:rFonts",true);
pXmlWrite->WriteAttribute(L"w:hAnsi",L"Cambria Math");
pXmlWrite->WriteAttribute(L"w:ascii",L"Cambria Math");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"w:sz",true);
pXmlWrite->WriteAttribute(L"w:val",L"40");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"w:szCs",true);
pXmlWrite->WriteAttribute(L"w:val",L"40");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeEnd(L"w:rPr",false,false);
}
else
{
std::wstring wsNameFont = pAttribute->GetFontName();
pXmlWrite->WriteNodeBegin(L"w:rPr",false);
pXmlWrite->WriteNodeBegin(L"w:rFonts",true);
if(!wsNameFont.empty())
{
pXmlWrite->WriteAttribute(L"w:hAnsi",wsNameFont);
pXmlWrite->WriteAttribute(L"w:ascii",wsNameFont);
}
else
{
pXmlWrite->WriteAttribute(L"w:hAnsi",L"Cambria Math");
pXmlWrite->WriteAttribute(L"w:ascii",L"Cambria Math");
}
pXmlWrite->WriteNodeEnd(L"w",true,true);
if(pAttribute->GetSize() == 0)
{
//тут должны быть базовые свойства шрифта, задаваемые выше - далее везде где не задано - аналогично
pXmlWrite->WriteNodeBegin(L"w:sz",true);
pXmlWrite->WriteAttribute(L"w:val",L"40");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"w:szCs",true);
pXmlWrite->WriteAttribute(L"w:val",L"40");
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
else if(pAttribute->GetSize() != 0)
{
pXmlWrite->WriteNodeBegin(L"w:sz",true);
pXmlWrite->WriteAttribute(L"w:val",std::to_wstring(pAttribute->GetSize()));
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"w:szCs",true);
pXmlWrite->WriteAttribute(L"w:val",std::to_wstring(pAttribute->GetSize()));
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
if(!pAttribute->EmptyColor())
{
pXmlWrite->WriteNodeBegin(L"w:color",true);
pXmlWrite->WriteAttribute(L"w:val",pAttribute->GetColor());
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
if(pAttribute->GetBold() && pAttribute->GetItal())
{
WriteStyNode(pXmlWrite,L"bi");
}
else if(pAttribute->GetBold())
{
pXmlWrite->WriteNodeBegin(L"m:sty", true);
pXmlWrite->WriteAttribute(L"m:val",L"b");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"w:b",true);
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"w:bCs",true);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
else if(pAttribute->GetItal())
{
pXmlWrite->WriteNodeBegin(L"w:i",true);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
if(pAttribute->GetStrike())
{
pXmlWrite->WriteNodeBegin(L"w:strike",true);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
pXmlWrite->WriteNodeEnd(L"w:rPr",false,false);
}
}
void CConversionSMtoOOXML::PropertiesMFPR(bool bType, XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:fPr",false);
if(bType)
{
pXmlWrite->WriteNodeBegin(L"m:type",true);
pXmlWrite->WriteAttribute(L"m:val",L"lin");
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
WriteCtrlPrNode(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeEnd(L"m:fPr",false,false);
}
void CConversionSMtoOOXML::PropertiesNaryPr(const TypeElement& enTypeOp,bool bEmptySub,bool bEmptySup,XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:naryPr",false);
switch(enTypeOp)
{
case TypeElement::sum:
{
WriteChrNode(L"\u2211",pXmlWrite);
break;
}
case TypeElement::prod:
WriteChrNode(L"\u220F",pXmlWrite);
break;
case TypeElement::coprod:
WriteChrNode(L"\u2210",pXmlWrite);
break;
case TypeElement::iint:
WriteChrNode(L"\u222C",pXmlWrite);
break;
case TypeElement::iiint:
WriteChrNode(L"\u222D",pXmlWrite);
break;
case TypeElement::lint:
WriteChrNode(L"\u222E",pXmlWrite);
break;
case TypeElement::llint:
WriteChrNode(L"\u222F",pXmlWrite);
break;
case TypeElement::lllint:
WriteChrNode(L"\u2230",pXmlWrite);
break;
default:
break;
}
WriteLimLocNode(L"undOvr",pXmlWrite);
if(bEmptySub)
{
pXmlWrite->WriteNodeBegin(L"m:subHide",true);
pXmlWrite->WriteAttribute(L"m:val",L"1");
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
if(bEmptySup)
{
pXmlWrite->WriteNodeBegin(L"m:supHide",true);
pXmlWrite->WriteAttribute(L"m:val",L"1");
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
WriteCtrlPrNode(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeEnd(L"m:naryPr",false,false);
}
void CConversionSMtoOOXML::WriteNodeConversion(const std::wstring &wsNameBlock, CElement *pValueBlock,XmlUtils::CXmlWriter* pXmlWrite)
{
if(pValueBlock != nullptr)
{
pXmlWrite->WriteNodeBegin(wsNameBlock,false);
pValueBlock->ConversionToOOXML(pXmlWrite);
pXmlWrite->WriteNodeEnd(wsNameBlock,false,false);
}
else
{
pXmlWrite->WriteNodeBegin(wsNameBlock,true);
pXmlWrite->WriteNodeEnd(L"",true,true);
}
/* pXmlWrite->WriteNodeBegin(wsNameBlock,false);
if(pValueBlock != nullptr)
pValueBlock->ConversionToOOXML(pXmlWrite);
pXmlWrite->WriteNodeEnd(wsNameBlock,false,false)*/;
}
std::wstring CConversionSMtoOOXML::GetOOXML()
{
return m_pXmlWrite->GetXmlString();
}
void CConversionSMtoOOXML::EndConversion()
{
m_pXmlWrite->WriteNodeEnd(L"m:oMath",false,false);
m_pXmlWrite->WriteNodeEnd(L"m:oMathPara",false,false);
}
void CConversionSMtoOOXML::PropertiesFuncPr(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:funcPr", false);
pXmlWrite->WriteNodeBegin(L"m:ctrlPr", false);
StandartProperties(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeEnd(L"m:ctrlPr", false,false);
pXmlWrite->WriteNodeEnd(L"m:funcPr",false,false);
}
void CConversionSMtoOOXML::PropertiesDPr(XmlUtils::CXmlWriter *pXmlWrite, const TypeElement &enTypeBracket,CAttribute* pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:dPr",false);
switch(enTypeBracket)
{
case TypeElement::langle:
BracketTypeNotation(L"\u2329",L"\u232A",pXmlWrite);
break;
case TypeElement::square:
BracketTypeNotation(L"\u005B",L"\u005D",pXmlWrite);
break;
case TypeElement::ldbracket:
BracketTypeNotation(L"\u27E6",L"\u27E7",pXmlWrite);
break;
case TypeElement::lbrace:
BracketTypeNotation(L"\u007B",L"\u007D",pXmlWrite);
break;
case TypeElement::lceil:
BracketTypeNotation(L"\u23A1",L"\u23A4",pXmlWrite);
break;
case TypeElement::lfloor:
BracketTypeNotation(L"\u23A3",L"\u23A6",pXmlWrite);
break;
case TypeElement::lline:
BracketTypeNotation(L"\u23AA",L"\u23AA",pXmlWrite);
break;
case TypeElement::ldline:
BracketTypeNotation(L"\u2016",L"\u2016",pXmlWrite);
break;
}
pXmlWrite->WriteNodeBegin(L"m:ctrlPr");
StandartProperties(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeEnd(L"m:ctrlPr",false,false);
pXmlWrite->WriteNodeEnd(L"m:dPr",false,false);
}
void CConversionSMtoOOXML::BracketTypeNotation(const std::wstring &wsOpenBracket, const std::wstring &wsCloseBracket, XmlUtils::CXmlWriter *pXmlWrite)
{
pXmlWrite->WriteNodeBegin(L"m:begChr", true);
pXmlWrite->WriteAttribute(L"m:val",wsOpenBracket);
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"m:endChr", true);
pXmlWrite->WriteAttribute(L"m:val", wsCloseBracket);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
void CConversionSMtoOOXML::PropertiesMPr(XmlUtils::CXmlWriter *pXmlWrite, const TypeElement &enTypeMatrix,CAttribute* pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:mPr",false);
pXmlWrite->WriteNodeBegin(L"m:mcs",false);
pXmlWrite->WriteNodeBegin(L"m:mc",false);
pXmlWrite->WriteNodeBegin(L"m:mcPr",false);
pXmlWrite->WriteNodeBegin(L"m:count",true);
switch(enTypeMatrix)
{
case TypeElement::matrix:
pXmlWrite->WriteAttribute(L"m:val",L"2");
break;
default:
pXmlWrite->WriteAttribute(L"m:val",L"1");
break;
}
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"m:mcJc",true);
pXmlWrite->WriteAttribute(L"m:val",L"center");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeEnd(L"m:mcPr",false,false);
pXmlWrite->WriteNodeEnd(L"m:mc",false,false);
pXmlWrite->WriteNodeEnd(L"m:mcs",false,false);
pXmlWrite->WriteNodeBegin(L"m:ctrlPr",false);
StandartProperties(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeEnd(L"m:ctrlPr",false,false);
pXmlWrite->WriteNodeEnd(L"m:mPr",false,false);
}
void CConversionSMtoOOXML::NodeGrade(XmlUtils::CXmlWriter *pXmlWrite,CElement* pValueGrade,CAttribute* pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:d",false);
pXmlWrite->WriteNodeBegin(L"m:dPr",false);
pXmlWrite->WriteNodeBegin(L"m:begChr",true);
pXmlWrite->WriteAttribute(L"m:val",L"");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"m:endChr",true);
pXmlWrite->WriteAttribute(L"m:val",L"\u23AA");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeBegin(L"m:ctrlPr",false);
StandartProperties(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeEnd(L"m:ctrlPr",false);
pXmlWrite->WriteNodeEnd(L"m:dPr",false,false);
pXmlWrite->WriteNodeBegin(L"m:e",false);
pValueGrade->ConversionToOOXML(pXmlWrite);
pXmlWrite->WriteNodeEnd(L"m:e",false,false);
pXmlWrite->WriteNodeEnd(L"m:d",false,false);
}
void CConversionSMtoOOXML::WriteCtrlPrNode(XmlUtils::CXmlWriter *pXmlWrite, CAttribute *pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:ctrlPr",false);
StandartProperties(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeEnd(L"m:ctrlPr",false,false);
}
void CConversionSMtoOOXML::WriteChrNode(const std::wstring &wsTypeOp,XmlUtils::CXmlWriter* pXmlWrite)
{
pXmlWrite->WriteNodeBegin(L"m:chr",true);
pXmlWrite->WriteAttribute(L"m:val",wsTypeOp);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
void CConversionSMtoOOXML::WriteLimLocNode(const std::wstring &wsTypeLimLock,XmlUtils::CXmlWriter* pXmlWrite)
{
pXmlWrite->WriteNodeBegin(L"m:limLoc",true);
pXmlWrite->WriteAttribute(L"m:val",wsTypeLimLock);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
void CConversionSMtoOOXML::WriteRPrFName(const TypeElement &enTypeOp, XmlUtils::CXmlWriter *pXmlWrite,CAttribute* pAttribute,const std::wstring& wsNameOp)
{
pXmlWrite->WriteNodeBegin(L"m:r",false);
pXmlWrite->WriteNodeBegin(L"m:rPr",false);
pXmlWrite->WriteNodeBegin(L"m:sty",true);
pXmlWrite->WriteAttribute(L"m:val",L"p");
pXmlWrite->WriteNodeEnd(L"w",true,true);
pXmlWrite->WriteNodeEnd(L"m:rPr",false,false);
CConversionSMtoOOXML::StandartProperties(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeBegin(L"m:t",false);
switch(enTypeOp)
{
case TypeElement::lim:
pXmlWrite->WriteString(L"lim");
break;
case TypeElement::liminf:
pXmlWrite->WriteString(L"lim inf");
break;
case TypeElement::limsup:
pXmlWrite->WriteString(L"lim sup");
break;
case TypeElement::oper:
pXmlWrite->WriteString(wsNameOp);
break;
default:
break;
}
pXmlWrite->WriteNodeEnd(L"m:t",false,false);
pXmlWrite->WriteNodeEnd(L"m:r",false,false);
}
void CConversionSMtoOOXML::WriteStyNode(XmlUtils::CXmlWriter *pXmlWrite, const std::wstring &wsAttributeNode)
{
pXmlWrite->WriteNodeBegin(L"m:sty", true);
pXmlWrite->WriteAttribute(L"m:val",wsAttributeNode);
pXmlWrite->WriteNodeEnd(L"w",true,true);
}
void CConversionSMtoOOXML::WritePreserveBlock(XmlUtils::CXmlWriter *pXmlWrite,CAttribute* pAttribute)
{
pXmlWrite->WriteNodeBegin(L"m:r",false);
StandartProperties(pXmlWrite,pAttribute);
pXmlWrite->WriteNodeBegin(L"m:t",true);
pXmlWrite->WriteAttribute(L"xml:space",L"preserve");
pXmlWrite->WriteNodeEnd(L"w",true,false);
pXmlWrite->WriteNodeEnd(L"m:t",false,false);
pXmlWrite->WriteNodeEnd(L"m:r",false,false);
}
void CConversionSMtoOOXML::WriteLimUpOrLowNode(XmlUtils::CXmlWriter *pXmlWrite,const std::wstring& wsNameNode,CElement* pValue, const TypeElement& enType,CAttribute* pAttribute,const std::wstring& wsName)
{
pXmlWrite->WriteNodeBegin(wsNameNode,false);
pXmlWrite->WriteNodeBegin(wsNameNode+L"Pr",false);
CConversionSMtoOOXML::WriteCtrlPrNode(pXmlWrite,nullptr);
pXmlWrite->WriteNodeEnd(wsNameNode+L"Pr",false,false);
pXmlWrite->WriteNodeBegin(L"m:e",false);
CConversionSMtoOOXML::WriteRPrFName(enType,pXmlWrite,pAttribute,wsName);
pXmlWrite->WriteNodeEnd(L"m:e",false,false);
WriteNodeConversion(L"m:lim",pValue,pXmlWrite);
pXmlWrite->WriteNodeEnd(wsNameNode,false,false);
}
void CConversionSMtoOOXML::ElementConversion(XmlUtils::CXmlWriter *pXmlWrite, CElement *pElement)
{
if(pElement!= nullptr)
pElement->ConversionToOOXML(pXmlWrite);
}
}

View File

@ -0,0 +1,68 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef CCONVERSIONSMTOOOXML_H
#define CCONVERSIONSMTOOOXML_H
#include "cstarmathpars.h"
#include "../../../../DesktopEditor/xml/include/xmlwriter.h"
namespace StarMath {
//delete XmlWrite
class CConversionSMtoOOXML
{
public:
CConversionSMtoOOXML();
void StartConversion(std::vector<CElement*> arPars);
static void StandartProperties(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute);
static void PropertiesMFPR(bool bType,XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute);
static void PropertiesNaryPr(const TypeElement& enTypeOp,bool bEmptySub,bool bEmptySup,XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute);
static void PropertiesFuncPr(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute);
static void WriteNodeConversion(const std::wstring& wsNameBlock,CElement* pValueBlock,XmlUtils::CXmlWriter* pXmlWrite);
static void PropertiesDPr(XmlUtils::CXmlWriter* pXmlWrite,const TypeElement& enTypeBracket,CAttribute* pAttribute);
static void PropertiesMPr(XmlUtils::CXmlWriter* pXmlWrite,const TypeElement& enTypeMatrix,CAttribute* pAttribute);
static void NodeGrade(XmlUtils::CXmlWriter* pXmlWrite,CElement* pValueGrade,CAttribute* pAttribute);
static void WriteCtrlPrNode(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute);
static void WriteChrNode(const std::wstring& wsTypeOp,XmlUtils::CXmlWriter* pXmlWrite);
static void WriteLimLocNode(const std::wstring& wsTypeLimLock,XmlUtils::CXmlWriter* pXmlWrite);
static void WriteRPrFName(const TypeElement& enTypeOp,XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute,const std::wstring& wsNameOp);
static void WriteStyNode(XmlUtils::CXmlWriter* pXmlWrite,const std::wstring& wsAttributeNode);
static void WritePreserveBlock(XmlUtils::CXmlWriter* pXmlWrite, CAttribute *pAttribute);
static void WriteLimUpOrLowNode(XmlUtils::CXmlWriter* pXmlWrite,const std::wstring& wsNameNode,CElement* pValue,const TypeElement& enType,CAttribute* pAttribute, const std::wstring& wsName = L"oper");
static void ElementConversion(XmlUtils::CXmlWriter* pXmlWrite,CElement* pElement);
void EndConversion();
std::wstring GetOOXML();
private:
static void BracketTypeNotation(const std::wstring& wsOpenBracket,const std::wstring& wsCloseBracket, XmlUtils::CXmlWriter* pXmlWrite);
XmlUtils::CXmlWriter* m_pXmlWrite;
};
}
#endif // CCONVERSIONSMTOOOXML_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,405 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef CSTARMATHPARS_H
#define CSTARMATHPARS_H
#include "typeselements.h"
#include <iostream>
#include <vector>
#include <iterator>
#include <stack>
#include <queue>
#include "../../../../DesktopEditor/xml/include/xmlwriter.h"
namespace StarMath
{
class CStarMathReader;
struct TBaseAttribute
{
int base_font_size = 12;
std::wstring base_font_name = L"Arial";
int base_alignment = 1;
bool base_font_bold = false;
bool base_font_italic = false;
};
class CAttribute
{
public:
CAttribute();
~CAttribute();
static TypeElement GetTypeColorAttribute(const std::wstring& wsToken);
static TypeElement GetTypeFontAttribute(const std::wstring& wsToken);
bool GetBold();
bool GetItal();
bool GetPhantom();
bool GetStrike();
unsigned int GetSize();
std::wstring GetColor();
const std::wstring& GetFontName();
bool EmptyColor();
void ParseFontAttribute(const TypeElement& enTypeFont,CStarMathReader* pReader);
void ParseColorAttribute(const std::wstring& wsToken,CStarMathReader* pReader);
void SetSize(const unsigned int& iSize);
void SetBold();
void SetItal();
void SetPhantom();
void SetStrike();
void SetColor(const TypeElement& enColor);
void SetColor(const std::wstring& wsColor);
void SetFont(const TypeElement& enFont);
void SetFontName(const std::wstring& wsNameFont);
private:
std::wstring m_wsColor;
bool m_bBold;
bool m_bItal;
bool m_bPhantom;
bool m_bStrike;
unsigned int m_iSize;
std::wstring m_wsNameFont;
};
//Сlass for working with tokens (reading, defining types, passing)
class CStarMathReader
{
public:
CStarMathReader(std::wstring::iterator& itStart, std::wstring::iterator& itEnd);
~CStarMathReader();
void GetToken();
//getting a subtype and setting the global type of a token to variables m_enUnderType and m_enGlobalType
void SetTypesToken();
//void SkipNextElement();
TypeElement GetGlobalType();
TypeElement GetLocalType();
std::wstring GetString();
//clearing a variable m_wsToken
void ClearReader();
bool CheckIteratorPosition();
bool EmptyString();
void SetAttribute(CAttribute* pAttribute);
CAttribute* GetAttribute();
void SetBaseAttribute(const TBaseAttribute* pAttribute);
CAttribute* GetBaseAttribute();
//The function returns a Token from a string (the iterator pointer m_itStart is on the next element)
std::wstring GetElement();
void FindingTheEndOfParentheses();
void IteratorNullification();
void ReadingTheNextToken();
private:
bool CheckTokenForGetElement(const wchar_t& cToken);
bool CheckIsalhpaForGetElement(const wchar_t& cToken,const wchar_t& cLastToken);
std::wstring::iterator m_itStart,m_itEnd;
TypeElement m_enGlobalType;
TypeElement m_enUnderType;
std::wstring m_wsToken;
CAttribute* m_pAttribute;
CAttribute* m_pBaseAttribute;
std::stack<std::wstring::iterator> m_stBracket;
};
class CElement
{
public:
CElement();
CElement(const TypeElement& enTypeBase);
virtual ~CElement();
virtual void Parse(CStarMathReader* pReader) = 0;
//The function creates the class we need (by determining the class type by a variable m_enGlobalType from the class CStarMathReader)
static CElement* CreateElement(CStarMathReader* pReader);
virtual void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) = 0;
virtual void SetAttribute(CAttribute* pAttribute) = 0;
void SetBaseAttribute(CAttribute* pAttribute);
void SetBaseType(const TypeElement& enType);
CAttribute* GetAttribute();
const TypeElement& GetBaseType();
private:
CAttribute* m_pAttribute;
TypeElement m_enBaseType;
};
class CElementIndex: public CElement
{
public:
CElementIndex(const TypeElement& enType);
virtual ~CElementIndex();
void SetValueIndex(CElement* pElement);
void SetLeftArg(CElement* pElement);
CElement* GetValueIndex();
CElement* GetLeftArg();
static TypeElement GetIndex(const std::wstring& wsCheckToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pValueIndex;
CElement* m_pLeftArg;
TypeElement m_enTypeIndex;
};
class CElementString: public CElement
{
public:
CElementString(const std::wstring& wsTokenString);
virtual ~CElementString();
void SetString(const std::wstring& wsTokenString);
std::wstring GetString();
static TypeElement GetDigit(const std::wstring& wsCheckToken);
static TypeElement GetWord(const std::wstring& wsToken);
void SetAttribute(CAttribute* pAttribute) override;
private:
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
std::wstring m_wsString;
};
class CElementBinOperator: public CElement
{
public:
CElementBinOperator(const TypeElement& enType);
virtual ~CElementBinOperator();
void SetLeftArg(CElement* pElement);
void SetRightArg(CElement* pElement);
void SetTypeBinOP(const TypeElement& enType);
CElement* GetRightArg();
CElement* GetLeftArg();
static TypeElement GetBinOperator(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
bool IsBinOperatorLowPrior();
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* oXmlWrite) override;
CElement* m_pLeftArgument;
CElement* m_pRightArgument;
TypeElement m_enTypeBinOp;
};
class CElementOperator: public CElement
{
public:
CElementOperator(const TypeElement& enType,const std::wstring& wsNameOp = L"");
virtual ~CElementOperator();
void SetValueOperator(CElement* pElement);
CElement* GetValueOperator();
void SetFromValue(CElement* pElement);
CElement* GetFromValue();
void SetToValue(CElement* pElement);
CElement* GetToValue();
void SetName(const std::wstring& wsNameOp);
std::wstring GetName();
static TypeElement GetOperator(const std::wstring& wsToken);
static TypeElement GetFromOrTo(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute);
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* oXmlWrite) override;
CElement* m_pValueOperator;
CElement* m_pValueFrom;
CElement* m_pValueTo;
TypeElement m_enTypeOperator;
std::wstring m_wsName;
};
class CElementGrade: public CElement
{
public:
CElementGrade();
virtual ~CElementGrade();
void SetValueGrade(CElement* pElement);
void SetValueFrom(CElement* pElement);
void SetValueTo(CElement* pElement);
static TypeElement GetGrade(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pValueGrade;
CElement* m_pValueFrom;
CElement* m_pValueTo;
};
class CElementBracket: public CElement
{
public:
CElementBracket(const TypeElement& enType);
virtual ~CElementBracket();
void SetBracketValue(const std::vector<CElement*>& arValue);
static TypeElement GetBracketOpen(const std::wstring& wsToken);
static TypeElement GetBracketClose(const std::wstring& wsToken);
std::vector<CElement*> GetBracketValue();
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;//
TypeElement m_enTypeBracket;
std::vector<CElement*> m_arBrecketValue;
};
class CElementBracketWithIndex: public CElement
{
public:
CElementBracketWithIndex(const TypeElement& enType);
virtual ~CElementBracketWithIndex();
void SetLeftArg(CElement* pElement);
void SetBracketValue(CElement* pElement);
CElement* GetLeftArg();
static TypeElement GetBracketWithIndex(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pLeftArg;
CElement* m_pValue;
TypeElement m_enTypeBracketWithIndex;
};
class CElementSetOperations: public CElement
{
public:
CElementSetOperations(const TypeElement& enType);
virtual ~CElementSetOperations();
void SetLeftArg(CElement* pElement);
CElement* GetLeftArg();
void SetRightArg(CElement* pElement);
CElement* GetRightArg();
static TypeElement GetSetOperation(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pLeftArgument;
CElement* m_pRightArgument;
TypeElement m_enTypeSet;
};
class CElementConnection: public CElement
{
public:
CElementConnection(const TypeElement& enType);
virtual ~CElementConnection();
void SetRightArg(CElement* pElement);
CElement* GetRightArg();
void SetLeftArg(CElement* pElement);
CElement* GetLeftArg();
static TypeElement GetConnection(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pLeftArgument;
CElement* m_pRightArgument;
TypeElement m_enTypeCon;
};
class CElementFunction: public CElement
{
public:
CElementFunction(const TypeElement& enType, const std::wstring& wsNameFunc = L"");
virtual ~CElementFunction();
void SetValueFunction(CElement* pElement);
CElement* GetValueFunction();
void SetNameFunc(const std::wstring& wsNameFunc);
std::wstring GetNameFuncInString();
static TypeElement GetFunction(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pValue;
std::wstring m_wsNameFunc;
TypeElement m_enTypeFunction;
};
class CElementSpecialSymbol: public CElement
{
public:
CElementSpecialSymbol(const TypeElement& enType);
virtual ~CElementSpecialSymbol();
static TypeElement GetSpecialSymbol(std::wstring& wsToken);
void SetValue(CElement* pValue);
const TypeElement GetType();
private:
void SetTypeSymbol();
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pValue;
TypeElement m_enTypeSpecial;
std::wstring m_wsType;
};
class CElementMatrix: public CElement
{
public:
CElementMatrix(const TypeElement& enType);
virtual ~CElementMatrix();
void SetFirstArgument(CElement* pElement);
void SetSecondArgument(CElement* pElement);
static TypeElement GetMatrix(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader *pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pFirstArgument;
CElement* m_pSecondArgument;
TypeElement m_enTypeMatrix;
};
class CElementDiacriticalMark: public CElement
{
public:
CElementDiacriticalMark(const TypeElement& enType);
virtual ~CElementDiacriticalMark();
void SetValueMark(CElement* pValue);
static TypeElement GetMark(const std::wstring& wsToken);
private:
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
CElement* m_pValueMark;
TypeElement m_enTypeMark;
};
class CParserStarMathString
{
public:
std::vector<CElement*> Parse(std::wstring& wsParseString, const TBaseAttribute* pBaseAttribute = nullptr);
static CElement* ParseElement(CStarMathReader* pReader);
//Function for adding a left argument (receives the argument itself and the element to which it needs to be added as input. Works with classes:CElementBinOperator,CElementConnection,CElementSetOperation).
static bool AddLeftArgument(CElement* pLeftArg,CElement* pElementWhichAdd);
static bool CheckForLeftArgument(const TypeElement& enType );
static CElement* ReadingWithoutBracket(CStarMathReader* pReader);
private:
std::vector<CElement*> m_arEquation;
};
}
#endif // CSTARMATHPARS_H

View File

@ -0,0 +1,367 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef TYPESELEMENTS_H
#define TYPESELEMENTS_H
namespace StarMath
{
enum class TypeElement{
undefine,
//global
String,
BinOperator,
SetOperations,
Operator,
Bracket,
BracketWithIndex,
Grade,
Mark,
UnarSign,
Attribute,
SpecialSymbol,
Function,
Operation,
Index,
Matrix,
Connection,
Empty,
//binoop
cdot,
times,
over,
plus,
minus,
frac,
div,
multipl,
division,
oplus,
ominus,
odot,
otimes,
odivide,
circ,
wideslash,
widebslash,
//logic
And,
Or,
neg,
//unary
plus_minus,
minus_plus,
//op
lim,
sum,
liminf,
limsup,
prod,
coprod,
Int,
iint,
iiint,
lint,
llint,
lllint,
oper,
//brace
brace,
round,
square,
ldbracket,
lbrace,
langle,
lceil,
lfloor,
lline,
ldline,
//attribute
ital,
bold,
phantom,
overstrike,
size,
font,
//top element
acute,
breve,
dot,
dddot,
vec,
tilde,
check,
grave,
circle,
ddot,
bar,
harpoon,
hat,
widevec,
widetilde,
overline,
wideharpoon,
widehat,
underline,//top elements
color,
hex,
rgb,
black,
green,
aqua,
yellow,
lime,
navy,
purple,
teal,
blue,
red,
fuchsia,
gray,
maroon,
olive,
silver,
coral,
midnightblue,
crimson,
violet,
orange,
seagreen,
hotpink,
orangered,
indigo,
lavender,
//color(without rgb and hex)
mline,
dlgrid,
//setopetions
intersection,
Union,
setminus,
setquotient,
subseteq,
subset,
supset,
supseteq,
nsubset,
nsupseteq,
nsupset,
nsubseteq,
in,
notin,
owns,
//connection
approx,
sim,
simeq,
equiv,
prop,
parallel,
ortho,
divides,
ndivides,
toward,
transl,
transr,
def,
equals,
notequals,
learrow,
learrowequals,
leslant,
riarrow,
riarrowequals,
geslant,
dllearrow,
dlriarrow,
prec,
succ,
preccurlyeq,
succcurlyeq,
precsim,
succsim,
nprec,
nsucc,
dlarrow,
dlrarrow,
drarrow,
//SpecialSymbol
emptyset,
aleph,
setN,
setZ,
setQ,
setR,
setC,
grid,
transition,
emptiness,
interval,
infinity,
partial,
nabla,
exists,
notexists,
forall,
hbar,
lambdabar,
Re,
Im,
wp,
laplace,
fourier,
backepsilon,
alpha,
zeta,
lambda,
pi,
phi,
alpha_small,
varepsilon,
iota_small,
xi,
varrho,
phi_small,
beta,
eta,
mu,
rho,
chi,
beta_small,
zeta_small,
kappa,
omicron,
sigma,
varphi,
gamma,
theta,
nu,
sigma_small,
psi,
gamma_small,
eta_small,
lambda_small,
pi_small,
varsigma,
chi_small,
delta,
iota,
xi_small,
tau,
omega,
delta_small,
theta_small,
mu_small,
varpi,
tau_small,
psi_small,
epsilon,
kappa_small,
omicron_small,
upsilon,
epsilon_small,
vartheta,
nu_small,
rho_small,
upsilon_small,
omega_small,
perthousand,
angle,
rightarrow,
leftarrow,
uparrow,
downarrow,
dotsaxis,
dotsvert,
dotsup,
dotsdown,
dotslow,
newline,
//function
abs,
fact,
sqrt,
nroot,//nroot?
sin,
cos,
tan,
cot,
sinh,
cosh,
tanh,
coth,
arcsin,
arccos,
arctan,
arccot,
arsinh,
arcosh,
artanh,
arcoth,
ln,
exp,
log,
func,
//index
upper,
lower,
lsup,
lsub,
csup,
csub,
//
binom,
stack,
matrix,
//bracket close
rwbrace,
rbrace,
rround,
rsquare,
rdbracket,
rangle,
rceil,
rfloor,
rline,
rdline,
right,
//op
from,
to,
//bracketWithIndex
overbrace,
underbrace,
//grade
evaluate,
};
}
#endif // TYPESELEMENTS_H

View File

@ -31,6 +31,7 @@
*/
#include "math_elements.h"
#include "../Converter/StarMath2OOXML/cconversionsmtoooxml.h"
namespace cpdoccore {
@ -93,10 +94,39 @@ void math_semantics::add_child_element( xml::sax * Reader, const std::wstring &
void math_semantics::oox_convert(oox::math_context & Context)
{
for (size_t i = 0 ; i < content_.size(); i++)
math_annotation* annotation = dynamic_cast<math_annotation*>(annotation_.get());
math_annotation_xml* annotation_xml = dynamic_cast<math_annotation_xml*>(annotation_.get());
std::wstring annotation_text;
if ((annotation) && (annotation->text_)) annotation_text = *annotation->text_;
else if ((annotation_xml) && (annotation_xml->text_)) annotation_text = *annotation_xml->text_;
bool result = false;
if (!annotation_text.empty())
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
result = true;
StarMath::CParserStarMathString parser;
StarMath::CConversionSMtoOOXML converter;
// базовые свойства шрифта для математики
/*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_name_;
/*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_size_;
/*parser.set*/ /*?*/ /*converter.set*/ Context.base_alignment_;
/*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_italic_;
/*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_bold_;
/*result = */converter.StartConversion(parser.Parse(annotation_text));
Context.output_stream() << converter.GetOOXML();
}
if (!result)
{
for (size_t i = 0; i < content_.size(); i++)
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
}
}
}
@ -126,11 +156,6 @@ void math_annotation::add_text(const std::wstring & Text)
text_ = Text;
}
void math_annotation::oox_convert(oox::math_context & Context)
{
}
//----------------------------------------------------------------------------------------------------
const wchar_t * math_annotation_xml::ns = L"math";
const wchar_t * math_annotation_xml::name = L"annotation-xml";
@ -157,10 +182,6 @@ void math_annotation_xml::add_text(const std::wstring & Text)
text_ = Text;
}
void math_annotation_xml::oox_convert(oox::math_context & Context)
{
}
//----------------------------------------------------------------------------------------------------
}

View File

@ -119,16 +119,16 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMathAnnotation;
virtual void oox_convert(oox::math_context & Context);
virtual void oox_convert(oox::math_context& Context) {}
_CP_OPT(std::wstring) text_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
_CP_OPT(std::wstring) encoding_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) encoding_;
};
CP_REGISTER_OFFICE_ELEMENT2(math_annotation);
@ -142,15 +142,15 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMathAnnotationXml;
virtual void oox_convert(oox::math_context & Context);
virtual void oox_convert(oox::math_context& Context) {}
_CP_OPT(std::wstring) text_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
_CP_OPT(std::wstring) encoding_;
};