zariguella Newbie

Joined: 05 Nov 2010 Posts: 2
|
Posted: Fri Nov 05, 2010 3:55 am Post subject: Insert document in to another document. Problem OLE images |
|
|
I'm using the api of writer in my java program and I have a problem when inserting the odt document content in another document created by the api. The problem is that when using insertDocumentfromUrl the document content is inserted but I have problems with OLE images. These images are not introduced and instead i get a box with a picture of a plug and the text object.
What could be the problem? There is another way to insert content of a document in my new document?
However if i use openoffice to insert the same document in an other one using insert-> file all the content is introducced correctly, images too.
Here is the java code I use to do this:
| Code: | private void nuevoWriter() {
loadProps = new PropertyValue[1];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
try {
document = xComponentLoader
.loadComponentFromURL(
"file:///C:/Documents and Settings/Plantilla.odt",
"_blank", 0, loadProps);
} catch (IllegalArgumentException ex) {
System.out.println("Error de direccion de plantilla");
System.out.println(ex);
} catch (com.sun.star.io.IOException ioex) {
System.out.println("Error de direccion de plantilla");
System.out.println(ioex);
} catch (java.lang.NullPointerException ex) {
System.out.println("Error con el nuevo documento Null pointer");
System.out.println(ex);
}
aTextDocument = (XTextDocument) UnoRuntime.queryInterface(
com.sun.star.text.XTextDocument.class, document);
xText = aTextDocument.getText();
TextCursor = xText.createTextCursor();
}
public static void writeDocument(Node nodo) { //nodo has the url to the document
loadProps = new PropertyValue[1];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
System.out.println("aƱadiendo fichero" + nodo.getTextContent());
TextCursor.gotoEnd(true);
XDocumentInsertable xd = (XDocumentInsertable) UnoRuntime
.queryInterface(XDocumentInsertable.class, TextCursor);
try {
xd.insertDocumentFromURL("file:///" + nodo.getTextContent(),
loadProps);
} catch (IllegalArgumentException ex) {
System.out
.println("No encuentra documento a insertar por fallo en ruta");
System.out.println(ex);
} catch (com.sun.star.io.IOException ex) {
System.out.println("Fallo en el documento a insertar");
System.out.println(ex);
}
TextCursor.gotoEnd(false);
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, TextCursor);
try {
xProps.setPropertyValue("BreakType", new Integer(
com.sun.star.style.BreakType.PAGE_AFTER_value));
xText.insertControlCharacter(TextCursor,
ControlCharacter.PARAGRAPH_BREAK, false);
xProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, TextCursor);
xProps.setPropertyValue("BreakType", new Integer(
com.sun.star.style.BreakType.NONE_value));
} catch (UnknownPropertyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WrappedTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
|
|