bool wxHTMLDataObject::SetData(size_t WXUNUSED(len), const void *buf) { if ( buf == NULL ) return false; // Windows and Mac always use UTF-8, and docs suggest GTK does as well. wxWCharBuffer buffer = wxConvUTF8.cMB2WX( (const char*)buf ); wxString html(buffer); // To be consistent with other platforms, we only add the Fragment part // of the Windows HTML clipboard format to the data object. We do the // trimming here as we can take advantage of the wxString methods here, // simplifying the trimming code considerably. #if __WXMSW__ int fragmentStart = html.rfind("StartFragment"); int fragmentEnd = html.rfind("EndFragment"); if (fragmentStart != wxNOT_FOUND && fragmentEnd != wxNOT_FOUND) { int startCommentEnd = html.find("-->", fragmentStart) + 3; int endCommentStart = html.rfind("<!--", fragmentEnd); if (startCommentEnd != wxNOT_FOUND && endCommentStart != wxNOT_FOUND) html = html.Mid(startCommentEnd, endCommentStart - startCommentEnd); } #endif SetHTML( html ); return true; }
bool CHTMLSection::SetHTMLFile( LPCTSTR pcszFilename ) { bool bRetVal = false; LPTSTR pcszHTML = NULL; UINT uLength = 0; if( LoadTextFile( pcszFilename, pcszHTML, uLength ) ) { TCHAR drive[_MAX_DRIVE]; TCHAR dir[_MAX_DIR]; TCHAR fname[_MAX_FNAME]; TCHAR ext[_MAX_EXT]; _tsplitpath( pcszFilename, drive, dir, fname, ext ); TCHAR path_buffer[_MAX_PATH]; _tmakepath( path_buffer, drive, dir, NULL, NULL ); SetHTML( pcszHTML, uLength, path_buffer ); bRetVal = true; delete[] pcszHTML; } return bRetVal; }
bool wxHTMLDataObject::SetData(size_t WXUNUSED(len), const void *buf) { if ( buf == NULL ) return false; // Windows and Mac always use UTF-8, and docs suggest GTK does as well. wxString html = wxString::FromUTF8(static_cast<const char*>(buf)); #ifdef __WXMSW__ // To be consistent with other platforms, we only add the Fragment part // of the Windows HTML clipboard format to the data object. int fragmentStart = html.rfind("StartFragment"); int fragmentEnd = html.rfind("EndFragment"); if (fragmentStart != wxNOT_FOUND && fragmentEnd != wxNOT_FOUND) { int startCommentEnd = html.find("-->", fragmentStart) + 3; int endCommentStart = html.rfind("<!--", fragmentEnd); if (startCommentEnd != wxNOT_FOUND && endCommentStart != wxNOT_FOUND) html = html.Mid(startCommentEnd, endCommentStart - startCommentEnd); } #endif // __WXMSW__ SetHTML( html ); return true; }