/** First start a new drag and drop thread if thelastonehasfinished
???? Dowereallyneedaseparatethreadfor everyDndoperationoronlyifthesource threadisanMTAthread ????
*/ void DragSource::StartDragImpl( const DragGestureEvent& trigger,
sal_Int8 sourceActions,
sal_Int32 /*cursor*/,
sal_Int32 /*image*/, const Reference<XTransferable >& trans, const Reference<XDragSourceListener >& listener )
{ // The actions supported by the drag source
m_sourceActions= sourceActions; // We need to know which mouse button triggered the operation. // If it was the left one, then the drop occurs when that button // has been released and if it was the right one then the drop // occurs when the right button has been released. If the event is not // set then we assume that the left button is pressed.
MouseEvent evtMouse;
trigger.Event >>= evtMouse;
m_MouseButton= evtMouse.Buttons;
// The SourceContext class administers the XDragSourceListener s and // fires events to them. An instance only exists in the scope of this // function. However, the drag and drop operation causes callbacks // to the IDropSource interface implemented in this class (but only // while this function executes). The source context is also used // in DragSource::QueryContinueDrag.
m_currentContext = new SourceContext(this, listener);
// Convert the XTransferable data object into an IDataObject object;
// Obtain the id of the thread that created the window
DWORD processId;
m_threadIdWindow= GetWindowThreadProcessId( m_hAppWindow, &processId);
// hold the instance for the DnD thread, it's too late // to acquire at the start of the thread procedure // the thread procedure is responsible for the release
acquire();
// The thread accesses members of this instance but does not call acquire. // Hopefully this instance is not destroyed before the thread has terminated.
HANDLE hThread
= reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0, DndOleSTAFunc, this, 0, nullptr));
// detach from thread
CloseHandle(hThread);
}
// XInitialization /** aArguments contains a machine id */ void SAL_CALL DragSource::initialize( const Sequence< Any >& aArguments )
{ if( aArguments.getLength() >=2)
m_hAppWindow= reinterpret_cast<HWND>(static_cast<sal_uIntPtr>(*o3tl::doAccess<sal_uInt64>(aArguments[1])));
OSL_ASSERT( IsWindow( m_hAppWindow) );
}
// fire dropActionChanged event. // this is actually done by the context, which also detects whether the action // changed at all
sal_Int8 dropAction= fEscapePressed ? ACTION_NONE :
dndOleKeysToAction( grfKeyState, m_sourceActions);
/** This function is called as extra thread from DragSource::executeDrag.Thefunction carriesoutadraganddropoperationbycalling DoDragDrop.Thethreadalsonotifiesall
XSourceListener. */ unsigned __stdcall DndOleSTAFunc(void* pParams)
{
osl_setThreadName("DragSource DndOleSTAFunc");
// The structure contains all arguments for DoDragDrop and other
DragSource *pSource= static_cast<DragSource*>(pParams);
// Drag and drop only works in a thread in which OleInitialize is called.
HRESULT hr= OleInitialize( nullptr);
if(SUCCEEDED(hr))
{ // We force the creation of a thread message queue. This is necessary // for a later call to AttachThreadInput
MSG msgtemp;
PeekMessageW( &msgtemp, nullptr, WM_USER, WM_USER, PM_NOREMOVE);
DWORD threadId= GetCurrentThreadId();
// This thread is attached to the thread that created the window. Hence // this thread also receives all mouse and keyboard messages which are // needed by DoDragDrop
AttachThreadInput( threadId , pSource->m_threadIdWindow, TRUE );
// #105428 detach my message queue from the other threads // message queue before calling fire_dragDropEnd else // the office may appear to hang sometimes
AttachThreadInput( threadId, pSource->m_threadIdWindow, FALSE);
//--> TRA // clear the global transferable again
g_XTransferable.clear(); //<-- TRA
OSL_ENSURE( hr != E_INVALIDARG, "IDataObject impl does not contain valid data");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.