In the answer I gave in this discussion [Calc] How to start a macro with user-specified parameters? there may be an indirect answer, certainly the solution to the initial problem that led me to open this discussion
Edit: mini-tutorial
In the following we will call PX the point in the document where the context menu was opened
- Use a wrtEv user function that initially contains the statement
oVC = thisComponent.currentController.viewCursor
oVC is the reference to the viewCursor
- Enter wrtEv both in the contextual menu (hereinafter mcText) associated with the “text” (the contextual that opens with a right click on a text segment at one point) and in the contextual menu (hereinafter mcTable, the specific menu contextual with right click inside a table)
This done, you can now access everything a viewCursor has access to:
-
with oVC. textParagraph directly accesses the paragraph containing the PX point
-
with oVC.location the X and Y coordinates of PX are obtained
-
the section (if any) containing PX is located in oVC.textSection
-
the table and the cell containing PX (if existing) are in oVC.textTable and oVC.cell
There is therefore no need for a keystroke to call up the macro, it is activated directly from the context menu which, if desired, can contain submenus with hierarchies of user macros, each of which can perform different functions in relation to the position of PX and the relative text Content