Changeset 6504 for trunk/src


Ignore:
Timestamp:
Aug 10, 2001, 9:22:33 PM (24 years ago)
Author:
sandervl
Message:

olepicture + typelib wine updates

Location:
trunk/src/oleaut32
Files:
2 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/oleaut32/makefile

    r6311 r6504  
    1 # $Id: makefile,v 1.28 2001-07-12 17:16:12 sandervl Exp $
     1# $Id: makefile,v 1.29 2001-08-10 19:22:18 sandervl Exp $
    22
    33#
     
    3535#$(OBJDIR)\iPictureEmf.obj \
    3636$(OBJDIR)\typelib.obj \
    37 $(OBJDIR)\itypelib.obj \
    38 $(OBJDIR)\itypecomp.obj \
    39 $(OBJDIR)\itypeinfo.obj \
     37#$(OBJDIR)\itypelib.obj \
     38#$(OBJDIR)\itypecomp.obj \
     39#$(OBJDIR)\itypeinfo.obj \
    4040$(OBJDIR)\hash.obj \
    4141$(OBJDIR)\safearray.obj \
  • trunk/src/oleaut32/oleaut32.cpp

    r6311 r6504  
    1 /* $Id: oleaut32.cpp,v 1.8 2001-07-12 17:16:12 sandervl Exp $ */
     1/* $Id: oleaut32.cpp,v 1.9 2001-08-10 19:22:23 sandervl Exp $ */
    22/*
    33 * OLEAUT32
     
    3030{
    3131#ifdef DEBUG
    32     OpenPrivateLogFileTypelib();
     32//    OpenPrivateLogFileTypelib();
    3333#endif
    3434}
     
    3939{
    4040#ifdef DEBUG
    41     ClosePrivateLogFileTypelib();
     41//    ClosePrivateLogFileTypelib();
    4242#endif
    4343}
  • trunk/src/oleaut32/olepicture.c

    r5856 r6504  
    55 *
    66 * Copyright 2000 Huw D M Davies for CodeWeavers.
     7 * Copyright 2001 Marcus Meissner
    78 *
    89 *
    910 * BUGS
    1011 *
    11  * Only implements PICTYPE_BITMAP.
    12  * Most methods are just stubs.
    13  * Doesn't even expose IPersistStream, IConnectionPointContainer.
     12 * Support PICTYPE_BITMAP and PICTYPE_ICON, altough only bitmaps very well..
     13 * Lots of methods are just stubs.
    1414 *
    1515 *
     
    2828#endif
    2929
     30#include "config.h"
     31
     32#include <unistd.h>
     33#include <stdio.h>
     34#include <string.h>
    3035#include "winerror.h"
    3136#include "winbase.h"
     
    3439#include "ole2.h"
    3540#include "olectl.h"
     41#include "oleauto.h"
    3642#include "wine/obj_picture.h"
     43#include "wine/obj_connection.h"
     44#include "connpt.h"
    3745#include "debugtools.h"
     46
     47#include "wine/wingdi16.h"
     48#include "cursoricon.h"
     49
     50#ifdef HAVE_LIBJPEG
     51/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
     52#define XMD_H
     53#ifdef HAVE_JPEGLIB_H
     54# include <jpeglib.h>
     55#endif
     56#endif
    3857
    3958#ifdef __WIN32OS2__
     
    6483    ICOM_VTABLE(IDispatch)      *lpvtbl2;
    6584    ICOM_VTABLE(IPersistStream) *lpvtbl3;
     85    ICOM_VTABLE(IConnectionPointContainer) *lpvtbl4;
    6686
    6787  /* Object referenece count */
     
    82102    OLE_YSIZE_HIMETRIC himetricHeight;
    83103
     104    IConnectionPoint *pCP;
     105
     106    BOOL keepOrigFormat;
     107    HDC hDCCur;
    84108} OLEPictureImpl;
    85109
     
    89113#define ICOM_THIS_From_IDispatch(impl, name) \
    90114    impl *This = (impl*)(((char*)name)-sizeof(void*));
    91 
    92115#define ICOM_THIS_From_IPersistStream(impl, name) \
    93116    impl *This = (impl*)(((char*)name)-2*sizeof(void*));
     117#define ICOM_THIS_From_IConnectionPointContainer(impl, name) \
     118    impl *This = (impl*)(((char*)name)-3*sizeof(void*));
    94119
    95120/*
     
    99124static ICOM_VTABLE(IDispatch) OLEPictureImpl_IDispatch_VTable;
    100125static ICOM_VTABLE(IPersistStream) OLEPictureImpl_IPersistStream_VTable;
     126static ICOM_VTABLE(IConnectionPointContainer) OLEPictureImpl_IConnectionPointContainer_VTable;
    101127
    102128/***********************************************************************
     
    104130 */
    105131
     132static void OLEPictureImpl_SetBitmap(OLEPictureImpl*This) {
     133  BITMAP bm;
     134  HDC hdcRef;
     135
     136  TRACE("bitmap handle %08x\n", This->desc.u.bmp.hbitmap);
     137  if(GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) {
     138    ERR("GetObject fails\n");
     139    return;
     140  }
     141  This->origWidth = bm.bmWidth;
     142  This->origHeight = bm.bmHeight;
     143  /* The width and height are stored in HIMETRIC units (0.01 mm),
     144     so we take our pixel width divide by pixels per inch and
     145     multiply by 25.4 * 100 */
     146  /* Should we use GetBitmapDimension if available? */
     147  hdcRef = CreateCompatibleDC(0);
     148  This->himetricWidth =(bm.bmWidth *2540)/GetDeviceCaps(hdcRef, LOGPIXELSX);
     149  This->himetricHeight=(bm.bmHeight*2540)/GetDeviceCaps(hdcRef, LOGPIXELSY);
     150  DeleteDC(hdcRef);
     151}
     152
    106153/************************************************************************
    107154 * OLEPictureImpl_Construct
     
    116163{
    117164  OLEPictureImpl* newObject = 0;
    118   TRACE("(%p) type = %d\n", pictDesc, pictDesc->picType);
     165
     166  if (pictDesc)
     167      TRACE("(%p) type = %d\n", pictDesc, pictDesc->picType);
    119168
    120169  /*
     
    132181  newObject->lpvtbl2 = &OLEPictureImpl_IDispatch_VTable;
    133182  newObject->lpvtbl3 = &OLEPictureImpl_IPersistStream_VTable;
    134  
     183  newObject->lpvtbl4 = &OLEPictureImpl_IConnectionPointContainer_VTable;
     184
     185  CreateConnectionPoint((IUnknown*)newObject,&IID_IPropertyNotifySink,&newObject->pCP);
     186
    135187  /*
    136188   * Start with one reference count. The caller of this function
    137189   * must release the interface pointer when it is done.
    138190   */
    139   newObject->ref = 1;
    140 
    141   newObject->fOwn = fOwn;
    142 
    143   if(pictDesc->cbSizeofstruct != sizeof(PICTDESC)) {
    144       FIXME("struct size = %d\n", pictDesc->cbSizeofstruct);
    145   }
    146   memcpy(&newObject->desc, pictDesc, sizeof(PICTDESC));
    147 
    148   switch(pictDesc->picType) {
    149   case PICTYPE_BITMAP:
    150     {
    151       BITMAP bm;
    152       HDC hdcRef;
    153 
    154       TRACE("bitmap handle %08x\n", pictDesc->u.bmp.hbitmap);
    155       if(GetObjectA(pictDesc->u.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) {
    156         ERR("GetObject fails\n");
     191  newObject->ref        = 1;
     192  newObject->hDCCur     = 0;
     193
     194  newObject->fOwn       = fOwn;
     195
     196  /* dunno about original value */
     197  newObject->keepOrigFormat = TRUE;
     198
     199  if (pictDesc) {
     200      if(pictDesc->cbSizeofstruct != sizeof(PICTDESC)) {
     201          FIXME("struct size = %d\n", pictDesc->cbSizeofstruct);
     202      }
     203      memcpy(&newObject->desc, pictDesc, sizeof(PICTDESC));
     204
     205
     206      switch(pictDesc->picType) {
     207      case PICTYPE_BITMAP:
     208        OLEPictureImpl_SetBitmap(newObject);
     209        break;
     210
     211      case PICTYPE_METAFILE:
     212        TRACE("metafile handle %08x\n", pictDesc->u.wmf.hmeta);
     213        newObject->himetricWidth = pictDesc->u.wmf.xExt;
     214        newObject->himetricHeight = pictDesc->u.wmf.yExt;
     215        break;
     216
     217      case PICTYPE_ICON:
     218      case PICTYPE_ENHMETAFILE:
     219      default:
     220        FIXME("Unsupported type %d\n", pictDesc->picType);
     221        newObject->himetricWidth = newObject->himetricHeight = 0;
    157222        break;
    158223      }
    159 
    160       newObject->origWidth = bm.bmWidth;
    161       newObject->origHeight = bm.bmHeight;
    162 
    163       /* The width and height are stored in HIMETRIC units (0.01 mm),
    164          so we take our pixel width divide by pixels per inch and
    165          multiply by 25.4 * 100 */
    166 
    167       /* Should we use GetBitmapDimension if available? */
    168 
    169       hdcRef = CreateCompatibleDC(0);
    170 
    171       newObject->himetricWidth = (bm.bmWidth * 2540) /
    172         GetDeviceCaps(hdcRef, LOGPIXELSX);
    173       newObject->himetricHeight = (bm.bmHeight * 2540) /
    174         GetDeviceCaps(hdcRef, LOGPIXELSY);
    175       DeleteDC(hdcRef);
    176     }
    177     break;
    178 
    179   case PICTYPE_METAFILE:
    180     TRACE("metafile handle %08x\n", pictDesc->u.wmf.hmeta);
    181     newObject->himetricWidth = pictDesc->u.wmf.xExt;
    182     newObject->himetricHeight = pictDesc->u.wmf.yExt;
    183     break;
    184 
    185   case PICTYPE_ICON:
    186   case PICTYPE_ENHMETAFILE:
    187   default:
    188     FIXME("Unsupported type %d\n", pictDesc->picType);
    189     newObject->himetricWidth = newObject->himetricHeight = 0;
    190     break;
     224  } else {
     225      newObject->desc.picType = PICTYPE_UNINITIALIZED;
    191226  }
    192227   
     
    272307    *ppvObject = (IDispatch*)&(This->lpvtbl2);
    273308  }
    274   /*  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
     309  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
    275310  {
    276311  *ppvObject = (IPersistStream*)&(This->lpvtbl3);
    277   }*/
    278  
     312  }
     313  else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0)
     314  {
     315  *ppvObject = (IConnectionPointContainer*)&(This->lpvtbl4);
     316  }
    279317  /*
    280318   * Check that we obtained an interface.
     
    294332  return S_OK;;
    295333}
    296        
     334/***********************************************************************
     335 *    OLEPicture_SendNotify (internal)
     336 *
     337 * Sends notification messages of changed properties to any interested
     338 * connections.
     339 */
     340static void OLEPicture_SendNotify(OLEPictureImpl* this, DISPID dispID)
     341{
     342  IEnumConnections *pEnum;
     343  CONNECTDATA CD;
     344
     345  if (IConnectionPoint_EnumConnections(this->pCP, &pEnum))
     346      return;
     347  while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
     348    IPropertyNotifySink *sink;
     349
     350    IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
     351    IPropertyNotifySink_OnChanged(sink, dispID);
     352    IPropertyNotifySink_Release(sink);
     353    IUnknown_Release(CD.pUnk);
     354  }
     355  IEnumConnections_Release(pEnum);
     356  return;
     357}
     358
    297359/************************************************************************
    298360 * OLEPictureImpl_AddRef (IUnknown)
     
    434496          prcWBounds->right, prcWBounds->bottom);
    435497
     498  /*
     499   * While the documentation suggests this to be here (or after rendering?)
     500   * it does cause an endless recursion in my sample app. -MM 20010804
     501  OLEPicture_SendNotify(This,DISPID_PICT_RENDER);
     502   */
     503
    436504  switch(This->desc.picType) {
    437505  case PICTYPE_BITMAP:
     
    458526    }
    459527    break;
     528  case PICTYPE_ICON:
     529    FIXME("Not quite correct implementation of rendering icons...\n");
     530    DrawIcon(hdc,x,y,This->desc.u.icon.hicon);
     531    break;
    460532
    461533  case PICTYPE_METAFILE:
    462   case PICTYPE_ICON:
    463534  case PICTYPE_ENHMETAFILE:
    464535  default:
     
    466537    return E_NOTIMPL;
    467538  }
    468 
    469539  return S_OK;
    470540}
     
    478548  ICOM_THIS(OLEPictureImpl, iface);
    479549  FIXME("(%p)->(%08x): stub\n", This, hpal);
     550  OLEPicture_SendNotify(This,DISPID_PICT_HPAL);
    480551  return E_NOTIMPL;
    481552}
     
    488559{
    489560  ICOM_THIS(OLEPictureImpl, iface);
    490   FIXME("(%p)->(%p): stub\n", This, phdc);
    491   return E_NOTIMPL;
     561  TRACE("(%p), returning %x\n", This, This->hDCCur);
     562  if (phdc) *phdc = This->hDCCur;
     563  return S_OK;
    492564}
    493565
     
    501573{
    502574  ICOM_THIS(OLEPictureImpl, iface);
    503   FIXME("(%p)->(%08x, %p, %p): stub\n", This, hdcIn, phdcOut, phbmpOut);
    504   return E_NOTIMPL;
     575  TRACE("(%p)->(%08x, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);
     576  if (This->desc.picType == PICTYPE_BITMAP) {
     577      SelectObject(hdcIn,This->desc.u.bmp.hbitmap);
     578
     579      if (phdcOut)
     580          *phdcOut = This->hDCCur;
     581      This->hDCCur = hdcIn;
     582      if (phbmpOut)
     583          *phbmpOut = This->desc.u.bmp.hbitmap;
     584      return S_OK;
     585  } else {
     586      FIXME("Don't know how to select picture type %d\n",This->desc.picType);
     587      return E_FAIL;
     588  }
    505589}
    506590
     
    512596{
    513597  ICOM_THIS(OLEPictureImpl, iface);
    514   FIXME("(%p)->(%p): stub\n", This, pfKeep);
    515   return E_NOTIMPL;
     598  TRACE("(%p)->(%p)\n", This, pfKeep);
     599  if (!pfKeep)
     600      return E_POINTER;
     601  *pfKeep = This->keepOrigFormat;
     602  return S_OK;
    516603}
    517604
     
    523610{
    524611  ICOM_THIS(OLEPictureImpl, iface);
    525   FIXME("(%p)->(%d): stub\n", This, keep);
    526   return E_NOTIMPL;
     612  TRACE("(%p)->(%d)\n", This, keep);
     613  This->keepOrigFormat = keep;
     614  /* FIXME: what DISPID notification here? */
     615  return S_OK;
    527616}
    528617
     
    533622{
    534623  ICOM_THIS(OLEPictureImpl, iface);
    535   FIXME("(%p)->(): stub\n", This);
    536   return E_NOTIMPL;
     624  TRACE("(%p)->()\n", This);
     625  OLEPicture_SendNotify(This,DISPID_PICT_HANDLE);
     626  return S_OK;
    537627}
    538628
     
    557647{
    558648  ICOM_THIS(OLEPictureImpl, iface);
    559   FIXME("(%p)->(%p): stub\n", This, pdwAttr);
     649  TRACE("(%p)->(%p).\n", This, pdwAttr);
     650  *pdwAttr = 0;
     651  switch (This->desc.picType) {
     652  case PICTYPE_BITMAP:  break;  /* not 'truely' scalable, see MSDN. */
     653  case PICTYPE_ICON: *pdwAttr     = PICTURE_TRANSPARENT;break;
     654  case PICTYPE_METAFILE: *pdwAttr = PICTURE_TRANSPARENT|PICTURE_SCALABLE;break;
     655  default:FIXME("Unknown pictype %d\n",This->desc.picType);break;
     656  }
     657  return S_OK;
     658}
     659
     660
     661/************************************************************************
     662 *    IConnectionPointContainer
     663 */
     664
     665static HRESULT WINAPI OLEPictureImpl_IConnectionPointContainer_QueryInterface(
     666  IConnectionPointContainer* iface,
     667  REFIID riid,
     668  VOID** ppvoid
     669) {
     670  ICOM_THIS_From_IConnectionPointContainer(IPicture,iface);
     671
     672  return IPicture_QueryInterface(This,riid,ppvoid);
     673}
     674
     675static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_AddRef(
     676  IConnectionPointContainer* iface)
     677{
     678  ICOM_THIS_From_IConnectionPointContainer(IPicture, iface);
     679
     680  return IPicture_AddRef(This);
     681}
     682
     683static ULONG WINAPI OLEPictureImpl_IConnectionPointContainer_Release(
     684  IConnectionPointContainer* iface)
     685{
     686  ICOM_THIS_From_IConnectionPointContainer(IPicture, iface);
     687
     688  return IPicture_Release(This);
     689}
     690
     691static HRESULT WINAPI OLEPictureImpl_EnumConnectionPoints(
     692  IConnectionPointContainer* iface,
     693  IEnumConnectionPoints** ppEnum
     694) {
     695  ICOM_THIS_From_IConnectionPointContainer(IPicture, iface);
     696
     697  FIXME("(%p,%p), stub!\n",This,ppEnum);
    560698  return E_NOTIMPL;
    561699}
    562700
    563 
     701static HRESULT WINAPI OLEPictureImpl_FindConnectionPoint(
     702  IConnectionPointContainer* iface,
     703  REFIID riid,
     704  IConnectionPoint **ppCP
     705) {
     706  ICOM_THIS_From_IConnectionPointContainer(OLEPictureImpl, iface);
     707  TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
     708  if (!ppCP)
     709      return E_POINTER;
     710  *ppCP = NULL;
     711  if (IsEqualGUID(riid,&IID_IPropertyNotifySink))
     712      return IConnectionPoint_QueryInterface(This->pCP,&IID_IConnectionPoint,(LPVOID)ppCP);
     713  FIXME("tried to find connection point on %s?\n",debugstr_guid(riid));
     714  return 0x80040200;
     715}
     716/************************************************************************
     717 *    IPersistStream
     718 */
     719/************************************************************************
     720 * OLEPictureImpl_IPersistStream_QueryInterface (IUnknown)
     721 *
     722 * See Windows documentation for more details on IUnknown methods.
     723 */
     724static HRESULT WINAPI OLEPictureImpl_IPersistStream_QueryInterface(
     725  IPersistStream* iface,
     726  REFIID     riid,
     727  VOID**     ppvoid)
     728{
     729  ICOM_THIS_From_IPersistStream(IPicture, iface);
     730
     731  return IPicture_QueryInterface(This, riid, ppvoid);
     732}
     733
     734/************************************************************************
     735 * OLEPictureImpl_IPersistStream_AddRef (IUnknown)
     736 *
     737 * See Windows documentation for more details on IUnknown methods.
     738 */
     739static ULONG WINAPI OLEPictureImpl_IPersistStream_AddRef(
     740  IPersistStream* iface)
     741{
     742  ICOM_THIS_From_IPersistStream(IPicture, iface);
     743
     744  return IPicture_AddRef(This);
     745}
     746
     747/************************************************************************
     748 * OLEPictureImpl_IPersistStream_Release (IUnknown)
     749 *
     750 * See Windows documentation for more details on IUnknown methods.
     751 */
     752static ULONG WINAPI OLEPictureImpl_IPersistStream_Release(
     753  IPersistStream* iface)
     754{
     755  ICOM_THIS_From_IPersistStream(IPicture, iface);
     756
     757  return IPicture_Release(This);
     758}
     759
     760/************************************************************************
     761 * OLEPictureImpl_IPersistStream_GetClassID
     762 */
     763static HRESULT WINAPI OLEPictureImpl_GetClassID(
     764  IPersistStream* iface,CLSID* pClassID)
     765{
     766  ICOM_THIS_From_IPersistStream(IPicture, iface);
     767  FIXME("(%p),stub!\n",This);
     768  return E_NOTIMPL;
     769}
     770
     771/************************************************************************
     772 * OLEPictureImpl_IPersistStream_IsDirty
     773 */
     774static HRESULT WINAPI OLEPictureImpl_IsDirty(
     775  IPersistStream* iface)
     776{
     777  ICOM_THIS_From_IPersistStream(IPicture, iface);
     778  FIXME("(%p),stub!\n",This);
     779  return E_NOTIMPL;
     780}
     781
     782#ifdef HAVE_LIBJPEG
     783/* for the jpeg decompressor source manager. */
     784static void _jpeg_init_source(j_decompress_ptr cinfo) { }
     785
     786static boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) {
     787    ERR("(), should not get here.\n");
     788    return FALSE;
     789}
     790
     791static void _jpeg_skip_input_data(j_decompress_ptr cinfo,long num_bytes) {
     792    ERR("(%ld), should not get here.\n",num_bytes);
     793}
     794
     795static boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) {
     796    ERR("(desired=%d), should not get here.\n",desired);
     797    return FALSE;
     798}
     799static void _jpeg_term_source(j_decompress_ptr cinfo) { }
     800#endif /* HAVE_LIBJPEG */
     801
     802/************************************************************************
     803 * OLEPictureImpl_IPersistStream_Load (IUnknown)
     804 *
     805 * Loads the binary data from the IStream. Starts at current position.
     806 * There appears to be an 2 DWORD header:
     807 *      DWORD magic;
     808 *      DWORD len;
     809 *
     810 * Currently implemented: BITMAP, ICON, JPEG.
     811 */
     812static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) {
     813  HRESULT       hr = E_FAIL;
     814  ULONG         xread;
     815  BYTE          *xbuf;
     816  DWORD         header[2];
     817  WORD          magic;
     818  ICOM_THIS_From_IPersistStream(OLEPictureImpl, iface);
     819
     820  TRACE("(%p,%p)\n",This,pStm);
     821
     822  hr=IStream_Read(pStm,header,8,&xread);
     823  if (hr || xread!=8) {
     824      FIXME("Failure while reading picture header (hr is %lx, nread is %ld).\n",hr,xread);
     825      return hr;
     826  }
     827  xread = 0;
     828  xbuf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]);
     829  while (xread < header[1]) {
     830    ULONG nread;
     831    hr = IStream_Read(pStm,xbuf+xread,header[1]-xread,&nread);
     832    xread+=nread;
     833    if (hr || !nread)
     834      break;
     835  }
     836  if (xread != header[1])
     837    FIXME("Could only read %ld of %ld bytes?\n",xread,header[1]);
     838
     839  magic = xbuf[0] + (xbuf[1]<<8);
     840  switch (magic) {
     841  case 0xd8ff: { /* JPEG */
     842#ifdef HAVE_LIBJPEG
     843    struct jpeg_decompress_struct       jd;
     844    struct jpeg_error_mgr               jerr;
     845    int                                 ret;
     846    JDIMENSION                          x;
     847    JSAMPROW                            samprow;
     848    BITMAPINFOHEADER                    bmi;
     849    LPBYTE                              bits;
     850    HDC                                 hdcref;
     851    struct jpeg_source_mgr              xjsm;
     852
     853    /* This is basically so we can use in-memory data for jpeg decompression.
     854     * We need to have all the functions.
     855     */
     856    xjsm.next_input_byte        = xbuf;
     857    xjsm.bytes_in_buffer        = xread;
     858    xjsm.init_source            = _jpeg_init_source;
     859    xjsm.fill_input_buffer      = _jpeg_fill_input_buffer;
     860    xjsm.skip_input_data        = _jpeg_skip_input_data;
     861    xjsm.resync_to_restart      = _jpeg_resync_to_restart;
     862    xjsm.term_source            = _jpeg_term_source;
     863
     864    jd.err = jpeg_std_error(&jerr);
     865    jpeg_create_decompress(&jd);
     866    jd.src = &xjsm;
     867    ret=jpeg_read_header(&jd,TRUE);
     868    jpeg_start_decompress(&jd);
     869    if (ret != JPEG_HEADER_OK) {
     870        ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
     871        HeapFree(GetProcessHeap(),0,xbuf);
     872        return E_FAIL;
     873    }
     874    bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(jd.output_height+1)*jd.output_width*jd.output_components);
     875    samprow=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,jd.output_width*jd.output_components);
     876    while ( jd.output_scanline<jd.output_height ) {
     877      x = jpeg_read_scanlines(&jd,&samprow,1);
     878      if (x != 1) {
     879        FIXME("failed to read current scanline?\n");
     880        break;
     881      }
     882      memcpy( bits+jd.output_scanline*jd.output_width*jd.output_components,
     883              samprow,
     884              jd.output_width*jd.output_components
     885      );
     886    }
     887    bmi.biSize          = sizeof(bmi);
     888    bmi.biWidth         =  jd.output_width;
     889    bmi.biHeight        = -jd.output_height;
     890    bmi.biPlanes        = 1;
     891    bmi.biBitCount      = jd.output_components<<3;
     892    bmi.biCompression   = BI_RGB;
     893    bmi.biSizeImage     = jd.output_height*jd.output_width*jd.output_components;
     894    bmi.biXPelsPerMeter = 0;
     895    bmi.biYPelsPerMeter = 0;
     896    bmi.biClrUsed       = 0;
     897    bmi.biClrImportant  = 0;
     898
     899    HeapFree(GetProcessHeap(),0,samprow);
     900    jpeg_finish_decompress(&jd);
     901    jpeg_destroy_decompress(&jd);
     902    hdcref = CreateCompatibleDC(0);
     903    This->desc.u.bmp.hbitmap=CreateDIBitmap(
     904            hdcref,
     905            &bmi,
     906            CBM_INIT,
     907            bits,
     908            (BITMAPINFO*)&bmi,
     909            DIB_RGB_COLORS
     910    );
     911    DeleteDC(hdcref);
     912    This->desc.picType = PICTYPE_BITMAP;
     913    OLEPictureImpl_SetBitmap(This);
     914    hr = S_OK;
     915    HeapFree(GetProcessHeap(),0,bits);
     916#else
     917    ERR("Trying to load JPEG picture, but JPEG supported not compiled in.\n");
     918    hr = E_FAIL;
     919#endif
     920    break;
     921  }
     922  case 0x4d42: { /* Bitmap */
     923    BITMAPFILEHEADER    *bfh = (BITMAPFILEHEADER*)xbuf;
     924    BITMAPINFO          *bi = (BITMAPINFO*)(bfh+1);
     925    HDC                 hdcref;
     926
     927    /* Does not matter whether this is a coreheader or not, we only use
     928     * components which are in both
     929     */
     930    hdcref = CreateCompatibleDC(0);
     931    This->desc.u.bmp.hbitmap = CreateDIBitmap(
     932        hdcref,
     933        &(bi->bmiHeader),
     934        CBM_INIT,
     935        xbuf+bfh->bfOffBits,
     936        bi,
     937        (bi->bmiHeader.biBitCount<=8)?DIB_PAL_COLORS:DIB_RGB_COLORS
     938    );
     939    DeleteDC(hdcref);
     940    This->desc.picType = PICTYPE_BITMAP;
     941    OLEPictureImpl_SetBitmap(This);
     942    hr = S_OK;
     943    break;
     944  }
     945  case 0x0000: { /* ICON , first word is dwReserved */
     946    HICON hicon;
     947    CURSORICONFILEDIR   *cifd = (CURSORICONFILEDIR*)xbuf;
     948    int i;
     949
     950    /*
     951    FIXME("icon.idReserved=%d\n",cifd->idReserved);
     952    FIXME("icon.idType=%d\n",cifd->idType);
     953    FIXME("icon.idCount=%d\n",cifd->idCount);
     954
     955    for (i=0;i<cifd->idCount;i++) {
     956        FIXME("[%d] width %d\n",i,cifd->idEntries[i].bWidth);
     957        FIXME("[%d] height %d\n",i,cifd->idEntries[i].bHeight);
     958        FIXME("[%d] bColorCount %d\n",i,cifd->idEntries[i].bColorCount);
     959        FIXME("[%d] bReserved %d\n",i,cifd->idEntries[i].bReserved);
     960        FIXME("[%d] xHotspot %d\n",i,cifd->idEntries[i].xHotspot);
     961        FIXME("[%d] yHotspot %d\n",i,cifd->idEntries[i].yHotspot);
     962        FIXME("[%d] dwDIBSize %d\n",i,cifd->idEntries[i].dwDIBSize);
     963        FIXME("[%d] dwDIBOffset %d\n",i,cifd->idEntries[i].dwDIBOffset);
     964    }
     965    */
     966    i=0;
     967    /* If we have more than one icon, try to find the best.
     968     * this currently means '32 pixel wide'.
     969     */
     970    if (cifd->idCount!=1) {
     971        for (i=0;i<cifd->idCount;i++) {
     972            if (cifd->idEntries[i].bWidth == 32)
     973                break;
     974        }
     975        if (i==cifd->idCount) i=0;
     976    }
     977
     978    hicon = CreateIconFromResourceEx(
     979                xbuf+cifd->idEntries[i].dwDIBOffset,
     980                cifd->idEntries[i].dwDIBSize,
     981                TRUE, /* is icon */
     982                0x00030000,
     983                cifd->idEntries[i].bWidth,
     984                cifd->idEntries[i].bHeight,
     985                0
     986    );
     987    if (!hicon) {
     988        FIXME("CreateIcon failed.\n");
     989        hr = E_FAIL;
     990    } else {
     991        This->desc.picType = PICTYPE_ICON;
     992        This->desc.u.icon.hicon = hicon;
     993        hr = S_OK;
     994    }
     995    break;
     996  }
     997  default:
     998    FIXME("Unknown magic %04x\n",magic);
     999    hr=E_FAIL;
     1000    break;
     1001  }
     1002  HeapFree(GetProcessHeap(),0,xbuf);
     1003
     1004  /* FIXME: this notify is not really documented */
     1005  if (hr==S_OK)
     1006      OLEPicture_SendNotify(This,DISPID_PICT_TYPE);
     1007  return hr;
     1008}
     1009
     1010static HRESULT WINAPI OLEPictureImpl_Save(
     1011  IPersistStream* iface,IStream*pStm,BOOL fClearDirty)
     1012{
     1013  ICOM_THIS_From_IPersistStream(IPicture, iface);
     1014  FIXME("(%p,%p,%d),stub!\n",This,pStm,fClearDirty);
     1015  return E_NOTIMPL;
     1016}
     1017
     1018static HRESULT WINAPI OLEPictureImpl_GetSizeMax(
     1019  IPersistStream* iface,ULARGE_INTEGER*pcbSize)
     1020{
     1021  ICOM_THIS_From_IPersistStream(IPicture, iface);
     1022  FIXME("(%p,%p),stub!\n",This,pcbSize);
     1023  return E_NOTIMPL;
     1024}
    5641025
    5651026/************************************************************************
     
    6711132  UINT*     puArgErr)
    6721133{
    673   FIXME("():Stub\n");
    674 
    675   return E_NOTIMPL;
     1134  FIXME("(dispid: %ld):Stub\n",dispIdMember);
     1135
     1136  VariantInit(pVarResult);
     1137  pVarResult->vt = VT_BOOL;
     1138  pVarResult->u.boolVal = FALSE;
     1139  return S_OK;
    6761140}
    6771141
     
    7111175};
    7121176
     1177static ICOM_VTABLE(IPersistStream) OLEPictureImpl_IPersistStream_VTable =
     1178{
     1179  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     1180  OLEPictureImpl_IPersistStream_QueryInterface,
     1181  OLEPictureImpl_IPersistStream_AddRef,
     1182  OLEPictureImpl_IPersistStream_Release,
     1183  OLEPictureImpl_GetClassID,
     1184  OLEPictureImpl_IsDirty,
     1185  OLEPictureImpl_Load,
     1186  OLEPictureImpl_Save,
     1187  OLEPictureImpl_GetSizeMax
     1188};
     1189
     1190static ICOM_VTABLE(IConnectionPointContainer) OLEPictureImpl_IConnectionPointContainer_VTable =
     1191{
     1192  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     1193  OLEPictureImpl_IConnectionPointContainer_QueryInterface,
     1194  OLEPictureImpl_IConnectionPointContainer_AddRef,
     1195  OLEPictureImpl_IConnectionPointContainer_Release,
     1196  OLEPictureImpl_EnumConnectionPoints,
     1197  OLEPictureImpl_FindConnectionPoint
     1198};
     1199
    7131200/***********************************************************************
    714  * OleCreatePictureIndirect
     1201 * OleCreatePictureIndirect (OLEAUT32.419)
    7151202 */
    7161203HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid,
     
    7531240
    7541241
     1242/***********************************************************************
     1243 * OleLoadPicture (OLEAUT32.418)
     1244 */
     1245HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
     1246                            REFIID riid, LPVOID *ppvObj )
     1247{
     1248  LPPERSISTSTREAM ps;
     1249  IPicture      *newpic;
     1250  HRESULT hr;
     1251
     1252  TRACE("(%p,%ld,%d,%s,%p), partially implemented.\n",
     1253        lpstream, lSize, fRunmode, debugstr_guid(riid), ppvObj);
     1254
     1255  hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic);
     1256  if (hr)
     1257    return hr;
     1258  hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps);
     1259  if (hr) {
     1260      FIXME("Could not get IPersistStream iface from Ole Picture?\n");
     1261      IPicture_Release(newpic);
     1262      *ppvObj = NULL;
     1263      return hr;
     1264  }
     1265  IPersistStream_Load(ps,lpstream);
     1266  IPersistStream_Release(ps);
     1267  hr = IPicture_QueryInterface(newpic,riid,ppvObj);
     1268  if (hr)
     1269      FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid));
     1270  IPicture_Release(newpic);
     1271  return hr;
     1272}
     1273
     1274/***********************************************************************
     1275 * OleLoadPictureEx (OLEAUT32.425)
     1276 */
     1277HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
     1278                            REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
     1279{
     1280  FIXME("(%p,%ld,%d,%p,%lx,%lx,%lx,%p), not implemented\n",
     1281        lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj);
     1282  return S_OK;
     1283}
    7551284 
    7561285#ifdef __WIN32OS2__
    757 
    758 /***********************************************************************
    759  * OleLoadPictureEx
    760  */
    761 HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
    762                             REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj )
    763 {
    764   FIXME("(%p,%ld,%d,%p,%lx,%lx,%lx,%p), not implemented\n",
    765         lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj);
    766   return E_NOTIMPL;
    767 }
    768 
    769 /***********************************************************************
    770  * OleLoadPicture
    771  */
    772 HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
    773                             REFIID reed, LPVOID *ppvObj )
    774 {
    775   FIXME("(%p,%ld,%d,%p,%p), not implemented\n",
    776         lpstream, lSize, fRunmode, reed, ppvObj);
    777   return OleLoadPictureEx(lpstream, lSize, fRunmode, reed, 0, 0, 0, ppvObj);
    778 }
    7791286
    7801287// ----------------------------------------------------------------------
  • trunk/src/oleaut32/stubs.cpp

    r6311 r6504  
    1 /* $Id: stubs.cpp,v 1.9 2001-07-12 17:16:12 sandervl Exp $ */
     1/* $Id: stubs.cpp,v 1.10 2001-08-10 19:22:25 sandervl Exp $ */
    22/*
    33 * Win32 COM/OLE stubs for OS/2
     
    169169//*****************************************************************************
    170170//*****************************************************************************
    171 HRESULT WINAPI DispCallFunc(void* pvInstance, ULONG oVft, CALLCONV_OLE2 cc,
     171HRESULT WINAPI DispCallFunc(void* pvInstance, ULONG oVft, CALLCONV cc,
    172172            VARTYPE vtReturn, UINT  cActuals, VARTYPE* prgvt,
    173173            VARIANTARG** prgpvarg, VARIANT* pvargResult)
Note: See TracChangeset for help on using the changeset viewer.