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 .
21 #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp>
22 #include <cppuhelper/compbase.hxx>
23 #include <cppuhelper/basemutex.hxx>
25 #include <win/dnd_source.hxx>
27 using namespace ::com::sun::star::datatransfer
;
28 using namespace ::com::sun::star::datatransfer::dnd
;
29 using namespace ::cppu
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::lang
;
33 // This class fires events to XDragSourceListener implementations.
34 // Of that interface only dragDropEnd and dropActionChanged are called.
35 // The functions dragEnter, dragExit and dragOver are not supported
37 // An instance of SourceContext only lives as long as the drag and drop
39 class SourceContext
: public cppu::BaseMutex
, public WeakComponentImplHelper
<XDragSourceContext
>
41 DragSource
* m_pDragSource
;
42 Reference
<XDragSource
> m_dragSource
;
43 // the action ( copy, move etc)
44 sal_Int8 m_currentAction
;
47 SourceContext(DragSource
* pSource
, const Reference
<XDragSourceListener
>& listener
);
48 ~SourceContext() override
;
49 SourceContext(const SourceContext
&) = delete;
50 SourceContext
& operator=(const SourceContext
&) = delete;
52 /// @throws RuntimeException
53 virtual void addDragSourceListener(const Reference
<XDragSourceListener
>& dsl
);
54 /// @throws RuntimeException
55 virtual void removeDragSourceListener(const Reference
<XDragSourceListener
>& dsl
);
56 virtual sal_Int32 SAL_CALL
getCurrentCursor() override
;
57 virtual void SAL_CALL
setCursor(sal_Int32 cursorId
) override
;
58 virtual void SAL_CALL
setImage(sal_Int32 imageId
) override
;
59 virtual void SAL_CALL
transferablesFlavorsChanged() override
;
61 // non - interface functions
62 void fire_dragDropEnd(bool success
, sal_Int8 byte
);
63 void fire_dropActionChanged(sal_Int8 dropAction
, sal_Int8 userAction
);
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */