hyper 和 Decimal 的映射
From Apache OpenOffice Wiki
< Zh | Documentation
与 UNO hyper 相比,Automation 不具有 8 字节整数值。但是,Automation 类型 Decimal 值的空间很大,足以表示 hyper。因此,当从 Automation 调用 UNO 方法时,只要 UNO 方法需要 hyper 或 unsigned hyper,就需要使用 Decimal。
并非所有使用 Automation 的语言都支持 Decimal 类型。例如,JScript 和 VBScript,调用这些 UNO 方法时就不应该使用这种类型。这是因为所提供的值可能被四舍五入,因此结果将会受到影响。
Visual Basic 限制只能将 Decimal 变量声明为 Variant。因此必须使用 CDec 函数来赋值。而且,VB 不允许使用大于 4 字节的整数文字。作为一种 解决方法,您可以提供一个包含该值的字符串。例如:
Dim aHyper As Variant
aHyper = CDec("9223372036854775807")
Visual Basic .NET 有内置类型 decimal 并且不限制整数文字。
如果从 UNO 调用 Automation 对象,则可以使用 com.sun.star.bridge.oleautomation.Decimal 类型为 Decimal 类型的 Automation 参数提供参数。返回的 Decimal 值将被转换成 com.sun.star.bridge.oleautomation.Decimal。
| Content on this page is licensed under the Public Documentation License (PDL). |