// query for the XLayerManager
XLayerSupplier xLayerSupplier = (XLayerSupplier)
(XLayerSupplier)UnoRuntime.queryInterface(
XLayerSupplier.class, xDrawDoc );
XNameAccess xNameAccess = xLayerSupplier.getLayerManager();
XLayerManager xLayerManager = (XLayerManager)
(XLayerManager)UnoRuntime.queryInterface(
XLayerManager.class, xNameAccess );
// create a layer and set its properties
XPropertySet xLayerPropSet;
XLayer xNotVisibleAndEditable = xLayerManager.insertNewByIndex(
xLayerManager.getCount() );
xLayerPropSet = (XPropertySet)
(XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xNotVisibleAndEditable );
xLayerPropSet.setPropertyValue( "Name", "NotVisibleAndEditable" );
xLayerPropSet.setPropertyValue( "IsVisible", new Boolean( false ) );
xLayerPropSet.setPropertyValue( "IsLocked", new Boolean( true ) );
// create a second layer
XLayer xNotEditable = xLayerManager.insertNewByIndex(
xLayerManager.getCount() );
xLayerPropSet = (XPropertySet)
(XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xNotEditable );
xLayerPropSet.setPropertyValue( "Name", "NotEditable" );
xLayerPropSet.setPropertyValue( "IsVisible", new Boolean( true ) );
xLayerPropSet.setPropertyValue( "IsLocked", new Boolean( true ) );
// attach the layer to the rectangles
xLayerManager.attachShapeToLayer( xRect1, xNotVisibleAndEditable );
xLayerManager.attachShapeToLayer( xRect2, xNotEditable );
}
catch( Exception ex )
{
System.out.println( ex );