documentText.insertString( textCursor, "Below, there's a table cell, and a text field. ", false );
documentText.insertString( textCursor, "Both are linked via an external value binding.\n", false );
documentText.insertString( textCursor, "That means that anything you insert into the table cell is reflected in the ", false );
documentText.insertString( textCursor, "text field, and vice versa.\n", false );
XTextTable table = (XTextTable)UnoRuntime.queryInterface( XTextTable.class,
m_document.createInstance( "com.sun.star.text.TextTable" )
);
table.initialize( 1, 1 );
documentText.insertTextContent( textCursor, table, false );
// insert our sample control
XPropertySet textControl = m_formLayer.insertControlLine( "DatabaseTextField", "enter some text", "", 30 );
// create a value binding for the first cell of the table
XValueBinding cellBinding = new TableCellTextBinding( table.getCellByName( "A1" ) );
// and bind it to the control
XBindableValue bindable = (XBindableValue)UnoRuntime.queryInterface(
XBindableValue.class, textControl
);
bindable.setValueBinding( cellBinding );