|
32 | 32 | import com.sun.jna.platform.win32.WinDef.PVOID; |
33 | 33 | import com.sun.jna.platform.win32.WinDef.UINT; |
34 | 34 | import com.sun.jna.platform.win32.WinNT.HRESULT; |
35 | | -import com.sun.jna.platform.win32.COM.TypeLib; |
36 | 35 | import com.sun.jna.ptr.DoubleByReference; |
37 | 36 | import com.sun.jna.ptr.PointerByReference; |
38 | 37 | import com.sun.jna.win32.StdCallLibrary; |
@@ -215,6 +214,163 @@ public interface OleAuto extends StdCallLibrary { |
215 | 214 | */ |
216 | 215 | HRESULT VariantClear(Pointer pvarg); |
217 | 216 |
|
| 217 | + public static final short VARIANT_NOVALUEPROP = 0x01; |
| 218 | + /** For VT_BOOL to VT_BSTR conversions, convert to "True"/"False" instead of "-1"/"0" */ |
| 219 | + public static final short VARIANT_ALPHABOOL = 0x02; |
| 220 | + /** For conversions to/from VT_BSTR, passes LOCALE_NOUSEROVERRIDE to core coercion routines */ |
| 221 | + public static final short VARIANT_NOUSEROVERRIDE = 0x04; |
| 222 | + public static final short VARIANT_CALENDAR_HIJRI = 0x08; |
| 223 | + /** For VT_BOOL to VT_BSTR and back, convert to local language rather than English */ |
| 224 | + public static final short VARIANT_LOCALBOOL = 0x10; |
| 225 | + /** SOUTHASIA calendar support */ |
| 226 | + public static final short VARIANT_CALENDAR_THAI = 0x20; |
| 227 | + /** SOUTHASIA calendar support */ |
| 228 | + public static final short VARIANT_CALENDAR_GREGORIAN = 0x40; |
| 229 | + /** NLS function call support */ |
| 230 | + public static final short VARIANT_USE_NLS = 0x80; |
| 231 | + |
| 232 | + /** |
| 233 | + * Converts a variant from one type to another. |
| 234 | + * @param pvargDest [out] The destination variant. If this is the same as |
| 235 | + * pvarSrc, the variant will be converted in place. |
| 236 | + * @param pvarSrc [in] The variant to convert. |
| 237 | + * @param wFlags Combination of the following flags |
| 238 | + * <table> |
| 239 | + * <thead> |
| 240 | + * <tr><th><!--indent under wFlags comment--><div style="visibility: hidden">wFlags</div></th><th>Value</th><th>Meaning</th></tr> |
| 241 | + * </thead> |
| 242 | + * <tbody valign="top"> |
| 243 | + * <tr><th></th><td>{@link #VARIANT_NOVALUEPROP}</td><td>Prevents the function from attempting to coerce an object to a fundamental type by getting the Value property. Applications should set this flag only if necessary, because it makes their behavior inconsistent with other applications.</td></tr> |
| 244 | + * <tr><th></th><td>{@link #VARIANT_ALPHABOOL}</td><td>Converts a {@link Variant#VT_BOOL VT_BOOL} value to a string containing either "True" or "False".</td></tr> |
| 245 | + * <tr><th></th><td>{@link #VARIANT_NOUSEROVERRIDE}</td><td>For conversions to or from {@link Variant#VT_BSTR VT_BSTR}, passes LOCALE_NOUSEROVERRIDE to the core coercion routines.</td></tr> |
| 246 | + * <tr><th></th><td>{@link #VARIANT_LOCALBOOL}</td><td>For conversions from {@link Variant#VT_BOOL VT_BOOL} to {@link Variant#VT_BSTR VT_BSTR} and back, uses the language specified by the locale in use on the local computer.</td></tr> |
| 247 | + * </tbody> |
| 248 | + * </table> |
| 249 | + * @param vt The type to convert to. If the return code is {@link WinError#S_OK S_OK}, the vt |
| 250 | + * field of the vargDest is guaranteed to be equal to this value. |
| 251 | + * @return This function can return one of these values: |
| 252 | + * <table> |
| 253 | + * <thead> |
| 254 | + * <tr><th>Return code</th><th>Description</th></tr> |
| 255 | + * </thead> |
| 256 | + * <tbody valign="top"> |
| 257 | + * <tr><td>{@link WinError#S_OK S_OK}</td><td>Success.</td></tr> |
| 258 | + * <tr><td>{@link WinError#DISP_E_BADVARTYPE DISP_E_BADVARTYPE}</td><td>The variant type is not a valid type of variant.</td></tr> |
| 259 | + * <tr><td>{@link WinError#DISP_E_OVERFLOW DISP_E_OVERFLOW}</td><td>The data pointed to by pvarSrc does not fit in the destination type.</td></tr> |
| 260 | + * <tr><td>{@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}</td><td>The argument could not be coerced to the specified type.</td></tr> |
| 261 | + * <tr><td>{@link WinError#E_INVALIDARG E_INVALIDARG}</td><td>One of the arguments is not valid.</td></tr> |
| 262 | + * <tr><td>{@link WinError#E_OUTOFMEMORY E_OUTOFMEMORY}</td><td>Insufficient memory to complete the operation.</td></tr> |
| 263 | + * </tbody> |
| 264 | + * </table> |
| 265 | + *</p> |
| 266 | + * <b>Remarks</b> |
| 267 | + *</p> |
| 268 | + * The VariantChangeType function handles coercions between the fundamental |
| 269 | + * types (including numeric-to-string and string-to-numeric coercions). The |
| 270 | + * pvarSrc argument is changed during the conversion process. For example, |
| 271 | + * if the source variant is of type {@link Variant#VT_BOOL VT_BOOL} and the |
| 272 | + * destination is of type {@link Variant#VT_UINT VT_UINT}, the pvarSrc |
| 273 | + * argument is first converted to {@link Variant#VT_I2 VT_I2} and then the |
| 274 | + * conversion proceeds. A variant that has {@link Variant#VT_BYREF VT_BYREF} |
| 275 | + * set is coerced to a value by obtaining the referenced value. An object is |
| 276 | + * coerced to a value by invoking the object's Value property |
| 277 | + * ({@link OaIdl#DISPID_VALUE DISPID_VALUE}). |
| 278 | + *</p> |
| 279 | + * Typically, the implementor of |
| 280 | + * {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke IDispatch.Invoke} |
| 281 | + * determines which member is being accessed, and then calls |
| 282 | + * VariantChangeType to get the value of one or more arguments. For example, |
| 283 | + * if the IDispatch call specifies a SetTitle member that takes one string |
| 284 | + * argument, the implementor would call VariantChangeType to attempt to |
| 285 | + * coerce the argument to {@link Variant#VT_BSTR VT_BSTR}. If |
| 286 | + * VariantChangeType does not return an error, the argument could then be |
| 287 | + * obtained directly from the |
| 288 | + * {@link Variant.VARIANT._VARIANT.__VARIANT#bstrVal bstrVal} field of the |
| 289 | + * {@link Variant.VARIANT VARIANT}. If VariantChangeType returns |
| 290 | + * {@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}, the implementor |
| 291 | + * would set {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke Invoke} |
| 292 | + * <code> puArgErr</code> parameter referenced value to 0 (indicating the |
| 293 | + * argument in error) and return DISP_E_TYPEMISMATCH from Invoke. |
| 294 | + *</p> |
| 295 | + * Arrays of one type cannot be converted to arrays of another type with |
| 296 | + * this function. |
| 297 | + *</p> |
| 298 | + * <b>Note</b> The type of a {@link Variant.VARIANT VARIANT} should not be |
| 299 | + * changed in the {@link DISPPARAMS#rgvarg rgvarg} array in place. |
| 300 | + */ |
| 301 | + HRESULT VariantChangeType(VARIANT pvargDest, VARIANT pvarSrc, short wFlags, VARTYPE vt); |
| 302 | + |
| 303 | + /** |
| 304 | + * Converts a variant from one type to another. |
| 305 | + * @param pvargDest [out] The destination variant. If this is the same as |
| 306 | + * pvarSrc, the variant will be converted in place. |
| 307 | + * @param pvarSrc [in] The variant to convert. |
| 308 | + * @param wFlags Combination of the following flags |
| 309 | + * <table> |
| 310 | + * <thead> |
| 311 | + * <tr><th><!--indent under wFlags comment--><div style="visibility: hidden">wFlags</div></th><th>Value</th><th>Meaning</th></tr> |
| 312 | + * </thead> |
| 313 | + * <tbody valign="top"> |
| 314 | + * <tr><th></th><td>{@link #VARIANT_NOVALUEPROP}</td><td>Prevents the function from attempting to coerce an object to a fundamental type by getting the Value property. Applications should set this flag only if necessary, because it makes their behavior inconsistent with other applications.</td></tr> |
| 315 | + * <tr><th></th><td>{@link #VARIANT_ALPHABOOL}</td><td>Converts a {@link Variant#VT_BOOL VT_BOOL} value to a string containing either "True" or "False".</td></tr> |
| 316 | + * <tr><th></th><td>{@link #VARIANT_NOUSEROVERRIDE}</td><td>For conversions to or from {@link Variant#VT_BSTR VT_BSTR}, passes LOCALE_NOUSEROVERRIDE to the core coercion routines.</td></tr> |
| 317 | + * <tr><th></th><td>{@link #VARIANT_LOCALBOOL}</td><td>For conversions from {@link Variant#VT_BOOL VT_BOOL} to {@link Variant#VT_BSTR VT_BSTR} and back, uses the language specified by the locale in use on the local computer.</td></tr> |
| 318 | + * </tbody> |
| 319 | + * </table> |
| 320 | + * @param vt The type to convert to. If the return code is {@link WinError#S_OK S_OK}, the vt |
| 321 | + * field of the vargDest is guaranteed to be equal to this value. |
| 322 | + * @return This function can return one of these values: |
| 323 | + * <table> |
| 324 | + * <thead> |
| 325 | + * <tr><th>Return code</th><th>Description</th></tr> |
| 326 | + * </thead> |
| 327 | + * <tbody valign="top"> |
| 328 | + * <tr><td>{@link WinError#S_OK S_OK}</td><td>Success.</td></tr> |
| 329 | + * <tr><td>{@link WinError#DISP_E_BADVARTYPE DISP_E_BADVARTYPE}</td><td>The variant type is not a valid type of variant.</td></tr> |
| 330 | + * <tr><td>{@link WinError#DISP_E_OVERFLOW DISP_E_OVERFLOW}</td><td>The data pointed to by pvarSrc does not fit in the destination type.</td></tr> |
| 331 | + * <tr><td>{@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}</td><td>The argument could not be coerced to the specified type.</td></tr> |
| 332 | + * <tr><td>{@link WinError#E_INVALIDARG E_INVALIDARG}</td><td>One of the arguments is not valid.</td></tr> |
| 333 | + * <tr><td>{@link WinError#E_OUTOFMEMORY E_OUTOFMEMORY}</td><td>Insufficient memory to complete the operation.</td></tr> |
| 334 | + * </tbody> |
| 335 | + * </table> |
| 336 | + *</p> |
| 337 | + * <b>Remarks</b> |
| 338 | + *</p> |
| 339 | + * The VariantChangeType function handles coercions between the fundamental |
| 340 | + * types (including numeric-to-string and string-to-numeric coercions). The |
| 341 | + * pvarSrc argument is changed during the conversion process. For example, |
| 342 | + * if the source variant is of type {@link Variant#VT_BOOL VT_BOOL} and the |
| 343 | + * destination is of type {@link Variant#VT_UINT VT_UINT}, the pvarSrc |
| 344 | + * argument is first converted to {@link Variant#VT_I2 VT_I2} and then the |
| 345 | + * conversion proceeds. A variant that has {@link Variant#VT_BYREF VT_BYREF} |
| 346 | + * set is coerced to a value by obtaining the referenced value. An object is |
| 347 | + * coerced to a value by invoking the object's Value property |
| 348 | + * ({@link OaIdl#DISPID_VALUE DISPID_VALUE}). |
| 349 | + *</p> |
| 350 | + * Typically, the implementor of |
| 351 | + * {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke IDispatch.Invoke} |
| 352 | + * determines which member is being accessed, and then calls |
| 353 | + * VariantChangeType to get the value of one or more arguments. For example, |
| 354 | + * if the IDispatch call specifies a SetTitle member that takes one string |
| 355 | + * argument, the implementor would call VariantChangeType to attempt to |
| 356 | + * coerce the argument to {@link Variant#VT_BSTR VT_BSTR}. If |
| 357 | + * VariantChangeType does not return an error, the argument could then be |
| 358 | + * obtained directly from the |
| 359 | + * {@link Variant.VARIANT._VARIANT.__VARIANT#bstrVal bstrVal} field of the |
| 360 | + * {@link Variant.VARIANT VARIANT}. If VariantChangeType returns |
| 361 | + * {@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}, the implementor |
| 362 | + * would set {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke Invoke} |
| 363 | + * <code> puArgErr</code> parameter referenced value to 0 (indicating the |
| 364 | + * argument in error) and return DISP_E_TYPEMISMATCH from Invoke. |
| 365 | + *</p> |
| 366 | + * Arrays of one type cannot be converted to arrays of another type with |
| 367 | + * this function. |
| 368 | + *</p> |
| 369 | + * <b>Note</b> The type of a {@link Variant.VARIANT VARIANT} should not be |
| 370 | + * changed in the {@link DISPPARAMS#rgvarg rgvarg} array in place. |
| 371 | + */ |
| 372 | + HRESULT VariantChangeType(VARIANT.ByReference pvargDest, VARIANT.ByReference pvarSrc, short wFlags, VARTYPE vt); |
| 373 | + |
218 | 374 | /** |
219 | 375 | * Creates a new array descriptor, allocates and initializes the data for |
220 | 376 | * the array, and returns a pointer to the new array descriptor. |
|
0 commit comments