xref: /trunk/main/dtrans/source/win32/ftransl/ftransl.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 _FTRANSL_HXX_
26 #define _FTRANSL_HXX_
27 
28 //------------------------------------------------------------------------
29 // includes
30 //------------------------------------------------------------------------
31 
32 #include <rtl/ustring.hxx>
33 #include <sal/types.h>
34 #include <cppuhelper/compbase2.hxx>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/datatransfer/XDataFormatTranslator.hpp>
37 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
38 #include "..\misc\WinClip.hxx"
39 
40 #include <vector>
41 
42 #if defined _MSC_VER
43 #pragma warning(push,1)
44 #endif
45 #include <windows.h>
46 #if defined _MSC_VER
47 #pragma warning(pop)
48 #endif
49 
50 //------------------------------------------------------------------------
51 // declarations
52 //------------------------------------------------------------------------
53 
54 struct FormatEntry
55 {
56    FormatEntry();
57 
58    FormatEntry(
59         const char* mime_content_type,
60         const char* human_presentable_name,
61         const char* native_format_name,
62         CLIPFORMAT std_clipboard_format_id,
63         com::sun::star::uno::Type const & cppu_type
64     );
65 
66     com::sun::star::datatransfer::DataFlavor aDataFlavor;
67     rtl::OUString                            aNativeFormatName;
68     sal_Int32                                aStandardFormatId;
69 };
70 
71 //------------------------------------------------
72 // CDataFormatTranslator
73 //------------------------------------------------
74 
75 class CDataFormatTranslator : public
76     cppu::WeakImplHelper2< com::sun::star::datatransfer::XDataFormatTranslator, \
77     com::sun::star::lang::XServiceInfo >
78 {
79 
80 public:
81     CDataFormatTranslator( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSrvMgr );
82 
83     //------------------------------------------------
84     // XDataFormatTranslator
85     //------------------------------------------------
86 
87     virtual ::com::sun::star::uno::Any SAL_CALL getSystemDataTypeFromDataFlavor( const ::com::sun::star::datatransfer::DataFlavor& aDataFlavor );
88 
89     virtual ::com::sun::star::datatransfer::DataFlavor SAL_CALL getDataFlavorFromSystemDataType( const ::com::sun::star::uno::Any& aSysDataType );
90 
91     //------------------------------------------------
92     // XServiceInfo
93     //------------------------------------------------
94 
95     virtual ::rtl::OUString SAL_CALL getImplementationName(  );
96 
97     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
98 
99     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  );
100 
101 private:
102     void SAL_CALL initTranslationTable( );
103 
104     void SAL_CALL findDataFlavorForStandardFormatId( sal_Int32 aStandardFormatId, com::sun::star::datatransfer::DataFlavor& aDataFlavor ) const;
105     void SAL_CALL findDataFlavorForNativeFormatName( const rtl::OUString& aNativeFormatName, com::sun::star::datatransfer::DataFlavor& aDataFlavor ) const;
106     void SAL_CALL findStandardFormatIdForCharset( const rtl::OUString& aCharset, com::sun::star::uno::Any& aAny ) const;
107     void SAL_CALL setStandardFormatIdForNativeFormatName( const rtl::OUString& aNativeFormatName, com::sun::star::uno::Any& aAny ) const;
108     void SAL_CALL findStdFormatIdOrNativeFormatNameForFullMediaType(
109         const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentTypeFactory >& aRefXMimeFactory,
110         const rtl::OUString& aFullMediaType, com::sun::star::uno::Any& aAny ) const;
111 
112     sal_Bool isTextPlainMediaType( const rtl::OUString& fullMediaType ) const;
113 
114     com::sun::star::datatransfer::DataFlavor SAL_CALL mkDataFlv( const rtl::OUString& cnttype, const rtl::OUString& hpname, ::com::sun::star::uno::Type dtype );
115 
116 private:
117     std::vector< FormatEntry >  m_TranslTable;
118     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >  m_SrvMgr;
119 };
120 
121 
122 #endif
123