From 4736cc8cd5c7637630fcb4cd64780ade32215af1 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Wed, 15 Aug 2001 18:47:28 +0000 Subject: [PATCH] Implemented VarParseNumFromStr, VarNumFromParseNum. --- dlls/oleaut32/oleaut32.spec | 4 +-- dlls/oleaut32/variant.c | 68 +++++++++++++++++++++++++++++++++++++ include/oleauto.h | 41 ++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec index 9c7ee17af73..a4317f1325d 100644 --- a/dlls/oleaut32/oleaut32.spec +++ b/dlls/oleaut32/oleaut32.spec @@ -52,8 +52,8 @@ debug_channels (ole typelib) 39 stdcall SafeArrayDestroyData(ptr) SafeArrayDestroyData 40 stdcall SafeArrayRedim(ptr ptr) SafeArrayRedim 41 stub OACreateTypeLib2 -46 stub VarParseNumFromStr -47 stub VarNumFromParseNum +46 stdcall VarParseNumFromStr(wstr long long ptr ptr) VarParseNumFromStr +47 stdcall VarNumFromParseNum(ptr ptr long ptr) VarNumFromParseNum 48 stdcall VarI2FromUI1(long ptr) VarI2FromUI1 49 stdcall VarI2FromI4(long ptr) VarI2FromI4 50 stdcall VarI2FromR4(long ptr) VarI2FromR4 diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 36726bb90c8..c0390c6c4b1 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -4331,6 +4331,74 @@ INT WINAPI DosDateTimeToVariantTime(USHORT wDosDate, USHORT wDosTime, return TmToDATE( &t, pvtime ); } + +/********************************************************************** + * VarParseNumFromStr [OLEAUT32.46] + */ +HRESULT WINAPI VarParseNumFromStr(OLECHAR * strIn, LCID lcid, ULONG dwFlags, + NUMPARSE * pnumprs, BYTE * rgbDig) +{ + int i,lastent=0; + int cDig; + FIXME("(%s,flags=%lx,....), partial stub!\n",debugstr_w(strIn),dwFlags); + FIXME("numparse: cDig=%d, InFlags=%lx\n",pnumprs->cDig,pnumprs->dwInFlags); + + /* The other struct components are to be set by us */ + + memset(rgbDig,0,pnumprs->cDig); + + cDig = 0; + for (i=0; strIn[i] ;i++) { + if ((strIn[i]>='0') && (strIn[i]<='9')) { + if (pnumprs->cDig > cDig) { + *(rgbDig++)=strIn[i]-'0'; + cDig++; + lastent = i; + } + } + } + pnumprs->cDig = cDig; + + /* FIXME: Just patching some values in */ + pnumprs->nPwr10 = 0; + pnumprs->nBaseShift = 0; + pnumprs->cchUsed = lastent; + pnumprs->dwOutFlags = NUMPRS_DECIMAL; + return S_OK; +} + + +/********************************************************************** + * VarNumFromParseNum [OLEAUT32.47] + */ +HRESULT WINAPI VarNumFromParseNum(NUMPARSE * pnumprs, BYTE * rgbDig, + ULONG dwVtBits, VARIANT * pvar) +{ + DWORD xint; + int i; + FIXME("(,dwVtBits=%lx,....), partial stub!\n",dwVtBits); + + xint = 0; + for (i=0;icDig;i++) + xint = xint*10 + rgbDig[i]; + + VariantInit(pvar); + if (dwVtBits & VTBIT_I4) { + pvar->vt = VT_I4; + pvar->u.intVal = xint; + return S_OK; + } + if (dwVtBits & VTBIT_R8) { + pvar->vt = VT_R8; + pvar->u.dblVal = xint; + return S_OK; + } else { + FIXME("vtbitmask is unsupported %lx\n",dwVtBits); + return E_FAIL; + } +} + + /********************************************************************** * VariantTimeToDosDateTime [OLEAUT32.??] * Convert variant representation of time to the date and time representation diff --git a/include/oleauto.h b/include/oleauto.h index 5a696a46a9d..6c1adacc02c 100644 --- a/include/oleauto.h +++ b/include/oleauto.h @@ -526,6 +526,47 @@ typedef struct { USHORT wDayOfYear; } UDATE; +typedef struct { + INT cDig; + ULONG dwInFlags; + ULONG dwOutFlags; + INT cchUsed; + INT nBaseShift; + INT nPwr10; +} NUMPARSE; + +#define NUMPRS_LEADING_WHITE 0x0001 +#define NUMPRS_TRAILING_WHITE 0x0002 +#define NUMPRS_LEADING_PLUS 0x0004 +#define NUMPRS_TRAILING_PLUS 0x0008 +#define NUMPRS_LEADING_MINUS 0x0010 +#define NUMPRS_TRAILING_MINUS 0x0020 +#define NUMPRS_HEX_OCT 0x0040 +#define NUMPRS_PARENS 0x0080 +#define NUMPRS_DECIMAL 0x0100 +#define NUMPRS_THOUSANDS 0x0200 +#define NUMPRS_CURRENCY 0x0400 +#define NUMPRS_EXPONENT 0x0800 +#define NUMPRS_USE_ALL 0x1000 +#define NUMPRS_STD 0x1FFF + +#define NUMPRS_NEG 0x10000 +#define NUMPRS_INEXACT 0x20000 + +#define VTBIT_I1 (1 << VT_I1) +#define VTBIT_UI1 (1 << VT_UI1) +#define VTBIT_I2 (1 << VT_I2) +#define VTBIT_UI2 (1 << VT_UI2) +#define VTBIT_I4 (1 << VT_I4) +#define VTBIT_UI4 (1 << VT_UI4) +#define VTBIT_R4 (1 << VT_R4) +#define VTBIT_R8 (1 << VT_R8) +#define VTBIT_CY (1 << VT_CY) +#define VTBIT_DECIMAL (1 << VT_DECIMAL) + +HRESULT WINAPI VarParseNumFromStr(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE*); +HRESULT WINAPI VarNumFromParseNum(NUMPARSE*,BYTE*,ULONG,VARIANT*); + INT WINAPI DosDateTimeToVariantTime(USHORT,USHORT,DATE*); INT WINAPI VariantTimeToDosDateTime(DATE, USHORT *, USHORT *);