Commit 47a2551b authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Добавлены парсер старого формата формул (Equation Word2003). Добавлен тестовый...

Добавлены парсер старого формата формул (Equation Word2003). Добавлен тестовый пример, который записывает формулы в XML.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58106 954022d7-b5bf-4e40-9824-e11837661b57
parent 8e6097ac
......@@ -356,6 +356,69 @@ Common/ASCDocxFormat/Lib/Release/XML.lib svn_mime_002dtype=application%2Foctet-s
Common/DocxFormat/Source/CompoundDocument svnc_tsvn_003alogminsize=5
Common/DocxFormat/Source/CompoundDocument/detail svnc_tsvn_003alogminsize=5
Common/DocxFormat/Source/DocxFormat/Diagram svnc_tsvn_003alogminsize=5
Common/DocxFormat/Source/MathEquation svnc_tsvn_003alogminsize=5
Common/DocxFormat/Source/MathEquation/Examples svnc_tsvn_003alogminsize=5
Common/DocxFormat/Source/MathEquation/Examples/oleObject1.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject10.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject11.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject12.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject13.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject14.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject15.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject16.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject17.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject18.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject19.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject2.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject20.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject21.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject22.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject23.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject24.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject25.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject26.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject27.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject28.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject29.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject3.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject30.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject31.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject32.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject33.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject34.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject35.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject36.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject37.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject38.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject39.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject4.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject40.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject41.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject42.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject43.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject44.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject45.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject46.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject47.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject48.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject49.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject5.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject50.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject51.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject52.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject53.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject54.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject55.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject56.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject57.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject58.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject59.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject6.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject60.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject7.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject8.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/Examples/oleObject9.bin svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/MathEquation/MathEquationTest svnc_tsvn_003alogminsize=5
Common/DocxFormat/Source/SystemUtility/Solution/FileSystemTest/app.ico svn_mime_002dtype=application%2Foctet-stream
Common/DocxFormat/Source/XML/libxml2/LIBXML2_LIB_TEST svnc_tsvn_003alogminsize=5
Common/DocxFormat/Source/XML/libxml2/XML/doc/DOM.gif svn_mime_002dtype=application%2Foctet-stream
......
#ifndef _MATHEQUATION_LESTREAM
#define _MATHEQUATION_LESTREAM
#include "..\CompoundDocument\pole.h"
#include "Types.h"
namespace MathEquation
{
template<class StreamBase>
class CLEStream
{
public :
CLEStream(StreamBase *pStream) : pBuffer(NULL)
{
if (NULL == pStream)
return;
pStream->seek(0, std::ios_base::end);
unsigned int unFileSize = (unsigned int)pStream->tellg();
pStream->seek(0);
pBuffer = new BYTE[unFileSize];
if (!pBuffer)
return;
pStream->read(pBuffer, unFileSize);
pCur = pBuffer;
pEnd = pBuffer + unFileSize;
}
~CLEStream()
{
if (NULL != pBuffer)
delete pBuffer;
}
void operator>>(uint8_t &nValue)
{
nValue = ReadUInt8();
}
void operator>>(uint16_t &nValue)
{
nValue = ReadUInt16();
}
void operator>>(uint32_t &nValue)
{
nValue = ReadUInt32();
}
void operator>>(int8_t &nValue)
{
nValue = ReadUInt8();
}
void operator>>(int16_t &nValue)
{
nValue = Read_UInt16();
}
bool IsValid() const
{
if (NULL == pBuffer)
return false;
return true;
}
bool IsEof() const
{
if (pCur >= pEnd)
return true;
return false;
}
uint8_t ReadUInt8()
{
if (pCur + 1 >= pEnd)
return 0;
uint8_t unResult = pCur[0];
pCur++;
return unResult;
}
uint16_t ReadUInt16()
{
if (pCur + 2 >= pEnd)
return 0;
uint16_t ushResult = (pCur[0]) | ((pCur[1]) << 8);
pCur += 2;
return ushResult;
}
uint32_t ReadUInt32()
{
if (pCur + 4 >= pEnd)
return 0;
uint32_t unResult = (uint32_t)((pCur[0]<< 0) | ((pCur[1]) << 8) | ((pCur[2]) << 16) | ((pCur[3]) << 24));
pCur += 4;
return unResult;
}
uint32_t Tell()
{
return (uint32_t)(pCur - pBuffer);
}
void SeekRel(uint32_t nPos)
{
pCur += nPos;
}
private:
BYTE *pBuffer;
BYTE *pCur;
BYTE *pEnd;
};
}
#endif
\ No newline at end of file
This diff is collapsed.
#ifndef _MATH_EQUATION_READER_H
#define _MATH_EQUATION_READER_H
#include "..\CompoundDocument\pole.h"
#include "Types.h"
#include "LEStream.h"
#include "String.h"
#include "OutputDev.h"
using namespace POLE;
namespace MathEquation
{
class CEquationReader
{
public:
CEquationReader(const wchar_t* wsFilePath) : m_oStorage(wsFilePath), pS(NULL), nHAlign(0), nVAlign(0)
{
InitSizes();
}
~CEquationReader()
{
if (NULL != pS)
delete pS;
}
void SetOutputDev(IOutputDev *pOutput)
{
pOutputDev = pOutput;
InitFonts();
}
int Parse();
private:
enum MTOKENS
{
END = 0x00,
LINE = 0x01,
CHAR = 0x02,
TMPL = 0x03,
PILE = 0x04,
MATRIX = 0x05,
EMBEL = 0x06,
RULER = 0x07,
FONT = 0x08,
SIZE_CUSTOM = 0x09,
SIZE_REGULAR = 0x0a, //
SIZE_BIGSCRIPT = 0x0b, //
SIZE_SMALLSCRIT = 0x0c, //
SIZE_BIGSYMBOL = 0x0d, //
SIZE_SMALLSYMBOL = 0x0e //
};
private:
void InitSizes();
void InitFonts();
int HandleRecords();
inline int xfLMOVE (BYTE nTest) {return nTest & 0x80;}
inline int xfAUTO (BYTE nTest) {return nTest & 0x10;}
inline int xfEMBELL(BYTE nTest) {return nTest & 0x20;}
inline int xfNULL (BYTE nTest) {return nTest & 0x10;}
inline int xfLSPACE(BYTE nTest) {return nTest & 0x40;}
inline int xfRULER (BYTE nTest) {return nTest & 0x20;}
void HandleNudge();
int HandleChar(uint8_t nTag);
int HandleTemplate();
void HandleStartTemplate(uint8_t nSelector, uint8_t nVariation);
void HandleEndTemplate (uint8_t nSelector, uint8_t nVariation);
int HandlePile();
int HandleMatrix();
void HandleEmblishments();
void HandleSetSize(MTOKENS eType);
void HandleRuler();
void HandleFont();
bool IsSpecialChar(Unicode_t nChar);
private:
// Header
struct
{
uint32_t nCBHdr;
uint16_t nVersion;
uint16_t nCf;
uint32_t nCBObject;
uint32_t nReserved1;
uint32_t nReserved2;
uint32_t nReserved3;
uint32_t nReserved4;
} oHeader;
// Ver 2 Header
uint8_t nVersion;
uint8_t nPlatform;
uint8_t nProduct;
uint8_t nProdVersion;
uint8_t nProdSubVersion;
Storage m_oStorage;
CLEStream<Stream> *pS;
IOutputDev* pOutputDev;
uint16_t aSizeTable[7];
uint8_t nHAlign;
uint8_t nVAlign;
TFontMap mFontMap;
};
}
#endif
// MathEquationTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "..\MathEquation.h"
#include "..\StringOutput.h"
using namespace MathEquation;
int main()
{
CStringOutput oStringOutput;
CEquationReader oReader(_T("..\\Examples\\oleObject60.bin"));
oReader.SetOutputDev(&oStringOutput);
oReader.Parse();
return 0;
}

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathEquationTest", "MathEquationTest.vcproj", "{DF62D134-666F-4701-ADF7-7E6C7C5B07BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DF62D134-666F-4701-ADF7-7E6C7C5B07BC}.Debug|Win32.ActiveCfg = Debug|Win32
{DF62D134-666F-4701-ADF7-7E6C7C5B07BC}.Debug|Win32.Build.0 = Debug|Win32
{DF62D134-666F-4701-ADF7-7E6C7C5B07BC}.Release|Win32.ActiveCfg = Release|Win32
{DF62D134-666F-4701-ADF7-7E6C7C5B07BC}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="MathEquationTest"
ProjectGUID="{DF62D134-666F-4701-ADF7-7E6C7C5B07BC}"
RootNamespace="MathEquationTest"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\MathEquationTest.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\LEStream.h"
>
</File>
<File
RelativePath="..\MathEquation.cpp"
>
</File>
<File
RelativePath="..\MathEquation.h"
>
</File>
<File
RelativePath="..\OutputDev.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath="..\String.h"
>
</File>
<File
RelativePath="..\StringOutput.h"
>
</File>
<File
RelativePath="..\Types.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
========================================================================
CONSOLE APPLICATION : MathEquationTest Project Overview
========================================================================
AppWizard has created this MathEquationTest application for you.
This file contains a summary of what you will find in each of the files that
make up your MathEquationTest application.
MathEquationTest.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
MathEquationTest.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named MathEquationTest.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
// stdafx.cpp : source file that includes just the standard includes
// MathEquationTest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#ifndef _MATH_EQUATION_OUTPUTDEV_H
#define _MATH_EQUATION_OUTPUTDEV_H
#include "Types.h"
namespace MathEquation
{
struct TMathFont;
class MathEquation;
class IOutputDev
{
public:
//
virtual void BeginEquation() = 0;
virtual void EndEquation() = 0;
// .
virtual void BeginBlock() = 0;
virtual void EndBlock() = 0;
//
virtual void SetSize(uint16_t nSize) = 0;
// . . , ..
virtual void BeginChar(Unicode_t uChar, uint8_t nTypeFace, bool bSpecialSymbol) = 0;
virtual void AddCharEmbel(MEMBELTYPE eType) = 0;
virtual void EndChar() = 0;
// . nRows * nCol, ( , ..)
virtual void BeginChar(uint8_t nVAlign, MMATRIXHORALIGN eHorAlign, MMATRIXVERALIGN eVerAlign, bool bEqualRows, bool bEqualCols, uint8_t nRows, uint8_t nCols, uint8_t* pVerBorders, uint8_t* pHorBorders) = 0;
virtual void EndMatrix () = 0;
virtual void StartPile(uint8_t nHAlign, uint8_t nVAlign) = 0;
virtual void EndPile() = 0;
//
virtual void BeginBrackets(MBRACKETSTYPE eType, bool bOpen, bool bClose) = 0;
virtual void EndBrackets (MBRACKETSTYPE eType, bool bOpen, bool bClose) = 0;
// . - , , , .
virtual void BeginRoot(bool bDegree) = 0;
virtual void EndRoot () = 0;
// . - , - .
virtual void BeginFraction(MFRACTIONTYPES eType, bool bInline) = 0;
virtual void EndFraction () = 0;
// bInline = true, Base, Sub, Sup
// bInline = false, Sub, Sup, Base
virtual void BeginScript(MSCRIPTALIGN eAlign, bool bBase = false, bool bSup = false, bool bSub = false, bool bInline = true) = 0;
virtual void EndScript () = 0;
//
virtual void BeginBar(MBARTYPE eType, bool bTop) = 0;
virtual void EndBar () = 0;
// ( BeginBar/EndBar ,
// , - , )
virtual void BeginArrow(MARROWTYPE eType, bool bTop) = 0;
virtual void EndArrow () = 0;
// . ( ) Base, Sub, Sup
virtual void BeginIntegral(MINTEGRALTYPE eType) = 0;
virtual void EndIntegral () = 0;
// / . , .
virtual void BeginVerticalBrace(bool bTop) = 0;
virtual void EndVerticalBrace () = 0;
// , , , , . Base, Sub, Sup
virtual void BeingNArray(MNARRAYTYPE eType) = 0;
virtual void EndNArray () = 0;
// . . , .
virtual void BeginLongDivision(MLONGDIVISION eType) = 0;
virtual void EndLongDivision () = 0;
// < | > -
virtual void BeginAngleBracketsWithSeparator(MANGLEBRACKETSWITHSEPARATORTYPE eType) = 0;
virtual void EndAngleBracketsWithSeparator () = 0;
void AddFont(uint8_t nTypeFace, std::string sName, bool bBold, bool bItalic)
{
TMathFont aFont;
aFont.sName = sName;
aFont.bBold = bBold;
aFont.bItalic = bItalic;
m_mFonts[nTypeFace] = aFont;
}
TMathFont* GetFont(uint8_t nTypeFace)
{
TFontMap::iterator itFind = m_mFonts.find(nTypeFace);
if (itFind != m_mFonts.end())
return &(itFind->second);
return NULL;
}
protected:
TFontMap m_mFonts;
};
}
#endif
\ No newline at end of file
#ifndef _MATH_EQUATION_STRING_H
#define _MATH_EQUATION_STRING_H
namespace MathEquation
{
#define STRING_NOTFOUND std::string::npos
class String
{
public:
String() {}
String(const char* val) : Value(val){}
String(std::string val) : Value(val){}
String &operator=(String &other)
{
Value = other.Value;
return (*this);
}
String &operator+=(const String &other)
{
Value += other.Value;
return (*this);
}
String &operator+=(const char* sChars)
{
Value += std::string(sChars);
return (*this);
}
String &operator+=(const char unChar)
{
char oChars[2];
oChars[0] = unChar; oChars[1] = 0x00;
Value += std::string((char*)&oChars);
return (*this);
}
void Append(const char* str)
{
Value.append(str);
}
void Append(String str)
{
Value.append(str.Value);
}
void Append(unsigned short ushUnicode)
{
char oChars[2];
oChars[0] = ushUnicode; oChars[1] = 0x00;
Value += std::string((char*)&oChars);
}
void AppendAscii(const char *sChars)
{
Value += std::string(sChars);
}
void Erase(int nPos = 0, int nLen = std::string::npos)
{
Value.erase(nPos, nLen);
}
int Len()
{
return (int)Value.length();
}
BYTE GetChar(int nPos)
{
return Value[nPos];
}
void InsertAscii(const char* str, int nPos)
{
Value.insert(nPos, str);
}
void Insert(String str, int nPos)
{
Value.insert(nPos, str.Value);
}
int SearchBackward(char nChar)
{
return (int)Value.rfind(nChar);
}
static String CreateFromInt32(int nValue)
{
char intStr[32];
_itoa_s(nValue, (char *)&intStr, 32, 10);
return String(intStr);
}
std::string GetValue()
{
return Value;
}
private:
std::string Value;
};
}
#endif
\ No newline at end of file
This diff is collapsed.
#ifndef _MATH_EQUATION_TYPES_H
#define _MATH_EQUATION_TYPES_H
#include <map>
namespace MathEquation
{
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned short Unicode_t;
typedef signed char Char_t;
struct TMathFont
{
std::string sName;
bool bItalic;
bool bBold;
};
typedef std::map<uint8_t, TMathFont> TFontMap;
enum MBRACKETSTYPE
{
bracketsAngle = 0x00, // < >
bracketsRound = 0x01, // ( )
bracketsCurve = 0x02, // { }
bracketsSquare = 0x03, // [ ]
bracketsLine = 0x04, // | |
bracketsDLine = 0x05, // || ||
bracketsFloor = 0x06, //
bracketsCeil = 0x07, //
bracketsSquareOpenOpen = 0x08, // [ [
bracketsSquareCloseClose = 0x09, // ] ]
bracketsSquareCloseOpen = 0x0a, // ] [
bracketsSquareRound = 0x0b, // [ )
bracketsRoundSquare = 0x0c // ( ]
};
enum MFRACTIONTYPES
{
fractionRegular = 0, //
fractionSlanted = 1 //
};
enum MSCRIPTALIGN
{
scriptalignRight = 0,
scriptalignCenter = 1,
scriptalignLeft = 2
};
enum MBARTYPE
{
bartypeLine = 0, //
bartypeDoubleLine = 1, //
bartypeArrowLeft = 2, //
bartypeArrowRight = 3, //
bartypeArrowDouble = 4 // ( , )
};
enum MARROWTYPE
{
arrowtypeLeft = 0, //
arrowtypeRight = 1, //
arrowtypeDouble = 2 // ( , )
};
enum MINTEGRALTYPE
{
integraltypeSingle = 0, //
integraltypeSingleRSub = 1, //
integraltypeSingleRSubSup = 2, //
integraltypeSingleOriented = 3, //
integraltypeSingleOrientedRSub = 4, //
integraltypeDouble = 5, //
integraltypeDoubleRSub = 6, //
integraltypeDoubleOriented = 7, //
integraltypeDoubleOrientedRSub = 8, //
integraltypeTriple = 9, //
integraltypeTripleRSub = 10, //
integraltypeTripleOriented = 11, //
integraltypeTripleOrientedRSub = 12, //
integraltypeSingleCSubSup = 13, //
integraltypeSingleCSub = 14, //
integraltypeSingleOrientedCSub = 15, //
integraltypeDoubleOrientedCSub = 16, //
integraltypeDoubleCSub = 17, //
integraltypeTripleOrientedCSub = 18, //
integraltypeTripleCSub = 19 //
};
enum MNARRAYTYPE
{
narySumCSub = 0, //
narySumCSubSup = 1, //
narySum = 2, //
narySumRSub = 3, //
narySumRSubSup = 4, //
naryProdCSub = 5, //
naryProdCSubSup = 6, //
naryProd = 7, //
naryProdRSub = 8, //
naryProdRSubSup = 9, //
naryCoProdCSub = 10, //
naryCoProdCSubSup = 11, //
naryCoProd = 12, //
naryCoProdRSub = 13, //
naryCoProdRSubSup = 14, //
naryUnionCSub = 15, //
naryUnionCSubSup = 16, //
naryUnion = 17, //
naryUnionRSub = 18, //
naryUnionRSubSup = 19, //
naryIntersectCSub = 20, //
naryIntersectCSubSup = 21, //
naryIntersect = 22, //
naryIntersectRSub = 23, //
naryIntersectRSubSup = 24 //
};
enum MLONGDIVISION
{
longdivisionWithResult = 0, //
longdivisionRegular = 1 //
};
enum MANGLEBRACKETSWITHSEPARATORTYPE
{
angbrwithsepBoth = 0, // < | >
angbrwithsepLeft = 1, // < |
angbrwithsepRight = 2 // | >
};
enum MEMBELTYPE
{
embelDot = 0x02, // .
embelDDot = 0x03, // ..
embelDDDot = 0x04, // ...
embelPrime = 0x05, // '
embelDPrime = 0x06, // "
embelLPrime = 0x07, // '
embelTilde = 0x08, // ~
embelHat = 0x09, // () ^
embelSlash = 0x0a, // /
embelRArrow = 0x0b, // <-
embelLArrow = 0x0c, // ->
embelDArrow = 0x0d, // <->
embelRHarpoon = 0x0e, //
embelLHarpoon = 0x0f, //
embelStrikeout = 0x10, //
embelBar = 0x11, //
embelTPrime = 0x12, // '''
embelFrown = 0x13, //
embelSmile = 0x14, //
embelMin = 0x02,
embelMax = 0x14
};
enum MMATRIXBORDERTYPE
{
matrixborderNone = 0x00,
matrixborderSolid = 0x01,
matrixborderDash = 0x02,
matrixborderDot = 0x03
};
enum MMATRIXHORALIGN
{
matrixhoralignLeft = 0x00, //
matrixhoralignCenter = 0x01, //
matrixhoralignRight = 0x02, //
matrixhoralignEqualSign = 0x03, // =
matrixhoralignCommaSign = 0x04 // ,
};
enum MMATRIXVERALIGN
{
matrixveralignTop = 0x00,
matrixveralignBaseLine = 0x01,
matrixveralginBottom = 0x02
};
enum MSPECIALSYMBOLS
{
specialsymAlignment = 0xeb00,
specialsymZeroSpace = 0xeb01,
specialsymThinSpace = 0xeb02,
specialsymThickSpace = 0xeb04,
specialsymLargeSpace = 0xeb05,
specialsymOnePtSpace = 0xeb08
};
}
#endif _MATH_EQUATION_OUTPUTDEV_H
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment