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 "globals.hxx"
25 #include <com/sun/star/datatransfer/XTransferable.hpp>
27 // used as shortcut when drag-source and drop-target are the same
28 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> g_XTransferable
;
32 using namespace com::sun::star::datatransfer::dnd::DNDConstants
;
34 sal_Int8
dndOleKeysToAction( DWORD grfKeyState
, sal_Int8 nSourceActions
)
38 // no MK_ALT, MK_CONTROL, MK_SHIFT
39 if( !(grfKeyState
& MK_CONTROL
) &&
40 !(grfKeyState
& MK_ALT
) &&
41 !(grfKeyState
& MK_RBUTTON
) &&
42 !(grfKeyState
& MK_SHIFT
))
44 if( nSourceActions
& ACTION_MOVE
)
46 ret
= ACTION_DEFAULT
| ACTION_MOVE
;
49 else if( nSourceActions
& ACTION_COPY
)
54 else if( nSourceActions
& ACTION_LINK
)
62 else if( grfKeyState
& MK_SHIFT
&&
63 !(grfKeyState
& MK_CONTROL
))
67 else if ( grfKeyState
& MK_CONTROL
&&
68 !(grfKeyState
& MK_SHIFT
) )
72 else if ( grfKeyState
& MK_CONTROL
&&
73 grfKeyState
& MK_SHIFT
)
77 else if ( grfKeyState
& MK_RBUTTON
||
80 ret
= ACTION_COPY_OR_MOVE
| ACTION_LINK
;
85 sal_Int8
dndOleDropEffectsToActions( DWORD dwEffect
)
87 sal_Int8 ret
= ACTION_NONE
;
88 if( dwEffect
& DROPEFFECT_COPY
)
90 if( dwEffect
& DROPEFFECT_MOVE
)
92 if( dwEffect
& DROPEFFECT_LINK
)
98 DWORD
dndActionsToDropEffects( sal_Int8 actions
)
100 DWORD ret
= DROPEFFECT_NONE
;
101 if( actions
& ACTION_MOVE
)
102 ret
|= DROPEFFECT_MOVE
;
103 if( actions
& ACTION_COPY
)
104 ret
|= DROPEFFECT_COPY
;
105 if( actions
& ACTION_LINK
)
106 ret
|= DROPEFFECT_LINK
;
107 if( actions
& ACTION_DEFAULT
)
108 ret
|= DROPEFFECT_COPY
;
112 DWORD
dndActionsToSingleDropEffect( sal_Int8 actions
)
114 DWORD effects
= dndActionsToDropEffects( actions
);
116 sal_Int8 countEffect
= 0;
118 if( effects
& DROPEFFECT_MOVE
)
120 if( effects
& DROPEFFECT_COPY
)
122 if( effects
& DROPEFFECT_LINK
)
125 // DROPEFFECT_MOVE is the default effect
126 DWORD retVal
= countEffect
> 1 ? DROPEFFECT_MOVE
: effects
;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */