How to show description of Macro method

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
jamesprabud
Posts: 1
Joined: Thu Feb 11, 2016 9:02 am

How to show description of Macro method

Post by jamesprabud »

Hi,

I need to show description of Macro. I have written one macro function like this,

' This function gives the Total Pages of the current file
Function TotalPages()
Dim cont
cont = ThisComponent.getCurrentController()
TotalPages = cont.PageCount
End Function

Please look above Function(TotalPages()), I have written the description as "' This function gives the Total Pages of the current file".

But this description was not shown when you go Tools--> Macros --> Run Macro and (You can see now "Macro Selector" Dialogue) click on macro name and see description box(bottom of the dialogue), here my description was not shown what I gave for TotalPages().

Please find the attachment for more details.

Please help to find the way to show description

Thank you in advance.

With Regards,
James
Attachments
Macro_Description.jpg
Openoffice Version: 4.3.0.4
Windows
User avatar
RoryOF
Moderator
Posts: 35223
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How to show description of Macro method

Post by RoryOF »

I've just made a quick investigation (I don't claim this is exhaustive). Those macros that put a description up as you require seem to be Beanshell macros, and the description is the text in a comment marked by //. See, for example macro Capitalise.

In https://wiki.openoffice.org/wiki/Docume ... ing_Macros
there is a note that
The parcel-descriptor.xml file is also used to detect BeanShell and JavaScript macros. It is created automatically when creating macros using the Organizer dialogs for BeanShell and JavaScript.
This may be a clue as to why Beanshell macros have a description, but not BASIC macros.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
User avatar
Lupp
Volunteer
Posts: 3757
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How to show description of Macro method

Post by Lupp »

Everybody seems to know how to define/edit a description for a "macro". I don't.
Would someone, please, help me out of my dark corner?

Another dull guy asked this question (2014-06-18): https://ask.libreoffice.org/en/question ... criptions/ in the sister's parlour, but did not get an answer.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: How to show description of Macro method

Post by B Marcelly »

Signature of jamesprabud wrote:Openoffice Version: 4.3.0.4
Windows
An incorrect signature may mislead those who answer.
Your screenshot is of LibreOffice, not Apache OpenOffice. There are notable differences.
Windows comes in various versions (XP, 7, 8.1, 10), it matters for some problems.

The descriptions are only displayed in the Macro Selector. This window appears with Tools > Run Macro.

Apache OpenOffice
In OpenOffice Macros there are numerous Basic macros, but no one shows a description text.
In library HelloWorld of OpenOffice Macros, you can see descriptions for macros written in Beanshell, Javascript and compiled java (HelloWorld.printHW). These descriptions are in a separate parcel-descriptor.xml file. There is no equivalent in other macro languages (Basic, Python).

LibreOffice (tested on version 4.4.5.2)
You must have specified, at customized installation, that you want the script provider for Beanshell, and for Javascript.
In LibreOffice Macros, the Macro Selector does not show JavaScript and Beanshell macros.
Yet, with Tools > Macros > Organize Macros > Beanshell... you will see Beanshell macros in various libraries of LibreOffice Macros.
Same with Javascript.


In a nutshell : to see the description of a Basic macro, read the source code. Of course, a self-understanding name of a macro also helps.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
User avatar
RoryOF
Moderator
Posts: 35223
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How to show description of Macro method

Post by RoryOF »

B Marcelly wrote: In a nutshell : to see the description of a Basic macro, read the source code. Of course, a self-understanding name of a macro also helps.
And comments - this applies in any programming language.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
User avatar
karolus
Volunteer
Posts: 1245
Joined: Sat Jul 02, 2011 9:47 am

Re: How to show description of Macro method

Post by karolus »

Hallo

It looks like another bug in Aoo|LO :(

In prior Versions the Doc-String of some Function written in Python was showed in Makro-Execution -Dialog, for now you cannot write any Docstring into the Source because the Content of those Module is hidden in that Dialog
[edit: sorry the last is false, it was my fault because mixing up <tab> and <space> for indentation (wrong Editor-settings)]
eg. Modulecontent like:

Code: Select all

def some_function():
    """
    this is the doc-string,
    its very usefull and valid python
    but unfortunatly the Function is now invisible in the GUI
    """


    pass
try this compared to simply without docstring:

Code: Select all

def some_function():

    pass
It seems I have to debug this shit, solve it, file the bug with whole solution and nobody cares about :(
see Bug-request https://bugs.documentfoundation.org/sho ... i?id=92007
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Post Reply