Expanding Nodes in TreeControl, yields Error: "unsatisfied query for interface…

classic Classic list List threaded Threaded
4 messages Options
jan-3 jan-3
Reply | Threaded
Open this post in threaded view
|

Expanding Nodes in TreeControl, yields Error: "unsatisfied query for interface…

Hello Libreoffice Devs,

I’m writing on an extension [0] that uses a Tree Control in its user
interface. I want the nodes of the tree all expanded (Currently they are
collapsed, seemingly by default), but when I try to I get a
"unsatisfied query for interface…-Error.

DESCRIPTION OF USED OBJECTS/METHODS: The function to expand is
implemented in XTreeControl [1], expandNode
It takes an XTreeNode as argument. To implement the tree I use the
mutableTreeDataModel [2], I create nodes on this, attach the tree to the
control’s data model and then pass the DataModel’s root node and
TreeControl to a helper that recursively should traverse the tree and
expand all nodes.

ERROR: However, when I call treeControl.expandNode(someNode), (someNode
being a [3])I get the following error:

com.sun.star.uno.RuntimeException: unsatisfied query for interface of
type com.sun.star.awt.tree.XTreeControl! (Error during invoking function
[… callstack…]

I assumed, since the TreeControl has the method, the data model in the
one that is set for the TreeControl and XMutableTreeNode inherits from
XTreeNode, I should be able to do what I tried above.

CONTEXT: In the implementation, the critical part would be here:
("would" since I did not commit the code, but I can put it on a branch
if it helps)

https://github.com/jdittrich/Office-QDA-TagTree/blob/master/src/pythonpath/ui_logic/qdaTreePanel.py#L110

from where I would call
expandAllNodesGuiTree(treeControl.Model.DataModel.Root, treeControl)

which calls

def expandAllNodesGuiTree(root,treeControl):
    for count in range(0,root.ChildCount):
        child = root.getChildAt(count)
        treeControl.expandNode(child)
        if child.ChildCount > 0:
            expandAllNodesGuiTree(child, treeControl)

Is this problem known? I assume I messed up the types somewhere, but I
was unable to find the source of the problem.

Kind Regards,
 Jan


LINKS:
[0]: https://github.com/jdittrich/Office-QDA-TagTree
[1]:
http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1tree_1_1XTreeControl.html#ab31fac529713c7b31a0758f42d54dcc4
[2]:
http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1awt_1_1tree_1_1MutableTreeDataModel.html
[3]
http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1tree_1_1XMutableTreeNode.html
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Michael Stahl-2 Michael Stahl-2
Reply | Threaded
Open this post in threaded view
|

Re: Expanding Nodes in TreeControl, yields Error: "unsatisfied query for interface…

On 09.07.2017 12:51, jan wrote:

> ERROR: However, when I call treeControl.expandNode(someNode), (someNode
> being a [3])I get the following error:
>
> com.sun.star.uno.RuntimeException: unsatisfied query for interface of
> type com.sun.star.awt.tree.XTreeControl! (Error during invoking function
> [… callstack…]
>
> I assumed, since the TreeControl has the method, the data model in the
> one that is set for the TreeControl and XMutableTreeNode inherits from
> XTreeNode, I should be able to do what I tried above.

i suspect you're calling this:

void SAL_CALL UnoTreeControl::expandNode( const Reference< XTreeNode >&
xNode )
{
    Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW
)->expandNode(xNode);
}

getPeer() returns UnoControl::mxPeer and that is created on-demand by a
couple of other functions; i'm assuming it is null in your case?

if that is the cause of the problem, i'm not familiar with dialog APIs,
so i don't know what the best way is to ensure the "peer" is created in
time; there is a "createPeer" function there in XControl fwiw.

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
jan-3 jan-3
Reply | Threaded
Open this post in threaded view
|

Re: Expanding Nodes in TreeControl, yields Error: "unsatisfied query for interface…

Am 11.07.2017 um 15:34 schrieb Michael Stahl:

> On 09.07.2017 12:51, jan wrote:
>
>> ERROR: However, when I call treeControl.expandNode(someNode), (someNode
>> being a [3])I get the following error:
>>
>> com.sun.star.uno.RuntimeException: unsatisfied query for interface of
>> type com.sun.star.awt.tree.XTreeControl! (Error during invoking function
>> [… callstack…]
>>
>> I assumed, since the TreeControl has the method, the data model in the
>> one that is set for the TreeControl and XMutableTreeNode inherits from
>> XTreeNode, I should be able to do what I tried above.
>
> i suspect you're calling this:
>
> void SAL_CALL UnoTreeControl::expandNode( const Reference< XTreeNode >&
> xNode )
> {
>     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW
> )->expandNode(xNode);
> }
>
> getPeer() returns UnoControl::mxPeer and that is created on-demand by a
> couple of other functions; i'm assuming it is null in your case?

Good question – I can't tell. I am using the API from python (sorry, I
think I forgot to say, so one could only guess from the code) and
debugging python I don't get to see what happens "inside" the C++
function. I might be able to understand the problem better, if I read
the code snippet you posted though I hoped I could stay on the pyUNO
level :-)

Thanks for the pointer!

Jan

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice
Michael Stahl-2 Michael Stahl-2
Reply | Threaded
Open this post in threaded view
|

Re: Expanding Nodes in TreeControl, yields Error: "unsatisfied query for interface…

On 12.07.2017 00:07, jan wrote:

> Am 11.07.2017 um 15:34 schrieb Michael Stahl:
>> On 09.07.2017 12:51, jan wrote:
>>
>>> ERROR: However, when I call treeControl.expandNode(someNode), (someNode
>>> being a [3])I get the following error:
>>>
>>> com.sun.star.uno.RuntimeException: unsatisfied query for interface of
>>> type com.sun.star.awt.tree.XTreeControl! (Error during invoking function
>>> [… callstack…]
>>>
>>> I assumed, since the TreeControl has the method, the data model in the
>>> one that is set for the TreeControl and XMutableTreeNode inherits from
>>> XTreeNode, I should be able to do what I tried above.
>>
>> i suspect you're calling this:
>>
>> void SAL_CALL UnoTreeControl::expandNode( const Reference< XTreeNode >&
>> xNode )
>> {
>>     Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW
>> )->expandNode(xNode);
>> }
>>
>> getPeer() returns UnoControl::mxPeer and that is created on-demand by a
>> couple of other functions; i'm assuming it is null in your case?
>
> Good question – I can't tell. I am using the API from python (sorry, I
> think I forgot to say, so one could only guess from the code) and
> debugging python I don't get to see what happens "inside" the C++
> function. I might be able to understand the problem better, if I read
> the code snippet you posted though I hoped I could stay on the pyUNO
> level :-)

well you can just call treeControl.getPeer() and see if it's null...
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice