// Insert it at the end of the document
mxDocText.insertTextContent ( mxDocText.getEnd(), xDateField, false );
// Use the text document's factory to create a user text field,
// and access it's XDependentTextField interface
XDependentTextField xUserField =
(XDependentTextField) UnoRuntime.queryInterface (
XDependentTextField.class, mxDocFactory.createInstance (
"com.sun.star.text.TextField.User" ) );
// Create a fieldmaster for our newly created User Text field, and access it's
// XPropertySet interface
XPropertySet xMasterPropSet = (XPropertySet) UnoRuntime.queryInterface (
XPropertySet.class, mxDocFactory.createInstance (
"com.sun.star.text.FieldMaster.User" ) );
// Set the name and value of the FieldMaster
xMasterPropSet.setPropertyValue ( "Name", "UserEmperor" );
xMasterPropSet.setPropertyValue ( "Value", new Integer ( 42 ) );
// Attach the field master to the user field
xUserField.attachTextFieldMaster ( xMasterPropSet );
// Move the cursor to the end of the document
mxDocCursor.gotoEnd( false );
// insert a paragraph break using the XSimpleText interface
mxDocText.insertControlCharacter (