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 _DOTRANSFERABLE_HXX_
26 #define _DOTRANSFERABLE_HXX_
27 
28 //------------------------------------------------------------------------
29 // includes
30 //------------------------------------------------------------------------
31 
32 #include <com/sun/star/datatransfer/XTransferable.hpp>
33 
34 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
35 #include <cppuhelper/implbase2.hxx>
36 #endif
37 #include "DataFmtTransl.hxx"
38 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
39 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
40 #include <com/sun/star/datatransfer/XSystemTransferable.hpp>
41 
42 #include <systools/win32/comtools.hxx>
43 
44 //------------------------------------------------------------------------
45 // deklarations
46 //------------------------------------------------------------------------
47 
48 // forward
49 class CDTransObjFactory;
50 class CFormatEtc;
51 
52 class CDOTransferable : public ::cppu::WeakImplHelper2< ::com::sun::star::datatransfer::XTransferable,
53 						::com::sun::star::datatransfer::XSystemTransferable>
54 {
55 public:
56 	typedef com::sun::star::uno::Sequence< sal_Int8 > ByteSequence_t;
57 
58 	//------------------------------------------------------------------------
59 	// XTransferable
60 	//------------------------------------------------------------------------
61 
62     virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
63 		throw( ::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
64 
65     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors(  )
66 		throw( ::com::sun::star::uno::RuntimeException );
67 
68 	virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
69 		throw( ::com::sun::star::uno::RuntimeException );
70 	//------------------------------------------------------------------------
71 	// XSystemTransferable
72 	//------------------------------------------------------------------------
73     virtual ::com::sun::star::uno::Any SAL_CALL getData( const com::sun::star::uno::Sequence<sal_Int8>& aProcessId  ) throw
74 	(::com::sun::star::uno::RuntimeException);
75 
76 
77 private:
78 	// should be created only by CDTransObjFactory
79 	explicit CDOTransferable(
80 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ServiceManager,
81 		IDataObjectPtr rDataObject );
82 
83 	//------------------------------------------------------------------------
84 	// some helper functions
85 	//------------------------------------------------------------------------
86 
87 	void SAL_CALL initFlavorList( );
88 
89 	void SAL_CALL addSupportedFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
90 	com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc );
91 
92 	ByteSequence_t SAL_CALL getClipboardData( CFormatEtc& aFormatEtc );
93 	rtl::OUString  SAL_CALL synthesizeUnicodeText( );
94 
95 	void SAL_CALL clipDataToByteStream( CLIPFORMAT cf, STGMEDIUM stgmedium, ByteSequence_t& aByteSequence );
96 
97 	::com::sun::star::uno::Any SAL_CALL byteStreamToAny( ByteSequence_t& aByteStream, const com::sun::star::uno::Type& aRequestedDataType );
98 	rtl::OUString              SAL_CALL byteStreamToOUString( ByteSequence_t& aByteStream );
99 
100 	LCID SAL_CALL getLocaleFromClipboard( );
101 
102 	sal_Bool SAL_CALL compareDataFlavors( const com::sun::star::datatransfer::DataFlavor& lhs,
103 										  const com::sun::star::datatransfer::DataFlavor& rhs );
104 
105 	sal_Bool SAL_CALL cmpFullMediaType( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xLhs,
106 										const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xRhs ) const;
107 
108 	sal_Bool SAL_CALL cmpAllContentTypeParameter( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xLhs,
109 										const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType >& xRhs ) const;
110 
111 private:
112 	IDataObjectPtr																			m_rDataObject;
113 	com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor >				m_FlavorList;
114 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >	m_SrvMgr;
115 	CDataFormatTranslator																	m_DataFormatTranslator;
116 	com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentTypeFactory > m_rXMimeCntFactory;
117 	::osl::Mutex																			m_aMutex;
118 	sal_Bool																				m_bUnicodeRegistered;
119 	CLIPFORMAT																				m_TxtFormatOnClipboard;
120 
121 // non supported operations
122 private:
123 	CDOTransferable( const CDOTransferable& );
124 	CDOTransferable& operator=( const CDOTransferable& );
125 
126 	friend class CDTransObjFactory;
127 };
128 
129 #endif
130