1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_vcl.hxx" 30 31 #include "unx/salinst.h" 32 33 #include <X11_clipboard.hxx> 34 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 36 #include <com/sun/star/registry/XRegistryKey.hpp> 37 #include <uno/dispatcher.h> // declaration of generic uno interface 38 #include <uno/mapping.hxx> // mapping stuff 39 #include <cppuhelper/factory.hxx> 40 #include <cppuhelper/compbase1.hxx> 41 42 namespace { 43 44 namespace css = com::sun::star; 45 46 } 47 48 using namespace rtl; 49 using namespace cppu; 50 using namespace com::sun::star::lang; 51 using namespace com::sun::star::datatransfer::clipboard; 52 using namespace com::sun::star::awt; 53 using namespace x11; 54 55 Sequence< OUString > SAL_CALL x11::X11Clipboard_getSupportedServiceNames() 56 { 57 Sequence< OUString > aRet(1); 58 aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard"); 59 return aRet; 60 } 61 62 Sequence< OUString > SAL_CALL x11::Xdnd_getSupportedServiceNames() 63 { 64 Sequence< OUString > aRet(1); 65 aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DragSource"); 66 return aRet; 67 } 68 69 Sequence< OUString > SAL_CALL x11::Xdnd_dropTarget_getSupportedServiceNames() 70 { 71 Sequence< OUString > aRet(1); 72 aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.dnd.X11DropTarget"); 73 return aRet; 74 } 75 76 // ------------------------------------------------------------------------ 77 78 css::uno::Reference< XInterface > X11SalInstance::CreateClipboard( const Sequence< Any >& arguments ) 79 { 80 static std::hash_map< OUString, ::std::hash_map< Atom, css::uno::Reference< XClipboard > >, ::rtl::OUStringHash > m_aInstances; 81 82 OUString aDisplayName; 83 Atom nSelection; 84 85 // extract display name from connection argument. An exception is thrown 86 // by SelectionManager.initialize() if no display connection is given. 87 if( arguments.getLength() > 0 ) 88 { 89 css::uno::Reference< XDisplayConnection > xConn; 90 arguments.getConstArray()[0] >>= xConn; 91 92 if( xConn.is() ) 93 { 94 Any aIdentifier = xConn->getIdentifier(); 95 aIdentifier >>= aDisplayName; 96 } 97 } 98 99 SelectionManager& rManager = SelectionManager::get( aDisplayName ); 100 rManager.initialize( arguments ); 101 102 // check if any other selection than clipboard selection is specified 103 if( arguments.getLength() > 1 ) 104 { 105 OUString aSelectionName; 106 107 arguments.getConstArray()[1] >>= aSelectionName; 108 nSelection = rManager.getAtom( aSelectionName ); 109 } 110 else 111 { 112 // default atom is clipboard selection 113 nSelection = rManager.getAtom( OUString::createFromAscii( "CLIPBOARD" ) ); 114 } 115 116 ::std::hash_map< Atom, css::uno::Reference< XClipboard > >& rMap( m_aInstances[ aDisplayName ] ); 117 ::std::hash_map< Atom, css::uno::Reference< XClipboard > >::iterator it = rMap.find( nSelection ); 118 if( it != rMap.end() ) 119 return it->second; 120 121 X11Clipboard* pClipboard = new X11Clipboard( rManager, nSelection ); 122 rMap[ nSelection ] = pClipboard; 123 124 return static_cast<OWeakObject*>(pClipboard); 125 } 126 127 // ------------------------------------------------------------------------ 128 129 css::uno::Reference< XInterface > X11SalInstance::CreateDragSource() 130 { 131 return css::uno::Reference < XInterface >( ( OWeakObject * ) new SelectionManagerHolder() ); 132 } 133 134 // ------------------------------------------------------------------------ 135 136 css::uno::Reference< XInterface > X11SalInstance::CreateDropTarget() 137 { 138 return css::uno::Reference < XInterface >( ( OWeakObject * ) new DropTarget() ); 139 } 140 141 142