LibreOffice Module sot (master) 1
formats.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sot/exchange.hxx>
21#include <sot/formats.hxx>
22#include <sot/filelist.hxx>
23#include <sysformats.hxx>
27#include <tools/globname.hxx>
28#include <tools/stream.hxx>
29#include <com/sun/star/datatransfer/DataFlavor.hpp>
30#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
31#include <com/sun/star/datatransfer/XTransferable.hpp>
32
33using namespace ::com::sun::star::uno;
34using namespace ::com::sun::star::datatransfer;
35
36// define a context check Id for every formatid
37#define FILEGRPDSC_ONLY_URL 1
38
39/*
40 * For each target there is exactly one SotDestinationEntry_Impl in the table.
41 * This entry contains, among other things, a default action for each format
42 * that can be evaluated by the target. The default actions refer to the table
43 * to be evaluated for each format, i.e., they contain only EXCHG_IN_ACTION_MOVE,
44 * EXCHG_IN_ACTION_COPY, or EXCHG_IN_ACTION_LINK. Corresponding to this action,
45 * aMoveActions, aCopyActions, or aLinkActions is then evaluated. The actions
46 * are sorted by priority, i.e., the "more important" is the format, the sooner
47 * it appears in the list.
48 */
49
50namespace {
51
52struct SotDestinationEntry_Impl
53{
54 SotExchangeDest nDestination;
55 const SotAction_Impl* aDefaultActions;
56 const SotAction_Impl* aMoveActions;
57 const SotAction_Impl* aCopyActions;
58 const SotAction_Impl* aLinkActions;
59};
60
61/*
62 * Via this table, the destination, existing data formats and the desired action
63 * are assigned to an action and the data format to be used in it. The table is
64 * sorted by the Exchange destinations (EXCHG_DEST_*). Within the goal entry are
65 * exactly four tables for default, move, copy and link actions. The mapping
66 * between default action (DropEvent::IsDefaultAction()) and the resulting real
67 * action is done via the default table. This table therefore contains only the
68 * EXCHG_IN_ACTION_COPY, EXCHG_IN_ACTION_MOVE, and EXCHG_IN_ACTION_LINK actions
69 * that point to the specific table. The other tables can contain any actions.
70 * Each table is sorted by format priority. Entry zero has the highest priority.
71 */
72
73SotAction_Impl const aEmptyArr[] =
74{
75 { static_cast<SotClipboardFormatId>(0xffff), 0 }
76};
77
78/* --- DOC_OLEOBJ --- */
79SotAction_Impl const aEXCHG_DEST_DOC_OLEOBJ_Def[] =
80{
88 { static_cast<SotClipboardFormatId>(0xffff), 0 }
89};
90SotAction_Impl const aEXCHG_DEST_DOC_OLEOBJ_Move[] =
91{
93 { static_cast<SotClipboardFormatId>(0xffff), 0 }
94};
95SotAction_Impl const aEXCHG_DEST_DOC_OLEOBJ_Link[] =
96{
105 { static_cast<SotClipboardFormatId>(0xffff), 0 }
106};
107
108/* --- CHARTDOC_OLEOBJ --- */
109SotAction_Impl const aEXCHG_DEST_CHARTDOC_OLEOBJ_Def[] =
110{
118 { static_cast<SotClipboardFormatId>(0xffff), 0 }
119};
120SotAction_Impl const aEXCHG_DEST_CHARTDOC_OLEOBJ_Move[] =
121{
123 { static_cast<SotClipboardFormatId>(0xffff), 0 }
124};
125SotAction_Impl const aEXCHG_DEST_CHARTDOC_OLEOBJ_Link[] =
126{
135 { static_cast<SotClipboardFormatId>(0xffff), 0 }
136};
137
138/* --- DOC_TEXTFRAME --- */
139SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_Def[] =
140{
166 { static_cast<SotClipboardFormatId>(0xffff), 0 }
167};
168SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_Move[] =
169{
193 { static_cast<SotClipboardFormatId>(0xffff), 0 }
194};
195SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_Copy[] =
196{
225 { static_cast<SotClipboardFormatId>(0xffff), 0 }
226};
227SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_Link[] =
228{
244 { static_cast<SotClipboardFormatId>(0xffff), 0 }
245};
246
247/* --- DOC_TEXTFRAME_WEB --- */
248SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_WEB_Def[] =
249{
269 { static_cast<SotClipboardFormatId>(0xffff), 0 }
270};
271SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_WEB_Move[] =
272{
290 { static_cast<SotClipboardFormatId>(0xffff), 0 }
291};
292SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_WEB_Copy[] =
293{
316 { static_cast<SotClipboardFormatId>(0xffff), 0 }
317};
318SotAction_Impl const aEXCHG_DEST_DOC_TEXTFRAME_WEB_Link[] =
319{
328 { static_cast<SotClipboardFormatId>(0xffff), 0 }
329};
330
331/* --- DOC_GRAPHOBJ --- */
332SotAction_Impl const aEXCHG_DEST_DOC_GRAPHOBJ_Def[] =
333{
350 { static_cast<SotClipboardFormatId>(0xffff), 0 }
351};
352SotAction_Impl const aEXCHG_DEST_DOC_GRAPHOBJ_Move[] =
353{
366 { static_cast<SotClipboardFormatId>(0xffff), 0 }
367};
368SotAction_Impl const aEXCHG_DEST_DOC_GRAPHOBJ_Copy[] =
369{
382 { static_cast<SotClipboardFormatId>(0xffff), 0 }
383};
384SotAction_Impl const aEXCHG_DEST_DOC_GRAPHOBJ_Link[] =
385{
397 { static_cast<SotClipboardFormatId>(0xffff), 0 }
398};
399
400/* --- DOC_LNKD_GRAPHOBJ --- */
401SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Def[] =
402{
418 { static_cast<SotClipboardFormatId>(0xffff), 0 }
419};
420SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Move[] =
421{
433 { static_cast<SotClipboardFormatId>(0xffff), 0 }
434};
435SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Copy[] =
436{
448 { static_cast<SotClipboardFormatId>(0xffff), 0 }
449};
450SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Link[] =
451{
463 { static_cast<SotClipboardFormatId>(0xffff), 0 }
464};
465
466/* --- DOC_GRAPH_W_IMAP --- */
467SotAction_Impl const aEXCHG_DEST_DOC_GRAPH_W_IMAP_Def[] =
468{
485 { static_cast<SotClipboardFormatId>(0xffff), 0 }
486};
487SotAction_Impl const aEXCHG_DEST_DOC_GRAPH_W_IMAP_Move[] =
488{
500 { static_cast<SotClipboardFormatId>(0xffff), 0 }
501};
502SotAction_Impl const aEXCHG_DEST_DOC_GRAPH_W_IMAP_Copy[] =
503{
515 { static_cast<SotClipboardFormatId>(0xffff), 0 }
516};
517SotAction_Impl const aEXCHG_DEST_DOC_GRAPH_W_IMAP_Link[] =
518{
530 { static_cast<SotClipboardFormatId>(0xffff), 0 }
531};
532
533/* --- DOC_LNKD_GRAPH_W_IMAP --- */
534SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Def[] =
535{
552 { static_cast<SotClipboardFormatId>(0xffff), 0 }
553};
554SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Move[] =
555{
567 { static_cast<SotClipboardFormatId>(0xffff), 0 }
568};
569SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Copy[] =
570{
582 { static_cast<SotClipboardFormatId>(0xffff), 0 }
583};
584SotAction_Impl const aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Link[] =
585{
597 { static_cast<SotClipboardFormatId>(0xffff), 0 }
598};
599
600/* --- DOC_IMAPREGION --- */
601SotAction_Impl const aEXCHG_DEST_DOC_IMAPREGION_Def[] =
602{
607 { static_cast<SotClipboardFormatId>(0xffff), 0 }
608};
609SotAction_Impl const aEXCHG_DEST_DOC_IMAPREGION_Copy[] =
610{
615 { static_cast<SotClipboardFormatId>(0xffff), 0 }
616};
617
618/* --- DOC_DRAWOBJ --- */
619SotAction_Impl const aEXCHG_DEST_DOC_DRAWOBJ_Def[] =
620{
636 { static_cast<SotClipboardFormatId>(0xffff), 0 }
637};
638SotAction_Impl const aEXCHG_DEST_DOC_DRAWOBJ_Copy[] =
639{
651 { static_cast<SotClipboardFormatId>(0xffff), 0 }
652};
653SotAction_Impl const aEXCHG_DEST_DOC_DRAWOBJ_Move[] =
654{
666 { static_cast<SotClipboardFormatId>(0xffff), 0 }
667};
668SotAction_Impl const aEXCHG_DEST_DOC_DRAWOBJ_Link[] =
669{
681 { static_cast<SotClipboardFormatId>(0xffff), 0 }
682};
683
684/* --- DOC_URLBUTTON --- */
685SotAction_Impl const aEXCHG_DEST_DOC_URLBUTTON_Def[] =
686{
698 { static_cast<SotClipboardFormatId>(0xffff), 0 }
699};
700SotAction_Impl const aEXCHG_DEST_DOC_URLBUTTON_Move[] =
701{
705 { static_cast<SotClipboardFormatId>(0xffff), 0 }
706};
707SotAction_Impl const aEXCHG_DEST_DOC_URLBUTTON_Copy[] =
708{
720 { static_cast<SotClipboardFormatId>(0xffff), 0 }
721};
722
723/* --- DOC_URLFIELD --- */
724SotAction_Impl const aEXCHG_DEST_DOC_URLFIELD_Def[] =
725{
730 { static_cast<SotClipboardFormatId>(0xffff), 0 }
731};
732SotAction_Impl const aEXCHG_DEST_DOC_URLFIELD_Copy[] =
733{
738 { static_cast<SotClipboardFormatId>(0xffff), 0 }
739};
740SotAction_Impl const aEXCHG_DEST_DOC_URLFIELD_Link[] =
741{
743 { static_cast<SotClipboardFormatId>(0xffff), 0 }
744};
745
746/* --- DOC_GROUPOBJ --- */
747SotAction_Impl const aEXCHG_DEST_DOC_GROUPOBJ_Def[] =
748{
764 { static_cast<SotClipboardFormatId>(0xffff), 0 }
765};
766SotAction_Impl const aEXCHG_DEST_DOC_GROUPOBJ_Move[] =
767{
779 { static_cast<SotClipboardFormatId>(0xffff), 0 }
780};
781SotAction_Impl const aEXCHG_DEST_DOC_GROUPOBJ_Copy[] =
782{
794 { static_cast<SotClipboardFormatId>(0xffff), 0 }
795};
796SotAction_Impl const aEXCHG_DEST_DOC_GROUPOBJ_Link[] =
797{
809 { static_cast<SotClipboardFormatId>(0xffff), 0 }
810};
811
812/* --- SWDOC_FREE_AREA --- */
813SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Def[] =
814{
843 { static_cast<SotClipboardFormatId>(0xffff), 0 }
844};
845SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Move[] =
846{
870 { static_cast<SotClipboardFormatId>(0xffff), 0 }
871};
872SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Copy[] =
873{
888#ifndef MACOSX
890#endif
898#ifdef MACOSX
900#endif
911 { static_cast<SotClipboardFormatId>(0xffff), 0 }
912};
913SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Link[] =
914{
930 { static_cast<SotClipboardFormatId>(0xffff), 0 }
931};
932
933/* --- SWDOC_FREE_AREA_WEB --- */
934SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Def[] =
935{
956 { static_cast<SotClipboardFormatId>(0xffff), 0 }
957};
958SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Move[] =
959{
975 { static_cast<SotClipboardFormatId>(0xffff), 0 }
976};
977SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Copy[] =
978{
999 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1000};
1001SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Link[] =
1002{
1011 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1012};
1013
1014/* --- SCDOC_FREE_AREA --- */
1015SotAction_Impl const aEXCHG_DEST_SCDOC_FREE_AREA_Def[] =
1016{
1039 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1040};
1041SotAction_Impl const aEXCHG_DEST_SCDOC_FREE_AREA_Move[] =
1042{
1065 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1066};
1067SotAction_Impl const aEXCHG_DEST_SCDOC_FREE_AREA_Copy[] =
1068{
1094 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1095};
1096SotAction_Impl const aEXCHG_DEST_SCDOC_FREE_AREA_Link[] =
1097{
1108 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1109};
1110
1111/* --- SDDOC_FREE_AREA --- */
1112SotAction_Impl const aEXCHG_DEST_SDDOC_FREE_AREA_Def[] =
1113{
1136 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1137};
1138SotAction_Impl const aEXCHG_DEST_SDDOC_FREE_AREA_Move[] =
1139{
1159 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1160};
1161SotAction_Impl const aEXCHG_DEST_SDDOC_FREE_AREA_Copy[] =
1162{
1185 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1186};
1187SotAction_Impl const aEXCHG_DEST_SDDOC_FREE_AREA_Link[] =
1188{
1199 { static_cast<SotClipboardFormatId>(0xffff), 0 }
1200};
1201
1202/* --- exchange destinations --- */
1203SotDestinationEntry_Impl const aDestinationArray[] =
1204{
1206 aEXCHG_DEST_DOC_OLEOBJ_Def,
1207 aEXCHG_DEST_DOC_OLEOBJ_Move,
1208 aEmptyArr,
1209 aEXCHG_DEST_DOC_OLEOBJ_Link
1210 },
1212 aEXCHG_DEST_CHARTDOC_OLEOBJ_Def,
1213 aEXCHG_DEST_CHARTDOC_OLEOBJ_Move,
1214 aEmptyArr,
1215 aEXCHG_DEST_CHARTDOC_OLEOBJ_Link
1216 },
1218 aEXCHG_DEST_DOC_TEXTFRAME_Def,
1219 aEXCHG_DEST_DOC_TEXTFRAME_Move,
1220 aEXCHG_DEST_DOC_TEXTFRAME_Copy,
1221 aEXCHG_DEST_DOC_TEXTFRAME_Link
1222 },
1224 aEXCHG_DEST_DOC_GRAPHOBJ_Def,
1225 aEXCHG_DEST_DOC_GRAPHOBJ_Move,
1226 aEXCHG_DEST_DOC_GRAPHOBJ_Copy,
1227 aEXCHG_DEST_DOC_GRAPHOBJ_Link
1228 },
1230 aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Def,
1231 aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Move,
1232 aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Copy,
1233 aEXCHG_DEST_DOC_LNKD_GRAPHOBJ_Link
1234 },
1236 aEXCHG_DEST_DOC_GRAPH_W_IMAP_Def,
1237 aEXCHG_DEST_DOC_GRAPH_W_IMAP_Move,
1238 aEXCHG_DEST_DOC_GRAPH_W_IMAP_Copy,
1239 aEXCHG_DEST_DOC_GRAPH_W_IMAP_Link
1240 },
1242 aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Def,
1243 aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Move,
1244 aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Copy,
1245 aEXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP_Link
1246 },
1248 aEXCHG_DEST_DOC_IMAPREGION_Def,
1249 aEXCHG_DEST_DOC_IMAPREGION_Copy,
1250 aEmptyArr,
1251 aEmptyArr
1252 },
1254 aEXCHG_DEST_DOC_DRAWOBJ_Def,
1255 aEXCHG_DEST_DOC_DRAWOBJ_Copy,
1256 aEXCHG_DEST_DOC_DRAWOBJ_Move,
1257 aEXCHG_DEST_DOC_DRAWOBJ_Link
1258 },
1260 aEXCHG_DEST_DOC_URLBUTTON_Def,
1261 aEXCHG_DEST_DOC_URLBUTTON_Move,
1262 aEXCHG_DEST_DOC_URLBUTTON_Copy,
1263 aEmptyArr
1264 },
1266 aEXCHG_DEST_DOC_URLFIELD_Def,
1267 aEmptyArr,
1268 aEXCHG_DEST_DOC_URLFIELD_Copy,
1269 aEXCHG_DEST_DOC_URLFIELD_Link
1270 },
1272 aEXCHG_DEST_DOC_GROUPOBJ_Def,
1273 aEXCHG_DEST_DOC_GROUPOBJ_Move,
1274 aEXCHG_DEST_DOC_GROUPOBJ_Copy,
1275 aEXCHG_DEST_DOC_GROUPOBJ_Link
1276 },
1278 aEXCHG_DEST_SWDOC_FREE_AREA_Def,
1279 aEXCHG_DEST_SWDOC_FREE_AREA_Move,
1280 aEXCHG_DEST_SWDOC_FREE_AREA_Copy,
1281 aEXCHG_DEST_SWDOC_FREE_AREA_Link
1282 },
1284 aEXCHG_DEST_SCDOC_FREE_AREA_Def,
1285 aEXCHG_DEST_SCDOC_FREE_AREA_Move,
1286 aEXCHG_DEST_SCDOC_FREE_AREA_Copy,
1287 aEXCHG_DEST_SCDOC_FREE_AREA_Link
1288 },
1290 aEXCHG_DEST_SDDOC_FREE_AREA_Def,
1291 aEXCHG_DEST_SDDOC_FREE_AREA_Move,
1292 aEXCHG_DEST_SDDOC_FREE_AREA_Copy,
1293 aEXCHG_DEST_SDDOC_FREE_AREA_Link
1294 },
1296 aEXCHG_DEST_DOC_TEXTFRAME_WEB_Def,
1297 aEXCHG_DEST_DOC_TEXTFRAME_WEB_Move,
1298 aEXCHG_DEST_DOC_TEXTFRAME_WEB_Copy,
1299 aEXCHG_DEST_DOC_TEXTFRAME_WEB_Link
1300 },
1302 aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Def,
1303 aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Move,
1304 aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Copy,
1305 aEXCHG_DEST_SWDOC_FREE_AREA_WEB_Link
1306 },
1307 {
1308 static_cast<SotExchangeDest>(0xffff), nullptr, nullptr, nullptr, nullptr
1309 }
1310};
1311
1312} // namespace
1313
1314namespace sot
1315{
1317{
1318 return aEXCHG_DEST_SWDOC_FREE_AREA_Copy;
1319}
1320}
1321
1322// - new style GetExchange methods -
1323
1324bool IsFormatSupported( const DataFlavorExVector& rDataFlavorExVector, SotClipboardFormatId nId )
1325{
1326 return std::any_of(rDataFlavorExVector.begin(), rDataFlavorExVector.end(),
1327 [nId](const DataFlavorEx& rDataFlavorEx) { return nId == rDataFlavorEx.mnSotId; });
1328}
1329
1330
1331static bool CheckTransferableContext_Impl( const Reference< XTransferable >* pxTransferable, const SotAction_Impl& rEntry )
1332{
1333 DataFlavor aFlavor;
1334 bool bRet = true;
1335
1336 try
1337 {
1338 if( pxTransferable && (*pxTransferable).is() &&
1340 (*pxTransferable)->isDataFlavorSupported( aFlavor ) )
1341 {
1342#ifdef _WIN32
1343 switch( rEntry.nContextCheckId )
1344 {
1346 {
1347 bRet = false;
1348
1350 (*pxTransferable)->isDataFlavorSupported( aFlavor ) &&
1351 SotExchange::GetFormatDataFlavor( rEntry.nFormatId, aFlavor ) &&
1352 (*pxTransferable)->isDataFlavorSupported( aFlavor ) )
1353 {
1354 Any aAny( (*pxTransferable)->getTransferData( aFlavor ) );
1355
1356 if( aAny.hasValue() )
1357 {
1358 Sequence< sal_Int8 > aSeq; aAny >>= aSeq;
1359
1360 if( aSeq.getLength() )
1361 {
1362 FILEGROUPDESCRIPTORW const * pFDesc = reinterpret_cast<FILEGROUPDESCRIPTORW const *>(aSeq.getConstArray());
1363
1364 if( pFDesc->cItems )
1365 {
1366 OUString sDesc( o3tl::toU(pFDesc->fgd[ 0 ].cFileName) );
1367 bRet = 4 < sDesc.getLength() && sDesc.endsWithIgnoreAsciiCase(".URL");
1368 }
1369 }
1370 }
1371 }
1372 }
1373 break;
1374 }
1375#else
1376 (void) rEntry; // avoid warnings
1377#endif
1378 }
1379 }
1380 catch( const UnsupportedFlavorException& )
1381 {
1382 }
1383 catch( const RuntimeException& )
1384 {
1385 }
1386
1387
1388 return bRet;
1389}
1390
1391
1393 const DataFlavorExVector& rDataFlavorExVector,
1394 const SotAction_Impl* pArray,
1395 SotClipboardFormatId& rFormat,
1396 SotClipboardFormatId nOnlyTestFormat,
1397 const Reference< XTransferable >* pxTransferable,
1398 SotExchangeActionFlags* pActionFlags )
1399{
1400 try
1401 {
1402 if( !rDataFlavorExVector.empty() )
1403 {
1404 const SotAction_Impl* pArrayStart = pArray;
1406
1407 while( nId != static_cast<SotClipboardFormatId>(0xffff) )
1408 {
1409 rFormat = nId;
1410
1411 if( ( nOnlyTestFormat == SotClipboardFormatId::NONE || nOnlyTestFormat == nId ) &&
1412 IsFormatSupported( rDataFlavorExVector, nId ) &&
1413 ( !pArray->nContextCheckId || CheckTransferableContext_Impl( pxTransferable, *pArray ) ) )
1414 {
1415 if( pxTransferable && (*pxTransferable).is() && ( SotClipboardFormatId::FILE_LIST == rFormat ) )
1416 {
1417 if( IsFormatSupported( rDataFlavorExVector, SotClipboardFormatId::SIMPLE_FILE ) )
1418 {
1419 DataFlavor aFileListFlavor;
1421 Any aAny( (*pxTransferable)->getTransferData( aFileListFlavor ) );
1422
1423 if( aAny.hasValue() )
1424 {
1425 Sequence< sal_Int8 > aSeq; aAny >>= aSeq;
1426 SvMemoryStream aMemStm( const_cast<sal_Int8 *>(aSeq.getConstArray()), aSeq.getLength(), StreamMode::READ );
1427 FileList aFileList;
1428
1429 ReadFileList( aMemStm, aFileList );
1430
1431 if( !aMemStm.GetError() && ( aFileList.Count() == 1 ) )
1432 {
1433 const SotAction_Impl* pCur = pArrayStart;
1434
1435 while( pCur->nFormatId != static_cast<SotClipboardFormatId>(0xffff) )
1436 {
1438 {
1440 if (pActionFlags)
1441 *pActionFlags = pCur->nFlags;
1442 return pCur->nAction;
1443 }
1444 pCur++;
1445 }
1446 }
1447 }
1448 }
1449 }
1450 if (pActionFlags)
1451 *pActionFlags = pArray->nFlags;
1452 return pArray->nAction;
1453 }
1454 pArray++;
1455 nId = pArray->nFormatId;
1456 }
1457 }
1458 }
1459 catch( const UnsupportedFlavorException& )
1460 {
1461 }
1462 catch( const RuntimeException& )
1463 {
1464 }
1465
1467}
1468
1469
1471 SotExchangeDest nDestination,
1472 sal_uInt16 nSourceOptions,
1473 sal_uInt8 nUserAction,
1474 SotClipboardFormatId& rFormat,
1475 sal_uInt8& rDefaultAction,
1476 SotClipboardFormatId nOnlyTestFormat,
1477 const Reference< XTransferable >* pxTransferable,
1478 SotExchangeActionFlags* pActionFlags )
1479{
1481
1482 //Todo: incorporate a binary search
1483 const SotDestinationEntry_Impl* pEntry = aDestinationArray;
1484 while( static_cast<SotExchangeDest>(0xffff) != pEntry->nDestination )
1485 {
1486 if( pEntry->nDestination == nDestination )
1487 break;
1488 ++pEntry;
1489 }
1490
1491 if( static_cast<SotExchangeDest>(0xffff) == pEntry->nDestination )
1492 {
1494 }
1495
1497
1498 /* Handling the default action using the following procedure:
1499 *
1500 * - The target is asked for the default action
1501 * - If the source supports this action, it is taken over
1502 * - Otherwise, from the actions made available by the source, one leading
1503 * to a most likely non-empty result action is selected. This is done in
1504 * the following order: Copy -> Link -> Move
1505 */
1506 if( nUserAction == EXCHG_IN_ACTION_DEFAULT )
1507 {
1508 nUserAction = GetTransferableAction_Impl(
1509 rDataFlavorExVector, pEntry->aDefaultActions,
1510 rFormat, nOnlyTestFormat, pxTransferable, pActionFlags );
1511 // Does the source support the action?
1512 if( !(nUserAction & nSourceOptions ))
1513 {
1514 // No -> Check all actions of the source
1515 rDefaultAction = (EXCHG_IN_ACTION_COPY & nSourceOptions);
1516 if( rDefaultAction )
1517 {
1518 nUserAction = GetTransferableAction_Impl(
1519 rDataFlavorExVector, pEntry->aCopyActions,
1520 rFormat, nOnlyTestFormat, pxTransferable, pActionFlags );
1521 if ( nUserAction )
1522 return nUserAction;
1523 }
1524 rDefaultAction = (EXCHG_IN_ACTION_LINK & nSourceOptions);
1525 if( rDefaultAction )
1526 {
1527 nUserAction = GetTransferableAction_Impl(
1528 rDataFlavorExVector, pEntry->aLinkActions,
1529 rFormat, nOnlyTestFormat, pxTransferable, pActionFlags );
1530 if ( nUserAction )
1531 return nUserAction;
1532 }
1533 rDefaultAction = (EXCHG_IN_ACTION_MOVE & nSourceOptions);
1534 if( rDefaultAction )
1535 {
1536 nUserAction = GetTransferableAction_Impl(
1537 rDataFlavorExVector, pEntry->aMoveActions,
1538 rFormat, nOnlyTestFormat, pxTransferable, pActionFlags );
1539 if ( nUserAction )
1540 return nUserAction;
1541 }
1542 rDefaultAction = 0;
1543 return 0;
1544 }
1545 rDefaultAction = nUserAction;
1546 }
1547 else
1548 rDefaultAction = nUserAction;
1549
1550 switch( nUserAction )
1551 {
1553 nUserAction = GetTransferableAction_Impl(
1554 rDataFlavorExVector, pEntry->aMoveActions,
1555 rFormat, nOnlyTestFormat, pxTransferable, pActionFlags );
1556 break;
1557
1559 nUserAction = GetTransferableAction_Impl(
1560 rDataFlavorExVector, pEntry->aCopyActions,
1561 rFormat, nOnlyTestFormat, pxTransferable, pActionFlags );
1562 break;
1563
1565 nUserAction = GetTransferableAction_Impl(
1566 rDataFlavorExVector, pEntry->aLinkActions,
1567 rFormat, nOnlyTestFormat, pxTransferable, pActionFlags );
1568 break;
1569
1570 default:
1571 nUserAction = EXCHG_INOUT_ACTION_NONE;
1572 }
1573 return nUserAction;
1574}
1575
1576
1577sal_uInt16 SotExchange::IsChart( const SvGlobalName& rName )
1578{
1579 sal_uInt16 nRet=0;
1580// if ( rName == SvGlobalName( SO3_SCH_CLASSID_8 ) )
1581// nRet = SOFFICE_FILEFORMAT_8;
1582// else
1583 if ( rName == SvGlobalName( SO3_SCH_CLASSID_60 ) )
1584 nRet = SOFFICE_FILEFORMAT_60;
1585 else if ( rName == SvGlobalName( SO3_SCH_CLASSID_50 ) )
1586 nRet = SOFFICE_FILEFORMAT_50;
1587 else if ( rName == SvGlobalName( SO3_SCH_CLASSID_40 ) )
1588 nRet = SOFFICE_FILEFORMAT_40;
1589 else if ( rName == SvGlobalName( SO3_SCH_CLASSID_30 ) )
1590 nRet = SOFFICE_FILEFORMAT_31;
1591
1592 return nRet;
1593}
1594
1595sal_uInt16 SotExchange::IsMath( const SvGlobalName& rName )
1596{
1597 sal_uInt16 nRet=0;
1598// if ( rName == SvGlobalName( SO3_SM_CLASSID_8 ) )
1599// nRet = SOFFICE_FILEFORMAT_8;
1600// else
1601 if ( rName == SvGlobalName( SO3_SM_CLASSID_60 ) )
1602 nRet = SOFFICE_FILEFORMAT_60;
1603 else if ( rName == SvGlobalName( SO3_SM_CLASSID_50 ) )
1604 nRet = SOFFICE_FILEFORMAT_50;
1605 else if ( rName == SvGlobalName( SO3_SM_CLASSID_40 ) )
1606 nRet = SOFFICE_FILEFORMAT_40;
1607 else if ( rName == SvGlobalName( SO3_SM_CLASSID_30 ) )
1608 nRet = SOFFICE_FILEFORMAT_31;
1609
1610 return nRet;
1611}
1612
1613/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t Count() const
Definition: filelist.cxx:74
static sal_uInt16 IsChart(const SvGlobalName &rName)
Definition: formats.cxx:1577
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
Definition: exchange.cxx:316
static sal_uInt8 GetExchangeAction(const DataFlavorExVector &rDataFlavorExVector, SotExchangeDest nDestination, sal_uInt16 nSourceOptions, sal_uInt8 nUserAction, SotClipboardFormatId &rFormat, sal_uInt8 &rDefaultAction, SotClipboardFormatId nOnlyTestFormat=SotClipboardFormatId::NONE, const css::uno::Reference< css::datatransfer::XTransferable > *pxTransferable=nullptr, SotExchangeActionFlags *pActionFlags=nullptr)
Definition: formats.cxx:1470
static sal_uInt16 IsMath(const SvGlobalName &rName)
Definition: formats.cxx:1595
ErrCode GetError() const
#define SO3_SCH_CLASSID_40
#define SO3_SM_CLASSID_50
#define SO3_SM_CLASSID_60
#define SO3_SCH_CLASSID_30
#define SO3_SCH_CLASSID_50
#define SO3_SCH_CLASSID_60
#define SO3_SM_CLASSID_30
#define SO3_SM_CLASSID_40
#define EXCHG_OUT_ACTION_INSERT_INTERACTIVE
Definition: exchange.hxx:56
#define EXCHG_OUT_ACTION_INSERT_GDIMETAFILE
Definition: exchange.hxx:65
#define EXCHG_OUT_ACTION_INSERT_HTML
Definition: exchange.hxx:60
#define EXCHG_OUT_ACTION_INSERT_BITMAP
Definition: exchange.hxx:66
#define EXCHG_IN_ACTION_LINK
Definition: exchange.hxx:52
#define EXCHG_INOUT_ACTION_NONE
Definition: exchange.hxx:48
#define EXCHG_OUT_ACTION_INSERT_DRAWOBJ
Definition: exchange.hxx:63
SotExchangeActionFlags
Definition: exchange.hxx:76
::std::vector< DataFlavorEx > DataFlavorExVector
Definition: exchange.hxx:41
#define EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE
Definition: exchange.hxx:71
#define EXCHG_OUT_ACTION_INSERT_GRAPH
Definition: exchange.hxx:74
#define EXCHG_OUT_ACTION_INSERT_IMAGEMAP
Definition: exchange.hxx:54
#define EXCHG_OUT_ACTION_REPLACE_BITMAP
Definition: exchange.hxx:72
#define EXCHG_OUT_ACTION_REPLACE_SVXB
Definition: exchange.hxx:70
#define EXCHG_IN_ACTION_COPY
Definition: exchange.hxx:51
#define EXCHG_OUT_ACTION_REPLACE_GRAPH
Definition: exchange.hxx:73
#define EXCHG_OUT_ACTION_INSERT_OLE
Definition: exchange.hxx:55
#define EXCHG_OUT_ACTION_INSERT_HYPERLINK
Definition: exchange.hxx:68
#define EXCHG_OUT_ACTION_INSERT_DDE
Definition: exchange.hxx:67
#define EXCHG_OUT_ACTION_REPLACE_DRAWOBJ
Definition: exchange.hxx:69
SotExchangeDest
Definition: exchange.hxx:88
#define EXCHG_OUT_ACTION_INSERT_STRING
Definition: exchange.hxx:62
#define EXCHG_IN_ACTION_MOVE
Definition: exchange.hxx:50
#define EXCHG_OUT_ACTION_INSERT_SVXB
Definition: exchange.hxx:64
#define EXCHG_IN_ACTION_DEFAULT
Definition: exchange.hxx:49
#define EXCHG_OUT_ACTION_GET_ATTRIBUTES
Definition: exchange.hxx:58
#define EXCHG_OUT_ACTION_INSERT_FILE
Definition: exchange.hxx:53
#define SOFFICE_FILEFORMAT_40
#define SOFFICE_FILEFORMAT_31
#define SOFFICE_FILEFORMAT_50
#define SOFFICE_FILEFORMAT_60
SvStream & ReadFileList(SvStream &rIStm, FileList &rFileList)
Definition: filelist.cxx:32
static sal_uInt16 GetTransferableAction_Impl(const DataFlavorExVector &rDataFlavorExVector, const SotAction_Impl *pArray, SotClipboardFormatId &rFormat, SotClipboardFormatId nOnlyTestFormat, const Reference< XTransferable > *pxTransferable, SotExchangeActionFlags *pActionFlags)
Definition: formats.cxx:1392
bool IsFormatSupported(const DataFlavorExVector &rDataFlavorExVector, SotClipboardFormatId nId)
Definition: formats.cxx:1324
#define FILEGRPDSC_ONLY_URL
Definition: formats.cxx:37
static bool CheckTransferableContext_Impl(const Reference< XTransferable > *pxTransferable, const SotAction_Impl &rEntry)
Definition: formats.cxx:1331
SotClipboardFormatId
Definition: formats.hxx:28
Sequence< sal_Int8 > aSeq
const SotAction_Impl * GetExchangeDestinationWriterFreeAreaCopy()
Definition: formats.cxx:1316
sal_Int16 nId
sal_uInt8 nContextCheckId
Definition: sysformats.hxx:36
SotExchangeActionFlags nFlags
Definition: sysformats.hxx:34
sal_uInt16 nAction
Definition: sysformats.hxx:35
SotClipboardFormatId nFormatId
Definition: sysformats.hxx:33
unsigned char sal_uInt8
signed char sal_Int8