X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a1b806b98241ab649c169aaa1f134df85e80fb8b..0ec1064b791833f087f192e79371dc1e2d828532:/src/msw/ole/dataobj.cpp?ds=sidebyside diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 156605e408..ad02bc6be3 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -67,6 +67,21 @@ #define GetTymedName(tymed) wxEmptyString #endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL +wxDataFormat HtmlFormatFixup(wxDataFormat format) +{ + // Since the HTML format is dynamically registered, the wxDF_HTML + // format does not match the native constant in the way other formats do, + // so for the format checks below to work, we must change the native + // id to the wxDF_HTML constant. + wxChar s_szBuf[256]; + if (::GetClipboardFormatName(format, s_szBuf, WXSIZEOF(s_szBuf))) + { + if (s_szBuf == wxString("HTML Format")) + format = wxDF_HTML; + } + return format; +} + // ---------------------------------------------------------------------------- // wxIEnumFORMATETC interface implementation // ---------------------------------------------------------------------------- @@ -139,7 +154,7 @@ private: void wxDataFormat::SetId(const wxString& format) { - m_format = (wxDataFormat::NativeFormat)::RegisterClipboardFormat(format.wx_str()); + m_format = (wxDataFormat::NativeFormat)::RegisterClipboardFormat(format.t_str()); if ( !m_format ) { wxLogError(_("Couldn't register clipboard format '%s'."), format); @@ -183,7 +198,10 @@ wxIEnumFORMATETC::wxIEnumFORMATETC(const wxDataFormat *formats, ULONG nCount) m_nCount = nCount; m_formats = new CLIPFORMAT[nCount]; for ( ULONG n = 0; n < nCount; n++ ) { - m_formats[n] = formats[n].GetFormatId(); + if (formats[n].GetFormatId() != wxDF_HTML) + m_formats[n] = formats[n].GetFormatId(); + else + m_formats[n] = ::RegisterClipboardFormat(wxT("HTML Format")); } } @@ -290,6 +308,7 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium) // for the bitmaps and metafiles we use the handles instead of global memory // to pass the data wxDataFormat format = (wxDataFormat::NativeFormat)pformatetcIn->cfFormat; + format = HtmlFormatFixup(format); switch ( format ) { @@ -432,6 +451,8 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc, { wxDataFormat format = pformatetc->cfFormat; + format = HtmlFormatFixup(format); + // this is quite weird, but for file drag and drop, explorer // calls our SetData() with the formats we do *not* support! // @@ -459,14 +480,14 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc, size_t size; switch ( format ) { + case wxDF_HTML: case CF_TEXT: case CF_OEMTEXT: size = strlen((const char *)pBuf); break; #if !(defined(__BORLANDC__) && (__BORLANDC__ < 0x500)) case CF_UNICODETEXT: -#if ( defined(__BORLANDC__) && (__BORLANDC__ > 0x530) ) \ - || ( defined(__MWERKS__) && defined(__WXMSW__) ) +#if ( defined(__BORLANDC__) && (__BORLANDC__ > 0x530) ) size = std::wcslen((const wchar_t *)pBuf) * sizeof(wchar_t); #else size = wxWcslen((const wchar_t *)pBuf) * sizeof(wchar_t); @@ -568,6 +589,8 @@ STDMETHODIMP wxIDataObject::QueryGetData(FORMATETC *pformatetc) // and now check the type of data requested wxDataFormat format = pformatetc->cfFormat; + format = HtmlFormatFixup(format); + if ( m_pDataObject->IsSupportedFormat(format) ) { wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::QueryGetData: %s ok"), wxGetFormatName(format)); @@ -1129,7 +1152,7 @@ bool wxFileDataObject::GetDataHere(void *WXUNUSED_IN_WINCE(pData)) const #endif // wxUSE_UNICODE_MSLU { len = m_filenames[i].length(); - memcpy(pbuf, m_filenames[i].wx_str(), len*sizeOfChar); + memcpy(pbuf, m_filenames[i].t_str(), len*sizeOfChar); } pbuf += len*sizeOfChar;