public static XControlShape createControlShape( XComponent oDoc, int height,
int width, int x, int y, String kind ) {
Size size = new Size();
Point position = new Point();
XControlShape oCShape = null;
XControlModel aControl = null;
//get MSF
XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
try{
Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
XPropertySet model_props = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,aCon);
model_props.setPropertyValue("DefaultControl","com.sun.star.form.control."+kind);
aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
size.Height = height;
size.Width = width;
position.X = x;
position.Y = y;
oCShape.setSize(size);
oCShape.setPosition(position);
} catch ( com.sun.star.uno.Exception e ) {
// Some exception occures.FAILED
System.out.println( "Couldn't create instance "+ e );
}
oCShape.setControl(aControl);
return oCShape;
} // finish createControlShape