postprocess/qa/services.cxx | 5 vcl/inc/factory.hxx | 7 vcl/source/app/session.cxx | 1 vcl/source/components/dtranscomp.cxx | 31 -- vcl/source/components/factory.cxx | 6 vcl/source/components/fontident.cxx | 1 vcl/vcl.common.component | 8 vcl/vcl.common.component.macosx | 1 vcl/vcl.common.component.unx | 1 vcl/workben/win/dnd/atlwindow.cxx | 238 --------------------- vcl/workben/win/dnd/atlwindow.hxx | 87 -------- vcl/workben/win/dnd/dndTest.cxx | 177 ---------------- vcl/workben/win/dnd/makefile.mk | 70 ------ vcl/workben/win/dnd/sourcelistener.cxx | 59 ----- vcl/workben/win/dnd/sourcelistener.hxx | 56 ----- vcl/workben/win/dnd/targetlistener.cxx | 78 ------- vcl/workben/win/dnd/targetlistener.hxx | 64 ----- vcl/workben/win/dnd/transferable.cxx | 105 --------- vcl/workben/win/dnd/transferable.hxx | 88 -------- vcl/workben/win/dtrans/XTDo.cxx | 358 --------------------------------- vcl/workben/win/dtrans/XTDo.hxx | 111 ---------- vcl/workben/win/dtrans/makefile.mk | 81 ------- vcl/workben/win/dtrans/test_wincb.cxx | 287 -------------------------- vcl/workben/win/dtrans/testmarshal.cxx | 212 ------------------- 24 files changed, 2132 deletions(-)
New commits: commit 44da22e03b46e4b00b1fa9d136560b77372d778f Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 11 13:47:54 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Jul 14 09:48:35 2025 +0200 vcl: Drop logic to create drop target by service name DropTarget_createInstance, which would have been called when trying to create a drop target via service name, calls SalInstance::CreateDropTarget with the default null `pSysEnv` param. For all cases except headless mode or when running unit tests, that calls the platform/VCL-specific SalInstance::ImplCreateDropTarget overrides, which would unconditionally dereference the null `pSysEnv`. Since this logic to create a drop target by service name is unused, presumably since commit 031576105c21b2e0c2585a1236092487d5d193e2 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Thu Jan 6 14:16:53 2022 +0100 VCL move platform code from mouse.cxx into plugins ... by moving it into ImplCreate(DragSource|DropTarget). The existing Create* variant now checks for headless mode and the IsRunningUnitTest flag, before creating the platform variants. There are two small helpers to initialize either X11 or Ole based UNO DnD interace implementations. Unfortunatly Windows requires to move two dtrans header files, but at least any other changes are minimal. , drop it altogether. com::sun::star::datatransfer::dnd.X11DropTarget is a published UNO service (see offapi/com/sun/star/datatransfer/dnd/X11DropTarget.idl), so leave the specification in the IDL file around, even if there is no way to create an instance via external code (macros, extensions). That's not new with this commit, since the service was only meant to be supported by the gen VCL plugin on Linux previously, but then, trying to create an instance would crash in X11SalInstance::ImplCreateDropTarget due to dereferencing the null `pSysEnv`. The XInitialization interface as mentioned in the IDL file: /** The service expects an instance of com::sun::star::awt::XDisplayConnection as the first parameter. The second parameter must be a long that contains an XWindow window which shall be registered as drop target. */ interface com::sun::star::lang::XInitialization; hasn't been implemented any more since commit 30b4c1d7876d29ef29ccc4a6245448c59718abce Author: Michael Weghorn <m.wegh...@posteo.de> Date: Fri Jul 4 10:01:23 2025 +0200 gen: Simplify DropTarget init, don't use XInitialization , but also before then, an XDisplayConnection to pass as a param to the XInitilization::initialize implementation couldn't be retrieved via external code, see the commit message of commit 7a9108a48efc80fafd68a2e33c854fac05dcb803 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Fri Jul 4 11:16:24 2025 +0200 vcl: Stop implementing XDisplayConnection for more details. The published service com::sun::star::datatransfer::dnd::OleDropTarget is Windows-specific in its description. Quoting from offapi/com/sun/star/datatransfer/dnd/OleDropTarget.idl: /** The service expects a windows window handle. It is passed as unsigned long. */ interface com::sun::star::lang::XInitialization; , while it was also used on macOS internally before the above-mentioned 031576105c21b2e0c2585a1236092487d5d193e2. The actual Windows implementation has a separate UNO constructor (see vcl/vclplug_win.component) and should therefore be unaffected by this change. If the X11-specific X11DropTarget service were actually relevant, it should probably be implemented similarly (specifically for the gen VCL plugin only, without reintroducing the rest of the logic dropped in this commit.) Searches for "com.sun.star.datatransfer.dnd.X11DropTarget" and "com.sun.star.datatransfer.dnd.OleDropTarget" in Google and on Ask [1] didn't give any results that would suggest that these services would actually be used by existing third party code. Change-Id: I93c099b82e209efe11f30bbc4f5fa0a6e1fff992 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187726 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/postprocess/qa/services.cxx b/postprocess/qa/services.cxx index 7e83206cc389..26f9963dc46f 100644 --- a/postprocess/qa/services.cxx +++ b/postprocess/qa/services.cxx @@ -357,11 +357,6 @@ void Test::createInstance( { expImpl = "com.sun.star.datatransfer.dnd.VclGenericDragSource"; expServs = {u"com.sun.star.datatransfer.dnd.GenericDragSource"_ustr}; - } else if (name == "com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1" - || name == "com.sun.star.datatransfer.dnd.XdndDropTarget") - { - expImpl = "com.sun.star.datatransfer.dnd.VclGenericDropTarget"; - expServs = {u"com.sun.star.datatransfer.dnd.GenericDropTarget"_ustr}; #endif } else if (name == "com.sun.star.ui.dialogs.FolderPicker") { // FolderPicker is a wrapper returning either a platform-specific or the diff --git a/vcl/inc/factory.hxx b/vcl/inc/factory.hxx index 297271ea7b76..f961f06d49ac 100644 --- a/vcl/inc/factory.hxx +++ b/vcl/inc/factory.hxx @@ -41,13 +41,6 @@ OUString DragSource_getImplementationName(); css::uno::Reference<css::uno::XInterface> DragSource_createInstance( css::uno::Reference<css::lang::XMultiServiceFactory > const &); -css::uno::Sequence<OUString> DropTarget_getSupportedServiceNames(); - -OUString DropTarget_getImplementationName(); - -css::uno::Reference<css::uno::XInterface> DropTarget_createInstance( - css::uno::Reference<css::lang::XMultiServiceFactory > const &); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/components/dtranscomp.cxx b/vcl/source/components/dtranscomp.cxx index 5b9298341ad2..053d2319b5aa 100644 --- a/vcl/source/components/dtranscomp.cxx +++ b/vcl/source/components/dtranscomp.cxx @@ -376,37 +376,6 @@ void GenericDropTarget::setDefaultActions( sal_Int8) { } -Sequence< OUString > DropTarget_getSupportedServiceNames() -{ -#if defined MACOSX - return { "com.sun.star.datatransfer.dnd.OleDropTarget" }; -#elif defined UNX - return { u"com.sun.star.datatransfer.dnd.X11DropTarget"_ustr }; -#else - return GenericDropTarget::getSupportedServiceNames_static(); -#endif -} - -OUString DropTarget_getImplementationName() -{ - return - #if defined MACOSX - "com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1" - #elif defined UNX - u"com.sun.star.datatransfer.dnd.XdndDropTarget"_ustr - #else - "com.sun.star.datatransfer.dnd.VclGenericDropTarget" - #endif - ; -} - -Reference< XInterface > DropTarget_createInstance( const Reference< XMultiServiceFactory >& ) -{ - SolarMutexGuard aGuard; - Reference< XInterface > xResult = ImplGetSVData()->mpDefInst->CreateDropTarget(); - return xResult; -} - } // namespace vcl /* diff --git a/vcl/source/components/factory.cxx b/vcl/source/components/factory.cxx index 4967d0de5254..806dc6277d8e 100644 --- a/vcl/source/components/factory.cxx +++ b/vcl/source/components/factory.cxx @@ -45,12 +45,6 @@ extern "C" { xMgr, vcl::DragSource_getImplementationName(), vcl::DragSource_createInstance, vcl::DragSource_getSupportedServiceNames() ); } - else if( vcl::DropTarget_getImplementationName().equalsAscii( pImplementationName ) ) - { - xFactory = ::cppu::createSingleFactory( - xMgr, vcl::DropTarget_getImplementationName(), vcl::DropTarget_createInstance, - vcl::DropTarget_getSupportedServiceNames() ); - } if( xFactory.is() ) { diff --git a/vcl/vcl.common.component b/vcl/vcl.common.component index 3069a1c79d19..d79fa0061db0 100644 --- a/vcl/vcl.common.component +++ b/vcl/vcl.common.component @@ -23,10 +23,6 @@ <service name="com.sun.star.datatransfer.dnd.OleDragSource"/> <optional/> </implementation> - <implementation name="com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1"> - <service name="com.sun.star.datatransfer.dnd.OleDropTarget"/> - <optional/> - </implementation> <implementation name="com.sun.star.comp.graphic.GraphicMapper" constructor="com_sun_star_comp_graphic_GraphicMapper_get_implementation"> <service name="com.sun.star.graphic.GraphicMapper"/> @@ -45,10 +41,6 @@ <service name="com.sun.star.datatransfer.clipboard.SystemClipboard"/> <optional/> </implementation> - <implementation name="com.sun.star.datatransfer.dnd.XdndDropTarget"> - <service name="com.sun.star.datatransfer.dnd.X11DropTarget"/> - <optional/> - </implementation> <implementation name="com.sun.star.datatransfer.dnd.XdndSupport"> <service name="com.sun.star.datatransfer.dnd.X11DragSource"/> <optional/> diff --git a/vcl/vcl.common.component.macosx b/vcl/vcl.common.component.macosx index bc990c02f0a6..cc831c8090e9 100644 --- a/vcl/vcl.common.component.macosx +++ b/vcl/vcl.common.component.macosx @@ -5,7 +5,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. com.sun.star.comp.datatransfer.dnd.OleDragSource_V1 -com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1 com.sun.star.datatransfer.clipboard.AquaClipboard com.sun.star.frame.VCLSessionManagerClient org.libreoffice.uitest.UITest diff --git a/vcl/vcl.common.component.unx b/vcl/vcl.common.component.unx index bd2e44569a1d..88ddc02397fe 100644 --- a/vcl/vcl.common.component.unx +++ b/vcl/vcl.common.component.unx @@ -4,7 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -com.sun.star.datatransfer.dnd.XdndDropTarget com.sun.star.datatransfer.dnd.XdndSupport com.sun.star.datatransfer.X11ClipboardSupport com.sun.star.frame.VCLSessionManagerClient commit 487942961db60a11c71edeea50d0ec0403271d01 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 11 14:04:32 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Jul 14 09:48:28 2025 +0200 vcl: Drop unused <factory.hxx> includes Change-Id: I38e8209dde0fd454dff5ba0b8ab045dc94d82d3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187725 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/app/session.cxx b/vcl/source/app/session.cxx index 2ec3bbc5c7d6..7fa5d7b98287 100644 --- a/vcl/source/app/session.cxx +++ b/vcl/source/app/session.cxx @@ -28,7 +28,6 @@ #include <utility> #include <vcl/svapp.hxx> -#include <factory.hxx> #include <svdata.hxx> #include <salinst.hxx> #include <salsession.hxx> diff --git a/vcl/source/components/fontident.cxx b/vcl/source/components/fontident.cxx index 342866ea02be..9c30822d9926 100644 --- a/vcl/source/components/fontident.cxx +++ b/vcl/source/components/fontident.cxx @@ -20,7 +20,6 @@ #include <vcl/svapp.hxx> #include <vcl/font.hxx> -#include <factory.hxx> #include <svdata.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> commit 1ca71074a86c5cd74d6f76d6298c3f30076efabd Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 11 12:15:51 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Jul 14 09:48:23 2025 +0200 win: Drop long dead vcl/workben/win/{dtrans,dnd} This seems to never have been migrated to gbuild and thus never have been part of the build since then, see the old/custom Makefiles vcl/workben/win/dnd/makefile.mk and vcl/workben/win/dtrans/makefile.mk. The code uses API that has long been dropped, e.g. tries to #include <cppuhelper/servicefactory.hxx> which has been removed more than a decade ago in commit f3051abde54e7a0bc3e2d184e31ac011e96d3e6b Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Dec 21 13:48:07 2012 +0100 API CHANGE: Remove deprecated cppuhelper/servicefactory.hxx and Java equiv. Drop the dead code altogether. The actual clipboard and Drag'n'Drop logic for Windows is located inside vcl/win/dtrans these days. Change-Id: Iff2360cae9b4101f90c740c5ba582883c36519ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187697 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/workben/win/dnd/atlwindow.cxx b/vcl/workben/win/dnd/atlwindow.cxx deleted file mode 100644 index 61781e18f5dd..000000000000 --- a/vcl/workben/win/dnd/atlwindow.cxx +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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; - -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 an 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("com.sun.star.datatransfer.dnd.OleDragSource"); - m_xDragSource.set( 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("com.sun.star.datatransfer.dnd.OleDropTarget"); - m_xDropTarget.set( 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 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) -{ - 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= CDOTransferable::create( - 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); - - CloseHandle(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/vcl/workben/win/dnd/atlwindow.hxx b/vcl/workben/win/dnd/atlwindow.hxx deleted file mode 100644 index 047acf6769b1..000000000000 --- a/vcl/workben/win/dnd/atlwindow.hxx +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once -#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; - -public: - explicit 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); - -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dnd/dndTest.cxx b/vcl/workben/win/dnd/dndTest.cxx deleted file mode 100644 index 2f2a7bccfc68..000000000000 --- a/vcl/workben/win/dnd/dndTest.cxx +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#if defined _MSC_VER -#pragma warning(push,1) -#endif -#include <windows.h> -#include <comdef.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/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; - -HRESULT doTest(); -DWORD WINAPI MTAFunc( void* threadData); - -Reference< XMultiServiceFactory > MultiServiceFactory; - -int main( int argc, char *argv[ ], char *envp[ ] ) -{ - HRESULT hr; - if( FAILED( hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) - { - printf("CoInitializeEx failed "); - return -1; - } - - _Module.Init( ObjectMap, GetModuleHandleA( NULL)); - - if( FAILED(hr=doTest())) - { - _com_error err( hr); - } - - _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= CreateEventA(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("DnD starting in Ole STA", threadIdMTA, pos1); - - RECT pos2={ 0, 205, 300, 405}; - AWindow win2("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("DnD starting in OLE STA", threadIdMTA, pos3, false, true); - - RECT pos4={ 300, 205, 600, 405}; - AWindow win24("DnD starting in Ole MTA", threadIdMTA, pos4, true, true); - - MSG msg; - while( GetMessageA(&msg, (HWND)NULL, 0, 0) ) - { - TranslateMessage( &msg); - DispatchMessageA( &msg); - } - - // Shut down the MTA thread - PostThreadMessageA( threadIdMTA, WM_QUIT, 0, 0); - WaitForSingleObject(hMTAThread, INFINITE); - CloseHandle(hMTAThread); - - return S_OK; -} - -extern Reference<XMultiServiceFactory> MultiServiceFactory; -DWORD WINAPI MTAFunc( void* threadData) -{ - HRESULT hr= CoInitializeEx( NULL, COINIT_MULTITHREADED); - ATLASSERT( FAILED(hr) ); - MSG msg; - // force the creation of a message queue - PeekMessageA(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); - SetEvent( *(HANDLE*)threadData ); - - RECT pos={0, 406, 300, 605}; - AWindow win("DnD, full MTA", GetCurrentThreadId(), pos, false, true); - - while( GetMessageA(&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.(); 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); - DispatchMessageA( &msg); - } - - CoUninitialize(); - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dnd/makefile.mk b/vcl/workben/win/dnd/makefile.mk deleted file mode 100644 index e0d438418eb1..000000000000 --- a/vcl/workben/win/dnd/makefile.mk +++ /dev/null @@ -1,70 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ=..$/..$/..$/ - -PRJNAME=dtrans -TARGET=dndTest -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings --- - -.INCLUDE : settings.mk - -# --- Files --- - -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 - -APP1DEF= $(MISC)\$(APP1TARGET).def - -# --- Targets --- - -.INCLUDE : target.mk - diff --git a/vcl/workben/win/dnd/sourcelistener.cxx b/vcl/workben/win/dnd/sourcelistener.cxx deleted file mode 100644 index aa3366e79a11..000000000000 --- a/vcl/workben/win/dnd/sourcelistener.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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/vcl/workben/win/dnd/sourcelistener.hxx b/vcl/workben/win/dnd/sourcelistener.hxx deleted file mode 100644 index 0fc051399042..000000000000 --- a/vcl/workben/win/dnd/sourcelistener.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <cppuhelper/implbase.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 WeakImplHelper<XDragSourceListener> -{ - // this is a window where dropped 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); - -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dnd/targetlistener.cxx b/vcl/workben/win/dnd/targetlistener.cxx deleted file mode 100644 index 3290cc2adf53..000000000000 --- a/vcl/workben/win/dnd/targetlistener.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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::DNDConstants; -using namespace com::sun::star::datatransfer; - -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->rejectDrop(); - - DataFlavor flavor( u"text/plain;charset=windows-1252"_ustr, - u"Text plain"_ustr, cppu::UnoType<Sequence<sal_Int8>>::get() ); - - 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); -} - -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/vcl/workben/win/dnd/targetlistener.hxx b/vcl/workben/win/dnd/targetlistener.hxx deleted file mode 100644 index f42fac33aec5..000000000000 --- a/vcl/workben/win/dnd/targetlistener.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#if defined _MSC_VER -#pragma warning(push,1) -#endif -#include <windows.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif -#include <cppuhelper/implbase.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 WeakImplHelper<XDropTargetListener> -{ - // this is a window where dropped data are shown as text (only text) - HWND m_hEdit; -public: - explicit 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); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dnd/transferable.cxx b/vcl/workben/win/dnd/transferable.cxx deleted file mode 100644 index 924c031763b5..000000000000 --- a/vcl/workben/win/dnd/transferable.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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 = cppu::UnoType<OUString>::get(); - - m_seqDFlv[0] = df; - */ - - //df.MimeType = L"text/plain; charset=windows1252"; - df.MimeType = L"text/plain"; - df.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - - 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/vcl/workben/win/dnd/transferable.hxx b/vcl/workben/win/dnd/transferable.hxx deleted file mode 100644 index c1606cab8648..000000000000 --- a/vcl/workben/win/dnd/transferable.hxx +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#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/implbase.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 "" - -// namespaces - -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 WeakImplHelper< XClipboardOwner, XTransferable > -{ -public: - CTransferable( ){}; - explicit 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; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dtrans/XTDo.cxx b/vcl/workben/win/dtrans/XTDo.cxx deleted file mode 100644 index f8da707d92e3..000000000000 --- a/vcl/workben/win/dtrans/XTDo.cxx +++ /dev/null @@ -1,358 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/diagnose.h> - -#include "../DTransHelper.hxx" - -#include "XTDo.hxx" - -#if defined _MSC_VER -#pragma warning(push,1) -#endif -#include <windows.h> -#include <ole2.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif -#include <memory> - -using namespace ::std; - -// OTWrapperDataObject - -/* - in the constructor we enumerate all formats offered by the transferable - and convert the formats into formatetc structures - if the transferable supports text in different charsets we use either - the charset equal to the charset of the current thread or an arbitrary - charset supported by the transferable and the system - if the transferable supports only unicodetext we offer in addition to - this text in the charset of the current thread - in order to allow the consumer of the clipboard to query for the charset - of the text in the clipboard we offer a CF_LOCALE -*/ -CXTDataObject::CXTDataObject( ) : - m_nRefCnt( 0 ) -{ - -} - -// IUnknown->QueryInterface - -STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject ) -{ - OSL_ASSERT( NULL != ppvObject ); - - if ( NULL == ppvObject ) - return E_INVALIDARG; - - HRESULT hr = E_NOINTERFACE; - - *ppvObject = NULL; - - if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) ) - { - *ppvObject = static_cast< IUnknown* >( this ); - ( (LPUNKNOWN)*ppvObject )->AddRef( ); - hr = S_OK; - } - - return hr; -} - -// IUnknown->AddRef - -STDMETHODIMP_(ULONG) CXTDataObject::AddRef( ) -{ - return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) ); -} - -// IUnknown->Release - -STDMETHODIMP_(ULONG) CXTDataObject::Release( ) -{ - // we need a helper variable because it's - // not allowed to access a member variable - // after an object is destroyed - ULONG nRefCnt = static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) ); - - if ( 0 == nRefCnt ) - { - delete this; - } - - return nRefCnt; -} - -/*------------------------------------------------------------------------ - - IDataObject->GetData - we deliver data only into global memory - - algo: - 1. convert the given formatect struct into a valid dataflavor - 2. if the transferable directly supports the requested format - 2.1. if text data requested add a trailing ' - problems (windows needs ' - 2.2. we expect unicode data as Sequence< sal_Unicode > and all other - text and raw data as Sequence< sal_Int8 > - -------------------------------------------------------------------------*/ - -STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ) -{ - if ( ( NULL == pFormatetc ) || ( NULL == pmedium ) ) - return E_INVALIDARG; - - HRESULT hr = E_FAIL; - - if ( CF_TEXT == pFormatetc->cfFormat ) - { - CHGlobalHelper hGlobHlp( TRUE ); - - char pBuff[] = "Test OleClipboard"; - hGlobHlp.Write( pBuff, sizeof( pBuff ), NULL ); - - pmedium->tymed = TYMED_HGLOBAL; - pmedium->hGlobal = hGlobHlp.GetHGlobal( ); - pmedium->pUnkForRelease = NULL; - - hr = S_OK; - } - - return hr; -} - -// IDataObject->EnumFormatEtc - -STDMETHODIMP CXTDataObject::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc ) -{ - if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) ) - return E_INVALIDARG; - - *ppenumFormatetc = NULL; - - HRESULT hr = E_FAIL; - - if ( DATADIR_GET == dwDirection ) - { - *ppenumFormatetc = new CEnumFormatEtc( this ); - static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( ); - hr = S_OK; - } - - return hr; -} - -// IDataObject->QueryGetData - -STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc ) -{ - return E_NOTIMPL; -} - -// IDataObject->GetDataHere - -STDMETHODIMP CXTDataObject::GetDataHere( LPFORMATETC, LPSTGMEDIUM ) -{ - return E_NOTIMPL; -} - -// IDataObject->GetCanonicalFormatEtc - -STDMETHODIMP CXTDataObject::GetCanonicalFormatEtc( LPFORMATETC, LPFORMATETC ) -{ - return E_NOTIMPL; -} - -// IDataObject->SetData - -STDMETHODIMP CXTDataObject::SetData( LPFORMATETC, LPSTGMEDIUM, BOOL ) -{ - return E_NOTIMPL; -} - -// IDataObject->DAdvise - -STDMETHODIMP CXTDataObject::DAdvise( LPFORMATETC, DWORD, LPADVISESINK, DWORD * ) -{ - return E_NOTIMPL; -} - -// IDataObject->DUnadvise - -STDMETHODIMP CXTDataObject::DUnadvise( DWORD ) -{ - return E_NOTIMPL; -} - -// IDataObject->EnumDAdvise - -STDMETHODIMP CXTDataObject::EnumDAdvise( LPENUMSTATDATA * ) -{ - return E_NOTIMPL; -} - -CXTDataObject::operator IDataObject*( ) -{ - return static_cast< IDataObject* >( this ); -} - -CEnumFormatEtc::CEnumFormatEtc( LPUNKNOWN pUnkDataObj ) : - m_nRefCnt( 0 ), - m_pUnkDataObj( pUnkDataObj ), - m_nCurrPos( 0 ) -{ -} - -// IUnknown->QueryInterface - -STDMETHODIMP CEnumFormatEtc::QueryInterface( REFIID iid, LPVOID* ppvObject ) -{ - if ( NULL == ppvObject ) - return E_INVALIDARG; - - HRESULT hr = E_NOINTERFACE; - - *ppvObject = NULL; - - if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IEnumFORMATETC ) == iid ) ) - { - *ppvObject = static_cast< IUnknown* >( this ); - static_cast< LPUNKNOWN >( *ppvObject )->AddRef( ); - hr = S_OK; - } - - return hr; -} - -// IUnknown->AddRef - -STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef( ) -{ - // keep the dataobject alive - m_pUnkDataObj->AddRef( ); - return InterlockedIncrement( &m_nRefCnt ); -} - -// IUnknown->Release - -STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( ) -{ - // release the outer dataobject - m_pUnkDataObj->Release( ); - - // we need a helper variable because it's - // not allowed to access a member variable - // after an object is destroyed - ULONG nRefCnt = InterlockedDecrement( &m_nRefCnt ); - if ( 0 == nRefCnt ) - delete this; - - return nRefCnt; -} - -// IEnumFORMATETC->Next - -STDMETHODIMP CEnumFormatEtc::Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched ) -{ - if ( ( 0 != celt ) && ( NULL == rgelt ) ) - return E_INVALIDARG; - - ULONG ulFetched = 0; - ULONG ulToFetch = celt; - HRESULT hr = S_FALSE; - - while( m_nCurrPos < 1 ) - { - rgelt->cfFormat = CF_TEXT; - rgelt->ptd = NULL; - rgelt->dwAspect = DVASPECT_CONTENT; - rgelt->lindex = -1; - rgelt->tymed = TYMED_HGLOBAL; - - ++m_nCurrPos; - ++rgelt; - --ulToFetch; - ++ulFetched; - } - - if ( ulFetched == celt ) - hr = S_OK; - - if ( NULL != pceltFetched ) - { - *pceltFetched = ulFetched; - } - - return hr; -} - -// IEnumFORMATETC->Skip - -STDMETHODIMP CEnumFormatEtc::Skip( ULONG celt ) -{ - HRESULT hr = S_FALSE; - - /* - if ( ( m_nCurrPos + celt ) < m_nClipFormats ) - { - m_nCurrPos += celt; - hr = S_OK; - } - */ - - return hr; -} - -// IEnumFORMATETC->Reset - -STDMETHODIMP CEnumFormatEtc::Reset( ) -{ - m_nCurrPos = 0; - return S_OK; -} - -// IEnumFORMATETC->Clone - -STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum ) -{ - OSL_ASSERT( NULL != ppenum ); - - if ( NULL == ppenum ) - return E_INVALIDARG; - - HRESULT hr = E_FAIL; - - *ppenum = NULL; - - CEnumFormatEtc* pCEnumFEtc = new CEnumFormatEtc( m_pUnkDataObj ); - if ( NULL != pCEnumFEtc ) - { - pCEnumFEtc->m_nCurrPos = m_nCurrPos; - *ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc ); - static_cast< LPUNKNOWN >( *ppenum )->AddRef( ); - hr = NOERROR; - } - - return hr; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dtrans/XTDo.hxx b/vcl/workben/win/dtrans/XTDo.hxx deleted file mode 100644 index 095987a49d0a..000000000000 --- a/vcl/workben/win/dtrans/XTDo.hxx +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#if defined _MSC_VER -#pragma warning(push,1) -#endif -#include <windows.h> -#include <ole2.h> -#include <objidl.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif - -#include <vector> - -class EnumFormatEtc; - -/*-------------------------------------------------------------------------- - - the function principle of the windows clipboard: - a data provider offers all formats he can deliver on the clipboard - a clipboard client ask for the available formats on the clipboard - and decides if there is a format he can use - if there is one, he requests the data in this format - - - This class inherits from IDataObject and so can be placed on the - OleClipboard. The class wraps a transferable object which is the - original DataSource - - DataFlavors offered by this transferable will be translated into - appropriate clipboard formats - - if the transferable contains text data always text and unicodetext - will be offered or vice versa - - text data will be automatically converted between text and unicode text - - although the transferable may support text in different charsets - (codepages) only text in one codepage can be offered by the clipboard - -----------------------------------------------------------------------------*/ - -class CXTDataObject : public IDataObject -{ -public: - CXTDataObject( ); - - // ole interface implementation - - //IUnknown interface methods - STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject); - STDMETHODIMP_( ULONG ) AddRef( ); - STDMETHODIMP_( ULONG ) Release( ); - - // IDataObject interface methods - STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); - STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); - STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc ); - STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut ); - STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease ); - STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc ); - STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection ); - STDMETHODIMP DUnadvise( DWORD dwConnection ); - STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise ); - - operator IDataObject*( ); - -private: - -private: - LONG m_nRefCnt; -}; - -class CEnumFormatEtc : public IEnumFORMATETC -{ -public: - explicit CEnumFormatEtc( LPUNKNOWN pUnkDataObj ); - - // IUnknown - STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject ); - STDMETHODIMP_( ULONG ) AddRef( ); - STDMETHODIMP_( ULONG ) Release( ); - - //IEnumFORMATETC - STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched ); - STDMETHODIMP Skip( ULONG celt ); - STDMETHODIMP Reset( ); - STDMETHODIMP Clone( IEnumFORMATETC** ppenum ); - -private: - LONG m_nRefCnt; - LPUNKNOWN m_pUnkDataObj; - ULONG m_nCurrPos; -}; - -typedef CEnumFormatEtc *PCEnumFormatEtc; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dtrans/makefile.mk b/vcl/workben/win/dtrans/makefile.mk deleted file mode 100644 index 3c82289f8ee1..000000000000 --- a/vcl/workben/win/dtrans/makefile.mk +++ /dev/null @@ -1,81 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ=..$/..$/.. - -PRJNAME= dtrans -TARGET= testwincb -TARGET1= testmshl -LIBTARGET= NO -TARGETTYPE= CUI -USE_BOUNDCHK= -TESTCB=TRUE - -.IF "$(USE_BOUNDCHK)"=="TR" -bndchk=tr -stoponerror=tr -.ENDIF - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -.IF "$(TESTCB)"=="TRUE" - -CFLAGS+=-D_WIN32_DCOM -EHsc -Ob0 - -# --- Files -------------------------------------------------------- - -OBJFILES= $(OBJ)$/test_wincb.obj -APP1TARGET= $(TARGET) -APP1OBJS= $(OBJ)$/test_wincb.obj - -APP1STDLIBS= $(SALLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(USER32LIB) \ - $(OLE32LIB)\ - $(COMDLG32LIB) - -APP1LIBS= $(SLB)$/dtutils.lib - -APP1NOSAL= TRUE - -.ENDIF - -.IF "$(TESTCB)"=="" - -CFLAGS+=/D_WIN32_DCOM /EHsc /Ob0 - -OBJFILES= $(OBJ)$/testmarshal.obj -APP1TARGET= $(TARGET1) -APP1OBJS= $(OBJ)$/testmarshal.obj - -APP1STDLIBS= $(SALLIB)\ - $(USER32LIB)\ - $(OLE32LIB)\ - comsupp.lib\ - $(OLEAUT32LIB) - -APP1LIBS= -APP1NOSAL= TRUE - -.ENDIF - -# --- Targets ------------------------------------------------------ -.INCLUDE : target.mk diff --git a/vcl/workben/win/dtrans/test_wincb.cxx b/vcl/workben/win/dtrans/test_wincb.cxx deleted file mode 100644 index 96839e22a49a..000000000000 --- a/vcl/workben/win/dtrans/test_wincb.cxx +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "../misc/ImplHelper.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/datatransfer/clipboard/XFlushableClipboard.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <cppuhelper/implbase.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> - -// my defines - -#define TEST_CLIPBOARD -#define RDB_SYSPATH "d:\projects\src623\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 "" - -// namespaces - -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; - -// globales - -Reference< XTransferable > rXTransfRead; -HANDLE g_hEvtThreadWakeup; - -class CClipboardListener : public WeakImplHelper < XClipboardListener > -{ -public: - ~CClipboardListener( ); - - // XClipboardListener - - virtual void SAL_CALL disposing( const EventObject& Source ) throw(RuntimeException); - virtual void SAL_CALL changedContents( const ClipboardEvent& event ) throw( RuntimeException ); -}; - -CClipboardListener::~CClipboardListener( ) -{ -} - -void SAL_CALL CClipboardListener::disposing( const EventObject& Source ) throw(RuntimeException) -{ - -} - -void SAL_CALL CClipboardListener::changedContents( const ClipboardEvent& event ) throw( RuntimeException ) -{ - //MessageBox( NULL, TEXT("Clipboard content changed"), TEXT("Info"), MB_OK | MB_ICONINFORMATION ); -} - -class CTransferable : public WeakImplHelper< XClipboardOwner, XTransferable > -{ -public: - CTransferable( ); - - // 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_FlavorList; - OUString m_Data; -}; - -// ctor - -CTransferable::CTransferable( ) : - m_FlavorList( 1 ), - m_Data( OUString("I bought a new bike!") ) -{ - DataFlavor df; - - //df.MimeType = L"text/plain;charset=utf-16"; - //df.DataType = cppu::UnoType<OUString>::get(); - - df.MimeType = L"text/plain;charset=Windows1252"; - df.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - - m_FlavorList[0] = df; -} - -// getTransferData - -Any SAL_CALL CTransferable::getTransferData( const DataFlavor& aFlavor ) - throw(UnsupportedFlavorException, IOException, RuntimeException) -{ - Any anyData; - - /* - if ( aFlavor.MimeType == m_FlavorList[0].MimeType ) - anyData = makeAny( m_Data ); - */ - if ( aFlavor.MimeType.equalsIgnoreCase( m_FlavorList[0].MimeType ) ) - { - OString text( - m_Data.getStr( ), - m_Data.getLength( ), - RTL_TEXTENCODING_ASCII_US ); - - Sequence< sal_Int8 > textStream( text.getLength( ) + 1 ); - - memcpy( textStream.getArray( ), text.getStr( ), textStream.getLength( ) ); - - anyData = makeAny( textStream ); - } - else - throw UnsupportedFlavorException( ); - - return anyData; -} - -// getTransferDataFlavors - -Sequence< DataFlavor > SAL_CALL CTransferable::getTransferDataFlavors( ) - throw(RuntimeException) -{ - return m_FlavorList; -} - -// isDataFlavorSupported - -sal_Bool SAL_CALL CTransferable::isDataFlavorSupported( const DataFlavor& aFlavor ) - throw(RuntimeException) -{ - sal_Int32 nLength = m_FlavorList.getLength( ); - - for ( sal_Int32 i = 0; i < nLength; ++i ) - if ( m_FlavorList[i].MimeType == aFlavor.MimeType ) - return sal_True; - - return sal_False; -} - -// lostOwnership - -void SAL_CALL CTransferable::lostOwnership( - const Reference< XClipboard >& xClipboard, const Reference< XTransferable >& xTrans ) - throw(RuntimeException) -{ - //MessageBox( NULL, TEXT("No longer clipboard owner"), TEXT("Info"), MB_OK | MB_ICONINFORMATION ); -} - -// main - -int SAL_CALL main( int nArgc, char* Argv[] ) -{ - // create a multi-threaded apartment; we can test only - // with a multithreaded apartment because for a single - // threaded apartment we need a message loop to deliver - // messages to our XTDataObject - //HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); - (void)CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ); - - char buff[6]; - - LCID lcid = MAKELCID( MAKELANGID( LANG_GERMAN, SUBLANG_GERMAN ), SORT_DEFAULT ); - - BOOL bValid = IsValidLocale( lcid, LCID_SUPPORTED ); - GetLocaleInfoA( lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof( buff ) ); - - // get the global service-manager - - Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( RDB_SYSPATH ) ); - - // Print a message if an error occurred. - if ( !g_xFactory.is( ) ) - { - OSL_FAIL("Can't create RegistryServiceFactory"); - return(-1); - } - - // try to get an Interface to a XFilePicker Service - - Reference< XTransferable > rXTransf( static_cast< XTransferable* >( new CTransferable ) ); - - Reference< XClipboard >xClipboard( g_xFactory->createInstance( WINCLIPBOARD_SERVICE_NAME ), UNO_QUERY ); - if ( !xClipboard.is( ) ) - { - OSL_FAIL( "Error creating Clipboard Service" ); - return(-1); - } - - Reference< XClipboardNotifier > xClipNotifier( xClipboard, UNO_QUERY ); - Reference< XClipboardListener > rXClipListener( static_cast< XClipboardListener* >( new CClipboardListener() ) ); - xClipNotifier->addClipboardListener( rXClipListener ); - - MessageBox( NULL, TEXT("Go"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION); - - // set new clipboard content - xClipboard->setContents( rXTransf, Reference< XClipboardOwner >( rXTransf, UNO_QUERY ) ); - - /* - MessageBox( NULL, TEXT("Clear content"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION); - - Reference< XClipboardOwner > rXClipOwner; - Reference< XTransferable > rXEmptyTransf; - xClipboard->setContents( rXEmptyTransf, rXClipOwner ); - */ - - MessageBox( NULL, TEXT("Stop"), TEXT("INFO"), MB_OK|MB_ICONINFORMATION); - - // flush the clipboard content - Reference< XFlushableClipboard > rXFlushableClip( xClipboard, UNO_QUERY ); - rXFlushableClip->flushClipboard( ); - rXFlushableClip.clear(); - - xClipNotifier->removeClipboardListener( rXClipListener ); - rXClipListener.clear(); - xClipNotifier.clear(); - - // shutdown the service manager - - // Cast factory to XComponent - Reference< XComponent > xComponent( g_xFactory, UNO_QUERY ); - - if ( !xComponent.is() ) - OSL_FAIL("Error shutting down"); - - // Dispose and clear factory - xComponent->dispose(); - xComponent.clear(); - - g_xFactory.clear(); - - CoUninitialize( ); - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/win/dtrans/testmarshal.cxx b/vcl/workben/win/dtrans/testmarshal.cxx deleted file mode 100644 index 8ef53c0f4d92..000000000000 --- a/vcl/workben/win/dtrans/testmarshal.cxx +++ /dev/null @@ -1,212 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <rtl/ustring.hxx> -#include <sal/types.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 "XTDo.hxx" - -// my defines - -#define WRITE_CB -#define EVT_MANUAL_RESET TRUE -#define EVT_INIT_NONSIGNALED FALSE -#define EVT_NONAME "" -#define WAIT_MSGLOOP -#define RAW_MARSHALING - -// namespaces - -using namespace ::std; - -// globales - -HANDLE g_hEvtThreadWakeup; - -#ifdef RAW_MARSHALING - HGLOBAL g_hGlob; -#else - IStream* g_pStm; -#endif - -// a thread in another apartment to test apartment transparency - -DWORD WINAPI ThreadProc(_In_ LPVOID pParam) -{ - // setup another apartment - HRESULT hr = OleInitialize( NULL ); - - WaitForSingleObject( g_hEvtThreadWakeup, INFINITE ); - - IDataObject* pIDo = NULL; - -#ifdef RAW_MARSHALING - - IStream* pStm = NULL; - hr = CreateStreamOnHGlobal( g_hGlob, FALSE, &pStm ); - if ( SUCCEEDED( hr ) ) - { - hr = CoUnmarshalInterface( - pStm, - __uuidof( IDataObject ), - (void**)&pIDo ); - - hr = pStm->Release( ); - } - -#else - - hr = CoGetInterfaceAndReleaseStream( - g_pStm, - __uuidof( IDataObject ), - (void**)&pIDo - ); - -#endif - - IEnumFORMATETC* pIEEtc; - hr = pIDo->EnumFormatEtc( DATADIR_GET, &pIEEtc ); - - hr = OleIsCurrentClipboard( pIDo ); - - hr = OleFlushClipboard( ); - - OleUninitialize( ); - - return 0; -} - -// main - -int SAL_CALL main( int nArgc, char* Argv[] ) -{ - HRESULT hr = OleInitialize( NULL ); - - g_hEvtThreadWakeup = CreateEvent( 0, - EVT_MANUAL_RESET, - EVT_INIT_NONSIGNALED, - EVT_NONAME ); - - DWORD uThreadId; - - // create a thread in another apartment - HANDLE hThread = CreateThread( NULL, 0, ThreadProc, NULL, 0, &uThreadId ); - - IDataObject* pIDo = new CXTDataObject( ); - - hr = OleSetClipboard( pIDo ); - hr = E_FAIL; - - hr = OleIsCurrentClipboard( pIDo ); - - //hr = OleGetClipboard( &pIDo ); - if ( SUCCEEDED( hr ) ) - { -#ifdef RAW_MARSHALING - - IStream* pStm = NULL; - - hr = CreateStreamOnHGlobal( 0, FALSE, &pStm ); - if ( SUCCEEDED( hr ) ) - { - hr = CoMarshalInterface( - pStm, - __uuidof( IDataObject ), - pIDo, - MSHCTX_INPROC, - 0, - MSHLFLAGS_NORMAL ); - if ( SUCCEEDED( hr ) ) - hr = GetHGlobalFromStream( pStm, &g_hGlob ); - - hr = pStm->Release( ); - } - -#else - - hr = CoMarshalInterThreadInterfaceInStream( - __uuidof( IDataObject ), - pIDo, - &g_pStm ); - -#endif - - if ( SUCCEEDED( hr ) ) - { - // wakeup the thread and waiting util it ends - SetEvent( g_hEvtThreadWakeup ); - -#ifdef WAIT_MSGLOOP - - BOOL bContinue = TRUE; - - while( bContinue ) - { - DWORD dwResult = WaitForMultipleObjects( - 1, - &hThread, - TRUE, - 0 ); - - if ( WAIT_OBJECT_0 == dwResult ) - { - bContinue = FALSE; - } - else - { - MSG msg; - while( PeekMessage( - &msg, - NULL, - 0, - 0, - PM_REMOVE ) ) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } // while - -#endif - - } // if - } // if - - OleFlushClipboard( ); - - OleUninitialize( ); - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */