// for XControl
XWindowPeer the_win = null;
XToolkit the_kit = null;
XControlContainer ctrlCont = null;
XGraphics aGraphic = null;
// create 3 XControls
// create first XControl
shape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000,
10000, "TextField");
WriterTools.getDrawPage(xTextDoc).add((XShape) shape);
model = shape.getControl();
access = (XControlAccess) UnoRuntime.queryInterface(
XControlAccess.class, xTextDoc.getCurrentController());
try {
xCtrl = access.getControl(model);
} catch (Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't create XControl", e);
}
// create second XControl
shape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000,
10000, "TextField");
WriterTools.getDrawPage(xTextDoc).add((XShape) shape);
model = shape.getControl();
access = (XControlAccess) UnoRuntime.queryInterface(
XControlAccess.class, xTextDoc.getCurrentController());
try {
xCtrl1 = access.getControl(model);
} catch (Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't create XControl", e);
}
// create third XControl
shape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000,
10000, "CommandButton");
WriterTools.getDrawPage(xTextDoc).add((XShape) shape);
model = shape.getControl();
access = (XControlAccess) UnoRuntime.queryInterface(
XControlAccess.class, xTextDoc.getCurrentController());
try {
xCtrl2 = access.getControl(model);
} catch (Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't create XControl", e);
}
// create XToolkit, XWindowPeer, XDevice
//Insert a ControlShape and get the ControlModel
XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000,
4500, 15000,
10000,
"CommandButton",
"UnoControlButton");
WriterTools.getDrawPage(xTD2).add((XShape) aShape);
XControlModel the_Model = aShape.getControl();
//Try to query XControlAccess
XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface(
XControlAccess.class,
xTD2.getCurrentController());
//get the ButtonControl for the needed Object relations
try {
the_win = the_access.getControl(the_Model).getPeer();
the_kit = the_win.getToolkit();
XDevice aDevice = the_kit.createScreenCompatibleDevice(200, 200);
aGraphic = aDevice.createGraphics();
} catch (Exception e) {
log.println("Couldn't get ButtonControl");
e.printStackTrace(log);
throw new StatusException("Couldn't get ButtonControl", e);
}
try {
XController aController = xTD2.getCurrentController();
XFrame aFrame = aController.getFrame();
anotherWindow = aFrame.getComponentWindow();
} catch (Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't create XWindow", e);
}
// finished create Object Relations -----------------------------------
// create the UnoControlContainer
try {
oObj = (XInterface) ((XMultiServiceFactory) param.getMSF()).createInstance(
"com.sun.star.awt.UnoControlContainer");
XControl xCtrl = (XControl) UnoRuntime.queryInterface(
XControl.class, oObj);
xCtrl.setModel(the_Model);
ctrlCont = (XControlContainer) UnoRuntime.queryInterface(
XControlContainer.class, oObj);
ctrlCont.addControl("jupp", access.getControl(aShape.getControl()));
} catch (Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't create UnoControlContainer", e);
}