Bug 155822 - Method findAll() of com.sun.star.util.XSearchable may return NULL though specified to return XIndexAccess container.
Summary: Method findAll() of com.sun.star.util.XSearchable may return NULL though spec...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks:
 
Reported: 2023-06-13 19:42 UTC by Wolfgang Jäger
Modified: 2023-06-14 03:12 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
The announced demo (10.76 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-06-13 19:42 UTC, Wolfgang Jäger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2023-06-13 19:42:09 UTC
Created attachment 187895 [details]
The announced demo

XIndexAccess containers can well be empty. The .Count property then is 0.

The result of a .findAll() with XSearchable is one of the cases where a result of type XIndexAccess is specified, but NO such result is returned if nothing was found. Instead of setting .Count to 0, in this case the NULL object is returned. 

It may factually be impossible to fix the bug because old running code would be broken this way. However, the API documentation should give a related hint, and list the cases where a NULL ob ject will be returned, while a XIndexAccess object should be expected.

Thare is a demonstrating example attched.
Comment 1 Mike Kaganski 2023-06-13 20:02:12 UTC
https://opengrok.libreoffice.org/xref/core/sc/source/ui/unoobj/cellsuno.cxx?r=3e7ff2a9&mo=189177&fi=3757#3757

introduced in the initial import.

It looks reasonable to throw an error when the initial check (pDocShell && xDesc.is()) fails, and if it passes, it seems possible to create an empty ScRangeList right away, and create the returned ScCellRangesObj with it unconditionally before return.

The easyhack needs a unit test.