Dear all,
I need to use the OpenOffice Java API to copy a document section and paste it over another document section. So far I have managed to copy the text of the section of the source document and paste it over the section at the target document (see the example below).
However, the problem is that non-text elements (graphics, formats, tables, etc.) don't get pasted on the destination document.
The code I have used to extract the text of the source Section is:
// Read source file text
XComponent xComponentSource = this.ooHelper.loadDocument("file://" + fSource);
// Get sections
XTextSectionsSupplier textSectionsSupplierSource = (XTextSectionsSupplier)UnoRuntime.queryInterface(XTextSectionsSupplier.class, xComponentSource);
XNameAccess nameAccessSource = textSectionsSupplierOrigen.getTextSections();
// Get sections by name
XTextSection textSectionSource = (XTextSection)UnoRuntime.queryInterface(XTextSection.class, nameAccessOrigen.getByName("SeccEditable"));
//Get section text
String sectionSource = textSectionSource.getAnchor().getString();
To paste the text over the target section, the code to select the section is the same, and I set the string:
textSectionDest.getAnchor().setString(sectionSource);
I have read the api javadoc, and I haven't found any method to copy the entire section. Is there any way to do it?
Thanks in advance, regards,