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 <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
22 #include "sourcecontext.hxx"
24 using namespace com::sun::star::datatransfer::dnd
;
25 using namespace com::sun::star::datatransfer::dnd::DNDConstants
;
27 SourceContext::SourceContext( DragSource
* pSource
,
28 const Reference
<XDragSourceListener
>& listener
):
29 WeakComponentImplHelper1
<XDragSourceContext
>(m_mutex
),
30 m_pDragSource( pSource
),
31 m_dragSource( static_cast<XDragSource
*>( m_pDragSource
) )
33 #if OSL_DEBUG_LEVEL > 1
36 rBHelper
.addListener( cppu::UnoType
<decltype(listener
)>::get(), listener
);
39 SourceContext::~SourceContext()
43 void SAL_CALL
SourceContext::addDragSourceListener(
44 const Reference
<XDragSourceListener
>& )
45 throw( RuntimeException
)
49 void SAL_CALL
SourceContext::removeDragSourceListener(
50 const Reference
<XDragSourceListener
>& )
51 throw( RuntimeException
)
55 sal_Int32 SAL_CALL
SourceContext::getCurrentCursor( )
56 throw( RuntimeException
)
61 void SAL_CALL
SourceContext::setCursor( sal_Int32
/*cursorId*/ )
62 throw( RuntimeException
)
66 void SAL_CALL
SourceContext::setImage( sal_Int32
/*imageId*/ )
67 throw( RuntimeException
)
71 void SAL_CALL
SourceContext::transferablesFlavorsChanged( )
72 throw( RuntimeException
)
76 // non -interface functions
77 // Fires XDragSourceListener::dragDropEnd events.
78 void SourceContext::fire_dragDropEnd( sal_Bool success
, sal_Int8 effect
)
81 DragSourceDropEvent e
;
83 if( success
== sal_True
)
86 e
.DropSuccess
= sal_True
;
90 e
.DropAction
= ACTION_NONE
;
91 e
.DropSuccess
= sal_False
;
93 e
.DragSource
= m_dragSource
;
94 e
.DragSourceContext
= static_cast<XDragSourceContext
*>( this);
95 e
.Source
= Reference
<XInterface
>( static_cast<XDragSourceContext
*>( this), UNO_QUERY
);
97 OInterfaceContainerHelper
* pContainer
= rBHelper
.getContainer(
98 cppu::UnoType
<XDragSourceListener
>::get());
102 OInterfaceIteratorHelper
iter( *pContainer
);
103 while( iter
.hasMoreElements())
105 Reference
<XDragSourceListener
> listener(
106 static_cast<XDragSourceListener
*>( iter
.next()));
107 listener
->dragDropEnd( e
);
112 void SourceContext::fire_dropActionChanged( sal_Int8 dropAction
, sal_Int8 userAction
)
114 if( m_currentAction
!= dropAction
)
116 m_currentAction
= dropAction
;
117 DragSourceDragEvent e
;
118 e
.DropAction
= dropAction
;
119 e
.UserAction
= userAction
;
120 e
.DragSource
= m_dragSource
;
121 e
.DragSourceContext
= static_cast<XDragSourceContext
*>( this);
122 e
.Source
= Reference
<XInterface
>( static_cast<XDragSourceContext
*>( this), UNO_QUERY
);
124 OInterfaceContainerHelper
* pContainer
= rBHelper
.getContainer(
125 cppu::UnoType
<XDragSourceListener
>::get());
129 OInterfaceIteratorHelper
iter( *pContainer
);
130 while( iter
.hasMoreElements())
132 Reference
<XDragSourceListener
> listener(
133 static_cast<XDragSourceListener
*>( iter
.next()));
134 listener
->dropActionChanged( e
);
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */