MathObjectType Enumeration

Specifies type of an Office Math object.

Namespace:  Aspose.Words.Math
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public enum MathObjectType
Members
  Member nameValueDescription
OMath0 Instance of mathematical text.
OMathPara1 Math paragraph, or display math zone, that contains one or more OMath elements that are in display mode.
Accent2 Accent function, consisting of a base and a combining diacritical mark.
Bar3 Bar function, consisting of a base argument and an overbar or underbar.
BorderBox4 Border Box object, consisting of a border drawn around an instance of mathematical text (such as a formula or equation)
Box5 Box object, which is used to group components of an equation or other instance of mathematical text.
Delimiter6 Delimiter object, consisting of opening and closing delimiters (such as parentheses, braces, brackets, and vertical bars), and an element contained inside.
Degree7 Degree in the mathematical radical.
Argument8 Argument object. Encloses Office Math entities when they are used as arguments to other Office Math entities.
Array9 Array object, consisting of one or more equations, expressions, or other mathematical text runs that can be vertically justified as a unit with respect to surrounding text on the line.
Fraction10 Fraction object, consisting of a numerator and denominator separated by a fraction bar.
Denominator11 Denominator of a fraction object.
Numerator12 Numerator of the Fraction object.
Function13 Function-Apply object, which consists of a function name and an argument element acted upon.
FunctionName14 Name of the function. For example, function names are sin and cos.
GroupCharacter15 Group-Character object, consisting of a character drawn above or below text, often with the purpose of visually grouping items
Limit16 Lower limit of the LowerLimit object and the upper limit of the UpperLimit function.
LowerLimit17 Lower-Limit object, consisting of text on the baseline and reduced-size text immediately below it.
UpperLimit18 Upper-Limit object, consisting of text on the baseline and reduced-size text immediately above it.
Matrix19 Matrix object, consisting of one or more elements laid out in one or more rows and one or more columns.
MatrixRow20 Single row of the matrix.
NAry21 N-ary object, consisting of an n-ary object, a base (or operand), and optional upper and lower limits.
Phantom22 Phantom object.
Radical23 Radical object, consisting of a radical, a base element, and an optional degree .
SubscriptPart24 Subscript of the object that can have subscript part.
SuperscriptPart25 Superscript of the superscript object.
PreSubSuperscript26 Pre-Sub-Superscript object, which consists of a base element and a subscript and superscript placed to the left of the base.
Subscript27 Subscript object, which consists of a base element and a reduced-size script placed below and to the right.
SubSuperscript28 Sub-superscript object, which consists of a base element, a reduced-size script placed below and to the right, and a reduced-size script placed above and to the right.
Supercript29 Superscript object, which consists of a base element and a reduced-size script placed above and to the right.
Examples
Traverse a document with a visitor that prints all OfficeMath nodes that it encounters.
public void OfficeMathToText()
{
    // Open the document that has office math objects we want to print the info of
    Document doc = new Document(MyDir + "DocumentVisitor-compatible features.docx");

    // Create an object that inherits from the DocumentVisitor class
    OfficeMathInfoPrinter visitor = new OfficeMathInfoPrinter();

    // Accepting a visitor lets it start traversing the nodes in the document, 
    // starting with the node that accepted it to then recursively visit every child
    doc.Accept(visitor);

    // Once the visiting is complete, we can retrieve the result of the operation,
    // that in this example, has accumulated in the visitor
    Console.WriteLine(visitor.GetText());
}

/// <summary>
/// This Visitor implementation prints information about office math objects encountered in the document.
/// </summary>
public class OfficeMathInfoPrinter : DocumentVisitor
{
    public OfficeMathInfoPrinter()
    {
        mBuilder = new StringBuilder();
        mVisitorIsInsideOfficeMath = false;
    }

    /// <summary>
    /// Gets the plain text of the document that was accumulated by the visitor.
    /// </summary>
    public string GetText()
    {
        return mBuilder.ToString();
    }

    /// <summary>
    /// Called when a Run node is encountered in the document.
    /// </summary>
    public override VisitorAction VisitRun(Run run)
    {
        if (mVisitorIsInsideOfficeMath) IndentAndAppendLine("[Run] \"" + run.GetText() + "\"");

        return VisitorAction.Continue;
    }

    /// <summary>
    /// Called when an OfficeMath node is encountered in the document.
    /// </summary>
    public override VisitorAction VisitOfficeMathStart(OfficeMath officeMath)
    {
        IndentAndAppendLine("[OfficeMath start] Math object type: " + officeMath.MathObjectType);
        mDocTraversalDepth++;
        mVisitorIsInsideOfficeMath = true;

        return VisitorAction.Continue;
    }

    /// <summary>
    /// Called when the visiting of a OfficeMath node is ended.
    /// </summary>
    public override VisitorAction VisitOfficeMathEnd(OfficeMath officeMath)
    {
        mDocTraversalDepth--;
        IndentAndAppendLine("[OfficeMath end]");
        mVisitorIsInsideOfficeMath = false;

        return VisitorAction.Continue;
    }

    /// <summary>
    /// Append a line to the StringBuilder and indent it depending on how deep the visitor is into the document tree.
    /// </summary>
    /// <param name="text"></param>
    private void IndentAndAppendLine(string text)
    {
        for (int i = 0; i < mDocTraversalDepth; i++) mBuilder.Append("|  ");

        mBuilder.AppendLine(text);
    }

    private bool mVisitorIsInsideOfficeMath;
    private int mDocTraversalDepth;
    private readonly StringBuilder mBuilder;
}
See Also