X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e4db172a3b318df9aff178eb6c5da149d56e0859..9c805dec6caf3c98a3797898cffe795b5b56e606:/src/msw/clipbrd.cpp diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index 59d6f2fcb0..594610275d 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -37,6 +37,7 @@ #include "wx/utils.h" #include "wx/intl.h" #include "wx/log.h" + #include "wx/dataobj.h" #endif #if wxUSE_METAFILE @@ -57,10 +58,6 @@ // the functions using wxDataObject in wxClipboard //#define wxUSE_DATAOBJ wxUSE_DRAG_AND_DROP -#if wxUSE_DATAOBJ - #include "wx/dataobj.h" -#endif - #if wxUSE_OLE && !defined(__WXWINCE__) // use OLE clipboard #define wxUSE_OLE_CLIPBOARD 1 @@ -93,13 +90,15 @@ bool wxOpenClipboard() gs_wxClipboardIsOpen = ::OpenClipboard((HWND)win->GetHWND()) != 0; if ( !gs_wxClipboardIsOpen ) + { wxLogSysError(_("Failed to open the clipboard.")); + } return gs_wxClipboardIsOpen; } else { - wxLogDebug(wxT("Can not open clipboard without a main window.")); + wxLogDebug(wxT("Cannot open clipboard without a main window.")); return false; } @@ -550,6 +549,9 @@ wxClipboard::~wxClipboard() void wxClipboard::Clear() { + if ( IsUsingPrimarySelection() ) + return; + #if wxUSE_OLE_CLIPBOARD if (m_lastDataObject) { @@ -558,10 +560,10 @@ void wxClipboard::Clear() if (S_OK == hr) { hr = OleSetClipboard(NULL); - if ( FAILED(hr) ) - { - wxLogApiError(wxT("OleSetClipboard(NULL)"), hr); - } + if ( FAILED(hr) ) + { + wxLogApiError(wxT("OleSetClipboard(NULL)"), hr); + } } m_lastDataObject = NULL; } @@ -579,14 +581,14 @@ bool wxClipboard::Flush() if (S_OK == hr) { hr = OleFlushClipboard(); - if ( FAILED(hr) ) - { - wxLogApiError(wxT("OleFlushClipboard"), hr); + if ( FAILED(hr) ) + { + wxLogApiError(wxT("OleFlushClipboard"), hr); - return false; - } - return true; - } + return false; + } + return true; + } } return false; #else // !wxUSE_OLE_CLIPBOARD @@ -616,6 +618,9 @@ bool wxClipboard::IsOpened() const bool wxClipboard::SetData( wxDataObject *data ) { + if ( IsUsingPrimarySelection() ) + return false; + #if !wxUSE_OLE_CLIPBOARD (void)wxEmptyClipboard(); #endif // wxUSE_OLE_CLIPBOARD @@ -628,6 +633,9 @@ bool wxClipboard::SetData( wxDataObject *data ) bool wxClipboard::AddData( wxDataObject *data ) { + if ( IsUsingPrimarySelection() ) + return false; + wxCHECK_MSG( data, false, wxT("data is invalid") ); #if wxUSE_OLE_CLIPBOARD @@ -721,11 +729,14 @@ void wxClipboard::Close() bool wxClipboard::IsSupported( const wxDataFormat& format ) { - return wxIsClipboardFormatAvailable(format); + return !IsUsingPrimarySelection() && wxIsClipboardFormatAvailable(format); } bool wxClipboard::GetData( wxDataObject& data ) { + if ( IsUsingPrimarySelection() ) + return false; + #if wxUSE_OLE_CLIPBOARD IDataObject *pDataObject = NULL; HRESULT hr = OleGetClipboard(&pDataObject); @@ -761,7 +772,7 @@ bool wxClipboard::GetData( wxDataObject& data ) // enumerate all explicit formats on the clipboard. // note that this does not include implicit / synthetic (automatically // converted) formats. -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL >= 2 // get the format enumerator IEnumFORMATETC *pEnumFormatEtc = NULL; hr = pDataObject->EnumFormatEtc(DATADIR_GET, &pEnumFormatEtc); @@ -794,7 +805,7 @@ bool wxClipboard::GetData( wxDataObject& data ) pEnumFormatEtc->Release(); } -#endif // Debug +#endif // wxDEBUG_LEVEL >= 2 STGMEDIUM medium; // stop at the first valid format found on the clipboard