LibreOffice Module dtrans (master)  1
sourcecontext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
21 
22 #include "sourcecontext.hxx"
23 
24 using namespace com::sun::star::datatransfer::dnd;
26 
28  const Reference<XDragSourceListener>& listener):
29  WeakComponentImplHelper<XDragSourceContext>(m_mutex),
30  m_pDragSource( pSource),
31  m_dragSource( static_cast<XDragSource*>( m_pDragSource) )
32 {
33 #if OSL_DEBUG_LEVEL > 1
34  if( listener.is())
35 #endif
36  rBHelper.addListener( cppu::UnoType<decltype(listener)>::get(), listener );
37 }
38 
40 {
41 }
42 
44  const Reference<XDragSourceListener >& )
45 {
46 }
47 
49  const Reference<XDragSourceListener >& )
50 {
51 }
52 
53 sal_Int32 SAL_CALL SourceContext::getCurrentCursor( )
54 {
55  return 0;
56 }
57 
58 void SAL_CALL SourceContext::setCursor( sal_Int32 /*cursorId*/ )
59 {
60 }
61 
62 void SAL_CALL SourceContext::setImage( sal_Int32 /*imageId*/ )
63 {
64 }
65 
67 {
68 }
69 
70 // non -interface functions
71 // Fires XDragSourceListener::dragDropEnd events.
72 void SourceContext::fire_dragDropEnd( bool success, sal_Int8 effect)
73 {
74 
75  DragSourceDropEvent e;
76 
77  if( success )
78  {
79  e.DropAction= effect;
80  e.DropSuccess= true;
81  }
82  else
83  {
84  e.DropAction= ACTION_NONE;
85  e.DropSuccess= false;
86  }
87  e.DragSource= m_dragSource;
88  e.DragSourceContext= static_cast<XDragSourceContext*>( this);
89  e.Source.set( static_cast<XDragSourceContext*>( this), UNO_QUERY);
90 
91  OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
93 
94  if( pContainer)
95  {
96  OInterfaceIteratorHelper iter( *pContainer);
97  while( iter.hasMoreElements())
98  {
99  Reference<XDragSourceListener> listener(
100  static_cast<XDragSourceListener*>( iter.next()));
101  listener->dragDropEnd( e);
102  }
103  }
104 }
105 
107 {
108  if( m_currentAction != dropAction)
109  {
110  m_currentAction= dropAction;
111  DragSourceDragEvent e;
112  e.DropAction= dropAction;
113  e.UserAction= userAction;
114  e.DragSource= m_dragSource;
115  e.DragSourceContext= static_cast<XDragSourceContext*>( this);
116  e.Source.set( static_cast<XDragSourceContext*>( this), UNO_QUERY);
117 
118  OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
120 
121  if( pContainer)
122  {
123  OInterfaceIteratorHelper iter( *pContainer);
124  while( iter.hasMoreElements())
125  {
126  Reference<XDragSourceListener> listener(
127  static_cast<XDragSourceListener*>( iter.next()));
128  listener->dropActionChanged( e);
129  }
130  }
131  }
132 }
133 
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL setImage(sal_Int32 imageId) override
signed char sal_Int8
void fire_dragDropEnd(bool success, sal_Int8 byte)
css::uno::XInterface *SAL_CALL next()
virtual void addDragSourceListener(const Reference< XDragSourceListener > &dsl)
SourceContext(DragSource *pSource, const Reference< XDragSourceListener > &listener)
Reference< XDragSource > m_dragSource
virtual sal_Int32 SAL_CALL getCurrentCursor() override
virtual void SAL_CALL transferablesFlavorsChanged() override
~SourceContext() override
virtual void removeDragSourceListener(const Reference< XDragSourceListener > &dsl)
void fire_dropActionChanged(sal_Int8 dropAction, sal_Int8 userAction)
virtual void SAL_CALL setCursor(sal_Int32 cursorId) override
sal_Int8 m_currentAction
bool SAL_CALL hasMoreElements() const