Changeset 6711 for trunk/src/ole32/oleobj.c
- Timestamp:
- Sep 15, 2001, 11:32:00 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/oleobj.c
r6648 r6711 1 /* $Id: oleobj.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */2 1 /* 3 * 2 * OLE2 COM objects 4 3 * 5 * 4 * Copyright 1998 Eric Kohl 6 5 * Copyright 1999 Francis Beaudet 7 6 */ … … 13 12 #include "debugtools.h" 14 13 #include "oleidl.h" 14 15 #ifdef __WIN32OS2__ 16 #undef FIXME 17 #undef TRACE 18 #ifdef DEBUG 19 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 20 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 21 #else 22 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 23 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 24 #endif 25 #endif 15 26 16 27 DEFAULT_DEBUG_CHANNEL(ole); … … 72 83 73 84 lpoah= (OleAdviseHolderImpl*)HeapAlloc(GetProcessHeap(), 74 75 76 85 0, 86 sizeof(OleAdviseHolderImpl)); 87 77 88 ICOM_VTBL(lpoah) = &oahvt; 78 89 lpoah->ref = 1; 79 90 lpoah->maxSinks = INITIAL_SINKS; 80 91 lpoah->arrayOfSinks = HeapAlloc(GetProcessHeap(), 81 82 92 0, 93 lpoah->maxSinks * sizeof(IAdviseSink*)); 83 94 84 95 for (index = 0; index < lpoah->maxSinks; index++) … … 106 117 } 107 118 } 108 119 109 120 HeapFree(GetProcessHeap(), 110 111 112 121 0, 122 ptrToDestroy->arrayOfSinks); 123 113 124 114 125 HeapFree(GetProcessHeap(), 115 116 126 0, 127 ptrToDestroy); 117 128 } 118 129 … … 122 133 static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface( 123 134 LPOLEADVISEHOLDER iface, 124 REFIID riid, 135 REFIID riid, 125 136 LPVOID* ppvObj) 126 137 { 127 ICOM_THIS(OleAdviseHolderImpl, iface); 138 ICOM_THIS(OleAdviseHolderImpl, iface); 128 139 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObj); 129 140 /* … … 135 146 *ppvObj = NULL; 136 147 137 if (IsEqualIID(riid, &IID_IUnknown)) 148 if (IsEqualIID(riid, &IID_IUnknown)) 138 149 { 139 150 /* IUnknown */ 140 *ppvObj = This; 141 } 142 else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 151 *ppvObj = This; 152 } 153 else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 143 154 { 144 155 /* IOleAdviseHolder */ … … 148 159 if(*ppvObj == NULL) 149 160 return E_NOINTERFACE; 150 161 151 162 /* 152 163 * A successful QI always increments the reference count. … … 163 174 LPOLEADVISEHOLDER iface) 164 175 { 165 ICOM_THIS(OleAdviseHolderImpl, iface); 166 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 176 ICOM_THIS(OleAdviseHolderImpl, iface); 177 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 167 178 return ++(This->ref); 168 179 } … … 174 185 LPOLEADVISEHOLDER iface) 175 186 { 176 ICOM_THIS(OleAdviseHolderImpl, iface); 177 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 187 ICOM_THIS(OleAdviseHolderImpl, iface); 188 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 178 189 This->ref--; 179 190 … … 197 208 { 198 209 DWORD index; 199 200 ICOM_THIS(OleAdviseHolderImpl, iface); 210 211 ICOM_THIS(OleAdviseHolderImpl, iface); 201 212 202 213 TRACE("(%p)->(%p, %p)\n", This, pAdvise, pdwConnection); … … 207 218 if (pdwConnection==NULL) 208 219 return E_POINTER; 209 220 210 221 *pdwConnection = 0; 211 222 … … 228 239 This->maxSinks+=INITIAL_SINKS; 229 240 230 This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 231 232 233 241 This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 242 0, 243 This->arrayOfSinks, 244 This->maxSinks*sizeof(IAdviseSink*)); 234 245 235 246 for (i=index;i < This->maxSinks; i++) 236 This->arrayOfSinks[i]=0; 247 This->arrayOfSinks[i]=0; 237 248 } 238 249 … … 259 270 */ 260 271 static HRESULT WINAPI OleAdviseHolderImpl_Unadvise( 261 LPOLEADVISEHOLDER iface, 272 LPOLEADVISEHOLDER iface, 262 273 DWORD dwConnection) 263 274 { 264 ICOM_THIS(OleAdviseHolderImpl, iface); 275 ICOM_THIS(OleAdviseHolderImpl, iface); 265 276 266 277 TRACE("(%p)->(%lu)\n", This, dwConnection); 267 278 268 279 /* 269 * So we don't return 0 as a cookie, the index was 280 * So we don't return 0 as a cookie, the index was 270 281 * incremented by 1 in OleAdviseHolderImpl_Advise 271 282 * we have to compensate. 272 283 */ 273 284 dwConnection--; 274 285 275 286 /* 276 287 * Check for invalid cookies. 277 288 */ 278 if ( (dwConnection < 0) || 289 if ( (dwConnection < 0) || 279 290 (dwConnection >= This->maxSinks) ) 280 291 return OLE_E_NOCONNECTION; … … 298 309 OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise) 299 310 { 300 ICOM_THIS(OleAdviseHolderImpl, iface); 311 ICOM_THIS(OleAdviseHolderImpl, iface); 301 312 FIXME("(%p)->(%p)\n", This, ppenumAdvise); 302 313 … … 312 323 OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk) 313 324 { 314 ICOM_THIS(OleAdviseHolderImpl, iface); 325 ICOM_THIS(OleAdviseHolderImpl, iface); 315 326 FIXME("(%p)->(%p)\n", This, pmk); 316 327 … … 325 336 OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER iface) 326 337 { 327 ICOM_THIS(OleAdviseHolderImpl, iface); 338 ICOM_THIS(OleAdviseHolderImpl, iface); 328 339 FIXME("(%p)\n", This); 329 340 … … 337 348 OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER iface) 338 349 { 339 ICOM_THIS(OleAdviseHolderImpl, iface); 350 ICOM_THIS(OleAdviseHolderImpl, iface); 340 351 FIXME("(%p)\n", This); 341 352 … … 351 362 FORMATETC fmat; 352 363 DWORD advf; 353 } DataAdviseConnection; 364 } DataAdviseConnection; 354 365 355 366 typedef struct DataAdviseHolder … … 368 379 static void DataAdviseHolder_Destructor(DataAdviseHolder* ptrToDestroy); 369 380 static HRESULT WINAPI DataAdviseHolder_QueryInterface( 370 371 372 373 static ULONG WINAPI DataAdviseHolder_AddRef( 381 IDataAdviseHolder* iface, 382 REFIID riid, 383 void** ppvObject); 384 static ULONG WINAPI DataAdviseHolder_AddRef( 374 385 IDataAdviseHolder* iface); 375 static ULONG WINAPI DataAdviseHolder_Release( 386 static ULONG WINAPI DataAdviseHolder_Release( 376 387 IDataAdviseHolder* iface); 377 static HRESULT WINAPI DataAdviseHolder_Advise( 388 static HRESULT WINAPI DataAdviseHolder_Advise( 378 389 IDataAdviseHolder* iface, 379 IDataObject* pDataObject, 380 FORMATETC* pFetc, 381 DWORD advf, 382 IAdviseSink* pAdvise, 383 384 static HRESULT WINAPI DataAdviseHolder_Unadvise( 390 IDataObject* pDataObject, 391 FORMATETC* pFetc, 392 DWORD advf, 393 IAdviseSink* pAdvise, 394 DWORD* pdwConnection); 395 static HRESULT WINAPI DataAdviseHolder_Unadvise( 385 396 IDataAdviseHolder* iface, 386 387 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 388 IDataAdviseHolder* iface, 389 390 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 391 IDataAdviseHolder* iface, 392 IDataObject* pDataObject, 393 DWORD dwReserved, 394 397 DWORD dwConnection); 398 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 399 IDataAdviseHolder* iface, 400 IEnumSTATDATA** ppenumAdvise); 401 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 402 IDataAdviseHolder* iface, 403 IDataObject* pDataObject, 404 DWORD dwReserved, 405 DWORD advf); 395 406 396 407 /************************************************************************** … … 417 428 418 429 newHolder = (DataAdviseHolder*)HeapAlloc(GetProcessHeap(), 419 420 421 430 0, 431 sizeof(DataAdviseHolder)); 432 422 433 ICOM_VTBL(newHolder) = &DataAdviseHolderImpl_VTable; 423 434 newHolder->ref = 1; 424 435 newHolder->maxCons = INITIAL_SINKS; 425 436 newHolder->Connections = HeapAlloc(GetProcessHeap(), 426 427 newHolder->maxCons * 428 437 HEAP_ZERO_MEMORY, 438 newHolder->maxCons * 439 sizeof(DataAdviseConnection)); 429 440 430 441 TRACE("returning %p\n", newHolder); … … 448 459 } 449 460 } 450 461 451 462 HeapFree(GetProcessHeap(), 0, ptrToDestroy->Connections); 452 463 HeapFree(GetProcessHeap(), 0, ptrToDestroy); … … 463 474 void** ppvObject) 464 475 { 465 ICOM_THIS(DataAdviseHolder, iface); 476 ICOM_THIS(DataAdviseHolder, iface); 466 477 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject); 467 478 /* … … 470 481 if ( (This==0) || (ppvObject==0) ) 471 482 return E_INVALIDARG; 472 483 473 484 /* 474 485 * Initialize the return parameter. … … 484 495 *ppvObject = iface; 485 496 } 486 497 487 498 /* 488 499 * Check that we obtained an interface. … … 492 503 return E_NOINTERFACE; 493 504 } 494 505 495 506 /* 496 507 * Query Interface always increases the reference count by one when it is 497 * successful. 508 * successful. 498 509 */ 499 510 IUnknown_AddRef((IUnknown*)*ppvObject); 500 511 501 return S_OK;; 512 return S_OK;; 502 513 } 503 514 … … 507 518 * See Windows documentation for more details on IUnknown methods. 508 519 */ 509 static ULONG WINAPI DataAdviseHolder_AddRef( 520 static ULONG WINAPI DataAdviseHolder_AddRef( 510 521 IDataAdviseHolder* iface) 511 522 { 512 ICOM_THIS(DataAdviseHolder, iface); 523 ICOM_THIS(DataAdviseHolder, iface); 513 524 TRACE("(%p) (ref=%ld)\n", This, This->ref); 514 525 This->ref++; … … 522 533 * See Windows documentation for more details on IUnknown methods. 523 534 */ 524 static ULONG WINAPI DataAdviseHolder_Release( 535 static ULONG WINAPI DataAdviseHolder_Release( 525 536 IDataAdviseHolder* iface) 526 537 { … … 542 553 return 0; 543 554 } 544 555 545 556 return This->ref; 546 557 } … … 552 563 static HRESULT WINAPI DataAdviseHolder_Advise( 553 564 IDataAdviseHolder* iface, 554 IDataObject* pDataObject, 555 FORMATETC* pFetc, 556 DWORD advf, 557 IAdviseSink* pAdvise, 565 IDataObject* pDataObject, 566 FORMATETC* pFetc, 567 DWORD advf, 568 IAdviseSink* pAdvise, 558 569 DWORD* pdwConnection) 559 570 { 560 571 DWORD index; 561 562 ICOM_THIS(DataAdviseHolder, iface); 572 573 ICOM_THIS(DataAdviseHolder, iface); 563 574 564 575 TRACE("(%p)->(%p, %p, %08lx, %p, %p)\n", This, pDataObject, pFetc, advf, 565 576 pAdvise, pdwConnection); 566 577 /* 567 578 * Sanity check … … 569 580 if (pdwConnection==NULL) 570 581 return E_POINTER; 571 582 572 583 *pdwConnection = 0; 573 584 … … 588 599 This->maxCons+=INITIAL_SINKS; 589 600 This->Connections = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 590 591 601 This->Connections, 602 This->maxCons*sizeof(DataAdviseConnection)); 592 603 } 593 604 /* … … 617 628 * DataAdviseHolder_Unadvise 618 629 */ 619 static HRESULT WINAPI DataAdviseHolder_Unadvise( 630 static HRESULT WINAPI DataAdviseHolder_Unadvise( 620 631 IDataAdviseHolder* iface, 621 632 DWORD dwConnection) 622 633 { 623 ICOM_THIS(DataAdviseHolder, iface); 634 ICOM_THIS(DataAdviseHolder, iface); 624 635 625 636 TRACE("(%p)->(%lu)\n", This, dwConnection); 626 637 627 638 /* 628 * So we don't return 0 as a cookie, the index was 639 * So we don't return 0 as a cookie, the index was 629 640 * incremented by 1 in OleAdviseHolderImpl_Advise 630 641 * we have to compensate. 631 642 */ 632 643 dwConnection--; 633 644 634 645 /* 635 646 * Check for invalid cookies. 636 647 */ 637 if ( (dwConnection < 0) || 648 if ( (dwConnection < 0) || 638 649 (dwConnection >= This->maxCons) ) 639 650 return OLE_E_NOCONNECTION; … … 650 661 } 651 662 652 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 653 IDataAdviseHolder* iface, 663 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 664 IDataAdviseHolder* iface, 654 665 IEnumSTATDATA** ppenumAdvise) 655 666 { 656 ICOM_THIS(DataAdviseHolder, iface); 667 ICOM_THIS(DataAdviseHolder, iface); 657 668 658 669 FIXME("(%p)->(%p)\n", This, ppenumAdvise); … … 663 674 * DataAdviseHolder_SendOnDataChange 664 675 */ 665 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 666 IDataAdviseHolder* iface, 667 IDataObject* pDataObject, 668 DWORD dwReserved, 676 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 677 IDataAdviseHolder* iface, 678 IDataObject* pDataObject, 679 DWORD dwReserved, 669 680 DWORD advf) 670 681 { 671 ICOM_THIS(DataAdviseHolder, iface); 682 ICOM_THIS(DataAdviseHolder, iface); 672 683 DWORD index; 673 684 STGMEDIUM stg; … … 679 690 if(This->Connections[index].sink != NULL) { 680 691 if(!(This->Connections[index].advf & ADVF_NODATA)) { 681 682 683 684 685 692 TRACE("Calling IDataObject_GetData\n"); 693 res = IDataObject_GetData(pDataObject, 694 &(This->Connections[index].fmat), 695 &stg); 696 TRACE("returns %08lx\n", res); 686 697 } 687 698 TRACE("Calling IAdviseSink_OnDataChange\n"); 688 699 IAdviseSink_OnDataChange(This->Connections[index].sink, 689 690 700 &(This->Connections[index].fmat), 701 &stg); 691 702 TRACE("Done IAdviseSink_OnDataChange\n"); 692 703 if(This->Connections[index].advf & ADVF_ONLYONCE) { 693 694 704 TRACE("Removing connection\n"); 705 DataAdviseHolder_Unadvise(iface, index+1); 695 706 } 696 707 }
Note:
See TracChangeset
for help on using the changeset viewer.