MathObjectType enumeration

MathObjectType enumeration

Specifies type of an Office Math object.

Members

NameDescription
OMathInstance of mathematical text.
OMathParaMath paragraph, or display math zone, that contains one or more MathObjectType.OMath elements that are in display mode.
AccentAccent function, consisting of a base and a combining diacritical mark.
BarBar function, consisting of a base argument and an overbar or underbar.
BorderBoxBorder Box object, consisting of a border drawn around an instance of mathematical text (such as a formula or equation)
BoxBox object, which is used to group components of an equation or other instance of mathematical text.
DelimiterDelimiter object, consisting of opening and closing delimiters (such as parentheses, braces, brackets, and vertical bars), and an element contained inside.
DegreeDegree in the mathematical radical.
ArgumentArgument object. Encloses Office Math entities when they are used as arguments to other Office Math entities.
ArrayArray 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.
FractionFraction object, consisting of a numerator and denominator separated by a fraction bar.
DenominatorDenominator of a fraction object.
NumeratorNumerator of the Fraction object.
FunctionFunction-Apply object, which consists of a function name and an argument element acted upon.
FunctionNameName of the function. For example, function names are sin and cos.
GroupCharacterGroup-Character object, consisting of a character drawn above or below text, often with the purpose of visually grouping items
LimitLower limit of the MathObjectType.LowerLimit object and the upper limit of the MathObjectType.UpperLimit function.
LowerLimitLower-Limit object, consisting of text on the baseline and reduced-size text immediately below it.
UpperLimitUpper-Limit object, consisting of text on the baseline and reduced-size text immediately above it.
MatrixMatrix object, consisting of one or more elements laid out in one or more rows and one or more columns.
MatrixRowSingle row of the matrix.
NAryN-ary object, consisting of an n-ary object, a base (or operand), and optional upper and lower limits.
PhantomPhantom object.
RadicalRadical object, consisting of a radical, a base element, and an optional degree .
SubscriptPartSubscript of the object that can have subscript part.
SuperscriptPartSuperscript of the superscript object.
PreSubSuperscriptPre-Sub-Superscript object, which consists of a base element and a subscript and superscript placed to the left of the base.
SubscriptSubscript object, which consists of a base element and a reduced-size script placed below and to the right.
SubSuperscriptSub-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.
SupercriptSuperscript object, which consists of a base element and a reduced-size script placed above and to the right.

Examples

Shows how to print the node structure of every office math node in a document.

test('OfficeMathToText', () => {
  let doc = new aw.Document(base.myDir + "DocumentVisitor-compatible features.docx");
  let visitor = new OfficeMathStructurePrinter();

  // When we get a composite node to accept a document visitor, the visitor visits the accepting node,
  // and then traverses all the node's children in a depth-first manner.
  // The visitor can read and modify each visited node.
  doc.accept(visitor);

  console.log(visitor.getText());
});


  /// <summary>
  /// Traverses a node's non-binary tree of child nodes.
  /// Creates a map in the form of a string of all encountered OfficeMath nodes and their children.
  /// </summary>
public class OfficeMathStructurePrinter : DocumentVisitor
{
  public OfficeMathStructurePrinter()
  {
    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 aw.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 aw.VisitorAction.Continue;
  }

    /// <summary>
    /// Called after all the child nodes of an OfficeMath node have been visited.
    /// </summary>
  public override VisitorAction VisitOfficeMathEnd(OfficeMath officeMath)
  {
    mDocTraversalDepth--;
    IndentAndAppendLine("[OfficeMath end]");
    mVisitorIsInsideOfficeMath = false;

    return aw.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 (let i = 0; i < mDocTraversalDepth; i++) mBuilder.append("|  ");

    mBuilder.AppendLine(text);
  }

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

See Also