Thread: [pywin32-checkins] pywin32/win32/src win32clipboardmodule.cpp,1.12,1.13
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-12-01 08:22:32
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv11683 Modified Files: win32clipboardmodule.cpp Log Message: Return raw binary data for all clipboard formats (other than those already with special handling). Add GetGlobalMemory so the data in a handle can be fetched manually. Index: win32clipboardmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32clipboardmodule.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32clipboardmodule.cpp 29 Nov 2003 05:50:18 -0000 1.12 --- win32clipboardmodule.cpp 1 Dec 2003 08:22:28 -0000 1.13 *************** *** 331,335 **** } ! void * cData; DWORD size; switch (format) { --- 331,335 ---- } ! void * cData = NULL; DWORD size; switch (format) { *************** *** 365,376 **** } break; ! case CF_BITMAP: ! PyErr_SetString(PyExc_NotImplementedError, "GetClipboardData(CF_BITMAP) unimplemented"); ! return NULL; ! break; ! case CF_DIB: ! PyErr_SetString(PyExc_NotImplementedError, "GetClipboardData(CF_DIB) unimplemented"); ! return NULL; ! break; default: cData = GlobalLock(handle); --- 365,369 ---- } break; ! // All other formats simply return the data as a blob. default: cData = GlobalLock(handle); *************** *** 415,432 **** GlobalUnlock(handle); break; - case CF_ENHMETAFILE: - case CF_METAFILEPICT: - case CF_BITMAP: - case CF_DIB: - ret = PyString_FromStringAndSize((char *)cData, size); - free(cData); - break; default: ! ret = PyString_FromStringAndSize((char *)cData, size); GlobalUnlock(handle); break; } return ret; - // @comm An application can enumerate the available formats in advance by // using the EnumClipboardFormats function.<nl> --- 408,422 ---- GlobalUnlock(handle); break; default: ! assert(cData); ! if (!cData) { ! ret = Py_None; ! Py_INCREF(ret); ! } else ! ret = PyString_FromStringAndSize((char *)cData, size); GlobalUnlock(handle); break; } return ret; // @comm An application can enumerate the available formats in advance by // using the EnumClipboardFormats function.<nl> *************** *** 446,453 **** // @pyseeapi Standard Clipboard Formats ! // @rdesc If the function succeeds, the return value is either a Unicode object ! // (if format is CF_UNICODETEXT), otherwise a string object. Depending on ! // format (eg, CF_METAFILEPICT) the string may contain raw data bytes.<nl> ! // If the function fails, the standard win32api.error exception is raised. } --- 436,472 ---- // @pyseeapi Standard Clipboard Formats ! // @rdesc If the function fails, the standard win32api.error exception ! // is raised. If the function succeeds, the return value is as ! // described in the following table: ! // @flagh Format|Result type ! // @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. ! } ! ! //***************************************************************************** ! // ! // @pymethod string|win32clipboard|GetGlobalMemory|Returns the contents of the specified ! // global memory object. ! static PyObject * ! py_get_global_memory(PyObject* self, PyObject* args) ! { ! int iglobal; ! if (!PyArg_ParseTuple(args, "i", &iglobal)) ! return NULL; ! HGLOBAL hglobal = (HGLOBAL)iglobal; ! DWORD size = GlobalSize(hglobal); ! if (!size) ! return ReturnAPIError("GlobalSize"); ! void *p = GlobalLock(hglobal); ! if (!p) ! return ReturnAPIError("GlobalAlloc"); ! PyObject *ret = PyString_FromStringAndSize((char *)p, size); ! GlobalUnlock(hglobal); ! return ret; } *************** *** 1080,1083 **** --- 1099,1106 ---- // the clipboard viewer chain. {"GetClipboardViewer", py_get_clipboard_viewer, 1}, + + // @pymeth GetGlobalMemory|Returns the contents of the specified global + // memory object. + {"GetGlobalMemory", py_get_global_memory, 1}, // @pymeth GetOpenClipboardWindow|Retrieves the handle of the window that |