void QClipboard::setMimeData(QMimeData *src, Mode mode) { if (mode != Clipboard) { delete src; return; } QClipboardData *d = clipboardData(); if (!(d->iData && d->iData->mimeData() == src)) { d->releaseIData(); d->iData = new QOleDataObject(src); } if (OleSetClipboard(d->iData) != S_OK) { d->releaseIData(); qErrnoWarning("QClipboard::setMimeData: Failed to set data on clipboard"); return; } #if defined(Q_OS_WINCE) // As WinCE does not support notifications we send the signal here // We will get no event when the clipboard changes outside... emit dataChanged(); emit changed(Clipboard); #endif }
bool QClipboard::event(QEvent *e) { if (e->type() != QEvent::Clipboard) return QObject::event(e); QClipboardData *d = clipboardData(); MSG *m = (MSG *)((QClipboardEvent*)e)->data(); if (!m) { // this is sent to render all formats at app shut down if (ownsClipboard()) { OleFlushClipboard(); d->releaseIData(); } return true; } bool propagate = false; if (m->message == WM_CHANGECBCHAIN) { if ((HWND)m->wParam == d->nextClipboardViewer) d->nextClipboardViewer = (HWND)m->lParam; else propagate = true; } else if (m->message == WM_DRAWCLIPBOARD) { emitChanged(QClipboard::Clipboard); if (!ownsClipboard() && d->iData) // clean up the clipboard object if we no longer own the clipboard d->releaseIData(); propagate = true; } if (propagate && d->nextClipboardViewer) { if (ptrIsHungAppWindow == 0) { QSystemLibrary library(QLatin1String("User32")); ptrIsHungAppWindow = (PtrIsHungAppWindow)library.resolve("IsHungAppWindow"); } if (ptrIsHungAppWindow && ptrIsHungAppWindow(d->nextClipboardViewer)) { qWarning("%s: Cowardly refusing to send clipboard message to hung application...", Q_FUNC_INFO); } else if (isProcessBeingDebugged(d->nextClipboardViewer)) { // Also refuse if the process is being debugged, specifically, if it is // displaying a runtime assert, which is not caught by isHungAppWindow(). qWarning("%s: Cowardly refusing to send clipboard message to application under debugger...", Q_FUNC_INFO); } else { SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam); } } return true; }
void QClipboard::setMimeData(QMimeData *src, Mode mode) { if (mode != Clipboard) return; QClipboardData *d = clipboardData(); if (!(d->iData && d->iData->mimeData() == src)) { d->releaseIData(); d->iData = new QOleDataObject(src); } if (OleSetClipboard(d->iData) != S_OK) { d->releaseIData(); qErrnoWarning("QClipboard::setMimeData: Failed to set data on clipboard"); return; } }
void QClipboard::clear(Mode mode) { if (mode != Clipboard) return; QClipboardData *d = clipboardData(); d->releaseIData(); if (OleSetClipboard(0) != S_OK) { qErrnoWarning("QClipboard::clear: Failed to clear data on clipboard"); return; } }
bool QClipboard::event(QEvent *e) { if (e->type() != QEvent::Clipboard) return QObject::event(e); QClipboardData *d = clipboardData(); MSG *m = (MSG *)((QClipboardEvent*)e)->data(); if (!m) { // this is sent to render all formats at app shut down if (ownsClipboard()) { OleFlushClipboard(); d->releaseIData(); } return true; } bool propagate = false; if (m->message == WM_CHANGECBCHAIN) { if ((HWND)m->wParam == d->nextClipboardViewer) d->nextClipboardViewer = (HWND)m->lParam; else propagate = true; } else if (m->message == WM_DRAWCLIPBOARD) { emitChanged(QClipboard::Clipboard); if (!ownsClipboard() && d->iData) // clean up the clipboard object if we no longer own the clipboard d->releaseIData(); propagate = true; } if (propagate && d->nextClipboardViewer) { SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam); } return true; }
void QClipboard::clear(Mode mode) { if (mode != Clipboard) return; QClipboardData *d = clipboardData(); d->releaseIData(); if (OleSetClipboard(0) != S_OK) { qErrnoWarning("QClipboard::clear: Failed to clear data on clipboard"); return; } #if defined(Q_OS_WINCE) // As WinCE does not support notifications we send the signal here // We will get no event when the clipboard changes outside... emit dataChanged(); emit changed(Clipboard); #endif }