1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: globals.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dtrans.hxx"
33 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
35 #include "globals.hxx"
38 #include <com/sun/star/datatransfer/XTransferable.hpp>
40 // used as shortcut when drag-source and drop-target are the same
41 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> g_XTransferable
;
45 using namespace com::sun::star::datatransfer::dnd::DNDConstants
;
47 sal_Int8
dndOleKeysToAction( DWORD grfKeyState
, sal_Int8 nSourceActions
)
51 // no MK_ALT, MK_CONTROL, MK_SHIFT
52 if( !(grfKeyState
& MK_CONTROL
) &&
53 !(grfKeyState
& MK_ALT
) &&
54 !(grfKeyState
& MK_RBUTTON
) &&
55 !(grfKeyState
& MK_SHIFT
))
57 if( nSourceActions
& ACTION_MOVE
)
59 ret
= ACTION_DEFAULT
| ACTION_MOVE
;
62 else if( nSourceActions
& ACTION_COPY
)
67 else if( nSourceActions
& ACTION_LINK
)
75 else if( grfKeyState
& MK_SHIFT
&&
76 !(grfKeyState
& MK_CONTROL
))
80 else if ( grfKeyState
& MK_CONTROL
&&
81 !(grfKeyState
& MK_SHIFT
) )
85 else if ( grfKeyState
& MK_CONTROL
&&
86 grfKeyState
& MK_SHIFT
)
90 else if ( grfKeyState
& MK_RBUTTON
|
93 ret
= ACTION_COPY_OR_MOVE
| ACTION_LINK
;
99 sal_Int8
dndOleDropEffectsToActions( DWORD dwEffect
)
101 sal_Int8 ret
= ACTION_NONE
;
102 if( dwEffect
& DROPEFFECT_COPY
)
104 if( dwEffect
& DROPEFFECT_MOVE
)
106 if( dwEffect
& DROPEFFECT_LINK
)
112 DWORD
dndActionsToDropEffects( sal_Int8 actions
)
114 DWORD ret
= DROPEFFECT_NONE
;
115 if( actions
& ACTION_MOVE
)
116 ret
|= DROPEFFECT_MOVE
;
117 if( actions
& ACTION_COPY
)
118 ret
|= DROPEFFECT_COPY
;
119 if( actions
& ACTION_LINK
)
120 ret
|= DROPEFFECT_LINK
;
121 if( actions
& ACTION_DEFAULT
)
122 ret
|= DROPEFFECT_COPY
;
126 DWORD
dndActionsToSingleDropEffect( sal_Int8 actions
)
128 DWORD effects
= dndActionsToDropEffects( actions
);
130 sal_Int8 countEffect
= 0;
132 if( effects
& DROPEFFECT_MOVE
)
134 if( effects
& DROPEFFECT_COPY
)
136 if( effects
& DROPEFFECT_LINK
)
139 // DROPEFFECT_MOVE is the default effect
140 DWORD retVal
= countEffect
> 1 ? DROPEFFECT_MOVE
: effects
;