com.aspose.words

Class MathObjectType

  • java.lang.Object
    • com.aspose.words.MathObjectType
public class MathObjectType 
extends java.lang.Object

Utility class containing constants. Specifies type of an Office Math object.

Example:

Shows how to print the node structure of every office math node in a document.
public void officeMathToText() throws Exception {
    Document doc = new Document(getMyDir() + "DocumentVisitor-compatible features.docx");
    OfficeMathStructurePrinter visitor = new OfficeMathStructurePrinter();

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

    System.out.println(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 static class OfficeMathStructurePrinter extends 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 int visitRun(final Run run) {
        if (mVisitorIsInsideOfficeMath) {
            indentAndAppendLine("[Run] \"" + run.getText() + "\"");
        }

        return VisitorAction.CONTINUE;
    }

    /// <summary>
    /// Called when an OfficeMath node is encountered in the document.
    /// </summary>
    public int visitOfficeMathStart(final OfficeMath officeMath) {
        indentAndAppendLine("[OfficeMath start] Math object type: " + officeMath.getMathObjectType());
        mDocTraversalDepth++;
        mVisitorIsInsideOfficeMath = true;

        return VisitorAction.CONTINUE;
    }

    /// <summary>
    /// Called after all the child nodes of an OfficeMath node have been visited.
    /// </summary>
    public int visitOfficeMathEnd(final 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(final String text) {
        for (int i = 0; i < mDocTraversalDepth; i++) {
            mBuilder.append("|  ");
        }

        mBuilder.append(text + "\r\n");
    }

    private boolean mVisitorIsInsideOfficeMath;
    private int mDocTraversalDepth;
    private StringBuilder mBuilder;
}

Field Summary
static final intO_MATH = 0
Instance of mathematical text.
static final intO_MATH_PARA = 1
Math paragraph, or display math zone, that contains one or more O_MATH elements that are in display mode.
static final intACCENT = 2
Accent function, consisting of a base and a combining diacritical mark.
static final intBAR = 3
Bar function, consisting of a base argument and an overbar or underbar.
static final intBORDER_BOX = 4
Border Box object, consisting of a border drawn around an instance of mathematical text (such as a formula or equation)
static final intBOX = 5
Box object, which is used to group components of an equation or other instance of mathematical text.
static final intDELIMITER = 6
Delimiter object, consisting of opening and closing delimiters (such as parentheses, braces, brackets, and vertical bars), and an element contained inside.
static final intDEGREE = 7
Degree in the mathematical radical.
static final intARGUMENT = 8
Argument object. Encloses Office Math entities when they are used as arguments to other Office Math entities.
static final intARRAY = 9
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.
static final intFRACTION = 10
Fraction object, consisting of a numerator and denominator separated by a fraction bar.
static final intDENOMINATOR = 11
Denominator of a fraction object.
static final intNUMERATOR = 12
Numerator of the Fraction object.
static final intFUNCTION = 13
Function-Apply object, which consists of a function name and an argument element acted upon.
static final intFUNCTION_NAME = 14
Name of the function. For example, function names are sin and cos.
static final intGROUP_CHARACTER = 15
Group-Character object, consisting of a character drawn above or below text, often with the purpose of visually grouping items
static final intLIMIT = 16
Lower limit of the LOWER_LIMIT object and the upper limit of the UPPER_LIMIT function.
static final intLOWER_LIMIT = 17
Lower-Limit object, consisting of text on the baseline and reduced-size text immediately below it.
static final intUPPER_LIMIT = 18
Upper-Limit object, consisting of text on the baseline and reduced-size text immediately above it.
static final intMATRIX = 19
Matrix object, consisting of one or more elements laid out in one or more rows and one or more columns.
static final intMATRIX_ROW = 20
Single row of the matrix.
static final intN_ARY = 21
N-ary object, consisting of an n-ary object, a base (or operand), and optional upper and lower limits.
static final intPHANTOM = 22
Phantom object.
static final intRADICAL = 23
Radical object, consisting of a radical, a base element, and an optional degree .
static final intSUBSCRIPT_PART = 24
Subscript of the object that can have subscript part.
static final intSUPERSCRIPT_PART = 25
Superscript of the superscript object.
static final intPRE_SUB_SUPERSCRIPT = 26
Pre-Sub-Superscript object, which consists of a base element and a subscript and superscript placed to the left of the base.
static final intSUBSCRIPT = 27
Subscript object, which consists of a base element and a reduced-size script placed below and to the right.
static final intSUB_SUPERSCRIPT = 28
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.
static final intSUPERCRIPT = 29
Superscript object, which consists of a base element and a reduced-size script placed above and to the right.
 

    • Field Detail

      • O_MATH = 0

        public static final int O_MATH
        Instance of mathematical text.
      • O_MATH_PARA = 1

        public static final int O_MATH_PARA
        Math paragraph, or display math zone, that contains one or more O_MATH elements that are in display mode.
      • ACCENT = 2

        public static final int ACCENT
        Accent function, consisting of a base and a combining diacritical mark.
      • BAR = 3

        public static final int BAR
        Bar function, consisting of a base argument and an overbar or underbar.
      • BORDER_BOX = 4

        public static final int BORDER_BOX
        Border Box object, consisting of a border drawn around an instance of mathematical text (such as a formula or equation)
      • BOX = 5

        public static final int BOX
        Box object, which is used to group components of an equation or other instance of mathematical text.
      • DELIMITER = 6

        public static final int DELIMITER
        Delimiter object, consisting of opening and closing delimiters (such as parentheses, braces, brackets, and vertical bars), and an element contained inside.
      • DEGREE = 7

        public static final int DEGREE
        Degree in the mathematical radical.
      • ARGUMENT = 8

        public static final int ARGUMENT
        Argument object. Encloses Office Math entities when they are used as arguments to other Office Math entities.
      • ARRAY = 9

        public static final int ARRAY
        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.
      • FRACTION = 10

        public static final int FRACTION
        Fraction object, consisting of a numerator and denominator separated by a fraction bar.
      • DENOMINATOR = 11

        public static final int DENOMINATOR
        Denominator of a fraction object.
      • NUMERATOR = 12

        public static final int NUMERATOR
        Numerator of the Fraction object.
      • FUNCTION = 13

        public static final int FUNCTION
        Function-Apply object, which consists of a function name and an argument element acted upon.
      • FUNCTION_NAME = 14

        public static final int FUNCTION_NAME
        Name of the function. For example, function names are sin and cos.
      • GROUP_CHARACTER = 15

        public static final int GROUP_CHARACTER
        Group-Character object, consisting of a character drawn above or below text, often with the purpose of visually grouping items
      • LIMIT = 16

        public static final int LIMIT
        Lower limit of the LOWER_LIMIT object and the upper limit of the UPPER_LIMIT function.
      • LOWER_LIMIT = 17

        public static final int LOWER_LIMIT
        Lower-Limit object, consisting of text on the baseline and reduced-size text immediately below it.
      • UPPER_LIMIT = 18

        public static final int UPPER_LIMIT
        Upper-Limit object, consisting of text on the baseline and reduced-size text immediately above it.
      • MATRIX = 19

        public static final int MATRIX
        Matrix object, consisting of one or more elements laid out in one or more rows and one or more columns.
      • MATRIX_ROW = 20

        public static final int MATRIX_ROW
        Single row of the matrix.
      • N_ARY = 21

        public static final int N_ARY
        N-ary object, consisting of an n-ary object, a base (or operand), and optional upper and lower limits.
      • PHANTOM = 22

        public static final int PHANTOM
        Phantom object.
      • RADICAL = 23

        public static final int RADICAL
        Radical object, consisting of a radical, a base element, and an optional degree .
      • SUBSCRIPT_PART = 24

        public static final int SUBSCRIPT_PART
        Subscript of the object that can have subscript part.
      • SUPERSCRIPT_PART = 25

        public static final int SUPERSCRIPT_PART
        Superscript of the superscript object.
      • PRE_SUB_SUPERSCRIPT = 26

        public static final int PRE_SUB_SUPERSCRIPT
        Pre-Sub-Superscript object, which consists of a base element and a subscript and superscript placed to the left of the base.
      • SUBSCRIPT = 27

        public static final int SUBSCRIPT
        Subscript object, which consists of a base element and a reduced-size script placed below and to the right.
      • SUB_SUPERSCRIPT = 28

        public static final int SUB_SUPERSCRIPT
        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.
      • SUPERCRIPT = 29

        public static final int SUPERCRIPT
        Superscript object, which consists of a base element and a reduced-size script placed above and to the right.