Guida di LibreOffice 7.6
Restituisce un oggetto che rappresenta un valore fortemente tipizzato con riferimento al sistema di tipi Uno.
Questo oggetto viene automaticamente convertito in un Any di tipo corrispondente quando viene passato a Uno. Il tipo deve essere specificato con il nome pienamente qualificato del tipo Uno.
La API di LibreOffice utilizza spesso il tipo Any. Si tratta della controparte del tipo Variant utilizzato in altri ambienti. Il tipo Any contiene un solo tipo Uno arbitrario e viene usato nelle interfacce Uno generiche.
CreateUnoValue(Type As String, Value As Object) As Object
Oggetto
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))
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.
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
Questa funzione può anche essere usata per passare valori non-Any, ma questo metodo è sconsigliato. Se Basic conosce già il tipo di destinazione, l'uso della funzione CreateUnoValue() determina solo operazioni di conversione aggiuntive che rallentano l'esecuzione Basic.