summaryrefslogtreecommitdiff
path: root/dtrans/test
diff options
context:
space:
mode:
Diffstat (limited to 'dtrans/test')
-rw-r--r--dtrans/test/win32/dnd/atlwindow.cxx82
-rw-r--r--dtrans/test/win32/dnd/atlwindow.hxx31
-rw-r--r--dtrans/test/win32/dnd/makefile.mk6
-rw-r--r--dtrans/test/win32/dnd/targetlistener.cxx27
4 files changed, 60 insertions, 86 deletions
diff --git a/dtrans/test/win32/dnd/atlwindow.cxx b/dtrans/test/win32/dnd/atlwindow.cxx
index c24c87d56019..a87d780d2d27 100644
--- a/dtrans/test/win32/dnd/atlwindow.cxx
+++ b/dtrans/test/win32/dnd/atlwindow.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: atlwindow.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jl $ $Date: 2001-07-19 11:14:24 $
+ * last change: $Author: hr $ $Date: 2003-03-25 14:05:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,7 +72,6 @@
#include "targetlistener.hxx"
#include "sourcelistener.hxx"
//#include "transferable.hxx"
-#include "dataobject.hxx"
#include <map>
#include <winbase.h>
@@ -147,8 +146,7 @@ LRESULT AWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandle
// create the DragSource
- OUString sServiceSource( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.datatransfer.dnd.OleDragSource"));
- Reference< XInterface> xint= MultiServiceFactory->createInstance(sServiceSource);
+ Reference< XInterface> xint= MultiServiceFactory->createInstance(OUString(L"com.sun.star.datatransfer.dnd.OleDragSource"));
m_xDragSource= Reference<XDragSource>( xint, UNO_QUERY);
Reference<XInitialization> xInit( xint, UNO_QUERY);
@@ -157,33 +155,18 @@ LRESULT AWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandle
xInit->initialize( Sequence<Any>( ar, 2) );
//create the DropTarget
- // the initialization func of the drop target can be called from an STA or
- // MTA
Reference< XInterface> xintTarget= MultiServiceFactory->createInstance(OUString(L"com.sun.star.datatransfer.dnd.OleDropTarget"));
m_xDropTarget= Reference<XDropTarget>( xintTarget, UNO_QUERY);
Reference<XInitialization> xInitTarget( xintTarget, UNO_QUERY);
- // call Initialize from the mta thread
- if( m_bInitInMTA)
- {
- InitializationData* pData= (InitializationData*) CoTaskMemAlloc(sizeof( InitializationData));
- ZeroMemory( pData, sizeof( InitializationData));
- pData->xInit= xInitTarget;
- pData->hWnd= m_hWnd;
+ Any any;
+ any <<= (sal_uInt32)m_hWnd;
+ xInitTarget->initialize( Sequence<Any>( &any, 1) );
- PostThreadMessage( m_idMTAThread, WM_SOURCE_INIT,(WPARAM) pData, 0);
- }
- else
- {
- // call initialize from the current thread
- Any any;
- any <<= (sal_uInt32)m_hWnd;
- xInitTarget->initialize( Sequence<Any>( &any, 1) );
- }
m_xDropTarget->addDropTargetListener( static_cast<XDropTargetListener*>
( new DropTargetListener( m_hwndEdit)) );
-// // make this window a drop target
+// // make this window tho a drop target
m_xDropTarget->setActive(sal_True);
return 0;
@@ -210,36 +193,51 @@ LRESULT AWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled
HRESULT hr;
USES_CONVERSION;
KillTimer( 1);
- // only if the dragsource exists and it is our own timer
- if(m_xDragSource.is() && (UINT) wParam == 1)
+ if(m_xDragSource.is())
{
//Get the Text out of the Edit window
int length= (int)::SendMessageA( m_hwndEdit, WM_GETTEXTLENGTH, 0, 0);
char * pBuffer= new char[length + 1];
ZeroMemory( pBuffer, length + 1);
- ::SendMessageA( m_hwndEdit, WM_GETTEXT, length+1, (LPARAM) pBuffer);
-
- IDataObject* pData= (IDataObject*)new DataObject(pBuffer);
- pData->AddRef();
+ ::SendMessageA( m_hwndEdit, WM_GETTEXT, length, (LPARAM) pBuffer);
+ IDataObject* pData= NULL;
+ HRESULT hr= CreateDataCache( NULL, CLSID_NULL, __uuidof(IDataObject),(void**) &pData);
if( pData)
{
-// CDTransObjFactory fac;
-// Reference<XTransferable> xTrans= fac.createTransferableFromDataObj(
-// MultiServiceFactory, pData);
+ FORMATETC format={ CF_TEXT, NULL, DVASPECT_CONTENT, -1, };
+
+ HGLOBAL mem= GlobalAlloc(GHND, length + 1 );
+ void* pMem= GlobalLock( mem);
+ memcpy( pMem, pBuffer, length+1);
+ GlobalUnlock( mem);
- Reference<XTransferable> xTrans= m_aDataConverter.createTransferableFromDataObj(
- MultiServiceFactory, pData);
+ STGMEDIUM medium;
+ medium.tymed= TYMED_HGLOBAL;
+ medium.hGlobal= mem;
+ medium.pUnkForRelease= NULL;
+
+ pData->SetData( &format, &medium, TRUE); // releases HGLOBAL eventually
+
+ Reference<XTransferable> xTrans= m_aDataConverter.createTransferableFromDataObj(
+ MultiServiceFactory, pData);
// call XDragSource::executeDrag from an MTA
if( m_isMTA )
{
- StartDragData* pData= (StartDragData*) CoTaskMemAlloc(sizeof( StartDragData));
- ZeroMemory( pData, sizeof( StartDragData));
- pData->source= m_xDragSource;
- pData->transferable= xTrans;
- PostThreadMessage( m_idMTAThread, WM_SOURCE_STARTDRAG,(WPARAM) pData, 0);
+ DWORD mtaThreadId;
+ ThreadData data;
+ data.source= m_xDragSource;
+ data.transferable= xTrans;
+
+ data.evtThreadReady= CreateEvent( NULL, FALSE, FALSE, NULL);
+
+ HANDLE hThread= CreateThread( NULL, 0, MTAFunc, &data, 0, &mtaThreadId);
+ // We must wait until the thread copied the ThreadData structure
+ WaitForSingleObject( data.evtThreadReady, INFINITE);
+ CloseHandle( data.evtThreadReady);
+
}
else
@@ -252,8 +250,6 @@ LRESULT AWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled
Reference<XDragSourceListener>( static_cast<XDragSourceListener*>(new DragSourceListener() ) ) );
}
}
- if( pData)
- pData->Release();
delete[] pBuffer;
}
@@ -294,4 +290,4 @@ LRESULT APIENTRY EditSubclassProc( HWND hwnd, UINT uMsg,WPARAM wParam, LPARAM lP
return CallWindowProc( wpOrigEditProc, hwnd, uMsg,
wParam, lParam);
}
-
+ \ No newline at end of file
diff --git a/dtrans/test/win32/dnd/atlwindow.hxx b/dtrans/test/win32/dnd/atlwindow.hxx
index 2d664510b236..ac5132483e65 100644
--- a/dtrans/test/win32/dnd/atlwindow.hxx
+++ b/dtrans/test/win32/dnd/atlwindow.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: atlwindow.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jl $ $Date: 2001-07-19 11:14:24 $
+ * last change: $Author: hr $ $Date: 2003-03-25 14:05:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,7 +64,6 @@
extern CComModule _Module;
#include<atlcom.h>
#include<atlctl.h>
-#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
@@ -75,21 +74,12 @@ extern CComModule _Module;
using namespace com::sun::star::uno;
using namespace com::sun::star::datatransfer::dnd;
using namespace com::sun::star::datatransfer;
-using namespace com::sun::star::lang;
-#define WM_SOURCE_INIT WM_APP+100
-#define WM_SOURCE_STARTDRAG WM_APP+101
-
-struct StartDragData
+struct ThreadData
{
Reference<XDragSource> source;
Reference<XTransferable> transferable;
-};
-
-struct InitializationData
-{
- Reference<XInitialization> xInit;
- HWND hWnd;
+ HANDLE evtThreadReady;
};
class AWindow: public CWindowImpl<AWindow, CWindow,
@@ -99,21 +89,18 @@ class AWindow: public CWindowImpl<AWindow, CWindow,
Reference<XDropTarget> m_xDropTarget;
Reference<XDragSource> m_xDragSource;
BOOL m_isMTA;
- BOOL m_bInitInMTA;
+
HWND m_hwndEdit;
- // Id of the MTA thread to which we post messages.
- DWORD m_idMTAThread;
+
CDTransObjFactory m_aDataConverter;
public:
- AWindow(LPCTSTR strName, DWORD idMTAThread): m_idMTAThread( idMTAThread)
+ AWindow(LPCTSTR strName)
{
RECT rcPos= {0,0,200,200};
Create(0, rcPos, strName);
}
- AWindow(LPCTSTR strName, DWORD idMTAThread, RECT pos, BOOL mta=FALSE,
- BOOL initInMTA=FALSE):
- m_isMTA( mta), m_idMTAThread( idMTAThread), m_bInitInMTA( initInMTA)
+ AWindow(LPCTSTR strName, RECT pos, BOOL mta=FALSE): m_isMTA( mta)
{
Create(0, pos, strName);
}
@@ -144,4 +131,4 @@ public:
};
-#endif
+#endif \ No newline at end of file
diff --git a/dtrans/test/win32/dnd/makefile.mk b/dtrans/test/win32/dnd/makefile.mk
index 537f834549f6..d8603b9b2443 100644
--- a/dtrans/test/win32/dnd/makefile.mk
+++ b/dtrans/test/win32/dnd/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.9 $
+# $Revision: 1.10 $
#
-# last change: $Author: jbu $ $Date: 2002-10-01 07:33:40 $
+# last change: $Author: hr $ $Date: 2003-03-25 14:05:43 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -80,7 +80,7 @@ BOOTSTRAP_SERVICE=FALSE
# --- Files ---
-# CFLAGS+=/GR -DUNICODE -D_UNICODE
+# CFLAGS+=-GR -DUNICODE -D_UNICODE
CFLAGS+= -D_WIN32_DCOM
.IF "$(BOOTSTRAP_SERVICE)" == "TRUE"
diff --git a/dtrans/test/win32/dnd/targetlistener.cxx b/dtrans/test/win32/dnd/targetlistener.cxx
index 2f6d51657635..8a1e4d2b101d 100644
--- a/dtrans/test/win32/dnd/targetlistener.cxx
+++ b/dtrans/test/win32/dnd/targetlistener.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: targetlistener.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jl $ $Date: 2001-08-14 14:11:25 $
+ * last change: $Author: hr $ $Date: 2003-03-25 14:05:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,9 +87,9 @@ void SAL_CALL DropTargetListener::disposing( const EventObject& Source )
void SAL_CALL DropTargetListener::drop( const DropTargetDropEvent& e )
throw(RuntimeException)
{
- e.Context->dropComplete( sal_True);
- e.Context->acceptDrop( ACTION_COPY);
-// e.Context->rejectDrop();
+// e.Context->dropComplete( sal_True);
+// e.Context->acceptDrop( ACTION_COPY);
+ e.Context->rejectDrop();
// if the Transferable contains text, then we send it to the edit window
// Sequence<DataFlavor> flavors= e.Transferable->getTransferDataFlavors();
@@ -108,13 +108,9 @@ void SAL_CALL DropTargetListener::drop( const DropTargetDropEvent& e )
void SAL_CALL DropTargetListener::dragEnter( const DropTargetDragEnterEvent& dtde )
throw(RuntimeException)
{
- if( (dtde.SourceActions & dtde.DropAction) )
- {
- dtde.Context->acceptDrag( dtde.DropAction);
- }
//If one drags something that is not moveable
-// if( !(dtde.SourceActions & dtde.DropAction) )
-// dtde.Context->acceptDrag( ACTION_COPY);
+ if( !(dtde.SourceActions & dtde.DropAction) )
+ dtde.Context->acceptDrag( ACTION_COPY);
// dtde.Context->rejectDrag( );
@@ -128,13 +124,8 @@ void SAL_CALL DropTargetListener::dragExit( const DropTargetEvent& dte )
void SAL_CALL DropTargetListener::dragOver( const DropTargetDragEvent& dtde )
throw(RuntimeException)
{
- if( (dtde.SourceActions & dtde.DropAction) )
- {
- dtde.Context->acceptDrag( dtde.DropAction);
- }
-
-// if( (dtde.SourceActions & dtde.DropAction) )
-// dtde.Context->acceptDrag( ACTION_COPY);
+ if( !(dtde.SourceActions & dtde.DropAction) )
+ dtde.Context->acceptDrag( ACTION_COPY);
}
void SAL_CALL DropTargetListener::dropActionChanged( const DropTargetDragEvent& dtde )