int nYPos, int nWidth, int nHeight, XIndexContainer xParentForm ) throws java.lang.Exception
{
// let the document create a shape
XMultiServiceFactory xDocAsFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
XMultiServiceFactory.class, m_document.getDocument() );
XControlShape xShape = (XControlShape)UnoRuntime.queryInterface( XControlShape.class,
xDocAsFactory.createInstance( "com.sun.star.drawing.ControlShape" ) );
// position and size of the shape
xShape.setSize( new Size( nWidth * 100, nHeight * 100 ) );
xShape.setPosition( new Point( nXPos * 100, nYPos * 100 ) );
// adjust the anchor so that the control is tied to the page
XPropertySet xShapeProps = UNO.queryPropertySet( xShape );
TextContentAnchorType eAnchorType = TextContentAnchorType.AT_PARAGRAPH;
xShapeProps.setPropertyValue( "AnchorType", eAnchorType );
// create the form component (the model of a form control)
String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService;
XControlModel xModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class,
m_document.getOrb().createInstance( sQualifiedComponentName ) );
// insert the model into the form component hierarchy, if the caller gave us a location
if ( null != xParentForm )
{
xParentForm.insertByIndex( xParentForm.getCount(), xModel );
}
// knitt them
xShape.setControl( xModel );
// add the shape to the shapes collection of the document
XDrawPage pageWhereToInsert = ( m_insertPage != -1 ) ? m_document.getDrawPage( m_insertPage ) : m_document.getMainDrawPage();
XShapes xDocShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert );