JavaScript macro

Hi!

I searched, but couldn’t find any examples for JavaScript macros. Are there any somewhere? Most of the examples are VBScript.
What I want to do is the following:

  • Find all Headings with the type of “Heading 2”
  • Under every Heading 2, there is a table with a specify table style. Read the value from the second row, second column(High-Low-Medium).
  • Insert sorted cross-references to heading 2 into a table under Heading 1 (table has different table style)
  • Also sort all chapters with Heading 2 according the value from the table.

Could someone please help me get started? I honestly don’t know where do I even begin. I found this site: LibreOffice: JavaScript Service Reference but this doesn’t help me.

Thanks in advance!

I have not looked in this for years, but you could start at OpenOffice as I don’t think there was much change. Note the used rhino-implementation will not be of newer date. So not everything a user of modern Javascript expect will be available…

https://www.openoffice.org/framework/scripting/release-0.2/javascript-devguide.html

Thanks for the reply! I found this site too, but this is definitely out of date.

? It is quite old, but “out of date” I’d used only, if there would be some/much change since then. Either javascript isn’t used much in OpenOffice/ LibreOffice or there are few questions open…
.
Quick search for rhino gave:

sorry, with “out of date” I meant, that the example uses ScriptContext there, however, that’s not working. Correct would be XSCRIPTCONTEXT, so there were a few changes since that was published.