Horizontal/Vertical Line Control

From Apache OpenOffice Wiki
Jump to: navigation, search

The line control service com.sun.star.awt.UnoControlFixedLine describes the behavior of simple lines in a dialog. In most cases, the line control is used to visually subdivide a dialog. The line control may provide horizontal or vertical orientation which is determined by the Orientation property of the model as specified in com.sun.star.awt.UnoControlFixedLineModel. The label of a line control is set by the Label property. The label is only displayed if the control has a horizontal orientation.

This example inserts a line with a horizontal orientation (Orientation == 0) in a dialog:

  public void insertHorizontalFixedLine(int _nPosX, int _nPosY, int _nWidth, String _sLabel){
      // create a unique name by means of an own implementation...
      String sName = createUniqueName(m_xDlgModelNameContainer, "FixedLine");
      // create a controlmodel at the multiservicefactory of the dialog model... 
      Object oFLModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedLineModel");
      XMultiPropertySet xFLModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFLModel);
      // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
      new String[] {"Height", "Name", "Orientation", "PositionX", "PositionY", "Width"},
      new Object[] { new Integer(2), sName, new Integer(0), new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
      // The controlmodel is not really available until inserted to the Dialog container
      m_xDlgModelNameContainer.insertByName(sName, oFLModel);
      // The following property may also be set with XMultiPropertySet but we
      // use the XPropertySet interface merely for reasons of demonstration 
      XPropertySet xFLPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFLModel);
      xFLPSet.setPropertyValue("Label", _sLabel);
  }catch (com.sun.star.uno.Exception ex){
      /* perform individual exception handling here.
       * Possible exception types are:
       * com.sun.star.lang.IllegalArgumentException,
       * com.sun.star.lang.WrappedTargetException,
       * com.sun.star.container.ElementExistException,
       * com.sun.star.beans.PropertyVetoException,
       * com.sun.star.beans.UnknownPropertyException,
       * com.sun.star.uno.Exception
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages