[Libreoffice-bugs] [Bug 129437] [PYUNO] "setPropertyValue" method does not accept particular Enum value

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Mon Jan 6 21:46:27 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=129437

--- Comment #5 from jeanmarczambon at gmail.com ---
> Exactly what corresponding Basic and Java code does not exhibit this issue?
I was half wrong.

If this basic code rases no error:

Sub any_enum_test():
    button_model = createUnoService("com.sun.star.awt.UnoControlButtonModel")
    button_types = com.sun.star.awt.PushButtonType
    button_model.setPropertyValue("PushButtonType", button_types.OK)
    print button_model.PushButtonType 'PushButtonType = 1
End Sub


Java does indeed need conversion, as shown by this (not tested) snippet from
the Developpers's Guide, that helped me for the python code:

public XButton insertButton(XActionListener _xActionListener, int _nPosX, int
_nPosY, int _nWidth, String _sLabel, short _nPushButtonType){
  XButton xButton = null;
  try{
    [...]
    xButtonMPSet.setPropertyValues(
      new String[] {"Height", "Label", "Name", "PositionX", "PositionY",
"PushButtonType", "Width" } ,
      new Object[] {new Integer(14), _sLabel, sName, new Integer(_nPosX), new
Integer(_nPosY), new Short(_nPushButtonType), new Integer(_nWidth)});
    [...]

I totally forgot the "Short" type conversion. So you were right, this could be
the expected behaviour, and the correct Python translation should be something
like this (that works):

    uno.invoke(button_model, "setPropertyValue", ("PushButtonType",
uno.Any("short", OK)))

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200106/b7d1adac/attachment.htm>


More information about the Libreoffice-bugs mailing list