Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "unx/salinst.h"
22 :
23 : #include <X11_clipboard.hxx>
24 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
26 : #include <com/sun/star/registry/XRegistryKey.hpp>
27 : #include <uno/dispatcher.h> // declaration of generic uno interface
28 : #include <uno/mapping.hxx> // mapping stuff
29 : #include <cppuhelper/factory.hxx>
30 : #include <cppuhelper/compbase1.hxx>
31 :
32 : using namespace cppu;
33 : using namespace com::sun::star::lang;
34 : using namespace com::sun::star::datatransfer::clipboard;
35 : using namespace com::sun::star::awt;
36 : using namespace x11;
37 :
38 : using ::rtl::OUString;
39 :
40 0 : Sequence< OUString > SAL_CALL x11::X11Clipboard_getSupportedServiceNames()
41 : {
42 0 : Sequence< OUString > aRet(1);
43 0 : aRet[0] = OUString("com.sun.star.datatransfer.clipboard.SystemClipboard");
44 0 : return aRet;
45 : }
46 :
47 0 : Sequence< OUString > SAL_CALL x11::Xdnd_getSupportedServiceNames()
48 : {
49 0 : Sequence< OUString > aRet(1);
50 0 : aRet[0] = OUString("com.sun.star.datatransfer.dnd.X11DragSource");
51 0 : return aRet;
52 : }
53 :
54 0 : Sequence< OUString > SAL_CALL x11::Xdnd_dropTarget_getSupportedServiceNames()
55 : {
56 0 : Sequence< OUString > aRet(1);
57 0 : aRet[0] = OUString("com.sun.star.datatransfer.dnd.X11DropTarget");
58 0 : return aRet;
59 : }
60 :
61 : // ------------------------------------------------------------------------
62 :
63 0 : css::uno::Reference< XInterface > X11SalInstance::CreateClipboard( const Sequence< Any >& arguments )
64 : {
65 0 : static boost::unordered_map< OUString, ::boost::unordered_map< Atom, Reference< XClipboard > >, ::rtl::OUStringHash > m_aInstances;
66 :
67 0 : OUString aDisplayName;
68 : Atom nSelection;
69 :
70 : // extract display name from connection argument. An exception is thrown
71 : // by SelectionManager.initialize() if no display connection is given.
72 0 : if( arguments.getLength() > 0 )
73 : {
74 0 : css::uno::Reference< XDisplayConnection > xConn;
75 0 : arguments.getConstArray()[0] >>= xConn;
76 :
77 0 : if( xConn.is() )
78 : {
79 0 : Any aIdentifier = xConn->getIdentifier();
80 0 : aIdentifier >>= aDisplayName;
81 0 : }
82 : }
83 :
84 0 : SelectionManager& rManager = SelectionManager::get( aDisplayName );
85 0 : rManager.initialize( arguments );
86 :
87 : // check if any other selection than clipboard selection is specified
88 0 : if( arguments.getLength() > 1 )
89 : {
90 0 : OUString aSelectionName;
91 :
92 0 : arguments.getConstArray()[1] >>= aSelectionName;
93 0 : nSelection = rManager.getAtom( aSelectionName );
94 : }
95 : else
96 : {
97 : // default atom is clipboard selection
98 0 : nSelection = rManager.getAtom( OUString("CLIPBOARD") );
99 : }
100 :
101 0 : ::boost::unordered_map< Atom, css::uno::Reference< XClipboard > >& rMap( m_aInstances[ aDisplayName ] );
102 0 : ::boost::unordered_map< Atom, css::uno::Reference< XClipboard > >::iterator it = rMap.find( nSelection );
103 0 : if( it != rMap.end() )
104 0 : return it->second;
105 :
106 0 : X11Clipboard* pClipboard = new X11Clipboard( rManager, nSelection );
107 0 : rMap[ nSelection ] = pClipboard;
108 :
109 0 : return static_cast<OWeakObject*>(pClipboard);
110 : }
111 :
112 : // ------------------------------------------------------------------------
113 :
114 0 : css::uno::Reference< XInterface > X11SalInstance::CreateDragSource()
115 : {
116 0 : return css::uno::Reference < XInterface >( ( OWeakObject * ) new SelectionManagerHolder() );
117 : }
118 :
119 : // ------------------------------------------------------------------------
120 :
121 0 : css::uno::Reference< XInterface > X11SalInstance::CreateDropTarget()
122 : {
123 0 : return css::uno::Reference < XInterface >( ( OWeakObject * ) new DropTarget() );
124 : }
125 :
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|