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

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

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

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.
_______________________________________________
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: Macro in JS: How to access ThisComponent-equivalent, run findAll

On 15.03.2017 22:32, jan wrote:

> 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.

did you try the getDocument() method?

http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1script_1_1provider_1_1XScriptContext.html#a191c375534e4ecbb1309581035eca1c6

_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice