Page 1 of 1

Inserting an existing OLE object into a Shape

PostPosted: Wed Jan 03, 2018 11:28 pm
by Waldo
I'm working on a project with a group and we've hit a stumbling block dealing with OLE objects. We've done a lot of research on this subject and can't find a way to insert an existing OLE object into a Shape using either macros or Java.

We know how to create an ole2shape object but the problem is that the model and embeddedobject properties are always set to read only. A user can insert an embedded object via the GUI so I feel like this has to be possible in some form or another. However, I'm worried that it may not be possible to do so programmatically since the API may not allow it. We know how to create an embedded object but can't figure out how to get that newly created embedded object into a shape object. Do we need to start with a different object that allows us to insert an embedded object and then convert it to a shape? Based on the LibreOffice source code it seems like that would be one way it works. Does anyone have any ideas on how to do this?

We've looked through the LibreOffice source code but probably need to see the Java API source code as well. Unfortunately I can't seem to find the Java API source code. Does anyone know if that's available somewhere?

Re: inserting an existing OLE object into a Shape

PostPosted: Sat Jan 06, 2018 7:50 pm
by Zizi64
A user can insert an embedded object via the GUI


Please upload an ODF type sample file here.

Re: inserting an existing OLE object into a Shape

PostPosted: Wed Jan 17, 2018 6:10 am
by UnklDonald418
Have you looked at Andrew Davidson's web site
http://fivedots.coe.psu.ac.th/~ad/jlop/
In addition to his book “Java LibreOffice Programming” he also gives his email address.

Re: Inserting an existing OLE object into a Shape

PostPosted: Wed Jan 17, 2018 6:15 pm
by hubert lambert
Hello,

Here is an example in basic, that inserts an empty Calc spreadsheet object into a writer document :
Code: Select all   Expand viewCollapse view
    doc = thiscomponent
    embed = doc.createInstance("com.sun.star.text.TextEmbeddedObject")
    embed.CLSID = "47BBB4CB-CE4C-4E80-a591-42d9ae74950f"
    dim size as new com.sun.star.awt.Size
    size.Height = 2500
    size.Width  = 10000
    embed.setSize(size)
    T = doc.Text
    T.insertTextContent(T.End, embed, False)

CLSID is unique for each OLE object type, but I can't find in the documentation a complete list. Just create an OLE object with the gui and inspect it to find the corresponding CLSID...
Regards.