Bug 164040 - SortableGridDataModel cannot be notified for changes
Summary: SortableGridDataModel cannot be notified for changes
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.0 all versions
Hardware: All All
: medium normal
Assignee: prrvchr
URL:
Whiteboard: target:25.2.0 target:24.8.4
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-25 09:56 UTC by prrvchr
Modified: 2024-11-26 08:30 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description prrvchr 2024-11-25 09:56:39 UTC
Description:
Hi,

I try to use the SortableGridDataModel[1] service with the help of my own XMutableGridDataModel[2] interface implementation (ie: the delegator).

After creating the service SortableGridDataModel, when initializing with the XMutableGridDataModel delegator, an XGridDataListener listener tries to register to the delegator with the method addGridDataListener(). But it seems that this listener does not have the required interface XGridDataListener (ie: getTypes() does not return XGridDataListener)

If I look at the source code and more precisely the file libreoffice/toolkit/source/controls/grid/sortablegriddatamodel.cxx[3] it appears the attempt to add the listener line 318[4], but it seems to me that the type XGridDataListener is excluded from the types to return line 271[5].

As a result, if we try to use the SortableGridDataModel service any change in the content of the Grid cannot be notified to this service (ie: the registered listener does not have the XGridDataListener interface, we cannot notify it).
And it results that the management of vertical scroll bars is not supported (ie: scroll bars do not follow the number of rows in the Grid)

As a test, if I include type XGridDataListener in the types returned by getTypes() then it is possible to notify the changes of the delegator and the scroll bar becomes operative.

I will propose a pull request.


[1]: https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/grid/SortableGridDataModel.html
[2]: https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/grid/XMutableGridDataModel.html
[3]: https://github.com/LibreOffice/core/blob/master/toolkit/source/controls/grid/sortablegriddatamodel.cxx
[4]: https://github.com/LibreOffice/core/blob/master/toolkit/source/controls/grid/sortablegriddatamodel.cxx#L318
[5]: https://github.com/LibreOffice/core/blob/master/toolkit/source/controls/grid/sortablegriddatamodel.cxx#L271


Steps to Reproduce:
Use the SortableGridDataModel service with the help of your own XMutableGridDataModel (ie: the delegator).

Actual Results:
The SortableGridDataModel service cannot be notified of changes by the delegator.

Expected Results:
The SortableGridDataModel service must be able to be notified of changes by the delegator.


Reproducible: Always


User Profile Reset: No

Additional Info:
if I change the getTypes method of the service SortableGridDataModel then everything works fine.


    Sequence< Type > SAL_CALL SortableGridDataModel::getTypes(  )
    {
        // don't expose the types got via SortableGridDataModel_PrivateBase - they're private, after all
        // No: if we want to be able to be notified of changes coming from the delagator
        // then we need to return the XGridDataListener interface too
        return ::comphelper::concatSequences(
            SortableGridDataModel_Base::getTypes(),
            SortableGridDataModel_PrivateBase::getTypes()
        );
    }
Comment 1 Commit Notification 2024-11-25 18:42:31 UTC
prrvchr committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4178b34521227e726bd1f393d384c17c63909c3d

tdf#164040 Expose XGridDataListener type in SortableGridDataModel

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 2 Commit Notification 2024-11-26 08:30:32 UTC
prrvchr committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/7efe1e9c079fa8efd3ed0d78c6e0993470bf0ab5

tdf#164040 Expose XGridDataListener type in SortableGridDataModel

It will be available in 24.8.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.