This is an automated email from the ASF dual-hosted git repository. mseidel pushed a commit to branch AOO42X in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push: new 99e632b Fixed typos, removed whitespace 99e632b is described below commit 99e632bc7c95db821d42b4075be8174711f27490 Author: mseidel <msei...@apache.org> AuthorDate: Fri Dec 4 22:25:56 2020 +0100 Fixed typos, removed whitespace (cherry picked from commit 41e09fa92c50065ecf599158644193ba71ae5561) --- main/dtrans/source/win32/dnd/source.cxx | 159 ++++++++++++++++---------------- main/dtrans/source/win32/dnd/source.hxx | 68 +++++++------- main/dtrans/source/win32/dnd/target.cxx | 141 ++++++++++++++-------------- main/dtrans/source/win32/dnd/target.hxx | 95 +++++++++---------- 4 files changed, 230 insertions(+), 233 deletions(-) diff --git a/main/dtrans/source/win32/dnd/source.cxx b/main/dtrans/source/win32/dnd/source.cxx index 07aceb1..e7020b4 100644 --- a/main/dtrans/source/win32/dnd/source.cxx +++ b/main/dtrans/source/win32/dnd/source.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * 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 @@ -7,16 +7,16 @@ * 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -75,7 +75,7 @@ DragSource::DragSource( const Reference<XMultiServiceFactory>& sf): // m_pcurrentContext_impl(0), m_hAppWindow(0), m_MouseButton(0), - m_RunningDndOperationCount(0) + m_RunningDndOperationCount(0) { g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); } @@ -90,23 +90,23 @@ DragSource::~DragSource() //---------------------------------------------------- /** First start a new drag and drop thread if - the last one has finished + the last one has finished - ???? - Do we really need a separate thread for - every Dnd opeartion or only if the source - thread is an MTA thread - ???? + ???? + Do we really need a separate thread for + every Dnd operation or only if the source + thread is an MTA thread + ???? */ void DragSource::StartDragImpl( - const DragGestureEvent& trigger, - sal_Int8 sourceActions, - sal_Int32 /*cursor*/, - sal_Int32 /*image*/, - const Reference<XTransferable >& trans, - const Reference<XDragSourceListener >& listener ) + 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 + // 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 @@ -132,26 +132,26 @@ void DragSource::StartDragImpl( g_XTransferable = trans; //<-- TRA - m_spDataObject= m_aDataConverter.createDataObjFromTransferable( + m_spDataObject= m_aDataConverter.createDataObjFromTransferable( m_serviceFactory, trans); // 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 to late - // to acquire at the start of the thread procedure - // the thread procedure is responsible for the release - acquire(); + // hold the instance for the DnD thread, it's to late + // to acquire at the start of the thread procedure + // the thread procedure is responsible for the release + acquire(); - // The thread acccesses members of this instance but does not call acquire. + // The thread accesses members of this instance but does not call acquire. // Hopefully this instance is not destroyed before the thread has terminated. unsigned threadId; HANDLE hThread= reinterpret_cast<HANDLE>(_beginthreadex( - 0, 0, DndOleSTAFunc, reinterpret_cast<void*>(this), 0, &threadId)); + 0, 0, DndOleSTAFunc, reinterpret_cast<void*>(this), 0, &threadId)); - // detach from thread - CloseHandle(hThread); + // detach from thread + CloseHandle(hThread); } // XInitialization @@ -187,57 +187,57 @@ sal_Int32 SAL_CALL DragSource::getDefaultCursor( sal_Int8 /*dragAction*/ ) //---------------------------------------------------- /** Notifies the XDragSourceListener by - calling dragDropEnd + calling dragDropEnd */ void SAL_CALL DragSource::startDrag( - const DragGestureEvent& trigger, + const DragGestureEvent& trigger, sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image, const Reference<XTransferable >& trans, const Reference<XDragSourceListener >& listener ) throw( RuntimeException) { - // Allow only one running dnd operation at a time, - // see XDragSource documentation - - long cnt = InterlockedIncrement(&m_RunningDndOperationCount); - - if (1 == cnt) - { - StartDragImpl(trigger, sourceActions, cursor, image, trans, listener); - } - else - { - //OSL_ENSURE(false, "Overlapping Drag&Drop operation rejected!"); - - cnt = InterlockedDecrement(&m_RunningDndOperationCount); - - DragSourceDropEvent dsde; - - dsde.DropAction = ACTION_NONE; - dsde.DropSuccess = false; - - try - { - listener->dragDropEnd(dsde); - } - catch(RuntimeException&) - { - OSL_ENSURE(false, "Runtime exception during event dispatching"); - } - } + // Allow only one running dnd operation at a time, + // see XDragSource documentation + + long cnt = InterlockedIncrement(&m_RunningDndOperationCount); + + if (1 == cnt) + { + StartDragImpl(trigger, sourceActions, cursor, image, trans, listener); + } + else + { + //OSL_ENSURE(false, "Overlapping Drag&Drop operation rejected!"); + + cnt = InterlockedDecrement(&m_RunningDndOperationCount); + + DragSourceDropEvent dsde; + + dsde.DropAction = ACTION_NONE; + dsde.DropSuccess = false; + + try + { + listener->dragDropEnd(dsde); + } + catch(RuntimeException&) + { + OSL_ENSURE(false, "Runtime exception during event dispatching"); + } + } } //---------------------------------------------------- /**IDropTarget */ -HRESULT STDMETHODCALLTYPE DragSource::QueryInterface( REFIID riid, void **ppvObject) +HRESULT STDMETHODCALLTYPE DragSource::QueryInterface( REFIID riid, void **ppvObject) { if( !ppvObject) return E_POINTER; *ppvObject= NULL; - if( riid == __uuidof( IUnknown) ) + if( riid == __uuidof( IUnknown) ) *ppvObject= static_cast<IUnknown*>( this); else if ( riid == __uuidof( IDropSource) ) *ppvObject= static_cast<IDropSource*>( this); @@ -266,7 +266,7 @@ ULONG STDMETHODCALLTYPE DragSource::AddRef( void) */ ULONG STDMETHODCALLTYPE DragSource::Release( void) { - ULONG ref= m_refCount; + ULONG ref= m_refCount; release(); return --ref; } @@ -334,36 +334,36 @@ dwEffect // XServiceInfo OUString SAL_CALL DragSource::getImplementationName( ) throw (RuntimeException) { - return OUString(RTL_CONSTASCII_USTRINGPARAM(DNDSOURCE_IMPL_NAME));; + return OUString(RTL_CONSTASCII_USTRINGPARAM(DNDSOURCE_IMPL_NAME));; } // XServiceInfo sal_Bool SAL_CALL DragSource::supportsService( const OUString& ServiceName ) throw (RuntimeException) { - if( ServiceName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(DNDSOURCE_SERVICE_NAME )))) - return sal_True; - return sal_False; + if( ServiceName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(DNDSOURCE_SERVICE_NAME )))) + return sal_True; + return sal_False; } Sequence< OUString > SAL_CALL DragSource::getSupportedServiceNames( ) throw (RuntimeException) { - OUString names[1]= {OUString(RTL_CONSTASCII_USTRINGPARAM(DNDSOURCE_SERVICE_NAME))}; + OUString names[1]= {OUString(RTL_CONSTASCII_USTRINGPARAM(DNDSOURCE_SERVICE_NAME))}; - return Sequence<OUString>(names, 1); + return Sequence<OUString>(names, 1); } //---------------------------------------------------- /**This function is called as extra thread from - DragSource::executeDrag. The function - carries out a drag and drop operation by calling - DoDragDrop. The thread also notifies all - XSourceListener. + DragSource::executeDrag. The function + carries out a drag and drop operation by calling + DoDragDrop. The thread also notifies all + XSourceListener. */ unsigned __stdcall DndOleSTAFunc(LPVOID pParams) { // The structure contains all arguments for DoDragDrop and other DragSource *pSource= (DragSource*)pParams; - // Drag and drop only works in a thread in which OleInitialize is called. + // Drag and drop only works in a thread in which OleInitialize is called. HRESULT hr= OleInitialize( NULL); if(SUCCEEDED(hr)) @@ -387,10 +387,10 @@ unsigned __stdcall DndOleSTAFunc(LPVOID pParams) dndActionsToDropEffects( pSource->m_sourceActions), &dwEffect); - // #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); + // #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 @@ -415,13 +415,10 @@ unsigned __stdcall DndOleSTAFunc(LPVOID pParams) InterlockedDecrement(&pSource->m_RunningDndOperationCount); - // the DragSource was manually acquired by - // thread starting method DelayedStartDrag + // the DragSource was manually acquired by + // thread starting method DelayedStartDrag pSource->release(); return 0; } - - - diff --git a/main/dtrans/source/win32/dnd/source.hxx b/main/dtrans/source/win32/dnd/source.hxx index 760aa82..d0cef9d 100644 --- a/main/dtrans/source/win32/dnd/source.hxx +++ b/main/dtrans/source/win32/dnd/source.hxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * 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 @@ -7,16 +7,16 @@ * 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -51,7 +51,7 @@ using namespace ::com::sun::star::datatransfer::dnd; class SourceContext; -// RIGHT MOUSE BUTTON drag and drop not supportet currently. +// RIGHT MOUSE BUTTON drag and drop not supported currently. // ALT modifier is considered to effect a user selection of effects class DragSource: public MutexDummy, @@ -64,25 +64,25 @@ class DragSource: // The mouse button that set off the drag and drop operation short m_MouseButton; - // Converts XTransferable objects to IDataObject objects. - CDTransObjFactory m_aDataConverter; + // Converts XTransferable objects to IDataObject objects. + CDTransObjFactory m_aDataConverter; DragSource(); DragSource(const DragSource&); DragSource &operator= ( const DragSource&); - // First starting a new drag and drop thread if - // the last one has finished - void StartDragImpl( - const DragGestureEvent& trigger, - sal_Int8 sourceActions, - sal_Int32 cursor, - sal_Int32 image, - const Reference<XTransferable >& trans, + // First starting a new drag and drop thread if + // the last one has finished + void StartDragImpl( + const DragGestureEvent& trigger, + sal_Int8 sourceActions, + sal_Int32 cursor, + sal_Int32 image, + const Reference<XTransferable >& trans, const Reference<XDragSourceListener >& listener); public: - long m_RunningDndOperationCount; + long m_RunningDndOperationCount; public: // only valid for one dnd operation @@ -100,16 +100,16 @@ public: DragSource(const Reference<XMultiServiceFactory>& sf); virtual ~DragSource(); - // XInitialization - virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException); // XDragSource - virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(RuntimeException); - virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) + virtual sal_Bool SAL_CALL isDragImageSupported( ) throw(RuntimeException); + virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) throw( IllegalArgumentException, RuntimeException); - virtual void SAL_CALL startDrag( const DragGestureEvent& trigger, + virtual void SAL_CALL startDrag( const DragGestureEvent& trigger, sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image, @@ -117,29 +117,29 @@ public: const Reference<XDragSourceListener >& listener ) throw( RuntimeException); - // XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); virtual HRESULT STDMETHODCALLTYPE QueryInterface( - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); + /* [in] */ REFIID riid, + /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - virtual ULONG STDMETHODCALLTYPE AddRef( ); + virtual ULONG STDMETHODCALLTYPE AddRef( ); - virtual ULONG STDMETHODCALLTYPE Release( ); + virtual ULONG STDMETHODCALLTYPE Release( ); // IDropSource - virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( - /* [in] */ BOOL fEscapePressed, - /* [in] */ DWORD grfKeyState); + virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( + /* [in] */ BOOL fEscapePressed, + /* [in] */ DWORD grfKeyState); - virtual HRESULT STDMETHODCALLTYPE GiveFeedback( - /* [in] */ DWORD dwEffect); + virtual HRESULT STDMETHODCALLTYPE GiveFeedback( + /* [in] */ DWORD dwEffect); }; diff --git a/main/dtrans/source/win32/dnd/target.cxx b/main/dtrans/source/win32/dnd/target.cxx index 3ec27a7..405c3d2 100644 --- a/main/dtrans/source/win32/dnd/target.cxx +++ b/main/dtrans/source/win32/dnd/target.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * 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 @@ -7,16 +7,16 @@ * 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -88,7 +88,7 @@ void SAL_CALL DropTarget::disposing() HRESULT hr= S_OK; if( m_threadIdTarget) { - // Call RevokeDragDrop and wait for the OLE thread to die; + // Call RevokeDragDrop and wait for the OLE thread to die; PostThreadMessage( m_threadIdTarget, WM_REVOKEDRAGDROP, (WPARAM)this, 0); WaitForSingleObject( m_hOleThread, INFINITE); CloseHandle( m_hOleThread); @@ -100,38 +100,38 @@ void SAL_CALL DropTarget::disposing() m_hWnd= 0; } if( m_pDropTarget) - { - CoLockObjectExternal( m_pDropTarget, FALSE, TRUE); - m_pDropTarget->Release(); - } + { + CoLockObjectExternal( m_pDropTarget, FALSE, TRUE); + m_pDropTarget->Release(); + } if( m_oleThreadId) - { - if( m_oleThreadId == CoGetCurrentProcess() ) - OleUninitialize(); - } + { + if( m_oleThreadId == CoGetCurrentProcess() ) + OleUninitialize(); + } } void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException) { - // The window must be registered for Dnd by RegisterDragDrop. We must ensure + // The window must be registered for Dnd by RegisterDragDrop. We must ensure // that RegisterDragDrop is called from an STA ( OleInitialize) thread. // As long as the window is registered we need to receive OLE messages in // 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. + // The thread will stay alive until aver RevokeDragDrop has been called. // 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 meesages sent during DND won't reach the windows message queue. + // otherwise messages sent during DND won't reach the windows message queue. // Calling AttachThreadInput first would resolve this problem but would block - // the message queue of the calling thread. So if the current thread + // the message queue of the calling thread. So if the current thread // (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.getLength() > 0) { // Get the window handle from aArgument. It is needed for RegisterDragDrop. @@ -144,7 +144,7 @@ void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments ) HRESULT hr= OleInitialize( NULL); // Current thread is MTA or Current thread and Window thread are not identical - if( hr == RPC_E_CHANGED_MODE || GetCurrentThreadId() != m_threadIdWindow ) + if( hr == RPC_E_CHANGED_MODE || GetCurrentThreadId() != m_threadIdWindow ) { OSL_ENSURE( ! m_threadIdTarget,"initialize was called twice"); // create the IDropTargetImplementation @@ -183,7 +183,7 @@ void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments ) // CoLockObjectExternal is prescribed by the protocol. It bumps up the ref count if( SUCCEEDED( CoLockObjectExternal( m_pDropTarget, TRUE, FALSE))) { - if( FAILED( RegisterDragDrop( m_hWnd, m_pDropTarget) ) ) + if( FAILED( RegisterDragDrop( m_hWnd, m_pDropTarget) ) ) { // do clean up if drag and drop is not possible CoLockObjectExternal( m_pDropTarget, FALSE, FALSE); @@ -247,7 +247,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams) pTarget->m_hWnd= 0; break; } - TranslateMessage( &msg); + TranslateMessage( &msg); DispatchMessage( &msg); } OleUninitialize(); @@ -261,20 +261,20 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams) // XServiceInfo OUString SAL_CALL DropTarget::getImplementationName( ) throw (RuntimeException) { - return OUString(RTL_CONSTASCII_USTRINGPARAM(DNDTARGET_IMPL_NAME));; + return OUString(RTL_CONSTASCII_USTRINGPARAM(DNDTARGET_IMPL_NAME));; } // XServiceInfo sal_Bool SAL_CALL DropTarget::supportsService( const OUString& ServiceName ) throw (RuntimeException) { - if( ServiceName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(DNDTARGET_SERVICE_NAME )))) - return sal_True; - return sal_False; + if( ServiceName.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(DNDTARGET_SERVICE_NAME )))) + return sal_True; + return sal_False; } Sequence< OUString > SAL_CALL DropTarget::getSupportedServiceNames( ) throw (RuntimeException) { - OUString names[1]= {OUString(RTL_CONSTASCII_USTRINGPARAM(DNDTARGET_SERVICE_NAME))}; - return Sequence<OUString>(names, 1); + OUString names[1]= {OUString(RTL_CONSTASCII_USTRINGPARAM(DNDTARGET_SERVICE_NAME))}; + return Sequence<OUString>(names, 1); } @@ -300,7 +300,7 @@ sal_Bool SAL_CALL DropTarget::isActive( ) throw(RuntimeException) void SAL_CALL DropTarget::setActive( sal_Bool _b ) throw(RuntimeException) { MutexGuard g(m_mutex); - m_bActive= _b; + m_bActive= _b; } @@ -319,22 +319,22 @@ void SAL_CALL DropTarget::setDefaultActions( sal_Int8 actions ) throw(RuntimeExc HRESULT DropTarget::DragEnter( IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, - DWORD *pdwEffect) + DWORD *pdwEffect) { #if defined DBG_CONSOLE_OUT printf("\nDropTarget::DragEnter state: %x effect %d", grfKeyState, *pdwEffect); #endif - if( m_bActive ) - { - // Intersection of pdwEffect and the allowed actions ( setDefaultActions) - m_nCurrentDropAction= getFilteredActions( grfKeyState, *pdwEffect); + if( m_bActive ) + { + // Intersection of pdwEffect and the allowed actions ( setDefaultActions) + m_nCurrentDropAction= getFilteredActions( grfKeyState, *pdwEffect); // m_nLastDropAction has to be set by a listener. If no listener calls //XDropTargetDragContext::acceptDrag and specifies an action then pdwEffect // will be DROPEFFECT_NONE throughout m_nLastDropAction= ACTION_DEFAULT | ACTION_MOVE; - m_currentDragContext= static_cast<XDropTargetDragContext*>( new TargetDragContext( - static_cast<DropTarget*>(this) ) ); + m_currentDragContext= static_cast<XDropTargetDragContext*>( new TargetDragContext( + static_cast<DropTarget*>(this) ) ); //--> TRA @@ -350,8 +350,8 @@ HRESULT DropTarget::DragEnter( IDataObject *pDataObj, //<-- TRA - if( m_nCurrentDropAction != ACTION_NONE) - { + if( m_nCurrentDropAction != ACTION_NONE) + { DropTargetDragEnterEvent e; e.SupportedDataFlavors= m_currentData->getTransferDataFlavors(); e.DropAction= m_nCurrentDropAction; @@ -366,32 +366,32 @@ HRESULT DropTarget::DragEnter( IDataObject *pDataObj, fire_dragEnter( e); // Check if the action derived from grfKeyState (m_nCurrentDropAction) or the action set // by the listener (m_nCurrentDropAction) is allowed by the source. Only a allowed action is set - // in pdwEffect. The listener notification is asynchron, that is we cannot expext that the listener + // 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 then 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. // On drop the target should present the user a dialog from which the user may change the action. sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect); *pdwEffect= dndActionsToSingleDropEffect( m_nLastDropAction & allowedActions); - } - else - { - *pdwEffect= DROPEFFECT_NONE; - } - } + } + else + { + *pdwEffect= DROPEFFECT_NONE; + } + } return S_OK; } HRESULT DropTarget::DragOver( DWORD grfKeyState, POINTL pt, - DWORD *pdwEffect) + DWORD *pdwEffect) { - if( m_bActive) - { - m_nCurrentDropAction= getFilteredActions( grfKeyState, *pdwEffect); + if( m_bActive) + { + m_nCurrentDropAction= getFilteredActions( grfKeyState, *pdwEffect); - if( m_nCurrentDropAction) - { + if( m_nCurrentDropAction) + { DropTargetDragEvent e; e.DropAction= m_nCurrentDropAction; e.Source= Reference<XInterface>(static_cast<XDropTarget*>(this),UNO_QUERY); @@ -414,7 +414,7 @@ HRESULT DropTarget::DragOver( DWORD grfKeyState, fire_dragOver( e); // Check if the action derived from grfKeyState (m_nCurrentDropAction) or the action set // by the listener (m_nCurrentDropAction) is allowed by the source. Only a allowed action is set - // in pdwEffect. The listener notification is asynchron, that is we cannot expext that the listener + // 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 then 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. @@ -422,12 +422,12 @@ HRESULT DropTarget::DragOver( DWORD grfKeyState, sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect); // set the last action to the current if listener has not changed the value yet *pdwEffect= dndActionsToSingleDropEffect( m_nLastDropAction & allowedActions); - } - else - { - *pdwEffect= DROPEFFECT_NONE; - } - } + } + else + { + *pdwEffect= DROPEFFECT_NONE; + } + } #if defined DBG_CONSOLE_OUT printf("\nDropTarget::DragOver %d", *pdwEffect ); #endif @@ -439,8 +439,8 @@ HRESULT DropTarget::DragLeave( void) #if defined DBG_CONSOLE_OUT printf("\nDropTarget::DragLeave"); #endif - if( m_bActive) - { + if( m_bActive) + { m_currentData=0; m_currentDragContext= 0; @@ -450,15 +450,15 @@ HRESULT DropTarget::DragLeave( void) if( m_nDefaultActions != ACTION_NONE) { DropTargetEvent e; - e.Source= static_cast<XDropTarget*>(this); + e.Source= static_cast<XDropTarget*>(this); fire_dragExit( e); } - } + } return S_OK; } -HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/, +HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) @@ -466,13 +466,13 @@ HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/, #if defined DBG_CONSOLE_OUT printf("\nDropTarget::Drop"); #endif - if( m_bActive) - { + if( m_bActive) + { m_bDropComplete= sal_False; m_nCurrentDropAction= getFilteredActions( grfKeyState, *pdwEffect); - m_currentDropContext= static_cast<XDropTargetDropContext*>( new TargetDropContext( static_cast<DropTarget*>(this )) ); + m_currentDropContext= static_cast<XDropTargetDropContext*>( new TargetDropContext( static_cast<DropTarget*>(this )) ); if( m_nCurrentDropAction) { DropTargetDropEvent e; @@ -487,7 +487,7 @@ HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/, e.Transferable= m_currentData; fire_drop( e); - //if fire_drop returns than a listener might have modified m_nCurrentDropAction + // if fire_drop returns than a listener might have modified m_nCurrentDropAction if( m_bDropComplete == sal_True) { sal_Int8 allowedActions= dndOleDropEffectsToActions( *pdwEffect); @@ -503,7 +503,7 @@ HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/, m_currentDragContext= 0; m_currentDropContext= 0; m_nLastDropAction= 0; - } + } return S_OK; } @@ -616,7 +616,7 @@ void DropTarget::_dropComplete(sal_Bool success, const Reference<XDropTargetDrop } // -------------------------------------------------------------------------------------- // DropTarget fires events to XDropTargetListeners. The event object can contains an -// XDropTargetDragContext implementaion. When the listener calls on that interface +// 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 @@ -641,7 +641,7 @@ void DropTarget::_rejectDrag( const Reference<XDropTargetDragContext>& context) //-------------------------------------------------------------------------------------- -// This function determines the action dependend on the pressed +// 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 @@ -651,7 +651,6 @@ void DropTarget::_rejectDrag( const Reference<XDropTargetDragContext>& context) inline sal_Int8 DropTarget::getFilteredActions( DWORD grfKeyState, DWORD dwEffect) { sal_Int8 actions= dndOleKeysToAction( grfKeyState, dndOleDropEffectsToActions( dwEffect)); - return actions & m_nDefaultActions; + return actions & m_nDefaultActions; } - diff --git a/main/dtrans/source/win32/dnd/target.hxx b/main/dtrans/source/win32/dnd/target.hxx index c95adbd..73b138b 100644 --- a/main/dtrans/source/win32/dnd/target.hxx +++ b/main/dtrans/source/win32/dnd/target.hxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * 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 @@ -7,19 +7,20 @@ * 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ + #ifndef _TARGET_HXX_ #define _TARGET_HXX_ @@ -70,8 +71,8 @@ class DropTarget: public MutexDummy, private: friend DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams); // The native window which acts as drop target. - // It is set in initialize. In case RegisterDragDrop fails it is set - // to NULL + // It is set in initialize. In case RegisterDragDrop fails it is set + // to NULL HWND m_hWnd; // set by initialize // Holds the thread id of the thread which created the window that is the // drop target. Only used when DropTarget::initialize is called from an MTA @@ -83,23 +84,23 @@ private: // The handle of the thread that is created in DropTarget::initialize // when the calling thread is an MTA HANDLE m_hOleThread; - // The thread id of the thread which called initialize. When the service dies - // than m_oleThreadId is used to determine if the service successfully called - // OleInitialize. If so then OleUninitialize has to be called. - DWORD m_oleThreadId; - // An Instance of IDropTargetImpl which receives calls from the system's drag - // and drop implementation. It delegate the calls to name alike functions in - // this class. - IDropTarget* m_pDropTarget; + // The thread id of the thread which called initialize. When the service dies + // than m_oleThreadId is used to determine if the service successfully called + // OleInitialize. If so then OleUninitialize has to be called. + DWORD m_oleThreadId; + // An Instance of IDropTargetImpl which receives calls from the system's drag + // and drop implementation. It delegate the calls to name alike functions in + // this class. + IDropTarget* m_pDropTarget; Reference<XMultiServiceFactory> m_serviceFactory; // If m_bActive == sal_True then events are fired to XDropTargetListener s, - // none otherwise. The default value is sal_True. - sal_Bool m_bActive; + // none otherwise. The default value is sal_True. + sal_Bool m_bActive; sal_Int8 m_nDefaultActions; // This value is set when a XDropTargetListener calls accept or reject on - // the XDropTargetDropContext or XDropTargetDragContext. + // the XDropTargetDropContext or XDropTargetDragContext. // The values are from the DNDConstants group. sal_Int8 m_nCurrentDropAction; // This value is manipulated by the XDropTargetListener @@ -112,7 +113,7 @@ private: // Set by listeners when they call XDropTargetDropContext::dropComplete sal_Bool m_bDropComplete; // converts IDataObject objects to XTransferable objects. - CDTransObjFactory m_aDataConverter; + CDTransObjFactory m_aDataConverter; Reference<XDropTargetDragContext> m_currentDragContext; Reference<XDropTargetDropContext> m_currentDropContext; @@ -126,50 +127,50 @@ public: DropTarget(const Reference<XMultiServiceFactory>& sf); virtual ~DropTarget(); - // Overrides WeakComponentImplHelper::disposing which is called by - // WeakComponentImplHelper::dispose - // Must be called. - virtual void SAL_CALL disposing(); - // XInitialization - virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) + // Overrides WeakComponentImplHelper::disposing which is called by + // WeakComponentImplHelper::dispose + // Must be called. + virtual void SAL_CALL disposing(); + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException); // XDropTarget - virtual void SAL_CALL addDropTargetListener( const Reference< XDropTargetListener >& dtl ) + virtual void SAL_CALL addDropTargetListener( const Reference< XDropTargetListener >& dtl ) throw(RuntimeException); - virtual void SAL_CALL removeDropTargetListener( const Reference< XDropTargetListener >& dtl ) + virtual void SAL_CALL removeDropTargetListener( const Reference< XDropTargetListener >& dtl ) throw(RuntimeException); // Default is not active - virtual sal_Bool SAL_CALL isActive( ) throw(RuntimeException); - virtual void SAL_CALL setActive( sal_Bool isActive ) throw(RuntimeException); - virtual sal_Int8 SAL_CALL getDefaultActions( ) throw(RuntimeException); - virtual void SAL_CALL setDefaultActions( sal_Int8 actions ) throw(RuntimeException); + virtual sal_Bool SAL_CALL isActive( ) throw(RuntimeException); + virtual void SAL_CALL setActive( sal_Bool isActive ) throw(RuntimeException); + virtual sal_Int8 SAL_CALL getDefaultActions( ) throw(RuntimeException); + virtual void SAL_CALL setDefaultActions( sal_Int8 actions ) throw(RuntimeException); - // XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); // Functions called from the IDropTarget implementation ( m_pDropTarget) virtual HRESULT DragEnter( - /* [unique][in] */ IDataObject *pDataObj, - /* [in] */ DWORD grfKeyState, - /* [in] */ POINTL pt, - /* [out][in] */ DWORD *pdwEffect); + /* [unique][in] */ IDataObject *pDataObj, + /* [in] */ DWORD grfKeyState, + /* [in] */ POINTL pt, + /* [out][in] */ DWORD *pdwEffect); virtual HRESULT STDMETHODCALLTYPE DragOver( - /* [in] */ DWORD grfKeyState, - /* [in] */ POINTL pt, - /* [out][in] */ DWORD *pdwEffect); + /* [in] */ DWORD grfKeyState, + /* [in] */ POINTL pt, + /* [out][in] */ DWORD *pdwEffect); virtual HRESULT STDMETHODCALLTYPE DragLeave( ) ; - virtual HRESULT STDMETHODCALLTYPE Drop( - /* [unique][in] */ IDataObject *pDataObj, - /* [in] */ DWORD grfKeyState, - /* [in] */ POINTL pt, - /* [out][in] */ DWORD *pdwEffect); + virtual HRESULT STDMETHODCALLTYPE Drop( + /* [unique][in] */ IDataObject *pDataObj, + /* [in] */ DWORD grfKeyState, + /* [in] */ POINTL pt, + /* [out][in] */ DWORD *pdwEffect); // Non - interface functions -------------------------------------------------- @@ -185,7 +186,7 @@ public: protected: - // Gets the current action dependend on the pressed modifiers, the effects + // Gets the current action dependent on the pressed modifiers, the effects // supported by the drop source (IDropSource) and the default actions of the // drop target (XDropTarget, this class)) inline sal_Int8 getFilteredActions( DWORD grfKeyState, DWORD sourceActions);