34#include <wx/xml/xml.h>
36#include <wx/filesys.h>
39#include <wx/hashmap.h>
41#include "cells/TextCell.h"
45#include <unordered_map>
67 void SetUserLabel(
const wxString &label){ m_userDefinedLabel = label; }
72 std::unique_ptr<Cell> ParseLine(wxString s,
CellType style = MC_TYPE_DEFAULT);
73 std::unique_ptr<Cell> ParseLine(
const wxXmlDocument &xml,
CellType style = MC_TYPE_DEFAULT);
78 std::unique_ptr<Cell> ParseTag(wxXmlNode *node,
bool all =
true);
79 std::unique_ptr<Cell> ParseRowTag(wxXmlNode *node);
86 using MathCellFunc = std::unique_ptr<Cell> (
MathParser::*)(wxXmlNode *node);
89 using GroupCellFunc = std::unique_ptr<GroupCell> (
MathParser::*)(wxXmlNode *node);
91 typedef std::unordered_map <wxString, MathCellFunc, wxStringHash> MathCellFunctionHash;
92 typedef std::unordered_map <wxString, GroupCellFunc, wxStringHash> GroupCellFunctionHash;
95 static MathCellFunctionHash m_innerTags;
97 static GroupCellFunctionHash m_groupTags;
100 static void ParseCommonAttrs(wxXmlNode *node,
Cell *cell);
101 template <
typename T>
102 static void ParseCommonAttrs(wxXmlNode *node,
const std::unique_ptr<T> &cell)
103 { ParseCommonAttrs(node, cell.get()); }
106 static void ParseCommonGroupCellAttrs(wxXmlNode *node,
const std::unique_ptr<GroupCell> &group);
109 std::unique_ptr<Cell> HandleNullPointer(std::unique_ptr<Cell> &&cell);
123 static wxXmlNode *GetNextTag(wxXmlNode *node);
126 static int CountChildren(wxXmlNode *node);
133 static wxXmlNode *SkipWhitespaceNode(wxXmlNode *node);
146 std::unique_ptr<Cell> ParseCellTag(wxXmlNode *node);
148 std::unique_ptr<GroupCell> GroupCellFromCodeTag(wxXmlNode *node);
150 std::unique_ptr<GroupCell> GroupCellFromImageTag(wxXmlNode *node);
152 std::unique_ptr<GroupCell> GroupCellFromTitleTag(wxXmlNode *WXUNUSED(node));
154 std::unique_ptr<GroupCell> GroupCellFromSectionTag(wxXmlNode *WXUNUSED(node));
156 std::unique_ptr<GroupCell> GroupCellFromPagebreakTag(wxXmlNode *WXUNUSED(node));
158 std::unique_ptr<GroupCell> GroupCellFromSubsectionTag(wxXmlNode *node);
160 std::unique_ptr<GroupCell> GroupCellFromSubsubsectionTag(wxXmlNode *WXUNUSED(node));
162 std::unique_ptr<GroupCell> GroupCellHeading5Tag(wxXmlNode *WXUNUSED(node));
164 std::unique_ptr<GroupCell> GroupCellHeading6Tag(wxXmlNode *WXUNUSED(node));
166 std::unique_ptr<GroupCell> GroupCellFromTextTag(wxXmlNode *WXUNUSED(node));
173 std::unique_ptr<Cell> ParseEditorTag(wxXmlNode *node);
175 std::unique_ptr<Cell> ParseFracTag(wxXmlNode *node);
177 std::unique_ptr<Cell> ParseText(wxXmlNode *node,
TextStyle style = TS_MATH);
182 std::unique_ptr<Cell> ParseVariableNameTag(wxXmlNode *node);
184 std::unique_ptr<Cell> ParseOperatorNameTag(wxXmlNode *node){
return ParseText(node->GetChildren(), TS_FUNCTION);}
186 std::unique_ptr<Cell> ParseMiscTextTag(wxXmlNode *node);
188 std::unique_ptr<Cell> ParseNumberTag(wxXmlNode *node){
return ParseText(node->GetChildren(), TS_NUMBER);}
190 std::unique_ptr<Cell> ParseHiddenOperatorTag(wxXmlNode *node);
192 std::unique_ptr<Cell> ParseGreekTag(wxXmlNode *node){
return ParseText(node->GetChildren(), TS_GREEK_CONSTANT);}
194 std::unique_ptr<Cell> ParseSpecialConstantTag(wxXmlNode *node){
return ParseText(node->GetChildren(), TS_SPECIAL_CONSTANT);}
196 std::unique_ptr<Cell> ParseFunctionNameTag(wxXmlNode *node){
return ParseText(node->GetChildren(), TS_FUNCTION);}
198 std::unique_ptr<Cell> ParseSpaceTag(wxXmlNode *WXUNUSED(node)){
return std::make_unique<TextCell>(m_group, m_configuration, wxS(
" "));}
203 std::unique_ptr<Cell> ParseMthTag(wxXmlNode *node);
205 std::unique_ptr<Cell> ParseOutputLabelTag(wxXmlNode *node);
207 std::unique_ptr<Cell> ParseStringTag(wxXmlNode *node);
209 std::unique_ptr<Cell> ParseHighlightTag(wxXmlNode *node);
211 std::unique_ptr<Cell> ParseImageTag(wxXmlNode *node);
213 std::unique_ptr<Cell> ParseAnimationTag(wxXmlNode *node);
215 std::unique_ptr<Cell> ParseCharCode(wxXmlNode *node);
217 std::unique_ptr<Cell> ParseSupTag(wxXmlNode *node);
219 std::unique_ptr<Cell> ParseSubTag(wxXmlNode *node);
221 std::unique_ptr<Cell> ParseAbsTag(wxXmlNode *node);
223 std::unique_ptr<Cell> ParseConjugateTag(wxXmlNode *node);
226 std::unique_ptr<Cell> ParseUnderTag(wxXmlNode *node);
229 std::unique_ptr<Cell> ParseTableTag(wxXmlNode *node);
231 std::unique_ptr<Cell> ParseAtTag(wxXmlNode *node);
233 std::unique_ptr<Cell> ParseDiffTag(wxXmlNode *node);
235 std::unique_ptr<Cell> ParseSumTag(wxXmlNode *node);
237 std::unique_ptr<Cell> ParseIntTag(wxXmlNode *node);
239 std::unique_ptr<Cell> ParseFunTag(wxXmlNode *node);
241 std::unique_ptr<Cell> ParseSqrtTag(wxXmlNode *node);
243 std::unique_ptr<Cell> ParseLimitTag(wxXmlNode *node);
245 std::unique_ptr<Cell> ParseParenTag(wxXmlNode *node);
247 std::unique_ptr<Cell> ParseSubSupTag(wxXmlNode *node);
249 std::unique_ptr<Cell> ParseMmultiscriptsTag(wxXmlNode *node);
251 std::unique_ptr<Cell> ParseOutputTag(wxXmlNode *node);
253 std::unique_ptr<Cell> ParseMtdTag(wxXmlNode *node);
256 wxString m_userDefinedLabel;
258 static wxRegEx m_graphRegex;
260 CellType m_ParserStyle = MC_TYPE_DEFAULT;
264 bool m_highlight =
false;
266 static wxString m_unknownXMLTagToolTip;
The definition of the base class of all cells the worksheet consists of.
CellType
The supported types of math cells.
Definition: Cell.h:64
This file contains the definition of the class EditorCell.
This file declares the class FracCell.
This file defines the class GroupCell that bundles input and output in the worksheet.
TextStyle
All text styles known to wxMaxima.
Definition: TextStyle.h:231
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:480
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
The configuration storage for the current worksheet.
Definition: Configuration.h:85
FracType
All types of fractions we support.
Definition: FracCell.h:59
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:74
This class handles parsing the xml representation of a cell tree.
Definition: MathParser.h:53
MathParser & operator=(const MathParser &)=delete
This class doesn't have a = operator.
MathParser(const MathParser &)=delete
This class doesn't have a copy constructor.
void SetGroup(GroupCell *group)
Sets the group the newly parsed cells are provided with.
Definition: MathParser.h:82