Set the type of VarBstrFromDate to dwFlags, instead of lcid.
Ulrich Czekalla <ulrichc@corel.ca> Fixed the problem with the date being off by one. Petar Djukic VariantCopy was ignoring VT_DISPATCH,VT_UNKNOWN, and VT_VARIANT. Same with VariantClear. Coerce function doesn't implement coercion for VT_DISPATCH type.
This commit is contained in:
parent
28db50f060
commit
64b9d86669
|
@ -362,12 +362,16 @@ static BOOL DateToTm( DATE dateIn, LCID lcid, struct tm* pTm )
|
||||||
/* find in what year the day in the "wholePart" falls into.
|
/* find in what year the day in the "wholePart" falls into.
|
||||||
* add the value to the year field.
|
* add the value to the year field.
|
||||||
*/
|
*/
|
||||||
yearsSince1900 = floor( wholePart / DAYS_IN_ONE_YEAR );
|
yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 );
|
||||||
pTm->tm_year += yearsSince1900;
|
pTm->tm_year += yearsSince1900;
|
||||||
/* determine if this is a leap year.
|
/* determine if this is a leap year.
|
||||||
*/
|
*/
|
||||||
if( isleap( pTm->tm_year ) )
|
if( isleap( pTm->tm_year ) )
|
||||||
|
{
|
||||||
leapYear = 1;
|
leapYear = 1;
|
||||||
|
wholePart++;
|
||||||
|
}
|
||||||
|
|
||||||
/* find what day of that year does the "wholePart" corresponds to.
|
/* find what day of that year does the "wholePart" corresponds to.
|
||||||
* Note: nDay is in [1-366] format
|
* Note: nDay is in [1-366] format
|
||||||
*/
|
*/
|
||||||
|
@ -871,11 +875,20 @@ static HRESULT Coerce( VARIANTARG* pd, LCID lcid, ULONG dwFlags, VARIANTARG* ps,
|
||||||
unsigned short vtFrom = 0;
|
unsigned short vtFrom = 0;
|
||||||
vtFrom = ps->vt & VT_TYPEMASK;
|
vtFrom = ps->vt & VT_TYPEMASK;
|
||||||
|
|
||||||
/* Note: Since "long" and "int" values both have 4 bytes and are both signed integers
|
/* Note: Since "long" and "int" values both have 4 bytes and are
|
||||||
* "int" will be treated as "long" in the following code.
|
* both signed integers "int" will be treated as "long" in the
|
||||||
* The same goes for there unsigned versions.
|
* following code.
|
||||||
|
* The same goes for their unsigned versions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Trivial Case: If the coercion is from two types that are
|
||||||
|
* identical then we can blindly copy from one argument to another.*/
|
||||||
|
if ((vt==vtFrom))
|
||||||
|
{
|
||||||
|
return VariantCopy(pd,ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cases requiring thought*/
|
||||||
switch( vt )
|
switch( vt )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1689,10 +1702,15 @@ HRESULT WINAPI VariantClear(VARIANTARG* pvarg)
|
||||||
SysFreeString( pvarg->u.bstrVal );
|
SysFreeString( pvarg->u.bstrVal );
|
||||||
break;
|
break;
|
||||||
case( VT_DISPATCH ):
|
case( VT_DISPATCH ):
|
||||||
|
if(pvarg->u.pdispVal!=NULL)
|
||||||
|
ICOM_CALL(Release,pvarg->u.pdispVal);
|
||||||
break;
|
break;
|
||||||
case( VT_VARIANT ):
|
case( VT_VARIANT ):
|
||||||
|
VariantClear(pvarg->u.pvarVal);
|
||||||
break;
|
break;
|
||||||
case( VT_UNKNOWN ):
|
case( VT_UNKNOWN ):
|
||||||
|
if(pvarg->u.punkVal!=NULL)
|
||||||
|
ICOM_CALL(Release,pvarg->u.punkVal);
|
||||||
break;
|
break;
|
||||||
case( VT_SAFEARRAY ):
|
case( VT_SAFEARRAY ):
|
||||||
SafeArrayDestroy(pvarg->u.parray);
|
SafeArrayDestroy(pvarg->u.parray);
|
||||||
|
@ -1766,10 +1784,17 @@ HRESULT WINAPI VariantCopy(VARIANTARG* pvargDest, VARIANTARG* pvargSrc)
|
||||||
pvargDest->u.bstrVal = SysAllocString( pvargSrc->u.bstrVal );
|
pvargDest->u.bstrVal = SysAllocString( pvargSrc->u.bstrVal );
|
||||||
break;
|
break;
|
||||||
case( VT_DISPATCH ):
|
case( VT_DISPATCH ):
|
||||||
|
pvargDest->u.pdispVal = pvargSrc->u.pdispVal;
|
||||||
|
if (pvargDest->u.pdispVal!=NULL)
|
||||||
|
ICOM_CALL(AddRef,pvargDest->u.pdispVal);
|
||||||
break;
|
break;
|
||||||
case( VT_VARIANT ):
|
case( VT_VARIANT ):
|
||||||
|
VariantCopy(pvargDest->u.pvarVal,pvargSrc->u.pvarVal);
|
||||||
break;
|
break;
|
||||||
case( VT_UNKNOWN ):
|
case( VT_UNKNOWN ):
|
||||||
|
pvargDest->u.punkVal = pvargSrc->u.punkVal;
|
||||||
|
if (pvargDest->u.pdispVal!=NULL)
|
||||||
|
ICOM_CALL(AddRef,pvargDest->u.punkVal);
|
||||||
break;
|
break;
|
||||||
case( VT_SAFEARRAY ):
|
case( VT_SAFEARRAY ):
|
||||||
SafeArrayCopy(pvargSrc->u.parray, &pvargDest->u.parray);
|
SafeArrayCopy(pvargSrc->u.parray, &pvargDest->u.parray);
|
||||||
|
@ -3242,9 +3267,9 @@ HRESULT WINAPI VarBstrFromDate(DATE dateIn, LCID lcid, ULONG dwFlags, BSTR* pbst
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( lcid & VAR_DATEVALUEONLY )
|
if( dwFlags & VAR_DATEVALUEONLY )
|
||||||
strftime( pBuffer, BUFFER_MAX, "%x", &TM );
|
strftime( pBuffer, BUFFER_MAX, "%x", &TM );
|
||||||
else if( lcid & VAR_TIMEVALUEONLY )
|
else if( dwFlags & VAR_TIMEVALUEONLY )
|
||||||
strftime( pBuffer, BUFFER_MAX, "%X", &TM );
|
strftime( pBuffer, BUFFER_MAX, "%X", &TM );
|
||||||
else
|
else
|
||||||
strftime( pBuffer, BUFFER_MAX, "%x %X", &TM );
|
strftime( pBuffer, BUFFER_MAX, "%x %X", &TM );
|
||||||
|
|
Loading…
Reference in New Issue