bump product version to 4.2.0.1
[LibreOffice.git] / vcl / aqua / source / dtrans / DragActionConversion.cxx
blobd4bb9e5c3c864c979821ed0d52f4479ce327f76c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "DragActionConversion.hxx"
21 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
24 using namespace com::sun::star::datatransfer::dnd;
27 /* Convert office drag actions as defined in
28 <type>com::sun::star::datatransfer::dnd::DNDConstants</type>
29 into system conform drag actions.
31 unsigned int OfficeToSystemDragActions(sal_Int8 dragActions)
33 unsigned int actions = NSDragOperationNone;
35 if (dragActions & DNDConstants::ACTION_COPY)
37 actions |= NSDragOperationCopy;
40 if (dragActions & DNDConstants::ACTION_MOVE)
42 actions |= NSDragOperationMove;
45 if (dragActions & DNDConstants::ACTION_LINK)
47 actions |= NSDragOperationLink;
50 return actions;
53 /* Convert system conform drag actions into office conform
54 drag actions as defined in
55 <type>com::sun::star::datatransfer::dnd::DNDConstants</type>.
57 sal_Int8 SystemToOfficeDragActions(unsigned int dragActions)
59 sal_Int8 actions = DNDConstants::ACTION_NONE;
61 if (dragActions & NSDragOperationCopy)
63 actions |= DNDConstants::ACTION_COPY;
66 if (dragActions & NSDragOperationMove)
68 actions |= DNDConstants::ACTION_MOVE;
71 if (dragActions & NSDragOperationLink)
73 actions |= DNDConstants::ACTION_LINK;
76 // We map NSDragOperationGeneric to ACTION_DEFAULT to
77 // signal that we have to decide for a drag action
78 if (dragActions & NSDragOperationGeneric)
80 actions |= DNDConstants::ACTION_DEFAULT;
83 return actions;
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */