CreateUnoValue-funktion

Returnerer et objekt som repræsenterer en nøje indtastet værdi, refererende til Uno-type systemet.

Dette objekt konverteres automatisk til en Any af den tilsvarende type når den overføres til Uno. Typen skal være angivet ved dets fulde kvalificerede Uno-type navn.

Noteikon

LibreOfficeDev API'en bruger ofte Any-typen. Det er modparten til Variant-typen kendt fra andre miljøer. Any-typen indeholder en vilkårlig Uno-type og bruges i generiske Uno-grænseflader.


Syntaks:

oUnoValue = CreateUnoValue( "[]Byte", MyBasicValue ) ' for at få en bytesekvens.

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 LibreOfficeDev Basic. The Basic runtime does not recognize these types as they are only defined in the corresponding service.

In this type of situation, LibreOfficeDev 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.