The XrayTool is a “extension like” library. It has not a regular “extension format” (.oxt), but you can install it by usage the downloaded .odt file. After restart the LibreOffice you can use it “in situ” in your BASIC macro code:
xray ThisComponent
You must load the XrayTool befofe you use it: you can do it manually in the IDE by double click on the library name in the Object Catalog of the IDE, or by a macro code:
Sub LoadXray
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("XrayTool")) Then
GlobalScope.BasicLibraries.LoadLibrary("XrayTool")
End If
end sub
Perfect, thank you very much for explaining. This is really helpful. Just to be sure, do you think that this link posted on the openoffice wiki website is still up to date? Extensions development basic - Apache OpenOffice Wiki
XrayTool works for me with all of the permanently installed and portable LibreOffice versions. Yes, the XrayTool is not present in the extension page, because the distributed format is not a real “extension” (.oxt).
The last version is availabe on the linked site (the author: Bernard Marcelly’s site)
I see, thank you for confirming. What concerns me slightly is that it is distributed as an .odt file. I’ve tried to inspect these files with binwalk before running, but it is not easy, they are composed of multiple formats. From security point of view it would be much better if they had source code available somewhere.
Thank you again, that is a really good advice. I am just looking for a way to disable macros completely - in the Preferences > Options > LibreOffice > Security > Macro Security there is an option to disable all macros except for the ones in “trusted locations”. Do you know if there is a way to disable all macros completely (including those from “trusted locations”)?
IMO, the Xray is really outdated and impossibly awkward to use compared to more advanced and convenient MRI. Also, there is a new Tools → Development Tools (but unrelated to ThisComponent object, also documented in Basic Guide, where the existence of this special Basic-only, not API, feature is explained).
… but note that that extension page lists an outdated version, and I couldn’t negotiate if MRI author wanted to take over that extension page ownership. So - please use the official plugin homepage.
Can I ask you a bit unrelated question, but would mean a ton to me - where do you find methods and properties of ThisComponent? I’ve been struggling for a day to find this out. Are they documented anywhere on the internet or do you have to use MRI? I’ve tried printing ThisComponent.DBG_properties, but there was no way to filter that long list in the pop-up window.
This is quite easy in the IDE: just use the “Watch” function, and expand ThisComponent there.
And for that:
The link to the built-in Help that I provided above has relevant references: it discusses what ThisComponent is, and then links to API documentation for different services representing different document types. This already gives much of the supported methods, browsing the included interfaces.
Indeed, you may use any of the introspection tools (Xray/MRI/Development Tools) to see the properties/methods of the current document.
Let me describe a hard way below, but that is available without any additional tools.
If you have your UNO object in the Basic IDE’s “Watch” panel, expanding it, you would find a “Types” node somewhere close to the bottom of the tree.
This is where all the introspection information may be manually found. Yes, it may be an intimidating task, e.g. Writer shows 111 types there in its list (i.e., it implements 111 UNO interfaces), but I promised that it will be the hard way, didn’t I?
So every “type” (UNO interface) contains its list of methods (among other things); first three of them in each type are identical (queryInterface/acquire/release of XInterface); and the rest is the interesting part of this interface API.
Indeed, looking at all this reveals how awful the UI of the IDE is…
I see, but the listed variables didn’t show any properties? I’ve tried a sample script (shows contents of selected cells):
Sub Main
Set oRange = ThisComponent.CurrentSelection
For i = 0 To oRange.Rows.getCount() - 1
For j = 0 To oRange.Columns.getCount() - 1
Set oCell = oRange.getCellByPosition( j, i )
Print oCell.String
Next
Next
End Sub
but that’s all it showed (there were no context menus or options available to expand them):
Thank you very much, that changes the game completely
This reminds me of IDE from Rhino, a lot, it worked similarly (I’m sure a lot of built-in code editors are like that as well). Sorry, I could have thought about this sooner
Sorry, I didn’t mean to spam the forum, but after a day of searching I was still stuck - the above recommendation to use the “Watch” panel is an absolute game changer and it allows you to investigate the object model much more independently, so it shouldn’t happen again.