From 86d5a32de40bfe711ef63b7472110c9893032dce Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Mon, 8 Jul 2002 19:36:24 +0000 Subject: [PATCH] - VarFormat now supports VT_R8 and BYREF variant types. - Add VarCyMulI4 support. --- dlls/oleaut32/oleaut32.spec | 2 +- dlls/oleaut32/variant.c | 41 +++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec index 6643d7b6cbc..0da892bcbf5 100644 --- a/dlls/oleaut32/oleaut32.spec +++ b/dlls/oleaut32/oleaut32.spec @@ -296,7 +296,7 @@ 298 stub VarDecCmpR8 # stdcall (ptr double) 299 stub VarCyAdd 303 stub VarCyMul -304 stub VarCyMulI4 +304 stdcall VarCyMulI4(double long ptr) VarCyMulI4 305 stub VarCySub 306 stub VarCyAbs 307 stub VarCyFix diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 1bd530a3cf7..c5fd965eacc 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -5492,6 +5492,9 @@ HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format, TRACE("varIn:\n"); dump_Variant(varIn); + /* Note: Must Handle references type Variants (contain ptrs + to values rather than values */ + /* Get format string */ 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 */ 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) { char tmpStr[BUFFER_MAX]; sprintf(tmpStr, "%f", curVal); @@ -5522,9 +5533,17 @@ HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format, 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 { - FIXME("Unsupported format!\n"); + FIXME("VarFormat: Unsupported format %d!\n", V_VT(varIn)&VT_TYPEMASK); *pbstrOut = StringDupAtoBstr( "??" ); } @@ -5533,3 +5552,21 @@ HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format, TRACE("result: '%s'\n", debugstr_w(*pbstrOut)); 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; +}