Beispiel #1
0
  private XTextComponent insertTextField(
      int posX, int posY, int width, int height, String text, char echoChar) throws Exception {

    // Create a unique name
    String uniqueName = createUniqueName(xDialogModelNameContainer, "TextField");

    // Create an editable text field control model
    Object oTextFieldModel =
        xMultiComponentFactoryDialogModel.createInstance("com.sun.star.awt.UnoControlEditModel");

    // Set the properties at the model
    XPropertySet xTextFieldPropertySet =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTextFieldModel);
    xTextFieldPropertySet.setPropertyValue("PositionX", new Integer(posX));
    xTextFieldPropertySet.setPropertyValue("PositionY", new Integer(posY));
    xTextFieldPropertySet.setPropertyValue("Height", new Integer(height));
    xTextFieldPropertySet.setPropertyValue("Width", new Integer(width));
    xTextFieldPropertySet.setPropertyValue("Text", (text != null) ? text : "");
    xTextFieldPropertySet.setPropertyValue("Name", uniqueName);
    xTextFieldPropertySet.setPropertyValue("MultiLine", false);
    xTextFieldPropertySet.setPropertyValue("ReadOnly", false);

    if (echoChar != 0 && echoChar != ' ') {
      // Useful for password fields
      xTextFieldPropertySet.setPropertyValue("EchoChar", new Short((short) echoChar));
    }

    // Add the model to the dialog model name container
    xDialogModelNameContainer.insertByName(uniqueName, oTextFieldModel);

    // Reference the control by the unique name
    XControl xTextFieldControl = xDialogContainer.getControl(uniqueName);

    return (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xTextFieldControl);
  }
Beispiel #2
0
  /**
   * Makes a string unique by appending a numerical suffix.
   *
   * @param elementContainer The container the new element is going to be inserted to
   * @param elementName The name of the element
   */
  public XTextComponent insertTextFrame(int posX, int posY, int width, String text)
      throws Exception {

    // Create a unique name
    String uniqueName = createUniqueName(xDialogModelNameContainer, "TextFrame");

    // Create an editable text field control model
    Object oTextFrameModel =
        xMultiComponentFactoryDialogModel.createInstance("com.sun.star.text.TextFrame");

    // Set the properties at the model
    XPropertySet xTextFramePropertySet =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTextFrameModel);
    xTextFramePropertySet.setPropertyValue("PositionX", new Integer(posX));
    xTextFramePropertySet.setPropertyValue("PositionY", new Integer(posY));
    xTextFramePropertySet.setPropertyValue("Height", new Integer(12));
    xTextFramePropertySet.setPropertyValue("Width", new Integer(width));
    xTextFramePropertySet.setPropertyValue("Text", (text != null) ? text : "");
    xTextFramePropertySet.setPropertyValue("Name", uniqueName);

    // Add the model to the dialog model name container
    xDialogModelNameContainer.insertByName(uniqueName, xTextFramePropertySet);

    // Reference the control by the unique name
    XControl xEditableTextFieldControl = xDialogContainer.getControl(uniqueName);

    return (XTextComponent)
        UnoRuntime.queryInterface(XTextComponent.class, xEditableTextFieldControl);
  }
Beispiel #3
0
  public XFixedText insertFixedText(int posX, int posY, int height, int width, String label)
      throws Exception {

    // Create a unique name
    String uniqueName = createUniqueName(xDialogModelNameContainer, "FixedText");

    // Create a fixed text control model
    Object oFixedTextModel =
        xMultiComponentFactoryDialogModel.createInstance(
            "com.sun.star.awt.UnoControlFixedTextModel");

    // Set the properties at the model
    XPropertySet xFixedTextPropertySet =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFixedTextModel);
    xFixedTextPropertySet.setPropertyValue("PositionX", new Integer(posX));
    xFixedTextPropertySet.setPropertyValue("PositionY", new Integer(posY + 2));
    xFixedTextPropertySet.setPropertyValue("Height", new Integer(height));
    xFixedTextPropertySet.setPropertyValue("Width", new Integer(width));
    xFixedTextPropertySet.setPropertyValue("Label", (label != null) ? label : "");
    xFixedTextPropertySet.setPropertyValue("Name", uniqueName);

    // Add the model to the dialog model name container
    xDialogModelNameContainer.insertByName(uniqueName, oFixedTextModel);

    // Reference the control by the unique name
    XControl xFixedTextControl = xDialogContainer.getControl(uniqueName);

    return (XFixedText) UnoRuntime.queryInterface(XFixedText.class, xFixedTextControl);
  }
Beispiel #4
0
  public XComboBox insertComboBox(
      int posX, int posY, int width, String[] stringItemList, String Name, String Text) {
    XComboBox xComboBox = null;
    try {
      // create a unique name by means of an own implementation...
      String sName = Name; // createUniqueName(xDialogModelNameContainer, "ComboBox");

      // create a controlmodel at the multiservicefactory of the dialog model...
      Object oComboBoxModel =
          xMultiComponentFactoryDialogModel.createInstance(
              "com.sun.star.awt.UnoControlComboBoxModel");

      XPropertySet xComboBOxPropertySet =
          (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oComboBoxModel);

      /*
      //######################Debug de propriedades#########################
      XPropertySetInfo xCursorPropsInfo = xComboBOxPropertySet.getPropertySetInfo();
      Property[] aProps = xCursorPropsInfo.getProperties();
      int i;
      for (i = 0; i < aProps.length; ++i) {
      // prints Property Name
      System.out.println(aProps[i].Name);
      }
      */

      xComboBOxPropertySet.setPropertyValue("Dropdown", true);
      xComboBOxPropertySet.setPropertyValue("Step", 3);
      xComboBOxPropertySet.setPropertyValue("PositionX", new Integer(posX));
      xComboBOxPropertySet.setPropertyValue("PositionY", new Integer(posY));
      xComboBOxPropertySet.setPropertyValue("Height", new Integer(12));
      xComboBOxPropertySet.setPropertyValue("Width", new Integer(width));
      xComboBOxPropertySet.setPropertyValue("StringItemList", stringItemList);
      xComboBOxPropertySet.setPropertyValue("Name", sName);
      xComboBOxPropertySet.setPropertyValue("Text", Text);

      xDialogModelNameContainer.insertByName(sName, oComboBoxModel);
      XControl xControl = xDialogContainer.getControl(sName);

      // retrieve a ComboBox that is more convenient to work with than the Model of the ComboBox...
      xComboBox = (XComboBox) UnoRuntime.queryInterface(XComboBox.class, xControl);

    } catch (com.sun.star.uno.Exception ex) {
      SpeechOO.logger = org.apache.log4j.Logger.getLogger(TrainingDialog.class.getName());
      SpeechOO.logger.error(ex);
    }
    return xComboBox;
  }