AppletShape properties not working

Hello,

I’m trying to understand how the ‘com.sun.star.drawing.AppletShape’ Service is working.
I have no problem to create and add this shape (here as an example in calc in python):

def appletShape():
	doc = XSCRIPTCONTEXT.getDocument()
	sheet = doc.Sheets[0]
	drawPage = sheet.DrawPage
	
	appletShape = doc.createInstance('com.sun.star.drawing.AppletShape')
	drawPage.add(appletShape)

The properties as per description https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1drawing_1_1AppletShape.html are visible (I see them in the MRI-tool, I can also see them if I create the AppletShape in the APSO-console).

The problem is, I cannot change them. For example, if I try to change the AppletName after the creation, it crashes the application (calc, draw, impress on both OS).

I’m trying to understand if I do something wrong (or if this a bug) and in case mistake is on my side how to do it the right way.

Many thanks for your consideration in advance!

Manipulate the object before you attach it to the draw page.

Hello Villeroy,

thanks for your reply. This does not work for “AppletName”, “AppletCode” or “AppletCodeBase” for me. Directly crashes the application.

Works for you?

Best regards

How can I test this without any applet, let alone applet code, applet script, applet code base, whatever that means. Yes, the application may crash when the URI of some resource points into the void…

Hello VIlleroy,

If you like, try this code below:

from com.sun.star.awt import Point
from com.sun.star.awt import Size

def applet():
    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.Sheets[0]
    drawPage = sheet.DrawPage

    appletShape = doc.createInstance('com.sun.star.drawing.AppletShape')
    position = Point(200, 200)
    size = Size(5000, 5000)
    appletShape.setPosition(position)
    appletShape.setSize(size)
    appletShape.AppletName = 'Test'    

On my PCs, this last codeline crashes the application.

So the usual shape attributes are working fine, but the specific AppletShape attributs do not. According to API, the AppletName is a simple String, so just naming it ‘test’ cannot be wrong.

Yes, it crashes.