Inserting an existing OLE object into a Shape

Creating a macro - Writing a Script - Using the API

Inserting an existing OLE object into a Shape

Postby Waldo » Wed Jan 03, 2018 11:28 pm

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?
LibreOffice 5.3.7 on Windows 7
Waldo
 
Posts: 4
Joined: Tue Jan 02, 2018 7:39 pm

Re: inserting an existing OLE object into a Shape

Postby Zizi64 » Sat Jan 06, 2018 7:50 pm

A user can insert an embedded object via the GUI


Please upload an ODF type sample file here.
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8152
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: inserting an existing OLE object into a Shape

Postby UnklDonald418 » Wed Jan 17, 2018 6:10 am

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.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1200
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Inserting an existing OLE object into a Shape

Postby hubert lambert » Wed Jan 17, 2018 6:15 pm

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.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 129
Joined: Mon Jun 13, 2016 10:50 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests