merge the formfield patch from ooo-build
[ooovba.git] / vcl / aqua / source / dtrans / DragActionConversion.cxx
blob7a324f480d6f7704609af928c0ad278d72cd3a3f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DragActionConversion.cxx,v $
10 * $Revision: 1.3 $
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 #include "DragActionConversion.hxx"
32 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
35 using namespace com::sun::star::datatransfer::dnd;
38 /* Convert office drag actions as defined in
39 <type>com::sun::star::datatransfer::dnd::DNDConstants</type>
40 into system conform drag actions.
42 unsigned int OfficeToSystemDragActions(sal_Int8 dragActions)
44 unsigned int actions = NSDragOperationNone;
46 if (dragActions & DNDConstants::ACTION_COPY)
48 actions |= NSDragOperationCopy;
51 if (dragActions & DNDConstants::ACTION_MOVE)
53 actions |= NSDragOperationMove;
56 if (dragActions & DNDConstants::ACTION_LINK)
58 actions |= NSDragOperationLink;
61 return actions;
64 /* Convert system conform drag actions into office conform
65 drag actions as defined in
66 <type>com::sun::star::datatransfer::dnd::DNDConstants</type>.
68 sal_Int8 SystemToOfficeDragActions(unsigned int dragActions)
70 sal_Int8 actions = DNDConstants::ACTION_NONE;
72 if (dragActions & NSDragOperationCopy)
74 actions |= DNDConstants::ACTION_COPY;
77 if (dragActions & NSDragOperationMove)
79 actions |= DNDConstants::ACTION_MOVE;
82 if (dragActions & NSDragOperationLink)
84 actions |= DNDConstants::ACTION_LINK;
87 // We map NSDragOperationGeneric to ACTION_DEFAULT to
88 // signal that we have to decide for a drag action
89 if (dragActions & NSDragOperationGeneric)
91 actions |= DNDConstants::ACTION_DEFAULT;
94 return actions;