Author: dchapyshev
Date: Sat Sep 5 17:03:37 2009
New Revision: 42995
URL:
http://svn.reactos.org/svn/reactos?rev=42995&view=rev
Log:
- Sync ole32 and oleaut32 with Wine 1.1.29
Modified:
trunk/reactos/dll/win32/ole32/compositemoniker.c
trunk/reactos/dll/win32/ole32/hglobalstream.c
trunk/reactos/dll/win32/ole32/ole2stubs.c
trunk/reactos/dll/win32/ole32/ole32.spec
trunk/reactos/dll/win32/ole32/stg_prop.c
trunk/reactos/dll/win32/ole32/stg_stream.c
trunk/reactos/dll/win32/ole32/storage32.c
trunk/reactos/dll/win32/oleaut32/olepicture.c
trunk/reactos/dll/win32/oleaut32/typelib.c
Modified: trunk/reactos/dll/win32/ole32/compositemoniker.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ole32/compositem…
==============================================================================
--- trunk/reactos/dll/win32/ole32/compositemoniker.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ole32/compositemoniker.c [iso-8859-1] Sat Sep 5 17:03:37
2009
@@ -552,6 +552,7 @@
IEnumMoniker *enumMoniker1,*enumMoniker2;
IMoniker *tempMk1,*tempMk2;
HRESULT res1,res2,res;
+ BOOL done;
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
@@ -567,27 +568,18 @@
IMoniker_Enum(iface,TRUE,&enumMoniker2);
- while(1){
+ do {
res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL);
if((res1==S_OK)&&(res2==S_OK)){
-
- if(IMoniker_IsEqual(tempMk1,tempMk2)==S_FALSE){
- res= S_FALSE;
- break;
- }
- else
- continue;
- }
- else if ( (res1==S_FALSE) && (res2==S_FALSE) ){
- res = S_OK;
- break;
- }
- else{
- res = S_FALSE;
- break;
+ done = (res = IMoniker_IsEqual(tempMk1,tempMk2)) == S_FALSE;
+ }
+ else
+ {
+ res = (res1==S_FALSE) && (res2==S_FALSE);
+ done = TRUE;
}
if (res1==S_OK)
@@ -595,7 +587,7 @@
if (res2==S_OK)
IMoniker_Release(tempMk2);
- }
+ } while (!done);
IEnumMoniker_Release(enumMoniker1);
IEnumMoniker_Release(enumMoniker2);
@@ -989,12 +981,12 @@
nbRestMk++;
IMoniker_Release(tempMk1);
- IMoniker_Release(tempMk1);
+ IMoniker_Release(tempMk2);
break;
}
IMoniker_Release(tempMk1);
- IMoniker_Release(tempMk1);
+ IMoniker_Release(tempMk2);
}
}
else{
Modified: trunk/reactos/dll/win32/ole32/hglobalstream.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ole32/hglobalstr…
==============================================================================
--- trunk/reactos/dll/win32/ole32/hglobalstream.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ole32/hglobalstream.c [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -397,7 +397,7 @@
*/
if (dlibMove.QuadPart < 0 && newPosition.QuadPart < -dlibMove.QuadPart)
return STG_E_INVALIDFUNCTION;
- newPosition.QuadPart = RtlLargeIntegerAdd(newPosition.QuadPart, dlibMove.QuadPart);
+ newPosition.QuadPart += dlibMove.QuadPart;
if (plibNewPosition) *plibNewPosition = newPosition;
This->currentPosition = newPosition;
Modified: trunk/reactos/dll/win32/ole32/ole2stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ole32/ole2stubs.…
==============================================================================
--- trunk/reactos/dll/win32/ole32/ole2stubs.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ole32/ole2stubs.c [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -128,3 +128,12 @@
FIXME("stub!\n");
return E_NOTIMPL;
}
+
+/***********************************************************************
+ * CoGetCurrentLogicalThreadId [OLE32.@]
+ */
+HRESULT WINAPI CoGetCurrentLogicalThreadId(GUID *pguid)
+{
+ FIXME(": stub\n");
+ return E_NOTIMPL;
+}
Modified: trunk/reactos/dll/win32/ole32/ole32.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ole32/ole32.spec…
==============================================================================
--- trunk/reactos/dll/win32/ole32/ole32.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ole32/ole32.spec [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -25,7 +25,7 @@
@ stdcall CoGetCallerTID(ptr)
@ stdcall CoGetClassObject(ptr long ptr ptr ptr)
@ stdcall CoGetContextToken(ptr)
-@ stub CoGetCurrentLogicalThreadId
+@ stdcall CoGetCurrentLogicalThreadId(ptr)
@ stdcall CoGetCurrentProcess()
@ stub CoGetInstanceFromFile #@ stdcall (ptr ptr ptr long wstr long ptr) return
0,ERR_NOTIMPLEMENTED
@ stub CoGetInstanceFromIStorage #@ stdcall (ptr ptr ptr long ptr long ptr) return
0,ERR_NOTIMPLEMENTED
Modified: trunk/reactos/dll/win32/ole32/stg_prop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ole32/stg_prop.c…
==============================================================================
--- trunk/reactos/dll/win32/ole32/stg_prop.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ole32/stg_prop.c [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -977,7 +977,7 @@
* FIXME: alignment?
*/
for (i = 0; i < len; i++)
- str[i] = le16toh(str[i]);
+ str[i] = lendian16toh(str[i]);
}
#else
#define PropertyStorage_ByteSwapString(s, l)
Modified: trunk/reactos/dll/win32/ole32/stg_stream.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ole32/stg_stream…
==============================================================================
--- trunk/reactos/dll/win32/ole32/stg_stream.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ole32/stg_stream.c [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -522,7 +522,7 @@
return STG_E_INVALIDFUNCTION;
}
- plibNewPosition->QuadPart = RtlLargeIntegerAdd( plibNewPosition->QuadPart,
dlibMove.QuadPart );
+ plibNewPosition->QuadPart += dlibMove.QuadPart;
/*
* tell the caller what we calculated
Modified: trunk/reactos/dll/win32/ole32/storage32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ole32/storage32.…
==============================================================================
--- trunk/reactos/dll/win32/ole32/storage32.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ole32/storage32.c [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -3563,7 +3563,7 @@
{
resRead = SmallBlockChainStream_ReadAt(*ppsbChain,
offset,
- This->smallBlockSize,
+ min(This->smallBlockSize, size.u.LowPart -
offset.u.LowPart),
buffer,
&cbRead);
if (FAILED(resRead))
@@ -3582,7 +3582,7 @@
if (FAILED(resWrite))
break;
- offset.u.LowPart += This->smallBlockSize;
+ offset.u.LowPart += cbRead;
}
} while (cbTotalRead.QuadPart < size.QuadPart);
HeapFree(GetProcessHeap(),0,buffer);
@@ -3663,7 +3663,8 @@
do
{
resRead = BlockChainStream_ReadAt(*ppbbChain, offset,
- This->bigBlockSize, buffer, &cbRead);
+ min(This->bigBlockSize, size.u.LowPart - offset.u.LowPart),
+ buffer, &cbRead);
if(FAILED(resRead))
break;
@@ -3678,7 +3679,7 @@
if(FAILED(resWrite))
break;
- offset.u.LowPart += This->bigBlockSize;
+ offset.u.LowPart += cbRead;
}
}while(cbTotalRead.QuadPart < size.QuadPart);
HeapFree(GetProcessHeap(), 0, buffer);
@@ -5917,7 +5918,7 @@
*/
hr = StorageBaseImpl_QueryInterface(
(IStorage*)newStorage,
- (REFIID)&IID_IStorage,
+ &IID_IStorage,
(void**)ppstgOpen);
end:
TRACE("<-- %p r = %08x\n", *ppstgOpen, hr);
@@ -6221,7 +6222,7 @@
*/
hr = StorageBaseImpl_QueryInterface(
(IStorage*)newStorage,
- (REFIID)&IID_IStorage,
+ &IID_IStorage,
(void**)ppstgOpen);
end:
@@ -6275,7 +6276,7 @@
*/
hr = StorageBaseImpl_QueryInterface(
(IStorage*)newStorage,
- (REFIID)&IID_IStorage,
+ &IID_IStorage,
(void**)ppstgOpen);
return hr;
@@ -6340,7 +6341,7 @@
*/
hr = StorageBaseImpl_QueryInterface(
(IStorage*)newStorage,
- (REFIID)&IID_IStorage,
+ &IID_IStorage,
(void**)ppstgOpen);
return hr;
@@ -7192,9 +7193,9 @@
debugstr_w(lpszUserType), debugstr_w(szClipName),
debugstr_w(szProgIDName));
- /* Create a CompObj stream if it doesn't exist */
+ /* Create a CompObj stream */
r = IStorage_CreateStream(pstg, szwStreamName,
- STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm );
+ STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm );
if( FAILED (r) )
return r;
Modified: trunk/reactos/dll/win32/oleaut32/olepicture.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/oleaut32/olepict…
==============================================================================
--- trunk/reactos/dll/win32/oleaut32/olepicture.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/oleaut32/olepicture.c [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -46,28 +46,6 @@
#include <stdio.h>
#include <string.h>
-#ifdef SONAME_LIBJPEG
-/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
-#define XMD_H
-#define UINT8 JPEG_UINT8
-#define UINT16 JPEG_UINT16
-#define boolean jpeg_boolean
-#undef HAVE_STDLIB_H
-# include <jpeglib.h>
-#undef HAVE_STDLIB_H
-#define HAVE_STDLIB_H 1
-#undef UINT8
-#undef UINT16
-#undef boolean
-#endif
-
-#ifdef HAVE_PNG_H
-#include <png.h>
-#endif
-
-/* Must be before wine includes, the header has things conflicting with
- * WINE headers.
- */
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
@@ -1002,167 +980,6 @@
return E_NOTIMPL;
}
-#ifdef SONAME_LIBJPEG
-
-static void *libjpeg_handle;
-#define MAKE_FUNCPTR(f) static typeof(f) * p##f
-MAKE_FUNCPTR(jpeg_std_error);
-MAKE_FUNCPTR(jpeg_CreateDecompress);
-MAKE_FUNCPTR(jpeg_read_header);
-MAKE_FUNCPTR(jpeg_start_decompress);
-MAKE_FUNCPTR(jpeg_read_scanlines);
-MAKE_FUNCPTR(jpeg_finish_decompress);
-MAKE_FUNCPTR(jpeg_destroy_decompress);
-#undef MAKE_FUNCPTR
-
-static void *load_libjpeg(void)
-{
- if((libjpeg_handle = wine_dlopen(SONAME_LIBJPEG, RTLD_NOW, NULL, 0)) != NULL) {
-
-#define LOAD_FUNCPTR(f) \
- if((p##f = wine_dlsym(libjpeg_handle, #f, NULL, 0)) == NULL) { \
- libjpeg_handle = NULL; \
- return NULL; \
- }
-
- LOAD_FUNCPTR(jpeg_std_error);
- LOAD_FUNCPTR(jpeg_CreateDecompress);
- LOAD_FUNCPTR(jpeg_read_header);
- LOAD_FUNCPTR(jpeg_start_decompress);
- LOAD_FUNCPTR(jpeg_read_scanlines);
- LOAD_FUNCPTR(jpeg_finish_decompress);
- LOAD_FUNCPTR(jpeg_destroy_decompress);
-#undef LOAD_FUNCPTR
- }
- return libjpeg_handle;
-}
-
-/* for the jpeg decompressor source manager. */
-static void _jpeg_init_source(j_decompress_ptr cinfo) { }
-
-static jpeg_boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) {
- ERR("(), should not get here.\n");
- return FALSE;
-}
-
-static void _jpeg_skip_input_data(j_decompress_ptr cinfo,long num_bytes) {
- TRACE("Skipping %ld bytes...\n", num_bytes);
- cinfo->src->next_input_byte += num_bytes;
- cinfo->src->bytes_in_buffer -= num_bytes;
-}
-
-static jpeg_boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) {
- ERR("(desired=%d), should not get here.\n",desired);
- return FALSE;
-}
-static void _jpeg_term_source(j_decompress_ptr cinfo) { }
-#endif /* SONAME_LIBJPEG */
-
-static HRESULT OLEPictureImpl_LoadJpeg(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
-{
-#ifdef SONAME_LIBJPEG
- struct jpeg_decompress_struct jd;
- struct jpeg_error_mgr jerr;
- int ret;
- JDIMENSION x;
- JSAMPROW samprow,oldsamprow;
- BITMAPINFOHEADER bmi;
- LPBYTE bits;
- HDC hdcref;
- struct jpeg_source_mgr xjsm;
- LPBYTE oldbits;
- unsigned int i;
-
- if(!libjpeg_handle) {
- if(!load_libjpeg()) {
- ERR("Failed reading JPEG because unable to find %s\n",
SONAME_LIBJPEG);
- return E_FAIL;
- }
- }
-
- /* This is basically so we can use in-memory data for jpeg decompression.
- * We need to have all the functions.
- */
- xjsm.next_input_byte = xbuf;
- xjsm.bytes_in_buffer = xread;
- xjsm.init_source = _jpeg_init_source;
- xjsm.fill_input_buffer = _jpeg_fill_input_buffer;
- xjsm.skip_input_data = _jpeg_skip_input_data;
- xjsm.resync_to_restart = _jpeg_resync_to_restart;
- xjsm.term_source = _jpeg_term_source;
-
- jd.err = pjpeg_std_error(&jerr);
- /* jpeg_create_decompress is a macro that expands to jpeg_CreateDecompress - see
jpeglib.h
- * jpeg_create_decompress(&jd); */
- pjpeg_CreateDecompress(&jd, JPEG_LIB_VERSION, sizeof(struct
jpeg_decompress_struct));
- jd.src = &xjsm;
- ret=pjpeg_read_header(&jd,TRUE);
- jd.out_color_space = JCS_RGB;
- pjpeg_start_decompress(&jd);
- if (ret != JPEG_HEADER_OK) {
- ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret);
- HeapFree(GetProcessHeap(),0,xbuf);
- return E_FAIL;
- }
-
- bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
- (jd.output_height+1) * ((jd.output_width*jd.output_components + 3)
& ~3) );
-
samprow=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,jd.output_width*jd.output_components);
-
- oldbits = bits;
- oldsamprow = samprow;
- while ( jd.output_scanline<jd.output_height ) {
- x = pjpeg_read_scanlines(&jd,&samprow,1);
- if (x != 1) {
- ERR("failed to read current scanline?\n");
- break;
- }
- /* We have to convert from RGB to BGR, see MSDN/ BITMAPINFOHEADER */
- for(i=0;i<jd.output_width;i++,samprow+=jd.output_components) {
- *(bits++) = *(samprow+2);
- *(bits++) = *(samprow+1);
- *(bits++) = *(samprow);
- }
- bits = (LPBYTE)(((UINT_PTR)bits + 3) & ~3);
- samprow = oldsamprow;
- }
- bits = oldbits;
-
- bmi.biSize = sizeof(bmi);
- bmi.biWidth = jd.output_width;
- bmi.biHeight = -jd.output_height;
- bmi.biPlanes = 1;
- bmi.biBitCount = jd.output_components<<3;
- bmi.biCompression = BI_RGB;
- bmi.biSizeImage = jd.output_height*jd.output_width*jd.output_components;
- bmi.biXPelsPerMeter = 0;
- bmi.biYPelsPerMeter = 0;
- bmi.biClrUsed = 0;
- bmi.biClrImportant = 0;
-
- HeapFree(GetProcessHeap(),0,samprow);
- pjpeg_finish_decompress(&jd);
- pjpeg_destroy_decompress(&jd);
- hdcref = GetDC(0);
- This->desc.u.bmp.hbitmap=CreateDIBitmap(
- hdcref,
- &bmi,
- CBM_INIT,
- bits,
- (BITMAPINFO*)&bmi,
- DIB_RGB_COLORS
- );
- ReleaseDC(0, hdcref);
- This->desc.picType = PICTYPE_BITMAP;
- OLEPictureImpl_SetBitmap(This);
- HeapFree(GetProcessHeap(),0,bits);
- return S_OK;
-#else
- ERR("Trying to load JPEG picture, but JPEG supported not compiled in.\n");
- return E_FAIL;
-#endif
-}
-
static HRESULT OLEPictureImpl_LoadDIB(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
{
BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)xbuf;
@@ -1319,298 +1136,52 @@
static HRESULT OLEPictureImpl_LoadWICDecoder(OLEPictureImpl *This, REFCLSID
decoder_clsid, BYTE *xbuf, ULONG xread)
{
HRESULT hr;
+ IWICImagingFactory *factory;
IWICBitmapDecoder *decoder;
IWICBitmapFrameDecode *framedecode;
HRESULT initresult;
- HGLOBAL hdata;
- BYTE *data;
- IStream *stream;
-
- hdata = GlobalAlloc(GMEM_MOVEABLE, xread);
- if (!hdata) return E_OUTOFMEMORY;
-
- data = GlobalLock(hdata);
- memcpy(data, xbuf, xread);
- GlobalUnlock(hdata);
-
- hr = CreateStreamOnHGlobal(hdata, TRUE, &stream);
- if (FAILED(hr))
+ IWICStream *stream;
+
+ initresult = CoInitialize(NULL);
+
+ hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IWICImagingFactory, (void**)&factory);
+ if (SUCCEEDED(hr)) /* created factory */
{
- GlobalFree(hdata);
- return hr;
- }
-
- initresult = CoInitialize(NULL);
-
- hr = CoCreateInstance(decoder_clsid, NULL, CLSCTX_INPROC_SERVER,
- &IID_IWICBitmapDecoder, (void**)&decoder);
- if (FAILED(hr)) goto end;
-
- hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
- if (SUCCEEDED(hr))
+ hr = IWICImagingFactory_CreateStream(factory, &stream);
+ IWICImagingFactory_Release(factory);
+ }
+
+ if (SUCCEEDED(hr)) /* created stream */
{
- hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
- if (SUCCEEDED(hr))
+ hr = IWICStream_InitializeFromMemory(stream, xbuf, xread);
+
+ if (SUCCEEDED(hr)) /* initialized stream */
{
- hr = OLEPictureImpl_LoadWICSource(This, (IWICBitmapSource*)framedecode);
- IWICBitmapFrameDecode_Release(framedecode);
+ hr = CoCreateInstance(decoder_clsid, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IWICBitmapDecoder, (void**)&decoder);
+ if (SUCCEEDED(hr)) /* created decoder */
+ {
+ hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)stream,
WICDecodeMetadataCacheOnLoad);
+
+ if (SUCCEEDED(hr)) /* initialized decoder */
+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
+
+ IWICBitmapDecoder_Release(decoder);
+ }
}
- }
-
- IWICBitmapDecoder_Release(decoder);
-
-end:
- IStream_Release(stream);
+
+ IWICStream_Release(stream);
+ }
+
+ if (SUCCEEDED(hr)) /* got framedecode */
+ {
+ hr = OLEPictureImpl_LoadWICSource(This, (IWICBitmapSource*)framedecode);
+ IWICBitmapFrameDecode_Release(framedecode);
+ }
+
if (SUCCEEDED(initresult)) CoUninitialize();
return hr;
-}
-
-/*****************************************************
-* start of PNG-specific code
-* currently only supports colortype PNG_COLOR_TYPE_RGB
-*/
-#ifdef SONAME_LIBPNG
-typedef struct{
- ULONG position;
- ULONG size;
- BYTE * buff;
-} png_io;
-
-static void png_stream_read_data(png_structp png_ptr, png_bytep data,
- png_size_t length)
-{
- png_io * io_ptr = png_ptr->io_ptr;
-
- if(length + io_ptr->position > io_ptr->size){
- length = io_ptr->size - io_ptr->position;
- }
-
- memcpy(data, io_ptr->buff + io_ptr->position, length);
-
- io_ptr->position += length;
-}
-
-static void *libpng_handle;
-#define MAKE_FUNCPTR(f) static typeof(f) * p##f
-MAKE_FUNCPTR(png_create_read_struct);
-MAKE_FUNCPTR(png_create_info_struct);
-MAKE_FUNCPTR(png_set_read_fn);
-MAKE_FUNCPTR(png_read_info);
-MAKE_FUNCPTR(png_read_image);
-MAKE_FUNCPTR(png_get_rowbytes);
-MAKE_FUNCPTR(png_set_bgr);
-MAKE_FUNCPTR(png_destroy_read_struct);
-MAKE_FUNCPTR(png_set_palette_to_rgb);
-MAKE_FUNCPTR(png_read_update_info);
-MAKE_FUNCPTR(png_get_tRNS);
-MAKE_FUNCPTR(png_get_PLTE);
-MAKE_FUNCPTR(png_set_expand);
-#undef MAKE_FUNCPTR
-
-static void *load_libpng(void)
-{
- if((libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) {
-
-#define LOAD_FUNCPTR(f) \
- if((p##f = wine_dlsym(libpng_handle, #f, NULL, 0)) == NULL) { \
- libpng_handle = NULL; \
- return NULL; \
- }
- LOAD_FUNCPTR(png_create_read_struct);
- LOAD_FUNCPTR(png_create_info_struct);
- LOAD_FUNCPTR(png_set_read_fn);
- LOAD_FUNCPTR(png_read_info);
- LOAD_FUNCPTR(png_read_image);
- LOAD_FUNCPTR(png_get_rowbytes);
- LOAD_FUNCPTR(png_set_bgr);
- LOAD_FUNCPTR(png_destroy_read_struct);
- LOAD_FUNCPTR(png_set_palette_to_rgb);
- LOAD_FUNCPTR(png_read_update_info);
- LOAD_FUNCPTR(png_get_tRNS);
- LOAD_FUNCPTR(png_get_PLTE);
- LOAD_FUNCPTR(png_set_expand);
-
-#undef LOAD_FUNCPTR
- }
- return libpng_handle;
-}
-#endif /* SONAME_LIBPNG */
-
-static HRESULT OLEPictureImpl_LoadPNG(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
-{
-#ifdef SONAME_LIBPNG
- png_io io;
- png_structp png_ptr = NULL;
- png_infop info_ptr = NULL;
- INT row, rowsize, height, width, num_trans, i, j;
- png_bytep* row_pointers = NULL;
- png_bytep pngdata = NULL;
- BITMAPINFOHEADER bmi;
- HDC hdcref = NULL, hdcXor, hdcMask;
- HRESULT ret;
- BOOL transparency;
- png_bytep trans;
- png_color_16p trans_values;
- COLORREF white = RGB(255, 255, 255), black = RGB(0, 0, 0);
- HBITMAP hbmoldXor, hbmoldMask, temp;
-
- if(!libpng_handle) {
- if(!load_libpng()) {
- ERR("Failed reading PNG because unable to find
%s\n",SONAME_LIBPNG);
- return E_FAIL;
- }
- }
-
- io.size = xread;
- io.position = 0;
- io.buff = xbuf;
-
- png_ptr = ppng_create_read_struct(PNG_LIBPNG_VER_STRING,
- NULL, NULL, NULL);
-
- if(setjmp(png_jmpbuf(png_ptr))){
- TRACE("Error in libpng\n");
- ret = E_FAIL;
- goto end;
- }
-
- info_ptr = ppng_create_info_struct(png_ptr);
- ppng_set_read_fn(png_ptr, &io, png_stream_read_data);
- ppng_read_info(png_ptr, info_ptr);
-
- if(!(png_ptr->color_type == PNG_COLOR_TYPE_RGB ||
- png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
- png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)){
- FIXME("Unsupported .PNG type: %d\n", png_ptr->color_type);
- ret = E_FAIL;
- goto end;
- }
-
- transparency = (ppng_get_tRNS(png_ptr, info_ptr, &trans, &num_trans,
&trans_values)
- == PNG_INFO_tRNS);
-
- /* sets format from anything to RGBA */
- ppng_set_expand(png_ptr);
- /* sets format to BGRA */
- ppng_set_bgr(png_ptr);
-
- ppng_read_update_info(png_ptr, info_ptr);
-
- rowsize = ppng_get_rowbytes(png_ptr, info_ptr);
- /* align rowsize to 4-byte boundary */
- rowsize = (rowsize + 3) & ~3;
- height = info_ptr->height;
- width = info_ptr->width;
-
- pngdata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, height * rowsize);
- row_pointers = HeapAlloc(GetProcessHeap(), 0, height * (sizeof(VOID *)));
-
- if(!pngdata || !row_pointers){
- ret = E_FAIL;
- goto end;
- }
-
- for (row = 0; row < height; row++){
- row_pointers[row] = pngdata + row * rowsize;
- }
-
- ppng_read_image(png_ptr, row_pointers);
-
- bmi.biSize = sizeof(bmi);
- bmi.biWidth = width;
- bmi.biHeight = -height;
- bmi.biPlanes = 1;
- bmi.biBitCount = info_ptr->channels * 8;
- bmi.biCompression = BI_RGB;
- bmi.biSizeImage = height * rowsize;
- bmi.biXPelsPerMeter = 0;
- bmi.biYPelsPerMeter = 0;
- bmi.biClrUsed = 0;
- bmi.biClrImportant = 0;
-
- hdcref = GetDC(0);
- This->desc.u.bmp.hbitmap = CreateDIBitmap(
- hdcref,
- &bmi,
- CBM_INIT,
- pngdata,
- (BITMAPINFO*)&bmi,
- DIB_RGB_COLORS
- );
-
- /* only fully-transparent alpha is handled */
- if((info_ptr->channels != 4) || !transparency){
- ReleaseDC(0, hdcref);
- goto succ;
- }
-
- This->hbmXor = CreateDIBitmap(
- hdcref,
- &bmi,
- CBM_INIT,
- pngdata,
- (BITMAPINFO*)&bmi,
- DIB_RGB_COLORS
- );
-
- /* set transparent pixels to black, all others to white */
- for(i = 0; i < height; i++){
- for(j = 3; j < rowsize; j += 4){
- if(row_pointers[i][j] == 0)
- *((DWORD*)(&row_pointers[i][j - 3])) = black;
- else
- *((DWORD*)(&row_pointers[i][j - 3])) = white;
- }
- }
-
- temp = CreateDIBitmap(
- hdcref,
- &bmi,
- CBM_INIT,
- pngdata,
- (BITMAPINFO*)&bmi,
- DIB_RGB_COLORS
- );
-
- ReleaseDC(0, hdcref);
-
- This->hbmMask = CreateBitmap(width,-height,1,1,NULL);
- hdcXor = CreateCompatibleDC(NULL);
- hdcMask = CreateCompatibleDC(NULL);
-
- hbmoldXor = SelectObject(hdcXor,temp);
- hbmoldMask = SelectObject(hdcMask,This->hbmMask);
- SetBkColor(hdcXor,black);
- BitBlt(hdcMask,0,0,width,height,hdcXor,0,0,SRCCOPY);
-
- SelectObject(hdcXor,This->hbmXor);
- DeleteObject(temp);
-
- SetTextColor(hdcXor,white);
- SetBkColor(hdcXor,black);
- BitBlt(hdcXor,0,0,width,height,hdcMask,0,0,SRCAND);
-
- SelectObject(hdcXor,hbmoldXor);
- SelectObject(hdcMask,hbmoldMask);
-
- DeleteDC(hdcXor);
- DeleteDC(hdcMask);
-
-succ:
- This->desc.picType = PICTYPE_BITMAP;
- OLEPictureImpl_SetBitmap(This);
- ret = S_OK;
-
-end:
- if(png_ptr)
- ppng_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : NULL, NULL);
- HeapFree(GetProcessHeap(), 0, row_pointers);
- HeapFree(GetProcessHeap(), 0, pngdata);
- return ret;
-#else /* SONAME_LIBPNG */
- ERR("Trying to load PNG picture, but PNG supported not compiled in.\n");
- return E_FAIL;
-#endif
}
/*****************************************************
@@ -1889,13 +1460,13 @@
hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICGifDecoder, xbuf, xread);
break;
case BITMAP_FORMAT_JPEG: /* JPEG */
- hr = OLEPictureImpl_LoadJpeg(This, xbuf, xread);
+ hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICJpegDecoder, xbuf, xread);
break;
case BITMAP_FORMAT_BMP: /* Bitmap */
hr = OLEPictureImpl_LoadDIB(This, xbuf, xread);
break;
case BITMAP_FORMAT_PNG: /* PNG */
- hr = OLEPictureImpl_LoadPNG(This, xbuf, xread);
+ hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICPngDecoder, xbuf, xread);
break;
case BITMAP_FORMAT_APM: /* APM */
hr = OLEPictureImpl_LoadAPM(This, xbuf, xread);
Modified: trunk/reactos/dll/win32/oleaut32/typelib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/oleaut32/typelib…
==============================================================================
--- trunk/reactos/dll/win32/oleaut32/typelib.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/oleaut32/typelib.c [iso-8859-1] Sat Sep 5 17:03:37 2009
@@ -930,6 +930,7 @@
const ITypeCompVtbl *lpVtblTypeComp;
LONG ref;
TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */
+ LCID lcid;
/* strings can be stored in tlb as multibyte strings BUT they are *always*
* exported to the application as a UNICODE string.
@@ -2878,6 +2879,8 @@
pTypeLibImpl->LibAttr.wMinorVerNum = HIWORD(tlbHeader.version);
pTypeLibImpl->LibAttr.wLibFlags = (WORD) tlbHeader.flags & 0xffff;/* check
mask */
+ pTypeLibImpl->lcid = tlbHeader.lcid;
+
/* name, eventually add to a hash table */
pTypeLibImpl->Name = MSFT_ReadName(&cx, tlbHeader.NameOffset);
@@ -3099,9 +3102,9 @@
ptr += 2;
if(SUBLANGID(*(WORD*)ptr) == SUBLANG_NEUTRAL)
- pTypeLibImpl->LibAttr.lcid =
MAKELCID(MAKELANGID(PRIMARYLANGID(*(WORD*)ptr),0),0);
+ pTypeLibImpl->lcid = pTypeLibImpl->LibAttr.lcid =
MAKELCID(MAKELANGID(PRIMARYLANGID(*(WORD*)ptr),0),0);
else
- pTypeLibImpl->LibAttr.lcid = 0;
+ pTypeLibImpl->lcid = pTypeLibImpl->LibAttr.lcid = 0;
ptr += 2;
ptr += 4; /* skip res12 */
@@ -3131,7 +3134,7 @@
static HRESULT sltg_get_typelib_ref(const sltg_ref_lookup_t *table, DWORD typeinfo_ref,
HREFTYPE *typelib_ref)
{
- if(typeinfo_ref < table->num)
+ if(table && typeinfo_ref < table->num)
{
*typelib_ref = table->refs[typeinfo_ref];
return S_OK;
@@ -6063,6 +6066,7 @@
VARTYPE *rgvt = INVBUF_GET_ARG_TYPE_ARRAY(buffer, func_desc->cParams);
UINT cNamedArgs = pDispParams->cNamedArgs;
DISPID *rgdispidNamedArgs = pDispParams->rgdispidNamedArgs;
+ UINT vargs_converted=0;
hres = S_OK;
@@ -6100,6 +6104,15 @@
USHORT wParamFlags =
func_desc->lprgelemdescParam[i].u.paramdesc.wParamFlags;
VARIANTARG *src_arg;
+ if (wParamFlags & PARAMFLAG_FLCID)
+ {
+ VARIANTARG *arg;
+ arg = prgpvarg[i] = &rgvarg[i];
+ V_VT(arg) = VT_I4;
+ V_I4(arg) = This->pTypeLib->lcid;
+ continue;
+ }
+
if (cNamedArgs)
{
USHORT j;
@@ -6112,7 +6125,10 @@
}
}
else
- src_arg = i < pDispParams->cArgs ?
&pDispParams->rgvarg[pDispParams->cArgs - 1 - i] : NULL;
+ {
+ src_arg = vargs_converted < pDispParams->cArgs ?
&pDispParams->rgvarg[pDispParams->cArgs - 1 - vargs_converted] : NULL;
+ vargs_converted++;
+ }
if (wParamFlags & PARAMFLAG_FRETVAL)
{
@@ -6278,10 +6294,15 @@
V_VT(&varresult), func_desc->cParams, rgvt,
prgpvarg, &varresult);
+ vargs_converted = 0;
+
for (i = 0; i < func_desc->cParams; i++)
{
USHORT wParamFlags =
func_desc->lprgelemdescParam[i].u.paramdesc.wParamFlags;
- if (wParamFlags & PARAMFLAG_FRETVAL)
+
+ if (wParamFlags & PARAMFLAG_FLCID)
+ continue;
+ else if (wParamFlags & PARAMFLAG_FRETVAL)
{
if (TRACE_ON(ole))
{
@@ -6309,11 +6330,11 @@
}
break;
}
- else if (i < pDispParams->cArgs)
+ else if (vargs_converted < pDispParams->cArgs)
{
if (wParamFlags & PARAMFLAG_FOUT)
{
- VARIANTARG *arg =
&pDispParams->rgvarg[pDispParams->cArgs - 1 - i];
+ VARIANTARG *arg =
&pDispParams->rgvarg[pDispParams->cArgs - 1 - vargs_converted];
if ((rgvt[i] == VT_BYREF) && (V_VT(arg) != VT_BYREF))
hres = VariantChangeType(arg, &rgvarg[i], 0, V_VT(arg));
@@ -6321,7 +6342,7 @@
if (FAILED(hres))
{
ERR("failed to convert param %d to vt %d\n", i,
- V_VT(&pDispParams->rgvarg[pDispParams->cArgs -
1 - i]));
+ V_VT(&pDispParams->rgvarg[pDispParams->cArgs -
1 - vargs_converted]));
break;
}
}
@@ -6354,6 +6375,7 @@
}
}
VariantClear(&rgvarg[i]);
+ vargs_converted++;
}
else if (wParamFlags & PARAMFLAG_FOPT)
{
@@ -7047,13 +7069,12 @@
TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData?
"" : "NOT");
- if(pCData)
- {
- VariantInit( pVarVal);
+ VariantInit( pVarVal);
+ if (pCData)
VariantCopy( pVarVal, &pCData->data);
- return S_OK;
- }
- return E_INVALIDARG; /* FIXME: correct? */
+ else
+ VariantClear( pVarVal );
+ return S_OK;
}
/* ITypeInfo2::GetFuncCustData