Sync to Wine-0_9_4:
Robert Shearman <rob@codeweavers.com>
- OLE: Fix SafeArrayCopy for NULL pvData.
  It is allowed to copy a SAFEARRAY with a NULL pvData, as long as
  cbElements is non-zero. Add a test for this and fix the safe array
  code.
- OLE: Add const to several typelib functions.
  Add const attributes to parameters for several functions and fix up
  some formatting.
- OleTranslateColor trace fix.
  OleTranslateColor isn't a stub so don't print ":stub" in the trace
  message.
Modified: trunk/reactos/lib/oleaut32/oleaut.c
Modified: trunk/reactos/lib/oleaut32/safearray.c
Modified: trunk/reactos/lib/oleaut32/typelib.c

Modified: trunk/reactos/lib/oleaut32/oleaut.c
--- trunk/reactos/lib/oleaut32/oleaut.c	2005-12-26 23:16:41 UTC (rev 20350)
+++ trunk/reactos/lib/oleaut32/oleaut.c	2005-12-26 23:18:49 UTC (rev 20351)
@@ -629,7 +629,7 @@
   COLORREF colorref;
   BYTE b = HIBYTE(HIWORD(clr));
 
-  TRACE("(%08lx, %p, %p):stub\n", clr, hpal, pColorRef);
+  TRACE("(%08lx, %p, %p)\n", clr, hpal, pColorRef);
 
   /*
    * In case pColorRef is NULL, provide our own to simplify the code.

Modified: trunk/reactos/lib/oleaut32/safearray.c
--- trunk/reactos/lib/oleaut32/safearray.c	2005-12-26 23:16:41 UTC (rev 20350)
+++ trunk/reactos/lib/oleaut32/safearray.c	2005-12-26 23:18:49 UTC (rev 20351)
@@ -355,7 +355,9 @@
 /* Copy data items from one array to another */
 static HRESULT SAFEARRAY_CopyData(SAFEARRAY *psa, SAFEARRAY *dest)
 {
-  if (!psa->pvData || !dest->pvData || psa->fFeatures & FADF_DATADELETED)
+  if (!psa->pvData)
+    return S_OK;
+  else if (!dest->pvData || psa->fFeatures & FADF_DATADELETED)
     return E_INVALIDARG;
   else
   {
@@ -1378,6 +1380,12 @@
   if (!psa)
     return S_OK; /* Handles copying of NULL arrays */
 
+  if (!psa->cbElements)
+  {
+    ERR("not copying an array of 0 elements\n");
+    return E_INVALIDARG;
+  }
+
   if (psa->fFeatures & (FADF_RECORD|FADF_HAVEIID|FADF_HAVEVARTYPE))
   {
     VARTYPE vt;

Modified: trunk/reactos/lib/oleaut32/typelib.c
--- trunk/reactos/lib/oleaut32/typelib.c	2005-12-26 23:16:41 UTC (rev 20350)
+++ trunk/reactos/lib/oleaut32/typelib.c	2005-12-26 23:18:49 UTC (rev 20351)
@@ -85,7 +85,7 @@
 /* The OLE Automation ProxyStub Interface Class (aka Typelib Marshaler) */
 const GUID CLSID_PSOAInterface = { 0x00020424, 0, 0, { 0xC0, 0, 0, 0, 0, 0, 0, 0x46 } };
 
-static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTYPE *vt);
+static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt);
 static HRESULT TLB_AllocAndInitVarDesc(const VARDESC *src, VARDESC **dest_ptr);
 
 /****************************************************************************
@@ -5054,7 +5054,7 @@
     return E_FAIL;
 }
 
-static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTYPE *vt)
+static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt)
 {
     HRESULT hr = S_OK;
     ITypeInfo *tinfo2 = NULL;
@@ -5088,11 +5088,11 @@
         break;
 
     case TKIND_INTERFACE:
-      	if (IsEqualIID(&IID_IDispatch, &tattr->guid))
-      	   *vt |= VT_DISPATCH;
-       	else
-       	   *vt |= VT_UNKNOWN;
-       	break;
+        if (IsEqualIID(&IID_IDispatch, &tattr->guid))
+           *vt |= VT_DISPATCH;
+        else
+           *vt |= VT_UNKNOWN;
+        break;
 
     case TKIND_DISPATCH:
         *vt |= VT_DISPATCH;
@@ -5118,7 +5118,7 @@
     return hr;
 }
 
-static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTYPE *vt)
+static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt)
 {
     HRESULT hr = S_OK;
 
@@ -5134,7 +5134,7 @@
             ((tdesc->vt == VT_PTR) && (tdesc->u.lptdesc->vt == VT_USERDEFINED)))
         {
             VARTYPE vt_userdefined = 0;
-            TYPEDESC *tdesc_userdefined = tdesc;
+            const TYPEDESC *tdesc_userdefined = tdesc;
             if (tdesc->vt == VT_PTR)
             {
                 vt_userdefined = VT_BYREF;