Update ooo320-m1
[ooovba.git] / vcl / aqua / source / dtrans / DataFlavorMapping.hxx
blobb5b95347b475bf3bb20b1c22599a7a381111fc8a
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: DataFlavorMapping.hxx,v $
10 * $Revision: 1.4 $
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 #ifndef INCLUDED_DATAFLAVORMAPPING_HXX_
32 #define INCLUDED_DATAFLAVORMAPPING_HXX_
34 #include <com/sun/star/datatransfer/DataFlavor.hpp>
35 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
36 #include <com/sun/star/datatransfer/XTransferable.hpp>
37 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
39 #include <premac.h>
40 #import <Cocoa/Cocoa.h>
41 #include <postmac.h>
43 #include <memory>
44 #include <boost/shared_ptr.hpp>
47 /* An interface to get the clipboard data in either
48 system or OOo format.
50 class DataProvider
52 public:
53 virtual ~DataProvider() {};
55 /* Get the clipboard data in the system format.
56 The caller has to retain/release the returned
57 CFDataRef on demand.
59 virtual NSData* getSystemData() = 0;
61 /* Get the clipboard data in OOo format.
63 virtual com::sun::star::uno::Any getOOoData() = 0;
66 typedef std::auto_ptr<DataProvider> DataProviderPtr_t;
69 //################################
72 class DataFlavorMapper
74 public:
75 /* Initialialize a DataFavorMapper instance. Throws a RuntimeException in case the XMimeContentTypeFactory service
76 cannot be created.
78 DataFlavorMapper();
81 /* Map a system data flavor to an OpenOffice data flavor.
82 Return an empty string if there is not suiteable
83 mapping from a system data flavor to a OpenOffice data
84 flavor.
86 com::sun::star::datatransfer::DataFlavor systemToOpenOfficeFlavor(NSString* systemDataFlavor) const;
89 /* Map an OpenOffice data flavor to a system data flavor.
90 If there is no suiteable mapping available NULL will
91 be returned.
93 NSString* openOfficeToSystemFlavor(const com::sun::star::datatransfer::DataFlavor& oooDataFlavor) const;
96 /* Get a data provider which is able to provide the data 'rTransferable' offers in a format that can
97 be put on to the system clipboard.
99 DataProviderPtr_t getDataProvider(NSString* systemFlavor,
100 const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable > rTransferable) const;
104 /* Get a data provider which is able to provide 'systemData' in the OOo expected format.
106 DataProviderPtr_t getDataProvider(const NSString* systemFlavor, NSArray* systemData) const;
109 /* Get a data provider which is able to provide 'systemData' in the OOo expected format.
111 DataProviderPtr_t getDataProvider(const NSString* systemFlavor, NSData* systemData) const;
114 /* Translate a sequence of DataFlavors into a NSArray of system types.
115 Only those DataFlavors for which a suitable mapping to a system
116 type exist will be contained in the returned types array.
118 NSArray* flavorSequenceToTypesArray(const com::sun::star::uno::Sequence<com::sun::star::datatransfer::DataFlavor>& flavors) const;
120 /* Translate a NSArray of system types into a sequence of DataFlavors.
121 Only those types for which a suitable mapping to a DataFlavor
122 exist will be contained in the new DataFlavor Sequence.
124 com::sun::star::uno::Sequence<com::sun::star::datatransfer::DataFlavor> typesArrayToFlavorSequence(NSArray* types) const;
126 /* Returns an NSArray containing all pasteboard types supported by OOo
128 NSArray* DataFlavorMapper::getAllSupportedPboardTypes() const;
130 private:
131 /* Determines if the provided Mime content type is valid.
133 bool isValidMimeContentType(const rtl::OUString& contentType) const;
135 private:
136 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory> mrXMimeCntFactory;
139 typedef boost::shared_ptr<DataFlavorMapper> DataFlavorMapperPtr_t;
141 #endif