Bug 51925 - [BASIC] Writer Table getColumns().getByIndex(i) returns null, where it should not
Summary: [BASIC] Writer Table getColumns().getByIndex(i) returns null, where it shoul...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
(earliest affected)
3.5.4 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
Reported: 2012-07-09 19:37 UTC by Olivier Hallot
Modified: 2021-09-19 03:44 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:
Regression By:

Text document showing bug in getColumns.getByIndex() flaw. (10.27 KB, application/vnd.oasis.opendocument.text)
2012-07-09 19:37 UTC, Olivier Hallot

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Hallot 2012-07-09 19:37:08 UTC
Created attachment 64047 [details]
Text document showing bug in getColumns.getByIndex() flaw.

The following piece of BASIC returns a null object where it should not.

REM  *****  BASIC  *****

Sub Main
nLin = 10
nCol = 7

oText = ThisComponent.getText()

'Create tabela
	oTabela = ThisComponent.createInstance("com.sun.star.text.TextTable")
	oTabela.initialize ( nLin, nCol )
	oCursorT = oText.createTextCursor()
	oText.insertTextContent(oCursorT, oTabela, True)
        oColuna = oTabela.getColumns().getByIndex(0)
        xray oColuna
	'oColuna.IsAutoWidth = False
	'oColuna.Width = 4440
End Sub

oColuna returns NULL where it should have returned an object. xray is a well known macro to inspect objects.

No way to set a column width, and other column properties.

The attached document provides a living example.

Please execute macro Main in Standard library.
Comment 1 Olivier Hallot 2012-07-15 03:14:31 UTC
getByIndex() is not working fot columns, work for rows.
Comment 2 Olivier Hallot 2012-07-20 13:51:19 UTC
A complete description of why this stupid situation is there:


In a nutshell: the getByIndex() method is there to fulfill the API completness, but it wasn't implemented, and deliberately returns NULL.
Comment 3 bfoman (inactive) 2013-01-28 12:28:17 UTC
https://issues.apache.org/ooo/show_bug.cgi?id=21669 status:

Fixed in CWS tl14.
Files changed:
- unotbl.cxx  new revision:
Comment 4 tommy27 2013-10-19 18:55:54 UTC
adding BASIC expert to CC  list
Comment 5 Joel Madero 2014-07-21 01:41:54 UTC
@Olivier - I get a basic runtime error with your sample - is this what you are referring to or should I be seeing something different?
Comment 6 Noel Power 2014-07-21 08:20:12 UTC
(In reply to comment #4)
> adding BASIC expert to CC  list

it's got nothing to do with basic, it's according to comment #2 and api implementation issue
Comment 7 tommy27 2014-07-21 08:52:24 UTC
sorry Noel for disturbing you. my bad :-)
Comment 8 Owen Genat (retired) 2014-07-28 11:45:15 UTC
I think according to comment 2 and comment 6 this report can be confirmed. As comment seven in the related Apache issue indicates, /core/sw/source/core/unocore/unotbl.cxx was changed back in 2005 to return null because "the internal table representation does not have columns".

The related change appears to be 904d699f6d76154e541c35395c69d6c85712ec2a which states: 2005/07/13 13:37:25 tl #i21669# SwXTableColumns::getByIndex returns an empty XInterface now.

Exactly how the issue might be resolved remains a problem, but the report at least would seem accurate. Apache issue added to See Also list for reference. Status set to NEW.
Comment 9 QA Administrators 2015-09-04 02:48:47 UTC Comment hidden (obsolete)
Comment 10 Olivier Hallot 2015-09-04 11:26:36 UTC
The bug is still valid as of today, any version.
Comment 11 QA Administrators 2016-09-20 10:29:58 UTC Comment hidden (obsolete)
Comment 12 Buovjaga 2019-08-11 10:39:12 UTC
Original macro seems to require Xray extension to be installed. I tested with MsgBox(oColuna) instead (empty result and "Object variable not set")

Arch Linux 64-bit
Build ID: 37fc9f51a8de11d40632e8cda17ccf1fa4b1f503
CPU threads: 8; OS: Linux 5.2; UI render: default; VCL: gtk3; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 6 August 2019
Comment 13 QA Administrators 2021-09-19 03:44:54 UTC
Dear Olivier Hallot,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)

If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword

Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team