[Solved] Enumerate enumeration names
Posted: Mon Apr 29, 2013 8:52 pm
Given the name of an enumeration (or constant group, or similar), how can I enumerate the names? Consider the following (horrible) code:
Sure, it works, but really, do I need to enumerate all of the values to find AnimationEffect.... Oh, you know what, just bothering to ask the question made the solution obvious to me...
Guess if I wondered, someone else may wonder as well, so post the solution.
Code: Select all
Sub TestEnumerations_001
Dim oTDM
Dim oTDME
Dim oTD
Dim typeArray
Set oTDM = GetDefaultContext().getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager")
typeArray = Array(com.sun.star.uno.TypeClass.ENUM, _
com.sun.star.uno.TypeClass.SEQUENCE, _
com.sun.star.uno.TypeClass.CONSTANT, _
com.sun.star.uno.TypeClass.CONSTANTS)
Dim sFullName$
Dim sBaseName$
sFullName = "com.sun.star.presentation.AnimationEffect"
sBaseName = "com.sun.star.presentation"
oTDME = oTDM.createTypeDescriptionEnumeration(sBaseName, typeArray, com.sun.star.reflection.TypeDescriptionSearchDepth.ONE)
While oTDME.hasMoreElements()
oTD = oTDME.nextTypeDescription()
If oTD.Name = sFullName Then
MsgBox Join( oTD.getEnumNames(), CHR$(10))
End If
wend
End SubCode: Select all
If oTDM.hasByHierarchicalName(sFullName) Then
oTDM.getByHierarchicalName(sFullName)
End If