Função CreateUnoValue

Retorna um objeto que representa um valor fortemente tipado referente ao sistema de tipo 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.

Ícone Nota

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.


Sintaxe:


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

Valor de retorno:

Objeto

Parâmetros:

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))

Códigos de erro:

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.

Exemplo:

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.

Esse exemplo usa o método com.sun.star.beans.XPropertySet.addProperty() para criar uma propriedade de documento cujos valores padrão requerem uso de CreateUnoValue():


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

Você também pode usar esta função para passar valores diferentes de Any, mas isso não é recomendado. Se o BASIC já souber o tipo de destino, o uso da função CreateUnoValue() resultará apenas em operações de conversão adicionais, que tornarão a execução do BASIC mais lenta.