Get type of UNO structure

Is there any way to determine the type of a UNO structure?
For example, if from macro code I obtain the rangeAddress of a range of cells and save it in a variable, the IDE informs me that the type of the variable content is “com.sun.star.table.RangeAddress”
But how can I test if a variable contains a structure of type “com.sun.star.table.RangeAddress” ?
Not being a UNO object it does not support supportsService
For now I can only do it using a function with on error goto to detect if the variable supports startColumn,etc properties)
Are there other systems?
Thanks in advance for any suggestion

Structs have »typeNames« in python:
structs_have_typeNames_in_python

Thanks, but unfortunately I don’t use Python and Java.
This is a possible solution in StarBasic, an extended version of implementationName

Sub fImplementationName_Test()
	oRange = ThisComponent.Sheets(0).getCellRangeByName("A1")
	msgbox fImplementationName(oRange)
	oAddr = oRange.CellAddress
	msgbox fImplementationName(oAddr)   
end sub	
function fImplementationName(o)
	dim s,sConfr,i0,i1
	s=o.dbg_properties(o)
	sConfr=""""
	i0=instr(s,sConfr)
	i1=instr(i0+1,s,sConfr)
	fImplementationName=mid(s,i0+1,i1-i0-1)
End function

Or a little more compact: :slightly_smiling_face:

' Returns the type of the Uno structure
Function fImplementationName(Byval o)
	fImplementationName=Split(o.dbg_properties(), """")(1)
End Function

1 Like

It’s true, very very compact :+1: :slightly_smiling_face:

Hi,
you may query the .dbg_Properties property of any UNO structure.

For example, in a Calc spreadsheet:

Sub Main
oRange = ThisComponent.Sheets(0).getCellRangeByName(“A1:A2”)
oAddr = oRange.RangeAddress
MsgBox oAddr.dbg_properties
End Sub

Returns:
Capture d’écran du 2022-12-17 14-26-09

1 Like

Thank you very much! I never noticed that dbg_properties provides the type of the structure at the beginning, just extract it from the string produced.
This solves me many other similar problems, very thanks for the solution :+1: