com.aspose.words

Class Forms2OleControl

  • java.lang.Object
public abstract class Forms2OleControl 
extends OleControl

Represents Microsoft Forms 2.0 OLE control.

Example:

Shows how to get ActiveX control and properties from the document.
Document doc = new Document(getMyDir() + "ActiveX controls.docx");

// Get ActiveX control from the document
Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
OleControl oleControl = shape.getOleFormat().getOleControl();

Assert.assertEquals(oleControl.getName(), null);

// Get ActiveX control properties
if (oleControl.isForms2OleControl()) {
    Forms2OleControl checkBox = (Forms2OleControl) oleControl;
    Assert.assertEquals(checkBox.getCaption(), "Первый");
    Assert.assertEquals(checkBox.getValue(), "0");
    Assert.assertEquals(checkBox.getEnabled(), true);
    Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
    Assert.assertEquals(checkBox.getChildNodes(), null);
}

Property Getters/Setters Summary
java.lang.StringgetCaption()
Gets Caption property of control. Default value is an empty string.
Forms2OleControlCollectiongetChildNodes()
Gets collection of immediate child controls.
booleangetEnabled()
Returns true if control is in enabled state.
booleanisForms2OleControl()
java.lang.StringgetName()
Gets name of the ActiveX control.
intgetType()
Gets type of Forms 2.0 control. The value of the property is Forms2OleControlType integer constant.
java.lang.StringgetValue()
Gets underlying Value property which often represents control state. For example checked option button has '1' value while unchecked has '0'. Default value is an empty string.
 

    • Property Getters/Setters Detail

      • getCaption

        public java.lang.String getCaption()
        
        Gets Caption property of control. Default value is an empty string.

        Example:

        Shows how to get ActiveX control and properties from the document.
        Document doc = new Document(getMyDir() + "ActiveX controls.docx");
        
        // Get ActiveX control from the document
        Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
        OleControl oleControl = shape.getOleFormat().getOleControl();
        
        Assert.assertEquals(oleControl.getName(), null);
        
        // Get ActiveX control properties
        if (oleControl.isForms2OleControl()) {
            Forms2OleControl checkBox = (Forms2OleControl) oleControl;
            Assert.assertEquals(checkBox.getCaption(), "Первый");
            Assert.assertEquals(checkBox.getValue(), "0");
            Assert.assertEquals(checkBox.getEnabled(), true);
            Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
            Assert.assertEquals(checkBox.getChildNodes(), null);
        }
      • getChildNodes

        public Forms2OleControlCollection getChildNodes()
        
        Gets collection of immediate child controls. Returns null if this control can not have children.

        Example:

        Shows how to get ActiveX control and properties from the document.
        Document doc = new Document(getMyDir() + "ActiveX controls.docx");
        
        // Get ActiveX control from the document
        Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
        OleControl oleControl = shape.getOleFormat().getOleControl();
        
        Assert.assertEquals(oleControl.getName(), null);
        
        // Get ActiveX control properties
        if (oleControl.isForms2OleControl()) {
            Forms2OleControl checkBox = (Forms2OleControl) oleControl;
            Assert.assertEquals(checkBox.getCaption(), "Первый");
            Assert.assertEquals(checkBox.getValue(), "0");
            Assert.assertEquals(checkBox.getEnabled(), true);
            Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
            Assert.assertEquals(checkBox.getChildNodes(), null);
        }
      • getEnabled

        public boolean getEnabled()
        
        Returns true if control is in enabled state.

        Example:

        Shows how to get ActiveX control and properties from the document.
        Document doc = new Document(getMyDir() + "ActiveX controls.docx");
        
        // Get ActiveX control from the document
        Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
        OleControl oleControl = shape.getOleFormat().getOleControl();
        
        Assert.assertEquals(oleControl.getName(), null);
        
        // Get ActiveX control properties
        if (oleControl.isForms2OleControl()) {
            Forms2OleControl checkBox = (Forms2OleControl) oleControl;
            Assert.assertEquals(checkBox.getCaption(), "Первый");
            Assert.assertEquals(checkBox.getValue(), "0");
            Assert.assertEquals(checkBox.getEnabled(), true);
            Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
            Assert.assertEquals(checkBox.getChildNodes(), null);
        }
      • isForms2OleControl

        public boolean isForms2OleControl()
        
      • getName

        public java.lang.String getName()
        
        Gets name of the ActiveX control.

        Example:

        Shows how to get ActiveX control and properties from the document.
        Document doc = new Document(getMyDir() + "ActiveX controls.docx");
        
        // Get ActiveX control from the document
        Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
        OleControl oleControl = shape.getOleFormat().getOleControl();
        
        Assert.assertEquals(oleControl.getName(), null);
        
        // Get ActiveX control properties
        if (oleControl.isForms2OleControl()) {
            Forms2OleControl checkBox = (Forms2OleControl) oleControl;
            Assert.assertEquals(checkBox.getCaption(), "Первый");
            Assert.assertEquals(checkBox.getValue(), "0");
            Assert.assertEquals(checkBox.getEnabled(), true);
            Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
            Assert.assertEquals(checkBox.getChildNodes(), null);
        }
      • getType

        public int getType()
        
        Gets type of Forms 2.0 control. The value of the property is Forms2OleControlType integer constant.

        Example:

        Shows how to get ActiveX control and properties from the document.
        Document doc = new Document(getMyDir() + "ActiveX controls.docx");
        
        // Get ActiveX control from the document
        Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
        OleControl oleControl = shape.getOleFormat().getOleControl();
        
        Assert.assertEquals(oleControl.getName(), null);
        
        // Get ActiveX control properties
        if (oleControl.isForms2OleControl()) {
            Forms2OleControl checkBox = (Forms2OleControl) oleControl;
            Assert.assertEquals(checkBox.getCaption(), "Первый");
            Assert.assertEquals(checkBox.getValue(), "0");
            Assert.assertEquals(checkBox.getEnabled(), true);
            Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
            Assert.assertEquals(checkBox.getChildNodes(), null);
        }
      • getValue

        public java.lang.String getValue()
        
        Gets underlying Value property which often represents control state. For example checked option button has '1' value while unchecked has '0'. Default value is an empty string.

        Example:

        Shows how to get ActiveX control and properties from the document.
        Document doc = new Document(getMyDir() + "ActiveX controls.docx");
        
        // Get ActiveX control from the document
        Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
        OleControl oleControl = shape.getOleFormat().getOleControl();
        
        Assert.assertEquals(oleControl.getName(), null);
        
        // Get ActiveX control properties
        if (oleControl.isForms2OleControl()) {
            Forms2OleControl checkBox = (Forms2OleControl) oleControl;
            Assert.assertEquals(checkBox.getCaption(), "Первый");
            Assert.assertEquals(checkBox.getValue(), "0");
            Assert.assertEquals(checkBox.getEnabled(), true);
            Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
            Assert.assertEquals(checkBox.getChildNodes(), null);
        }