1998-12-10 11:00:38 +01:00
|
|
|
/*
|
|
|
|
* VARIANT
|
|
|
|
*
|
|
|
|
* Copyright 1998 Jean-Claude Cote
|
2003-11-14 22:01:36 +01:00
|
|
|
* Copyright 2003 Jon Griffiths
|
|
|
|
* The alorithm for conversion from Julian days to day/month/year is based on
|
|
|
|
* that devised by Henry Fliegel, as implemented in PostgreSQL, which is
|
|
|
|
* Copyright 1994-7 Regents of the University of California
|
1998-12-10 11:00:38 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
1998-12-10 11:00:38 +01:00
|
|
|
* NOTES
|
|
|
|
* This implements the low-level and hi-level APIs for manipulating VARIANTs.
|
|
|
|
* The low-level APIs are used to do data coercion between different data types.
|
|
|
|
* The hi-level APIs are built on top of these low-level APIs and handle
|
|
|
|
* initialization, copying, destroying and changing the type of VARIANTs.
|
|
|
|
*
|
|
|
|
* TODO:
|
1999-08-18 20:35:57 +02:00
|
|
|
* - The Variant APIs do not support international languages, currency
|
1998-12-10 11:00:38 +01:00
|
|
|
* types, number formating and calendar. They only support U.S. English format.
|
|
|
|
* - The Variant APIs do not the following types: IUknown, IDispatch, DECIMAL and SafeArray.
|
1998-12-24 17:59:17 +01:00
|
|
|
* - The parsing of date for the VarDateFromStr is not complete.
|
2000-12-02 21:18:08 +01:00
|
|
|
* - The date manipulations do not support dates prior to 1900.
|
|
|
|
* - The parsing does not accept as many formats as the Windows implementation.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-10-25 00:13:47 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:39:48 +01:00
|
|
|
#include <stdio.h>
|
1998-12-10 11:00:38 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
1998-12-15 14:01:21 +01:00
|
|
|
#ifdef HAVE_FLOAT_H
|
|
|
|
# include <float.h>
|
|
|
|
#endif
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2000-02-10 20:39:48 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:39:48 +01:00
|
|
|
#include "oleauto.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winreg.h"
|
2000-02-10 20:39:48 +01:00
|
|
|
#include "heap.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2003-10-03 05:36:46 +02:00
|
|
|
#include "wine/unicode.h"
|
2000-02-10 20:39:48 +01:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "parsedt.h"
|
2002-06-21 01:07:55 +02:00
|
|
|
#include "typelib.h"
|
2003-01-24 00:07:38 +01:00
|
|
|
#include "winternl.h"
|
2003-10-03 05:36:46 +02:00
|
|
|
#include "variant.h"
|
2000-02-10 20:39:48 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
2000-02-10 20:39:48 +01:00
|
|
|
|
2003-11-25 02:49:31 +01:00
|
|
|
const char* wine_vtypes[VT_CLSID] =
|
|
|
|
{
|
|
|
|
"VT_EMPTY","VT_NULL","VT_I2","VT_I4","VT_R4","VT_R8","VT_CY","VT_DATE",
|
|
|
|
"VT_BSTR","VT_DISPATCH","VT_ERROR","VT_BOOL","VT_VARIANT","VT_UNKNOWN",
|
|
|
|
"VT_DECIMAL","15","VT_I1","VT_UI1","VT_UI2","VT_UI4","VT_I8","VT_UI8",
|
|
|
|
"VT_INT","VT_UINT","VT_VOID","VT_HRESULT","VT_PTR","VT_SAFEARRAY",
|
|
|
|
"VT_CARRAY","VT_USERDEFINED","VT_LPSTR","VT_LPWSTR""32","33","34","35",
|
|
|
|
"VT_RECORD","VT_INT_PTR","VT_UINT_PTR","39","40","41","42","43","44","45",
|
|
|
|
"46","47","48","49","50","51","52","53","54","55","56","57","58","59","60",
|
|
|
|
"61","62","63","VT_FILETIME","VT_BLOB","VT_STREAM","VT_STORAGE",
|
|
|
|
"VT_STREAMED_OBJECT","VT_STORED_OBJECT","VT_BLOB_OBJECT","VT_CF","VT_CLSID"
|
|
|
|
};
|
2001-09-21 23:01:31 +02:00
|
|
|
|
2003-11-25 02:49:31 +01:00
|
|
|
const char* wine_vflags[16] =
|
|
|
|
{
|
|
|
|
"",
|
|
|
|
"|VT_VECTOR",
|
|
|
|
"|VT_ARRAY",
|
|
|
|
"|VT_VECTOR|VT_ARRAY",
|
|
|
|
"|VT_BYREF",
|
|
|
|
"|VT_VECTOR|VT_ARRAY",
|
|
|
|
"|VT_ARRAY|VT_BYREF",
|
|
|
|
"|VT_VECTOR|VT_ARRAY|VT_BYREF",
|
|
|
|
"|VT_HARDTYPE",
|
|
|
|
"|VT_VECTOR|VT_HARDTYPE",
|
|
|
|
"|VT_ARRAY|VT_HARDTYPE",
|
|
|
|
"|VT_VECTOR|VT_ARRAY|VT_HARDTYPE",
|
|
|
|
"|VT_BYREF|VT_HARDTYPE",
|
|
|
|
"|VT_VECTOR|VT_ARRAY|VT_HARDTYPE",
|
|
|
|
"|VT_ARRAY|VT_BYREF|VT_HARDTYPE",
|
|
|
|
"|VT_VECTOR|VT_ARRAY|VT_BYREF|VT_HARDTYPE",
|
|
|
|
};
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-11-25 02:49:31 +01:00
|
|
|
#define SYSDUPSTRING(str) SysAllocStringByteLen((LPCSTR)(str), SysStringByteLen(str))
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2002-12-03 22:42:17 +01:00
|
|
|
/* the largest valid type
|
|
|
|
*/
|
|
|
|
#define VT_MAXVALIDTYPE VT_CLSID
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* This mask is used to set a flag in wReserved1 of
|
|
|
|
* the VARIANTARG structure. The flag indicates if
|
|
|
|
* the API function is using an inner variant or not.
|
|
|
|
*/
|
|
|
|
#define PROCESSING_INNER_VARIANT 0x0001
|
|
|
|
|
|
|
|
/* General use buffer.
|
|
|
|
*/
|
|
|
|
#define BUFFER_MAX 1024
|
|
|
|
static char pBuffer[BUFFER_MAX];
|
|
|
|
|
1998-12-24 17:59:17 +01:00
|
|
|
/*
|
|
|
|
* Note a leap year is one that is a multiple of 4
|
|
|
|
* but not of a 100. Except if it is a multiple of
|
|
|
|
* 400 then it is a leap year.
|
|
|
|
*/
|
2002-06-21 01:07:55 +02:00
|
|
|
|
2002-07-05 03:22:03 +02:00
|
|
|
/*
|
2002-06-21 01:07:55 +02:00
|
|
|
* Use 365 days/year and a manual calculation for leap year days
|
|
|
|
* to keep arithmetic simple
|
1998-12-24 17:59:17 +01:00
|
|
|
*/
|
2002-06-21 01:07:55 +02:00
|
|
|
static const double DAYS_IN_ONE_YEAR = 365.0;
|
|
|
|
|
1998-12-24 17:59:17 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* DateTimeStringToTm [INTERNAL]
|
|
|
|
*
|
|
|
|
* Converts a string representation of a date and/or time to a tm structure.
|
|
|
|
*
|
|
|
|
* Note this function uses the postgresql date parsing functions found
|
|
|
|
* in the parsedt.c file.
|
|
|
|
*
|
2000-12-02 21:18:08 +01:00
|
|
|
* Returns TRUE if successful.
|
1998-12-24 17:59:17 +01:00
|
|
|
*
|
|
|
|
* Note: This function does not parse the day of the week,
|
|
|
|
* daylight savings time. It will only fill the followin fields in
|
|
|
|
* the tm struct, tm_sec, tm_min, tm_hour, tm_year, tm_day, tm_mon.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2001-08-15 19:39:24 +02:00
|
|
|
static BOOL DateTimeStringToTm( OLECHAR* strIn, DWORD dwFlags, struct tm* pTm )
|
1998-12-24 17:59:17 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL res = FALSE;
|
1998-12-24 17:59:17 +01:00
|
|
|
double fsec;
|
|
|
|
int tzp;
|
|
|
|
int dtype;
|
|
|
|
int nf;
|
|
|
|
char *field[MAXDATEFIELDS];
|
|
|
|
int ftype[MAXDATEFIELDS];
|
|
|
|
char lowstr[MAXDATELEN + 1];
|
|
|
|
char* strDateTime = NULL;
|
|
|
|
|
|
|
|
/* Convert the string to ASCII since this is the only format
|
|
|
|
* postgesql can handle.
|
|
|
|
*/
|
|
|
|
strDateTime = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
|
|
|
|
|
|
|
|
if( strDateTime != NULL )
|
|
|
|
{
|
|
|
|
/* Make sure we don't go over the maximum length
|
|
|
|
* accepted by postgesql.
|
|
|
|
*/
|
|
|
|
if( strlen( strDateTime ) <= MAXDATELEN )
|
|
|
|
{
|
|
|
|
if( ParseDateTime( strDateTime, lowstr, field, ftype, MAXDATEFIELDS, &nf) == 0 )
|
|
|
|
{
|
2001-08-15 19:39:24 +02:00
|
|
|
if( dwFlags & VAR_DATEVALUEONLY )
|
1998-12-24 17:59:17 +01:00
|
|
|
{
|
|
|
|
/* Get the date information.
|
|
|
|
* It returns 0 if date information was
|
|
|
|
* present and 1 if only time information was present.
|
|
|
|
* -1 if an error occures.
|
|
|
|
*/
|
|
|
|
if( DecodeDateTime(field, ftype, nf, &dtype, pTm, &fsec, &tzp) == 0 )
|
|
|
|
{
|
|
|
|
/* Eliminate the time information since we
|
|
|
|
* were asked to get date information only.
|
|
|
|
*/
|
|
|
|
pTm->tm_sec = 0;
|
|
|
|
pTm->tm_min = 0;
|
|
|
|
pTm->tm_hour = 0;
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2001-08-15 19:39:24 +02:00
|
|
|
if( dwFlags & VAR_TIMEVALUEONLY )
|
1998-12-24 17:59:17 +01:00
|
|
|
{
|
|
|
|
/* Get time information only.
|
|
|
|
*/
|
|
|
|
if( DecodeTimeOnly(field, ftype, nf, &dtype, pTm, &fsec) == 0 )
|
|
|
|
{
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Get both date and time information.
|
|
|
|
* It returns 0 if date information was
|
|
|
|
* present and 1 if only time information was present.
|
|
|
|
* -1 if an error occures.
|
|
|
|
*/
|
|
|
|
if( DecodeDateTime(field, ftype, nf, &dtype, pTm, &fsec, &tzp) != -1 )
|
|
|
|
{
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, strDateTime );
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TmToDATE [INTERNAL]
|
|
|
|
*
|
|
|
|
* The date is implemented using an 8 byte floating-point number.
|
|
|
|
* Days are represented by whole numbers increments starting with 0.00 has
|
|
|
|
* being December 30 1899, midnight.
|
|
|
|
* The hours are expressed as the fractional part of the number.
|
|
|
|
* December 30 1899 at midnight = 0.00
|
|
|
|
* January 1 1900 at midnight = 2.00
|
|
|
|
* January 4 1900 at 6 AM = 5.25
|
|
|
|
* January 4 1900 at noon = 5.50
|
|
|
|
* December 29 1899 at midnight = -1.00
|
|
|
|
* December 18 1899 at midnight = -12.00
|
|
|
|
* December 18 1899 at 6AM = -12.25
|
|
|
|
* December 18 1899 at 6PM = -12.75
|
|
|
|
* December 19 1899 at midnight = -11.00
|
|
|
|
* The tm structure is as follows:
|
|
|
|
* struct tm {
|
|
|
|
* int tm_sec; seconds after the minute - [0,59]
|
|
|
|
* int tm_min; minutes after the hour - [0,59]
|
|
|
|
* int tm_hour; hours since midnight - [0,23]
|
|
|
|
* int tm_mday; day of the month - [1,31]
|
|
|
|
* int tm_mon; months since January - [0,11]
|
|
|
|
* int tm_year; years
|
|
|
|
* int tm_wday; days since Sunday - [0,6]
|
|
|
|
* int tm_yday; days since January 1 - [0,365]
|
|
|
|
* int tm_isdst; daylight savings time flag
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* Note: This function does not use the tm_wday, tm_yday, tm_wday,
|
|
|
|
* and tm_isdst fields of the tm structure. And only converts years
|
|
|
|
* after 1900.
|
|
|
|
*
|
2000-12-02 21:18:08 +01:00
|
|
|
* Returns TRUE if successful.
|
1998-12-24 17:59:17 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
static BOOL TmToDATE( struct tm* pTm, DATE *pDateOut )
|
1998-12-24 17:59:17 +01:00
|
|
|
{
|
2001-10-02 20:28:31 +02:00
|
|
|
int leapYear = 0;
|
1998-12-24 17:59:17 +01:00
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
/* Hmmm... An uninitialized Date in VB is December 30 1899 so
|
|
|
|
Start at 0. This is the way DATE is defined. */
|
1998-12-24 17:59:17 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
/* Start at 1. This is the way DATE is defined.
|
|
|
|
* January 1, 1900 at Midnight is 1.00.
|
|
|
|
* January 1, 1900 at 6AM is 1.25.
|
|
|
|
* and so on.
|
|
|
|
*/
|
|
|
|
*pDateOut = 1;
|
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
if( (pTm->tm_year - 1900) >= 0 ) {
|
2001-10-02 20:28:31 +02:00
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
/* Add the number of days corresponding to
|
|
|
|
* tm_year.
|
|
|
|
*/
|
|
|
|
*pDateOut += (pTm->tm_year - 1900) * 365;
|
2001-10-02 20:28:31 +02:00
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
/* Add the leap days in the previous years between now and 1900.
|
|
|
|
* Note a leap year is one that is a multiple of 4
|
|
|
|
* but not of a 100. Except if it is a multiple of
|
|
|
|
* 400 then it is a leap year.
|
2002-07-05 03:22:03 +02:00
|
|
|
* Copied + reversed functionality into TmToDate
|
2002-06-21 01:07:55 +02:00
|
|
|
*/
|
|
|
|
*pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
|
|
|
|
*pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
|
|
|
|
*pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
|
|
|
|
|
|
|
|
/* Set the leap year flag if the
|
|
|
|
* current year specified by tm_year is a
|
|
|
|
* leap year. This will be used to add a day
|
|
|
|
* to the day count.
|
|
|
|
*/
|
|
|
|
if( isleap( pTm->tm_year ) )
|
|
|
|
leapYear = 1;
|
|
|
|
|
|
|
|
/* Add the number of days corresponding to
|
|
|
|
* the month. (remember tm_mon is 0..11)
|
|
|
|
*/
|
|
|
|
switch( pTm->tm_mon )
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
*pDateOut += 31;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
*pDateOut += ( 59 + leapYear );
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
*pDateOut += ( 90 + leapYear );
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
*pDateOut += ( 120 + leapYear );
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
*pDateOut += ( 151 + leapYear );
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
*pDateOut += ( 181 + leapYear );
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
*pDateOut += ( 212 + leapYear );
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
*pDateOut += ( 243 + leapYear );
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
*pDateOut += ( 273 + leapYear );
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
*pDateOut += ( 304 + leapYear );
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
*pDateOut += ( 334 + leapYear );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Add the number of days in this month.
|
|
|
|
*/
|
|
|
|
*pDateOut += pTm->tm_mday;
|
|
|
|
|
|
|
|
/* Add the number of seconds, minutes, and hours
|
2003-07-09 04:52:57 +02:00
|
|
|
* to the DATE. Note these are the fractional part
|
2002-06-21 01:07:55 +02:00
|
|
|
* of the DATE so seconds / number of seconds in a day.
|
|
|
|
*/
|
|
|
|
} else {
|
|
|
|
*pDateOut = 0;
|
2001-10-02 20:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*pDateOut += pTm->tm_hour / 24.0;
|
|
|
|
*pDateOut += pTm->tm_min / 1440.0;
|
|
|
|
*pDateOut += pTm->tm_sec / 86400.0;
|
|
|
|
return TRUE;
|
1998-12-24 17:59:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DateToTm [INTERNAL]
|
|
|
|
*
|
2000-12-02 21:18:08 +01:00
|
|
|
* This function converts a windows DATE to a tm structure.
|
1998-12-24 17:59:17 +01:00
|
|
|
*
|
|
|
|
* It does not fill all the fields of the tm structure.
|
|
|
|
* Here is a list of the fields that are filled:
|
|
|
|
* tm_sec, tm_min, tm_hour, tm_year, tm_day, tm_mon.
|
|
|
|
*
|
|
|
|
* Note this function does not support dates before the January 1, 1900
|
|
|
|
* or ( dateIn < 2.0 ).
|
|
|
|
*
|
2000-12-02 21:18:08 +01:00
|
|
|
* Returns TRUE if successful.
|
1998-12-24 17:59:17 +01:00
|
|
|
*/
|
2002-06-21 01:07:55 +02:00
|
|
|
BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
|
1998-12-24 17:59:17 +01:00
|
|
|
{
|
2001-10-02 20:28:31 +02:00
|
|
|
double decimalPart = 0.0;
|
|
|
|
double wholePart = 0.0;
|
1998-12-24 17:59:17 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
memset(pTm,0,sizeof(*pTm));
|
1998-12-24 17:59:17 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
/* Because of the nature of DATE format which
|
|
|
|
* associates 2.0 to January 1, 1900. We will
|
|
|
|
* remove 1.0 from the whole part of the DATE
|
|
|
|
* so that in the following code 1.0
|
|
|
|
* will correspond to January 1, 1900.
|
|
|
|
* This simplifies the processing of the DATE value.
|
|
|
|
*/
|
2002-06-21 01:07:55 +02:00
|
|
|
decimalPart = fmod( dateIn, 1.0 ); /* Do this before the -1, otherwise 0.xx goes negative */
|
2001-10-02 20:28:31 +02:00
|
|
|
dateIn -= 1.0;
|
|
|
|
wholePart = (double) floor( dateIn );
|
|
|
|
|
|
|
|
if( !(dwFlags & VAR_TIMEVALUEONLY) )
|
|
|
|
{
|
2002-06-21 01:07:55 +02:00
|
|
|
unsigned int nDay = 0;
|
2001-10-02 20:28:31 +02:00
|
|
|
int leapYear = 0;
|
|
|
|
double yearsSince1900 = 0;
|
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
/* Hard code dates smaller than January 1, 1900. */
|
|
|
|
if( dateIn < 2.0 ) {
|
|
|
|
pTm->tm_year = 1899;
|
|
|
|
pTm->tm_mon = 11; /* December as tm_mon is 0..11 */
|
|
|
|
if( dateIn < 1.0 ) {
|
|
|
|
pTm->tm_mday = 30;
|
|
|
|
dateIn = dateIn * -1.0; /* Ensure +ve for time calculation */
|
|
|
|
decimalPart = decimalPart * -1.0; /* Ensure +ve for time calculation */
|
|
|
|
} else {
|
|
|
|
pTm->tm_mday = 31;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Start at 1900, this is where the DATE time 0.0 starts.
|
|
|
|
*/
|
|
|
|
pTm->tm_year = 1900;
|
|
|
|
/* find in what year the day in the "wholePart" falls into.
|
|
|
|
* add the value to the year field.
|
|
|
|
*/
|
|
|
|
yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
|
|
|
|
pTm->tm_year += yearsSince1900;
|
|
|
|
/* determine if this is a leap year.
|
|
|
|
*/
|
|
|
|
if( isleap( pTm->tm_year ) )
|
|
|
|
{
|
|
|
|
leapYear = 1;
|
|
|
|
wholePart++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find what day of that year the "wholePart" corresponds to.
|
|
|
|
* Note: nDay is in [1-366] format
|
|
|
|
*/
|
|
|
|
nDay = (((unsigned int) wholePart) - ((pTm->tm_year-1900) * DAYS_IN_ONE_YEAR ));
|
|
|
|
|
|
|
|
/* Remove the leap days in the previous years between now and 1900.
|
|
|
|
* Note a leap year is one that is a multiple of 4
|
|
|
|
* but not of a 100. Except if it is a multiple of
|
|
|
|
* 400 then it is a leap year.
|
2002-07-05 03:22:03 +02:00
|
|
|
* Copied + reversed functionality from TmToDate
|
2002-06-21 01:07:55 +02:00
|
|
|
*/
|
|
|
|
nDay -= ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 );
|
|
|
|
nDay += ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 );
|
|
|
|
nDay -= ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 );
|
|
|
|
|
|
|
|
/* Set the tm_yday value.
|
|
|
|
* Note: The day must be converted from [1-366] to [0-365]
|
|
|
|
*/
|
|
|
|
/*pTm->tm_yday = nDay - 1;*/
|
|
|
|
/* find which month this day corresponds to.
|
|
|
|
*/
|
|
|
|
if( nDay <= 31 )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay;
|
|
|
|
pTm->tm_mon = 0;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 59 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - 31;
|
|
|
|
pTm->tm_mon = 1;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 90 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 59 + leapYear );
|
|
|
|
pTm->tm_mon = 2;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 120 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 90 + leapYear );
|
|
|
|
pTm->tm_mon = 3;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 151 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 120 + leapYear );
|
|
|
|
pTm->tm_mon = 4;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 181 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 151 + leapYear );
|
|
|
|
pTm->tm_mon = 5;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 212 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 181 + leapYear );
|
|
|
|
pTm->tm_mon = 6;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 243 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 212 + leapYear );
|
|
|
|
pTm->tm_mon = 7;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 273 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 243 + leapYear );
|
|
|
|
pTm->tm_mon = 8;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 304 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 273 + leapYear );
|
|
|
|
pTm->tm_mon = 9;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 334 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 304 + leapYear );
|
|
|
|
pTm->tm_mon = 10;
|
|
|
|
}
|
|
|
|
else if( nDay <= ( 365 + leapYear ) )
|
|
|
|
{
|
|
|
|
pTm->tm_mday = nDay - ( 334 + leapYear );
|
|
|
|
pTm->tm_mon = 11;
|
|
|
|
}
|
2001-10-02 20:28:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if( !(dwFlags & VAR_DATEVALUEONLY) )
|
|
|
|
{
|
|
|
|
/* find the number of seconds in this day.
|
|
|
|
* fractional part times, hours, minutes, seconds.
|
2002-06-21 01:07:55 +02:00
|
|
|
* Note: 0.1 is hack to ensure figures come out in whole numbers
|
|
|
|
* due to floating point inaccuracies
|
2001-10-02 20:28:31 +02:00
|
|
|
*/
|
|
|
|
pTm->tm_hour = (int) ( decimalPart * 24 );
|
|
|
|
pTm->tm_min = (int) ( ( ( decimalPart * 24 ) - pTm->tm_hour ) * 60 );
|
2002-06-21 01:07:55 +02:00
|
|
|
/* Note: 0.1 is hack to ensure seconds come out in whole numbers
|
|
|
|
due to floating point inaccuracies */
|
|
|
|
pTm->tm_sec = (int) (( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 ) + 0.1);
|
2001-10-02 20:28:31 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
1998-12-24 17:59:17 +01:00
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SizeOfVariantData [INTERNAL]
|
|
|
|
*
|
|
|
|
* This function finds the size of the data referenced by a Variant based
|
|
|
|
* the type "vt" of the Variant.
|
|
|
|
*/
|
|
|
|
static int SizeOfVariantData( VARIANT* parg )
|
|
|
|
{
|
|
|
|
int size = 0;
|
2001-08-21 19:03:10 +02:00
|
|
|
switch( V_VT(parg) & VT_TYPEMASK )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
case( VT_I2 ):
|
|
|
|
size = sizeof(short);
|
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
size = sizeof(int);
|
|
|
|
break;
|
|
|
|
case( VT_I4 ):
|
|
|
|
size = sizeof(long);
|
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
|
|
|
size = sizeof(BYTE);
|
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
|
|
|
size = sizeof(unsigned short);
|
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
size = sizeof(unsigned int);
|
|
|
|
break;
|
|
|
|
case( VT_UI4 ):
|
|
|
|
size = sizeof(unsigned long);
|
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
|
|
|
size = sizeof(float);
|
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
|
|
|
size = sizeof(double);
|
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
|
|
|
size = sizeof(DATE);
|
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
|
|
|
size = sizeof(VARIANT_BOOL);
|
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2002-06-21 22:13:18 +02:00
|
|
|
case( VT_DISPATCH ):
|
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
size = sizeof(void*);
|
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2002-06-21 22:13:18 +02:00
|
|
|
size = sizeof(CY);
|
|
|
|
break;
|
|
|
|
case( VT_DECIMAL ): /* hmm, tricky, DECIMAL is only VT_BYREF */
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
2001-08-21 19:03:10 +02:00
|
|
|
FIXME("Add size information for type vt=%d\n", V_VT(parg) & VT_TYPEMASK );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
/******************************************************************************
|
|
|
|
* StringDupAtoBstr [INTERNAL]
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
static BSTR StringDupAtoBstr( char* strIn )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
BSTR bstr = NULL;
|
|
|
|
OLECHAR* pNewString = NULL;
|
2003-01-24 00:07:38 +01:00
|
|
|
UNICODE_STRING usBuffer;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz( &usBuffer, strIn );
|
|
|
|
pNewString = usBuffer.Buffer;
|
2003-10-03 05:36:46 +02:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
bstr = SysAllocString( pNewString );
|
2003-01-24 00:07:38 +01:00
|
|
|
RtlFreeUnicodeString( &usBuffer );
|
1998-12-10 11:00:38 +01:00
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* round [INTERNAL]
|
|
|
|
*
|
|
|
|
* Round the double value to the nearest integer value.
|
|
|
|
*/
|
|
|
|
static double round( double d )
|
|
|
|
{
|
1998-12-11 15:02:16 +01:00
|
|
|
double decimals = 0.0, integerValue = 0.0, roundedValue = 0.0;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL bEvenNumber = FALSE;
|
1998-12-10 11:00:38 +01:00
|
|
|
int nSign = 0;
|
|
|
|
|
|
|
|
/* Save the sign of the number
|
|
|
|
*/
|
1998-12-11 15:02:16 +01:00
|
|
|
nSign = (d >= 0.0) ? 1 : -1;
|
1998-12-10 11:00:38 +01:00
|
|
|
d = fabs( d );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/* Remove the decimals.
|
|
|
|
*/
|
1998-12-11 15:02:16 +01:00
|
|
|
integerValue = floor( d );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Set the Even flag. This is used to round the number when
|
|
|
|
* the decimals are exactly 1/2. If the integer part is
|
|
|
|
* odd the number is rounded up. If the integer part
|
|
|
|
* is even the number is rounded down. Using this method
|
|
|
|
* numbers are rounded up|down half the time.
|
|
|
|
*/
|
1998-12-11 15:02:16 +01:00
|
|
|
bEvenNumber = (((short)fmod(integerValue, 2)) == 0) ? TRUE : FALSE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Remove the integral part of the number.
|
|
|
|
*/
|
|
|
|
decimals = d - integerValue;
|
|
|
|
|
|
|
|
/* Note: Ceil returns the smallest integer that is greater that x.
|
|
|
|
* and floor returns the largest integer that is less than or equal to x.
|
|
|
|
*/
|
|
|
|
if( decimals > 0.5 )
|
|
|
|
{
|
|
|
|
/* If the decimal part is greater than 1/2
|
|
|
|
*/
|
|
|
|
roundedValue = ceil( d );
|
|
|
|
}
|
|
|
|
else if( decimals < 0.5 )
|
|
|
|
{
|
|
|
|
/* If the decimal part is smaller than 1/2
|
|
|
|
*/
|
|
|
|
roundedValue = floor( d );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* the decimals are exactly 1/2 so round according to
|
|
|
|
* the bEvenNumber flag.
|
|
|
|
*/
|
|
|
|
if( bEvenNumber )
|
|
|
|
{
|
|
|
|
roundedValue = floor( d );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
roundedValue = ceil( d );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return roundedValue * nSign;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Coerce [INTERNAL]
|
|
|
|
*
|
|
|
|
* This function dispatches execution to the proper conversion API
|
|
|
|
* to do the necessary coercion.
|
2001-08-18 20:00:50 +02:00
|
|
|
*
|
|
|
|
* FIXME: Passing down dwFlags to the conversion functions is wrong, this
|
|
|
|
* is a different flagmask. Check MSDN.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
|
|
|
static HRESULT Coerce( VARIANTARG* pd, LCID lcid, ULONG dwFlags, VARIANTARG* ps, VARTYPE vt )
|
|
|
|
{
|
|
|
|
HRESULT res = S_OK;
|
|
|
|
unsigned short vtFrom = 0;
|
2001-08-21 19:03:10 +02:00
|
|
|
vtFrom = V_VT(ps) & VT_TYPEMASK;
|
2001-08-18 20:00:50 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-18 20:14:29 +01:00
|
|
|
/* Note: Since "long" and "int" values both have 4 bytes and are
|
|
|
|
* both signed integers "int" will be treated as "long" in the
|
|
|
|
* following code.
|
|
|
|
* The same goes for their unsigned versions.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Trivial Case: If the coercion is from two types that are
|
2000-02-18 20:14:29 +01:00
|
|
|
* identical then we can blindly copy from one argument to another.*/
|
|
|
|
if ((vt==vtFrom))
|
|
|
|
return VariantCopy(pd,ps);
|
|
|
|
|
|
|
|
/* Cases requiring thought*/
|
1998-12-10 11:00:38 +01:00
|
|
|
switch( vt )
|
|
|
|
{
|
|
|
|
|
|
|
|
case( VT_EMPTY ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantClear( pd );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_NULL ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantClear( pd );
|
1998-12-10 11:00:38 +01:00
|
|
|
if( res == S_OK )
|
|
|
|
{
|
2001-08-21 19:03:10 +02:00
|
|
|
V_VT(pd) = VT_NULL;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case( VT_I1 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromI2( V_UNION(ps,iVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromI4( V_UNION(ps,lVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromUI1( V_UNION(ps,bVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromR4( V_UNION(ps,fltVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromR8( V_UNION(ps,dblVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromDate( V_UNION(ps,date), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromBool( V_UNION(ps,boolVal), &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,cVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI1FromCy( V_UNION(ps,cyVal), &V_UNION(pd,cVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarI1FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,cVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarI1FromDec( V_UNION(ps,decVal), &V_UNION(pd,cVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_I1\n", vtFrom );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_I2 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromI1( V_UNION(ps,cVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromI4( V_UNION(ps,lVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromUI1( V_UNION(ps,bVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromR4( V_UNION(ps,fltVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromR8( V_UNION(ps,dblVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromDate( V_UNION(ps,date), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromBool( V_UNION(ps,boolVal), &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,iVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI2FromCy( V_UNION(ps,cyVal), &V_UNION(pd,iVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarI2FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,iVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarI2FromDec( V_UNION(ps,deiVal), &V_UNION(pd,iVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_I2\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
2002-02-04 19:31:53 +01:00
|
|
|
case( VT_EMPTY ):
|
|
|
|
V_UNION(pd,lVal) = 0;
|
|
|
|
res = S_OK;
|
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromI1( V_UNION(ps,cVal), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromI2( V_UNION(ps,iVal), &V_UNION(pd,lVal) );
|
2003-01-03 00:11:56 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
case( VT_ERROR ):
|
|
|
|
V_UNION(pd,lVal) = V_UNION(pd,scode);
|
|
|
|
res = S_OK;
|
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantCopy( pd, ps );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromR4( V_UNION(ps,fltVal), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromDate( V_UNION(ps,date), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,lVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarI4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,lVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarI4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,lVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarI4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,lVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_INT/VT_I4\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_UI1 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromI1( V_UNION(ps,cVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromI2( V_UNION(ps,iVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromI4( V_UNION(ps,lVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantCopy( pd, ps );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromR4( V_UNION(ps,fltVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromR8( V_UNION(ps,dblVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromDate( V_UNION(ps,date), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromBool( V_UNION(ps,boolVal), &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,bVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI1FromCy( V_UNION(ps,cyVal), &V_UNION(pd,bVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarUI1FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,bVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarUI1FromDec( V_UNION(ps,deiVal), &V_UNION(pd,bVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_UI1\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_UI2 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromI1( V_UNION(ps,cVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromI2( V_UNION(ps,iVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromI4( V_UNION(ps,lVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromUI1( V_UNION(ps,bVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantCopy( pd, ps );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromR4( V_UNION(ps,fltVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromR8( V_UNION(ps,dblVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromDate( V_UNION(ps,date), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromBool( V_UNION(ps,boolVal), &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,uiVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI2FromCy( V_UNION(ps,cyVal), &V_UNION(pd,uiVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarUI2FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,uiVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarUI2FromDec( V_UNION(ps,deiVal), &V_UNION(pd,uiVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_UI2\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromI1( V_UNION(ps,cVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromI2( V_UNION(ps,iVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromI4( V_UNION(ps,lVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI4 ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantCopy( pd, ps );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromR4( V_UNION(ps,fltVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromDate( V_UNION(ps,date), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,ulVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarUI4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,ulVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarUI4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,ulVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarUI4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,ulVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_UINT/VT_UI4\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_R4 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromI1( V_UNION(ps,cVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromI2( V_UNION(ps,iVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromI4( V_UNION(ps,lVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromUI1( V_UNION(ps,bVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
2003-01-03 00:11:56 +01:00
|
|
|
case( VT_R4 ):
|
|
|
|
res = VariantCopy( pd, ps );
|
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromR8( V_UNION(ps,dblVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromDate( V_UNION(ps,date), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromBool( V_UNION(ps,boolVal), &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,fltVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR4FromCy( V_UNION(ps,cyVal), &V_UNION(pd,fltVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
2003-01-03 00:11:56 +01:00
|
|
|
case( VT_ERROR ):
|
|
|
|
V_UNION(pd,fltVal) = V_UNION(ps,scode);
|
|
|
|
res = S_OK;
|
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarR4FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,fltVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarR4FromDec( V_UNION(ps,deiVal), &V_UNION(pd,fltVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_R4\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_R8 ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromI1( V_UNION(ps,cVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromI2( V_UNION(ps,iVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromI4( V_UNION(ps,lVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromUI1( V_UNION(ps,bVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromUI2( V_UNION(ps,uiVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromUI4( V_UNION(ps,ulVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromR4( V_UNION(ps,fltVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantCopy( pd, ps );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromDate( V_UNION(ps,date), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromBool( V_UNION(ps,boolVal), &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,dblVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarR8FromCy( V_UNION(ps,cyVal), &V_UNION(pd,dblVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarR8FromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,dblVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarR8FromDec( V_UNION(ps,deiVal), &V_UNION(pd,dblVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_R8\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_DATE ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromI1( V_UNION(ps,cVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromI2( V_UNION(ps,iVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromInt( V_UNION(ps,intVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromI4( V_UNION(ps,lVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromUI1( V_UNION(ps,bVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromUint( V_UNION(ps,uintVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromR4( V_UNION(ps,fltVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromR8( V_UNION(ps,dblVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromBool( V_UNION(ps,boolVal), &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,date) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarDateFromCy( V_UNION(ps,cyVal), &V_UNION(pd,date) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarDateFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,date) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarDateFromDec( V_UNION(ps,deiVal), &V_UNION(pd,date) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_DATE\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_BOOL ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
2003-06-24 21:21:20 +02:00
|
|
|
case( VT_NULL ):
|
2002-02-05 19:11:17 +01:00
|
|
|
case( VT_EMPTY ):
|
|
|
|
res = S_OK;
|
|
|
|
V_UNION(pd,boolVal) = VARIANT_FALSE;
|
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromI1( V_UNION(ps,cVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromI2( V_UNION(ps,iVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromInt( V_UNION(ps,intVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromI4( V_UNION(ps,lVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromUI1( V_UNION(ps,bVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromUint( V_UNION(ps,uintVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromR4( V_UNION(ps,fltVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromR8( V_UNION(ps,dblVal), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromDate( V_UNION(ps,date), &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,boolVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBoolFromCy( V_UNION(ps,cyVal), &V_UNION(pd,boolVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarBoolFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,boolVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarBoolFromDec( V_UNION(ps,deiVal), &V_UNION(pd,boolVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_BOOL\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_BSTR ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
2000-11-25 02:20:37 +01:00
|
|
|
case( VT_EMPTY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
if ((V_UNION(pd,bstrVal) = SysAllocStringLen(NULL, 0)))
|
2000-11-25 02:20:37 +01:00
|
|
|
res = S_OK;
|
|
|
|
else
|
|
|
|
res = E_OUTOFMEMORY;
|
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromI1( V_UNION(ps,cVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromI2( V_UNION(ps,iVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromInt( V_UNION(ps,intVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromI4( V_UNION(ps,lVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromUI1( V_UNION(ps,bVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromUI2( V_UNION(ps,uiVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromUint( V_UNION(ps,uintVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromUI4( V_UNION(ps,ulVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromR4( V_UNION(ps,fltVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromR8( V_UNION(ps,dblVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromDate( V_UNION(ps,date), lcid, 0, &V_UNION(pd,bstrVal) );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2003-11-25 02:49:31 +01:00
|
|
|
if (dwFlags & VARIANT_ALPHABOOL)
|
|
|
|
res = VarBstrFromBool(V_BOOL(ps), lcid, 0, &V_BSTR(pd));
|
|
|
|
else if (dwFlags & VARIANT_LOCALBOOL)
|
|
|
|
res = VarBstrFromBool(V_BOOL(ps), lcid, VAR_LOCALBOOL, &V_BSTR(pd));
|
|
|
|
else
|
|
|
|
res = VarBstrFromI2(V_BOOL(ps), lcid, dwFlags, &V_BSTR(pd));
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_BSTR ):
|
|
|
|
res = VariantCopy( pd, ps );
|
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_CY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarBstrFromCy( V_UNION(ps,cyVal), lcid, 0, &V_UNION(pd,bstrVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarBstrFromDisp( V_UNION(ps,pdispVal), lcid, 0, &(pd,bstrVal) );*/
|
1998-12-10 11:00:38 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarBstrFromDec( V_UNION(ps,deiVal), lcid, 0, &(pd,bstrVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
case( VT_UNKNOWN ):
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_BSTR\n", vtFrom);
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
case( VT_CY ):
|
|
|
|
switch( vtFrom )
|
|
|
|
{
|
|
|
|
case( VT_I1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromI1( V_UNION(ps,cVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_I2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromI2( V_UNION(ps,iVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_INT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromInt( V_UNION(ps,intVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_I4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromI4( V_UNION(ps,lVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI1 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromUI1( V_UNION(ps,bVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI2 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromUI2( V_UNION(ps,uiVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_UINT ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromUint( V_UNION(ps,uintVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_UI4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromUI4( V_UNION(ps,ulVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_R4 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromR4( V_UNION(ps,fltVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_R8 ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromR8( V_UNION(ps,dblVal), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_DATE ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromDate( V_UNION(ps,date), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_BOOL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromBool( V_UNION(ps,date), &V_UNION(pd,cyVal) );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_CY ):
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantCopy( pd, ps );
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
case( VT_BSTR ):
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VarCyFromStr( V_UNION(ps,bstrVal), lcid, 0, &V_UNION(pd,cyVal) );
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
1998-12-11 15:02:16 +01:00
|
|
|
case( VT_DISPATCH ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarCyFromDisp( V_UNION(ps,pdispVal), lcid, &V_UNION(pd,cyVal) );*/
|
1998-12-11 15:02:16 +01:00
|
|
|
case( VT_DECIMAL ):
|
2001-08-21 19:03:10 +02:00
|
|
|
/*res = VarCyFromDec( V_UNION(ps,deiVal), &V_UNION(pd,cyVal) );*/
|
2001-05-31 23:32:08 +02:00
|
|
|
break;
|
|
|
|
case( VT_UNKNOWN ):
|
1998-12-11 15:02:16 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
FIXME("Coercion from %d to VT_CY\n", vtFrom);
|
1998-12-11 15:02:16 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-10-04 18:14:24 +02:00
|
|
|
case( VT_UNKNOWN ):
|
2003-01-11 21:58:58 +01:00
|
|
|
switch (vtFrom) {
|
|
|
|
case VT_DISPATCH:
|
|
|
|
if (V_DISPATCH(ps) == NULL) {
|
|
|
|
V_UNKNOWN(pd) = NULL;
|
|
|
|
} else {
|
|
|
|
res = IDispatch_QueryInterface(V_DISPATCH(ps), &IID_IUnknown, (LPVOID*)&V_UNKNOWN(pd));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VT_EMPTY: case VT_NULL: case VT_I2: case VT_I4:
|
|
|
|
case VT_R4: case VT_R8: case VT_CY: case VT_DATE:
|
|
|
|
case VT_BSTR: case VT_ERROR: case VT_BOOL:
|
|
|
|
case VT_VARIANT: case VT_DECIMAL: case VT_I1: case VT_UI1:
|
|
|
|
case VT_UI2: case VT_UI4: case VT_I8: case VT_UI8: case VT_INT:
|
|
|
|
case VT_UINT: case VT_VOID: case VT_HRESULT: case VT_PTR:
|
|
|
|
case VT_SAFEARRAY: case VT_CARRAY: case VT_USERDEFINED:
|
|
|
|
case VT_LPSTR: case VT_LPWSTR: case VT_RECORD: case VT_FILETIME:
|
|
|
|
case VT_BLOB: case VT_STREAM: case VT_STORAGE:
|
|
|
|
case VT_STREAMED_OBJECT: case VT_STORED_OBJECT: case VT_BLOB_OBJECT:
|
|
|
|
case VT_CF: case VT_CLSID:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Coercion from %d to VT_UNKNOWN unhandled.\n", vtFrom);
|
|
|
|
res = DISP_E_BADVARTYPE;
|
|
|
|
break;
|
2001-10-04 18:14:24 +02:00
|
|
|
}
|
2003-01-11 21:58:58 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case( VT_DISPATCH ):
|
|
|
|
switch (vtFrom) {
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
if (V_UNION(ps,punkVal) == NULL) {
|
|
|
|
V_UNION(pd,pdispVal) = NULL;
|
|
|
|
} else {
|
|
|
|
res = IUnknown_QueryInterface(V_UNION(ps,punkVal), &IID_IDispatch, (LPVOID*)&V_UNION(pd,pdispVal));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VT_EMPTY: case VT_NULL: case VT_I2: case VT_I4:
|
|
|
|
case VT_R4: case VT_R8: case VT_CY: case VT_DATE:
|
|
|
|
case VT_BSTR: case VT_ERROR: case VT_BOOL:
|
|
|
|
case VT_VARIANT: case VT_DECIMAL: case VT_I1: case VT_UI1:
|
|
|
|
case VT_UI2: case VT_UI4: case VT_I8: case VT_UI8: case VT_INT:
|
2003-03-06 23:42:28 +01:00
|
|
|
case VT_UINT: case VT_VOID: case VT_HRESULT:
|
2003-01-11 21:58:58 +01:00
|
|
|
case VT_SAFEARRAY: case VT_CARRAY: case VT_USERDEFINED:
|
|
|
|
case VT_LPSTR: case VT_LPWSTR: case VT_RECORD: case VT_FILETIME:
|
|
|
|
case VT_BLOB: case VT_STREAM: case VT_STORAGE:
|
|
|
|
case VT_STREAMED_OBJECT: case VT_STORED_OBJECT: case VT_BLOB_OBJECT:
|
|
|
|
case VT_CF: case VT_CLSID:
|
2001-10-04 18:14:24 +02:00
|
|
|
res = DISP_E_TYPEMISMATCH;
|
2003-01-11 21:58:58 +01:00
|
|
|
break;
|
2003-03-06 23:42:28 +01:00
|
|
|
case VT_PTR:
|
|
|
|
V_UNION(pd,pdispVal) = V_UNION(ps,pdispVal);
|
|
|
|
break;
|
2003-01-11 21:58:58 +01:00
|
|
|
default:
|
|
|
|
FIXME("Coercion from %d to VT_DISPATCH unhandled.\n", vtFrom);
|
|
|
|
res = DISP_E_BADVARTYPE;
|
|
|
|
break;
|
2001-10-04 18:14:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
default:
|
|
|
|
res = DISP_E_TYPEMISMATCH;
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("Coercion from %d to %d\n", vtFrom, vt );
|
1998-12-10 11:00:38 +01:00
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ValidateVtRange [INTERNAL]
|
|
|
|
*
|
|
|
|
* Used internally by the hi-level Variant API to determine
|
|
|
|
* if the vartypes are valid.
|
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
static HRESULT ValidateVtRange( VARTYPE vt )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
/* if by value we must make sure it is in the
|
|
|
|
* range of the valid types.
|
|
|
|
*/
|
|
|
|
if( ( vt & VT_TYPEMASK ) > VT_MAXVALIDTYPE )
|
|
|
|
{
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
/* Copy data from one variant to another. */
|
|
|
|
static void VARIANT_CopyData(const VARIANT *srcVar, VARTYPE vt, void *pOut)
|
|
|
|
{
|
|
|
|
switch(vt)
|
|
|
|
{
|
|
|
|
case VT_I1:
|
|
|
|
case VT_UI1: memcpy(pOut, &V_UI1(srcVar), sizeof(BYTE)); break;
|
|
|
|
case VT_BOOL:
|
|
|
|
case VT_I2:
|
|
|
|
case VT_UI2: memcpy(pOut, &V_UI2(srcVar), sizeof(SHORT)); break;
|
|
|
|
case VT_R4:
|
|
|
|
case VT_I4:
|
|
|
|
case VT_UI4: memcpy(pOut, &V_UI4(srcVar), sizeof (LONG)); break;
|
|
|
|
case VT_R8:
|
|
|
|
case VT_DATE:
|
|
|
|
case VT_CY:
|
|
|
|
case VT_I8:
|
|
|
|
case VT_UI8: memcpy(pOut, &V_UI8(srcVar), sizeof (LONG64)); break;
|
|
|
|
case VT_DECIMAL: memcpy(pOut, &V_DECIMAL(srcVar), sizeof (DECIMAL)); break;
|
|
|
|
default:
|
|
|
|
FIXME("VT_ type %d unhandled, please report!\n", vt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Coerce VT_DISPATCH to another type */
|
|
|
|
HRESULT VARIANT_FromDisp(IDispatch* pdispIn, LCID lcid, void* pOut, VARTYPE vt)
|
|
|
|
{
|
|
|
|
VARIANTARG srcVar, dstVar;
|
|
|
|
HRESULT hRet;
|
|
|
|
|
|
|
|
V_VT(&srcVar) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&srcVar) = pdispIn;
|
|
|
|
|
|
|
|
hRet = VariantChangeTypeEx(&dstVar, &srcVar, lcid, 0, vt);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hRet))
|
|
|
|
VARIANT_CopyData(&dstVar, vt, pOut);
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Coerce VT_BSTR to a numeric type */
|
|
|
|
HRESULT VARIANT_NumberFromBstr(OLECHAR* pStrIn, LCID lcid, ULONG ulFlags,
|
|
|
|
void* pOut, VARTYPE vt)
|
|
|
|
{
|
|
|
|
VARIANTARG dstVar;
|
|
|
|
HRESULT hRet;
|
|
|
|
NUMPARSE np;
|
|
|
|
BYTE rgb[1024];
|
|
|
|
|
|
|
|
/* Use VarParseNumFromStr/VarNumFromParseNum as MSDN indicates */
|
|
|
|
np.cDig = sizeof(rgb) / sizeof(BYTE);
|
|
|
|
np.dwInFlags = NUMPRS_STD;
|
|
|
|
|
|
|
|
hRet = VarParseNumFromStr(pStrIn, lcid, ulFlags, &np, rgb);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hRet))
|
|
|
|
{
|
|
|
|
/* 1 << vt gives us the VTBIT constant for the destination number type */
|
|
|
|
hRet = VarNumFromParseNum(&np, rgb, 1 << vt, &dstVar);
|
|
|
|
if (SUCCEEDED(hRet))
|
|
|
|
VARIANT_CopyData(&dstVar, vt, pOut);
|
|
|
|
}
|
|
|
|
return hRet;
|
|
|
|
}
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ValidateVartype [INTERNAL]
|
|
|
|
*
|
|
|
|
* Used internally by the hi-level Variant API to determine
|
|
|
|
* if the vartypes are valid.
|
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
static HRESULT ValidateVariantType( VARTYPE vt )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
HRESULT res = S_OK;
|
|
|
|
|
|
|
|
/* check if we have a valid argument.
|
|
|
|
*/
|
|
|
|
if( vt & VT_BYREF )
|
|
|
|
{
|
|
|
|
/* if by reference check that the type is in
|
|
|
|
* the valid range and that it is not of empty or null type
|
|
|
|
*/
|
|
|
|
if( ( vt & VT_TYPEMASK ) == VT_EMPTY ||
|
|
|
|
( vt & VT_TYPEMASK ) == VT_NULL ||
|
|
|
|
( vt & VT_TYPEMASK ) > VT_MAXVALIDTYPE )
|
|
|
|
{
|
2002-03-26 02:54:25 +01:00
|
|
|
res = DISP_E_BADVARTYPE;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
res = ValidateVtRange( vt );
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ValidateVt [INTERNAL]
|
|
|
|
*
|
|
|
|
* Used internally by the hi-level Variant API to determine
|
|
|
|
* if the vartypes are valid.
|
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
static HRESULT ValidateVt( VARTYPE vt )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
HRESULT res = S_OK;
|
|
|
|
|
|
|
|
/* check if we have a valid argument.
|
|
|
|
*/
|
|
|
|
if( vt & VT_BYREF )
|
|
|
|
{
|
|
|
|
/* if by reference check that the type is in
|
|
|
|
* the valid range and that it is not of empty or null type
|
|
|
|
*/
|
|
|
|
if( ( vt & VT_TYPEMASK ) == VT_EMPTY ||
|
|
|
|
( vt & VT_TYPEMASK ) == VT_NULL ||
|
|
|
|
( vt & VT_TYPEMASK ) > VT_MAXVALIDTYPE )
|
|
|
|
{
|
|
|
|
res = DISP_E_BADVARTYPE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
res = ValidateVtRange( vt );
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Check if a variants type is valid.
|
|
|
|
*/
|
|
|
|
static inline HRESULT VARIANT_ValidateType(VARTYPE vt)
|
|
|
|
{
|
|
|
|
VARTYPE vtExtra = vt & VT_EXTRA_TYPE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
vt &= VT_TYPEMASK;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if (!(vtExtra & (VT_VECTOR|VT_RESERVED)))
|
|
|
|
{
|
|
|
|
if (vt < VT_VOID || vt == VT_RECORD || vt == VT_CLSID)
|
|
|
|
{
|
|
|
|
if ((vtExtra & (VT_BYREF|VT_ARRAY)) && vt <= VT_NULL)
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
if (vt != (VARTYPE)15)
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
}
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VariantInit [OLEAUT32.8]
|
1998-12-10 11:00:38 +01:00
|
|
|
*
|
2003-10-03 05:36:46 +02:00
|
|
|
* Initialise a variant.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pVarg [O] Variant to initialise
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* This function simply sets the type of the variant to VT_EMPTY. It does not
|
|
|
|
* free any existing value, use VariantClear() for that.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
void WINAPI VariantInit(VARIANTARG* pVarg)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%p)\n", pVarg);
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
V_VT(pVarg) = VT_EMPTY; /* Native doesn't set any other fields */
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VariantClear [OLEAUT32.9]
|
1998-12-10 11:00:38 +01:00
|
|
|
*
|
2003-10-03 05:36:46 +02:00
|
|
|
* Clear a variant.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pVarg [I/O] Variant to clear
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. Any previous value in pVarg is freed and its type is set to VT_EMPTY.
|
|
|
|
* Failure: DISP_E_BADVARTYPE, if the variant is a not a valid variant type.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
HRESULT WINAPI VariantClear(VARIANTARG* pVarg)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pVarg);
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
hres = VARIANT_ValidateType(V_VT(pVarg));
|
|
|
|
|
|
|
|
if (SUCCEEDED(hres))
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
if (!V_ISBYREF(pVarg))
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
if (V_ISARRAY(pVarg) || V_VT(pVarg) == VT_SAFEARRAY)
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
if (V_ARRAY(pVarg))
|
|
|
|
hres = SafeArrayDestroy(V_ARRAY(pVarg));
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
else if (V_VT(pVarg) == VT_BSTR)
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
if (V_BSTR(pVarg))
|
|
|
|
SysFreeString(V_BSTR(pVarg));
|
|
|
|
}
|
|
|
|
else if (V_VT(pVarg) == VT_RECORD)
|
|
|
|
{
|
|
|
|
struct __tagBRECORD* pBr = &V_UNION(pVarg,brecVal);
|
|
|
|
if (pBr->pRecInfo)
|
|
|
|
{
|
|
|
|
IRecordInfo_RecordClear(pBr->pRecInfo, pBr->pvRecord);
|
|
|
|
IRecordInfo_Release(pBr->pRecInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (V_VT(pVarg) == VT_DISPATCH ||
|
|
|
|
V_VT(pVarg) == VT_UNKNOWN)
|
|
|
|
{
|
|
|
|
if (V_UNKNOWN(pVarg))
|
|
|
|
IUnknown_Release(V_UNKNOWN(pVarg));
|
|
|
|
}
|
|
|
|
else if (V_VT(pVarg) == VT_VARIANT)
|
|
|
|
{
|
|
|
|
if (V_VARIANTREF(pVarg))
|
|
|
|
VariantClear(V_VARIANTREF(pVarg));
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
V_VT(pVarg) = VT_EMPTY;
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
return hres;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VariantCopy [OLEAUT32.10]
|
1998-12-10 11:00:38 +01:00
|
|
|
*
|
2003-10-03 05:36:46 +02:00
|
|
|
* Copy a variant.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pvargDest [O] Destination for copy
|
|
|
|
* pvargSrc [I] Source variant to copy
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pvargDest contains a copy of pvargSrc.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* pvargDest is always freed, and may be equal to pvargSrc.
|
|
|
|
* If pvargSrc is by-reference, pvargDest is by-reference also.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VariantCopy(VARIANTARG* pvargDest, VARIANTARG* pvargSrc)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-02-28 11:07:12 +01:00
|
|
|
HRESULT res = S_OK;
|
|
|
|
|
2001-09-21 23:01:31 +02:00
|
|
|
TRACE("(%p, %p), vt=%d\n", pvargDest, pvargSrc, V_VT(pvargSrc));
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-08-21 19:03:10 +02:00
|
|
|
res = ValidateVariantType( V_VT(pvargSrc) );
|
1999-02-28 11:07:12 +01:00
|
|
|
|
|
|
|
/* If the pointer are to the same variant we don't need
|
|
|
|
* to do anything.
|
|
|
|
*/
|
|
|
|
if( pvargDest != pvargSrc && res == S_OK )
|
|
|
|
{
|
2003-01-03 00:11:56 +01:00
|
|
|
VariantClear( pvargDest ); /* result is not checked */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-01-03 00:11:56 +01:00
|
|
|
if( V_VT(pvargSrc) & VT_BYREF )
|
|
|
|
{
|
|
|
|
/* In the case of byreference we only need
|
|
|
|
* to copy the pointer.
|
|
|
|
*/
|
|
|
|
pvargDest->n1.n2.n3 = pvargSrc->n1.n2.n3;
|
|
|
|
V_VT(pvargDest) = V_VT(pvargSrc);
|
|
|
|
}
|
|
|
|
else
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
2003-01-03 00:11:56 +01:00
|
|
|
/*
|
|
|
|
* The VT_ARRAY flag is another way to designate a safe array.
|
|
|
|
*/
|
|
|
|
if (V_VT(pvargSrc) & VT_ARRAY)
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
2003-01-03 00:11:56 +01:00
|
|
|
SafeArrayCopy(V_UNION(pvargSrc,parray), &V_UNION(pvargDest,parray));
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-01-03 00:11:56 +01:00
|
|
|
/* In the case of by value we need to
|
|
|
|
* copy the actual value. In the case of
|
|
|
|
* VT_BSTR a copy of the string is made,
|
|
|
|
* if VT_DISPATCH or VT_IUNKNOWN AddRef is
|
|
|
|
* called to increment the object's reference count.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-01-03 00:11:56 +01:00
|
|
|
switch( V_VT(pvargSrc) & VT_TYPEMASK )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-01-03 00:11:56 +01:00
|
|
|
case( VT_BSTR ):
|
|
|
|
V_UNION(pvargDest,bstrVal) = SYSDUPSTRING( V_UNION(pvargSrc,bstrVal) );
|
|
|
|
break;
|
|
|
|
case( VT_DISPATCH ):
|
|
|
|
V_UNION(pvargDest,pdispVal) = V_UNION(pvargSrc,pdispVal);
|
|
|
|
if (V_UNION(pvargDest,pdispVal)!=NULL)
|
2003-01-05 02:06:04 +01:00
|
|
|
IDispatch_AddRef(V_UNION(pvargDest,pdispVal));
|
2003-01-03 00:11:56 +01:00
|
|
|
break;
|
|
|
|
case( VT_VARIANT ):
|
|
|
|
VariantCopy(V_UNION(pvargDest,pvarVal),V_UNION(pvargSrc,pvarVal));
|
|
|
|
break;
|
|
|
|
case( VT_UNKNOWN ):
|
|
|
|
V_UNION(pvargDest,punkVal) = V_UNION(pvargSrc,punkVal);
|
|
|
|
if (V_UNION(pvargDest,pdispVal)!=NULL)
|
2003-01-05 02:06:04 +01:00
|
|
|
IUnknown_AddRef(V_UNION(pvargDest,punkVal));
|
2003-01-03 00:11:56 +01:00
|
|
|
break;
|
|
|
|
case( VT_SAFEARRAY ):
|
|
|
|
SafeArrayCopy(V_UNION(pvargSrc,parray), &V_UNION(pvargDest,parray));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pvargDest->n1.n2.n3 = pvargSrc->n1.n2.n3;
|
|
|
|
break;
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2003-01-03 00:11:56 +01:00
|
|
|
V_VT(pvargDest) = V_VT(pvargSrc);
|
|
|
|
dump_Variant(pvargDest);
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VariantCopyInd [OLEAUT32.11]
|
1998-12-10 11:00:38 +01:00
|
|
|
*
|
2003-10-03 05:36:46 +02:00
|
|
|
*
|
|
|
|
* Copy a variant, dereferencing if it is by-reference.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pvargDest [O] Destination for copy
|
|
|
|
* pvargSrc [I] Source variant to copy
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pvargDest contains a copy of pvargSrc.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* pvargDest is always freed, and may be equal to pvargSrc.
|
|
|
|
* If pvargSrc is not by-reference, this function acts as VariantCopy().
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VariantCopyInd(VARIANT* pvargDest, VARIANTARG* pvargSrc)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-02-28 11:07:12 +01:00
|
|
|
HRESULT res = S_OK;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p)\n", pvargDest, pvargSrc);
|
1999-02-28 11:07:12 +01:00
|
|
|
|
2001-08-21 19:03:10 +02:00
|
|
|
res = ValidateVariantType( V_VT(pvargSrc) );
|
1999-02-28 11:07:12 +01:00
|
|
|
|
|
|
|
if( res != S_OK )
|
|
|
|
return res;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-21 19:03:10 +02:00
|
|
|
if( V_VT(pvargSrc) & VT_BYREF )
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
|
|
|
VARIANTARG varg;
|
|
|
|
VariantInit( &varg );
|
|
|
|
|
|
|
|
/* handle the in place copy.
|
|
|
|
*/
|
|
|
|
if( pvargDest == pvargSrc )
|
|
|
|
{
|
|
|
|
/* we will use a copy of the source instead.
|
|
|
|
*/
|
|
|
|
res = VariantCopy( &varg, pvargSrc );
|
|
|
|
pvargSrc = &varg;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( res == S_OK )
|
|
|
|
{
|
|
|
|
res = VariantClear( pvargDest );
|
|
|
|
|
|
|
|
if( res == S_OK )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The VT_ARRAY flag is another way to designate a safearray variant.
|
|
|
|
*/
|
2001-08-21 19:03:10 +02:00
|
|
|
if ( V_VT(pvargSrc) & VT_ARRAY)
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
2001-08-21 19:03:10 +02:00
|
|
|
SafeArrayCopy(*V_UNION(pvargSrc,pparray), &V_UNION(pvargDest,parray));
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
|
|
|
else
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-02-28 11:07:12 +01:00
|
|
|
/* In the case of by reference we need
|
|
|
|
* to copy the date pointed to by the variant.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get the variant type.
|
|
|
|
*/
|
2001-08-21 19:03:10 +02:00
|
|
|
switch( V_VT(pvargSrc) & VT_TYPEMASK )
|
1999-02-28 11:07:12 +01:00
|
|
|
{
|
|
|
|
case( VT_BSTR ):
|
2001-09-21 23:01:31 +02:00
|
|
|
V_UNION(pvargDest,bstrVal) = SYSDUPSTRING( *(V_UNION(pvargSrc,pbstrVal)) );
|
1999-02-28 11:07:12 +01:00
|
|
|
break;
|
|
|
|
case( VT_DISPATCH ):
|
2003-01-03 00:11:56 +01:00
|
|
|
V_UNION(pvargDest,pdispVal) = *V_UNION(pvargSrc,ppdispVal);
|
|
|
|
if (V_UNION(pvargDest,pdispVal)!=NULL)
|
2003-01-05 02:06:04 +01:00
|
|
|
IDispatch_AddRef(V_UNION(pvargDest,pdispVal));
|
1999-02-28 11:07:12 +01:00
|
|
|
break;
|
|
|
|
case( VT_VARIANT ):
|
|
|
|
{
|
|
|
|
/* Prevent from cycling. According to tests on
|
|
|
|
* VariantCopyInd in Windows and the documentation
|
|
|
|
* this API dereferences the inner Variants to only one depth.
|
|
|
|
* If the inner Variant itself contains an
|
|
|
|
* other inner variant the E_INVALIDARG error is
|
2002-06-01 01:06:46 +02:00
|
|
|
* returned.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2001-08-21 19:03:10 +02:00
|
|
|
if( pvargSrc->n1.n2.wReserved1 & PROCESSING_INNER_VARIANT )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-02-28 11:07:12 +01:00
|
|
|
/* If we get here we are attempting to deference
|
|
|
|
* an inner variant that that is itself contained
|
|
|
|
* in an inner variant so report E_INVALIDARG error.
|
|
|
|
*/
|
|
|
|
res = E_INVALIDARG;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
1999-02-28 11:07:12 +01:00
|
|
|
else
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-02-28 11:07:12 +01:00
|
|
|
/* Set the processing inner variant flag.
|
|
|
|
* We will set this flag in the inner variant
|
|
|
|
* that will be passed to the VariantCopyInd function.
|
|
|
|
*/
|
2001-08-21 19:03:10 +02:00
|
|
|
(V_UNION(pvargSrc,pvarVal))->n1.n2.wReserved1 |= PROCESSING_INNER_VARIANT;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 11:07:12 +01:00
|
|
|
/* Dereference the inner variant.
|
|
|
|
*/
|
2001-08-21 19:03:10 +02:00
|
|
|
res = VariantCopyInd( pvargDest, V_UNION(pvargSrc,pvarVal) );
|
2000-03-09 19:31:52 +01:00
|
|
|
/* We must also copy its type, I think.
|
|
|
|
*/
|
2001-08-21 19:03:10 +02:00
|
|
|
V_VT(pvargSrc) = V_VT(V_UNION(pvargSrc,pvarVal));
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case( VT_UNKNOWN ):
|
2003-01-03 00:11:56 +01:00
|
|
|
V_UNION(pvargDest,punkVal) = *V_UNION(pvargSrc,ppunkVal);
|
|
|
|
if (V_UNION(pvargDest,pdispVal)!=NULL)
|
2003-01-05 02:06:04 +01:00
|
|
|
IUnknown_AddRef(V_UNION(pvargDest,punkVal));
|
1999-02-28 11:07:12 +01:00
|
|
|
break;
|
|
|
|
case( VT_SAFEARRAY ):
|
2001-08-21 19:03:10 +02:00
|
|
|
SafeArrayCopy(*V_UNION(pvargSrc,pparray), &V_UNION(pvargDest,parray));
|
1999-02-28 11:07:12 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* This is a by reference Variant which means that the union
|
|
|
|
* part of the Variant contains a pointer to some data of
|
2001-08-21 19:03:10 +02:00
|
|
|
* type "V_VT(pvargSrc) & VT_TYPEMASK".
|
1999-02-28 11:07:12 +01:00
|
|
|
* We will deference this data in a generic fashion using
|
|
|
|
* the void pointer "Variant.u.byref".
|
|
|
|
* We will copy this data into the union of the destination
|
|
|
|
* Variant.
|
|
|
|
*/
|
2002-01-02 22:44:30 +01:00
|
|
|
memcpy( &pvargDest->n1.n2.n3, V_UNION(pvargSrc,byref), SizeOfVariantData( pvargSrc ) );
|
1999-02-28 11:07:12 +01:00
|
|
|
break;
|
|
|
|
}
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
2002-03-26 02:54:25 +01:00
|
|
|
|
|
|
|
if (res == S_OK) V_VT(pvargDest) = V_VT(pvargSrc) & VT_TYPEMASK;
|
1999-02-28 11:07:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this should not fail.
|
|
|
|
*/
|
|
|
|
VariantClear( &varg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
res = VariantCopy( pvargDest, pvargSrc );
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
2002-12-23 03:03:10 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Coerces a full safearray. Not optimal code.
|
|
|
|
*/
|
|
|
|
static HRESULT
|
|
|
|
coerce_array(
|
2003-01-03 00:11:56 +01:00
|
|
|
VARIANTARG* src, VARIANTARG *dst, LCID lcid, USHORT wFlags, VARTYPE vt
|
2002-12-23 03:03:10 +01:00
|
|
|
) {
|
2003-01-03 00:11:56 +01:00
|
|
|
SAFEARRAY *sarr = V_ARRAY(src);
|
2002-12-23 03:03:10 +01:00
|
|
|
HRESULT hres;
|
2003-01-03 00:11:56 +01:00
|
|
|
LPVOID data;
|
|
|
|
VARTYPE vartype;
|
|
|
|
|
|
|
|
SafeArrayGetVartype(sarr,&vartype);
|
|
|
|
switch (vt) {
|
|
|
|
case VT_BSTR:
|
|
|
|
if (sarr->cDims != 1) {
|
|
|
|
FIXME("Can not coerce array with dim %d into BSTR\n", sarr->cDims);
|
2002-12-23 03:03:10 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2003-01-03 00:11:56 +01:00
|
|
|
switch (V_VT(src) & VT_TYPEMASK) {
|
|
|
|
case VT_UI1:
|
|
|
|
hres = SafeArrayAccessData(sarr, &data);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
|
|
|
|
/* Yes, just memcpied apparently. */
|
|
|
|
V_BSTR(dst) = SysAllocStringByteLen(data, sarr->rgsabound[0].cElements);
|
|
|
|
hres = SafeArrayUnaccessData(sarr);
|
|
|
|
if (FAILED(hres)) return hres;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Cannot coerce array of %d into BSTR yet. Please report!\n", V_VT(src) & VT_TYPEMASK);
|
2002-12-23 03:03:10 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2003-01-03 00:11:56 +01:00
|
|
|
break;
|
|
|
|
case VT_SAFEARRAY:
|
|
|
|
V_VT(dst) = VT_SAFEARRAY;
|
|
|
|
return SafeArrayCopy(sarr, &V_ARRAY(dst));
|
|
|
|
default:
|
|
|
|
FIXME("Cannot coerce array of vt 0x%x/0x%x into vt 0x%x yet. Please report/implement!\n", vartype, V_VT(src), vt);
|
|
|
|
return E_FAIL;
|
2002-12-23 03:03:10 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VariantChangeType [OLEAUT32.12]
|
2003-10-03 05:36:46 +02:00
|
|
|
*
|
|
|
|
* Change the type of a variant.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pvargDest [O] Destination for the converted variant
|
|
|
|
* pvargSrc [O] Source variant to change the type of
|
|
|
|
* wFlags [I] VARIANT_ flags from "oleauto.h"
|
|
|
|
* vt [I] Variant type to change pvargSrc into
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pvargDest contains the converted value.
|
|
|
|
* Failure: An HRESULT error code describing the failure.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The LCID used for the conversion is LOCALE_USER_DEFAULT.
|
|
|
|
* See VariantChangeTypeEx.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VariantChangeType(VARIANTARG* pvargDest, VARIANTARG* pvargSrc,
|
1998-12-10 11:00:38 +01:00
|
|
|
USHORT wFlags, VARTYPE vt)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return VariantChangeTypeEx( pvargDest, pvargSrc, 0, wFlags, vt );
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VariantChangeTypeEx [OLEAUT32.147]
|
2003-10-03 05:36:46 +02:00
|
|
|
*
|
|
|
|
* Change the type of a variant.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pvargDest [O] Destination for the converted variant
|
|
|
|
* pvargSrc [O] Source variant to change the type of
|
|
|
|
* lcid [I] LCID for the conversion
|
|
|
|
* wFlags [I] VARIANT_ flags from "oleauto.h"
|
|
|
|
* vt [I] Variant type to change pvargSrc into
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pvargDest contains the converted value.
|
|
|
|
* Failure: An HRESULT error code describing the failure.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* pvargDest and pvargSrc can point to the same variant to perform an in-place
|
|
|
|
* conversion. If the conversion is successful, pvargSrc will be freed.
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VariantChangeTypeEx(VARIANTARG* pvargDest, VARIANTARG* pvargSrc,
|
1998-12-10 11:00:38 +01:00
|
|
|
LCID lcid, USHORT wFlags, VARTYPE vt)
|
|
|
|
{
|
|
|
|
HRESULT res = S_OK;
|
|
|
|
VARIANTARG varg;
|
1999-02-26 12:11:13 +01:00
|
|
|
VariantInit( &varg );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-21 23:01:31 +02:00
|
|
|
TRACE("(%p, %p, %ld, %u, %u) vt=%d\n", pvargDest, pvargSrc, lcid, wFlags, vt, V_VT(pvargSrc));
|
2002-06-21 01:07:55 +02:00
|
|
|
TRACE("Src Var:\n");
|
|
|
|
dump_Variant(pvargSrc);
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* validate our source argument.
|
|
|
|
*/
|
2001-08-21 19:03:10 +02:00
|
|
|
res = ValidateVariantType( V_VT(pvargSrc) );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* validate the vartype.
|
|
|
|
*/
|
|
|
|
if( res == S_OK )
|
|
|
|
{
|
|
|
|
res = ValidateVt( vt );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we are doing an in-place conversion make a copy of the source.
|
|
|
|
*/
|
|
|
|
if( res == S_OK && pvargDest == pvargSrc )
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantCopy( &varg, pvargSrc );
|
1998-12-10 11:00:38 +01:00
|
|
|
pvargSrc = &varg;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( res == S_OK )
|
|
|
|
{
|
|
|
|
/* free up the destination variant.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
res = VariantClear( pvargDest );
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if( res == S_OK )
|
|
|
|
{
|
2001-08-21 19:03:10 +02:00
|
|
|
if( V_VT(pvargSrc) & VT_BYREF )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
/* Convert the source variant to a "byvalue" variant.
|
|
|
|
*/
|
|
|
|
VARIANTARG Variant;
|
2003-10-03 05:36:46 +02:00
|
|
|
|
2002-12-23 03:03:10 +01:00
|
|
|
if ((V_VT(pvargSrc) & 0xf000) != VT_BYREF) {
|
|
|
|
FIXME("VT_TYPEMASK %x is unhandled.\n",V_VT(pvargSrc) & VT_TYPEMASK);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
VariantInit( &Variant );
|
|
|
|
res = VariantCopyInd( &Variant, pvargSrc );
|
1998-12-10 11:00:38 +01:00
|
|
|
if( res == S_OK )
|
|
|
|
{
|
|
|
|
res = Coerce( pvargDest, lcid, wFlags, &Variant, vt );
|
|
|
|
/* this should not fail.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
VariantClear( &Variant );
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
2002-12-23 03:03:10 +01:00
|
|
|
} else {
|
|
|
|
if (V_VT(pvargSrc) & VT_ARRAY) {
|
|
|
|
if ((V_VT(pvargSrc) & 0xf000) != VT_ARRAY) {
|
|
|
|
FIXME("VT_TYPEMASK %x is unhandled in VT_ARRAY.\n",V_VT(pvargSrc) & VT_TYPEMASK);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
V_VT(pvargDest) = VT_ARRAY | vt;
|
2003-01-03 00:11:56 +01:00
|
|
|
res = coerce_array(pvargSrc, pvargDest, lcid, wFlags, vt);
|
2002-12-23 03:03:10 +01:00
|
|
|
} else {
|
|
|
|
if ((V_VT(pvargSrc) & 0xf000)) {
|
|
|
|
FIXME("VT_TYPEMASK %x is unhandled in normal case.\n",V_VT(pvargSrc) & VT_TYPEMASK);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
/* Use the current "byvalue" source variant.
|
|
|
|
*/
|
|
|
|
res = Coerce( pvargDest, lcid, wFlags, pvargSrc, vt );
|
|
|
|
}
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* this should not fail.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
VariantClear( &varg );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-03-19 17:44:32 +01:00
|
|
|
/* set the type of the destination
|
|
|
|
*/
|
|
|
|
if ( res == S_OK )
|
2001-08-21 19:03:10 +02:00
|
|
|
V_VT(pvargDest) = vt;
|
1999-03-19 17:44:32 +01:00
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
TRACE("Dest Var:\n");
|
|
|
|
dump_Variant(pvargDest);
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromI2 [OLEAUT32.130]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromI2(short sIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", sIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( sIn < UI1_MIN || sIn > UI1_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbOut = (BYTE) sIn;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromI4 [OLEAUT32.131]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromI4(LONG lIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", lIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( lIn < UI1_MIN || lIn > UI1_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbOut = (BYTE) lIn;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromR4 [OLEAUT32.132]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromR4(FLOAT fltIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
fltIn = round( fltIn );
|
|
|
|
if( fltIn < UI1_MIN || fltIn > UI1_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbOut = (BYTE) fltIn;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromR8 [OLEAUT32.133]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromR8(double dblIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
dblIn = round( dblIn );
|
|
|
|
if( dblIn < UI1_MIN || dblIn > UI1_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbOut = (BYTE) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromDate [OLEAUT32.135]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromDate(DATE dateIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
dateIn = round( dateIn );
|
|
|
|
if( dateIn < UI1_MIN || dateIn > UI1_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbOut = (BYTE) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromBool [OLEAUT32.138]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromBool(VARIANT_BOOL boolIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pbOut = (BYTE) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromI1 [OLEAUT32.237]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarUI1FromI1(signed char cIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pbOut = cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromUI2 [OLEAUT32.238]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromUI2(USHORT uiIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( uiIn > UI1_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbOut = (BYTE) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromUI4 [OLEAUT32.239]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromUI4(ULONG ulIn, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", ulIn, pbOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( ulIn > UI1_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbOut = (BYTE) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VarUI1FromStr [OLEAUT32.136]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, BYTE* pbOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, pbOut);
|
|
|
|
return _VarUI1FromStr(strIn, lcid, dwFlags, pbOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI1FromCy [OLEAUT32.134]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to unsigned char
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
if (t > UI1_MAX || t < UI1_MIN) return DISP_E_OVERFLOW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
*pbOut = (BYTE)t;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromUI1 [OLEAUT32.48]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromUI1(BYTE bIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( 0x%08x, %p ), stub\n", bIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*psOut = (short) bIn;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromI4 [OLEAUT32.49]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromI4(LONG lIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %lx, %p ), stub\n", lIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( lIn < I2_MIN || lIn > I2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*psOut = (short) lIn;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromR4 [OLEAUT32.50]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromR4(FLOAT fltIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
fltIn = round( fltIn );
|
|
|
|
if( fltIn < I2_MIN || fltIn > I2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*psOut = (short) fltIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromR8 [OLEAUT32.51]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromR8(double dblIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
dblIn = round( dblIn );
|
|
|
|
if( dblIn < I2_MIN || dblIn > I2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*psOut = (short) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromDate [OLEAUT32.53]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromDate(DATE dateIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
dateIn = round( dateIn );
|
|
|
|
if( dateIn < I2_MIN || dateIn > I2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*psOut = (short) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromBool [OLEAUT32.56]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromBool(VARIANT_BOOL boolIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*psOut = (short) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VarI2FromI1 [OLEAUT32.205]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI2FromI1(signed char cIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*psOut = (short) cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromUI2 [OLEAUT32.206]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromUI2(USHORT uiIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( uiIn > I2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*psOut = (short) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VarI2FromUI4 [OLEAUT32.207]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromUI4(ULONG ulIn, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %lx, %p ), stub\n", ulIn, psOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( ulIn < I2_MIN || ulIn > I2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*psOut = (short) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromStr [OLEAUT32.54]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, short* psOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, psOut);
|
|
|
|
return _VarI2FromStr(strIn, lcid, dwFlags, psOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI2FromCy [OLEAUT32.52]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to signed short
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI2FromCy(CY cyIn, short* psOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
if (t > I2_MAX || t < I2_MIN) return DISP_E_OVERFLOW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
*psOut = (SHORT)t;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromUI1 [OLEAUT32.58]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromUI1(BYTE bIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %X, %p ), stub\n", bIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*plOut = (LONG) bIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromR4 [OLEAUT32.60]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromR4(FLOAT fltIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
fltIn = round( fltIn );
|
|
|
|
if( fltIn < I4_MIN || fltIn > I4_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*plOut = (LONG) fltIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromR8 [OLEAUT32.61]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromR8(double dblIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
dblIn = round( dblIn );
|
|
|
|
if( dblIn < I4_MIN || dblIn > I4_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*plOut = (LONG) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromDate [OLEAUT32.63]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromDate(DATE dateIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
dateIn = round( dateIn );
|
|
|
|
if( dateIn < I4_MIN || dateIn > I4_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*plOut = (LONG) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromBool [OLEAUT32.66]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromBool(VARIANT_BOOL boolIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*plOut = (LONG) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromI1 [OLEAUT32.209]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI4FromI1(signed char cIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*plOut = (LONG) cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromUI2 [OLEAUT32.210]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromUI2(USHORT uiIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*plOut = (LONG) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromUI4 [OLEAUT32.211]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromUI4(ULONG ulIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %lx, %p ), stub\n", ulIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
|
|
|
if( ulIn < I4_MIN || ulIn > I4_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*plOut = (LONG) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromI2 [OLEAUT32.59]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromI2(short sIn, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", sIn, plOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*plOut = (LONG) sIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromStr [OLEAUT32.64]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, LONG* plOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, plOut);
|
|
|
|
return _VarI4FromStr(strIn, lcid, dwFlags, plOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI4FromCy [OLEAUT32.62]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to signed long
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarI4FromCy(CY cyIn, LONG* plOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
if (t > I4_MAX || t < I4_MIN) return DISP_E_OVERFLOW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
*plOut = (LONG)t;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromUI1 [OLEAUT32.68]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromUI1(BYTE bIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %X, %p ), stub\n", bIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pfltOut = (FLOAT) bIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromI2 [OLEAUT32.69]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromI2(short sIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", sIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pfltOut = (FLOAT) sIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromI4 [OLEAUT32.70]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromI4(LONG lIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %lx, %p ), stub\n", lIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pfltOut = (FLOAT) lIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromR8 [OLEAUT32.71]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromR8(double dblIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
if( dblIn < -(R4_MAX) || dblIn > R4_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pfltOut = (FLOAT) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromDate [OLEAUT32.73]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromDate(DATE dateIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
if( dateIn < -(R4_MAX) || dateIn > R4_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pfltOut = (FLOAT) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromBool [OLEAUT32.76]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromBool(VARIANT_BOOL boolIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pfltOut = (FLOAT) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromI1 [OLEAUT32.213]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarR4FromI1(signed char cIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pfltOut = (FLOAT) cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromUI2 [OLEAUT32.214]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromUI2(USHORT uiIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pfltOut = (FLOAT) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromUI4 [OLEAUT32.215]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromUI4(ULONG ulIn, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", ulIn, pfltOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pfltOut = (FLOAT) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromStr [OLEAUT32.74]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, FLOAT* pfltOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, pfltOut);
|
|
|
|
return _VarR4FromStr(strIn, lcid, dwFlags, pfltOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR4FromCy [OLEAUT32.72]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to float
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR4FromCy(CY cyIn, FLOAT* pfltOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
*pfltOut = (FLOAT)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VarR8FromUI1 [OLEAUT32.78]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromUI1(BYTE bIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", bIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) bIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VarR8FromI2 [OLEAUT32.79]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromI2(short sIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", sIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) sIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VarR8FromI4 [OLEAUT32.80]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromI4(LONG lIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", lIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) lIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR8FromR4 [OLEAUT32.81]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromR4(FLOAT fltIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) fltIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR8FromDate [OLEAUT32.83]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromDate(DATE dateIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR8FromBool [OLEAUT32.86]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromBool(VARIANT_BOOL boolIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR8FromI1 [OLEAUT32.217]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarR8FromI1(signed char cIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR8FromUI2 [OLEAUT32.218]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromUI2(USHORT uiIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR8FromUI4 [OLEAUT32.219]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromUI4(ULONG ulIn, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", ulIn, pdblOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdblOut = (double) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarR8FromStr [OLEAUT32.84]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarR8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, double* pdblOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, pdblOut);
|
|
|
|
return _VarR8FromStr(strIn, lcid, dwFlags, pdblOut);
|
|
|
|
}
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* VarR8FromCy [OLEAUT32.82]
|
|
|
|
* Convert currency to double
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarR8FromCy(CY cyIn, double* pdblOut) {
|
|
|
|
*pdblOut = (double)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
|
|
|
TRACE("%lu %ld -> %f\n", cyIn.s.Hi, cyIn.s.Lo, *pdblOut);
|
|
|
|
return S_OK;
|
|
|
|
}
|
1998-12-11 15:02:16 +01:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* VarDateFromUI1 [OLEAUT32.88]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromUI1(BYTE bIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", bIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdateOut = (DATE) bIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VarDateFromI2 [OLEAUT32.89]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromI2(short sIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", sIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdateOut = (DATE) sIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromI4 [OLEAUT32.90]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromI4(LONG lIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", lIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
if( lIn < DATE_MIN || lIn > DATE_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdateOut = (DATE) lIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromR4 [OLEAUT32.91]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromR4(FLOAT fltIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
1998-12-24 17:59:17 +01:00
|
|
|
if( ceil(fltIn) < DATE_MIN || floor(fltIn) > DATE_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdateOut = (DATE) fltIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromR8 [OLEAUT32.92]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromR8(double dblIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
1998-12-24 17:59:17 +01:00
|
|
|
if( ceil(dblIn) < DATE_MIN || floor(dblIn) > DATE_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdateOut = (DATE) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromStr [OLEAUT32.94]
|
1998-12-10 11:00:38 +01:00
|
|
|
* The string representing the date is composed of two parts, a date and time.
|
|
|
|
*
|
|
|
|
* The format of the time is has follows:
|
|
|
|
* hh[:mm][:ss][AM|PM]
|
|
|
|
* Whitespace can be inserted anywhere between these tokens. A whitespace consists
|
|
|
|
* of space and/or tab characters, which are ignored.
|
|
|
|
*
|
|
|
|
* The formats for the date part are has follows:
|
2002-06-01 01:06:46 +02:00
|
|
|
* mm/[dd/][yy]yy
|
1998-12-10 11:00:38 +01:00
|
|
|
* [dd/]mm/[yy]yy
|
2002-06-01 01:06:46 +02:00
|
|
|
* [yy]yy/mm/dd
|
1998-12-10 11:00:38 +01:00
|
|
|
* January dd[,] [yy]yy
|
|
|
|
* dd January [yy]yy
|
|
|
|
* [yy]yy January dd
|
|
|
|
* Whitespace can be inserted anywhere between these tokens.
|
|
|
|
*
|
|
|
|
* The formats for the date and time string are has follows.
|
2002-06-01 01:06:46 +02:00
|
|
|
* date[whitespace][time]
|
1998-12-10 11:00:38 +01:00
|
|
|
* [time][whitespace]date
|
|
|
|
*
|
|
|
|
* These are the only characters allowed in a string representing a date and time:
|
|
|
|
* [A-Z] [a-z] [0-9] ':' '-' '/' ',' ' ' '\t'
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2000-11-01 04:11:12 +01:00
|
|
|
HRESULT ret = S_OK;
|
|
|
|
struct tm TM;
|
|
|
|
|
|
|
|
memset( &TM, 0, sizeof(TM) );
|
1998-12-24 17:59:17 +01:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %p, %lx, %lx, %p ), stub\n", strIn, lcid, dwFlags, pdateOut );
|
1998-12-24 17:59:17 +01:00
|
|
|
|
2001-08-15 19:39:24 +02:00
|
|
|
if( DateTimeStringToTm( strIn, dwFlags, &TM ) )
|
1998-12-24 17:59:17 +01:00
|
|
|
{
|
|
|
|
if( TmToDATE( &TM, pdateOut ) == FALSE )
|
|
|
|
{
|
|
|
|
ret = E_INVALIDARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = DISP_E_TYPEMISMATCH;
|
|
|
|
}
|
2002-06-21 01:07:55 +02:00
|
|
|
TRACE("Return value %f\n", *pdateOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromI1 [OLEAUT32.221]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarDateFromI1(signed char cIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdateOut = (DATE) cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromUI2 [OLEAUT32.222]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromUI2(USHORT uiIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdateOut = (DATE) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromUI4 [OLEAUT32.223]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromUI4(ULONG ulIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", ulIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
if( ulIn < DATE_MIN || ulIn > DATE_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdateOut = (DATE) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromBool [OLEAUT32.96]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromBool(VARIANT_BOOL boolIn, DATE* pdateOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, pdateOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pdateOut = (DATE) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarDateFromCy [OLEAUT32.93]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to date
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarDateFromCy(CY cyIn, DATE* pdateOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
*pdateOut = (DATE)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
1998-12-11 15:02:16 +01:00
|
|
|
|
|
|
|
if (*pdateOut > DATE_MAX || *pdateOut < DATE_MIN) return DISP_E_TYPEMISMATCH;
|
|
|
|
return S_OK;
|
|
|
|
}
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromUI1 [OLEAUT32.108]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromUI1(BYTE bVal, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %ld, %ld, %p ), stub\n", bVal, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
sprintf( pBuffer, "%d", bVal );
|
|
|
|
|
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromI2 [OLEAUT32.109]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromI2(short iVal, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %ld, %ld, %p ), stub\n", iVal, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
sprintf( pBuffer, "%d", iVal );
|
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromI4 [OLEAUT32.110]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromI4(LONG lIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %ld, %ld, %p ), stub\n", lIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
sprintf( pBuffer, "%ld", lIn );
|
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromR4 [OLEAUT32.111]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %ld, %ld, %p ), stub\n", fltIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-01-13 19:30:18 +01:00
|
|
|
sprintf( pBuffer, "%.7G", fltIn );
|
1998-12-10 11:00:38 +01:00
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromR8 [OLEAUT32.112]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromR8(double dblIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %ld, %ld, %p ), stub\n", dblIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-01-13 19:30:18 +01:00
|
|
|
sprintf( pBuffer, "%.15G", dblIn );
|
1998-12-10 11:00:38 +01:00
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* VarBstrFromCy [OLEAUT32.113]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut) {
|
2002-06-21 01:07:55 +02:00
|
|
|
HRESULT rc = S_OK;
|
|
|
|
double curVal = 0.0;
|
|
|
|
|
|
|
|
TRACE("([cyIn], %08lx, %08lx, %p), partial stub (no flags handled).\n", lcid, dwFlags, pbstrOut);
|
|
|
|
|
|
|
|
/* Firstly get the currency in a double, then put it in a buffer */
|
|
|
|
rc = VarR8FromCy(cyIn, &curVal);
|
|
|
|
if (rc == S_OK) {
|
2003-01-13 19:30:18 +01:00
|
|
|
sprintf(pBuffer, "%G", curVal);
|
2002-06-21 01:07:55 +02:00
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
}
|
|
|
|
return rc;
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromDate [OLEAUT32.114]
|
1998-12-10 11:00:38 +01:00
|
|
|
*
|
|
|
|
* The date is implemented using an 8 byte floating-point number.
|
2001-05-18 23:01:38 +02:00
|
|
|
* Days are represented by whole numbers increments starting with 0.00 as
|
1998-12-10 11:00:38 +01:00
|
|
|
* being December 30 1899, midnight.
|
|
|
|
* The hours are expressed as the fractional part of the number.
|
|
|
|
* December 30 1899 at midnight = 0.00
|
|
|
|
* January 1 1900 at midnight = 2.00
|
|
|
|
* January 4 1900 at 6 AM = 5.25
|
|
|
|
* January 4 1900 at noon = 5.50
|
|
|
|
* December 29 1899 at midnight = -1.00
|
|
|
|
* December 18 1899 at midnight = -12.00
|
|
|
|
* December 18 1899 at 6AM = -12.25
|
|
|
|
* December 18 1899 at 6PM = -12.75
|
|
|
|
* December 19 1899 at midnight = -11.00
|
|
|
|
* The tm structure is as follows:
|
|
|
|
* struct tm {
|
|
|
|
* int tm_sec; seconds after the minute - [0,59]
|
|
|
|
* int tm_min; minutes after the hour - [0,59]
|
|
|
|
* int tm_hour; hours since midnight - [0,23]
|
|
|
|
* int tm_mday; day of the month - [1,31]
|
|
|
|
* int tm_mon; months since January - [0,11]
|
1998-12-24 17:59:17 +01:00
|
|
|
* int tm_year; years
|
1998-12-10 11:00:38 +01:00
|
|
|
* int tm_wday; days since Sunday - [0,6]
|
|
|
|
* int tm_yday; days since January 1 - [0,365]
|
|
|
|
* int tm_isdst; daylight savings time flag
|
|
|
|
* };
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromDate(DATE dateIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2000-11-01 04:11:12 +01:00
|
|
|
struct tm TM;
|
|
|
|
memset( &TM, 0, sizeof(TM) );
|
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
TRACE("( %20.20f, %ld, %ld, %p ), stub\n", dateIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-08-15 19:39:24 +02:00
|
|
|
if( DateToTm( dateIn, dwFlags, &TM ) == FALSE )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1998-12-24 17:59:17 +01:00
|
|
|
return E_INVALIDARG;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
2000-02-18 20:14:29 +01:00
|
|
|
if( dwFlags & VAR_DATEVALUEONLY )
|
1998-12-10 11:00:38 +01:00
|
|
|
strftime( pBuffer, BUFFER_MAX, "%x", &TM );
|
2000-02-18 20:14:29 +01:00
|
|
|
else if( dwFlags & VAR_TIMEVALUEONLY )
|
1998-12-10 11:00:38 +01:00
|
|
|
strftime( pBuffer, BUFFER_MAX, "%X", &TM );
|
|
|
|
else
|
1998-12-24 17:59:17 +01:00
|
|
|
strftime( pBuffer, BUFFER_MAX, "%x %X", &TM );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
TRACE("result: %s\n", pBuffer);
|
1998-12-10 11:00:38 +01:00
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromBool [OLEAUT32.116]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromBool(VARIANT_BOOL boolIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %ld, %ld, %p ), stub\n", boolIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
sprintf( pBuffer, (boolIn == VARIANT_FALSE) ? "False" : "True" );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromI1 [OLEAUT32.229]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarBstrFromI1(signed char cIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %ld, %ld, %p ), stub\n", cIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
sprintf( pBuffer, "%d", cIn );
|
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromUI2 [OLEAUT32.230]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromUI2(USHORT uiIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %ld, %ld, %p ), stub\n", uiIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
sprintf( pBuffer, "%d", uiIn );
|
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBstrFromUI4 [OLEAUT32.231]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBstrFromUI4(ULONG ulIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %ld, %ld, %p ), stub\n", ulIn, lcid, dwFlags, pbstrOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
sprintf( pBuffer, "%ld", ulIn );
|
|
|
|
*pbstrOut = StringDupAtoBstr( pBuffer );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-05-16 00:58:48 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* VarBstrFromDec [OLEAUT32.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarBstrFromDec(DECIMAL* pDecIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
|
2003-05-17 20:30:03 +02:00
|
|
|
{
|
|
|
|
if(!pDecIn->u.s.sign && !pDecIn->u.s.scale &&
|
|
|
|
!pDecIn->Hi32 && !pDecIn->u1.s1.Mid32)
|
|
|
|
return VarBstrFromUI4(pDecIn->u1.s1.Lo32, lcid, dwFlags, pbstrOut);
|
|
|
|
FIXME("%c%08lx%08lx%08lx E%02x stub\n",
|
2003-05-16 00:58:48 +02:00
|
|
|
(pDecIn->u.s.sign == DECIMAL_NEG) ? '-' :
|
|
|
|
(pDecIn->u.s.sign == 0) ? '+' : '?',
|
|
|
|
pDecIn->Hi32, pDecIn->u1.s1.Mid32, pDecIn->u1.s1.Lo32,
|
|
|
|
pDecIn->u.s.scale);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromUI1 [OLEAUT32.118]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromUI1(BYTE bIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", bIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
if( bIn == 0 )
|
|
|
|
{
|
|
|
|
*pboolOut = VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pboolOut = VARIANT_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromI2 [OLEAUT32.119]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromI2(short sIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", sIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (sIn) ? VARIANT_TRUE : VARIANT_FALSE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromI4 [OLEAUT32.120]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromI4(LONG lIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", lIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (lIn) ? VARIANT_TRUE : VARIANT_FALSE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromR4 [OLEAUT32.121]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromR4(FLOAT fltIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (fltIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromR8 [OLEAUT32.122]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromR8(double dblIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (dblIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromDate [OLEAUT32.123]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromDate(DATE dateIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (dateIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromStr [OLEAUT32.125]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
static const WCHAR szTrue[] = { 'T','r','u','e','\0' };
|
|
|
|
static const WCHAR szFalse[] = { 'F','a','l','s','e','\0' };
|
1998-12-10 11:00:38 +01:00
|
|
|
HRESULT ret = S_OK;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if( strIn == NULL || strlenW( strIn ) == 0 )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
ret = DISP_E_TYPEMISMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ret == S_OK )
|
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
if( strcmpiW( (LPCWSTR)strIn, szTrue ) == 0 )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
*pboolOut = VARIANT_TRUE;
|
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
else if( strcmpiW( (LPCWSTR)strIn, szFalse ) == 0 )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
*pboolOut = VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Try converting the string to a floating point number.
|
|
|
|
*/
|
|
|
|
double dValue = 0.0;
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT res = VarR8FromStr( strIn, lcid, dwFlags, &dValue );
|
1998-12-10 11:00:38 +01:00
|
|
|
if( res != S_OK )
|
|
|
|
{
|
|
|
|
ret = DISP_E_TYPEMISMATCH;
|
|
|
|
}
|
|
|
|
else
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (dValue == 0.0) ?
|
|
|
|
VARIANT_FALSE : VARIANT_TRUE;
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromI1 [OLEAUT32.233]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarBoolFromI1(signed char cIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (cIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromUI2 [OLEAUT32.234]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromUI2(USHORT uiIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (uiIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromUI4 [OLEAUT32.235]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromUI4(ULONG ulIn, VARIANT_BOOL* pboolOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", ulIn, pboolOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
*pboolOut = (ulIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarBoolFromCy [OLEAUT32.124]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to boolean
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarBoolFromCy(CY cyIn, VARIANT_BOOL* pboolOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
if (cyIn.s.Hi || cyIn.s.Lo) *pboolOut = -1;
|
1998-12-11 15:02:16 +01:00
|
|
|
else *pboolOut = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromUI1 [OLEAUT32.244]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromUI1(BYTE bIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", bIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
/* Check range of value.
|
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
if( bIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) bIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromI2 [OLEAUT32.245]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromI2(short uiIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if( uiIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromI4 [OLEAUT32.246]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromI4(LONG lIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", lIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if( lIn < I1_MIN || lIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) lIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromR4 [OLEAUT32.247]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromR4(FLOAT fltIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
fltIn = round( fltIn );
|
2003-10-03 05:36:46 +02:00
|
|
|
if( fltIn < I1_MIN || fltIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) fltIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromR8 [OLEAUT32.248]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromR8(double dblIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
dblIn = round( dblIn );
|
2003-10-03 05:36:46 +02:00
|
|
|
if( dblIn < I1_MIN || dblIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromDate [OLEAUT32.249]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromDate(DATE dateIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
dateIn = round( dateIn );
|
2003-10-03 05:36:46 +02:00
|
|
|
if( dateIn < I1_MIN || dateIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromStr [OLEAUT32.251]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, pcOut);
|
|
|
|
return _VarI1FromStr(strIn, lcid, dwFlags, pcOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromBool [OLEAUT32.253]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromBool(VARIANT_BOOL boolIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pcOut = (CHAR) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromUI2 [OLEAUT32.254]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromUI2(USHORT uiIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if( uiIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromUI4 [OLEAUT32.255]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromUI4(ULONG ulIn, signed char *pcOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", ulIn, pcOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if( ulIn > I1_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcOut = (CHAR) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarI1FromCy [OLEAUT32.250]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to signed char
|
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarI1FromCy(CY cyIn, signed char *pcOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if (t > I1_MAX || t < I1_MIN) return DISP_E_OVERFLOW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
*pcOut = (CHAR)t;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromUI1 [OLEAUT32.257]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromUI1(BYTE bIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", bIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*puiOut = (USHORT) bIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromI2 [OLEAUT32.258]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromI2(short uiIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
if( uiIn < UI2_MIN )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*puiOut = (USHORT) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromI4 [OLEAUT32.259]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromI4(LONG lIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", lIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
if( lIn < UI2_MIN || lIn > UI2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*puiOut = (USHORT) lIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromR4 [OLEAUT32.260]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromR4(FLOAT fltIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", fltIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
fltIn = round( fltIn );
|
|
|
|
if( fltIn < UI2_MIN || fltIn > UI2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*puiOut = (USHORT) fltIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromR8 [OLEAUT32.261]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
dblIn = round( dblIn );
|
|
|
|
if( dblIn < UI2_MIN || dblIn > UI2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*puiOut = (USHORT) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromDate [OLEAUT32.262]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromDate(DATE dateIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
dateIn = round( dateIn );
|
|
|
|
if( dateIn < UI2_MIN || dateIn > UI2_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*puiOut = (USHORT) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromStr [OLEAUT32.264]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, puiOut);
|
|
|
|
return _VarUI2FromStr(strIn, lcid, dwFlags, puiOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromBool [OLEAUT32.266]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromBool(VARIANT_BOOL boolIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*puiOut = (USHORT) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromI1 [OLEAUT32.267]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarUI2FromI1(signed char cIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*puiOut = (USHORT) cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromUI4 [OLEAUT32.268]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromUI4(ULONG ulIn, USHORT* puiOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", ulIn, puiOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2002-06-22 00:25:17 +02:00
|
|
|
if( ulIn > UI2_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*puiOut = (USHORT) ulIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromStr [OLEAUT32.277]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
2003-10-03 05:36:46 +02:00
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, pulOut);
|
|
|
|
return _VarUI4FromStr(strIn, lcid, dwFlags, pulOut);
|
1998-12-10 11:00:38 +01:00
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI2FromCy [OLEAUT32.263]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to unsigned short
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
if (t > UI2_MAX || t < UI2_MIN) return DISP_E_OVERFLOW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
*pusOut = (USHORT)t;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-10 11:00:38 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromUI1 [OLEAUT32.270]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromUI1(BYTE bIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", bIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pulOut = (USHORT) bIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromI2 [OLEAUT32.271]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromI2(short uiIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
if( uiIn < UI4_MIN )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pulOut = (ULONG) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromI4 [OLEAUT32.272]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromI4(LONG lIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %ld, %p ), stub\n", lIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2002-06-22 00:25:17 +02:00
|
|
|
if( lIn < 0 )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pulOut = (ULONG) lIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromR4 [OLEAUT32.273]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromR4(FLOAT fltIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
fltIn = round( fltIn );
|
|
|
|
if( fltIn < UI4_MIN || fltIn > UI4_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pulOut = (ULONG) fltIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromR8 [OLEAUT32.274]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dblIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
dblIn = round( dblIn );
|
1998-12-10 11:00:38 +01:00
|
|
|
if( dblIn < UI4_MIN || dblIn > UI4_MAX )
|
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
2001-10-02 20:28:31 +02:00
|
|
|
}
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pulOut = (ULONG) dblIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromDate [OLEAUT32.275]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromDate(DATE dateIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %f, %p ), stub\n", dateIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
dateIn = round( dateIn );
|
|
|
|
if( dateIn < UI4_MIN || dateIn > UI4_MAX )
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pulOut = (ULONG) dateIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromBool [OLEAUT32.279]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromBool(VARIANT_BOOL boolIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", boolIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pulOut = (ULONG) boolIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromI1 [OLEAUT32.280]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
2003-07-19 00:52:58 +02:00
|
|
|
HRESULT WINAPI VarUI4FromI1(signed char cIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %c, %p ), stub\n", cIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pulOut = (ULONG) cIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromUI2 [OLEAUT32.281]
|
1998-12-10 11:00:38 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromUI2(USHORT uiIn, ULONG* pulOut)
|
1998-12-10 11:00:38 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("( %d, %p ), stub\n", uiIn, pulOut );
|
1998-12-10 11:00:38 +01:00
|
|
|
|
|
|
|
*pulOut = (ULONG) uiIn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarUI4FromCy [OLEAUT32.276]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert currency to unsigned long
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG* pulOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
if (t > UI4_MAX || t < UI4_MIN) return DISP_E_OVERFLOW;
|
|
|
|
|
|
|
|
*pulOut = (ULONG)t;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromUI1 [OLEAUT32.98]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert unsigned char to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY* pcyOut) {
|
2001-10-02 20:28:31 +02:00
|
|
|
pcyOut->s.Hi = 0;
|
|
|
|
pcyOut->s.Lo = ((ULONG)bIn) * 10000;
|
|
|
|
|
|
|
|
return S_OK;
|
1998-12-11 15:02:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromI2 [OLEAUT32.99]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert signed short to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromI2(short sIn, CY* pcyOut) {
|
2001-10-02 20:28:31 +02:00
|
|
|
if (sIn < 0) pcyOut->s.Hi = -1;
|
|
|
|
else pcyOut->s.Hi = 0;
|
|
|
|
pcyOut->s.Lo = ((ULONG)sIn) * 10000;
|
|
|
|
|
|
|
|
return S_OK;
|
1998-12-11 15:02:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromI4 [OLEAUT32.100]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert signed long to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromI4(LONG lIn, CY* pcyOut) {
|
1998-12-11 15:02:16 +01:00
|
|
|
double t = (double)lIn * (double)10000;
|
1999-09-19 16:20:33 +02:00
|
|
|
pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
|
|
|
|
pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
|
|
|
|
if (lIn < 0) pcyOut->s.Hi--;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromR4 [OLEAUT32.101]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert float to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromR4(FLOAT fltIn, CY* pcyOut) {
|
1998-12-11 15:02:16 +01:00
|
|
|
double t = round((double)fltIn * (double)10000);
|
1999-09-19 16:20:33 +02:00
|
|
|
pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
|
|
|
|
pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
|
|
|
|
if (fltIn < 0) pcyOut->s.Hi--;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromR8 [OLEAUT32.102]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert double to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromR8(double dblIn, CY* pcyOut) {
|
1998-12-11 15:02:16 +01:00
|
|
|
double t = round(dblIn * (double)10000);
|
1999-09-19 16:20:33 +02:00
|
|
|
pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
|
|
|
|
pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
|
|
|
|
if (dblIn < 0) pcyOut->s.Hi--;
|
1998-12-11 15:02:16 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromDate [OLEAUT32.103]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert date to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromDate(DATE dateIn, CY* pcyOut) {
|
1998-12-11 15:02:16 +01:00
|
|
|
double t = round((double)dateIn * (double)10000);
|
1999-09-19 16:20:33 +02:00
|
|
|
pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
|
|
|
|
pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
|
|
|
|
if (dateIn < 0) pcyOut->s.Hi--;
|
1998-12-11 15:02:16 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/**********************************************************************
|
2000-03-24 21:46:04 +01:00
|
|
|
* VarCyFromStr [OLEAUT32.104]
|
2003-06-18 05:30:39 +02:00
|
|
|
* FIXME: Never tested with decimal separator other than '.'
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pcyOut)
|
|
|
|
{
|
|
|
|
TRACE("(%s, 0x%08lx, 0x%08lx, %p)\n", debugstr_w(strIn), lcid, dwFlags, pcyOut);
|
|
|
|
return _VarCyFromStr(strIn, lcid, dwFlags, pcyOut);
|
1999-03-28 15:15:40 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromBool [OLEAUT32.106]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert boolean to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromBool(VARIANT_BOOL boolIn, CY* pcyOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
if (boolIn < 0) pcyOut->s.Hi = -1;
|
|
|
|
else pcyOut->s.Hi = 0;
|
|
|
|
pcyOut->s.Lo = (ULONG)boolIn * (ULONG)10000;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromI1 [OLEAUT32.225]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert signed char to currency
|
|
|
|
*/
|
2001-01-22 20:23:54 +01:00
|
|
|
HRESULT WINAPI VarCyFromI1(signed char cIn, CY* pcyOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
if (cIn < 0) pcyOut->s.Hi = -1;
|
|
|
|
else pcyOut->s.Hi = 0;
|
|
|
|
pcyOut->s.Lo = (ULONG)cIn * (ULONG)10000;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromUI2 [OLEAUT32.226]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert unsigned short to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromUI2(USHORT usIn, CY* pcyOut) {
|
1999-09-19 16:20:33 +02:00
|
|
|
pcyOut->s.Hi = 0;
|
|
|
|
pcyOut->s.Lo = (ULONG)usIn * (ULONG)10000;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* VarCyFromUI4 [OLEAUT32.227]
|
1998-12-11 15:02:16 +01:00
|
|
|
* Convert unsigned long to currency
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI VarCyFromUI4(ULONG ulIn, CY* pcyOut) {
|
1998-12-11 15:02:16 +01:00
|
|
|
double t = (double)ulIn * (double)10000;
|
1999-09-19 16:20:33 +02:00
|
|
|
pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
|
|
|
|
pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-11 15:02:16 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
1999-03-12 18:02:32 +01:00
|
|
|
|
2003-05-15 06:15:25 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* VarDecFromStr [OLEAUT32.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarDecFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags,
|
|
|
|
DECIMAL* pdecOut)
|
|
|
|
{ WCHAR *p=strIn;
|
|
|
|
ULONGLONG t;
|
|
|
|
ULONG cy;
|
2003-05-16 22:13:50 +02:00
|
|
|
|
2003-05-15 06:15:25 +02:00
|
|
|
DECIMAL_SETZERO(pdecOut);
|
2003-05-16 22:13:50 +02:00
|
|
|
|
2003-05-15 06:15:25 +02:00
|
|
|
if(*p == (WCHAR)'-')pdecOut->u.s.sign= DECIMAL_NEG;
|
|
|
|
if((*p == (WCHAR)'-') || (*p == (WCHAR)'+')) p++;
|
|
|
|
for(;*p != (WCHAR)0; p++) {
|
|
|
|
if((*p < (WCHAR)'0')||(*p > (WCHAR)'9')) goto error ;
|
|
|
|
t = (ULONGLONG)pdecOut->u1.s1.Lo32 *(ULONGLONG)10
|
|
|
|
+ (ULONGLONG)(*p -(WCHAR)'0');
|
|
|
|
cy = (ULONG)(t >> 32);
|
|
|
|
pdecOut->u1.s1.Lo32 = (ULONG)(t & (ULONGLONG)UI4_MAX);
|
|
|
|
t = (ULONGLONG)pdecOut->u1.s1.Mid32 * (ULONGLONG)10
|
|
|
|
+ (ULONGLONG)cy;
|
|
|
|
cy = (ULONG)(t >> 32);
|
|
|
|
pdecOut->u1.s1.Mid32 = (ULONG)(t & (ULONGLONG)UI4_MAX);
|
|
|
|
t = (ULONGLONG)pdecOut->Hi32 * (ULONGLONG)10
|
|
|
|
+ (ULONGLONG)cy;
|
|
|
|
cy = (ULONG)(t >> 32);
|
|
|
|
pdecOut->Hi32 = (ULONG)(t & (ULONGLONG)UI4_MAX);
|
|
|
|
if(cy) goto overflow ;
|
|
|
|
}
|
2003-05-16 22:13:50 +02:00
|
|
|
TRACE("%s -> sign %02x,hi %08lx,mid %08lx, lo%08lx, scale %08x\n",
|
2003-05-15 06:15:25 +02:00
|
|
|
debugstr_w(strIn),
|
|
|
|
pdecOut->u.s.sign, pdecOut->Hi32, pdecOut->u1.s1.Mid32,
|
|
|
|
pdecOut->u1.s1.Lo32, pdecOut->u.s.scale);
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
overflow:
|
|
|
|
/* like NT4 SP5 */
|
|
|
|
pdecOut->Hi32 = pdecOut->u1.s1.Mid32 = pdecOut->u1.s1.Lo32 = 0xffffffff;
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
|
|
|
|
error:
|
|
|
|
ERR("%s: unknown char at pos %d\n",
|
|
|
|
debugstr_w(strIn), p - strIn + 1);
|
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
}
|
1999-03-12 18:02:32 +01:00
|
|
|
|
2003-11-14 22:01:36 +01:00
|
|
|
/* Date Conversions */
|
|
|
|
|
|
|
|
#define IsLeapYear(y) (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
|
|
|
|
|
|
|
|
/* Convert a VT_DATE value to a Julian Date */
|
|
|
|
static inline int VARIANT_JulianFromDate(int dateIn)
|
|
|
|
{
|
|
|
|
int julianDays = dateIn;
|
|
|
|
|
|
|
|
julianDays -= DATE_MIN; /* Convert to + days from 1 Jan 100 AD */
|
|
|
|
julianDays += 1757585; /* Convert to + days from 23 Nov 4713 BC (Julian) */
|
|
|
|
return julianDays;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a Julian Date to a VT_DATE value */
|
|
|
|
static inline int VARIANT_DateFromJulian(int dateIn)
|
|
|
|
{
|
|
|
|
int julianDays = dateIn;
|
|
|
|
|
|
|
|
julianDays -= 1757585; /* Convert to + days from 1 Jan 100 AD */
|
|
|
|
julianDays += DATE_MIN; /* Convert to +/- days from 1 Jan 1899 AD */
|
|
|
|
return julianDays;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a Julian date to Day/Month/Year - from PostgreSQL */
|
|
|
|
static inline void VARIANT_DMYFromJulian(int jd, USHORT *year, USHORT *month, USHORT *day)
|
|
|
|
{
|
|
|
|
int j, i, l, n;
|
|
|
|
|
|
|
|
l = jd + 68569;
|
|
|
|
n = l * 4 / 146097;
|
|
|
|
l -= (n * 146097 + 3) / 4;
|
|
|
|
i = (4000 * (l + 1)) / 1461001;
|
|
|
|
l += 31 - (i * 1461) / 4;
|
|
|
|
j = (l * 80) / 2447;
|
|
|
|
*day = l - (j * 2447) / 80;
|
|
|
|
l = j / 11;
|
|
|
|
*month = (j + 2) - (12 * l);
|
|
|
|
*year = 100 * (n - 49) + i + l;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert Day/Month/Year to a Julian date - from PostgreSQL */
|
|
|
|
static inline double VARIANT_JulianFromDMY(USHORT year, USHORT month, USHORT day)
|
|
|
|
{
|
|
|
|
int m12 = (month - 14) / 12;
|
|
|
|
|
|
|
|
return ((1461 * (year + 4800 + m12)) / 4 + (367 * (month - 2 - 12 * m12)) / 12 -
|
|
|
|
(3 * ((year + 4900 + m12) / 100)) / 4 + day - 32075);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Macros for accessing DOS format date/time fields */
|
|
|
|
#define DOS_YEAR(x) (1980 + (x >> 9))
|
|
|
|
#define DOS_MONTH(x) ((x >> 5) & 0xf)
|
|
|
|
#define DOS_DAY(x) (x & 0x1f)
|
|
|
|
#define DOS_HOUR(x) (x >> 11)
|
|
|
|
#define DOS_MINUTE(x) ((x >> 5) & 0x3f)
|
|
|
|
#define DOS_SECOND(x) ((x & 0x1f) << 1)
|
|
|
|
/* Create a DOS format date/time */
|
|
|
|
#define DOS_DATE(d,m,y) (d | (m << 5) | ((y-1980) << 9))
|
|
|
|
#define DOS_TIME(h,m,s) ((s >> 1) | (m << 5) | (h << 11))
|
|
|
|
|
|
|
|
/* Roll a date forwards or backwards to correct it */
|
|
|
|
static HRESULT VARIANT_RollUdate(UDATE *lpUd)
|
|
|
|
{
|
|
|
|
static const BYTE days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
|
|
|
|
|
|
|
TRACE("Raw date: %d/%d/%d %d:%d:%d\n", lpUd->st.wDay, lpUd->st.wMonth,
|
|
|
|
lpUd->st.wYear, lpUd->st.wHour, lpUd->st.wMinute, lpUd->st.wSecond);
|
|
|
|
|
|
|
|
/* Years < 100 are treated as 1900 + year */
|
|
|
|
if (lpUd->st.wYear < 100)
|
|
|
|
lpUd->st.wYear += 1900;
|
|
|
|
|
|
|
|
if (!lpUd->st.wMonth)
|
|
|
|
{
|
|
|
|
/* Roll back to December of the previous year */
|
|
|
|
lpUd->st.wMonth = 12;
|
|
|
|
lpUd->st.wYear--;
|
|
|
|
}
|
|
|
|
else while (lpUd->st.wMonth > 12)
|
|
|
|
{
|
|
|
|
/* Roll forward the correct number of months */
|
|
|
|
lpUd->st.wYear++;
|
|
|
|
lpUd->st.wMonth -= 12;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpUd->st.wYear > 9999 || lpUd->st.wHour > 23 ||
|
|
|
|
lpUd->st.wMinute > 59 || lpUd->st.wSecond > 59)
|
|
|
|
return E_INVALIDARG; /* Invalid values */
|
|
|
|
|
|
|
|
if (!lpUd->st.wDay)
|
|
|
|
{
|
|
|
|
/* Roll back the date one day */
|
|
|
|
if (lpUd->st.wMonth == 1)
|
|
|
|
{
|
|
|
|
/* Roll back to December 31 of the previous year */
|
|
|
|
lpUd->st.wDay = 31;
|
|
|
|
lpUd->st.wMonth = 12;
|
|
|
|
lpUd->st.wYear--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpUd->st.wMonth--; /* Previous month */
|
|
|
|
if (lpUd->st.wMonth == 2 && IsLeapYear(lpUd->st.wYear))
|
|
|
|
lpUd->st.wDay = 29; /* Februaury has 29 days on leap years */
|
|
|
|
else
|
|
|
|
lpUd->st.wDay = days[lpUd->st.wMonth]; /* Last day of the month */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lpUd->st.wDay > 28)
|
|
|
|
{
|
|
|
|
int rollForward = 0;
|
|
|
|
|
|
|
|
/* Possibly need to roll the date forward */
|
|
|
|
if (lpUd->st.wMonth == 2 && IsLeapYear(lpUd->st.wYear))
|
|
|
|
rollForward = lpUd->st.wDay - 29; /* Februaury has 29 days on leap years */
|
|
|
|
else
|
|
|
|
rollForward = lpUd->st.wDay - days[lpUd->st.wMonth];
|
|
|
|
|
|
|
|
if (rollForward > 0)
|
|
|
|
{
|
|
|
|
lpUd->st.wDay = rollForward;
|
|
|
|
lpUd->st.wMonth++;
|
|
|
|
if (lpUd->st.wMonth > 12)
|
|
|
|
{
|
|
|
|
lpUd->st.wMonth = 1; /* Roll forward into January of the next year */
|
|
|
|
lpUd->st.wYear++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("Rolled date: %d/%d/%d %d:%d:%d\n", lpUd->st.wDay, lpUd->st.wMonth,
|
|
|
|
lpUd->st.wYear, lpUd->st.wHour, lpUd->st.wMinute, lpUd->st.wSecond);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-12 18:02:32 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* DosDateTimeToVariantTime [OLEAUT32.14]
|
2003-11-14 22:01:36 +01:00
|
|
|
*
|
|
|
|
* Convert a Dos format date and time into variant VT_DATE format.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* wDosDate [I] Dos format date
|
|
|
|
* wDosTime [I] Dos format time
|
|
|
|
* pDateOut [O] Destination for VT_DATE format
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. pDateOut contains the converted time.
|
|
|
|
* Failure: FALSE, if wDosDate or wDosTime are invalid (see notes).
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* - Dos format dates can only hold dates from 1-Jan-1980 to 31-Dec-2099.
|
|
|
|
* - Dos format times are accurate to only 2 second precision.
|
|
|
|
* - The format of a Dos Date is:
|
|
|
|
*| Bits Values Meaning
|
|
|
|
*| ---- ------ -------
|
|
|
|
*| 0-4 1-31 Day of the week. 0 rolls back one day. A value greater than
|
|
|
|
*| the days in the month rolls forward the extra days.
|
|
|
|
*| 5-8 1-12 Month of the year. 0 rolls back to December of the previous
|
|
|
|
*| year. 13-15 are invalid.
|
|
|
|
*| 9-15 0-119 Year based from 1980 (Max 2099). 120-127 are invalid.
|
|
|
|
* - The format of a Dos Time is:
|
|
|
|
*| Bits Values Meaning
|
|
|
|
*| ---- ------ -------
|
|
|
|
*| 0-4 0-29 Seconds/2. 30 and 31 are invalid.
|
|
|
|
*| 5-10 0-59 Minutes. 60-63 are invalid.
|
|
|
|
*| 11-15 0-23 Hours (24 hour clock). 24-32 are invalid.
|
1999-03-12 18:02:32 +01:00
|
|
|
*/
|
|
|
|
INT WINAPI DosDateTimeToVariantTime(USHORT wDosDate, USHORT wDosTime,
|
2003-11-14 22:01:36 +01:00
|
|
|
double *pDateOut)
|
|
|
|
{
|
|
|
|
UDATE ud;
|
|
|
|
|
|
|
|
TRACE("(0x%x(%d/%d/%d),0x%x(%d:%d:%d),%p)\n",
|
|
|
|
wDosDate, DOS_YEAR(wDosDate), DOS_MONTH(wDosDate), DOS_DAY(wDosDate),
|
|
|
|
wDosTime, DOS_HOUR(wDosTime), DOS_MINUTE(wDosTime), DOS_SECOND(wDosTime),
|
|
|
|
pDateOut);
|
|
|
|
|
|
|
|
ud.st.wYear = DOS_YEAR(wDosDate);
|
|
|
|
ud.st.wMonth = DOS_MONTH(wDosDate);
|
|
|
|
if (ud.st.wYear > 2099 || ud.st.wMonth > 12)
|
|
|
|
return FALSE;
|
|
|
|
ud.st.wDay = DOS_DAY(wDosDate);
|
|
|
|
ud.st.wHour = DOS_HOUR(wDosTime);
|
|
|
|
ud.st.wMinute = DOS_MINUTE(wDosTime);
|
|
|
|
ud.st.wSecond = DOS_SECOND(wDosTime);
|
|
|
|
ud.st.wDayOfWeek = ud.st.wMilliseconds = 0;
|
|
|
|
|
|
|
|
return !VarDateFromUdate(&ud, 0, pDateOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* VariantTimeToDosDateTime [OLEAUT32.13]
|
|
|
|
*
|
|
|
|
* Convert a variant format date into a Dos format date and time.
|
|
|
|
*
|
|
|
|
* dateIn [I] VT_DATE time format
|
|
|
|
* pwDosDate [O] Destination for Dos format date
|
|
|
|
* pwDosTime [O] Destination for Dos format time
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. pwDosDate and pwDosTime contains the converted values.
|
|
|
|
* Failure: FALSE, if dateIn cannot be represented in Dos format.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See DosDateTimeToVariantTime() for Dos format details and bugs.
|
|
|
|
*/
|
|
|
|
INT WINAPI VariantTimeToDosDateTime(double dateIn, USHORT *pwDosDate, USHORT *pwDosTime)
|
|
|
|
{
|
|
|
|
UDATE ud;
|
|
|
|
|
|
|
|
TRACE("(%g,%p,%p)\n", dateIn, pwDosDate, pwDosTime);
|
|
|
|
|
|
|
|
if (FAILED(VarUdateFromDate(dateIn, 0, &ud)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (ud.st.wYear < 1980 || ud.st.wYear > 2099)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*pwDosDate = DOS_DATE(ud.st.wDay, ud.st.wMonth, ud.st.wYear);
|
|
|
|
*pwDosTime = DOS_TIME(ud.st.wHour, ud.st.wMinute, ud.st.wSecond);
|
|
|
|
|
|
|
|
TRACE("Returning 0x%x(%d/%d/%d), 0x%x(%d:%d:%d)\n",
|
|
|
|
*pwDosDate, DOS_YEAR(*pwDosDate), DOS_MONTH(*pwDosDate), DOS_DAY(*pwDosDate),
|
|
|
|
*pwDosTime, DOS_HOUR(*pwDosTime), DOS_MINUTE(*pwDosTime), DOS_SECOND(*pwDosTime));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SystemTimeToVariantTime [OLEAUT32.184]
|
|
|
|
*
|
|
|
|
* Convert a System format date and time into variant VT_DATE format.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpSt [I] System format date and time
|
|
|
|
* pDateOut [O] Destination for VT_DATE format date
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. *pDateOut contains the converted value.
|
|
|
|
* Failure: FALSE, if lpSt cannot be represented in VT_DATE format.
|
|
|
|
*/
|
|
|
|
INT WINAPI SystemTimeToVariantTime(LPSYSTEMTIME lpSt, double *pDateOut)
|
|
|
|
{
|
|
|
|
UDATE ud;
|
|
|
|
|
|
|
|
TRACE("(%p->%d/%d/%d %d:%d:%d,%p)\n", lpSt, lpSt->wDay, lpSt->wMonth,
|
|
|
|
lpSt->wYear, lpSt->wHour, lpSt->wMinute, lpSt->wSecond, pDateOut);
|
|
|
|
|
|
|
|
if (lpSt->wMonth > 12)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memcpy(&ud.st, lpSt, sizeof(ud.st));
|
|
|
|
return !VarDateFromUdate(&ud, 0, pDateOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VariantTimeToSystemTime [OLEAUT32.185]
|
|
|
|
*
|
|
|
|
* Convert a variant VT_DATE into a System format date and time.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* datein [I] Variant VT_DATE format date
|
|
|
|
* lpSt [O] Destination for System format date and time
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. *lpSt contains the converted value.
|
|
|
|
* Failure: FALSE, if dateIn is too large or small.
|
|
|
|
*/
|
|
|
|
INT WINAPI VariantTimeToSystemTime(double dateIn, LPSYSTEMTIME lpSt)
|
|
|
|
{
|
|
|
|
UDATE ud;
|
|
|
|
|
|
|
|
TRACE("(%g,%p)\n", dateIn, lpSt);
|
|
|
|
|
|
|
|
if (FAILED(VarUdateFromDate(dateIn, 0, &ud)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memcpy(lpSt, &ud.st, sizeof(ud.st));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VarDateFromUdate [OLEAUT32.330]
|
|
|
|
*
|
|
|
|
* Convert an unpacked format date and time to a variant VT_DATE.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pUdateIn [I] Unpacked format date and time to convert
|
|
|
|
* dwFlags [I] Flags controlling the conversion (VAR_ flags from "oleauto.h")
|
|
|
|
* pDateOut [O] Destination for variant VT_DATE.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. *pDateOut contains the converted value.
|
|
|
|
* Failure: E_INVALIDARG, if pUdateIn cannot be represented in VT_DATE format.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarDateFromUdate(UDATE *pUdateIn, ULONG dwFlags, DATE *pDateOut)
|
|
|
|
{
|
|
|
|
UDATE ud;
|
|
|
|
double dateVal;
|
|
|
|
|
|
|
|
TRACE("(%p->%d/%d/%d %d:%d:%d:%d %d %d,0x%08lx,%p)\n", pUdateIn,
|
|
|
|
pUdateIn->st.wMonth, pUdateIn->st.wDay, pUdateIn->st.wYear,
|
|
|
|
pUdateIn->st.wHour, pUdateIn->st.wMinute, pUdateIn->st.wSecond,
|
|
|
|
pUdateIn->st.wMilliseconds, pUdateIn->st.wDayOfWeek,
|
|
|
|
pUdateIn->wDayOfYear, dwFlags, pDateOut);
|
|
|
|
|
|
|
|
memcpy(&ud, pUdateIn, sizeof(ud));
|
|
|
|
|
|
|
|
if (dwFlags & VAR_VALIDDATE)
|
|
|
|
WARN("Ignoring VAR_VALIDDATE\n");
|
|
|
|
|
|
|
|
if (FAILED(VARIANT_RollUdate(&ud)))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* Date */
|
|
|
|
dateVal = VARIANT_DateFromJulian(VARIANT_JulianFromDMY(ud.st.wYear, ud.st.wMonth, ud.st.wDay));
|
|
|
|
|
|
|
|
/* Time */
|
|
|
|
dateVal += ud.st.wHour / 24.0;
|
|
|
|
dateVal += ud.st.wMinute / 1440.0;
|
|
|
|
dateVal += ud.st.wSecond / 86400.0;
|
|
|
|
dateVal += ud.st.wMilliseconds / 86400000.0;
|
|
|
|
|
|
|
|
TRACE("Returning %g\n", dateVal);
|
|
|
|
*pDateOut = dateVal;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VarUdateFromDate [OLEAUT32.331]
|
|
|
|
*
|
|
|
|
* Convert a variant VT_DATE into an unpacked format date and time.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* datein [I] Variant VT_DATE format date
|
|
|
|
* dwFlags [I] Flags controlling the conversion (VAR_ flags from "oleauto.h")
|
2003-11-25 02:49:31 +01:00
|
|
|
* lpUdate [O] Destination for unpacked format date and time
|
2003-11-14 22:01:36 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. *lpUdate contains the converted value.
|
|
|
|
* Failure: E_INVALIDARG, if dateIn is too large or small.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarUdateFromDate(DATE dateIn, ULONG dwFlags, UDATE *lpUdate)
|
1999-03-12 18:02:32 +01:00
|
|
|
{
|
2003-11-14 22:01:36 +01:00
|
|
|
/* Cumulative totals of days per month */
|
|
|
|
static const USHORT cumulativeDays[] =
|
|
|
|
{
|
|
|
|
0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
|
|
|
|
};
|
|
|
|
double datePart, timePart;
|
|
|
|
int julianDays;
|
1999-03-12 18:02:32 +01:00
|
|
|
|
2003-11-14 22:01:36 +01:00
|
|
|
TRACE("(%g,0x%08lx,%p)\n", dateIn, dwFlags, lpUdate);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-11-14 22:01:36 +01:00
|
|
|
if (dateIn <= (DATE_MIN - 1.0) || dateIn >= (DATE_MAX + 1.0))
|
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-11-14 22:01:36 +01:00
|
|
|
datePart = dateIn < 0.0 ? ceil(dateIn) : floor(dateIn);
|
|
|
|
/* Compensate for int truncation (always downwards) */
|
|
|
|
timePart = dateIn - datePart + 0.00000000001;
|
|
|
|
if (timePart >= 1.0)
|
|
|
|
timePart -= 0.00000000001;
|
|
|
|
|
|
|
|
/* Date */
|
|
|
|
julianDays = VARIANT_JulianFromDate(dateIn);
|
|
|
|
VARIANT_DMYFromJulian(julianDays, &lpUdate->st.wYear, &lpUdate->st.wMonth,
|
|
|
|
&lpUdate->st.wDay);
|
|
|
|
|
|
|
|
datePart = (datePart + 1.5) / 7.0;
|
|
|
|
lpUdate->st.wDayOfWeek = (datePart - floor(datePart)) * 7;
|
|
|
|
if (lpUdate->st.wDayOfWeek == 0)
|
|
|
|
lpUdate->st.wDayOfWeek = 5;
|
|
|
|
else if (lpUdate->st.wDayOfWeek == 1)
|
|
|
|
lpUdate->st.wDayOfWeek = 6;
|
|
|
|
else
|
|
|
|
lpUdate->st.wDayOfWeek -= 2;
|
1999-03-12 18:02:32 +01:00
|
|
|
|
2003-11-14 22:01:36 +01:00
|
|
|
if (lpUdate->st.wMonth > 2 && IsLeapYear(lpUdate->st.wYear))
|
|
|
|
lpUdate->wDayOfYear = 1; /* After February, in a leap year */
|
|
|
|
else
|
|
|
|
lpUdate->wDayOfYear = 0;
|
|
|
|
|
|
|
|
lpUdate->wDayOfYear += cumulativeDays[lpUdate->st.wMonth];
|
|
|
|
lpUdate->wDayOfYear += lpUdate->st.wDay;
|
|
|
|
|
|
|
|
/* Time */
|
|
|
|
timePart *= 24.0;
|
|
|
|
lpUdate->st.wHour = timePart;
|
|
|
|
timePart -= lpUdate->st.wHour;
|
|
|
|
timePart *= 60.0;
|
|
|
|
lpUdate->st.wMinute = timePart;
|
|
|
|
timePart -= lpUdate->st.wMinute;
|
|
|
|
timePart *= 60.0;
|
|
|
|
lpUdate->st.wSecond = timePart;
|
|
|
|
timePart -= lpUdate->st.wSecond;
|
|
|
|
lpUdate->st.wMilliseconds = 0;
|
|
|
|
if (timePart > 0.0005)
|
|
|
|
{
|
|
|
|
/* Round the milliseconds, adjusting the time/date forward if needed */
|
|
|
|
if (lpUdate->st.wSecond < 59)
|
|
|
|
lpUdate->st.wSecond++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpUdate->st.wSecond = 0;
|
|
|
|
if (lpUdate->st.wMinute < 59)
|
|
|
|
lpUdate->st.wMinute++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpUdate->st.wMinute = 0;
|
|
|
|
if (lpUdate->st.wHour < 23)
|
|
|
|
lpUdate->st.wHour++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpUdate->st.wHour = 0;
|
|
|
|
/* Roll over a whole day */
|
|
|
|
if (++lpUdate->st.wDay > 28)
|
|
|
|
VARIANT_RollUdate(lpUdate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return S_OK;
|
1999-03-12 18:02:32 +01:00
|
|
|
}
|
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
#define GET_NUMBER_TEXT(fld,name) \
|
|
|
|
buff[0] = 0; \
|
|
|
|
if (!GetLocaleInfoW(lcid, lctype|fld, buff, sizeof(WCHAR) * 2)) \
|
|
|
|
WARN("buffer too small for " #fld "\n"); \
|
|
|
|
else \
|
|
|
|
if (buff[0]) lpChars->name = buff[0]; \
|
|
|
|
TRACE("lcid 0x%lx, " #name "=%d '%c'\n", lcid, lpChars->name, lpChars->name)
|
|
|
|
|
|
|
|
/* Get the valid number characters for an lcid */
|
|
|
|
void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID lcid, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
static const VARIANT_NUMBER_CHARS defaultChars = { '-','+','.',',','$',0,'.',',' };
|
|
|
|
LCTYPE lctype = 0;
|
|
|
|
WCHAR buff[4];
|
|
|
|
|
|
|
|
if (dwFlags & VARIANT_NOUSEROVERRIDE)
|
|
|
|
lctype |= LOCALE_NOUSEROVERRIDE;
|
|
|
|
|
|
|
|
memcpy(lpChars, &defaultChars, sizeof(defaultChars));
|
|
|
|
GET_NUMBER_TEXT(LOCALE_SNEGATIVESIGN, cNegativeSymbol);
|
|
|
|
GET_NUMBER_TEXT(LOCALE_SPOSITIVESIGN, cPositiveSymbol);
|
|
|
|
GET_NUMBER_TEXT(LOCALE_SDECIMAL, cDecimalPoint);
|
|
|
|
GET_NUMBER_TEXT(LOCALE_STHOUSAND, cDigitSeperator);
|
|
|
|
GET_NUMBER_TEXT(LOCALE_SMONDECIMALSEP, cCurrencyDecimalPoint);
|
|
|
|
GET_NUMBER_TEXT(LOCALE_SMONTHOUSANDSEP, cCurrencyDigitSeperator);
|
|
|
|
|
|
|
|
/* Local currency symbols are often 2 characters */
|
|
|
|
lpChars->cCurrencyLocal2 = '\0';
|
|
|
|
switch(GetLocaleInfoW(lcid, lctype|LOCALE_SCURRENCY, buff, sizeof(WCHAR) * 4))
|
|
|
|
{
|
|
|
|
case 3: lpChars->cCurrencyLocal2 = buff[1]; /* Fall through */
|
|
|
|
case 2: lpChars->cCurrencyLocal = buff[0];
|
|
|
|
break;
|
|
|
|
default: WARN("buffer too small for LOCALE_SCURRENCY\n");
|
|
|
|
}
|
|
|
|
TRACE("lcid 0x%lx, cCurrencyLocal =%d,%d '%c','%c'\n", lcid, lpChars->cCurrencyLocal,
|
|
|
|
lpChars->cCurrencyLocal2, lpChars->cCurrencyLocal, lpChars->cCurrencyLocal2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Number Parsing States */
|
|
|
|
#define B_PROCESSING_EXPONENT 0x1
|
|
|
|
#define B_NEGATIVE_EXPONENT 0x2
|
|
|
|
#define B_EXPONENT_START 0x4
|
|
|
|
#define B_INEXACT_ZEROS 0x8
|
|
|
|
#define B_LEADING_ZERO 0x10
|
2001-08-15 20:47:28 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* VarParseNumFromStr [OLEAUT32.46]
|
2003-10-03 05:36:46 +02:00
|
|
|
*
|
|
|
|
* Parse a string containing a number into a NUMPARSE structure.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to parse number from
|
|
|
|
* lcid [I] Locale Id for the conversion
|
|
|
|
* dwFlags [I] Apparently not used
|
|
|
|
* pNumprs [I/O] Destination for parsed number
|
|
|
|
* rgbDig [O] Destination for digits read in
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pNumprs and rgbDig contain the parsed representation of
|
|
|
|
* the number.
|
|
|
|
* Failure: E_INVALIDARG, if any parameter is invalid.
|
|
|
|
* DISP_E_TYPEMISMATCH, if the string is not a number or is formatted
|
|
|
|
* incorrectly.
|
|
|
|
* DISP_E_OVERFLOW, if rgbDig is too small to hold the number.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* pNumprs must have the following fields set:
|
|
|
|
* cDig: Set to the size of rgbDig.
|
|
|
|
* dwInFlags: Set to the allowable syntax of the number using NUMPRS_ flags
|
|
|
|
* from "oleauto.h".
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* - I am unsure if this function should parse non-arabic (e.g. Thai)
|
|
|
|
* numerals, so this has not been implemented.
|
2001-08-15 20:47:28 +02:00
|
|
|
*/
|
2003-10-03 05:36:46 +02:00
|
|
|
HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
|
|
|
|
NUMPARSE *pNumprs, BYTE *rgbDig)
|
|
|
|
{
|
|
|
|
VARIANT_NUMBER_CHARS chars;
|
|
|
|
BYTE rgbTmp[1024];
|
|
|
|
DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS;
|
|
|
|
int iMaxDigits = sizeof(rgbTmp) / sizeof(BYTE);
|
|
|
|
int cchUsed = 0;
|
|
|
|
|
|
|
|
TRACE("(%s,%ld,%ld,%p,%p)\n", debugstr_w(lpszStr), lcid, dwFlags, pNumprs, rgbDig);
|
|
|
|
|
|
|
|
if (pNumprs->dwInFlags & NUMPRS_HEX_OCT)
|
|
|
|
FIXME("dwInFlags & NUMPRS_HEX_OCT not yet implemented!\n");
|
|
|
|
|
|
|
|
if (!pNumprs || !rgbDig)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (pNumprs->cDig < iMaxDigits)
|
|
|
|
iMaxDigits = pNumprs->cDig;
|
|
|
|
|
|
|
|
pNumprs->cDig = 0;
|
|
|
|
pNumprs->dwOutFlags = 0;
|
|
|
|
pNumprs->cchUsed = 0;
|
|
|
|
pNumprs->nBaseShift = 0;
|
|
|
|
pNumprs->nPwr10 = 0;
|
|
|
|
|
|
|
|
if (!lpszStr)
|
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
|
|
|
|
VARIANT_GetLocalisedNumberChars(&chars, lcid, dwFlags);
|
|
|
|
|
|
|
|
/* First consume all the leading symbols and space from the string */
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (pNumprs->dwInFlags & NUMPRS_LEADING_WHITE && isspaceW(*lpszStr))
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_LEADING_WHITE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
} while (isspaceW(*lpszStr));
|
|
|
|
}
|
|
|
|
else if (pNumprs->dwInFlags & NUMPRS_LEADING_PLUS &&
|
|
|
|
*lpszStr == chars.cPositiveSymbol &&
|
|
|
|
!(pNumprs->dwOutFlags & NUMPRS_LEADING_PLUS))
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_LEADING_PLUS;
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
else if (pNumprs->dwInFlags & NUMPRS_LEADING_MINUS &&
|
|
|
|
*lpszStr == chars.cNegativeSymbol &&
|
|
|
|
!(pNumprs->dwOutFlags & NUMPRS_LEADING_MINUS))
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= (NUMPRS_LEADING_MINUS|NUMPRS_NEG);
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
else if (pNumprs->dwInFlags & NUMPRS_CURRENCY &&
|
|
|
|
!(pNumprs->dwOutFlags & NUMPRS_CURRENCY) &&
|
|
|
|
*lpszStr == chars.cCurrencyLocal &&
|
|
|
|
(!chars.cCurrencyLocal2 || lpszStr[1] == chars.cCurrencyLocal2))
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_CURRENCY;
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
/* Only accept currency characters */
|
|
|
|
chars.cDecimalPoint = chars.cCurrencyDecimalPoint;
|
|
|
|
chars.cDigitSeperator = chars.cCurrencyDigitSeperator;
|
|
|
|
}
|
|
|
|
else if (pNumprs->dwInFlags & NUMPRS_PARENS && *lpszStr == '(' &&
|
|
|
|
!(pNumprs->dwOutFlags & NUMPRS_PARENS))
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_PARENS;
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pNumprs->dwOutFlags & NUMPRS_CURRENCY))
|
|
|
|
{
|
|
|
|
/* Only accept non-currency characters */
|
|
|
|
chars.cCurrencyDecimalPoint = chars.cDecimalPoint;
|
|
|
|
chars.cCurrencyDigitSeperator = chars.cDigitSeperator;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Strip Leading zeros */
|
|
|
|
while (*lpszStr == '0')
|
|
|
|
{
|
|
|
|
dwState |= B_LEADING_ZERO;
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*lpszStr)
|
|
|
|
{
|
|
|
|
if (isdigitW(*lpszStr))
|
|
|
|
{
|
|
|
|
if (dwState & B_PROCESSING_EXPONENT)
|
|
|
|
{
|
|
|
|
int exponentSize = 0;
|
|
|
|
if (dwState & B_EXPONENT_START)
|
|
|
|
{
|
|
|
|
while (*lpszStr == '0')
|
|
|
|
{
|
|
|
|
/* Skip leading zero's in the exponent */
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
if (!isdigitW(*lpszStr))
|
|
|
|
break; /* No exponent digits - invalid */
|
|
|
|
}
|
|
|
|
|
|
|
|
while (isdigitW(*lpszStr))
|
|
|
|
{
|
|
|
|
exponentSize *= 10;
|
|
|
|
exponentSize += *lpszStr - '0';
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
if (dwState & B_NEGATIVE_EXPONENT)
|
|
|
|
exponentSize = -exponentSize;
|
|
|
|
/* Add the exponent into the powers of 10 */
|
|
|
|
pNumprs->nPwr10 += exponentSize;
|
|
|
|
dwState &= ~(B_PROCESSING_EXPONENT|B_EXPONENT_START);
|
|
|
|
lpszStr--; /* back up to allow processing of next char */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pNumprs->cDig >= iMaxDigits)
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_INEXACT;
|
|
|
|
|
|
|
|
if (*lpszStr != '0')
|
|
|
|
dwState &= ~B_INEXACT_ZEROS; /* Inexact number with non-trailing zeros */
|
|
|
|
|
|
|
|
/* This digit can't be represented, but count it in nPwr10 */
|
|
|
|
if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
|
|
|
|
pNumprs->nPwr10--;
|
|
|
|
else
|
|
|
|
pNumprs->nPwr10++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
|
|
|
|
pNumprs->nPwr10--; /* Count decimal points in nPwr10 */
|
|
|
|
rgbTmp[pNumprs->cDig] = *lpszStr - '0';
|
2002-06-21 01:07:55 +02:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
pNumprs->cDig++;
|
|
|
|
cchUsed++;
|
|
|
|
}
|
2001-08-15 20:47:28 +02:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
else if (*lpszStr == chars.cDigitSeperator && pNumprs->dwInFlags & NUMPRS_THOUSANDS)
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_THOUSANDS;
|
|
|
|
cchUsed++;
|
|
|
|
}
|
|
|
|
else if (*lpszStr == chars.cDecimalPoint &&
|
|
|
|
pNumprs->dwInFlags & NUMPRS_DECIMAL &&
|
|
|
|
!(pNumprs->dwOutFlags & (NUMPRS_DECIMAL|NUMPRS_EXPONENT)))
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_DECIMAL;
|
|
|
|
cchUsed++;
|
|
|
|
|
|
|
|
/* Remove trailing zeros from the whole number part */
|
|
|
|
while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
|
|
|
|
{
|
|
|
|
pNumprs->nPwr10++;
|
|
|
|
pNumprs->cDig--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we have no digits so far, skip leading zeros */
|
|
|
|
if (!pNumprs->cDig)
|
|
|
|
{
|
|
|
|
while (lpszStr[1] == '0')
|
|
|
|
{
|
|
|
|
dwState |= B_LEADING_ZERO;
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((*lpszStr == 'e' || *lpszStr == 'E') &&
|
|
|
|
pNumprs->dwInFlags & NUMPRS_EXPONENT &&
|
|
|
|
!(pNumprs->dwOutFlags & NUMPRS_EXPONENT))
|
|
|
|
{
|
|
|
|
dwState |= B_PROCESSING_EXPONENT;
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_EXPONENT;
|
|
|
|
cchUsed++;
|
|
|
|
}
|
|
|
|
else if (dwState & B_PROCESSING_EXPONENT && *lpszStr == chars.cPositiveSymbol)
|
|
|
|
{
|
|
|
|
cchUsed++; /* Ignore positive exponent */
|
|
|
|
}
|
|
|
|
else if (dwState & B_PROCESSING_EXPONENT && *lpszStr == chars.cNegativeSymbol)
|
|
|
|
{
|
|
|
|
dwState |= B_NEGATIVE_EXPONENT;
|
|
|
|
cchUsed++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break; /* Stop at an unrecognised character */
|
|
|
|
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pNumprs->cDig && dwState & B_LEADING_ZERO)
|
|
|
|
{
|
|
|
|
/* Ensure a 0 on its own gets stored */
|
|
|
|
pNumprs->cDig = 1;
|
|
|
|
rgbTmp[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pNumprs->dwOutFlags & NUMPRS_EXPONENT && dwState & B_PROCESSING_EXPONENT)
|
|
|
|
{
|
|
|
|
pNumprs->cchUsed = cchUsed;
|
|
|
|
return DISP_E_TYPEMISMATCH; /* Failed to completely parse the exponent */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pNumprs->dwOutFlags & NUMPRS_INEXACT)
|
|
|
|
{
|
|
|
|
if (dwState & B_INEXACT_ZEROS)
|
|
|
|
pNumprs->dwOutFlags &= ~NUMPRS_INEXACT; /* All zeros doesn't set NUMPRS_INEXACT */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Remove trailing zeros from the last (whole number or decimal) part */
|
|
|
|
while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
|
|
|
|
{
|
|
|
|
if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
|
|
|
|
pNumprs->nPwr10--;
|
|
|
|
else
|
|
|
|
pNumprs->nPwr10++;
|
|
|
|
pNumprs->cDig--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pNumprs->cDig <= iMaxDigits)
|
|
|
|
pNumprs->dwOutFlags &= ~NUMPRS_INEXACT; /* Ignore stripped zeros for NUMPRS_INEXACT */
|
|
|
|
else
|
|
|
|
pNumprs->cDig = iMaxDigits; /* Only return iMaxDigits worth of digits */
|
|
|
|
|
|
|
|
/* Copy the digits we processed into rgbDig */
|
|
|
|
memcpy(rgbDig, rgbTmp, pNumprs->cDig * sizeof(BYTE));
|
|
|
|
|
|
|
|
/* Consume any trailing symbols and space */
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if ((pNumprs->dwInFlags & NUMPRS_TRAILING_WHITE) && isspaceW(*lpszStr))
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_TRAILING_WHITE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
} while (isspaceW(*lpszStr));
|
|
|
|
}
|
|
|
|
else if (pNumprs->dwInFlags & NUMPRS_TRAILING_PLUS &&
|
|
|
|
!(pNumprs->dwOutFlags & NUMPRS_LEADING_PLUS) &&
|
|
|
|
*lpszStr == chars.cPositiveSymbol)
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_TRAILING_PLUS;
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
else if (pNumprs->dwInFlags & NUMPRS_TRAILING_MINUS &&
|
|
|
|
!(pNumprs->dwOutFlags & NUMPRS_LEADING_MINUS) &&
|
|
|
|
*lpszStr == chars.cNegativeSymbol)
|
|
|
|
{
|
|
|
|
pNumprs->dwOutFlags |= (NUMPRS_TRAILING_MINUS|NUMPRS_NEG);
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
else if (pNumprs->dwInFlags & NUMPRS_PARENS && *lpszStr == ')' &&
|
|
|
|
pNumprs->dwOutFlags & NUMPRS_PARENS)
|
|
|
|
{
|
|
|
|
cchUsed++;
|
|
|
|
lpszStr++;
|
|
|
|
pNumprs->dwOutFlags |= NUMPRS_NEG;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pNumprs->dwOutFlags & NUMPRS_PARENS && !(pNumprs->dwOutFlags & NUMPRS_NEG))
|
|
|
|
{
|
|
|
|
pNumprs->cchUsed = cchUsed;
|
|
|
|
return DISP_E_TYPEMISMATCH; /* Opening parenthesis not matched */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pNumprs->dwInFlags & NUMPRS_USE_ALL && *lpszStr != '\0')
|
|
|
|
return DISP_E_TYPEMISMATCH; /* Not all chars were consumed */
|
|
|
|
|
|
|
|
if (!pNumprs->cDig)
|
|
|
|
return DISP_E_TYPEMISMATCH; /* No Number found */
|
|
|
|
|
|
|
|
pNumprs->cchUsed = cchUsed;
|
|
|
|
return S_OK;
|
2001-08-15 20:47:28 +02:00
|
|
|
}
|
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
/* VTBIT flags indicating an integer value */
|
|
|
|
#define INTEGER_VTBITS (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
|
|
|
|
/* VTBIT flags indicating a real number value */
|
|
|
|
#define REAL_VTBITS (VTBIT_R4|VTBIT_R8|VTBIT_CY|VTBIT_DECIMAL)
|
2001-08-15 20:47:28 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* VarNumFromParseNum [OLEAUT32.47]
|
2003-10-03 05:36:46 +02:00
|
|
|
*
|
|
|
|
* Convert a NUMPARSE structure into a numeric Variant type.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pNumprs [I] Source for parsed number. cDig must be set to the size of rgbDig
|
|
|
|
* rgbDig [I] Source for the numbers digits
|
|
|
|
* dwVtBits [I] VTBIT_ flags from "oleauto.h" indicating the acceptable dest types
|
|
|
|
* pVarDst [O] Destination for the converted Variant value.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pVarDst contains the converted value.
|
|
|
|
* Failure: E_INVALIDARG, if any parameter is invalid.
|
|
|
|
* DISP_E_OVERFLOW, if the number is too big for the types set in dwVtBits.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* - The smallest favoured type present in dwVtBits that can represent the
|
|
|
|
* number in pNumprs without losing precision is used.
|
|
|
|
* - Signed types are preferrred over unsigned types of the same size.
|
|
|
|
* - Preferred types in order are: integer, float, double, currency then decimal.
|
|
|
|
* - Rounding (dropping of decimal points) occurs without error. See VarI8FromR8()
|
|
|
|
* for details of the rounding method.
|
|
|
|
* - pVarDst is not cleared before the result is stored in it.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig,
|
|
|
|
ULONG dwVtBits, VARIANT *pVarDst)
|
|
|
|
{
|
2003-10-28 22:45:30 +01:00
|
|
|
/* Scale factors and limits for double arithmetics */
|
2003-10-03 05:36:46 +02:00
|
|
|
static const double dblMultipliers[11] = {
|
|
|
|
1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0,
|
|
|
|
1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0
|
|
|
|
};
|
|
|
|
static const double dblMinimums[11] = {
|
|
|
|
R8_MIN, R8_MIN*10.0, R8_MIN*100.0, R8_MIN*1000.0, R8_MIN*10000.0,
|
|
|
|
R8_MIN*100000.0, R8_MIN*1000000.0, R8_MIN*10000000.0,
|
|
|
|
R8_MIN*100000000.0, R8_MIN*1000000000.0, R8_MIN*10000000000.0
|
|
|
|
};
|
|
|
|
static const double dblMaximums[11] = {
|
|
|
|
R8_MAX, R8_MAX/10.0, R8_MAX/100.0, R8_MAX/1000.0, R8_MAX/10000.0,
|
|
|
|
R8_MAX/100000.0, R8_MAX/1000000.0, R8_MAX/10000000.0,
|
|
|
|
R8_MAX/100000000.0, R8_MAX/1000000000.0, R8_MAX/10000000000.0
|
|
|
|
};
|
|
|
|
|
|
|
|
int wholeNumberDigits, fractionalDigits, divisor10 = 0, multiplier10 = 0;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,0x%lx,%p)\n", pNumprs, rgbDig, dwVtBits, pVarDst);
|
|
|
|
|
|
|
|
if (pNumprs->nBaseShift)
|
|
|
|
{
|
|
|
|
/* nBaseShift indicates a hex or octal number */
|
|
|
|
FIXME("nBaseShift=%d not yet implemented, returning overflow\n", pNumprs->nBaseShift);
|
|
|
|
return DISP_E_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Count the number of relevant fractional and whole digits stored,
|
|
|
|
* And compute the divisor/multiplier to scale the number by.
|
|
|
|
*/
|
|
|
|
if (pNumprs->nPwr10 < 0)
|
|
|
|
{
|
|
|
|
if (-pNumprs->nPwr10 >= pNumprs->cDig)
|
|
|
|
{
|
|
|
|
/* A real number < +/- 1.0 e.g. 0.1024 or 0.01024 */
|
|
|
|
wholeNumberDigits = 0;
|
|
|
|
fractionalDigits = pNumprs->cDig;
|
|
|
|
divisor10 = -pNumprs->nPwr10;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* An exactly represented real number e.g. 1.024 */
|
|
|
|
wholeNumberDigits = pNumprs->cDig + pNumprs->nPwr10;
|
|
|
|
fractionalDigits = pNumprs->cDig - wholeNumberDigits;
|
|
|
|
divisor10 = pNumprs->cDig - wholeNumberDigits;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pNumprs->nPwr10 == 0)
|
|
|
|
{
|
|
|
|
/* An exactly represented whole number e.g. 1024 */
|
|
|
|
wholeNumberDigits = pNumprs->cDig;
|
|
|
|
fractionalDigits = 0;
|
|
|
|
}
|
|
|
|
else /* pNumprs->nPwr10 > 0 */
|
|
|
|
{
|
|
|
|
/* A whole number followed by nPwr10 0's e.g. 102400 */
|
|
|
|
wholeNumberDigits = pNumprs->cDig;
|
|
|
|
fractionalDigits = 0;
|
|
|
|
multiplier10 = pNumprs->nPwr10;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("cDig %d; nPwr10 %d, whole %d, frac %d ", pNumprs->cDig,
|
|
|
|
pNumprs->nPwr10, wholeNumberDigits, fractionalDigits);
|
|
|
|
TRACE("mult %d; div %d\n", multiplier10, divisor10);
|
|
|
|
|
|
|
|
if (dwVtBits & INTEGER_VTBITS &&
|
|
|
|
(!fractionalDigits || !(dwVtBits & (REAL_VTBITS|VTBIT_CY|VTBIT_DECIMAL))))
|
|
|
|
{
|
|
|
|
/* We have one or more integer output choices, and either:
|
|
|
|
* 1) An integer input value, or
|
|
|
|
* 2) A real number input value but no floating output choices.
|
|
|
|
* So, place the integer value into pVarDst, using the smallest type
|
|
|
|
* possible and preferring signed over unsigned types.
|
|
|
|
*/
|
|
|
|
BOOL bOverflow = FALSE, bNegative;
|
|
|
|
ULONG64 ul64 = 0;
|
2001-08-15 20:47:28 +02:00
|
|
|
int i;
|
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
/* Convert the integer part of the number into a UI8 */
|
|
|
|
for (i = 0; i < wholeNumberDigits; i++)
|
|
|
|
{
|
|
|
|
if (ul64 > (UI8_MAX / 10 - rgbDig[i]))
|
|
|
|
{
|
|
|
|
TRACE("Overflow multiplying digits\n");
|
|
|
|
bOverflow = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ul64 = ul64 * 10 + rgbDig[i];
|
|
|
|
}
|
2001-08-15 20:47:28 +02:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
/* Account for the scale of the number */
|
|
|
|
if (!bOverflow && multiplier10)
|
|
|
|
{
|
|
|
|
for (i = 0; i < multiplier10; i++)
|
|
|
|
{
|
|
|
|
if (ul64 > (UI8_MAX / 10))
|
|
|
|
{
|
|
|
|
TRACE("Overflow scaling number\n");
|
|
|
|
bOverflow = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ul64 = ul64 * 10;
|
|
|
|
}
|
2002-06-21 01:07:55 +02:00
|
|
|
}
|
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
/* If we have any fractional digits, round the value.
|
|
|
|
* Note we dont have to do this if divisor10 is < 1,
|
|
|
|
* because this means the fractional part must be < 0.5
|
|
|
|
*/
|
|
|
|
if (!bOverflow && fractionalDigits && divisor10 > 0)
|
|
|
|
{
|
|
|
|
const BYTE* fracDig = rgbDig + wholeNumberDigits;
|
|
|
|
BOOL bAdjust = FALSE;
|
|
|
|
|
|
|
|
TRACE("first decimal value is %d\n", *fracDig);
|
|
|
|
|
|
|
|
if (*fracDig > 5)
|
|
|
|
bAdjust = TRUE; /* > 0.5 */
|
|
|
|
else if (*fracDig == 5)
|
|
|
|
{
|
|
|
|
for (i = 1; i < fractionalDigits; i++)
|
|
|
|
{
|
|
|
|
if (fracDig[i])
|
|
|
|
{
|
|
|
|
bAdjust = TRUE; /* > 0.5 */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If exactly 0.5, round only odd values */
|
|
|
|
if (i == fractionalDigits && (ul64 & 1))
|
|
|
|
bAdjust = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bAdjust)
|
|
|
|
{
|
|
|
|
if (ul64 == UI8_MAX)
|
|
|
|
{
|
|
|
|
TRACE("Overflow after rounding\n");
|
|
|
|
bOverflow = TRUE;
|
|
|
|
}
|
|
|
|
ul64++;
|
|
|
|
}
|
2001-08-15 20:47:28 +02:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
|
|
|
|
/* Zero is not a negative number */
|
|
|
|
bNegative = pNumprs->dwOutFlags & NUMPRS_NEG && ul64 ? TRUE : FALSE;
|
|
|
|
|
|
|
|
TRACE("Integer value is %lld, bNeg %d\n", ul64, bNegative);
|
|
|
|
|
|
|
|
/* For negative integers, try the signed types in size order */
|
|
|
|
if (!bOverflow && bNegative)
|
|
|
|
{
|
|
|
|
if (dwVtBits & (VTBIT_I1|VTBIT_I2|VTBIT_I4|VTBIT_I8))
|
|
|
|
{
|
|
|
|
if (dwVtBits & VTBIT_I1 && ul64 <= -I1_MIN)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I1;
|
|
|
|
V_I1(pVarDst) = -ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (dwVtBits & VTBIT_I2 && ul64 <= -I2_MIN)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I2;
|
|
|
|
V_I2(pVarDst) = -ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (dwVtBits & VTBIT_I4 && ul64 <= -((LONGLONG)I4_MIN))
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I4;
|
|
|
|
V_I4(pVarDst) = -ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (dwVtBits & VTBIT_I8 && ul64 <= (ULONGLONG)I8_MAX + 1)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I8;
|
|
|
|
V_I8(pVarDst) = -ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2001-08-15 20:47:28 +02:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
else if (!bOverflow)
|
|
|
|
{
|
|
|
|
/* For positive integers, try signed then unsigned types in size order */
|
|
|
|
if (dwVtBits & VTBIT_I1 && ul64 <= I1_MAX)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I1;
|
|
|
|
V_I1(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (dwVtBits & VTBIT_UI1 && ul64 <= UI1_MAX)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_UI1;
|
|
|
|
V_UI1(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (dwVtBits & VTBIT_I2 && ul64 <= I2_MAX)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I2;
|
|
|
|
V_I2(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (dwVtBits & VTBIT_UI2 && ul64 <= UI2_MAX)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_UI2;
|
|
|
|
V_UI2(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (dwVtBits & VTBIT_I4 && ul64 <= I4_MAX)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I4;
|
|
|
|
V_I4(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (dwVtBits & VTBIT_UI4 && ul64 <= UI4_MAX)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_UI4;
|
|
|
|
V_UI4(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (dwVtBits & VTBIT_I8 && ul64 <= I8_MAX)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_I8;
|
|
|
|
V_I8(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (dwVtBits & VTBIT_UI8)
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_UI8;
|
|
|
|
V_UI8(pVarDst) = ul64;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwVtBits & REAL_VTBITS)
|
|
|
|
{
|
|
|
|
/* Try to put the number into a float or real */
|
|
|
|
BOOL bOverflow = FALSE, bNegative = pNumprs->dwOutFlags & NUMPRS_NEG;
|
|
|
|
double whole = 0.0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Convert the number into a double */
|
|
|
|
for (i = 0; i < pNumprs->cDig; i++)
|
|
|
|
whole = whole * 10.0 + rgbDig[i];
|
|
|
|
|
|
|
|
TRACE("Whole double value is %16.16g\n", whole);
|
|
|
|
|
|
|
|
/* Account for the scale */
|
|
|
|
while (multiplier10 > 10)
|
|
|
|
{
|
|
|
|
if (whole > dblMaximums[10])
|
|
|
|
{
|
|
|
|
dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY);
|
|
|
|
bOverflow = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
whole = whole * dblMultipliers[10];
|
|
|
|
multiplier10 -= 10;
|
|
|
|
}
|
|
|
|
if (multiplier10)
|
|
|
|
{
|
|
|
|
if (whole > dblMaximums[multiplier10])
|
|
|
|
{
|
|
|
|
dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY);
|
|
|
|
bOverflow = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
whole = whole * dblMultipliers[multiplier10];
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Scaled double value is %16.16g\n", whole);
|
|
|
|
|
|
|
|
while (divisor10 > 10)
|
|
|
|
{
|
|
|
|
if (whole < dblMinimums[10])
|
|
|
|
{
|
|
|
|
dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY); /* Underflow */
|
|
|
|
bOverflow = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
whole = whole / dblMultipliers[10];
|
|
|
|
divisor10 -= 10;
|
|
|
|
}
|
|
|
|
if (divisor10)
|
|
|
|
{
|
|
|
|
if (whole < dblMinimums[divisor10])
|
|
|
|
{
|
|
|
|
dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY); /* Underflow */
|
|
|
|
bOverflow = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
whole = whole / dblMultipliers[divisor10];
|
|
|
|
}
|
|
|
|
if (!bOverflow)
|
|
|
|
TRACE("Final double value is %16.16g\n", whole);
|
|
|
|
|
|
|
|
if (dwVtBits & VTBIT_R4 &&
|
|
|
|
((whole <= R4_MAX && whole >= R4_MIN) || whole == 0.0))
|
|
|
|
{
|
|
|
|
TRACE("Set R4 to final value\n");
|
|
|
|
V_VT(pVarDst) = VT_R4; /* Fits into a float */
|
|
|
|
V_R4(pVarDst) = pNumprs->dwOutFlags & NUMPRS_NEG ? -whole : whole;
|
|
|
|
return S_OK;
|
2002-06-21 01:07:55 +02:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
|
|
|
|
if (dwVtBits & VTBIT_R8)
|
|
|
|
{
|
|
|
|
TRACE("Set R8 to final value\n");
|
|
|
|
V_VT(pVarDst) = VT_R8; /* Fits into a double */
|
|
|
|
V_R8(pVarDst) = pNumprs->dwOutFlags & NUMPRS_NEG ? -whole : whole;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwVtBits & VTBIT_CY)
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(VarCyFromR8(bNegative ? -whole : whole, &V_CY(pVarDst))))
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_CY; /* Fits into a currency */
|
|
|
|
TRACE("Set CY to final value\n");
|
2002-06-21 01:07:55 +02:00
|
|
|
return S_OK;
|
2003-10-03 05:36:46 +02:00
|
|
|
}
|
|
|
|
TRACE("Value Overflows CY\n");
|
2002-06-21 01:07:55 +02:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
|
|
|
|
if (!bOverflow && dwVtBits & VTBIT_DECIMAL)
|
|
|
|
{
|
|
|
|
WARN("VTBIT_DECIMAL not yet implemented\n");
|
|
|
|
#if 0
|
|
|
|
if (SUCCEEDED(VarDecFromR8(bNegative ? -whole : whole, &V_DECIMAL(pVarDst))))
|
|
|
|
{
|
|
|
|
V_VT(pVarDst) = VT_DECIMAL; /* Fits into a decimal */
|
|
|
|
TRACE("Set DECIMAL to final value\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
#endif
|
2002-07-05 03:22:03 +02:00
|
|
|
}
|
2003-10-03 05:36:46 +02:00
|
|
|
}
|
2002-06-21 01:07:55 +02:00
|
|
|
|
2003-10-03 05:36:46 +02:00
|
|
|
if (dwVtBits & VTBIT_DECIMAL)
|
|
|
|
{
|
|
|
|
FIXME("VT_DECIMAL > R8 not yet supported, returning overflow\n");
|
|
|
|
}
|
|
|
|
return DISP_E_OVERFLOW; /* No more output choices */
|
2001-08-15 20:47:28 +02:00
|
|
|
}
|
|
|
|
|
2001-08-16 20:01:41 +02:00
|
|
|
/**********************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* VarBstrCmp [OLEAUT32.314]
|
2001-08-16 20:01:41 +02:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* flags can be:
|
2001-08-16 20:01:41 +02:00
|
|
|
* NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS
|
|
|
|
* NORM_IGNORESTRINGWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarBstrCmp(BSTR left, BSTR right, LCID lcid, DWORD flags)
|
|
|
|
{
|
2002-06-22 00:25:17 +02:00
|
|
|
INT r;
|
2001-08-16 20:01:41 +02:00
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
TRACE("( %s %s %ld %lx ) partial stub\n", debugstr_w(left), debugstr_w(right), lcid, flags);
|
2001-08-16 20:01:41 +02:00
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
/* Contrary to the MSDN, this returns eq for null vs null, null vs L"" and L"" vs NULL */
|
|
|
|
if((!left) || (!right)) {
|
|
|
|
|
|
|
|
if (!left && (!right || *right==0)) return VARCMP_EQ;
|
|
|
|
else if (!right && (!left || *left==0)) return VARCMP_EQ;
|
|
|
|
else return VARCMP_NULL;
|
|
|
|
}
|
2001-08-16 20:01:41 +02:00
|
|
|
|
|
|
|
if(flags&NORM_IGNORECASE)
|
|
|
|
r = lstrcmpiW(left,right);
|
|
|
|
else
|
|
|
|
r = lstrcmpW(left,right);
|
|
|
|
|
|
|
|
if(r<0)
|
|
|
|
return VARCMP_LT;
|
|
|
|
if(r>0)
|
|
|
|
return VARCMP_GT;
|
|
|
|
|
|
|
|
return VARCMP_EQ;
|
|
|
|
}
|
|
|
|
|
2001-08-18 18:06:30 +02:00
|
|
|
/**********************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* VarBstrCat [OLEAUT32.313]
|
2001-08-18 18:06:30 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarBstrCat(BSTR left, BSTR right, BSTR *out)
|
|
|
|
{
|
|
|
|
BSTR result;
|
2002-07-05 03:22:03 +02:00
|
|
|
int size = 0;
|
2001-08-18 18:06:30 +02:00
|
|
|
|
|
|
|
TRACE("( %s %s %p )\n", debugstr_w(left), debugstr_w(right), out);
|
|
|
|
|
2002-07-05 03:22:03 +02:00
|
|
|
/* On Windows, NULL parms are still handled (as empty strings) */
|
|
|
|
if (left) size=size + lstrlenW(left);
|
|
|
|
if (right) size=size + lstrlenW(right);
|
2001-08-18 18:06:30 +02:00
|
|
|
|
2002-07-05 03:22:03 +02:00
|
|
|
if (out) {
|
|
|
|
result = SysAllocStringLen(NULL, size);
|
|
|
|
*out = result;
|
|
|
|
if (left) lstrcatW(result,left);
|
|
|
|
if (right) lstrcatW(result,right);
|
|
|
|
TRACE("result = %s, [%p]\n", debugstr_w(result), result);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2001-08-18 18:06:30 +02:00
|
|
|
}
|
|
|
|
|
2002-01-29 03:44:44 +01:00
|
|
|
/**********************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* VarCat [OLEAUT32.318]
|
2002-01-29 03:44:44 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out)
|
|
|
|
{
|
|
|
|
/* Should we VariantClear out? */
|
|
|
|
/* Can we handle array, vector, by ref etc. */
|
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_NULL &&
|
|
|
|
(V_VT(right)&VT_TYPEMASK) == VT_NULL)
|
|
|
|
{
|
|
|
|
V_VT(out) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2003-01-03 00:11:56 +01:00
|
|
|
|
|
|
|
if (V_VT(left) == VT_BSTR && V_VT(right) == VT_BSTR)
|
2002-01-29 03:44:44 +01:00
|
|
|
{
|
|
|
|
V_VT(out) = VT_BSTR;
|
|
|
|
VarBstrCat (V_BSTR(left), V_BSTR(right), &V_BSTR(out));
|
|
|
|
return S_OK;
|
|
|
|
}
|
2003-01-03 00:11:56 +01:00
|
|
|
if (V_VT(left) == VT_BSTR) {
|
|
|
|
VARIANT bstrvar;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(out) = VT_BSTR;
|
|
|
|
hres = VariantChangeTypeEx(&bstrvar,right,0,0,VT_BSTR);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("Failed to convert right side from vt %d to VT_BSTR?\n",V_VT(right));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
VarBstrCat (V_BSTR(left), V_BSTR(&bstrvar), &V_BSTR(out));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (V_VT(right) == VT_BSTR) {
|
|
|
|
VARIANT bstrvar;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(out) = VT_BSTR;
|
|
|
|
hres = VariantChangeTypeEx(&bstrvar,left,0,0,VT_BSTR);
|
|
|
|
if (hres) {
|
|
|
|
FIXME("Failed to convert right side from vt %d to VT_BSTR?\n",V_VT(right));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
VarBstrCat (V_BSTR(&bstrvar), V_BSTR(right), &V_BSTR(out));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
FIXME ("types %d / %d not supported\n",V_VT(left)&VT_TYPEMASK, V_VT(right)&VT_TYPEMASK);
|
2002-01-29 03:44:44 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2002-06-21 01:07:55 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* VarCmp [OLEAUT32.176]
|
2002-06-21 01:07:55 +02:00
|
|
|
*
|
|
|
|
* flags can be:
|
|
|
|
* NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS
|
|
|
|
* NORM_IGNOREWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2003-01-28 01:23:19 +01:00
|
|
|
BOOL lOk = TRUE;
|
|
|
|
BOOL rOk = TRUE;
|
|
|
|
LONGLONG lVal = -1;
|
|
|
|
LONGLONG rVal = -1;
|
|
|
|
VARIANT rv,lv;
|
|
|
|
DWORD xmask;
|
|
|
|
HRESULT rc;
|
|
|
|
|
|
|
|
VariantInit(&lv);VariantInit(&rv);
|
|
|
|
V_VT(right) &= ~0x8000; /* hack since we sometime get this flag. */
|
|
|
|
V_VT(left) &= ~0x8000; /* hack since we sometime get this flag. */
|
2002-06-21 01:07:55 +02:00
|
|
|
|
|
|
|
TRACE("Left Var:\n");
|
|
|
|
dump_Variant(left);
|
|
|
|
TRACE("Right Var:\n");
|
|
|
|
dump_Variant(right);
|
|
|
|
|
|
|
|
/* If either are null, then return VARCMP_NULL */
|
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_NULL ||
|
|
|
|
(V_VT(right)&VT_TYPEMASK) == VT_NULL)
|
|
|
|
return VARCMP_NULL;
|
|
|
|
|
|
|
|
/* Strings - use VarBstrCmp */
|
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_BSTR &&
|
|
|
|
(V_VT(right)&VT_TYPEMASK) == VT_BSTR) {
|
|
|
|
return VarBstrCmp(V_BSTR(left), V_BSTR(right), lcid, flags);
|
|
|
|
}
|
|
|
|
|
2003-01-28 01:23:19 +01:00
|
|
|
xmask = (1<<(V_VT(left)&VT_TYPEMASK))|(1<<(V_VT(right)&VT_TYPEMASK));
|
|
|
|
if (xmask & (1<<VT_R8)) {
|
|
|
|
rc = VariantChangeType(&lv,left,0,VT_R8);
|
|
|
|
if (FAILED(rc)) return rc;
|
|
|
|
rc = VariantChangeType(&rv,right,0,VT_R8);
|
|
|
|
if (FAILED(rc)) return rc;
|
2003-11-25 02:49:31 +01:00
|
|
|
|
2003-01-28 01:23:19 +01:00
|
|
|
if (V_R8(&lv) == V_R8(&rv)) return VARCMP_EQ;
|
|
|
|
if (V_R8(&lv) < V_R8(&rv)) return VARCMP_LT;
|
|
|
|
if (V_R8(&lv) > V_R8(&rv)) return VARCMP_GT;
|
|
|
|
return E_FAIL; /* can't get here */
|
|
|
|
}
|
|
|
|
if (xmask & (1<<VT_R4)) {
|
|
|
|
rc = VariantChangeType(&lv,left,0,VT_R4);
|
|
|
|
if (FAILED(rc)) return rc;
|
|
|
|
rc = VariantChangeType(&rv,right,0,VT_R4);
|
|
|
|
if (FAILED(rc)) return rc;
|
2003-11-25 02:49:31 +01:00
|
|
|
|
2003-01-28 01:23:19 +01:00
|
|
|
if (V_R4(&lv) == V_R4(&rv)) return VARCMP_EQ;
|
|
|
|
if (V_R4(&lv) < V_R4(&rv)) return VARCMP_LT;
|
|
|
|
if (V_R4(&lv) > V_R4(&rv)) return VARCMP_GT;
|
|
|
|
return E_FAIL; /* can't get here */
|
|
|
|
}
|
|
|
|
|
2002-07-05 03:22:03 +02:00
|
|
|
/* Integers - Ideally like to use VarDecCmp, but no Dec support yet
|
2002-06-21 01:07:55 +02:00
|
|
|
Use LONGLONG to maximize ranges */
|
|
|
|
lOk = TRUE;
|
|
|
|
switch (V_VT(left)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : lVal = V_UNION(left,cVal); break;
|
|
|
|
case VT_I2 : lVal = V_UNION(left,iVal); break;
|
|
|
|
case VT_I4 : lVal = V_UNION(left,lVal); break;
|
|
|
|
case VT_INT : lVal = V_UNION(left,lVal); break;
|
|
|
|
case VT_UI1 : lVal = V_UNION(left,bVal); break;
|
|
|
|
case VT_UI2 : lVal = V_UNION(left,uiVal); break;
|
|
|
|
case VT_UI4 : lVal = V_UNION(left,ulVal); break;
|
|
|
|
case VT_UINT : lVal = V_UNION(left,ulVal); break;
|
2003-01-03 00:11:56 +01:00
|
|
|
case VT_BOOL : lVal = V_UNION(left,boolVal); break;
|
2002-06-21 01:07:55 +02:00
|
|
|
default: lOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rOk = TRUE;
|
|
|
|
switch (V_VT(right)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : rVal = V_UNION(right,cVal); break;
|
|
|
|
case VT_I2 : rVal = V_UNION(right,iVal); break;
|
|
|
|
case VT_I4 : rVal = V_UNION(right,lVal); break;
|
|
|
|
case VT_INT : rVal = V_UNION(right,lVal); break;
|
|
|
|
case VT_UI1 : rVal = V_UNION(right,bVal); break;
|
|
|
|
case VT_UI2 : rVal = V_UNION(right,uiVal); break;
|
|
|
|
case VT_UI4 : rVal = V_UNION(right,ulVal); break;
|
|
|
|
case VT_UINT : rVal = V_UNION(right,ulVal); break;
|
2003-01-03 00:11:56 +01:00
|
|
|
case VT_BOOL : rVal = V_UNION(right,boolVal); break;
|
2002-06-21 01:07:55 +02:00
|
|
|
default: rOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lOk && rOk) {
|
|
|
|
if (lVal < rVal) {
|
|
|
|
return VARCMP_LT;
|
|
|
|
} else if (lVal > rVal) {
|
|
|
|
return VARCMP_GT;
|
|
|
|
} else {
|
|
|
|
return VARCMP_EQ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Strings - use VarBstrCmp */
|
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_DATE &&
|
|
|
|
(V_VT(right)&VT_TYPEMASK) == VT_DATE) {
|
|
|
|
|
|
|
|
if (floor(V_UNION(left,date)) == floor(V_UNION(right,date))) {
|
|
|
|
/* Due to floating point rounding errors, calculate varDate in whole numbers) */
|
|
|
|
double wholePart = 0.0;
|
|
|
|
double leftR;
|
|
|
|
double rightR;
|
|
|
|
|
|
|
|
/* Get the fraction * 24*60*60 to make it into whole seconds */
|
|
|
|
wholePart = (double) floor( V_UNION(left,date) );
|
|
|
|
if (wholePart == 0) wholePart = 1;
|
|
|
|
leftR = floor(fmod( V_UNION(left,date), wholePart ) * (24*60*60));
|
|
|
|
|
|
|
|
wholePart = (double) floor( V_UNION(right,date) );
|
|
|
|
if (wholePart == 0) wholePart = 1;
|
|
|
|
rightR = floor(fmod( V_UNION(right,date), wholePart ) * (24*60*60));
|
|
|
|
|
|
|
|
if (leftR < rightR) {
|
|
|
|
return VARCMP_LT;
|
|
|
|
} else if (leftR > rightR) {
|
|
|
|
return VARCMP_GT;
|
|
|
|
} else {
|
|
|
|
return VARCMP_EQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (V_UNION(left,date) < V_UNION(right,date)) {
|
|
|
|
return VARCMP_LT;
|
|
|
|
} else if (V_UNION(left,date) > V_UNION(right,date)) {
|
|
|
|
return VARCMP_GT;
|
|
|
|
}
|
|
|
|
}
|
2003-01-03 00:11:56 +01:00
|
|
|
FIXME("VarCmp partial implementation, doesnt support vt 0x%x / 0x%x\n",V_VT(left), V_VT(right));
|
2002-06-21 01:07:55 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* VarAnd [OLEAUT32.142]
|
2002-06-21 01:07:55 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarAnd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
|
|
|
|
{
|
|
|
|
HRESULT rc = E_FAIL;
|
|
|
|
|
|
|
|
TRACE("Left Var:\n");
|
|
|
|
dump_Variant(left);
|
|
|
|
TRACE("Right Var:\n");
|
|
|
|
dump_Variant(right);
|
|
|
|
|
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_BOOL &&
|
|
|
|
(V_VT(right)&VT_TYPEMASK) == VT_BOOL) {
|
|
|
|
|
|
|
|
V_VT(result) = VT_BOOL;
|
|
|
|
if (V_BOOL(left) && V_BOOL(right)) {
|
|
|
|
V_BOOL(result) = VARIANT_TRUE;
|
|
|
|
} else {
|
|
|
|
V_BOOL(result) = VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
rc = S_OK;
|
|
|
|
|
|
|
|
} else {
|
2002-11-25 03:42:33 +01:00
|
|
|
/* Integers */
|
|
|
|
BOOL lOk = TRUE;
|
|
|
|
BOOL rOk = TRUE;
|
|
|
|
LONGLONG lVal = -1;
|
|
|
|
LONGLONG rVal = -1;
|
|
|
|
LONGLONG res = -1;
|
2003-10-03 05:36:46 +02:00
|
|
|
int resT = 0; /* Testing has shown I2 & I2 == I2, all else
|
2002-11-25 03:42:33 +01:00
|
|
|
becomes I4, even unsigned ints (incl. UI2) */
|
|
|
|
|
|
|
|
lOk = TRUE;
|
|
|
|
switch (V_VT(left)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : lVal = V_UNION(left,cVal); resT=VT_I4; break;
|
|
|
|
case VT_I2 : lVal = V_UNION(left,iVal); resT=VT_I2; break;
|
|
|
|
case VT_I4 : lVal = V_UNION(left,lVal); resT=VT_I4; break;
|
|
|
|
case VT_INT : lVal = V_UNION(left,lVal); resT=VT_I4; break;
|
|
|
|
case VT_UI1 : lVal = V_UNION(left,bVal); resT=VT_I4; break;
|
|
|
|
case VT_UI2 : lVal = V_UNION(left,uiVal); resT=VT_I4; break;
|
|
|
|
case VT_UI4 : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
|
|
|
|
case VT_UINT : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
|
|
|
|
default: lOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rOk = TRUE;
|
|
|
|
switch (V_VT(right)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : rVal = V_UNION(right,cVal); resT=VT_I4; break;
|
|
|
|
case VT_I2 : rVal = V_UNION(right,iVal); resT=max(VT_I2, resT); break;
|
|
|
|
case VT_I4 : rVal = V_UNION(right,lVal); resT=VT_I4; break;
|
|
|
|
case VT_INT : rVal = V_UNION(right,lVal); resT=VT_I4; break;
|
|
|
|
case VT_UI1 : rVal = V_UNION(right,bVal); resT=VT_I4; break;
|
|
|
|
case VT_UI2 : rVal = V_UNION(right,uiVal); resT=VT_I4; break;
|
|
|
|
case VT_UI4 : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
|
|
|
|
case VT_UINT : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
|
|
|
|
default: rOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lOk && rOk) {
|
|
|
|
res = (lVal & rVal);
|
|
|
|
V_VT(result) = resT;
|
|
|
|
switch (resT) {
|
|
|
|
case VT_I2 : V_UNION(result,iVal) = res; break;
|
|
|
|
case VT_I4 : V_UNION(result,lVal) = res; break;
|
|
|
|
default:
|
|
|
|
FIXME("Unexpected result variant type %x\n", resT);
|
|
|
|
V_UNION(result,lVal) = res;
|
|
|
|
}
|
|
|
|
rc = S_OK;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
FIXME("VarAnd stub\n");
|
|
|
|
}
|
2002-06-21 01:07:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("rc=%d, Result:\n", (int) rc);
|
|
|
|
dump_Variant(result);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-12-10 20:06:28 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* VarAdd [OLEAUT32.141]
|
2002-12-16 23:08:48 +01:00
|
|
|
* FIXME: From MSDN: If ... Then
|
|
|
|
* Both expressions are of the string type Concatenated.
|
|
|
|
* One expression is a string type and the other a character Addition.
|
|
|
|
* One expression is numeric and the other is a string Addition.
|
|
|
|
* Both expressions are numeric Addition.
|
|
|
|
* Either expression is NULL NULL is returned.
|
|
|
|
* Both expressions are empty Integer subtype is returned.
|
2002-12-10 20:06:28 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarAdd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
|
|
|
|
{
|
|
|
|
HRESULT rc = E_FAIL;
|
|
|
|
|
|
|
|
TRACE("Left Var:\n");
|
|
|
|
dump_Variant(left);
|
|
|
|
TRACE("Right Var:\n");
|
|
|
|
dump_Variant(right);
|
|
|
|
|
2003-06-24 21:36:58 +02:00
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_EMPTY)
|
|
|
|
return VariantCopy(result,right);
|
|
|
|
|
|
|
|
if ((V_VT(right)&VT_TYPEMASK) == VT_EMPTY)
|
|
|
|
return VariantCopy(result,left);
|
|
|
|
|
|
|
|
if (((V_VT(left)&VT_TYPEMASK) == VT_R8) || ((V_VT(right)&VT_TYPEMASK) == VT_R8)) {
|
|
|
|
BOOL lOk = TRUE;
|
|
|
|
BOOL rOk = TRUE;
|
|
|
|
double lVal = -1;
|
|
|
|
double rVal = -1;
|
|
|
|
double res = -1;
|
|
|
|
|
|
|
|
lOk = TRUE;
|
|
|
|
switch (V_VT(left)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : lVal = V_UNION(left,cVal); break;
|
|
|
|
case VT_I2 : lVal = V_UNION(left,iVal); break;
|
|
|
|
case VT_I4 : lVal = V_UNION(left,lVal); break;
|
|
|
|
case VT_INT : lVal = V_UNION(left,lVal); break;
|
|
|
|
case VT_UI1 : lVal = V_UNION(left,bVal); break;
|
|
|
|
case VT_UI2 : lVal = V_UNION(left,uiVal); break;
|
|
|
|
case VT_UI4 : lVal = V_UNION(left,ulVal); break;
|
|
|
|
case VT_UINT : lVal = V_UNION(left,ulVal); break;
|
|
|
|
case VT_R4 : lVal = V_UNION(left,fltVal); break;
|
|
|
|
case VT_R8 : lVal = V_UNION(left,dblVal); break;
|
|
|
|
case VT_NULL : lVal = 0.0; break;
|
|
|
|
default: lOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rOk = TRUE;
|
|
|
|
switch (V_VT(right)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : rVal = V_UNION(right,cVal); break;
|
|
|
|
case VT_I2 : rVal = V_UNION(right,iVal); break;
|
|
|
|
case VT_I4 : rVal = V_UNION(right,lVal); break;
|
|
|
|
case VT_INT : rVal = V_UNION(right,lVal); break;
|
|
|
|
case VT_UI1 : rVal = V_UNION(right,bVal); break;
|
|
|
|
case VT_UI2 : rVal = V_UNION(right,uiVal); break;
|
|
|
|
case VT_UI4 : rVal = V_UNION(right,ulVal); break;
|
|
|
|
case VT_UINT : rVal = V_UNION(right,ulVal); break;
|
|
|
|
case VT_R4 : rVal = V_UNION(right,fltVal);break;
|
|
|
|
case VT_R8 : rVal = V_UNION(right,dblVal);break;
|
|
|
|
case VT_NULL : rVal = 0.0; break;
|
|
|
|
default: rOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lOk && rOk) {
|
|
|
|
res = (lVal + rVal);
|
|
|
|
V_VT(result) = VT_R8;
|
|
|
|
V_UNION(result,dblVal) = res;
|
|
|
|
rc = S_OK;
|
|
|
|
} else {
|
|
|
|
FIXME("Unhandled type pair %d / %d in double addition.\n",
|
|
|
|
(V_VT(left)&VT_TYPEMASK),
|
|
|
|
(V_VT(right)&VT_TYPEMASK)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-12-10 20:06:28 +01:00
|
|
|
/* Handle strings as concat */
|
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_BSTR &&
|
|
|
|
(V_VT(right)&VT_TYPEMASK) == VT_BSTR) {
|
|
|
|
V_VT(result) = VT_BSTR;
|
2003-03-04 03:14:32 +01:00
|
|
|
rc = VarBstrCat(V_BSTR(left), V_BSTR(right), &V_BSTR(result));
|
2002-12-10 20:06:28 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Integers */
|
|
|
|
BOOL lOk = TRUE;
|
|
|
|
BOOL rOk = TRUE;
|
|
|
|
LONGLONG lVal = -1;
|
|
|
|
LONGLONG rVal = -1;
|
|
|
|
LONGLONG res = -1;
|
2002-12-16 23:08:48 +01:00
|
|
|
int resT = 0; /* Testing has shown I2 + I2 == I2, all else
|
2002-12-10 20:06:28 +01:00
|
|
|
becomes I4 */
|
|
|
|
|
|
|
|
lOk = TRUE;
|
|
|
|
switch (V_VT(left)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : lVal = V_UNION(left,cVal); resT=VT_I4; break;
|
|
|
|
case VT_I2 : lVal = V_UNION(left,iVal); resT=VT_I2; break;
|
|
|
|
case VT_I4 : lVal = V_UNION(left,lVal); resT=VT_I4; break;
|
|
|
|
case VT_INT : lVal = V_UNION(left,lVal); resT=VT_I4; break;
|
|
|
|
case VT_UI1 : lVal = V_UNION(left,bVal); resT=VT_I4; break;
|
|
|
|
case VT_UI2 : lVal = V_UNION(left,uiVal); resT=VT_I4; break;
|
|
|
|
case VT_UI4 : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
|
|
|
|
case VT_UINT : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
|
2003-06-24 21:36:58 +02:00
|
|
|
case VT_NULL : lVal = 0; resT = VT_I4; break;
|
2002-12-10 20:06:28 +01:00
|
|
|
default: lOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rOk = TRUE;
|
|
|
|
switch (V_VT(right)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : rVal = V_UNION(right,cVal); resT=VT_I4; break;
|
|
|
|
case VT_I2 : rVal = V_UNION(right,iVal); resT=max(VT_I2, resT); break;
|
|
|
|
case VT_I4 : rVal = V_UNION(right,lVal); resT=VT_I4; break;
|
|
|
|
case VT_INT : rVal = V_UNION(right,lVal); resT=VT_I4; break;
|
|
|
|
case VT_UI1 : rVal = V_UNION(right,bVal); resT=VT_I4; break;
|
|
|
|
case VT_UI2 : rVal = V_UNION(right,uiVal); resT=VT_I4; break;
|
|
|
|
case VT_UI4 : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
|
|
|
|
case VT_UINT : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
|
2003-06-24 21:36:58 +02:00
|
|
|
case VT_NULL : rVal = 0; resT=VT_I4; break;
|
2002-12-10 20:06:28 +01:00
|
|
|
default: rOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lOk && rOk) {
|
|
|
|
res = (lVal + rVal);
|
|
|
|
V_VT(result) = resT;
|
|
|
|
switch (resT) {
|
|
|
|
case VT_I2 : V_UNION(result,iVal) = res; break;
|
|
|
|
case VT_I4 : V_UNION(result,lVal) = res; break;
|
|
|
|
default:
|
|
|
|
FIXME("Unexpected result variant type %x\n", resT);
|
|
|
|
V_UNION(result,lVal) = res;
|
|
|
|
}
|
|
|
|
rc = S_OK;
|
|
|
|
|
|
|
|
} else {
|
2003-06-24 21:36:58 +02:00
|
|
|
FIXME("unimplemented part (0x%x + 0x%x)\n",V_VT(left), V_VT(right));
|
2002-12-16 23:08:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("rc=%d, Result:\n", (int) rc);
|
|
|
|
dump_Variant(result);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2003-01-28 01:23:19 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* VarMul [OLEAUT32.156]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarMul(LPVARIANT left, LPVARIANT right, LPVARIANT result)
|
|
|
|
{
|
|
|
|
HRESULT rc = E_FAIL;
|
|
|
|
VARTYPE lvt,rvt,resvt;
|
|
|
|
VARIANT lv,rv;
|
|
|
|
BOOL found;
|
|
|
|
|
|
|
|
TRACE("left: ");dump_Variant(left);
|
|
|
|
TRACE("right: ");dump_Variant(right);
|
|
|
|
|
|
|
|
VariantInit(&lv);VariantInit(&rv);
|
|
|
|
lvt = V_VT(left)&VT_TYPEMASK;
|
|
|
|
rvt = V_VT(right)&VT_TYPEMASK;
|
|
|
|
found = FALSE;resvt=VT_VOID;
|
|
|
|
if (((1<<lvt) | (1<<rvt)) & ((1<<VT_R4)|(1<<VT_R8))) {
|
|
|
|
found = TRUE;
|
|
|
|
resvt = VT_R8;
|
|
|
|
}
|
|
|
|
if (!found && (((1<<lvt) | (1<<rvt)) & ((1<<VT_I1)|(1<<VT_I2)|(1<<VT_UI1)|(1<<VT_UI2)|(1<<VT_I4)|(1<<VT_UI4)|(1<<VT_INT)|(1<<VT_UINT)))) {
|
|
|
|
found = TRUE;
|
|
|
|
resvt = VT_I4;
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
FIXME("can't expand vt %d vs %d to a target type.\n",lvt,rvt);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
rc = VariantChangeType(&lv, left, 0, resvt);
|
|
|
|
if (FAILED(rc)) {
|
|
|
|
FIXME("Could not convert 0x%x to %d?\n",V_VT(left),resvt);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
rc = VariantChangeType(&rv, right, 0, resvt);
|
|
|
|
if (FAILED(rc)) {
|
|
|
|
FIXME("Could not convert 0x%x to %d?\n",V_VT(right),resvt);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
switch (resvt) {
|
|
|
|
case VT_R8:
|
|
|
|
V_VT(result) = resvt;
|
|
|
|
V_R8(result) = V_R8(&lv) * V_R8(&rv);
|
|
|
|
rc = S_OK;
|
|
|
|
break;
|
|
|
|
case VT_I4:
|
|
|
|
V_VT(result) = resvt;
|
|
|
|
V_I4(result) = V_I4(&lv) * V_I4(&rv);
|
|
|
|
rc = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TRACE("rc=%d, Result:\n", (int) rc);
|
|
|
|
dump_Variant(result);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* VarDiv [OLEAUT32.143]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarDiv(LPVARIANT left, LPVARIANT right, LPVARIANT result)
|
|
|
|
{
|
|
|
|
HRESULT rc = E_FAIL;
|
|
|
|
VARTYPE lvt,rvt,resvt;
|
|
|
|
VARIANT lv,rv;
|
|
|
|
BOOL found;
|
|
|
|
|
|
|
|
TRACE("left: ");dump_Variant(left);
|
|
|
|
TRACE("right: ");dump_Variant(right);
|
|
|
|
|
|
|
|
VariantInit(&lv);VariantInit(&rv);
|
|
|
|
lvt = V_VT(left)&VT_TYPEMASK;
|
|
|
|
rvt = V_VT(right)&VT_TYPEMASK;
|
|
|
|
found = FALSE;resvt = VT_VOID;
|
|
|
|
if (((1<<lvt) | (1<<rvt)) & ((1<<VT_R4)|(1<<VT_R8))) {
|
|
|
|
found = TRUE;
|
|
|
|
resvt = VT_R8;
|
|
|
|
}
|
|
|
|
if (!found && (((1<<lvt) | (1<<rvt)) & ((1<<VT_I1)|(1<<VT_I2)|(1<<VT_UI1)|(1<<VT_UI2)|(1<<VT_I4)|(1<<VT_UI4)|(1<<VT_INT)|(1<<VT_UINT)))) {
|
|
|
|
found = TRUE;
|
|
|
|
resvt = VT_I4;
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
FIXME("can't expand vt %d vs %d to a target type.\n",lvt,rvt);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
rc = VariantChangeType(&lv, left, 0, resvt);
|
|
|
|
if (FAILED(rc)) {
|
|
|
|
FIXME("Could not convert 0x%x to %d?\n",V_VT(left),resvt);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
rc = VariantChangeType(&rv, right, 0, resvt);
|
|
|
|
if (FAILED(rc)) {
|
|
|
|
FIXME("Could not convert 0x%x to %d?\n",V_VT(right),resvt);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
switch (resvt) {
|
|
|
|
case VT_R8:
|
|
|
|
V_VT(result) = resvt;
|
|
|
|
V_R8(result) = V_R8(&lv) / V_R8(&rv);
|
|
|
|
rc = S_OK;
|
|
|
|
break;
|
|
|
|
case VT_I4:
|
|
|
|
V_VT(result) = resvt;
|
|
|
|
V_I4(result) = V_I4(&lv) / V_I4(&rv);
|
|
|
|
rc = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TRACE("rc=%d, Result:\n", (int) rc);
|
|
|
|
dump_Variant(result);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* VarSub [OLEAUT32.159]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarSub(LPVARIANT left, LPVARIANT right, LPVARIANT result)
|
|
|
|
{
|
|
|
|
HRESULT rc = E_FAIL;
|
|
|
|
VARTYPE lvt,rvt,resvt;
|
|
|
|
VARIANT lv,rv;
|
|
|
|
BOOL found;
|
|
|
|
|
|
|
|
TRACE("left: ");dump_Variant(left);
|
|
|
|
TRACE("right: ");dump_Variant(right);
|
|
|
|
|
|
|
|
VariantInit(&lv);VariantInit(&rv);
|
|
|
|
lvt = V_VT(left)&VT_TYPEMASK;
|
|
|
|
rvt = V_VT(right)&VT_TYPEMASK;
|
|
|
|
found = FALSE;resvt = VT_VOID;
|
|
|
|
if (((1<<lvt) | (1<<rvt)) & ((1<<VT_R4)|(1<<VT_R8))) {
|
|
|
|
found = TRUE;
|
|
|
|
resvt = VT_R8;
|
|
|
|
}
|
|
|
|
if (!found && (((1<<lvt) | (1<<rvt)) & ((1<<VT_I1)|(1<<VT_I2)|(1<<VT_UI1)|(1<<VT_UI2)|(1<<VT_I4)|(1<<VT_UI4)|(1<<VT_INT)|(1<<VT_UINT)))) {
|
|
|
|
found = TRUE;
|
|
|
|
resvt = VT_I4;
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
FIXME("can't expand vt %d vs %d to a target type.\n",lvt,rvt);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
rc = VariantChangeType(&lv, left, 0, resvt);
|
|
|
|
if (FAILED(rc)) {
|
|
|
|
FIXME("Could not convert 0x%x to %d?\n",V_VT(left),resvt);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
rc = VariantChangeType(&rv, right, 0, resvt);
|
|
|
|
if (FAILED(rc)) {
|
|
|
|
FIXME("Could not convert 0x%x to %d?\n",V_VT(right),resvt);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
switch (resvt) {
|
|
|
|
case VT_R8:
|
|
|
|
V_VT(result) = resvt;
|
|
|
|
V_R8(result) = V_R8(&lv) - V_R8(&rv);
|
|
|
|
rc = S_OK;
|
|
|
|
break;
|
|
|
|
case VT_I4:
|
|
|
|
V_VT(result) = resvt;
|
|
|
|
V_I4(result) = V_I4(&lv) - V_I4(&rv);
|
|
|
|
rc = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TRACE("rc=%d, Result:\n", (int) rc);
|
|
|
|
dump_Variant(result);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-12-16 23:08:48 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* VarOr [OLEAUT32.157]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarOr(LPVARIANT left, LPVARIANT right, LPVARIANT result)
|
|
|
|
{
|
|
|
|
HRESULT rc = E_FAIL;
|
|
|
|
|
|
|
|
TRACE("Left Var:\n");
|
|
|
|
dump_Variant(left);
|
|
|
|
TRACE("Right Var:\n");
|
|
|
|
dump_Variant(right);
|
|
|
|
|
|
|
|
if ((V_VT(left)&VT_TYPEMASK) == VT_BOOL &&
|
|
|
|
(V_VT(right)&VT_TYPEMASK) == VT_BOOL) {
|
|
|
|
|
|
|
|
V_VT(result) = VT_BOOL;
|
|
|
|
if (V_BOOL(left) || V_BOOL(right)) {
|
|
|
|
V_BOOL(result) = VARIANT_TRUE;
|
|
|
|
} else {
|
|
|
|
V_BOOL(result) = VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
rc = S_OK;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* Integers */
|
|
|
|
BOOL lOk = TRUE;
|
|
|
|
BOOL rOk = TRUE;
|
|
|
|
LONGLONG lVal = -1;
|
|
|
|
LONGLONG rVal = -1;
|
|
|
|
LONGLONG res = -1;
|
2003-10-03 05:36:46 +02:00
|
|
|
int resT = 0; /* Testing has shown I2 & I2 == I2, all else
|
2002-12-16 23:08:48 +01:00
|
|
|
becomes I4, even unsigned ints (incl. UI2) */
|
|
|
|
|
|
|
|
lOk = TRUE;
|
|
|
|
switch (V_VT(left)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : lVal = V_UNION(left,cVal); resT=VT_I4; break;
|
|
|
|
case VT_I2 : lVal = V_UNION(left,iVal); resT=VT_I2; break;
|
|
|
|
case VT_I4 : lVal = V_UNION(left,lVal); resT=VT_I4; break;
|
|
|
|
case VT_INT : lVal = V_UNION(left,lVal); resT=VT_I4; break;
|
|
|
|
case VT_UI1 : lVal = V_UNION(left,bVal); resT=VT_I4; break;
|
|
|
|
case VT_UI2 : lVal = V_UNION(left,uiVal); resT=VT_I4; break;
|
|
|
|
case VT_UI4 : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
|
|
|
|
case VT_UINT : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
|
|
|
|
default: lOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rOk = TRUE;
|
|
|
|
switch (V_VT(right)&VT_TYPEMASK) {
|
|
|
|
case VT_I1 : rVal = V_UNION(right,cVal); resT=VT_I4; break;
|
|
|
|
case VT_I2 : rVal = V_UNION(right,iVal); resT=max(VT_I2, resT); break;
|
|
|
|
case VT_I4 : rVal = V_UNION(right,lVal); resT=VT_I4; break;
|
|
|
|
case VT_INT : rVal = V_UNION(right,lVal); resT=VT_I4; break;
|
|
|
|
case VT_UI1 : rVal = V_UNION(right,bVal); resT=VT_I4; break;
|
|
|
|
case VT_UI2 : rVal = V_UNION(right,uiVal); resT=VT_I4; break;
|
|
|
|
case VT_UI4 : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
|
|
|
|
case VT_UINT : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
|
|
|
|
default: rOk = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lOk && rOk) {
|
|
|
|
res = (lVal | rVal);
|
|
|
|
V_VT(result) = resT;
|
|
|
|
switch (resT) {
|
|
|
|
case VT_I2 : V_UNION(result,iVal) = res; break;
|
|
|
|
case VT_I4 : V_UNION(result,lVal) = res; break;
|
|
|
|
default:
|
|
|
|
FIXME("Unexpected result variant type %x\n", resT);
|
|
|
|
V_UNION(result,lVal) = res;
|
|
|
|
}
|
|
|
|
rc = S_OK;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
FIXME("unimplemented part\n");
|
2002-12-10 20:06:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("rc=%d, Result:\n", (int) rc);
|
|
|
|
dump_Variant(result);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-06-21 01:07:55 +02:00
|
|
|
/**********************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* VarNot [OLEAUT32.174]
|
2002-06-21 01:07:55 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarNot(LPVARIANT in, LPVARIANT result)
|
|
|
|
{
|
|
|
|
HRESULT rc = E_FAIL;
|
|
|
|
|
|
|
|
TRACE("Var In:\n");
|
|
|
|
dump_Variant(in);
|
|
|
|
|
|
|
|
if ((V_VT(in)&VT_TYPEMASK) == VT_BOOL) {
|
|
|
|
|
|
|
|
V_VT(result) = VT_BOOL;
|
|
|
|
if (V_BOOL(in)) {
|
|
|
|
V_BOOL(result) = VARIANT_FALSE;
|
|
|
|
} else {
|
|
|
|
V_BOOL(result) = VARIANT_TRUE;
|
|
|
|
}
|
|
|
|
rc = S_OK;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
FIXME("VarNot stub\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("rc=%d, Result:\n", (int) rc);
|
|
|
|
dump_Variant(result);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-07-08 21:36:24 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* VarCyMulI4 [OLEAUT32.304]
|
|
|
|
* Multiply currency value by integer
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarCyMulI4(CY cyIn, LONG mulBy, CY *pcyOut) {
|
|
|
|
|
|
|
|
double cyVal = 0;
|
|
|
|
HRESULT rc = S_OK;
|
|
|
|
|
|
|
|
rc = VarR8FromCy(cyIn, &cyVal);
|
|
|
|
if (rc == S_OK) {
|
|
|
|
rc = VarCyFromR8((cyVal * (double) mulBy), pcyOut);
|
|
|
|
TRACE("Multiply %f by %ld = %f [%ld,%lu]\n", cyVal, mulBy, (cyVal * (double) mulBy),
|
|
|
|
pcyOut->s.Hi, pcyOut->s.Lo);
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
2003-09-08 20:37:22 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* VarMod [OLEAUT32.154]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI VarMod(LPVARIANT left, LPVARIANT right, LPVARIANT result)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n", left, right, result);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|