WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
XLoadable formLoader = FormTools.bindForm(xTextDoc);
//Try to query XControlAccess
XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface(
XControlAccess.class,
xTextDoc.getCurrentController());
try {
columns = (XGridColumnFactory) UnoRuntime.queryInterface(
XGridColumnFactory.class, the_Model);
aControl = columns.createColumn("TextField");
aControl.setPropertyValue("DataField", "Identifier");
aControl.setPropertyValue("Label", "Identifier");
aControl2 = columns.createColumn("TextField");
aControl2.setPropertyValue("DataField", "Publisher");
aControl2.setPropertyValue("Label", "Publisher");
aControl3 = columns.createColumn("TextField");
aControl3.setPropertyValue("DataField", "Author");
aControl3.setPropertyValue("Label", "Author");
aControl4 = columns.createColumn("TextField");
aControl4.setPropertyValue("DataField", "Title");
aControl4.setPropertyValue("Label", "Title");
} catch (com.sun.star.lang.IllegalArgumentException e) {
// Some exception occures.FAILED
log.println("!!! Couldn't create instance : " + e);
throw new StatusException("Can't create column instances.", e);
} catch (com.sun.star.lang.WrappedTargetException e) {
// Some exception occures.FAILED
log.println("!!! Couldn't create instance : " + e);
throw new StatusException("Can't create column instances.", e);
} catch (com.sun.star.beans.PropertyVetoException e) {
// Some exception occures.FAILED
log.println("!!! Couldn't create instance : " + e);
throw new StatusException("Can't create column instances.", e);
} catch (com.sun.star.beans.UnknownPropertyException e) {
// Some exception occures.FAILED
log.println("!!! Couldn't create instance : " + e);
throw new StatusException("Can't create column instances.", e);
}
XNameContainer aContainer = (XNameContainer) UnoRuntime.queryInterface(
XNameContainer.class, the_Model);
try {
aContainer.insertByName("First", aControl);
aContainer.insertByName("Second", aControl2);
} catch (com.sun.star.uno.Exception e) {
log.println("!!! Could't insert column Instance");
e.printStackTrace(log);
throw new StatusException("Can't insert columns", e);
}
//now get the OGridControl
try {
oObj = the_access.getControl(the_Model);
the_win = the_access.getControl(the_Model).getPeer();
the_kit = the_win.getToolkit();
aDevice = the_kit.createScreenCompatibleDevice(200, 200);
aGraphic = aDevice.createGraphics();
} catch (com.sun.star.uno.Exception e) {
log.println("Couldn't get GridControl");
e.printStackTrace(log);
throw new StatusException("Couldn't get GridControl", e);
}
// creating another window
aShape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000,
10000, "TextField");
WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
the_Model = aShape.getControl();
//Try to query XControlAccess
the_access = (XControlAccess) UnoRuntime.queryInterface(
XControlAccess.class,
xTextDoc.getCurrentController());
//now get the TextControl
XWindow win = null;
Object cntrl = null;
try {
cntrl = the_access.getControl(the_Model);
win = (XWindow) UnoRuntime.queryInterface(XWindow.class, cntrl);
} catch (com.sun.star.uno.Exception e) {
log.println("Couldn't get Control");
e.printStackTrace(log);
throw new StatusException("Couldn't get Control", e);