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