In the process of creating a few nutshell examples using OLE/COM.
One open problem is how to get to the UNO_CONSTANTS via the OLE/COM bridge. Here a snippet and its
output (the tilde is the message operator in ooRexx and could be replaced by a dot for JScript and
the like; .nil is the singleton object with the string value "The NIL object" to represent null):
factory = .OLEObject~new('com.sun.star.ServiceManager')
coreReflection =
factory~createInstance("com.sun.star.reflection.CoreReflection")
clzName="com.sun.star.table.CellHoriJustify"
say clzName":" "(UNO_ENUM)"
type=coreReflection~forName(clzName)
say "type:" type "type~getName:" type~getname "(forName)"
do f over type~getFields -- iterate over all fields
say f~getName":" f~get(.nil) -- show name and get the value
end
say
type=coreReflection~getType(clzName)
say "type:" type "type~getName:" type~getname "(getType)"
say "-"~copies(79)
say
clzName="com.sun.star.awt.FontWeight"
say clzName":" "(UNO_CONSTANTS)"
type=coreReflection~forName(clzName)
say "type:" type "(forName)"
say
type=coreReflection~getType(clzName)
say "type:" type "type~getName:" type~getname "(getType)"
The output is:
com.sun.star.table.CellHoriJustify: (UNO_ENUM)
type: an OLEObject type~getName: com.sun.star.table.CellHoriJustify (forName)
STANDARD: 0
LEFT: 1
CENTER: 2
RIGHT: 3
BLOCK: 4
REPEAT: 5
type: an OLEObject type~getName: string (getType)
-------------------------------------------------------------------------------
com.sun.star.awt.FontWeight: (UNO_CONSTANTS)
type: The NIL object (forName)
type: an OLEObject type~getName: string (getType)
So using CoreReflection does not allow one to reflect UNO_CONSTANTS (forName()
returns null).
Using getType() will return "string" for both, UNO_ENUM and UNO_CONSTANTS.
---
Would anyone have an idea how to use OLE/COM to get at the fields and values for UNO_CONSTANTS like
FontWeight (getting the UNO_CONSTANT value for BOLD other than manually via
<https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/FontWeight.html>)?
---rony
P.S.: In the process of creating OLE/COM nutshell examples for scalc, swriter
and simpress.