Reliably; Funny guy.
Of course there is.
Each control model has a service name property. That is what you want
Here is an example routine which will walk down every control on a form looking for certain types of controls.
And then go over what is happening. (actually it should be fairly self explanatory)
sub setNativeWidgetLook( aDataForm as variant, aYesNo as Boolean )
dim enControlModels
dim oControlModel as object
'thisComponent.LockControllers '
enControlModels = aDataForm.CreateEnumeration
if enControlModels.hasMoreElements then
do
oControlModel = enControlModels.nextElement
if oControlModel.ServiceName = "stardiv.one.form.component.Form" then
setNativeWidgetLook( oControlModel, aYesNo )
else
if oControlModel.ServiceName <> "stardiv.one.form.component.Grid" then
if oControlModel.ServiceName <> "stardiv.one.form.component.Hidden" then
oControlModel.NativeWidgetLook = aYesNo
end if
else
setNativeWidgetLook( oControlModel, aYesNo )
end if
end if
loop while enControlModels.hasMoreElements = True
end if
'thisComponent.UnLockControllers '
end sub
Of course a dataform can nest include other dataforms (ie. for a master/slave type form) so in these lines:
if oControlModel.ServiceName = "stardiv.one.form.component.Form" then
setNativeWidgetLook( oControlModel, aYesNo )
if the current control is another dataform the routine uses recursion to walk down the controls on this sub-dataform first.
Then it looks it checks that the control model is neither a grid control nor a hidden control (which is not just any control hidden, it is separate type of control) and if not then it sets the property NativeWidetLook (yes for OS, no for LO).
If the current control was a grid, that again has a collection of controls so again it uses recursion to call itself and walk down those also.
You will want to get a copy of SDK from the LO download site, with that is the documentation that will give you the needed ServiceNames, etc and this document can be linked to from MRI so you can use it to get details while you are working.
When you say datatype of the control are you actually asking to find the dataytpe of the database field the control is linked to? (I’ll assume you are)
so here is an example of another working routine which uses that:
sub PrettyControl( aControl as variant, aReqColor as double, setDisplaySize as boolean )
if aControl.ServiceName = "stardiv.one.form.component.Edit" _
or aControl.ServiceName = "stardiv.one.form.component.TimeField" _
or aControl.ServiceName = "stardiv.one.form.component.DateField" _
then
if aControl.BoundField.isNullable = 0 and aReqColor <> -1 then
aControl.BackgroundColor = aReqColor
end if
aControl.ReadOnly = aControl.BoundField.IsAutoIncrement
if aControl.BoundField.TypeName = "VARCHAR"_
OR aControl.BoundField.TypeName = "CHAR"_
then
if setDisplaySize then
aControl.MaxTextLen = aControl.BoundField.DisplaySize
end if
end if
if aControl.HelpText = "" then
aControl.HelpText = aControl.BoundField.Helptext
end if
end if
end sub
Each data awara UI control has a property BoundField which is the database column and here the routine checks that for certain things like whether is can be null and if not colors the UI controls background, the only thing that might need explaining are the last lines:
if aControl.HelpText = "" then
aControl.HelpText = aControl.BoundField.Helptext
end if
In the table edit dialog there is the ability to add a description to a column, that string can be accessed through the Helptext property and this copies that string into the UI controls HelpText property.
Hope that helps.