LibreOffice Module dtrans (master)  1
source.hxx
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 #pragma once
21 
22 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
23 #include <com/sun/star/datatransfer/dnd/XDragSourceContext.hpp>
24 #include <com/sun/star/lang/XInitialization.hpp>
25 #include <osl/mutex.hxx>
26 #include <cppuhelper/compbase.hxx>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include "globals.hxx"
29 #include <oleidl.h>
30 
31 #include <systools/win32/comtools.hxx>
32 
33 namespace com::sun::star::uno { class XComponentContext; }
34 
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::uno;
37 using namespace cppu;
38 using namespace osl;
39 using namespace ::com::sun::star::datatransfer;
40 using namespace ::com::sun::star::datatransfer::dnd;
41 
42 class SourceContext;
43 // RIGHT MOUSE BUTTON drag and drop not supported currently.
44 // ALT modifier is considered to effect a user selection of effects
45 class DragSource:
46  public MutexDummy,
47  public WeakComponentImplHelper<XDragSource, XInitialization, XServiceInfo>,
48  public IDropSource
49 
50 {
53 
54  // The mouse button that set off the drag and drop operation
56 
57  // First starting a new drag and drop thread if
58  // the last one has finished
59  void StartDragImpl(
60  const DragGestureEvent& trigger,
61  sal_Int8 sourceActions,
62  sal_Int32 cursor,
63  sal_Int32 image,
64  const Reference<XTransferable >& trans,
65  const Reference<XDragSourceListener >& listener);
66 
67 public:
69 
70 public:
71  // only valid for one dnd operation
72  // the thread ID of the thread which created the window
74  // The context notifies the XDragSourceListener s
75  Reference<XDragSourceContext> m_currentContext;
76 
77  // the wrapper for the Transferable ( startDrag)
78  IDataObjectPtr m_spDataObject;
79 
81 
82 public:
83  explicit DragSource(const Reference<XComponentContext>& rxContext);
84  virtual ~DragSource() override;
85  DragSource(const DragSource&) = delete;
86  DragSource &operator= ( const DragSource&) = delete;
87 
88  // XInitialization
89  virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override;
90 
91  // XDragSource
92  virtual sal_Bool SAL_CALL isDragImageSupported( ) override;
93  virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) override;
94  virtual void SAL_CALL startDrag( const DragGestureEvent& trigger,
95  sal_Int8 sourceActions,
96  sal_Int32 cursor,
97  sal_Int32 image,
98  const Reference<XTransferable >& trans,
99  const Reference<XDragSourceListener >& listener ) override;
100 
101  // XServiceInfo
102  virtual OUString SAL_CALL getImplementationName( ) override;
103  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
104  virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
105 
106  virtual HRESULT STDMETHODCALLTYPE QueryInterface(
107  /* [in] */ REFIID riid,
108  /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) override;
109 
110  virtual ULONG STDMETHODCALLTYPE AddRef( ) override;
111 
112  virtual ULONG STDMETHODCALLTYPE Release( ) override;
113 
114  // IDropSource
115  virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(
116  /* [in] */ BOOL fEscapePressed,
117  /* [in] */ DWORD grfKeyState) override;
118 
119  virtual HRESULT STDMETHODCALLTYPE GiveFeedback(
120  /* [in] */ DWORD dwEffect) override;
121 
122 };
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DWORD m_threadIdWindow
Definition: source.hxx:73
signed char sal_Int8
IDataObjectPtr m_spDataObject
Definition: source.hxx:78
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
long m_RunningDndOperationCount
Definition: source.hxx:68
const wchar_t *typedef BOOL
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int8 m_sourceActions
Definition: source.hxx:80
Reference< XDragSourceContext > m_currentContext
Definition: source.hxx:75
unsigned char sal_Bool
Reference< XComponentContext > m_xContext
Definition: source.hxx:51
HWND m_hAppWindow
Definition: source.hxx:52
short m_MouseButton
Definition: source.hxx:55