1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef _TRANSFERABLE_HXX_
30 #define _TRANSFERABLE_HXX_
31 
32 //------------------------------------------------------------------------
33 // includes
34 //------------------------------------------------------------------------
35 
36 #include <com/sun/star/datatransfer/XTransferable.hpp>
37 #include <cppuhelper/implbase1.hxx>
38 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
39 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
40 
41 #include "DataFlavorMapping.hxx"
42 
43 #include <premac.h>
44 #import <Cocoa/Cocoa.h>
45 #include <postmac.h>
46 
47 #include <boost/shared_ptr.hpp>
48 #include <boost/utility.hpp>
49 #include <vector>
50 
51 
52 class OSXTransferable : public ::cppu::WeakImplHelper1<com::sun::star::datatransfer::XTransferable>,
53 						private ::boost::noncopyable
54 {
55 public:
56   typedef com::sun::star::uno::Sequence< sal_Int8 > ByteSequence_t;
57 
58   explicit OSXTransferable(com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory> rXMimeCntFactory,
59 						   DataFlavorMapperPtr_t pDataFlavorMapper,
60 						   NSPasteboard* pasteboard);
61 
62   virtual ~OSXTransferable();
63 
64   //------------------------------------------------------------------------
65   // XTransferable
66   //------------------------------------------------------------------------
67 
68   virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
69 	throw( ::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
70 
71   virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors(  )
72 	throw( ::com::sun::star::uno::RuntimeException );
73 
74   virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
75 	throw( ::com::sun::star::uno::RuntimeException );
76 
77   //------------------------------------------------------------------------
78   // Helper functions not part of the XTransferable interface
79   //------------------------------------------------------------------------
80 
81   void initClipboardItemList();
82 
83   //com::sun::star::uno::Any getClipboardItemData(ClipboardItemPtr_t clipboardItem);
84 
85   bool isUnicodeText(const com::sun::star::datatransfer::DataFlavor& flavor);
86 
87   bool compareDataFlavors( const com::sun::star::datatransfer::DataFlavor& lhs,
88 						   const com::sun::star::datatransfer::DataFlavor& rhs );
89 
90   bool cmpAllContentTypeParameter( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType > xLhs,
91 								   const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType > xRhs ) const;
92 
93 private:
94   com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor > mFlavorList;
95   ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory> mrXMimeCntFactory;
96   DataFlavorMapperPtr_t mDataFlavorMapper;
97   NSPasteboard* mPasteboard;
98 };
99 
100 #endif
101