Macro in JS: How to access ThisComponent-equivalent, run findAll

I would like to execute the command “findAll” in a Javascript Macro. In Basic, one can access thisComponent and access its findAll method (See e.g. p405 of Macros Explained)

However, javascript does not have thisComponent. I tried

var currentComp = XDesktop.getCurrentComponent()

to get the current document (as described in, section but it failed silently.

I also tried

var desktop = XSCRIPTCONTEXT.getDesktop();
var comp = desktop.getCurrentComponent();

…which gives me something, but that returned object does not have the findAll-Method.

How to run findAll() in a JS Macro?

You may get some replies if you join and post in the OpenOffice forum here. It has been going for a long time and I have seen questions regarding the use of JavaScript there.

If you get an answer post it back here.