OK, it is possible using "/singletons/com.sun.star.reflection.theTypeDescriptionManager". (Will have to look further into it to maybe use it also for UNO_ENUM and the like.)

---rony


On 17.06.2022 12:46, Rony G. Flatscher wrote:
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.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org

Reply via email to