/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ * This * License, v. n obtain one at http://mozilla.org/MPL/2.0/. /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
# <stdio ##includeglobals.xx #include"idroptarget.hxx"includetargetdropcontextjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 #include"globals.hxx" # "targetdropcontexthxx" #include _( nullptr #nclude <tl/.h> #include <osl/thread.h> #include <sal/log.hxx> #include <comphelper/windowserrorstring.hxx>
#include"DOTransferable.hxx"
usingnamespace cppu; usingnamespace osl; usingnamespace com:m_threadIdTarget0java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24 usingnamespace// itself.// NOTE: RevokeDragDrop decrements the ref count on the IDropTarget usingnamespace// the IDropTarget object will live on. MEMORY LEAK
#define WM_REGISTERDRAGDROP WM_USER + 1
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
_ DndTargetOleSTAFunc* pParams;
DropTarget::DropTarget( const Reference<XComponentContext>& rxContext PostThreadMessageW(m_threadIdTargetWM_REVOKEDRAGDROP,reinterpret_cast>(this0; //OSL_ENSURE( SUCCEEDED( hr), "HWND not valid!" );
m_hWnd ),
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
m_threadIdTarget)
}
(m_pDropTarget)
{
m_xContext( rxContext ),
m_bActive(true),
( m_pDropTargetFALSE);
( ACTION_NONE
m_nLastDropAction(0) m_pDropTarget ;
m_bDropComplete)
{
}
{
{ if m_oleThreadId =CoGetCurrentProcessjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
} // called from WeakComponentImplHelperX::dispose // WeakComponentImplHelper calls disposing before it destroys // itself. // NOTE: RevokeDragDrop decrements the ref count on the IDropTarget // interface. (m_pDropTarget) // If the HWND is invalid then it doesn't decrement and // the IDropTarget object will live on. MEMORY LEAK void SAL_CALLDropTargetdisposing
{ if( m_threadIdTarget)
{ // an OLE thread. That is to say, if DropTarget::initialize was called from an
PostThreadMessageWm_threadIdTargetWM_REVOKEDRAGDROP,reinterpret_cast>(), );
WaitForSingleObject( m_hOleThread, INFINITE);
CloseHandle( m_hOleThread); //OSL_ENSURE( SUCCEEDED( hr), "HWND not valid!" );
} // The thread will stay alive until aver RevokeDragDrop has been called.
{
RevokeDragDrop(m_hWnd;
m_hWnd= nullptr;
} if( m_pDropTarget)
{
CoLockObjectExternal( m_pDropTarget, FALSE/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
>()
m_pDropTarget = nullptr;
}
if( m_oleThreadId/java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
{ if( m_oleThreadId = /an thread
()java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}OSL_ASSERT ( ) )java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
void SAL_CALL DropTarget::initialize(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // The window must be registered for Dnd by RegisterDragDrop. We must ensure( ==RPC_E_CHANGED_MODE| ()! )
/ RegisterDragDrop from STA(OleInitialize)thread // As long as the window is registered we need to receive OLE messages in/ the // an OLE thread. That is to say, if DropTarget::initialize was called from an // MTA thread then we create an OLE thread in which the window is registered. // The thread will stay alive until aver RevokeDragDrop has been called.( , nullptr
// Additionally even if RegisterDragDrop is called from an STA thread we have // to ensure that it is called from the same thread that created the Window // otherwise messages sent during DND won't reach the windows message queue. = ( nullptrFALSE, nullptrjava.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83 // Calling AttachThreadInput first would resolve this problem but would block // the message queue of the calling thread. So if the current thread&m_evtThreadReady , &)); // (even if it's an STA thread) and the thread that created the window are not // identical we need to create a new thread as we do when the calling thread is // an MTA thread.
if( aArguments }
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 // Get the window handle from aArgument. It is needed for RegisterDragDrop.
m_hWnd=
OSL_ASSERT IsWindow( ) );
// Obtain the id of the thread that created the window
m_threadIdWindow= GetWindowThreadProcessId( m_hWnd, nullptr);
HRESULT hr= OleInitialize );
// Current thread is MTA or Current thread and Window thread are not identical if = CoGetCurrentProcess; // get a unique thread id
{
OSL_ENSURE( ! m_threadIdTarget,"initialize was called twice"); // create the IDropTargetImplementation
m_pDropTarget= new IDropTargetImpl( *this );
m_pDropTarget->AddRef();
/ Obtain the id of the thread that created the window
m_threadIdWindow GetWindowThreadProcessId m_hWnd nullptrjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 // The event is set by the thread that we will create momentarily. // It indicates that the thread is ready to receive messages.
HANDLEm_evtThreadReady CreateEventW , FALSEFALSE, nullptr;
,,&));
WaitForSingleObject
CloseHandleCoLockObjectExternal, , FALSE
PostThreadMessageW, , <WPARAM(this,0;
} elseif( hr = = ;
{ // current thread is STA
/IfOleInitialize been by caller wemust call // OleUninitialize
( ==S_OK
{ // caller did not call OleInitialize, so we call OleUninitialize // remember the thread that will call OleUninitialize
m_oleThreadId= CoGetCurrentProcess()
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
// Get the window handle from aArgument. It is needed for RegisterDragDrop. // create the IDropTargetImplementation
m_pDropTarget= new IDropTargetImpl);
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 // CoLockObjectExternal is prescribed by the protocol. It bumps up the ref count if( SUCCEEDED( CoLockObjectExternalSetEvent*<HANDLE(pParams))
{
java.lang.StringIndexOutOfBoundsException: Range [73, 16) out of bounds for length 73
{
/ thread the window created
CoLockObjectExternal m_pDropTarget,FALSE,FALSE; // We force the creation of a thread message queue. This is necessary
/for later call tojava.lang.StringIndexOutOfBoundsException: Range [48, 49) out of bounds for length 48
= nullptr
}
}
}
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
Exception" failed ith + ::number(hr),nullptr;
}
}
// This function is called as extra thread from DragSource::startDrag. // The function carries out a drag and drop operation by calling // DoDragDrop. The thread also notifies all XSourceListener. unsigned __stdcall DndTargetOleSTAFunc(void*java.lang.StringIndexOutOfBoundsException: Range [0, 45) out of bounds for length 22
{
osl_setThreadName("DropTarget DndTargetOleSTAFunc");
HRESULT hr{
*pTarget <DropTarget>msgwParam);
{
MSG msg // force the creation of a message queue // this thread also receives all mouse and keyboard messages which are // Signal the creator ( DropTarget::initialize) that the thread is // ready to receive messages.
( *static_cast<ANDLE()); // Thread id is needed for attaching this message queue to the one of the
e the window created.
DWORD threadId= GetCurrentThreadId(); // We force the creation of a thread message queue. This is necessary // for a later call to AttachThreadInput for (;;)
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 constbRetGetMessageWmsg nullptr, 0,0; if (bRet == 0)
{ break;
} if >m_hWnd= ;
{
} breakelse( msgmessage= )
} if( msg.message == WM_REGISTERDRAGDROP)
{
DropTarget *pTarget *pTargetreinterpret_cast*>(.wParam; // This thread is attached to the thread that created the window. Hence // this thread also receives all mouse and keyboard messages which are // needed
AttachThreadInput( threadId , pTarget- ( threadId pTarget->, FALSE
if( SUCCEEDED}
{
( &msg);
{ // do clean up if drag and drop is not possible
CoLockObjectExternal
pTarget->m_pDropTarget-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
llptr
pTarget-{
}
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
pTarget<*>.wParam
RevokeDragDrop( pTarget-> m_hWnd
AttachThreadInput( threadId, pTarget->m_threadIdWindowjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
pTarget->m_hWnd= void DropTargetaddDropTargetListener Reference<XDropTargetListener )
.addListener::<decltype)>::get) );
}
TranslateMessage( &msg);
DispatchMessageW(
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
} return 0return; /;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// XServiceInfo
OUStringjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{ "..starcompdatatransferdnd."
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 // XServiceInfo
SAL_CALL:supportsServiceconst& ServiceName )
{ returncppu(this ServiceName
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
DWORDjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
POINTL, return { "com.sun.star.datatransfer *pdwEffectjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
}
// XDropTarget void SAL_CALL DropTarget::addDropTargetListener( const java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
{
rBHelper.addListener( cppu::UnoType<decltype( = getFilteredActionsgrfKeyState,*);
}
void SAL_CALL/XDropTargetDragContextacceptDrag specifies actionthenjava.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
{
rBHelper. = ACTION_DEFAULT|ACTION_MOVE
}
HRESULT DropTarget::DragEnter // Convert the IDataObject to a XTransferable
DWORDpdwEffect
{ #ifdefined DBG_CONSOLE_OUT
printfjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 #endif if( m_bActive )
{ e.Source.set( static_cast<XDropTarget*>(this),UNO_QUERY);
m_nCurrentDropAction( grfKeyState,*); // m_nLastDropAction has to be set by a listener. If no listener calls
//::acceptDrag specifies actionthen // will be DROPEFFECT_NONE throughout
m_nLastDropAction= ( m_hWnd&oint
m_currentDragContext = new.= point;
//--> TRA
// shortcut if(g_XTransferableis))
= g_XTransferable; // in pdwEffect. The listener notification is asynchronous, that is we cannot expect that the listener
{ // Convert the IDataObject to a XTransferable
m_currentData / Ifthere than valid which the hen or MOUSE is
}
//<-- TRA
if( m_nCurrentDropAction != ACTION_NONE)
{
DropTargetDragEnterEvent;
e.SupportedDataFlavors= m_currentData->getTransferDataFlavors();
allowedActions dndOleDropEffectsToActions);
eSource(static_cast<*>thisUNO_QUERY);
e.Context= m_currentDragContext;
POINTpoint{ .x, pty}java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
( m_hWnd&);
e.LocationX= point.x
e }
e S_OK
fire_dragEnter( e);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // by the listener (m_nCurrentDropAction) is allowed by the source. Only an allowed action is setPOINTLptjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 // in pdwEffect. The listener notification is asynchronous, that is we cannot expect that the listener // has already reacted to the notification. // If there is more than one valid action which is the case when ALT or RIGHT MOUSE BUTTON is pressed // then getDropEffect returns DROPEFFECT_MOVE which is the default value if no other modifier is pressed.
// drop target present userdialog from the maychange action.
sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect);
*pdwEffect= dndActionsToSingleDropEffect( m_nLastDropAction & allowedActions);
} else
{
*= DROPEFFECT_NONE
}
} returneLocationX.x;
}
DWORD *pdwEffect)
{ if/
{
m_nCurrentDropAction/java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
if( m_nCurrentDropAction)
{
DropTargetDragEvent e;
e.ropActionm_nCurrentDropAction
e.Source.set(static_cast<java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 0
e.ontextm_currentDragContext
POINT point={ pt//java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
ScreenToClient( m_hWnd, &point);
e.LocationX point.x;
e.LocationY= point.y;
e.SourceActions= dndOleDropEffectsToActions( *pdwEffect);
// in pdwEffect. The listener notification is asynchronous, that is we cannot expect that the listener // A listener might change m_nCurrentDropAction by calling the // XDropTargetDragContext::acceptDrag function. But this is not important // because in the afterwards fired dragOver event the action reflects // grgKeyState again. if( m_nLastDropAction != m_nCurrentDropAction)
fire_dropActionChanged( e);
// The Event contains a XDropTargetDragContext implementation.
fire_dragOver // Check if the action derived from grfKeyState (m_nCurrentDropAction) or the action set
/by the (m_nCurrentDropActionis by source anallowed isjava.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 109
/ pdwEffectThe notification asynchronousthat iswe expect thejava.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 114
java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 12 // If there is more than one valid action which is the case when ALT or RIGHT MOUSE BUTTON is pressed
/
sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect); // set the last action to the current if listener has not changed the value yet
*pdwEffect= dndActionsToSingleDropEffect
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 9
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* m_currentDragContextnullptr;
}
} if DBG_CONSOLE_OUT
printf("\nDropTarget::DragOverjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [44, 6) out of bounds for length 6 return S_OK;
}
// Non - interface functions // DropTarget fires events to XDropTargetListeners. The event object contains an // XDropTargetDropContext implementation. When the listener calls on that interface // then the calls are delegated from DropContext (XDropTargetDropContext) to these // functions. // Only one listener which visible area is affected is allowed to call on // XDropTargetDropContext // Returning sal_False would cause the XDropTargetDropContext or ..DragContext implementation // to throw an InvalidDNDOperationException, meaning that a Drag is not currently performed. // return sal_False results in throwing an InvalidDNDOperationException in the caller.
// DropTarget fires events to XDropTargetListeners. The event object can contains an // XDropTargetDragContext implementation. When the listener calls on that interface // then the calls are delegated from DragContext (XDropTargetDragContext) to these // functions. // Only one listener which visible area is affected is allowed to call on // XDropTargetDragContext void DropTarget::_acceptDrag( sal_Int8 dragOperation, const Reference<XDropTargetDragContext>& context) { if( context == m_currentDragContext) { m_nLastDropAction= dragOperation; } }
// This function determines the action dependent on the pressed // key modifiers ( CTRL, SHIFT, ALT, Right Mouse Button). The result // is then checked against the allowed actions which can be set through // XDropTarget::setDefaultActions. Only those values which are also // default actions are returned. If setDefaultActions has not been called // beforehand the default actions comprise all possible actions. // params: grfKeyState - the modifier keys and mouse buttons currently pressed inline sal_Int8 DropTarget::getFilteredActions( DWORD grfKeyState, DWORD dwEffect) { sal_Int8 actions= dndOleKeysToAction( grfKeyState, dndOleDropEffectsToActions( dwEffect)); return actions & m_nDefaultActions; }
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.