// 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 );
xDocShapes.add( xShape );
// some initializations which are the same for all controls
XPropertySet xModelProps = UNO.queryPropertySet( xModel );
try
{
XPropertySetInfo xPSI = xModelProps.getPropertySetInfo();
if ( xPSI.hasPropertyByName( "Border" ) )
{
if ( ((Short)xModelProps.getPropertyValue( "Border" )).shortValue() == com.sun.star.awt.VisualEffect.LOOK3D )
xModelProps.setPropertyValue( "Border", new Short( com.sun.star.awt.VisualEffect.FLAT ) );
}
if ( xPSI.hasPropertyByName( "VisualEffect" ) )
xModelProps.setPropertyValue( "VisualEffect", new Short( com.sun.star.awt.VisualEffect.FLAT ) );
if ( m_document.classify() != DocumentType.CALC )
if ( xPSI.hasPropertyByName( "BorderColor" ) )
xModelProps.setPropertyValue( "BorderColor", new Integer( 0x00C0C0C0 ) );
}
catch( com.sun.star.uno.Exception e )
{
System.err.println(e);
e.printStackTrace( System.err );