24#include <osl/mutex.hxx>
32#include <com/sun/star/lang/IllegalArgumentException.hpp>
33#include <com/sun/star/lang/XMultiServiceFactory.hpp>
34#include <com/sun/star/lang/XServiceInfo.hpp>
35#include <com/sun/star/lang/XSingleServiceFactory.hpp>
36#include <com/sun/star/lang/XInitialization.hpp>
37#include <com/sun/star/datatransfer/XTransferable.hpp>
38#include <com/sun/star/datatransfer/clipboard/LokClipboard.hpp>
39#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
40#include <com/sun/star/datatransfer/clipboard/XSystemClipboard.hpp>
41#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
42#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
43#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
57class GenericClipboard :
59 datatransfer::clipboard::XSystemClipboard,
65 std::vector< Reference< css::datatransfer::clipboard::XClipboardListener > >
m_aListeners;
88 virtual void SAL_CALL setContents(
92 virtual OUString SAL_CALL getName()
override;
98 virtual sal_Int8 SAL_CALL getRenderingCapabilities()
override;
103 virtual void SAL_CALL addClipboardListener(
106 virtual void SAL_CALL removeClipboardListener(
118OUString GenericClipboard::getImplementationName()
120 return "com.sun.star.datatransfer.VCLGenericClipboard";
125 return getSupportedServiceNames_static();
128sal_Bool GenericClipboard::supportsService(
const OUString& ServiceName )
138void GenericClipboard::setContents(
142 std::unique_lock aGuard( m_aMutex );
149 datatransfer::clipboard::ClipboardEvent aEv;
154 if( xOldOwner.is() && xOldOwner != xClipboardOwner )
155 xOldOwner->lostOwnership(
this, xOldContents );
156 for (
auto const& listener : aListeners)
158 listener->changedContents( aEv );
162OUString GenericClipboard::getName()
167sal_Int8 GenericClipboard::getRenderingCapabilities()
174 std::unique_lock aGuard(m_aMutex);
181 std::unique_lock aGuard(m_aMutex);
188extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
190 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any>
const& args)
195 xClipboard->acquire();
196 return xClipboard.get();
205 datatransfer::dnd::XDragSource,
207 css::lang::XServiceInfo
210 css::uno::Reference<css::datatransfer::XTransferable>
m_xTrans;
212 GenericDragSource() {}
215 virtual sal_Bool SAL_CALL isDragImageSupported()
override;
216 virtual sal_Int32 SAL_CALL getDefaultCursor(
sal_Int8 dragAction )
override;
217 virtual void SAL_CALL startDrag(
218 const datatransfer::dnd::DragGestureEvent& trigger,
219 sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image,
225 virtual void SAL_CALL initialize(
const Sequence< Any >& arguments )
override;
228 {
return "com.sun.star.datatransfer.dnd.VclGenericDragSource"; }
234 {
return getSupportedServiceNames_static(); }
238 return {
"com.sun.star.datatransfer.dnd.GenericDragSource" };
244sal_Bool GenericDragSource::isDragImageSupported()
249sal_Int32 GenericDragSource::getDefaultCursor(
sal_Int8 )
254void GenericDragSource::startDrag(
const datatransfer::dnd::DragGestureEvent&,
265 datatransfer::dnd::DragSourceDropEvent aEv;
266 aEv.DropAction = datatransfer::dnd::DNDConstants::ACTION_COPY;
267 aEv.DropSuccess =
false;
268 listener->dragDropEnd( aEv );
278 return {
"com.sun.star.datatransfer.dnd.OleDragSource" };
280 return {
"com.sun.star.datatransfer.dnd.X11DragSource" };
282 return {
"com.sun.star.datatransfer.dnd.VclGenericDragSource" };
289 return "com.sun.star.comp.datatransfer.dnd.OleDragSource_V1";
291 return "com.sun.star.datatransfer.dnd.XdndSupport";
293 return "com.sun.star.datatransfer.dnd.VclGenericDragSource";
311 datatransfer::dnd::XDropTarget,
313 css::lang::XServiceInfo
317 GenericDropTarget() {}
320 virtual void SAL_CALL initialize(
const Sequence< Any >& args )
override;
327 virtual sal_Int8 SAL_CALL getDefaultActions()
override;
328 virtual void SAL_CALL setDefaultActions(
sal_Int8 actions )
override;
331 {
return "com.sun.star.datatransfer.dnd.VclGenericDropTarget"; }
337 {
return getSupportedServiceNames_static(); }
341 return {
"com.sun.star.datatransfer.dnd.GenericDropTarget" };
359sal_Bool GenericDropTarget::isActive()
364void GenericDropTarget::setActive(
sal_Bool )
368sal_Int8 GenericDropTarget::getDefaultActions()
373void GenericDropTarget::setDefaultActions(
sal_Int8)
380 return {
"com.sun.star.datatransfer.dnd.OleDropTarget" };
382 return {
"com.sun.star.datatransfer.dnd.X11DropTarget" };
384 return GenericDropTarget::getSupportedServiceNames_static();
392 "com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1"
394 "com.sun.star.datatransfer.dnd.XdndDropTarget"
396 "com.sun.star.datatransfer.dnd.VclGenericDropTarget"
415 if (arguments.hasElements()) {
416 throw css::lang::IllegalArgumentException(
417 "non-empty SalInstance::CreateClipboard arguments", {}, -1);
420 return getXWeak(
new vcl::GenericClipboard());
427 css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
428 css::datatransfer::clipboard::LokClipboard::create(
435 m_clipboard = getXWeak(
new vcl::GenericClipboard());
442 return css::uno::Reference<css::uno::XInterface>();
450 return getXWeak(
new vcl::GenericDragSource());
456 return css::uno::Reference<css::uno::XInterface>();
463 return getXWeak(
new vcl::GenericDropTarget());
static bool IsHeadlessModeEnabled()
Determines if headless mode is enabled.
virtual css::uno::Reference< css::uno::XInterface > CreateClipboard(const css::uno::Sequence< css::uno::Any > &i_rArguments)
static bool IsRunningUnitTest()
css::uno::Reference< css::uno::XInterface > CreateDropTarget(const SystemEnvData *=nullptr)
virtual css::uno::Reference< css::uno::XInterface > ImplCreateDropTarget(const SystemEnvData *)
virtual css::uno::Reference< css::uno::XInterface > ImplCreateDragSource(const SystemEnvData *)
css::uno::Reference< css::uno::XInterface > CreateDragSource(const SystemEnvData *=nullptr)
css::uno::Reference< css::uno::XInterface > m_clipboard
#define DBG_TESTSOLARMUTEX()
Reference< css::datatransfer::clipboard::XClipboardOwner > m_aOwner
css::uno::Reference< css::datatransfer::XTransferable > m_xTrans
Reference< css::datatransfer::XTransferable > m_aContents
std::vector< Reference< css::datatransfer::clipboard::XClipboardListener > > m_aListeners
void setActive(bool bActive)
Reference< XComponentContext > getProcessComponentContext()
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString DragSource_getImplementationName()
Reference< XInterface > DragSource_createInstance(const Reference< XMultiServiceFactory > &)
Sequence< OUString > DropTarget_getSupportedServiceNames()
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * vcl_SystemClipboard_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &args)
Sequence< OUString > DragSource_getSupportedServiceNames()
Reference< XInterface > DropTarget_createInstance(const Reference< XMultiServiceFactory > &)
OUString DropTarget_getImplementationName()
ImplSVData * ImplGetSVData()