Library Module As Document

The Application Programming Interface and the OASIS Open Document Format

Library Module As Document

Postby DavidHMcCracken » Sun Jul 28, 2019 6:42 pm

Is it possible to gain an XInterface access to the currently viewed OoBasic library module. The purpose of this is to apply a macro to the macro source file. For the currently viewed document, the XInterface is already defined as ThisComponent. I don't know the origin of ThisComponent but if it is manufactured then there should be a similar process for manufacturing an XInterface for the macro source file. I know that macros can be invoked while viewing a library module but they can't do much if they don't know how to access the module as a document.

LibreOffice version 6.1.5.2 (x64) on Windows 10
OpenOffice 4.1.5 on Ubuntu 16.04
DavidHMcCracken
 
Posts: 12
Joined: Tue Apr 10, 2018 6:15 am

Re: Library Module As Document

Postby JeJe » Sun Jul 28, 2019 8:59 pm

stardesktop.currentcomponent (when the IDE is active)

ThisComponent.BasicLibraries for access to libraries in a document.

MRI should help you further.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 551
Joined: Wed Mar 09, 2016 2:40 pm

Re: Library Module As Document

Postby DavidHMcCracken » Mon Jul 29, 2019 6:30 am

JeJe,
Thank you for your quick reply but I'm not sure that I completely understand. stardesktop.currentcomponent seems to be almost what I need but not quite. In my library module I created a macro with the statement:
controller = stardesktop.currentcomponent.CurrentController.
xray controller shows that it is an instance of com.sun.star.frame.XController and its Title is "My Macros & Dialogs.TestLib" which correctly identifies the module. However, unlike ThisComponent.CurrentController, it has no GetViewCursor method. It seems to provide no means of producing an XInterface similar to ThisComponent.
OpenOffice 4.1.5 on Ubuntu 16.04
DavidHMcCracken
 
Posts: 12
Joined: Tue Apr 10, 2018 6:15 am

Re: Library Module As Document

Postby JeJe » Mon Jul 29, 2019 10:29 am

What you can do is enumerate the paragraphs (may not be very stable), see this thread:

viewtopic.php?f=20&t=6458

Take a look at the (Basic) source code for Basic IDE Tools. It uses copy and paste to modify the text eg by commenting/uncommenting lines.

https://extensions.openoffice.org/en/pr ... -ide-tools
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 551
Joined: Wed Mar 09, 2016 2:40 pm

Re: Library Module As Document

Postby JeJe » Mon Jul 29, 2019 10:39 am

For an example for looking at the module nodes etc see the source code for BasicAddonBuilder

https://extensions.openoffice.org/en/pr ... s-packager

https://www.openoffice.org/api/docs/com ... le-ix.html

Edit: (but you can't do what you want, which is create a cursor etc as you can in a Text Document)
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 551
Joined: Wed Mar 09, 2016 2:40 pm

Re: Library Module As Document

Postby JeJe » Mon Jul 29, 2019 11:14 am

Maybe you could use the copy and paste method... copy the pane text, create a hidden text document, paste the text and modify it there, then copy it back into the pane...? Roundabout way... and I don't know how stable that would be...
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 551
Joined: Wed Mar 09, 2016 2:40 pm

Re: Library Module As Document

Postby DavidHMcCracken » Tue Jul 30, 2019 3:51 am

Thank you JeJe for your thoughtful suggestions. I actually don't need to modify the file. I only need my macro to read a comment, which is a reference to a document (writer) file with bookmark. The macro opens the indicated file and jumps to the bookmark. This enables extended comments, including graphics and design history, to be linked to the script file. For pretty-printing a block of code a few steps is not too much to ask of the user. But I'm trying to make this as close as possible to simply clicking a link. I have been able to do this with emacs, where the user only has to position the cursor in front of the comment and invoke a function bound to a hot key, e.g. F1. It would be a shame to provide this to other development environments but not to the OOBasic IDE.
OpenOffice 4.1.5 on Ubuntu 16.04
DavidHMcCracken
 
Posts: 12
Joined: Tue Apr 10, 2018 6:15 am

Re: Library Module As Document

Postby JeJe » Tue Jul 30, 2019 10:09 am

If you look at the code posted by ms777 in the link I gave above it gives you the selected text.

viewtopic.php?f=20&t=6458
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 551
Joined: Wed Mar 09, 2016 2:40 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests