Bug 126392 - [RFE] A way to print properties/methods of an object is needed
Summary: [RFE] A way to print properties/methods of an object is needed
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
6.2.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-14 22:38 UTC by Konstantin Kharlamov
Modified: 2019-08-01 03:39 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Connects to LO instance running as a server (844 bytes, text/x-python)
2019-07-14 22:38 UTC, Konstantin Kharlamov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kharlamov 2019-07-14 22:38:21 UTC
Created attachment 152769 [details]
Connects to LO instance running as a server

Currently when writing an UNO script it is very hard to figure out what methods/properties an object has. One needs to search for documentation, however some properties are not documented; and even if they were, it is much faster to just print everything an object provides in an interactive prompt.

# Steps to reproduce

1. Download to current directory the attached script (it simply connects to libreoffice)
1. Run office as: soffice --calc --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
2. Run "python" to enter an interactive shell
3. Execute in python: exec(open("./connect-to-lo.py").read())
4. Try printing the "model.CurrentController" object in such a way so you could see "ActiveSheet" field

## Expected

There's a way to do it

## Actual

There's no way to view properties of the object, including the "ActiveSheet" field.
Comment 1 Konstantin Kharlamov 2019-07-14 23:33:41 UTC
UPDATE: I found 2 workarounds:

1. executing "dir(object_name)", e.g. "dir(model.CurrentController)" for the "steps to reproduce" seems to give properties and methods
2. forcing interactive python shell to autocomplete, e.g. by typing model.CurrentController. and pressing TAB twice, makes it to show the list too (and this list even shows methods and properties differently: methods ends up with "(" symbol).

Possible gotcha: these workarounds are specific to python. So I'm not sure whether they can be qualified as a solution to the report.
Comment 2 Xisco Faulí 2019-07-31 09:59:44 UTC
mmm, using dir() is not a workaround, it's just the way to print the properties of an object in python. Other than that, you could also use an extension like MSI < https://extensions.libreoffice.org/extensions/mri-uno-object-inspection-tool > as an object inspector.
Closing as RESOLVED NOTABUG