// ===========================================================================
// implementation
// ===========================================================================
// ===========================================================================
// implementation
// ===========================================================================
// old-style clipboard functions using Windows API
// ---------------------------------------------------------------------------
// old-style clipboard functions using Windows API
// ---------------------------------------------------------------------------
{
// for bitmaps, DIBs will also do
case CF_BITMAP:
return ::IsClipboardFormatAvailable(CF_DIB) != 0;
{
// for bitmaps, DIBs will also do
case CF_BITMAP:
return ::IsClipboardFormatAvailable(CF_DIB) != 0;
// Now go back, calculate all the lengths, and write out the
// necessary header information. Note, wsprintf() truncates the
// string when you overwrite it so you follow up with code to replace
// Now go back, calculate all the lengths, and write out the
// necessary header information. Note, wsprintf() truncates the
// string when you overwrite it so you follow up with code to replace
char *ptr = strstr(buf, "StartHTML");
wsprintf(ptr+10, "%08u", strstr(buf, "<html>") - buf);
*(ptr+10+8) = '\r';
char *ptr = strstr(buf, "StartHTML");
wsprintf(ptr+10, "%08u", strstr(buf, "<html>") - buf);
*(ptr+10+8) = '\r';
ptr = strstr(buf, "EndHTML");
wsprintf(ptr+8, "%08u", strlen(buf));
*(ptr+8+8) = '\r';
ptr = strstr(buf, "EndHTML");
wsprintf(ptr+8, "%08u", strlen(buf));
*(ptr+8+8) = '\r';
ptr = strstr(buf, "StartFragment");
wsprintf(ptr+14, "%08u", strstr(buf, "<!--StartFrag") - buf);
*(ptr+14+8) = '\r';
ptr = strstr(buf, "StartFragment");
wsprintf(ptr+14, "%08u", strstr(buf, "<!--StartFrag") - buf);
*(ptr+14+8) = '\r';
ptr = strstr(buf, "EndFragment");
wsprintf(ptr+12, "%08u", strstr(buf, "<!--EndFrag") - buf);
*(ptr+12+8) = '\r';
ptr = strstr(buf, "EndFragment");
wsprintf(ptr+12, "%08u", strstr(buf, "<!--EndFrag") - buf);
*(ptr+12+8) = '\r';
// Allocate global memory for transfer...
HGLOBAL hText = GlobalAlloc(GMEM_MOVEABLE |GMEM_DDESHARE, strlen(buf)+4);
// Allocate global memory for transfer...
HGLOBAL hText = GlobalAlloc(GMEM_MOVEABLE |GMEM_DDESHARE, strlen(buf)+4);
wxBM->SetWidth(bm.bmWidth);
wxBM->SetHeight(bm.bmHeight);
wxBM->SetDepth(bm.bmPlanes);
wxBM->SetWidth(bm.bmWidth);
wxBM->SetHeight(bm.bmHeight);
wxBM->SetDepth(bm.bmPlanes);
// using OLE clipboard when the app terminates - by default, we call
// OleSetClipboard(NULL) which won't waste RAM, but the app can call
// wxClipboard::Flush() to chaneg this
// using OLE clipboard when the app terminates - by default, we call
// OleSetClipboard(NULL) which won't waste RAM, but the app can call
// wxClipboard::Flush() to chaneg this
// This didn't compile, of course
// return wxSetClipboardData(data);
// TODO
// This didn't compile, of course
// return wxSetClipboardData(data);
// TODO
IEnumFORMATETC *pEnumFormatEtc = NULL;
hr = pDataObject->EnumFormatEtc(DATADIR_GET, &pEnumFormatEtc);
if ( FAILED(hr) || !pEnumFormatEtc )
IEnumFORMATETC *pEnumFormatEtc = NULL;
hr = pDataObject->EnumFormatEtc(DATADIR_GET, &pEnumFormatEtc);
if ( FAILED(hr) || !pEnumFormatEtc )
wxLogTrace(wxTRACE_OleCalls,
wxT("Object on the clipboard supports format %s."),
wxDataObject::GetFormatName(cf));
wxLogTrace(wxTRACE_OleCalls,
wxT("Object on the clipboard supports format %s."),
wxDataObject::GetFormatName(cf));
- if ( !supportedFormats.IsEmpty() )
- {
- FORMATETC formatEtc;
+ // if the format is not available, try the next one
+ // this test includes implicit / sythetic formats
+ if ( !::IsClipboardFormatAvailable(cf) )
+ continue;
+
+ formatEtc.cfFormat = cf;
- // try to get data
- hr = pDataObject->GetData(&formatEtc, &medium);
- if ( FAILED(hr) )
+ default:
+ formatEtc.tymed = TYMED_HGLOBAL;
+ }
+
+ // try to get data
+ hr = pDataObject->GetData(&formatEtc, &medium);
+ if ( FAILED(hr) )
+ {
+ // try other tymed for GDI objects
+ if ( formatEtc.cfFormat == CF_BITMAP )
- // try other tymed for GDI objects
- if ( formatEtc.cfFormat == CF_BITMAP )
- {
- formatEtc.tymed = TYMED_HGLOBAL;
- hr = pDataObject->GetData(&formatEtc, &medium);
- }
+ formatEtc.tymed = TYMED_HGLOBAL;
+ hr = pDataObject->GetData(&formatEtc, &medium);
- // pass the data to the data object
- hr = data.GetInterface()->SetData(&formatEtc, &medium, TRUE);
- if ( FAILED(hr) )
- {
- wxLogDebug(wxT("Failed to set data in wxIDataObject"));
+ wxLogDebug(wxT("Failed to set data in wxIDataObject"));
- // IDataObject only takes the ownership of data if it
- // successfully got it - which is not the case here
- ReleaseStgMedium(&medium);
- }
- else
- {
- result = TRUE;
- }
+ // IDataObject only takes the ownership of data if it
+ // successfully got it - which is not the case here
+ ReleaseStgMedium(&medium);
+ }
+ else
+ {
+ result = true;
wxTextDataObject& textDataObject = (wxTextDataObject &)data;
char* s = (char*)wxGetClipboardData(format);
if ( !s )
wxTextDataObject& textDataObject = (wxTextDataObject &)data;
char* s = (char*)wxGetClipboardData(format);
if ( !s )
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data.GetPreferredFormat());
if ( !bitmap )
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data.GetPreferredFormat());
if ( !bitmap )
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;
wxMetafile* metaFile = (wxMetafile *)wxGetClipboardData(wxDF_METAFILE);
if ( !metaFile )
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;
wxMetafile* metaFile = (wxMetafile *)wxGetClipboardData(wxDF_METAFILE);
if ( !metaFile )