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 #ifndef INCLUDED_SOT_EXCHANGE_HXX
21 #define INCLUDED_SOT_EXCHANGE_HXX
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <com/sun/star/datatransfer/DataFlavor.hpp>
27 #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
28 #include <sot/sotdllapi.h>
29 #include <sot/formats.hxx>
30 #include <tools/solar.h>
31 #include <o3tl/typed_flags_set.hxx>
35 namespace com
{ namespace sun
{ namespace star
{ namespace datatransfer
{
40 struct DataFlavorEx
: public css::datatransfer::DataFlavor
42 SotClipboardFormatId mnSotId
;
45 typedef ::std::vector
<DataFlavorEx
> DataFlavorExVector
;
48 SOT_DLLPUBLIC
bool IsFormatSupported( const DataFlavorExVector
& rDataFlavorExVector
,
49 SotClipboardFormatId nId
);
52 #define EXCHG_INOUT_ACTION_NONE (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_NONE))
53 #define EXCHG_IN_ACTION_DEFAULT EXCHG_INOUT_ACTION_NONE
54 #define EXCHG_IN_ACTION_MOVE (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_MOVE))
55 #define EXCHG_IN_ACTION_COPY (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_COPY))
56 #define EXCHG_IN_ACTION_LINK (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_LINK))
57 #define EXCHG_OUT_ACTION_INSERT_FILE (sal_uInt8(20))
58 #define EXCHG_OUT_ACTION_INSERT_IMAGEMAP (sal_uInt8(22))
59 #define EXCHG_OUT_ACTION_INSERT_OLE (sal_uInt8(23))
60 #define EXCHG_OUT_ACTION_INSERT_INTERACTIVE (sal_uInt8(24))
61 #define EXCHG_OUT_ACTION_REPLACE_IMAGEMAP (sal_uInt8(29))
62 #define EXCHG_OUT_ACTION_GET_ATTRIBUTES (sal_uInt8(30))
63 #define EXCHG_OUT_ACTION_INSERT_PRIVATE (sal_uInt8(35))
64 #define EXCHG_OUT_ACTION_INSERT_HTML (sal_uInt8(36))
65 #define EXCHG_OUT_ACTION_MOVE_PRIVATE (sal_uInt8(37))
66 #define EXCHG_OUT_ACTION_INSERT_STRING (sal_uInt8(38))
67 #define EXCHG_OUT_ACTION_INSERT_DRAWOBJ (sal_uInt8(39))
68 #define EXCHG_OUT_ACTION_INSERT_SVXB (sal_uInt8(40))
69 #define EXCHG_OUT_ACTION_INSERT_GDIMETAFILE (sal_uInt8(41))
70 #define EXCHG_OUT_ACTION_INSERT_BITMAP (sal_uInt8(42))
71 #define EXCHG_OUT_ACTION_INSERT_DDE (sal_uInt8(43))
72 #define EXCHG_OUT_ACTION_INSERT_HYPERLINK (sal_uInt8(44))
73 #define EXCHG_OUT_ACTION_REPLACE_DRAWOBJ (sal_uInt8(45))
74 #define EXCHG_OUT_ACTION_REPLACE_SVXB (sal_uInt8(46))
75 #define EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE (sal_uInt8(47))
76 #define EXCHG_OUT_ACTION_REPLACE_BITMAP (sal_uInt8(48))
77 #define EXCHG_OUT_ACTION_REPLACE_GRAPH (sal_uInt8(49))
78 #define EXCHG_OUT_ACTION_INSERT_GRAPH (sal_uInt8(50))
80 enum class SotExchangeActionFlags
{
83 InsertImageMap
= 0x0400,
84 ReplaceImageMap
= 0x0800,
86 InsertTargetUrl
= 0x2000,
89 template<> struct typed_flags
<SotExchangeActionFlags
> : is_typed_flags
<SotExchangeActionFlags
, 0x3e00> {};
93 enum class SotExchangeDest
100 DOC_LNKD_GRAPHOBJ
= 5,
101 DOC_GRAPH_W_IMAP
= 6,
102 DOC_LNKD_GRAPH_W_IMAP
= 7,
108 SWDOC_FREE_AREA
= 13,
109 SCDOC_FREE_AREA
= 14,
110 SDDOC_FREE_AREA
= 15,
111 DOC_TEXTFRAME_WEB
= 16,
112 SWDOC_FREE_AREA_WEB
= 17,
117 class SOT_DLLPUBLIC SotExchange
120 static SotClipboardFormatId
RegisterFormat( const css::datatransfer::DataFlavor
& rFlavor
);
121 static SotClipboardFormatId
RegisterFormatName( const OUString
& rName
);
122 static SotClipboardFormatId
RegisterFormatMimeType( const OUString
& rMimeType
);
124 static SotClipboardFormatId
GetFormat( const css::datatransfer::DataFlavor
& rFlavor
);
125 static OUString
GetFormatName( SotClipboardFormatId nFormat
);
126 static bool GetFormatDataFlavor( SotClipboardFormatId nFormat
, css::datatransfer::DataFlavor
& rFlavor
);
127 static OUString
GetFormatMimeType( SotClipboardFormatId nFormat
);
128 static bool IsInternal( const SvGlobalName
& );
129 static SotClipboardFormatId
GetFormatIdFromMimeType( const OUString
& rMimeType
);
131 // same for XTransferable interface
132 static sal_uInt8
GetExchangeAction(
134 const DataFlavorExVector
& rDataFlavorExVector
,
135 // destination of an action
136 SotExchangeDest nDestination
,
137 // action for a source
138 sal_uInt16 nSourceOptions
,
139 // user action (EXCHG_IN_*, EXCHG_INOUT_*)
140 sal_uInt8 nUserAction
,
141 // In:- Out: format to use
142 SotClipboardFormatId
& rFormat
,
143 // In:- Out: default action (EXCHG_IN_*, EXCHG_INOUT_*)
144 sal_uInt8
& rDefaultAction
,
145 // In:- optional - check only for this specific format
146 SotClipboardFormatId nOnlyTestFormat
= SotClipboardFormatId::NONE
,
147 // In:- optional - check the contents of Xtransferable
148 const css::uno::Reference
< css::datatransfer::XTransferable
>* pxTransferable
= nullptr,
149 // Out: optional: - default action flags
150 SotExchangeActionFlags
* pActionFlags
= nullptr);
152 static sal_uInt16
IsChart( const SvGlobalName
& rName
);
153 static sal_uInt16
IsMath( const SvGlobalName
& rName
);
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */