Bug 126416 - CurrentController in LO Calc offers "ActiveSheet" but not "Sheets"
Summary: CurrentController in LO Calc offers "ActiveSheet" but not "Sheets"
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-15 22:54 UTC by Konstantin Kharlamov
Modified: 2019-07-21 17:14 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
script to try accessing "Sheets" in CurrentController (898 bytes, text/x-python)
2019-07-15 22:54 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-15 22:54:14 UTC
Created attachment 152796 [details]
script to try accessing "Sheets" in CurrentController

If CurrentController offers ActiveSheet, why not to make it offer "Sheets" property as well?

To me it doesn't make sense, and costed some hours of research until I blindly listed methods in XComponent that's higher the stack, and found "Sheets" there.

# Steps to reproduce

1. Execute: soffice --calc --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
2. Download the attachment (script to try accessing "Sheets" in CurrentController).
3. In directory with the script run `python ./connect-to-lo.py`

# Expected

Script finishes without errors

# Actual

Script fails on accessing model.CurrentController.Sheets
Comment 1 Oliver Brinzing 2019-07-21 15:10:48 UTC
getSheets() method belongs to com::sun::star::sheet::SpreadsheetDocument Service
(-> interface com::sun::star::sheet::XSpreadsheets):
 
https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sheet_1_1SpreadsheetDocument.html

for example:
https://docs.libreoffice.org/unotest/html/SpreadsheetDocument_8java_source.html

https://api.libreoffice.org/examples/DevelopersGuide/Forms/SpreadsheetDocument.java
Comment 2 Oliver Brinzing 2019-07-21 15:26:32 UTC
to make your example script work:

soffice --calc --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"

[...]
model = connect_to_lo()
print("Trying to access model.Sheets")
sheets1 = model.getSheets()
print("Succeed!")
print(sheets1.getByIndex(0).getName())
Comment 3 Konstantin Kharlamov 2019-07-21 16:42:14 UTC
(In reply to Oliver Brinzing from comment #2)
> to make your example script work:
> 
> soffice --calc
> --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
> 
> [...]
> model = connect_to_lo()
> print("Trying to access model.Sheets")
> sheets1 = model.getSheets()
> print("Succeed!")
> print(sheets1.getByIndex(0).getName())

You basically reworded my description here, where I mentioned that I know how to make it work. This report is about making the API more accessible.

Do you mind to reopen it?
Comment 4 Oliver Brinzing 2019-07-21 17:14:20 UTC
(In reply to Konstantin Kharlamov from comment #3)

> You basically reworded my description here, where I mentioned that I know
> how to make it work. This report is about making the API more accessible.
> 
> Do you mind to reopen it?

you may have a look at:

https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Frame-Controller-Model_Paradigm_in_OpenOffice.org