- VarFormat now supports VT_R8 and BYREF variant types.

- Add VarCyMulI4 support.
This commit is contained in:
Jason Edmeades 2002-07-08 19:36:24 +00:00 committed by Alexandre Julliard
parent 80884be68c
commit 86d5a32de4
2 changed files with 40 additions and 3 deletions

View File

@ -296,7 +296,7 @@
298 stub VarDecCmpR8 # stdcall (ptr double) 298 stub VarDecCmpR8 # stdcall (ptr double)
299 stub VarCyAdd 299 stub VarCyAdd
303 stub VarCyMul 303 stub VarCyMul
304 stub VarCyMulI4 304 stdcall VarCyMulI4(double long ptr) VarCyMulI4
305 stub VarCySub 305 stub VarCySub
306 stub VarCyAbs 306 stub VarCyAbs
307 stub VarCyFix 307 stub VarCyFix

View File

@ -5492,6 +5492,9 @@ HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format,
TRACE("varIn:\n"); TRACE("varIn:\n");
dump_Variant(varIn); dump_Variant(varIn);
/* Note: Must Handle references type Variants (contain ptrs
to values rather than values */
/* Get format string */ /* Get format string */
pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, format ); pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, format );
@ -5500,7 +5503,15 @@ HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format,
/* Can't use VarBstrFromCy as it does not put currency sign on nor decimal places */ /* Can't use VarBstrFromCy as it does not put currency sign on nor decimal places */
double curVal; double curVal;
rc = VarR8FromCy(V_UNION(varIn,cyVal), &curVal);
/* Handle references type Variants (contain ptrs to values rather than values */
if (V_VT(varIn)&VT_BYREF) {
rc = VarR8FromCy(*(CY *)V_UNION(varIn,byref), &curVal);
} else {
rc = VarR8FromCy(V_UNION(varIn,cyVal), &curVal);
}
if (rc == S_OK) { if (rc == S_OK) {
char tmpStr[BUFFER_MAX]; char tmpStr[BUFFER_MAX];
sprintf(tmpStr, "%f", curVal); sprintf(tmpStr, "%f", curVal);
@ -5522,9 +5533,17 @@ HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format,
rc = VarFormatFromTokens(varIn, format, pBuffer, dwFlags, pbstrOut, GetUserDefaultLCID()); rc = VarFormatFromTokens(varIn, format, pBuffer, dwFlags, pbstrOut, GetUserDefaultLCID());
} }
} else if ((V_VT(varIn)&VT_TYPEMASK) == VT_R8) {
if (V_VT(varIn)&VT_BYREF) {
sprintf(pBuffer, "%f", *(double *)V_UNION(varIn,byref));
} else {
sprintf(pBuffer, "%f", V_UNION(varIn,dblVal));
}
*pbstrOut = StringDupAtoBstr( pBuffer );
} else { } else {
FIXME("Unsupported format!\n"); FIXME("VarFormat: Unsupported format %d!\n", V_VT(varIn)&VT_TYPEMASK);
*pbstrOut = StringDupAtoBstr( "??" ); *pbstrOut = StringDupAtoBstr( "??" );
} }
@ -5533,3 +5552,21 @@ HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format,
TRACE("result: '%s'\n", debugstr_w(*pbstrOut)); TRACE("result: '%s'\n", debugstr_w(*pbstrOut));
return rc; return rc;
} }
/**********************************************************************
* 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;
}