CreateUnoValue 函数

返回一个对象,该对象表示一个涉及 Uno 类型系统的精确类型值。

该对象被传送到 Uno 时,将自动转换成一种相应的 Any 类型,此类型必须由全限定的 Uno 类型名称来指定。

批注图标

Collabora Office API 经常使用 Any 类型。它与其他环境中的 Variant 类型相对应。Any 类型具有一个任意类型的 Uno,可用于一般的 Uno 接口。


语法:

oUnoValue = CreateUnoValue( "[]byte", MyBasicValue ) ' 获取字节序列。

If CreateUnoValue cannot be converted to the specified Uno type, and error occurs. For the conversion, the TypeConverter service is used.

This function is intended for use in situations where the default Basic to Uno type converting mechanism is insufficient. This can happen when you try to access generic Any based interfaces, such as XPropertySet::setPropertyValue( Name, Value ) or X???Container::insertBy???( ???, Value ), from Collabora Office Basic. The Basic runtime does not recognize these types as they are only defined in the corresponding service.

In this type of situation, Collabora Office Basic chooses the best matching type for the Basic type that you want to convert. However, if the wrong type is selected, an error occurs. You use the CreateUnoValue() function to create a value for the unknown Uno type.

You can also use this function to pass non-Any values, but this is not recommend. If Basic already knows the target type, using the CreateUnoValue() function will only lead to additional converting operations that slow down the Basic execution.

请支持我们!