Hi Oliver,
If a code uses the API and works, for me it is legal ;-)

Your code using the singleton is very interesting. In fact it works both for constants and enums. Here is a simplified VBScript code, with some examples.


' ---- This is a VBScript example -----

' ______ helper objects and routine ________

Set objServiceManager= WScript.CreateObject("com.sun.star.ServiceManager")
Set oContext = objServiceManager.DefaultContext
 ' Set oContext = objServiceManager.getPropertyValue("DefaultContext")
Set oTDM = oContext.getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager")


Function GetOOoConst(constString)
If oTDM.hasByHierarchicalName(constString) Then
  GetOOoConst = oTDM.getByHierarchicalName(constString)
Else
  MsgBox "Unrecognized name : " & constString, 16, "OOo API constant or enum"
End If
End Function


' _________ examples of use ___________________

Sub DisplayConst(constString)
MsgBox "Value = " & GetOOoConst(constString), 0, constString
End Sub

'get some constant values
DisplayConst "com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK"
DisplayConst "com.sun.star.awt.FontWeight.BOLD"
DisplayConst "com.sun.star.sheet.FilterOperator2.ENDS_WITH"
DisplayConst "com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN"
'get some enum values
DisplayConst "com.sun.star.text.WrapTextMode.THROUGHT"
DisplayConst "com.sun.star.awt.FontSlant.ITALIC"
DisplayConst "com.sun.star.table.CellVertJustify.BOTTOM"
DisplayConst "com.sun.star.sheet.FilterOperator.BOTTOM_VALUES"
' inexistent enum name value : BOLDDOT
DisplayConst "com.sun.star.awt.FontUnderline.BOLDDOT"


Regards
  Bernard

Message de Oliver Brinzing  date 2011-03-16 09:16 :
is it legal to use the following source code for reading oo Enum/Constant 
values ?
cause i found all vbscript examples seem to use direct values instead of 
constants, for example:
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Automation_Bridge

and i am not a vba expert ;-)

Regards

Oliver

--
-----------------------------------------------------------------
To unsubscribe send email to dev-unsubscr...@api.openoffice.org
For additional commands send email to sy...@api.openoffice.org
with Subject: help

Reply via email to