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 : #include "unx/salinst.h"
21 :
22 : #include <X11_clipboard.hxx>
23 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
25 : #include <com/sun/star/registry/XRegistryKey.hpp>
26 : #include <uno/dispatcher.h>
27 : #include <uno/mapping.hxx>
28 : #include <cppuhelper/factory.hxx>
29 : #include <cppuhelper/compbase1.hxx>
30 :
31 : using namespace cppu;
32 : using namespace com::sun::star::uno;
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 0 : Sequence< OUString > SAL_CALL x11::X11Clipboard_getSupportedServiceNames()
39 : {
40 0 : Sequence< OUString > aRet(1);
41 0 : aRet[0] = "com.sun.star.datatransfer.clipboard.SystemClipboard";
42 0 : return aRet;
43 : }
44 :
45 0 : Sequence< OUString > SAL_CALL x11::Xdnd_getSupportedServiceNames()
46 : {
47 0 : Sequence< OUString > aRet(1);
48 0 : aRet[0] = "com.sun.star.datatransfer.dnd.X11DragSource";
49 0 : return aRet;
50 : }
51 :
52 0 : Sequence< OUString > SAL_CALL x11::Xdnd_dropTarget_getSupportedServiceNames()
53 : {
54 0 : Sequence< OUString > aRet(1);
55 0 : aRet[0] = "com.sun.star.datatransfer.dnd.X11DropTarget";
56 0 : return aRet;
57 : }
58 :
59 0 : css::uno::Reference< XInterface > X11SalInstance::CreateClipboard( const Sequence< Any >& arguments )
60 : {
61 0 : SelectionManager& rManager = SelectionManager::get();
62 0 : css::uno::Sequence<css::uno::Any> mgrArgs(1);
63 0 : mgrArgs[0] <<= Application::GetDisplayConnection();
64 0 : rManager.initialize(mgrArgs);
65 :
66 0 : OUString sel;
67 0 : if (arguments.getLength() == 0) {
68 0 : sel = "CLIPBOARD";
69 0 : } else if (arguments.getLength() != 1 || !(arguments[0] >>= sel)) {
70 : throw css::lang::IllegalArgumentException(
71 : "bad X11SalInstance::CreateClipboard arguments",
72 0 : css::uno::Reference<css::uno::XInterface>(), -1);
73 : }
74 0 : Atom nSelection = rManager.getAtom(sel);
75 :
76 0 : ::boost::unordered_map< Atom, css::uno::Reference< XClipboard > >::iterator it = m_aInstances.find( nSelection );
77 0 : if( it != m_aInstances.end() )
78 0 : return it->second;
79 :
80 0 : X11Clipboard* pClipboard = new X11Clipboard( rManager, nSelection );
81 0 : m_aInstances[ nSelection ] = pClipboard;
82 :
83 0 : return static_cast<OWeakObject*>(pClipboard);
84 : }
85 :
86 0 : css::uno::Reference< XInterface > X11SalInstance::CreateDragSource()
87 : {
88 0 : return css::uno::Reference < XInterface >( ( OWeakObject * ) new SelectionManagerHolder() );
89 : }
90 :
91 0 : css::uno::Reference< XInterface > X11SalInstance::CreateDropTarget()
92 : {
93 0 : return css::uno::Reference < XInterface >( ( OWeakObject * ) new DropTarget() );
94 0 : }
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|