summaryrefslogtreecommitdiff
path: root/dtrans/source/win32/dnd/target.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dtrans/source/win32/dnd/target.cxx')
-rw-r--r--dtrans/source/win32/dnd/target.cxx72
1 files changed, 37 insertions, 35 deletions
diff --git a/dtrans/source/win32/dnd/target.cxx b/dtrans/source/win32/dnd/target.cxx
index ba76771a484f..5f2dea68d5a1 100644
--- a/dtrans/source/win32/dnd/target.cxx
+++ b/dtrans/source/win32/dnd/target.cxx
@@ -20,6 +20,8 @@
#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/any.hxx>
+
#include <stdio.h>
#include "target.hxx"
#include "idroptarget.hxx"
@@ -45,14 +47,14 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams);
DropTarget::DropTarget( const Reference<XComponentContext>& rxContext):
WeakComponentImplHelper<XInitialization,XDropTarget, XServiceInfo>(m_mutex),
- m_hWnd( NULL),
+ m_hWnd( nullptr),
m_threadIdWindow(0),
m_threadIdTarget(0),
- m_hOleThread(0),
+ m_hOleThread(nullptr),
m_oleThreadId( 0),
- m_pDropTarget( NULL),
+ m_pDropTarget( nullptr),
m_xContext( rxContext ),
- m_bActive(sal_True),
+ m_bActive(true),
m_nDefaultActions(ACTION_COPY|ACTION_MOVE|ACTION_LINK|ACTION_DEFAULT),
m_nCurrentDropAction( ACTION_NONE),
m_nLastDropAction(0),
@@ -75,7 +77,7 @@ void SAL_CALL DropTarget::disposing()
if( m_threadIdTarget)
{
// Call RevokeDragDrop and wait for the OLE thread to die;
- PostThreadMessage( m_threadIdTarget, WM_REVOKEDRAGDROP, (WPARAM)this, 0);
+ PostThreadMessage( m_threadIdTarget, WM_REVOKEDRAGDROP, reinterpret_cast<WPARAM>(this), 0);
WaitForSingleObject( m_hOleThread, INFINITE);
CloseHandle( m_hOleThread);
//OSL_ENSURE( SUCCEEDED( hr), "HWND not valid!" );
@@ -83,7 +85,7 @@ void SAL_CALL DropTarget::disposing()
else
{
RevokeDragDrop( m_hWnd);
- m_hWnd= 0;
+ m_hWnd= nullptr;
}
if( m_pDropTarget)
{
@@ -122,33 +124,33 @@ void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments )
if( aArguments.getLength() > 0)
{
// Get the window handle from aArgument. It is needed for RegisterDragDrop.
- m_hWnd= *(HWND*)aArguments[0].getValue();
+ m_hWnd= reinterpret_cast<HWND>(static_cast<sal_uIntPtr>(*o3tl::doAccess<sal_uInt64>(aArguments[0])));
OSL_ASSERT( IsWindow( m_hWnd) );
// Obtain the id of the thread that created the window
- m_threadIdWindow= GetWindowThreadProcessId( m_hWnd, NULL);
+ m_threadIdWindow= GetWindowThreadProcessId( m_hWnd, nullptr);
- HRESULT hr= OleInitialize( NULL);
+ HRESULT hr= OleInitialize( nullptr);
// Current thread is MTA or Current thread and Window thread are not identical
if( hr == RPC_E_CHANGED_MODE || GetCurrentThreadId() != m_threadIdWindow )
{
OSL_ENSURE( ! m_threadIdTarget,"initialize was called twice");
// create the IDropTargetImplementation
- m_pDropTarget= new IDropTargetImpl( *static_cast<DropTarget*>( this) );
+ m_pDropTarget= new IDropTargetImpl( *this );
m_pDropTarget->AddRef();
// Obtain the id of the thread that created the window
- m_threadIdWindow= GetWindowThreadProcessId( m_hWnd, NULL);
+ m_threadIdWindow= GetWindowThreadProcessId( m_hWnd, nullptr);
// The event is set by the thread that we will create momentarily.
// It indicates that the thread is ready to receive messages.
- HANDLE m_evtThreadReady= CreateEvent( NULL, FALSE, FALSE, NULL);
+ HANDLE m_evtThreadReady= CreateEvent( nullptr, FALSE, FALSE, nullptr);
- m_hOleThread= CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)DndTargetOleSTAFunc,
+ m_hOleThread= CreateThread( nullptr, 0, DndTargetOleSTAFunc,
&m_evtThreadReady, 0, &m_threadIdTarget);
WaitForSingleObject( m_evtThreadReady, INFINITE);
CloseHandle( m_evtThreadReady);
- PostThreadMessage( m_threadIdTarget, WM_REGISTERDRAGDROP, (WPARAM)static_cast<DropTarget*>(this), 0);
+ PostThreadMessage( m_threadIdTarget, WM_REGISTERDRAGDROP, reinterpret_cast<WPARAM>(this), 0);
}
else if( hr == S_OK || hr == S_FALSE)
{
@@ -164,7 +166,7 @@ void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments )
// Get the window handle from aArgument. It is needed for RegisterDragDrop.
// create the IDropTargetImplementation
- m_pDropTarget= new IDropTargetImpl( *static_cast<DropTarget*>( this) );
+ m_pDropTarget= new IDropTargetImpl( *this );
m_pDropTarget->AddRef();
// CoLockObjectExternal is prescribed by the protocol. It bumps up the ref count
if( SUCCEEDED( CoLockObjectExternal( m_pDropTarget, TRUE, FALSE)))
@@ -175,7 +177,7 @@ void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments )
CoLockObjectExternal( m_pDropTarget, FALSE, FALSE);
m_pDropTarget->Release();
m_pDropTarget = nullptr;
- m_hWnd= NULL;
+ m_hWnd= nullptr;
}
}
}
@@ -192,25 +194,25 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams)
{
osl_setThreadName("DropTarget DndTargetOleSTAFunc");
- HRESULT hr= OleInitialize( NULL);
+ HRESULT hr= OleInitialize( nullptr);
if( SUCCEEDED( hr) )
{
MSG msg;
// force the creation of a message queue
- PeekMessage( &msg, (HWND)NULL, 0, 0, PM_NOREMOVE);
+ PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE);
// Signal the creator ( DropTarget::initialize) that the thread is
// ready to receive messages.
- SetEvent( *(HANDLE*) pParams);
+ SetEvent( *static_cast<HANDLE*>(pParams));
// Thread id is needed for attaching this message queue to the one of the
// thread where the window was created.
DWORD threadId= GetCurrentThreadId();
// We force the creation of a thread message queue. This is necessary
// for a later call to AttachThreadInput
- while( GetMessage(&msg, (HWND)NULL, 0, 0) )
+ while( GetMessage(&msg, nullptr, 0, 0) )
{
if( msg.message == WM_REGISTERDRAGDROP)
{
- DropTarget *pTarget= (DropTarget*)msg.wParam;
+ DropTarget *pTarget= reinterpret_cast<DropTarget*>(msg.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
@@ -224,17 +226,17 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams)
CoLockObjectExternal( pTarget->m_pDropTarget, FALSE, FALSE);
pTarget->m_pDropTarget->Release();
pTarget->m_pDropTarget = nullptr;
- pTarget->m_hWnd= NULL;
+ pTarget->m_hWnd= nullptr;
}
}
}
else if( msg.message == WM_REVOKEDRAGDROP)
{
- DropTarget *pTarget= (DropTarget*)msg.wParam;
+ DropTarget *pTarget= reinterpret_cast<DropTarget*>(msg.wParam);
RevokeDragDrop( pTarget-> m_hWnd);
// Detach this thread from the window thread
AttachThreadInput( threadId, pTarget->m_threadIdWindow, FALSE);
- pTarget->m_hWnd= 0;
+ pTarget->m_hWnd= nullptr;
break;
}
TranslateMessage( &msg);
@@ -315,7 +317,7 @@ HRESULT DropTarget::DragEnter( IDataObject *pDataObj,
m_nLastDropAction= ACTION_DEFAULT | ACTION_MOVE;
m_currentDragContext= static_cast<XDropTargetDragContext*>( new TargetDragContext(
- static_cast<DropTarget*>(this) ) );
+ this ) );
//--> TRA
@@ -423,9 +425,9 @@ HRESULT DropTarget::DragLeave()
if( m_bActive)
{
- m_currentData=0;
- m_currentDragContext= 0;
- m_currentDropContext= 0;
+ m_currentData=nullptr;
+ m_currentDragContext= nullptr;
+ m_currentDropContext= nullptr;
m_nLastDropAction= 0;
if( m_nDefaultActions != ACTION_NONE)
@@ -450,10 +452,10 @@ HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/,
if( m_bActive)
{
- m_bDropComplete= sal_False;
+ m_bDropComplete= false;
m_nCurrentDropAction= getFilteredActions( grfKeyState, *pdwEffect);
- m_currentDropContext= static_cast<XDropTargetDropContext*>( new TargetDropContext( static_cast<DropTarget*>(this )) );
+ m_currentDropContext= static_cast<XDropTargetDropContext*>( new TargetDropContext( this ) );
if( m_nCurrentDropAction)
{
DropTargetDropEvent e;
@@ -469,7 +471,7 @@ HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/,
fire_drop( e);
//if fire_drop returns than a listener might have modified m_nCurrentDropAction
- if( m_bDropComplete == sal_True)
+ if( m_bDropComplete )
{
sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect);
*pdwEffect= dndActionsToSingleDropEffect( m_nCurrentDropAction & allowedActions);
@@ -480,9 +482,9 @@ HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/,
else
*pdwEffect= DROPEFFECT_NONE;
- m_currentData= 0;
- m_currentDragContext= 0;
- m_currentDropContext= 0;
+ m_currentData= nullptr;
+ m_currentDragContext= nullptr;
+ m_currentDropContext= nullptr;
m_nLastDropAction= 0;
}
return S_OK;
@@ -586,7 +588,7 @@ void DropTarget::_rejectDrop( const Reference<XDropTargetDropContext>& context)
}
}
-void DropTarget::_dropComplete(sal_Bool success, const Reference<XDropTargetDropContext>& context)
+void DropTarget::_dropComplete(bool success, const Reference<XDropTargetDropContext>& context)
{
if(context == m_currentDropContext)
{