Hey, I've been looking to merge an unknown nr. of documents in order to print them using a custom method. And so I came up to this code but there are a few things that are bothering me, which might be related to me being new to OOo Uno programming. All the documents are always OpenOffice 2.4 populated Writer templates.
The problems I have are here: serviceFactory.createInstance("com.sun.star.text.TextSection", document1) I can't seem to find a (X)ServiceFactory type that allows two arguments (String, Object?). also the use of the method "componentExport". I know I should find it somewhere in the added links around here but with the first problem being unresolved, I haven't really gotten around to this one. Thanks at any rate already. This thread does already showed that there is a possible solution to this. Grover Blue wrote: > > I got everything to work, except for images and horizontal line objects. > Images are completely ignored and not imported into the document, whereas > horizontal line objects are flushing themselves at the top of the current > page. > > I do have a question about the section I am using. If you look at the > following code, am I properly inserting the second document (document2) > into > the newly created section? > > Here is my routine: > > public void appendDocument(XTextDocument document1, XTextDocument > document2) > throws IllegalArgumentException, java.lang.Exception { > > XText xDocText = document1.getText(); > XTextCursor xOrigDocTextCursor = xDocText.createTextCursor(); > XNamed xChildNamed; > XTextContent xChildContent; > String tempDoc = generateTempDocucmentPathName(); > > xOrigDocTextCursor.gotoEnd(false); > > xDocText.insertControlCharacter(xOrigDocTextCursor, > ControlCharacter.PARAGRAPH_BREAK, false); > > xChildNamed = (XNamed) UnoRuntime.queryInterface( > XNamed.class, > > serviceFactory.createInstance("com.sun.star.text.TextSection", > document1)); > > xChildNamed.setName("" + document2.hashCode()); > > xChildContent = (XTextContent) UnoRuntime.queryInterface( > XTextContent.class, > xChildNamed); > > /* Add document2 to the new section */ > xDocText.insertTextContent(xOrigDocTextCursor, xChildContent, > false); > > PropertyValue[] storeProps = createPropertyValueArray( > createPropertyValue("FilterName", new > Any(Type.STRING, "writer8_template")), > createPropertyValue("CompressionMode", new > Any(Type.STRING, "1")), > createPropertyValue("Pages", new > Any(Type.STRING, "All")), > createPropertyValue("Overwrite", new > Any(Type.BOOLEAN, Boolean.TRUE))); > > componentExport(document2, storeProps, tempDoc); > > XDocumentInsertable xDocI = (XDocumentInsertable) > UnoRuntime.queryInterface( > XDocumentInsertable.class, > xOrigDocTextCursor); > > PropertyValue[] loadProps=new PropertyValue[0]; > > xDocI.insertDocumentFromURL("file:///" + tempDoc, loadProps); > > deleteFile(tempDoc); > } > > -- View this message in context: http://www.nabble.com/Sections-and-appending-documents-tp22312435p22541182.html Sent from the openoffice - dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org