1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef _TRANSFERABLE_HXX_
26 #define _TRANSFERABLE_HXX_
27 
28 //------------------------------------------------------------------------
29 // includes
30 //------------------------------------------------------------------------
31 
32 #include <com/sun/star/datatransfer/XTransferable.hpp>
33 #include <cppuhelper/implbase1.hxx>
34 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
35 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
36 
37 #include "DataFlavorMapping.hxx"
38 
39 #include <premac.h>
40 #import <Cocoa/Cocoa.h>
41 #include <postmac.h>
42 
43 #include <boost/shared_ptr.hpp>
44 #include <boost/utility.hpp>
45 #include <vector>
46 
47 
48 class OSXTransferable : public ::cppu::WeakImplHelper1<com::sun::star::datatransfer::XTransferable>,
49 						private ::boost::noncopyable
50 {
51 public:
52   typedef com::sun::star::uno::Sequence< sal_Int8 > ByteSequence_t;
53 
54   explicit OSXTransferable(com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory> rXMimeCntFactory,
55 						   DataFlavorMapperPtr_t pDataFlavorMapper,
56 						   NSPasteboard* pasteboard);
57 
58   virtual ~OSXTransferable();
59 
60   //------------------------------------------------------------------------
61   // XTransferable
62   //------------------------------------------------------------------------
63 
64   virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
65 	throw( ::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
66 
67   virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors(  )
68 	throw( ::com::sun::star::uno::RuntimeException );
69 
70   virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
71 	throw( ::com::sun::star::uno::RuntimeException );
72 
73   //------------------------------------------------------------------------
74   // Helper functions not part of the XTransferable interface
75   //------------------------------------------------------------------------
76 
77   void initClipboardItemList();
78 
79   //com::sun::star::uno::Any getClipboardItemData(ClipboardItemPtr_t clipboardItem);
80 
81   bool isUnicodeText(const com::sun::star::datatransfer::DataFlavor& flavor);
82 
83   bool compareDataFlavors( const com::sun::star::datatransfer::DataFlavor& lhs,
84 						   const com::sun::star::datatransfer::DataFlavor& rhs );
85 
86   bool cmpAllContentTypeParameter( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType > xLhs,
87 								   const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType > xRhs ) const;
88 
89 private:
90   com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor > mFlavorList;
91   ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory> mrXMimeCntFactory;
92   DataFlavorMapperPtr_t mDataFlavorMapper;
93   NSPasteboard* mPasteboard;
94 };
95 
96 #endif
97