Does anyone have an example of inserting a section and merging two
XTextDocuments?
I'm stuck. Below is what I have so far, but I'm not sure how to insert the
second document.
public void appendDocument(XTextDocument document1, XTextDocument document2)
throws IllegalArgumentException, java.lang.Exception {
XText xDocText = document1.getText();
XTextCursor xOrigDocTextCursor = xDocText.createTextCursor();
XNamed xChildNamed;
XTextContent xChildContent;
XPropertySet xOrigDocTextCursorProp;
xOrigDocTextCursor.gotoEnd(false);
xDocText.insertControlCharacter(xOrigDocTextCursor,
ControlCharacter.PARAGRAPH_BREAK, false);
xOrigDocTextCursorProp = (XPropertySet)
FileManager.getOOoUnoRuntimeQueryInterface(
XPropertySet.class,
xOrigDocTextCursor);
xOrigDocTextCursorProp.setPropertyValue("BreakType",
BreakType.PAGE_BEFORE);
xChildNamed = (XNamed) FileManager.getOOoUnoRuntimeQueryInterface(
XNamed.class,
FileManager.getOOoUnoRuntimeCreateInstance("com.sun.star.text.TextSection"));
xChildNamed.setName("NewSection");
xChildContent = (XTextContent)
FileManager.getOOoUnoRuntimeQueryInterface(
XTextContent.class,
xChildNamed);
/* Add document2 to the new section somehow */
xDocText.insertTextContent(xOrigDocTextCursor, xChildContent,
false);
Thanks