Thread: [pywin32-checkins] pywin32/win32/src win32clipboardmodule.cpp, 1.20, 1.21
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-08-14 01:27:25
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2470/win32/src Modified Files: win32clipboardmodule.cpp Log Message: Fix a couple of 64 bit issues, and some autoduck Index: win32clipboardmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32clipboardmodule.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** win32clipboardmodule.cpp 3 Jun 2007 14:53:07 -0000 1.20 --- win32clipboardmodule.cpp 14 Aug 2007 01:27:26 -0000 1.21 *************** *** 337,341 **** void * cData = NULL; ! DWORD size; switch (format) { case CF_HDROP: --- 337,342 ---- void * cData = NULL; ! size_t size; ! DWORD dwordsize; switch (format) { case CF_HDROP: *************** *** 343,372 **** break; case CF_ENHMETAFILE: ! size = GetEnhMetaFileBits((HENHMETAFILE)handle, 0, NULL); ! if (!size) return ReturnAPIError("GetClipboardData:GetEnhMetafileBits(NULL)"); // allocate a temporary buffer for enhanced metafile ! cData = malloc(size); if (cData == NULL) return ReturnAPIError("GetClipboardData:malloc"); // copy enhanced metafile into the temporary buffer ! if (0 == GetEnhMetaFileBits((HENHMETAFILE)handle, size, (LPBYTE)cData)) { free(cData); return ReturnAPIError("GetClipboardData:GetEnhMetafileBits"); } break; case CF_METAFILEPICT: ! size = GetMetaFileBitsEx((HMETAFILE)handle, 0, NULL); ! if (!size) return ReturnAPIError("GetClipboardData:GetMetafileBitsEx(NULL)"); // allocate a temporary buffer for metafile ! cData = malloc(size); if (cData == NULL) return ReturnAPIError("GetClipboardData:malloc"); // copy metafile into the temporary buffer ! if (0 == GetMetaFileBitsEx((HMETAFILE)handle, size, cData)) { free(cData); return ReturnAPIError("GetClipboardData:GetMetafileBitsEx"); } break; // All other formats simply return the data as a blob. --- 344,378 ---- break; case CF_ENHMETAFILE: ! dwordsize = GetEnhMetaFileBits((HENHMETAFILE)handle, 0, NULL); ! if (!dwordsize) return ReturnAPIError("GetClipboardData:GetEnhMetafileBits(NULL)"); // allocate a temporary buffer for enhanced metafile ! cData = malloc(dwordsize); if (cData == NULL) return ReturnAPIError("GetClipboardData:malloc"); // copy enhanced metafile into the temporary buffer ! if (0 == GetEnhMetaFileBits((HENHMETAFILE)handle, dwordsize, (LPBYTE)cData)) { free(cData); return ReturnAPIError("GetClipboardData:GetEnhMetafileBits"); } + size=dwordsize; break; case CF_METAFILEPICT: ! // @todo CF_METAFILEPICT format returns a pointer to a METAFILEPICT struct which contains the metafile handle, ! // rather than returning the handle directly. This code currently fails with ! // error: (6, 'GetClipboardData:GetMetafileBitsEx(NULL)', 'The handle is invalid.') ! dwordsize = GetMetaFileBitsEx((HMETAFILE)handle, 0, NULL); ! if (!dwordsize) return ReturnAPIError("GetClipboardData:GetMetafileBitsEx(NULL)"); // allocate a temporary buffer for metafile ! cData = malloc(dwordsize); if (cData == NULL) return ReturnAPIError("GetClipboardData:malloc"); // copy metafile into the temporary buffer ! if (0 == GetMetaFileBitsEx((HMETAFILE)handle, dwordsize, cData)) { free(cData); return ReturnAPIError("GetClipboardData:GetMetafileBitsEx"); } + size=dwordsize; break; // All other formats simply return the data as a blob. *************** *** 404,408 **** break; case CF_UNICODETEXT: ! ret = PyWinObject_FromWCHAR((wchar_t *)cData, (size / sizeof(wchar_t))-1); GlobalUnlock(handle); break; --- 410,414 ---- break; case CF_UNICODETEXT: ! ret = PyUnicode_FromWideChar((wchar_t *)cData, (size / sizeof(wchar_t))-1); GlobalUnlock(handle); break; *************** *** 424,427 **** --- 430,434 ---- } return ret; + // @comm An application can enumerate the available formats in advance by // using the EnumClipboardFormats function.<nl> *************** *** 447,453 **** // @flag CF_HDROP|A tuple of Unicode filenames. // @flag CF_UNICODETEXT|A unicode object. ! // @flag CF_UNICODETEXT|A string object. // @flag CF_ENHMETAFILE|A string with binary data obtained from GetEnhMetaFileBits ! // @flag CF_METAFILEPICT|A string with binary data obtained from GetMetaFileBitsEx // @flag All other formats|A string with binary data obtained directly from the // global memory referenced by the handle. --- 454,461 ---- // @flag CF_HDROP|A tuple of Unicode filenames. // @flag CF_UNICODETEXT|A unicode object. ! // @flag CF_OEMTEXT|A string object. ! // @flag CF_TEXT|A string object. // @flag CF_ENHMETAFILE|A string with binary data obtained from GetEnhMetaFileBits ! // @flag CF_METAFILEPICT|A string with binary data obtained from GetMetaFileBitsEx (currently broken) // @flag All other formats|A string with binary data obtained directly from the // global memory referenced by the handle. *************** *** 671,683 **** //***************************************************************************** // ! // @pymethod int|win32clipboard|GetPriorityClipboardFormat|The ! // GetPriorityClipboardFormat function returns the first available clipboard ! // format in the specified list. ! static PyObject * py_getPriority_clipboard_format(PyObject* self, PyObject* args) { ! // @pyparm tuple|formats||Tuple of integers identifying clipboard formats, // in priority order. For a description of the standard clipboard formats, // see Standard Clipboard Formats. --- 679,688 ---- //***************************************************************************** // ! // @pymethod int|win32clipboard|GetPriorityClipboardFormat|Returns the first available clipboard format in the specified list. static PyObject * py_getPriority_clipboard_format(PyObject* self, PyObject* args) { ! // @pyparm sequence|formats||Sequence of integers identifying clipboard formats, // in priority order. For a description of the standard clipboard formats, // see Standard Clipboard Formats. *************** *** 689,708 **** } ! if (!PyTuple_Check(formats)) { ! RETURN_TYPE_ERR( ! "GetPriorityClipboardFormat requires a tuple of integer formats"); ! } ! ! int num_formats = PyTuple_Size(formats); ! UINT *format_list = new UINT[num_formats]; ! PyObject *o; ! for (int i = 0; i < num_formats; i++) { ! o = PyTuple_GetItem(formats, i); ! if (!PyInt_Check(o)) { ! delete format_list; ! RETURN_TYPE_ERR ("GetPriorityClipboardFormat expected integer formats."); ! } ! format_list[i] = PyInt_AsLong(o); ! } int rc; --- 694,701 ---- } ! UINT *format_list; ! DWORD num_formats; ! if (!PyWinObject_AsDWORDArray(formats, (DWORD **)&format_list, &num_formats, FALSE)) ! return NULL; int rc; *************** *** 711,718 **** Py_END_ALLOW_THREADS; ! delete format_list; ! ! return (Py_BuildValue("i", rc)); ! // @pyseeapi GetPriorityClipboardFormat // @pyseeapi Standard Clipboard Formats --- 704,709 ---- Py_END_ALLOW_THREADS; ! free(format_list); ! return PyInt_FromLong(rc); // @pyseeapi GetPriorityClipboardFormat // @pyseeapi Standard Clipboard Formats |