OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Insert document in to another document. Problem OLE images

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
zariguella
Newbie
Newbie


Joined: 05 Nov 2010
Posts: 2

PostPosted: Fri Nov 05, 2010 3:55 am    Post subject: Insert document in to another document. Problem OLE images Reply with quote

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();
      }
   }

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group