<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED NOTABUG - [PYUNO] "setPropertyValue" method does not accept particular Enum value"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=129437#c5">Comment # 5</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED NOTABUG - [PYUNO] "setPropertyValue" method does not accept particular Enum value"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=129437">bug 129437</a>
from <span class="vcard"><a class="email" href="mailto:jeanmarczambon@gmail.com" title="jeanmarczambon@gmail.com">jeanmarczambon@gmail.com</a>
</span></b>
<pre><span class="quote">> Exactly what corresponding Basic and Java code does not exhibit this issue?</span >
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)))</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>