diff options
Diffstat (limited to 'dtrans/test')
-rw-r--r-- | dtrans/test/win32/dnd/atlwindow.cxx | 264 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/atlwindow.hxx | 103 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/dndTest.cxx | 211 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/makefile.mk | 83 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/sourcelistener.cxx | 75 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/sourcelistener.hxx | 68 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/targetlistener.cxx | 106 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/targetlistener.hxx | 77 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/transferable.cxx | 129 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/transferable.hxx | 116 |
10 files changed, 1232 insertions, 0 deletions
diff --git a/dtrans/test/win32/dnd/atlwindow.cxx b/dtrans/test/win32/dnd/atlwindow.cxx new file mode 100644 index 000000000000..82f0b9d4f45e --- /dev/null +++ b/dtrans/test/win32/dnd/atlwindow.cxx @@ -0,0 +1,264 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dtrans.hxx" + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> + +#include <cppuhelper/servicefactory.hxx> +#include <rtl/string.h> + +#include "atlwindow.hxx" +#include "targetlistener.hxx" +#include "sourcelistener.hxx" +#include <map> + +#include <winbase.h> +using namespace com::sun::star::lang; +using namespace com::sun::star::datatransfer::dnd; +using namespace com::sun::star::datatransfer::dnd::DNDConstants; +using namespace cppu; +using namespace rtl; +using namespace std; + +LRESULT APIENTRY EditSubclassProc( HWND hwnd, UINT uMsg,WPARAM wParam, LPARAM lParam) ; + + +extern Reference< XMultiServiceFactory > MultiServiceFactory; +DWORD WINAPI MTAFunc(LPVOID pParams); + +char* szSTAWin= "XDragSource::executeDrag is called from the same " + "OLE STA thread that created the window."; +char* szMTAWin= "XDragSource::executeDrag is called from a MTA thread " + "that did not create the window."; + +WNDPROC wpOrigEditProc; + +map<HWND, HWND> mapEditToMainWnd; + +LRESULT AWindow::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + Reference<XComponent> xcompSource( m_xDragSource, UNO_QUERY); + + PostQuitMessage(0); + + + m_xDropTarget=0; + m_xDragSource=0; + + + // Remove the subclass from the edit control. + ::SetWindowLong(m_hwndEdit, GWL_WNDPROC, + (LONG) wpOrigEditProc); + + return 0; +} + + +LRESULT AWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + // Prepare the EDIT control + m_hwndEdit = CreateWindowA( + "EDIT", // predefined class + NULL, // no window title + WS_CHILD | WS_VISIBLE | WS_VSCROLL | + ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL, + 0, 0, 0, 0, // set size in WM_SIZE message + m_hWnd, // parent window + (HMENU) NULL, // edit control ID + (HINSTANCE) GetWindowLong( GWL_HINSTANCE), + NULL); + + // the map is used in the window procedure for the edit window to associate the + // it to the right main window ( AWindow) + mapEditToMainWnd[m_hwndEdit]= m_hWnd; + // Superclass the edit window, because we want to process mouse messages + wpOrigEditProc = (WNDPROC) ::SetWindowLongA(m_hwndEdit, + GWL_WNDPROC, (LONG) EditSubclassProc); + + + // Add text to the window. + if( m_isMTA) + ::SendMessageA(m_hwndEdit, WM_SETTEXT, 0, (LPARAM) szMTAWin); + else + ::SendMessageA(m_hwndEdit, WM_SETTEXT, 0, (LPARAM) szSTAWin); + + + // create the DragSource + 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); + + Any ar[2]; + ar[1]<<= (sal_uInt32)m_hWnd; + xInit->initialize( Sequence<Any>( ar, 2) ); + + //create the DropTarget + 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); + + 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 tho a drop target + m_xDropTarget->setActive(sal_True); + + return 0; +} + +// When the mouse is dragged for a second than a drag is initiated +LRESULT AWindow::OnMouseAction(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + if( uMsg== WM_LBUTTONDOWN) + { + SetTimer( 1, 1000); + } + + else if( uMsg == WM_LBUTTONUP) + { + KillTimer( 1); + } + + return 0; +} + +LRESULT AWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + HRESULT hr; + USES_CONVERSION; + KillTimer( 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, (LPARAM) pBuffer); + + IDataObject* pData= NULL; + HRESULT hr= CreateDataCache( NULL, CLSID_NULL, __uuidof(IDataObject),(void**) &pData); + if( 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); + + 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 ) + { + 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 + { + m_xDragSource->startDrag( DragGestureEvent(), + ACTION_LINK|ACTION_MOVE|ACTION_COPY, + 0, + 0, + xTrans, + Reference<XDragSourceListener>( static_cast<XDragSourceListener*>(new DragSourceListener() ) ) ); + } + } + + delete[] pBuffer; + } + + return 0; +} + +LRESULT AWindow::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + // Make the edit control the size of the window's + // client area. + ::MoveWindow(m_hwndEdit, + 0, 0, // starting x- and y-coordinates + LOWORD(lParam), // width of client area + HIWORD(lParam), // height of client area + TRUE); // repaint window + + return 0; +} +LRESULT AWindow::OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + ::SetFocus(m_hwndEdit); + return 0; +} + + + +// Subclass procedure for EDIT window +LRESULT APIENTRY EditSubclassProc( HWND hwnd, UINT uMsg,WPARAM wParam, LPARAM lParam) +{ + + if( uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST) + { + HWND hAWindow= mapEditToMainWnd[hwnd]; + ::SendMessage( hAWindow, uMsg, wParam, lParam); + + } + return CallWindowProc( wpOrigEditProc, hwnd, uMsg, + wParam, lParam); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/atlwindow.hxx b/dtrans/test/win32/dnd/atlwindow.hxx new file mode 100644 index 000000000000..f18ac08af1da --- /dev/null +++ b/dtrans/test/win32/dnd/atlwindow.hxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _WINDOW_HXX_ +#define _WINDOW_HXX_ +#include <atlbase.h> +extern CComModule _Module; +#include<atlcom.h> +#include<atlctl.h> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSource.hpp> +#include <com/sun/star/datatransfer/XTransferable.hpp> +#include <com/sun/star/uno/Reference.h> +#include "../../source/inc/DtObjFactory.hxx" + + +using namespace com::sun::star::uno; +using namespace com::sun::star::datatransfer::dnd; +using namespace com::sun::star::datatransfer; + +struct ThreadData +{ + Reference<XDragSource> source; + Reference<XTransferable> transferable; + HANDLE evtThreadReady; +}; + +class AWindow: public CWindowImpl<AWindow, CWindow, + CWinTraits<WS_CAPTION |WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0> > +{ + TCHAR m_strName[80]; + Reference<XDropTarget> m_xDropTarget; + Reference<XDragSource> m_xDragSource; + BOOL m_isMTA; + + HWND m_hwndEdit; + + CDTransObjFactory m_aDataConverter; + +public: + AWindow(LPCTSTR strName) + { + RECT rcPos= {0,0,200,200}; + Create(0, rcPos, strName); + } + AWindow(LPCTSTR strName, RECT pos, BOOL mta=FALSE): m_isMTA( mta) + { + Create(0, pos, strName); + } + + ~AWindow() + { + if(m_hWnd) + DestroyWindow(); + } + + + BEGIN_MSG_MAP(AWindow) + MESSAGE_HANDLER( WM_CLOSE, OnClose) + MESSAGE_HANDLER( WM_CREATE, OnCreate) + MESSAGE_RANGE_HANDLER( WM_MOUSEFIRST, WM_MOUSELAST, OnMouseAction) + MESSAGE_HANDLER( WM_TIMER, OnTimer) + MESSAGE_HANDLER( WM_SIZE, OnSize) + MESSAGE_HANDLER( WM_SETFOCUS, OnFocus) + + END_MSG_MAP() + + LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnMouseAction(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/dndTest.cxx b/dtrans/test/win32/dnd/dndTest.cxx new file mode 100644 index 000000000000..34080fb46efe --- /dev/null +++ b/dtrans/test/win32/dnd/dndTest.cxx @@ -0,0 +1,211 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dtrans.hxx" + +#if defined _MSC_VER +#pragma warning(push,1) +#endif +#include <windows.h> +#include <comdef.h> +#include <tchar.h> +#include <atlbase.h> +CComModule _Module; +#include<atlcom.h> +#include<atlimpl.cpp> +#if defined _MSC_VER +#pragma warning(pop) +#endif +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <rtl/process.h> +#include <cppuhelper/servicefactory.hxx> +#include "sourcelistener.hxx" + +#include "atlwindow.hxx" +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + +using namespace com::sun::star::lang; +using namespace com::sun::star::datatransfer; +using namespace com::sun::star::uno; +using namespace com::sun::star::datatransfer::dnd; +using namespace com::sun::star::datatransfer::dnd::DNDConstants; +using namespace rtl; + +// defined in atlwindow.hxx +// #define WM_SOURCE_INIT WM_APP+100 +// #define WM_SOURCE_STARTDRAG WM_APP+101 +#define WM_CREATE_MTA_WND + +HRESULT doTest(); +DWORD WINAPI MTAFunc( void* threadData); + +Reference< XMultiServiceFactory > MultiServiceFactory; +//int APIENTRY WinMain(HINSTANCE hInstance, +// HINSTANCE hPrevInstance, +// LPSTR lpCmdLine, +// int nCmdShow) +//int _tmain( int argc, TCHAR *argv[ ], TCHAR *envp[ ] ) +int main( int argc, char *argv[ ], char *envp[ ] ) +{ + HRESULT hr; + if( FAILED( hr=CoInitialize(NULL ))) + { + _tprintf(_T("CoInitialize failed \n")); + return -1; + } + + + _Module.Init( ObjectMap, GetModuleHandle( NULL)); + + if( FAILED(hr=doTest())) + { + _com_error err( hr); + const TCHAR * errMsg= err.ErrorMessage(); +// MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR); + } + + + _Module.Term(); + CoUninitialize(); + return 0; +} + +HRESULT doTest() +{ + + MultiServiceFactory= createRegistryServiceFactory( OUString(L"types.rdb"), OUString( L"services.rdb") , sal_True); + + // create the MTA thread that is used to realize MTA calls to the services + // We create the thread and wait until the thread has created its message queue + HANDLE evt= CreateEvent(NULL, FALSE, FALSE, NULL); + DWORD threadIdMTA=0; + HANDLE hMTAThread= CreateThread( NULL, 0, MTAFunc, &evt, 0, &threadIdMTA); + WaitForSingleObject( evt, INFINITE); + CloseHandle(evt); + + + HRESULT hr= S_OK; + RECT pos1={0,0,300,200}; + AWindow win(_T("DnD starting in Ole STA"), threadIdMTA, pos1); + + RECT pos2={ 0, 205, 300, 405}; + AWindow win2( _T("DnD starting in MTA"), threadIdMTA, pos2, true); + + // win3 and win4 call initialize from an MTA but they are created in an STA + RECT pos3={300,0,600,200}; + AWindow win3(_T("DnD starting in OLE STA"), threadIdMTA, pos3, false, true); + + RECT pos4={ 300, 205, 600, 405}; + AWindow win24( _T("DnD starting in Ole MTA"), threadIdMTA, pos4, true, true); + + + MSG msg; + while( GetMessage(&msg, (HWND)NULL, 0, 0) ) + { + TranslateMessage( &msg); + DispatchMessage( &msg); + } + + // Shut down the MTA thread + PostThreadMessage( threadIdMTA, WM_QUIT, 0, 0); + WaitForSingleObject(hMTAThread, INFINITE); + CloseHandle(hMTAThread); + + return S_OK; +} + +extern Reference<XMultiServiceFactory> MultiServiceFactory; +DWORD WINAPI MTAFunc( void* threadData) +{ + HRESULT hr= S_OK; + hr= CoInitializeEx( NULL, COINIT_MULTITHREADED); + ATLASSERT( FAILED(hr) ); + MSG msg; + // force the creation of a message queue + PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); + SetEvent( *(HANDLE*)threadData ); + + RECT pos={0, 406, 300, 605}; + AWindow win(_T("DnD, full MTA"), GetCurrentThreadId(), pos, false, true); +// ThreadData data= *( ThreadData*)pParams; +// SetEvent(data.evtThreadReady); + while( GetMessage(&msg, (HWND)NULL, 0, 0) ) + { + switch( msg.message) + { + case WM_SOURCE_INIT: + { + InitializationData* pData= (InitializationData*)msg.wParam; + Any any; + any <<= (sal_uInt32) pData->hWnd; + pData->xInit->initialize( Sequence<Any>( &any, 1)); + + CoTaskMemFree( pData); + break; + } + case WM_SOURCE_STARTDRAG: + { + // wParam contains necessary data + StartDragData* pData= (StartDragData*)msg.wParam; + Sequence<DataFlavor> seq= pData->transferable->getTransferDataFlavors(); + // have a look what flavours are supported + for( int i=0; i<seq.getLength(); i++) + { + DataFlavor d= seq[i]; + } + pData->source->startDrag( DragGestureEvent(), + ACTION_LINK|ACTION_MOVE|ACTION_COPY, + 0, + 0, + pData->transferable, + Reference<XDragSourceListener>( static_cast<XDragSourceListener*> + ( new DragSourceListener()))); + CoTaskMemFree( pData); + break; + } + + } // end switch + + TranslateMessage( &msg); + DispatchMessage( &msg); + } + + + CoUninitialize(); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/makefile.mk b/dtrans/test/win32/dnd/makefile.mk new file mode 100644 index 000000000000..3744e6135806 --- /dev/null +++ b/dtrans/test/win32/dnd/makefile.mk @@ -0,0 +1,83 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/..$/ + +PRJNAME=dtrans +TARGET=dndTest +TARGETTYPE=CUI +LIBTARGET=NO + +#USE_DEFFILE= TRUE +ENABLE_EXCEPTIONS=TRUE + +# --- Settings --- + +.INCLUDE : settings.mk + +# --- Files --- + +# CFLAGS+=-GR -DUNICODE -D_UNICODE +CFLAGS+= -D_WIN32_DCOM + +INCPRE+= -I$(ATL_INCLUDE) + +OBJFILES= $(OBJ)$/dndTest.obj \ + $(OBJ)$/atlwindow.obj \ + $(OBJ)$/targetlistener.obj \ + $(OBJ)$/sourcelistener.obj \ + $(OBJ)$/dataobject.obj + +APP1NOSAL=TRUE + +APP1TARGET= $(TARGET) +APP1OBJS=$(OBJFILES) + +APP1STDLIBS= \ + $(SALLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(UWINAPILIB) \ + $(USER32LIB) \ + $(OLE32LIB) \ + comsupp.lib \ + $(OLEAUT32LIB) \ + $(GDI32LIB) \ + $(UUIDLIB) + +APP1LIBS= \ + $(SLB)$/dtobjfact.lib \ + $(SLB)$/dtutils.lib + +# $(SOLARLIBDIR)$/imtaolecb.lib\ + +APP1DEF= $(MISC)\$(APP1TARGET).def + +# --- Targets --- + +.INCLUDE : target.mk + diff --git a/dtrans/test/win32/dnd/sourcelistener.cxx b/dtrans/test/win32/dnd/sourcelistener.cxx new file mode 100644 index 000000000000..a3a0a6f441bd --- /dev/null +++ b/dtrans/test/win32/dnd/sourcelistener.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dtrans.hxx" + + + +#include "sourcelistener.hxx" + + + +DragSourceListener::DragSourceListener() +{ +} +DragSourceListener::~DragSourceListener() +{ +} + +void SAL_CALL DragSourceListener::disposing( const EventObject& Source ) + throw(RuntimeException) +{ +} + +void SAL_CALL DragSourceListener::dragDropEnd( const DragSourceDropEvent& dsde ) + throw(RuntimeException) +{ +} + +void SAL_CALL DragSourceListener::dragEnter( const DragSourceDragEvent& dsde ) + throw(RuntimeException) +{ +} + +void SAL_CALL DragSourceListener::dragExit( const DragSourceEvent& dse ) + throw(RuntimeException) +{ +} + +void SAL_CALL DragSourceListener::dragOver( const DragSourceDragEvent& dsde ) + throw(RuntimeException) +{ +} + +void SAL_CALL DragSourceListener::dropActionChanged( const DragSourceDragEvent& dsde ) + throw(RuntimeException) +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/sourcelistener.hxx b/dtrans/test/win32/dnd/sourcelistener.hxx new file mode 100644 index 000000000000..dbe9f0308914 --- /dev/null +++ b/dtrans/test/win32/dnd/sourcelistener.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SOURCELISTENER_HXX_ +#define _SOURCELISTENER_HXX_ + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp> +#include <com/sun/star/datatransfer/dnd/DragSourceDropEvent.hpp> +#include <com/sun/star/datatransfer/dnd/DragSourceDragEvent.hpp> + +using namespace ::com::sun::star::datatransfer; +using namespace ::com::sun::star::datatransfer::dnd; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; + +class DragSourceListener: public WeakImplHelper1<XDragSourceListener> +{ + // this is a window where droped data are shown as text (only text) +public: + DragSourceListener( ); + ~DragSourceListener(); + + virtual void SAL_CALL disposing( const EventObject& Source ) + throw(RuntimeException); + + virtual void SAL_CALL dragDropEnd( const DragSourceDropEvent& dsde ) + throw(RuntimeException); + virtual void SAL_CALL dragEnter( const DragSourceDragEvent& dsde ) + throw(RuntimeException); + virtual void SAL_CALL dragExit( const DragSourceEvent& dse ) + throw(RuntimeException); + virtual void SAL_CALL dragOver( const DragSourceDragEvent& dsde ) + throw(RuntimeException); + virtual void SAL_CALL dropActionChanged( const DragSourceDragEvent& dsde ) + throw(RuntimeException); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/targetlistener.cxx b/dtrans/test/win32/dnd/targetlistener.cxx new file mode 100644 index 000000000000..7b74d1cde55a --- /dev/null +++ b/dtrans/test/win32/dnd/targetlistener.cxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dtrans.hxx" + + +#include "targetlistener.hxx" +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> +#include <com/sun/star/datatransfer/DataFlavor.hpp> + +//using namespace com::sun::star::datatransfer::dnd; +using namespace com::sun::star::datatransfer::dnd::DNDConstants; +using namespace com::sun::star::datatransfer; +using namespace rtl; + +DropTargetListener::DropTargetListener(HWND hEdit):m_hEdit( hEdit) +{ +} +DropTargetListener::~DropTargetListener() +{ +} + +void SAL_CALL DropTargetListener::disposing( const EventObject& Source ) + throw(RuntimeException) +{ + +} + + + +void SAL_CALL DropTargetListener::drop( const DropTargetDropEvent& e ) + throw(RuntimeException) +{ +// 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(); +// DataFlavor aFlavor; +// for( int i=0; i < flavors.getLength(); i++) +// aFlavor= flavors[4]; + + DataFlavor flavor( OUString(OUString::createFromAscii("text/plain;charset=windows-1252")), + OUString(L"Text plain"), getCppuType( ( Sequence<sal_Int8>*)0 ) ); + + Any anyData= e.Transferable->getTransferData( flavor); + Sequence<sal_Int8> seq= *( Sequence<sal_Int8>*)anyData.getValue(); + SendMessage( m_hEdit, WM_SETTEXT, 0, (LPARAM) seq.getConstArray() ); +} + +void SAL_CALL DropTargetListener::dragEnter( const DropTargetDragEnterEvent& dtde ) + throw(RuntimeException) +{ + //If one drags something that is not moveable + if( !(dtde.SourceActions & dtde.DropAction) ) + dtde.Context->acceptDrag( ACTION_COPY); + +// dtde.Context->rejectDrag( ); + +} + +void SAL_CALL DropTargetListener::dragExit( const DropTargetEvent& dte ) + throw(RuntimeException) +{ +} + +void SAL_CALL DropTargetListener::dragOver( const DropTargetDragEvent& dtde ) + throw(RuntimeException) +{ + if( !(dtde.SourceActions & dtde.DropAction) ) + dtde.Context->acceptDrag( ACTION_COPY); +} + +void SAL_CALL DropTargetListener::dropActionChanged( const DropTargetDragEvent& dtde ) + throw(RuntimeException) +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/targetlistener.hxx b/dtrans/test/win32/dnd/targetlistener.hxx new file mode 100644 index 000000000000..b5543fdc9e41 --- /dev/null +++ b/dtrans/test/win32/dnd/targetlistener.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _TARGETLISTENER_HXX_ +#define _TARGETLISTENER_HXX_ + +#if defined _MSC_VER +#pragma warning(push,1) +#endif +#include <windows.h> +#if defined _MSC_VER +#pragma warning(pop) +#endif +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDropEvent.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDragEvent.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDragEnterEvent.hpp> + +using namespace ::com::sun::star::datatransfer; +using namespace ::com::sun::star::datatransfer::dnd; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; + +class DropTargetListener: public WeakImplHelper1<XDropTargetListener> +{ + // this is a window where droped data are shown as text (only text) + HWND m_hEdit; +public: + DropTargetListener( HWND hEdit); + ~DropTargetListener(); + + virtual void SAL_CALL disposing( const EventObject& Source ) + throw(RuntimeException); + + + virtual void SAL_CALL drop( const DropTargetDropEvent& dtde ) + throw(RuntimeException); + virtual void SAL_CALL dragEnter( const DropTargetDragEnterEvent& dtde ) + throw(RuntimeException); + virtual void SAL_CALL dragExit( const DropTargetEvent& dte ) + throw(RuntimeException); + virtual void SAL_CALL dragOver( const DropTargetDragEvent& dtde ) + throw(RuntimeException); + virtual void SAL_CALL dropActionChanged( const DropTargetDragEvent& dtde ) + throw(RuntimeException); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/transferable.cxx b/dtrans/test/win32/dnd/transferable.cxx new file mode 100644 index 000000000000..c20514f93b4b --- /dev/null +++ b/dtrans/test/win32/dnd/transferable.cxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dtrans.hxx" +#include "transferable.hxx" + +//---------------------------------------------------------------- +// ctor +//---------------------------------------------------------------- + + + +CTransferable::CTransferable( wchar_t* dataString ) : + m_seqDFlv( 1 ), + m_Data( dataString ) +{ + DataFlavor df; + + /* + df.MimeType = L"text/plain; charset=unicode"; + df.DataType = getCppuType( ( OUString* )0 ); + + m_seqDFlv[0] = df; + */ + + //df.MimeType = L"text/plain; charset=windows1252"; + df.MimeType = L"text/plain"; + df.DataType = getCppuType( ( Sequence< sal_Int8 >* )0 ); + + + m_seqDFlv[0] = df; +} + +//---------------------------------------------------------------- +// getTransferData +//---------------------------------------------------------------- + +Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor ) + throw(UnsupportedFlavorException, IOException, RuntimeException) +{ + Any anyData; + + /*if ( aFlavor == m_seqDFlv[0] ) + { + anyData = makeAny( m_Data ); + } + else*/ if ( aFlavor == m_seqDFlv[0] ) + { + OString aStr( m_Data.getStr( ), m_Data.getLength( ), 1252 ); + Sequence< sal_Int8 > sOfChars( aStr.getLength( ) ); + sal_Int32 lenStr = aStr.getLength( ); + + for ( sal_Int32 i = 0; i < lenStr; ++i ) + sOfChars[i] = aStr[i]; + + anyData = makeAny( sOfChars ); + } + + return anyData; +} + +//---------------------------------------------------------------- +// getTransferDataFlavors +//---------------------------------------------------------------- + +Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( ) + throw(RuntimeException) +{ + return m_seqDFlv; +} + +//---------------------------------------------------------------- +// isDataFlavorSupported +//---------------------------------------------------------------- + +sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor ) + throw(RuntimeException) +{ + sal_Int32 nLength = m_seqDFlv.getLength( ); + sal_Bool bRet = sal_False; + + for ( sal_Int32 i = 0; i < nLength; ++i ) + { + if ( m_seqDFlv[i] == aFlavor ) + { + bRet = sal_True; + break; + } + } + + return bRet; +} + +//---------------------------------------------------------------- +// lostOwnership +//---------------------------------------------------------------- + +void SAL_CALL CTransferable::lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) + throw(RuntimeException) +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/test/win32/dnd/transferable.hxx b/dtrans/test/win32/dnd/transferable.hxx new file mode 100644 index 000000000000..315b3f55c9b2 --- /dev/null +++ b/dtrans/test/win32/dnd/transferable.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _TRANSFERABLE_HXX_ +#define _TRANSFERABLE_HXX_ + +#include <cppuhelper/servicefactory.hxx> +#include <com/sun/star/datatransfer/XTransferable.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <cppuhelper/implbase2.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> +#include <osl/diagnose.h> + +#include <stdio.h> +#if defined _MSC_VER +#pragma warning(push,1) +#endif +#include <windows.h> +#include <objbase.h> +#if defined _MSC_VER +#pragma warning(pop) +#endif + +#include <memory> + +#include <process.h> + +#include "..\..\source\win32\ImplHelper.hxx" + + +//------------------------------------------------------------- +// my defines +//------------------------------------------------------------- + +#define TEST_CLIPBOARD +#define RDB_SYSPATH "d:\\projects\\src616\\dtrans\\wntmsci7\\bin\\applicat.rdb" +#define WINCLIPBOARD_SERVICE_NAME L"com.sun.star.datatransfer.clipboard.SystemClipboard" +#define WRITE_CB +#define EVT_MANUAL_RESET TRUE +#define EVT_INIT_NONSIGNALED FALSE +#define EVT_NONAME "" + +//------------------------------------------------------------ +// namesapces +//------------------------------------------------------------ + +using namespace ::rtl; +using namespace ::std; +using namespace ::cppu; +using namespace ::com::sun::star::datatransfer; +using namespace ::com::sun::star::datatransfer::clipboard; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::lang; + +//------------------------------------------------------------ +// +//------------------------------------------------------------ + +class CTransferable : public WeakImplHelper2< XClipboardOwner, XTransferable > +{ +public: + CTransferable( ){}; + CTransferable( wchar_t* dataString); + + //------------------------------------------------- + // XTransferable + //------------------------------------------------- + + virtual Any SAL_CALL getTransferData( const DataFlavor& aFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException); + virtual Sequence< DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(RuntimeException); + virtual sal_Bool SAL_CALL isDataFlavorSupported( const DataFlavor& aFlavor ) throw(RuntimeException); + + //------------------------------------------------- + // XClipboardOwner + //------------------------------------------------- + + virtual void SAL_CALL lostOwnership( const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) throw(RuntimeException); + +private: + Sequence< DataFlavor > m_seqDFlv; + OUString m_Data; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |