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 <sal/config.h>
22 #include <o3tl/test_info.hxx>
23 #include <unx/salinst.h>
24 #include <dndhelper.hxx>
25 #include <vcl/sysdata.hxx>
27 #include "X11_clipboard.hxx"
28 #include <com/sun/star/lang/IllegalArgumentException.hpp>
31 using namespace com::sun::star::uno
;
32 using namespace com::sun::star::lang
;
33 using namespace com::sun::star::datatransfer::clipboard
;
36 Sequence
< OUString
> x11::X11Clipboard_getSupportedServiceNames()
38 return { u
"com.sun.star.datatransfer.clipboard.SystemClipboard"_ustr
};
41 Sequence
< OUString
> x11::Xdnd_getSupportedServiceNames()
43 return { u
"com.sun.star.datatransfer.dnd.X11DragSource"_ustr
};
46 Sequence
< OUString
> x11::Xdnd_dropTarget_getSupportedServiceNames()
48 return { u
"com.sun.star.datatransfer.dnd.X11DropTarget"_ustr
};
51 css::uno::Reference
< XInterface
> X11SalInstance::CreateClipboard( const Sequence
< Any
>& arguments
)
53 if ( o3tl::IsRunningUnitTest() || o3tl::IsRunningUITest() )
54 return SalInstance::CreateClipboard( arguments
);
56 SelectionManager
& rManager
= SelectionManager::get();
57 css::uno::Sequence
<css::uno::Any
> mgrArgs
{ css::uno::Any(Application::GetDisplayConnection()) };
58 rManager
.initialize(mgrArgs
);
61 if (!arguments
.hasElements()) {
63 } else if (arguments
.getLength() != 1 || !(arguments
[0] >>= sel
)) {
64 throw css::lang::IllegalArgumentException(
65 u
"bad X11SalInstance::CreateClipboard arguments"_ustr
,
66 css::uno::Reference
<css::uno::XInterface
>(), -1);
68 Atom nSelection
= rManager
.getAtom(sel
);
70 std::unordered_map
< Atom
, css::uno::Reference
< XClipboard
> >::iterator it
= m_aInstances
.find( nSelection
);
71 if( it
!= m_aInstances
.end() )
74 css::uno::Reference
<css::datatransfer::clipboard::XClipboard
> pClipboard
= X11Clipboard::create( rManager
, nSelection
);
75 m_aInstances
[ nSelection
] = pClipboard
;
80 css::uno::Reference
<XInterface
> X11SalInstance::ImplCreateDragSource(const SystemEnvData
* pSysEnv
)
82 return vcl::X11DnDHelper(new SelectionManagerHolder(), pSysEnv
->aShellWindow
);
85 css::uno::Reference
<XInterface
> X11SalInstance::ImplCreateDropTarget(const SystemEnvData
* pSysEnv
)
87 return vcl::X11DnDHelper(new DropTarget(), pSysEnv
->aShellWindow
);
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */