34#include <wx/xml/xml.h>
36#include <wx/filesys.h>
39#include <wx/hashmap.h>
41#include "cells/TextCell.h"
47#include <unordered_map>
48#include <unordered_set>
82 void SetUserLabel(
const wxString &label){ m_userDefinedLabel = label; }
87 std::unique_ptr<Cell> ParseLine(wxString s,
CellType style = MC_TYPE_DEFAULT);
88 std::unique_ptr<Cell> ParseLine(
const wxXmlDocument &xml,
CellType style = MC_TYPE_DEFAULT);
93 std::unique_ptr<Cell> ParseTag(wxXmlNode *node,
bool all =
true,
int depth = 0);
94 std::unique_ptr<Cell> ParseRowTag(wxXmlNode *node,
int depth = 0);
96 std::unique_ptr<GroupCell> CreateTreeFromXMLNode(wxXmlNode *xmlcells);
103 using MathCellFunc = std::unique_ptr<Cell> (
MathParser::*)(wxXmlNode *node,
int depth);
106 using GroupCellFunc = std::unique_ptr<GroupCell> (
MathParser::*)(wxXmlNode *node);
108 using MathCellFunctionHash = std::unordered_map<wxString, MathCellFunc, wxStringHash>;
109 using GroupCellFunctionHash = std::unordered_map<wxString, GroupCellFunc, wxStringHash>;
112 static MathCellFunctionHash m_innerTags;
114 static GroupCellFunctionHash m_groupTags;
116 static std::unordered_set<wxString, wxStringHash> m_knownAttributes;
119 static void ParseCommonAttrs(wxXmlNode *node,
Cell *cell);
120 template <
typename T>
121 static void ParseCommonAttrs(wxXmlNode *node,
const std::unique_ptr<T> &cell)
122 { ParseCommonAttrs(node, cell.get()); }
125 static void ParseCommonGroupCellAttrs(wxXmlNode *node,
const std::unique_ptr<GroupCell> &
group);
128 std::unique_ptr<Cell> HandleNullPointer(std::unique_ptr<Cell> &&cell);
142 static wxXmlNode *GetNextTag(wxXmlNode *node);
145 static int CountChildren(wxXmlNode *node);
152 static wxXmlNode *SkipWhitespaceNode(wxXmlNode *node);
165 std::unique_ptr<Cell> ParseCellTag(wxXmlNode *node,
int depth = 0);
167 std::unique_ptr<GroupCell> GroupCellFromCodeTag(wxXmlNode *node);
169 std::unique_ptr<GroupCell> GroupCellFromImageTag(wxXmlNode *node);
171 std::unique_ptr<GroupCell> GroupCellFromTitleTag(wxXmlNode *WXUNUSED(node));
173 std::unique_ptr<GroupCell> GroupCellFromSectionTag(wxXmlNode *WXUNUSED(node));
175 std::unique_ptr<GroupCell> GroupCellFromPagebreakTag(wxXmlNode *WXUNUSED(node));
177 std::unique_ptr<GroupCell> GroupCellFromSubsectionTag(wxXmlNode *node);
179 std::unique_ptr<GroupCell> GroupCellFromSubsubsectionTag(wxXmlNode *WXUNUSED(node));
181 std::unique_ptr<GroupCell> GroupCellHeading5Tag(wxXmlNode *WXUNUSED(node));
183 std::unique_ptr<GroupCell> GroupCellHeading6Tag(wxXmlNode *WXUNUSED(node));
185 std::unique_ptr<GroupCell> GroupCellFromTextTag(wxXmlNode *WXUNUSED(node));
192 std::unique_ptr<Cell> ParseEditorTag(wxXmlNode *node,
int depth = 0);
194 std::unique_ptr<Cell> ParseFracTag(wxXmlNode *node,
int depth = 0);
196 std::unique_ptr<Cell> ParseText(wxXmlNode *node,
TextStyle style = TS_MATH,
int depth = 0);
201 std::unique_ptr<Cell> ParseVariableNameTag(wxXmlNode *node,
int depth = 0);
203 std::unique_ptr<Cell> ParseOperatorNameTag(wxXmlNode *node,
int depth = 0){
return ParseText(node->GetChildren(), TS_FUNCTION, depth);}
205 std::unique_ptr<Cell> ParseMiscTextTag(wxXmlNode *node,
int depth = 0);
207 std::unique_ptr<Cell> ParseNumberTag(wxXmlNode *node,
int depth = 0){
return ParseText(node->GetChildren(), TS_NUMBER, depth);}
209 std::unique_ptr<Cell> ParseHiddenOperatorTag(wxXmlNode *node,
int depth = 0);
211 std::unique_ptr<Cell> ParseGreekTag(wxXmlNode *node,
int depth = 0){
return ParseText(node->GetChildren(), TS_GREEK_CONSTANT, depth);}
213 std::unique_ptr<Cell> ParseSpecialConstantTag(wxXmlNode *node,
int depth = 0){
return ParseText(node->GetChildren(), TS_SPECIAL_CONSTANT, depth);}
215 std::unique_ptr<Cell> ParseFunctionNameTag(wxXmlNode *node,
int depth = 0){
return ParseText(node->GetChildren(), TS_FUNCTION, depth);}
217 std::unique_ptr<Cell> ParseSpaceTag(wxXmlNode *WXUNUSED(node),
int WXUNUSED(depth) = 0){
return std::make_unique<TextCell>(m_group, m_configuration, wxS(
" "));}
222 std::unique_ptr<Cell> ParseMthTag(wxXmlNode *node,
int depth = 0);
224 std::unique_ptr<Cell> ParseOutputLabelTag(wxXmlNode *node,
int depth = 0);
226 std::unique_ptr<Cell> ParseStringTag(wxXmlNode *node,
int depth = 0);
228 std::unique_ptr<Cell> ParseHighlightTag(wxXmlNode *node,
int depth = 0);
230 std::unique_ptr<Cell> ParseImageTag(wxXmlNode *node,
int depth = 0);
232 std::unique_ptr<Cell> ParseAnimationTag(wxXmlNode *node,
int depth = 0);
234 static void ReadUserScale(wxXmlNode *node,
ImgCellBase *cell);
236 std::unique_ptr<Cell> ParseCharCode(wxXmlNode *node,
int depth = 0);
238 std::unique_ptr<Cell> ParseSupTag(wxXmlNode *node,
int depth = 0);
240 std::unique_ptr<Cell> ParseSubTag(wxXmlNode *node,
int depth = 0);
242 std::unique_ptr<Cell> ParseAbsTag(wxXmlNode *node,
int depth = 0);
244 std::unique_ptr<Cell> ParseConjugateTag(wxXmlNode *node,
int depth = 0);
247 std::unique_ptr<Cell> ParseUnderTag(wxXmlNode *node,
int depth = 0);
250 std::unique_ptr<Cell> ParseTableTag(wxXmlNode *node,
int depth = 0);
252 std::unique_ptr<Cell> ParseAtTag(wxXmlNode *node,
int depth = 0);
254 std::unique_ptr<Cell> ParseDiffTag(wxXmlNode *node,
int depth = 0);
256 std::unique_ptr<Cell> ParseSumTag(wxXmlNode *node,
int depth = 0);
258 std::unique_ptr<Cell> ParseIntTag(wxXmlNode *node,
int depth = 0);
260 std::unique_ptr<Cell> ParseFunTag(wxXmlNode *node,
int depth = 0);
262 std::unique_ptr<Cell> ParseSqrtTag(wxXmlNode *node,
int depth = 0);
264 std::unique_ptr<Cell> ParseLimitTag(wxXmlNode *node,
int depth = 0);
266 std::unique_ptr<Cell> ParseParenTag(wxXmlNode *node,
int depth = 0);
268 std::unique_ptr<Cell> ParseSubSupTag(wxXmlNode *node,
int depth = 0);
270 std::unique_ptr<Cell> ParseMmultiscriptsTag(wxXmlNode *node,
int depth = 0);
272 std::unique_ptr<Cell> ParseOutputTag(wxXmlNode *node,
int depth = 0);
274 std::unique_ptr<Cell> ParseMtdTag(wxXmlNode *node,
int depth = 0);
277 wxString m_userDefinedLabel;
279 static wxRegEx m_graphRegex;
281 CellType m_ParserStyle = MC_TYPE_DEFAULT;
285 bool m_highlight =
false;
288 static wxString m_unknownXMLTagToolTip;
Where the files a worksheet's XML refers to (images, gnuplot sources and data) can be read from.
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:230
The files a worksheet's XML refers to by name.
Definition: AttachmentSource.h:49
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:539
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
The configuration storage for the current worksheet.
Definition: Configuration.h:102
FracType
All types of fractions we support.
Definition: FracCell.h:80
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
Definition: ImgCellBase.h:44
This class handles parsing the xml representation of a cell tree.
Definition: MathParser.h:56
void SetUserLabel(const wxString &label)
Tells the parser what user label to assign to the next label cell.
Definition: MathParser.h:82
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:99