1*fbcf0fe9SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*fbcf0fe9SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*fbcf0fe9SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*fbcf0fe9SAndrew Rist  * distributed with this work for additional information
6*fbcf0fe9SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*fbcf0fe9SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*fbcf0fe9SAndrew Rist  * "License"); you may not use this file except in compliance
9*fbcf0fe9SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*fbcf0fe9SAndrew Rist  *
11*fbcf0fe9SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*fbcf0fe9SAndrew Rist  *
13*fbcf0fe9SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*fbcf0fe9SAndrew Rist  * software distributed under the License is distributed on an
15*fbcf0fe9SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*fbcf0fe9SAndrew Rist  * KIND, either express or implied.  See the License for the
17*fbcf0fe9SAndrew Rist  * specific language governing permissions and limitations
18*fbcf0fe9SAndrew Rist  * under the License.
19*fbcf0fe9SAndrew Rist  *
20*fbcf0fe9SAndrew Rist  *************************************************************/
21*fbcf0fe9SAndrew Rist 
22*fbcf0fe9SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef _FTRANSL_HXX_
26cdf0e10cSrcweir #define _FTRANSL_HXX_
27cdf0e10cSrcweir 
28cdf0e10cSrcweir //------------------------------------------------------------------------
29cdf0e10cSrcweir // includes
30cdf0e10cSrcweir //------------------------------------------------------------------------
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <rtl/ustring.hxx>
33cdf0e10cSrcweir #include <sal/types.h>
34cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
35cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
36cdf0e10cSrcweir #include <com/sun/star/datatransfer/XDataFormatTranslator.hpp>
37cdf0e10cSrcweir #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
38cdf0e10cSrcweir #include "..\misc\WinClip.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <vector>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #if defined _MSC_VER
43cdf0e10cSrcweir #pragma warning(push,1)
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #include <windows.h>
46cdf0e10cSrcweir #if defined _MSC_VER
47cdf0e10cSrcweir #pragma warning(pop)
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //------------------------------------------------------------------------
51cdf0e10cSrcweir // declarations
52cdf0e10cSrcweir //------------------------------------------------------------------------
53cdf0e10cSrcweir 
54cdf0e10cSrcweir struct FormatEntry
55cdf0e10cSrcweir {
56cdf0e10cSrcweir    FormatEntry();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir    FormatEntry(
59cdf0e10cSrcweir         const char* mime_content_type,
60cdf0e10cSrcweir         const char* human_presentable_name,
61cdf0e10cSrcweir         const char* native_format_name,
62cdf0e10cSrcweir         CLIPFORMAT std_clipboard_format_id,
63cdf0e10cSrcweir         com::sun::star::uno::Type const & cppu_type
64cdf0e10cSrcweir 	);
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	com::sun::star::datatransfer::DataFlavor aDataFlavor;
67cdf0e10cSrcweir 	rtl::OUString							 aNativeFormatName;
68cdf0e10cSrcweir 	sal_Int32								 aStandardFormatId;
69cdf0e10cSrcweir };
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //------------------------------------------------
72cdf0e10cSrcweir // CDataFormatTranslator
73cdf0e10cSrcweir //------------------------------------------------
74cdf0e10cSrcweir 
75cdf0e10cSrcweir class CDataFormatTranslator : public
76cdf0e10cSrcweir 	cppu::WeakImplHelper2< com::sun::star::datatransfer::XDataFormatTranslator, \
77cdf0e10cSrcweir 	com::sun::star::lang::XServiceInfo >
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 
80cdf0e10cSrcweir public:
81cdf0e10cSrcweir 	CDataFormatTranslator( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSrvMgr );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	//------------------------------------------------
84cdf0e10cSrcweir 	// XDataFormatTranslator
85cdf0e10cSrcweir 	//------------------------------------------------
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL getSystemDataTypeFromDataFlavor( const ::com::sun::star::datatransfer::DataFlavor& aDataFlavor )
88cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     virtual ::com::sun::star::datatransfer::DataFlavor SAL_CALL getDataFlavorFromSystemDataType( const ::com::sun::star::uno::Any& aSysDataType )
91cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	//------------------------------------------------
94cdf0e10cSrcweir 	// XServiceInfo
95cdf0e10cSrcweir 	//------------------------------------------------
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getImplementationName(	 )
98cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
101cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
104cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir private:
107cdf0e10cSrcweir 	void SAL_CALL initTranslationTable( );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	void SAL_CALL findDataFlavorForStandardFormatId( sal_Int32 aStandardFormatId, com::sun::star::datatransfer::DataFlavor& aDataFlavor ) const;
110cdf0e10cSrcweir 	void SAL_CALL findDataFlavorForNativeFormatName( const rtl::OUString& aNativeFormatName, com::sun::star::datatransfer::DataFlavor& aDataFlavor ) const;
111cdf0e10cSrcweir 	void SAL_CALL findStandardFormatIdForCharset( const rtl::OUString& aCharset, com::sun::star::uno::Any& aAny ) const;
112cdf0e10cSrcweir 	void SAL_CALL setStandardFormatIdForNativeFormatName( const rtl::OUString& aNativeFormatName, com::sun::star::uno::Any& aAny ) const;
113cdf0e10cSrcweir 	void SAL_CALL findStdFormatIdOrNativeFormatNameForFullMediaType(
114cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentTypeFactory >& aRefXMimeFactory,
115cdf0e10cSrcweir 		const rtl::OUString& aFullMediaType, com::sun::star::uno::Any& aAny ) const;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     sal_Bool isTextPlainMediaType( const rtl::OUString& fullMediaType ) const;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	com::sun::star::datatransfer::DataFlavor SAL_CALL mkDataFlv( const rtl::OUString& cnttype, const rtl::OUString& hpname, ::com::sun::star::uno::Type dtype );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir private:
122cdf0e10cSrcweir 	std::vector< FormatEntry >	m_TranslTable;
123cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >	m_SrvMgr;
124cdf0e10cSrcweir };
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir #endif
128cdf0e10cSrcweir 
129