CreateUnoValue Function

āĻāĻ•āĻŸāĻŋ āĻŦāĻ¸ā§āĻ¤ā§ āĻĒā§āĻ°āĻĻāĻžāĻ¨ āĻ•āĻ°ā§‡ āĻ¯āĻž Uno āĻŸāĻžāĻ‡āĻĒ āĻĒāĻĻā§āĻ§āĻ¤āĻŋāĻ¤ā§‡ āĻ‰āĻ˛ā§āĻ˛ā§‡āĻ–āĻŋāĻ¤ āĻ¸āĻ āĻŋāĻ•āĻ­āĻžāĻŦā§‡ āĻŸāĻžāĻ‡āĻĒāĻ•ā§ƒāĻ¤ āĻŽāĻžāĻ¨ā§‡āĻ° āĻ¸ā§āĻ¸ā§āĻĒāĻˇā§āĻŸ āĻŦā§āĻ¯āĻžāĻ–ā§āĻ¯āĻž āĻĒā§āĻ°āĻĻāĻžāĻ¨ āĻ•āĻ°ā§‡āĨ¤

This object is automatically converted to an Any of the corresponding type when passed to Uno. The type must be specified by its fully qualified Uno type name.

āĻ¨ā§‹āĻŸ āĻ†āĻ‡āĻ•āĻ¨

The LibreOffice API frequently uses the Any type. It is the counterpart of the Variant type known from other environments. The Any type holds one arbitrary Uno type and is used in generic Uno interfaces.


Syntax:


  CreateUnoValue(Type As String, Value As Object) As Object 

Return value:

Object

Parameters:

Type: The fully qualified Uno type name. Supported data types are void, char, boolean, byte, short, unsigned short, long, unsigned long, hyper, unsigned hyper, float, double, string, type, and any. Names are case sensitive and may be preceded by square brackets to indicate an array.

Value: A strictly typed value.


   byte_sequence_object = CreateUnoValue("[]byte", Array(85, 3, 27))

Error codes:

If CreateUnoValue cannot convert the value to the specified Uno type, an error occurs. The com.sun.star.script.Converter service is responsible for the conversion.

Example:

This function is intended for use in situations where the default Basic to Uno type converting mechanism is insufficient. This happens calling generic Any based API methods, such as com.sun.star.beans.XPropertySet.setPropertyValue() or com.sun.star.container.XNameContainer.insertByName(). CreateUnoValue() sets a value object for the unknown Uno type.

This example uses com.sun.star.beans.XPropertySet.addProperty() method to create a document property whose default values requires CreateUnoValue() usage:


  With ThisComponent.DocumentProperties.getUserDefinedProperties()
      .addProperty("FOO", com.sun.star.beans.PropertyAttribute.REMOVEABLE, CreateUnoValue("double", 23))
  End With	

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

Please support us!