1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <unx/salinst.h>
22 #include "X11_clipboard.hxx"
23 #include <com/sun/star/lang/IllegalArgumentException.hpp>
26 using namespace com::sun::star::uno
;
27 using namespace com::sun::star::lang
;
28 using namespace com::sun::star::datatransfer::clipboard
;
29 using namespace com::sun::star::awt
;
32 Sequence
< OUString
> x11::X11Clipboard_getSupportedServiceNames()
34 return { "com.sun.star.datatransfer.clipboard.SystemClipboard" };
37 Sequence
< OUString
> x11::Xdnd_getSupportedServiceNames()
39 return { "com.sun.star.datatransfer.dnd.X11DragSource" };
42 Sequence
< OUString
> x11::Xdnd_dropTarget_getSupportedServiceNames()
44 return { "com.sun.star.datatransfer.dnd.X11DropTarget" };
47 css::uno::Reference
< XInterface
> X11SalInstance::CreateClipboard( const Sequence
< Any
>& arguments
)
49 SelectionManager
& rManager
= SelectionManager::get();
50 css::uno::Sequence
<css::uno::Any
> mgrArgs(1);
51 mgrArgs
[0] <<= Application::GetDisplayConnection();
52 rManager
.initialize(mgrArgs
);
55 if (!arguments
.hasElements()) {
57 } else if (arguments
.getLength() != 1 || !(arguments
[0] >>= sel
)) {
58 throw css::lang::IllegalArgumentException(
59 "bad X11SalInstance::CreateClipboard arguments",
60 css::uno::Reference
<css::uno::XInterface
>(), -1);
62 Atom nSelection
= rManager
.getAtom(sel
);
64 std::unordered_map
< Atom
, css::uno::Reference
< XClipboard
> >::iterator it
= m_aInstances
.find( nSelection
);
65 if( it
!= m_aInstances
.end() )
68 css::uno::Reference
<css::datatransfer::clipboard::XClipboard
> pClipboard
= X11Clipboard::create( rManager
, nSelection
);
69 m_aInstances
[ nSelection
] = pClipboard
;
74 css::uno::Reference
< XInterface
> X11SalInstance::CreateDragSource()
76 return css::uno::Reference
< XInterface
>( static_cast<OWeakObject
*>(new SelectionManagerHolder()) );
79 css::uno::Reference
< XInterface
> X11SalInstance::CreateDropTarget()
81 return css::uno::Reference
< XInterface
>( static_cast<OWeakObject
*>(new DropTarget()) );
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */