mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, true );
// Create a new TextSection from the document factory and access it's XNamed interface
XNamed xChildNamed = (XNamed) UnoRuntime.queryInterface( XNamed.class,
mxDocFactory.createInstance( "com.sun.star.text.TextSection" ) );
// Set the new sections name to 'Child_Section'
xChildNamed.setName ( "Child_Section" );
// Access the Child_Section's XTextContent interface and insert it into the document
XTextContent xChildSection = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xChildNamed );
mxDocText.insertTextContent ( mxDocCursor, xChildSection, false );
// Access the XParagraphCursor interface of our text cursor
XParagraphCursor xParaCursor = (XParagraphCursor) UnoRuntime.queryInterface(
XParagraphCursor.class, mxDocCursor );
// Go back one paragraph (into Child_Section)
xParaCursor.gotoPreviousParagraph ( false );
// Insert a string into the Child_Section
mxDocText.insertString ( mxDocCursor, "This is a test", false );
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Go back two paragraphs
xParaCursor.gotoPreviousParagraph ( false );
xParaCursor.gotoPreviousParagraph ( false );
// Go to the end of the document, selecting the two paragraphs
mxDocCursor.gotoEnd ( true );
// Create another text section and access it's XNamed interface
XNamed xParentNamed = (XNamed) UnoRuntime.queryInterface( XNamed.class,
mxDocFactory.createInstance( "com.sun.star.text.TextSection" ) );
// Set this text section's name to Parent_Section
xParentNamed.setName ( "Parent_Section" );
// Access the Parent_Section's XTextContent interface ...
XTextContent xParentSection = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xParentNamed );
// ...and insert it into the document
mxDocText.insertTextContent ( mxDocCursor, xParentSection, false );
// Go to the end of the document
mxDocCursor.gotoEnd ( false );
// Insert a new paragraph
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// And select the new pargraph
xParaCursor.gotoPreviousParagraph ( true );
// Create a new Text Section and access it's XNamed interface
XNamed xLinkNamed = (XNamed) UnoRuntime.queryInterface( XNamed.class,
mxDocFactory.createInstance( "com.sun.star.text.TextSection" ) );
// Set the new text section's name to Linked_Section
xLinkNamed.setName ( "Linked_Section" );
// Access the Linked_Section's XTextContent interface
XTextContent xLinkedSection = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xLinkNamed );
// And insert the Linked_Section into the document