How can I find out about XSelectSheetSupplier (or what methods will return an object type)

I am doing some macro work in Calc. Having made my macro do what I want on the ActiveSheet, it occurred to me that it should be able to work on all selected sheets. A bit of looking and I stumbled on getSelectedSheets() which (purportedly) does exactly what I need. Except it is a Method (Member Function) of XSelectedSheetsSupplier - and I can find nothing about creating an object that provides the XSelectedSheetsSupplier interface.

In general, the API documentation (such as it is) tells me what interfaces and functions an object provides, but nothing I’ve ever seen shows me what returns an object type. I uusually end up Googling for it - and in this case I can find that XSelectedSheetsSupplier is in the com.sun.star.sheet namespace and has .idl files in the builds, and that is it.
So how can I find out what returns an XSelectedSheetsSupplier object?

PS. Having wasted four days trying to find it, I gave up and found a different way to do the job, based on processing CurrentSelection.

Compare XSelectedSheetsSupplier documentation to, say, XSpreadsheetDocument documentation. The crucial difference is:

image

vs.

image

Do you notice that “published” decoration available for XSpreadsheetDocument? The XSelectedSheetsSupplier interface was introduced as an internal interface, only for use within LibreOffice codebase, for some specific task. It was not published, is not part of the official published API, and is not intended for use externally.

You may also look at the source code. Searching for XSelectedSheetsSupplier in OpenGrok gives only five matches; only two classes derive from that interface - namely, ScTabViewObj and ScPreviewObj. As a UNO interface (using UNO reference and querying for the wanted interface), it is used in a single place - inside ScModelObj::FillRenderMarkData. But even if this could give you an idea how the code can obtain that, you need to realize that using this unpublished interface may make your code broken at any point without a prior notice, because we can change the unpublished interface in an incompatible way, when needed.

1 Like

XSelectedSheetsSupplier it Have only one method getSelectedSheets and returns the indices of currently selected sheets.

https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XSelectedSheetsSupplier.html

I am well aware of what it purports to do. It does it to an XSelectedSheetsSupplier object, which I can find no way to create. The question is, how do I create the necessary object to use the method?

MikeKaganski answers this in the comment (I don’t know how to mark the comment as the answer). I id not know that published documentation was not published unless it was separately marked as published. Now I know, and need to go back over much of my work to make sure I am only using truly published features. Luckily I have already found a way to do it without this.
Thank You, MikeKaganski.

And don’t forget about the workaround when shape(s) is selected in the worksheet (if relevant). :slightly_smiling_face: