Bug 126415 - Seems to be missing API to get a cell from a row
Summary: Seems to be missing API to get a cell from a row
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:26 UTC by Konstantin Kharlamov
Modified: 2019-07-16 01:49 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
connect to LO server running (702 bytes, text/x-python)
2019-07-15 22:26 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:26:14 UTC
Created attachment 152795 [details]
connect to LO server running

A "TableRow" object doesn't seem to have any methods to access cells it stores. There's "getCellByPosition()", however this method accepts a row index, and is probably present in TableRow by mistake (should I report a bug on this?).

Feel free to close this report if I'm wrong, I just spent some hours trying to understand how to loop over rows in a spreadsheet, and at this point I admit I am lost.

# Steps to reproduce
1. Execute: soffice --calc --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
2. Download the attachment (python script to connect to LO)
3. In directory with the script run `python`, and execute:
    >>> exec(open("./connect-to-lo.py").read())
    >>> row = model.CurrentController.ActiveSheet.Rows.getByIndex(0)
4. Now, try to get a cell from the row.

## Expected

There's a way to do it.

## Actual

Except the mentioned "getCellByPosition()" that is irrelevant to a row there doesn't seem to be a way to do it.
Comment 1 Konstantin Kharlamov 2019-07-15 23:45:38 UTC
UPD: btw, turns out getCellByPosition() has not use either, because TableRow.Position property is incompatible with this function, and there doesn't seem to be a way to derive its index.

Although I managed to find such call: 

    row.getCellRangeByName(row.AbsoluteName)

This returns a range, but… the range doesn't provide any means to get a cell either.
Comment 2 Konstantin Kharlamov 2019-07-16 01:42:10 UTC
I asked on IRC: turns out, a row (which is basically a range) has a function getCellByPosition(), whose addressing is relative to the range. E.g. if your range starts at 1,1 global position, then your_range.getCellByPosition(0,0) would refer to 1,1 cell in global coordinates.
Comment 3 Mike Kaganski 2019-07-16 01:46:28 UTC
The row object is a cell range. It implements relevant services (e.g., com.sun.star.sheet.SheetCellRange, com.sun.star.table.CellRange), and interfaces (com.sun.star.table.XCellRange, com.sun.star.sheet.XCellRangeData, com.sun.star.sheet.XCellRangeFormula). The mentioned getCellByPosition (a method of XCellRange interface) allows you to get com.sun.star.table.XCell. You need to understand that indexing in a cell range object is relative to the range bounds; so for a given row (= a rectangular range of 1 row and many columns), the possible indices passed to aRow.getCellByPosition(colIx, rowIx) are 0..1048575 for colIx, and 0 for rowIx (regardless which row is represented by this aRow object).

Closing NOTABUG (WORKSFORME is only for real defects that were fixed by an unknown commit).
Comment 4 Mike Kaganski 2019-07-16 01:49:53 UTC
(In reply to Mike Kaganski from comment #3)
> ... 0..1048575 for colIx, 

of course, a typo: 0..1023 (currently, until bug 50916 is fixed).