1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dtrans.hxx" 30 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> 31 32 #include "globals.hxx" 33 34 //--> TRA 35 #include <com/sun/star/datatransfer/XTransferable.hpp> 36 37 // used as shortcut when drag-source and drop-target are the same 38 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > g_XTransferable; 39 40 //<-- TRA 41 42 using namespace com::sun::star::datatransfer::dnd::DNDConstants; 43 44 sal_Int8 dndOleKeysToAction( DWORD grfKeyState, sal_Int8 nSourceActions) 45 { 46 sal_Int8 ret= 0; 47 48 // no MK_ALT, MK_CONTROL, MK_SHIFT 49 if( !(grfKeyState & MK_CONTROL) && 50 !(grfKeyState & MK_ALT) && 51 !(grfKeyState & MK_RBUTTON) && 52 !(grfKeyState & MK_SHIFT)) 53 { 54 if( nSourceActions & ACTION_MOVE ) 55 { 56 ret= ACTION_DEFAULT | ACTION_MOVE; 57 } 58 59 else if( nSourceActions & ACTION_COPY ) 60 { 61 ret= ACTION_COPY; 62 } 63 64 else if( nSourceActions & ACTION_LINK ) 65 { 66 ret= ACTION_LINK; 67 } 68 69 else 70 ret = 0; 71 } 72 else if( grfKeyState & MK_SHIFT && 73 !(grfKeyState & MK_CONTROL)) 74 { 75 ret= ACTION_MOVE; 76 } 77 else if ( grfKeyState & MK_CONTROL && 78 !(grfKeyState & MK_SHIFT) ) 79 { 80 ret= ACTION_COPY; 81 } 82 else if ( grfKeyState & MK_CONTROL && 83 grfKeyState & MK_SHIFT) 84 { 85 ret= ACTION_LINK; 86 } 87 else if ( grfKeyState & MK_RBUTTON | 88 grfKeyState & MK_ALT) 89 { 90 ret= ACTION_COPY_OR_MOVE | ACTION_LINK; 91 } 92 return ret; 93 } 94 95 96 sal_Int8 dndOleDropEffectsToActions( DWORD dwEffect) 97 { 98 sal_Int8 ret= ACTION_NONE; 99 if( dwEffect & DROPEFFECT_COPY) 100 ret |= ACTION_COPY; 101 if( dwEffect & DROPEFFECT_MOVE) 102 ret |= ACTION_MOVE; 103 if( dwEffect & DROPEFFECT_LINK) 104 ret |= ACTION_LINK; 105 106 return ret; 107 } 108 109 DWORD dndActionsToDropEffects( sal_Int8 actions) 110 { 111 DWORD ret= DROPEFFECT_NONE; 112 if( actions & ACTION_MOVE) 113 ret |= DROPEFFECT_MOVE; 114 if( actions & ACTION_COPY) 115 ret |= DROPEFFECT_COPY; 116 if( actions & ACTION_LINK) 117 ret |= DROPEFFECT_LINK; 118 if( actions & ACTION_DEFAULT) 119 ret |= DROPEFFECT_COPY; 120 return ret; 121 } 122 123 DWORD dndActionsToSingleDropEffect( sal_Int8 actions) 124 { 125 DWORD effects= dndActionsToDropEffects( actions); 126 127 sal_Int8 countEffect= 0; 128 129 if( effects & DROPEFFECT_MOVE) 130 countEffect++; 131 if( effects & DROPEFFECT_COPY) 132 countEffect++; 133 if( effects & DROPEFFECT_LINK) 134 countEffect++; 135 136 // DROPEFFECT_MOVE is the default effect 137 DWORD retVal= countEffect > 1 ? DROPEFFECT_MOVE : effects; 138 return retVal; 139 } 140