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

jan dittrich.c.jan at gmail.com
Wed Mar 15 21:32:39 UTC 2017


Hello,

I would like to execute the command "findAll" in a Javascript Macro. In
Basic, one can access thisComponent and access its findAll method (See [1])

However, the exposed Javascript API does not have thisComponent. I tried

  importClass(Packages.com.sun.star.frame.XDesktop)
  var currentComp = XDesktop.getCurrentComponent()

to get the current document (as described in [2])  but it failed
silently [3].

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?


Kind regards,
 Jan

[1] p405 of OpenOffice.org Macros Explained, http://www.pitonyak.org/book/
[2] http://www.pitonyak.org/AndrewMacro.odt, section 3.6.9.2)
[3] and, if manually evaluated, by printing some number like 361 in the
console. Whyever.


More information about the LibreOffice mailing list