bool MCMacOSXScrapPasteboard::QueryFlavors(ScrapFlavorType*& r_types, uint4& r_type_count) { bool t_success; t_success = true; UInt32 t_count; t_count = 0; if (t_success) if (GetScrapFlavorCount(m_scrap, &t_count) != noErr) t_success = false; ScrapFlavorInfo *t_info_array; t_info_array = NULL; if (t_success) { t_info_array = new ScrapFlavorInfo[t_count]; if (t_info_array == NULL) t_success = false; } if (t_success) if (GetScrapFlavorInfoList(m_scrap, &t_count, t_info_array) != noErr) t_success = false; ScrapFlavorType *t_types; t_types = NULL; if (t_success) { t_types = new ScrapFlavorType[t_count]; if (t_types == NULL) t_success = false; } if (t_success) { for(uint4 i = 0; i < t_count; ++i) t_types[i] = t_info_array[i] . flavorType; r_types = t_types; r_type_count = t_count; } else delete t_types; delete t_info_array; return t_success; }
static PyObject *ScrapObj_GetScrapFlavorInfoList(ScrapObject *_self, PyObject *_args) { PyObject *_res = NULL; PyObject *item; OSStatus _err; UInt32 infoCount; ScrapFlavorInfo *infolist = NULL; int i; if (!PyArg_ParseTuple(_args, "")) return NULL; _err = GetScrapFlavorCount(_self->ob_itself, &infoCount); if (_err != noErr) return PyMac_Error(_err); if (infoCount == 0) return Py_BuildValue("[]"); if ((infolist = (ScrapFlavorInfo *)malloc(infoCount*sizeof(ScrapFlavorInfo))) == NULL ) return PyErr_NoMemory(); _err = GetScrapFlavorInfoList(_self->ob_itself, &infoCount, infolist); if (_err != noErr) { free(infolist); return NULL; } if ((_res = PyList_New(infoCount)) == NULL ) { free(infolist); return NULL; } for(i=0; i<infoCount; i++) { item = Py_BuildValue("O&l", PyMac_BuildOSType, infolist[i].flavorType, infolist[i].flavorFlags); if ( !item || PyList_SetItem(_res, i, item) < 0 ) { Py_DECREF(_res); free(infolist); return NULL; } } free(infolist); return _res; }
tyscraptype getscraptype (void) { /* return the type of the first object on the scrap. */ #ifdef MACVERSION //Code change by Timothy Paustian Sunday, June 25, 2000 11:06:10 AM //Carbon support for new Scrap Manager API #if TARGET_API_MAC_CARBON == 1 ScrapRef scrap; UInt32 infoNumber = 1; ScrapFlavorInfo info[1]; OSStatus status; status = GetCurrentScrap(&scrap); if(status != noErr) return 0; //now get the first item on the list status = GetScrapFlavorInfoList(scrap, &infoNumber, info); if(status != noErr) return 0; return (tyscraptype)info[1].flavorType; #else PScrapStuff pscrap; OSType **htype; pscrap = InfoScrap (); htype = (OSType **) (*pscrap).scrapHandle; if (htype == nil) return (0); return (**htype); #endif #endif #ifdef WIN95VERSION UINT format = 0; while (true) { format = EnumClipboardFormats (format); if (format == 0) return (0); if (format == win_textscraptype) return (textscraptype); if (format == win_pictscraptype) return (pictscraptype); if (format == win_opscraptype) return (opscraptype); if (format == win_scriptscraptype) return (scriptscraptype); if (format == win_wpscraptype) return (wpscraptype); if (format == win_hashscraptype) return (hashscraptype); if (format == win_menuscraptype) return (menuscraptype); } #endif } /*getscraptype*/