Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * OLE2DISP library |
| 3 | * |
| 4 | * Copyright 1995 Martin von Loewis |
| 5 | */ |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 6 | #include <string.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 7 | #include "windef.h" |
| 8 | #include "wingdi.h" |
Michael Veksler | 4405f3c | 1999-08-18 18:35:57 +0000 | [diff] [blame] | 9 | #include "winuser.h" |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 10 | #include "winerror.h" |
Eric Pouech | 853043b | 2000-02-18 19:06:00 +0000 | [diff] [blame] | 11 | #include "olectl.h" |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 12 | #include "oleauto.h" |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 13 | #include "heap.h" |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 14 | #include "ldt.h" |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 15 | #include "debugtools.h" |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 16 | |
Eric Pouech | 853043b | 2000-02-18 19:06:00 +0000 | [diff] [blame] | 17 | DEFAULT_DEBUG_CHANNEL(ole); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 18 | |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 19 | /* This implementation of the BSTR API is 16-bit only. It |
| 20 | represents BSTR as a 16:16 far pointer, and the strings |
| 21 | as ISO-8859 */ |
| 22 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 23 | /****************************************************************************** |
| 24 | * BSTR_AllocBytes [Internal] |
| 25 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 26 | static BSTR16 BSTR_AllocBytes(int n) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 27 | { |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 28 | void *ptr = SEGPTR_ALLOC(n); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 29 | return (BSTR16)SEGPTR_GET(ptr); |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 30 | } |
| 31 | |
Matthew Becker | 7517534 | 1998-10-18 14:39:06 +0000 | [diff] [blame] | 32 | /****************************************************************************** |
| 33 | * BSTR_Free [INTERNAL] |
| 34 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 35 | static void BSTR_Free(BSTR16 in) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 36 | { |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 37 | SEGPTR_FREE( PTR_SEG_TO_LIN(in) ); |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Matthew Becker | 7517534 | 1998-10-18 14:39:06 +0000 | [diff] [blame] | 40 | /****************************************************************************** |
| 41 | * BSTR_GetAddr [INTERNAL] |
| 42 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 43 | static void* BSTR_GetAddr(BSTR16 in) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 44 | { |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 45 | return in ? PTR_SEG_TO_LIN(in) : 0; |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 48 | /****************************************************************************** |
| 49 | * SysAllocString16 [OLE2DISP.2] |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 50 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 51 | BSTR16 WINAPI SysAllocString16(LPCOLESTR16 in) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 52 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 53 | BSTR16 out=BSTR_AllocBytes(strlen(in)+1); |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 54 | if(!out)return 0; |
| 55 | strcpy(BSTR_GetAddr(out),in); |
| 56 | return out; |
| 57 | } |
| 58 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 59 | /****************************************************************************** |
| 60 | * SysAllocString32 [OLEAUT32.2] |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 61 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 62 | BSTR WINAPI SysAllocString(LPCOLESTR in) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 63 | { |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 64 | /* Delegate this to the SysAllocStringLen32 method. */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 65 | return SysAllocStringLen(in, lstrlenW(in)); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 68 | /****************************************************************************** |
| 69 | * SysReAllocString16 [OLE2DISP.3] |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 70 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 71 | INT16 WINAPI SysReAllocString16(LPBSTR16 old,LPCOLESTR16 in) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 72 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 73 | BSTR16 new=SysAllocString16(in); |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 74 | BSTR_Free(*old); |
| 75 | *old=new; |
| 76 | return 1; |
| 77 | } |
| 78 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 79 | /****************************************************************************** |
| 80 | * SysReAllocString32 [OLEAUT32.3] |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 81 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 82 | INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR in) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 83 | { |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 84 | /* |
| 85 | * Sanity check |
| 86 | */ |
| 87 | if (old==NULL) |
| 88 | return 0; |
| 89 | |
| 90 | /* |
| 91 | * Make sure we free the old string. |
| 92 | */ |
| 93 | if (*old!=NULL) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 94 | SysFreeString(*old); |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * Allocate the new string |
| 98 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 99 | *old = SysAllocString(in); |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 100 | |
| 101 | return 1; |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 104 | /****************************************************************************** |
| 105 | * SysAllocStringLen16 [OLE2DISP.4] |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 106 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 107 | BSTR16 WINAPI SysAllocStringLen16(const char *in, int len) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 108 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 109 | BSTR16 out=BSTR_AllocBytes(len+1); |
Andreas Mohr | deebddf | 1999-10-25 15:41:24 +0000 | [diff] [blame] | 110 | |
| 111 | if (!out) |
| 112 | return 0; |
| 113 | |
| 114 | /* |
| 115 | * Copy the information in the buffer. |
| 116 | * Since it is valid to pass a NULL pointer here, we'll initialize the |
| 117 | * buffer to nul if it is the case. |
| 118 | */ |
| 119 | if (in != 0) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 120 | strcpy(BSTR_GetAddr(out),in); |
Andreas Mohr | deebddf | 1999-10-25 15:41:24 +0000 | [diff] [blame] | 121 | else |
| 122 | memset(BSTR_GetAddr(out), 0, len+1); |
| 123 | |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 124 | return out; |
| 125 | } |
| 126 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 127 | /****************************************************************************** |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 128 | * SysAllocStringLen32 [OLEAUT32.4] |
| 129 | * |
| 130 | * In "Inside OLE, second edition" by Kraig Brockshmidt. In the Automation |
| 131 | * section, he describes the DWORD value placed before the BSTR data type. |
| 132 | * he describes it as a "DWORD count of characters". By experimenting with |
| 133 | * a windows application, this count seems to be a DWORD count of bytes in |
| 134 | * the string. Meaning that the count is double the number of wide |
| 135 | * characters in the string. |
| 136 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 137 | BSTR WINAPI SysAllocStringLen(const OLECHAR *in, unsigned int len) |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 138 | { |
| 139 | DWORD bufferSize; |
| 140 | DWORD* newBuffer; |
| 141 | WCHAR* stringBuffer; |
| 142 | |
| 143 | /* |
| 144 | * Find the lenth of the buffer passed-in in bytes. |
| 145 | */ |
| 146 | bufferSize = len * sizeof (WCHAR); |
| 147 | |
| 148 | /* |
| 149 | * Allocate a new buffer to hold the string. |
| 150 | * dont't forget to keep an empty spot at the begining of the |
| 151 | * buffer for the character count and an extra character at the |
| 152 | * end for the NULL. |
| 153 | */ |
| 154 | newBuffer = (DWORD*)HeapAlloc(GetProcessHeap(), |
| 155 | 0, |
| 156 | bufferSize + sizeof(WCHAR) + sizeof(DWORD)); |
| 157 | |
| 158 | /* |
| 159 | * If the memory allocation failed, return a null pointer. |
| 160 | */ |
| 161 | if (newBuffer==0) |
| 162 | return 0; |
| 163 | |
| 164 | /* |
| 165 | * Copy the length of the string in the placeholder. |
| 166 | */ |
| 167 | *newBuffer = bufferSize; |
| 168 | |
| 169 | /* |
| 170 | * Skip the byte count. |
| 171 | */ |
| 172 | newBuffer++; |
| 173 | |
| 174 | /* |
| 175 | * Copy the information in the buffer. |
| 176 | * Since it is valid to pass a NULL pointer here, we'll initialize the |
| 177 | * buffer to nul if it is the case. |
| 178 | */ |
| 179 | if (in != 0) |
| 180 | memcpy(newBuffer, in, bufferSize); |
| 181 | else |
| 182 | memset(newBuffer, 0, bufferSize); |
| 183 | |
| 184 | /* |
| 185 | * Make sure that there is a nul character at the end of the |
| 186 | * string. |
| 187 | */ |
| 188 | stringBuffer = (WCHAR*)newBuffer; |
| 189 | stringBuffer[len] = L'\0'; |
| 190 | |
| 191 | return (LPWSTR)stringBuffer; |
| 192 | } |
| 193 | |
| 194 | /****************************************************************************** |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 195 | * SysReAllocStringLen16 [OLE2DISP.5] |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 196 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 197 | int WINAPI SysReAllocStringLen16(BSTR16 *old,const char *in,int len) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 198 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 199 | BSTR16 new=SysAllocStringLen16(in,len); |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 200 | BSTR_Free(*old); |
| 201 | *old=new; |
| 202 | return 1; |
| 203 | } |
| 204 | |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 205 | |
| 206 | /****************************************************************************** |
| 207 | * SysReAllocStringLen32 [OLEAUT32.5] |
| 208 | */ |
Francois Gouget | dfc0f5e | 1999-03-13 18:13:10 +0000 | [diff] [blame] | 209 | int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* in, unsigned int len) |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 210 | { |
| 211 | /* |
| 212 | * Sanity check |
| 213 | */ |
| 214 | if (old==NULL) |
| 215 | return 0; |
| 216 | |
| 217 | /* |
| 218 | * Make sure we free the old string. |
| 219 | */ |
| 220 | if (*old!=NULL) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 221 | SysFreeString(*old); |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 222 | |
| 223 | /* |
| 224 | * Allocate the new string |
| 225 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 226 | *old = SysAllocStringLen(in, len); |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 227 | |
| 228 | return 1; |
| 229 | } |
| 230 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 231 | /****************************************************************************** |
| 232 | * SysFreeString16 [OLE2DISP.6] |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 233 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 234 | void WINAPI SysFreeString16(BSTR16 in) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 235 | { |
| 236 | BSTR_Free(in); |
| 237 | } |
| 238 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 239 | /****************************************************************************** |
| 240 | * SysFreeString32 [OLEAUT32.6] |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 241 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 242 | void WINAPI SysFreeString(BSTR in) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 243 | { |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 244 | DWORD* bufferPointer; |
Rein Klazes | 3e9608d | 1999-06-05 11:53:33 +0000 | [diff] [blame] | 245 | |
| 246 | /* NULL is a valid parameter */ |
| 247 | if(!in) return; |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 248 | |
| 249 | /* |
| 250 | * We have to be careful when we free a BSTR pointer, it points to |
| 251 | * the beginning of the string but it skips the byte count contained |
| 252 | * before the string. |
| 253 | */ |
| 254 | bufferPointer = (DWORD*)in; |
| 255 | |
| 256 | bufferPointer--; |
| 257 | |
| 258 | /* |
| 259 | * Free the memory from it's "real" origin. |
| 260 | */ |
| 261 | HeapFree(GetProcessHeap(), 0, bufferPointer); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Matthew Becker | b05264f | 1998-10-11 14:21:42 +0000 | [diff] [blame] | 264 | /****************************************************************************** |
| 265 | * SysStringLen16 [OLE2DISP.7] |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 266 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 267 | int WINAPI SysStringLen16(BSTR16 str) |
Alexandre Julliard | ded3038 | 1995-07-06 17:18:27 +0000 | [diff] [blame] | 268 | { |
| 269 | return strlen(BSTR_GetAddr(str)); |
| 270 | } |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 271 | |
Matthew Becker | 7517534 | 1998-10-18 14:39:06 +0000 | [diff] [blame] | 272 | /****************************************************************************** |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 273 | * SysStringLen32 [OLEAUT32.7] |
| 274 | * |
| 275 | * The Windows documentation states that the length returned by this function |
| 276 | * is not necessarely the same as the length returned by the _lstrlenW method. |
| 277 | * It is the same number that was passed in as the "len" parameter if the |
| 278 | * string was allocated with a SysAllocStringLen method call. |
| 279 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 280 | int WINAPI SysStringLen(BSTR str) |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 281 | { |
| 282 | DWORD* bufferPointer; |
| 283 | |
Eric Pouech | be5e3c6 | 1999-12-12 21:27:41 +0000 | [diff] [blame] | 284 | if (!str) return 0; |
Francis Beaudet | f1779ed | 1998-11-25 17:20:36 +0000 | [diff] [blame] | 285 | /* |
| 286 | * The length of the string (in bytes) is contained in a DWORD placed |
| 287 | * just before the BSTR pointer |
| 288 | */ |
| 289 | bufferPointer = (DWORD*)str; |
| 290 | |
| 291 | bufferPointer--; |
| 292 | |
| 293 | return (int)(*bufferPointer/sizeof(WCHAR)); |
| 294 | } |
| 295 | |
| 296 | /****************************************************************************** |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 297 | * SysStringByteLen [OLEAUT32.149] |
| 298 | * |
| 299 | * The Windows documentation states that the length returned by this function |
| 300 | * is not necessarely the same as the length returned by the _lstrlenW method. |
| 301 | * It is the same number that was passed in as the "len" parameter if the |
| 302 | * string was allocated with a SysAllocStringLen method call. |
| 303 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 304 | int WINAPI SysStringByteLen(BSTR str) |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 305 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 306 | return SysStringLen(str)*sizeof(WCHAR); |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | /****************************************************************************** |
Matthew Becker | 7517534 | 1998-10-18 14:39:06 +0000 | [diff] [blame] | 310 | * CreateDispTypeInfo [OLE2DISP.31] |
| 311 | */ |
Andreas Mohr | faa05bd | 1999-03-28 13:13:03 +0000 | [diff] [blame] | 312 | HRESULT WINAPI CreateDispTypeInfo16( |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 313 | INTERFACEDATA *pidata, |
| 314 | LCID lcid, |
Paul Quinn | ea1640f | 1999-03-10 18:03:53 +0000 | [diff] [blame] | 315 | ITypeInfo **pptinfo |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 316 | ) { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 317 | FIXME("(%p,%ld,%p),stub\n",pidata,lcid,pptinfo); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 318 | return 0; |
| 319 | } |
| 320 | |
Matthew Becker | 7517534 | 1998-10-18 14:39:06 +0000 | [diff] [blame] | 321 | /****************************************************************************** |
| 322 | * RegisterActiveObject [OLE2DISP.35] |
| 323 | */ |
Andreas Mohr | faa05bd | 1999-03-28 13:13:03 +0000 | [diff] [blame] | 324 | HRESULT WINAPI RegisterActiveObject16( |
Paul Quinn | ea1640f | 1999-03-10 18:03:53 +0000 | [diff] [blame] | 325 | IUnknown *punk, REFCLSID rclsid, DWORD dwFlags, unsigned long *pdwRegister |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 326 | ) { |
Alexandre Julliard | 681c75b | 2000-01-18 05:09:49 +0000 | [diff] [blame] | 327 | FIXME("(%p,%s,0x%08lx,%p):stub\n",punk,debugstr_guid(rclsid),dwFlags,pdwRegister); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 328 | return 0; |
| 329 | } |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 330 | |
| 331 | /****************************************************************************** |
| 332 | * OleTranslateColor [OLEAUT32.421] |
Thuy Nguyen | ad7e9c4 | 1999-05-08 09:37:59 +0000 | [diff] [blame] | 333 | * |
| 334 | * Converts an OLE_COLOR to a COLORREF. |
| 335 | * See the documentation for conversion rules. |
| 336 | * pColorRef can be NULL. In that case the user only wants to test the |
| 337 | * conversion. |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 338 | */ |
Eric Pouech | 853043b | 2000-02-18 19:06:00 +0000 | [diff] [blame] | 339 | HRESULT WINAPI OleTranslateColor( |
| 340 | OLE_COLOR clr, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 341 | HPALETTE hpal, |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 342 | COLORREF* pColorRef) |
| 343 | { |
Thuy Nguyen | ad7e9c4 | 1999-05-08 09:37:59 +0000 | [diff] [blame] | 344 | COLORREF colorref; |
| 345 | BYTE b = HIBYTE(HIWORD(clr)); |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 346 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 347 | TRACE("(%08lx, %d, %p):stub\n", clr, hpal, pColorRef); |
Thuy Nguyen | ad7e9c4 | 1999-05-08 09:37:59 +0000 | [diff] [blame] | 348 | |
| 349 | /* |
| 350 | * In case pColorRef is NULL, provide our own to simplify the code. |
| 351 | */ |
| 352 | if (pColorRef == NULL) |
| 353 | pColorRef = &colorref; |
| 354 | |
| 355 | switch (b) |
| 356 | { |
| 357 | case 0x00: |
| 358 | { |
| 359 | if (hpal != 0) |
| 360 | *pColorRef = PALETTERGB(GetRValue(clr), |
| 361 | GetGValue(clr), |
| 362 | GetBValue(clr)); |
| 363 | else |
| 364 | *pColorRef = clr; |
| 365 | |
| 366 | break; |
| 367 | } |
| 368 | |
| 369 | case 0x01: |
| 370 | { |
| 371 | if (hpal != 0) |
| 372 | { |
| 373 | PALETTEENTRY pe; |
| 374 | /* |
| 375 | * Validate the palette index. |
| 376 | */ |
| 377 | if (GetPaletteEntries(hpal, LOWORD(clr), 1, &pe) == 0) |
| 378 | return E_INVALIDARG; |
| 379 | } |
| 380 | |
| 381 | *pColorRef = clr; |
| 382 | |
| 383 | break; |
| 384 | } |
| 385 | |
| 386 | case 0x02: |
| 387 | *pColorRef = clr; |
| 388 | break; |
| 389 | |
| 390 | case 0x80: |
| 391 | { |
| 392 | int index = LOBYTE(LOWORD(clr)); |
| 393 | |
| 394 | /* |
| 395 | * Validate GetSysColor index. |
| 396 | */ |
| 397 | if ((index < COLOR_SCROLLBAR) || (index > COLOR_GRADIENTINACTIVECAPTION)) |
| 398 | return E_INVALIDARG; |
| 399 | |
| 400 | *pColorRef = GetSysColor(index); |
| 401 | |
| 402 | break; |
| 403 | } |
| 404 | |
| 405 | default: |
| 406 | return E_INVALIDARG; |
| 407 | } |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 408 | |
| 409 | return S_OK; |
| 410 | } |
| 411 | |
Stephane Lussier | 986de4b | 1999-03-12 17:02:32 +0000 | [diff] [blame] | 412 | /****************************************************************************** |
| 413 | * SysAllocStringByteLen [OLEAUT32.150] |
| 414 | * |
| 415 | */ |
| 416 | BSTR WINAPI SysAllocStringByteLen(char *in, int len) |
| 417 | { |
| 418 | DWORD* newBuffer; |
| 419 | char* stringBuffer; |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 420 | |
Stephane Lussier | 986de4b | 1999-03-12 17:02:32 +0000 | [diff] [blame] | 421 | /* |
| 422 | * Allocate a new buffer to hold the string. |
| 423 | * dont't forget to keep an empty spot at the begining of the |
| 424 | * buffer for the character count and an extra character at the |
| 425 | * end for the NULL. |
| 426 | */ |
| 427 | newBuffer = (DWORD*)HeapAlloc(GetProcessHeap(), |
| 428 | 0, |
| 429 | len + sizeof(WCHAR) + sizeof(DWORD)); |
| 430 | |
| 431 | /* |
| 432 | * If the memory allocation failed, return a null pointer. |
| 433 | */ |
| 434 | if (newBuffer==0) |
| 435 | return 0; |
| 436 | |
| 437 | /* |
| 438 | * Copy the length of the string in the placeholder. |
| 439 | */ |
| 440 | *newBuffer = len; |
| 441 | |
| 442 | /* |
| 443 | * Skip the byte count. |
| 444 | */ |
| 445 | newBuffer++; |
| 446 | |
| 447 | /* |
| 448 | * Copy the information in the buffer. |
| 449 | * Since it is valid to pass a NULL pointer here, we'll initialize the |
| 450 | * buffer to nul if it is the case. |
| 451 | */ |
| 452 | if (in != 0) |
| 453 | memcpy(newBuffer, in, len); |
| 454 | |
| 455 | /* |
| 456 | * Make sure that there is a nul character at the end of the |
| 457 | * string. |
| 458 | */ |
| 459 | stringBuffer = (char *)newBuffer; |
| 460 | stringBuffer[len] = 0; |
| 461 | stringBuffer[len+1] = 0; |
| 462 | |
| 463 | return (LPWSTR)stringBuffer; |
| 464 | } |
Francis Beaudet | eb5a29b | 1999-02-20 16:48:53 +0000 | [diff] [blame] | 465 | |
| 466 | |