xref: /AOO41X/main/dtrans/source/win32/ftransl/ftransl.cxx (revision 5443dcac4da55ae8863c5c80e8907938642a7f1b)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dtrans.hxx"
26 
27 //------------------------------------------------------------------------
28 // includes
29 //------------------------------------------------------------------------
30 #include <osl/diagnose.h>
31 
32 #ifndef _DFLVCONT_HXX_
33 #include "ftransl.hxx"
34 #endif
35 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
36 #include "..\misc\ImplHelper.hxx"
37 
38 #if defined _MSC_VER
39 #pragma warning(push,1)
40 #pragma warning(disable:4917)
41 #endif
42 #include <shlobj.h>
43 #if defined _MSC_VER
44 #pragma warning(pop)
45 #endif
46 
47 //------------------------------------------------------------------------
48 // defines
49 //------------------------------------------------------------------------
50 
51 #define IMPL_NAME  "com.sun.star.datatransfer.DataFormatTranslator"
52 
53 #define MODULE_PRIVATE
54 #define CPPUTYPE_SEQSALINT8       getCppuType( (const Sequence< sal_Int8 >*) 0 )
55 #define CPPUTYPE_DEFAULT          CPPUTYPE_SEQSALINT8
56 #define CPPUTYPE_OUSTR            getCppuType( (const ::rtl::OUString*) 0 )
57 #define CPPUTYPE_SALINT32         getCppuType( ( sal_Int32 * ) 0 )
58 #define OUSTR( str )              OUString::createFromAscii( #str )
59 #define OUSTR_( str )             OUString::createFromAscii( str )
60 #define EMPTY_OUSTR               OUString::createFromAscii( "" )
61 //#define PRIVATE_OO                  OUString::createFromAscii( "application/x-openoffice;" "windows_formatname=" )
62 
63 const rtl::OUString Windows_FormatName = rtl::OUString::createFromAscii("windows_formatname");
64 const com::sun::star::uno::Type CppuType_ByteSequence = ::getCppuType((const com::sun::star::uno::Sequence<sal_Int8>*)0);
65 const com::sun::star::uno::Type CppuType_String       = ::getCppuType((const ::rtl::OUString*)0);
66 
67 //------------------------------------------------------------------------
68 // namespace directives
69 //------------------------------------------------------------------------
70 
71 using namespace rtl;
72 using namespace osl;
73 using namespace cppu;
74 using namespace std;
75 using namespace com::sun::star::uno;
76 using namespace com::sun::star::lang;
77 using namespace com::sun::star::datatransfer;
78 using namespace com::sun::star::container;
79 
80 //------------------------------------------------------------------------
81 // helper functions
82 //------------------------------------------------------------------------
83 
84 namespace MODULE_PRIVATE
85 {
86     Sequence< OUString > SAL_CALL DataFormatTranslator_getSupportedServiceNames( )
87     {
88         Sequence< OUString > aRet(1);
89         aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.DataFormatTranslator");
90         return aRet;
91     }
92 }
93 
94 //------------------------------------------------
95 //
96 //------------------------------------------------
97 
98 FormatEntry::FormatEntry()
99 {
100 }
101 
102 //------------------------------------------------
103 //
104 //------------------------------------------------
105 
106 FormatEntry::FormatEntry(
107     const char* mime_content_type,
108     const char* human_presentable_name,
109     const char* native_format_name,
110     CLIPFORMAT std_clipboard_format_id,
111     ::com::sun::star::uno::Type const & cppu_type)
112 {
113     aDataFlavor.MimeType             = rtl::OUString::createFromAscii(mime_content_type);
114     aDataFlavor.HumanPresentableName = rtl::OUString::createFromAscii(human_presentable_name);
115     aDataFlavor.DataType             = cppu_type;
116 
117     if (native_format_name)
118         aNativeFormatName = rtl::OUString::createFromAscii(native_format_name);
119     else
120         aNativeFormatName = rtl::OUString::createFromAscii(human_presentable_name);
121 
122     aStandardFormatId = std_clipboard_format_id;
123 }
124 
125 //------------------------------------------------------------------------
126 // ctor
127 //------------------------------------------------------------------------
128 
129 CDataFormatTranslator::CDataFormatTranslator( const Reference< XMultiServiceFactory >& rSrvMgr ) :
130     m_SrvMgr( rSrvMgr )
131 {
132     initTranslationTable( );
133 }
134 
135 //------------------------------------------------------------------------
136 //
137 //------------------------------------------------------------------------
138 
139 Any SAL_CALL CDataFormatTranslator::getSystemDataTypeFromDataFlavor( const DataFlavor& aDataFlavor )
140     throw( RuntimeException )
141 {
142     Any aAny;
143 
144     try
145     {
146         Reference< XMimeContentTypeFactory > refXMimeCntFactory( m_SrvMgr->createInstance(
147             OUSTR( com.sun.star.datatransfer.MimeContentTypeFactory ) ), UNO_QUERY );
148 
149         if ( !refXMimeCntFactory.is( ) )
150             throw RuntimeException( );
151 
152         Reference< XMimeContentType >
153             refXMimeCntType( refXMimeCntFactory->createMimeContentType( aDataFlavor.MimeType ) );
154 
155         OUString fullMediaType = refXMimeCntType->getFullMediaType( );
156         if ( isTextPlainMediaType( fullMediaType ) )
157         {
158             // default is CF_TEXT
159             aAny <<= static_cast< sal_Int32 >( CF_TEXT );
160 
161             if ( refXMimeCntType->hasParameter( OUSTR( charset ) ) )
162             {
163                 // but maybe it is unicode text or oem text
164                 OUString charset = refXMimeCntType->getParameterValue( OUSTR( charset ) );
165                 findStandardFormatIdForCharset( charset, aAny );
166             }
167         }
168         else
169         {
170             if (refXMimeCntType->hasParameter(Windows_FormatName))
171             {
172                 OUString winfmtname = refXMimeCntType->getParameterValue(Windows_FormatName);
173                 aAny <<= winfmtname;
174 
175                 setStandardFormatIdForNativeFormatName( winfmtname, aAny );
176             }
177             else
178                 findStdFormatIdOrNativeFormatNameForFullMediaType( refXMimeCntFactory, fullMediaType, aAny );
179         }
180     }
181     catch( IllegalArgumentException& )
182     {
183         OSL_ENSURE( sal_False, "Invalid content-type detected!" );
184     }
185     catch( NoSuchElementException& )
186     {
187         OSL_ENSURE( sal_False, "Illegal content-type parameter" );
188     }
189     catch( ... )
190     {
191         OSL_ENSURE( sal_False, "Unexpected error" );
192         throw;
193     }
194 
195     return aAny;
196 }
197 
198 //------------------------------------------------------------------------
199 //
200 //------------------------------------------------------------------------
201 
202 DataFlavor SAL_CALL CDataFormatTranslator::getDataFlavorFromSystemDataType( const Any& aSysDataType )
203     throw( RuntimeException )
204 {
205     OSL_PRECOND( aSysDataType.hasValue( ), "Empty system data type delivered" );
206 
207     DataFlavor aFlavor = mkDataFlv( EMPTY_OUSTR, EMPTY_OUSTR, CPPUTYPE_SEQSALINT8 );
208 
209     if ( aSysDataType.getValueType( ) == CPPUTYPE_SALINT32 )
210     {
211         sal_Int32 clipformat;
212         aSysDataType >>= clipformat;
213         if ( CF_INVALID != clipformat )
214             findDataFlavorForStandardFormatId( clipformat, aFlavor );
215     }
216     else if ( aSysDataType.getValueType( ) == CPPUTYPE_OUSTR )
217     {
218         OUString nativeFormatName;
219         aSysDataType >>= nativeFormatName;
220 
221         findDataFlavorForNativeFormatName( nativeFormatName, aFlavor );
222     }
223     else
224         OSL_ENSURE( sal_False, "Invalid data type received" );
225 
226     return aFlavor;
227 }
228 
229 // -------------------------------------------------
230 // XServiceInfo
231 // -------------------------------------------------
232 
233 OUString SAL_CALL CDataFormatTranslator::getImplementationName(  )
234     throw( RuntimeException )
235 {
236     return OUString::createFromAscii( IMPL_NAME );
237 }
238 
239 // -------------------------------------------------
240 //  XServiceInfo
241 // -------------------------------------------------
242 
243 sal_Bool SAL_CALL CDataFormatTranslator::supportsService( const OUString& ServiceName )
244     throw( RuntimeException )
245 {
246     Sequence < OUString > SupportedServicesNames = DataFormatTranslator_getSupportedServiceNames();
247 
248     for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
249         if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
250             return sal_True;
251 
252     return sal_False;
253 }
254 
255 // -------------------------------------------------
256 //  XServiceInfo
257 // -------------------------------------------------
258 
259 Sequence< OUString > SAL_CALL CDataFormatTranslator::getSupportedServiceNames( )
260     throw( RuntimeException )
261 {
262     return DataFormatTranslator_getSupportedServiceNames( );
263 }
264 
265 // -------------------------------------------------
266 // to optimize searching we add all entries with a
267 // standard clipboard format number first, in the
268 // table before the entries with CF_INVALID
269 // if we are searching for a standard clipboard
270 // format number we can stop if we find the first
271 // CF_INVALID
272 // -------------------------------------------------
273 
274 void SAL_CALL CDataFormatTranslator::initTranslationTable()
275 {
276     //SOT_FORMATSTR_ID_DIF
277     m_TranslTable.push_back(FormatEntry("application/x-openoffice-dif;windows_formatname=\"DIF\"", "DIF", "DIF", CF_DIF, CPPUTYPE_DEFAULT));
278     // SOT_FORMAT_BITMAP
279     m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_DIBV5, CPPUTYPE_DEFAULT));
280     m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_DIB, CPPUTYPE_DEFAULT));
281     m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_BITMAP, CPPUTYPE_DEFAULT));
282     // SOT_FORMAT_STRING
283     m_TranslTable.push_back(FormatEntry("text/plain;charset=utf-16", "Unicode-Text", "", CF_UNICODETEXT, CppuType_String));
284     // Format Locale - for internal use
285     m_TranslTable.push_back(FormatEntry("application/x-openoffice-locale;windows_formatname=\"Locale\"", "Locale", "Locale", CF_LOCALE, CPPUTYPE_DEFAULT));
286     // SOT_FORMAT_WMF
287     m_TranslTable.push_back(FormatEntry("application/x-openoffice-wmf;windows_formatname=\"Image WMF\"", "Windows MetaFile", "Image WMF", CF_METAFILEPICT, CPPUTYPE_DEFAULT));
288     // SOT_FORMAT_EMF
289     m_TranslTable.push_back(FormatEntry("application/x-openoffice-emf;windows_formatname=\"Image EMF\"", "Windows Enhanced MetaFile", "Image EMF", CF_ENHMETAFILE, CPPUTYPE_DEFAULT));
290     // SOT_FORMAT_FILE_LIST
291     m_TranslTable.push_back(FormatEntry("application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", "FileList", CF_HDROP, CPPUTYPE_DEFAULT));
292     //SOT_FORMATSTR_ID_SYLK
293     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sylk;windows_formatname=\"Sylk\"", "Sylk", "Sylk", CF_SYLK, CPPUTYPE_DEFAULT ) );
294     // SOT_FORMAT_GDIMETAFILE
295     m_TranslTable.push_back(FormatEntry("application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"", "GDIMetaFile", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
296     // SOT_FORMAT_PRIVATE
297     m_TranslTable.push_back(FormatEntry("application/x-openoffice-private;windows_formatname=\"Private\"", "Private", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
298     // SOT_FORMAT_FILE
299     m_TranslTable.push_back(FormatEntry("application/x-openoffice-file;windows_formatname=\"FileName\"", "FileName", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
300     // SOT_FORMAT_RTF
301     m_TranslTable.push_back(FormatEntry("text/richtext", "Rich Text Format", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
302     // SOT_FORMATSTR_ID_DRAWING
303     m_TranslTable.push_back(FormatEntry("application/x-openoffice-drawing;windows_formatname=\"Drawing Format\"", "Drawing Format", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
304     // SOT_FORMATSTR_ID_SVXB
305     m_TranslTable.push_back(FormatEntry("application/x-openoffice-svbx;windows_formatname=\"SVXB (StarView Bitmap/Animation)\"", "SVXB (StarView Bitmap/Animation)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
306     // SOT_FORMATSTR_ID_SVIM
307     m_TranslTable.push_back(FormatEntry("application/x-openoffice-svim;windows_formatname=\"SVIM (StarView ImageMap)\"", "SVIM (StarView ImageMap)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
308     // SOT_FORMATSTR_ID_XFA
309     m_TranslTable.push_back(FormatEntry("application/x-openoffice-xfa;windows_formatname=\"XFA (XOutDev FillAttr)\"", "XFA (XOutDev FillAttr)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
310     // SOT_FORMATSTR_ID_EDITENGINE
311     m_TranslTable.push_back(FormatEntry("application/x-openoffice-editengine;windows_formatname=\"EditEngineFormat\"", "EditEngineFormat", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
312     // SOT_FORMATSTR_ID_INTERNALLINK_STATE
313     m_TranslTable.push_back(FormatEntry("application/x-openoffice-internallink-state;windows_formatname=\"StatusInfo vom SvxInternalLink\"", "StatusInfo vom SvxInternalLink", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
314     // SOT_FORMATSTR_ID_SOLK
315     m_TranslTable.push_back(FormatEntry("application/x-openoffice-solk;windows_formatname=\"SOLK (StarOffice Link)\"", "SOLK (StarOffice Link)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
316     // SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
317     m_TranslTable.push_back(FormatEntry("application/x-openoffice-netscape-bookmark;windows_formatname=\"Netscape Bookmark\"", "Netscape Bookmark", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
318     // SOT_FORMATSTR_ID_TREELISTBOX
319     m_TranslTable.push_back(FormatEntry("application/x-openoffice-treelistbox;windows_formatname=\"SV_LBOX_DD_FORMAT\"", "SV_LBOX_DD_FORMAT", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
320     // SOT_FORMATSTR_ID_NATIVE
321     m_TranslTable.push_back(FormatEntry("application/x-openoffice-native;windows_formatname=\"Native\"", "Native", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
322     // SOT_FORMATSTR_ID_OWNERLINK
323     m_TranslTable.push_back(FormatEntry("application/x-openoffice-ownerlink;windows_formatname=\"OwnerLink\"", "OwnerLink", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
324     // SOT_FORMATSTR_ID_STARSERVER
325     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starserver;windows_formatname=\"StarServerFormat\"", "StarServerFormat", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
326     // SOT_FORMATSTR_ID_STAROBJECT
327     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starobject;windows_formatname=\"StarObjectFormat\"", "StarObjectFormat", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
328     // SOT_FORMATSTR_ID_APPLETOBJECT
329     m_TranslTable.push_back(FormatEntry("application/x-openoffice-appletobject;windows_formatname=\"Applet Object\"", "Applet Object", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
330     // SOT_FORMATSTR_ID_PLUGIN_OBJECT
331     m_TranslTable.push_back(FormatEntry("application/x-openoffice-plugin-object;windows_formatname=\"PlugIn Object\"", "PlugIn Object", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
332     // SOT_FORMATSTR_ID_STARWRITER_30
333     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starwriter-30;windows_formatname=\"StarWriter 3.0\"", "StarWriter 3.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
334     //SOT_FORMATSTR_ID_STARWRITER_40
335     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starwriter-40;windows_formatname=\"StarWriter 4.0\"", "StarWriter 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
336     //SOT_FORMATSTR_ID_STARWRITER_50
337     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starwriter-50;windows_formatname=\"StarWriter 5.0\"", "StarWriter 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
338     //SOT_FORMATSTR_ID_STARWRITERWEB_40
339     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starwriterweb-40;windows_formatname=\"StarWriter/Web 4.0\"", "StarWriter/Web 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
340     //SOT_FORMATSTR_ID_STARWRITERWEB_50
341     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starwriterweb-50;windows_formatname=\"StarWriter/Web 5.0\"", "StarWriter/Web 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
342     //SOT_FORMATSTR_ID_STARWRITERGLOB_40
343     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starwriterglob-40;windows_formatname=\"StarWriter/Global 4.0\"", "StarWriter/Global 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
344     // SOT_FORMATSTR_ID_STARWRITERGLOB_50
345     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starwriterglob-50;windows_formatname=\"StarWriter/Global 5.0\"", "StarWriter/Global 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
346     //SOT_FORMATSTR_ID_STARDRAW
347     m_TranslTable.push_back(FormatEntry("application/x-openoffice-stardraw;windows_formatname=\"StarDrawDocument\"", "StarDrawDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
348     //SOT_FORMATSTR_ID_STARDRAW_40
349     m_TranslTable.push_back(FormatEntry("application/x-openoffice-stardraw-40;windows_formatname=\"StarDrawDocument 4.0\"", "StarDrawDocument 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
350     //SOT_FORMATSTR_ID_STARIMPRESS_50
351     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starimpress-50;windows_formatname=\"StarImpress 5.0\"", "StarImpress 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
352     // SOT_FORMATSTR_ID_STARDRAW_50
353     m_TranslTable.push_back(FormatEntry("application/x-openoffice-stardraw-50;windows_formatname=\"StarDraw 5.0\"", "StarDraw 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
354     //SOT_FORMATSTR_ID_STARCALC
355     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starcalc;windows_formatname=\"StarCalcDocument\"", "StarCalcDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
356     //SOT_FORMATSTR_ID_STARCALC_40
357     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starcalc-40;windows_formatname=\"StarCalc 4.0\"", "StarCalc 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
358     // SOT_FORMATSTR_ID_STARCALC_50
359     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starcalc-50;windows_formatname=\"StarCalc 5.0\"", "StarCalc 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
360     // SOT_FORMATSTR_ID_STARCHART
361     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starchart;windows_formatname=\"StarChartDocument\"", "StarChartDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
362     // SOT_FORMATSTR_ID_STARCHART_40
363     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starchart-40;windows_formatname=\"StarChartDocument 4.0\"", "StarChartDocument 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
364     // SOT_FORMATSTR_ID_STARCHART_50
365     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starchart-50;windows_formatname=\"StarChart 5.0\"", "StarChart 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
366     //SOT_FORMATSTR_ID_STARIMAGE
367     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starimage;windows_formatname=\"StarImageDocument\"", "StarImageDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
368     //SOT_FORMATSTR_ID_STARIMAGE_40
369     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starimage-40;windows_formatname=\"StarImageDocument 4.0\"", "StarImageDocument 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
370     //SOT_FORMATSTR_ID_STARIMAGE_50
371     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starimage-50;windows_formatname=\"StarImage 5.0\"",  "StarImage 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
372     //SOT_FORMATSTR_ID_STARMATH
373     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starmath;windows_formatname=\"StarMath\"", "StarMath", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
374     //SOT_FORMATSTR_ID_STARMATH_40
375     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starmath-40;windows_formatname=\"StarMathDocument 4.0\"", "StarMathDocument 4.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
376     //SOT_FORMATSTR_ID_STARMATH_50
377     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starmath-50;windows_formatname=\"StarMath 5.0\"", "StarMath 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
378     //SOT_FORMATSTR_ID_STAROBJECT_PAINTDOC
379     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starobject-paintdoc;windows_formatname=\"StarObjectPaintDocument\"", "StarObjectPaintDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
380     //SOT_FORMATSTR_ID_FILLED_AREA
381     m_TranslTable.push_back(FormatEntry("application/x-openoffice-filled-area;windows_formatname=\"FilledArea\"", "FilledArea", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
382     //SOT_FORMATSTR_ID_HTML
383     m_TranslTable.push_back(FormatEntry("text/html", "HTML (HyperText Markup Language)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
384     //SOT_FORMATSTR_ID_HTML_SIMPLE
385     m_TranslTable.push_back(FormatEntry("application/x-openoffice-html-simple;windows_formatname=\"HTML Format\"", "HTML Format", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
386     //SOT_FORMATSTR_ID_CHAOS
387     m_TranslTable.push_back(FormatEntry("application/x-openoffice-chaos;windows_formatname=\"FORMAT_CHAOS\"", "FORMAT_CHAOS", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
388     //SOT_FORMATSTR_ID_CNT_MSGATTACHFILE
389     m_TranslTable.push_back(FormatEntry("application/x-openoffice-msgattachfile;windows_formatname=\"CNT_MSGATTACHFILE_FORMAT\"", "CNT_MSGATTACHFILE_FORMAT", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
390     //SOT_FORMATSTR_ID_BIFF_5
391     m_TranslTable.push_back(FormatEntry("application/x-openoffice-biff5;windows_formatname=\"Biff5\"", "Biff5", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
392     //SOT_FORMATSTR_ID_BIFF__5
393     m_TranslTable.push_back(FormatEntry("application/x-openoffice-biff-5;windows_formatname=\"Biff 5\"", "Biff 5", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
394     //SOT_FORMATSTR_ID_BIFF_8
395     m_TranslTable.push_back(FormatEntry("application/x-openoffice-biff-8;windows_formatname=\"Biff8\"", "Biff8", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
396     //SOT_FORMATSTR_ID_SYLK_BIGCAPS
397     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sylk-bigcaps;windows_formatname=\"SYLK\"", "SYLK", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
398     //SOT_FORMATSTR_ID_LINK
399     m_TranslTable.push_back(FormatEntry("application/x-openoffice-link;windows_formatname=\"Link\"", "Link", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
400     //SOT_FORMATSTR_ID_STARDRAW_TABBAR
401     m_TranslTable.push_back(FormatEntry("application/x-openoffice-stardraw-tabbar;windows_formatname=\"StarDraw TabBar\"", "StarDraw TabBar", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
402     //SOT_FORMATSTR_ID_SONLK
403     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sonlk;windows_formatname=\"SONLK (StarOffice Navi Link)\"", "SONLK (StarOffice Navi Link)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
404     //SOT_FORMATSTR_ID_MSWORD_DOC
405     m_TranslTable.push_back(FormatEntry("application/msword", "MSWordDoc", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
406     //SOT_FORMATSTR_ID_STAR_FRAMESET_DOC
407     m_TranslTable.push_back(FormatEntry("application/x-openoffice-star-frameset-doc;windows_formatname=\"StarFrameSetDocument\"", "StarFrameSetDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
408     //SOT_FORMATSTR_ID_OFFICE_DOC
409     m_TranslTable.push_back(FormatEntry("application/x-openoffice-office-doc;windows_formatname=\"OfficeDocument\"", "OfficeDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
410     //SOT_FORMATSTR_ID_NOTES_DOCINFO
411     m_TranslTable.push_back(FormatEntry("application/x-openoffice-notes-docinfo;windows_formatname=\"NotesDocInfo\"", "NotesDocInfo", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
412     //SOT_FORMATSTR_ID_NOTES_HNOTE
413     m_TranslTable.push_back(FormatEntry("application/x-openoffice-notes-hnote;windows_formatname=\"NoteshNote\"", "NoteshNote", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
414     //SOT_FORMATSTR_ID_NOTES_NATIVE
415     m_TranslTable.push_back(FormatEntry("application/x-openoffice-notes-native;windows_formatname=\"Native\"", "Native", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
416     //SOT_FORMATSTR_ID_SFX_DOC
417     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sfx-doc;windows_formatname=\"SfxDocument\"", "SfxDocument", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
418     //SOT_FORMATSTR_ID_EVDF
419     m_TranslTable.push_back(FormatEntry("application/x-openoffice-evdf;windows_formatname=\"EVDF (Explorer View Dummy Format)\"", "EVDF (Explorer View Dummy Format)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
420     //SOT_FORMATSTR_ID_ESDF
421     m_TranslTable.push_back(FormatEntry("application/x-openoffice-esdf;windows_formatname=\"ESDF (Explorer Search Dummy Format)\"", "ESDF (Explorer Search Dummy Format)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
422     //SOT_FORMATSTR_ID_IDF
423     m_TranslTable.push_back(FormatEntry("application/x-openoffice-idf;windows_formatname=\"IDF (Iconview Dummy Format)\"", "IDF (Iconview Dummy Format)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
424     //SOT_FORMATSTR_ID_EFTP
425     m_TranslTable.push_back(FormatEntry("application/x-openoffice-eftp;windows_formatname=\"EFTP (Explorer Ftp File)\"", "EFTP (Explorer Ftp File)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
426     //SOT_FORMATSTR_ID_EFD
427     m_TranslTable.push_back(FormatEntry("application/x-openoffice-efd;windows_formatname=\"EFD (Explorer Ftp Dir)\"", "EFD (Explorer Ftp Dir)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
428     //SOT_FORMATSTR_ID_SVX_FORMFIELDEXCH
429     m_TranslTable.push_back(FormatEntry("application/x-openoffice-svx-formfieldexch;windows_formatname=\"SvxFormFieldExch\"", "SvxFormFieldExch", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
430     //SOT_FORMATSTR_ID_EXTENDED_TABBAR
431     m_TranslTable.push_back(FormatEntry("application/x-openoffice-extended-tabbar;windows_formatname=\"ExtendedTabBar\"", "ExtendedTabBar", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
432     //SOT_FORMATSTR_ID_SBA_DATAEXCHANGE
433     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-dataexchange;windows_formatname=\"SBA-DATAFORMAT\"", "SBA-DATAFORMAT", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
434     //SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE
435     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-fielddataexchange;windows_formatname=\"SBA-FIELDFORMAT\"", "SBA-FIELDFORMAT", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
436     //SOT_FORMATSTR_ID_SBA_PRIVATE_URL
437     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-private-url;windows_formatname=\"SBA-PRIVATEURLFORMAT\"", "SBA-PRIVATEURLFORMAT", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
438     //SOT_FORMATSTR_ID_SBA_TABED
439     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-tabed;windows_formatname=\"Tabed\"", "Tabed", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
440     //SOT_FORMATSTR_ID_SBA_TABID
441     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-tabid;windows_formatname=\"Tabid\"", "Tabid", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
442     //SOT_FORMATSTR_ID_SBA_JOIN
443     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-join;windows_formatname=\"SBA-JOINFORMAT\"", "SBA-JOINFORMAT", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
444     //SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
445     m_TranslTable.push_back(FormatEntry("application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\"", "Star Object Descriptor (XML)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
446     //SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR
447     m_TranslTable.push_back(FormatEntry("application/x-openoffice-linksrcdescriptor-xml;windows_formatname=\"Star Link Source Descriptor (XML)\"", "Star Link Source Descriptor (XML)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
448     //SOT_FORMATSTR_ID_EMBED_SOURCE
449     m_TranslTable.push_back(FormatEntry("application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"", "Star Embed Source (XML)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
450     //SOT_FORMATSTR_ID_LINK_SOURCE
451     m_TranslTable.push_back(FormatEntry("application/x-openoffice-link-source-xml;windows_formatname=\"Star Link Source (XML)\"", "Star Link Source (XML)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
452     //SOT_FORMATSTR_ID_EMBEDDED_OBJ
453     m_TranslTable.push_back(FormatEntry("application/x-openoffice-embedded-obj-xml;windows_formatname=\"Star Embedded Object (XML)\"", "Star Embedded Object (XML)", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
454     //SOT_FORMATSTR_ID_FILECONTENT
455     m_TranslTable.push_back(FormatEntry("application/x-openoffice-filecontent;windows_formatname=\"" CFSTR_FILECONTENTS "\"", CFSTR_FILECONTENTS, NULL, CF_INVALID, CPPUTYPE_DEFAULT));
456     //SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
457     m_TranslTable.push_back(FormatEntry("application/x-openoffice-filegrpdescriptor;windows_formatname=\"" CFSTR_FILEDESCRIPTOR "\"", CFSTR_FILEDESCRIPTOR, NULL, CF_INVALID, CPPUTYPE_DEFAULT));
458     //SOT_FORMATSTR_ID_FILENAME
459     m_TranslTable.push_back(FormatEntry("application/x-openoffice-filename;windows_formatname=\"" CFSTR_FILENAME "\"", CFSTR_FILENAME, NULL, CF_INVALID, CPPUTYPE_DEFAULT));
460     //SOT_FORMATSTR_ID_SD_OLE
461     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sd-ole;windows_formatname=\"SD-OLE\"", "SD-OLE", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
462     //SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
463     m_TranslTable.push_back(FormatEntry("application/x-openoffice-embedded-obj-ole;windows_formatname=\"Embedded Object\"", "Embedded Object", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
464     //SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
465     m_TranslTable.push_back(FormatEntry("application/x-openoffice-embed-source-ole;windows_formatname=\"Embed Source\"", "Embed Source", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
466     //SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE
467     m_TranslTable.push_back(FormatEntry("application/x-openoffice-objectdescriptor-ole;windows_formatname=\"Object Descriptor\"", "Object Descriptor", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
468     //SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR_OLE
469     m_TranslTable.push_back(FormatEntry("application/x-openoffice-linkdescriptor-ole;windows_formatname=\"Link Source Descriptor\"", "Link Source Descriptor", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
470     //SOT_FORMATSTR_ID_LINK_SOURCE_OLE
471     m_TranslTable.push_back(FormatEntry("application/x-openoffice-link-source-ole;windows_formatname=\"Link Source\"", "Link Source", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
472     //SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE
473     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-ctrldataexchange;windows_formatname=\"SBA-CTRLFORMAT\"", "SBA-CTRLFORMAT", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
474     //SOT_FORMATSTR_ID_OUTPLACE_OBJ
475     m_TranslTable.push_back(FormatEntry("application/x-openoffice-outplace-obj;windows_formatname=\"OutPlace Object\"", "OutPlace Object", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
476     //SOT_FORMATSTR_ID_CNT_OWN_CLIP
477     m_TranslTable.push_back(FormatEntry("application/x-openoffice-cnt-own-clip;windows_formatname=\"CntOwnClipboard\"", "CntOwnClipboard", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
478     //SOT_FORMATSTR_ID_INET_IMAGE
479     m_TranslTable.push_back(FormatEntry("application/x-openoffice-inet-image;windows_formatname=\"SO-INet-Image\"", "SO-INet-Image", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
480     //SOT_FORMATSTR_ID_NETSCAPE_IMAGE
481     m_TranslTable.push_back(FormatEntry("application/x-openoffice-netscape-image;windows_formatname=\"Netscape Image Format\"", "Netscape Image Format", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
482     //SOT_FORMATSTR_ID_SBA_FORMEXCHANGE
483     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-formexchange;windows_formatname=\"SBA_FORMEXCHANGE\"", "SBA_FORMEXCHANGE", NULL, CF_INVALID, CPPUTYPE_DEFAULT));  //SOT_FORMATSTR_ID_SBA_REPORTEXCHANGE
484     m_TranslTable.push_back(FormatEntry("application/x-openoffice-sba-reportexchange;windows_formatname=\"SBA_REPORTEXCHANGE\"", "SBA_REPORTEXCHANGE", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
485     //SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
486     m_TranslTable.push_back(FormatEntry("application/x-openoffice-uniformresourcelocator;windows_formatname=\"UniformResourceLocator\"", "UniformResourceLocator", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
487     //SOT_FORMATSTR_ID_STARCHARTDOCUMENT_50
488     m_TranslTable.push_back(FormatEntry("application/x-openoffice-starchartdocument-50;windows_formatname=\"StarChartDocument 5.0\"", "StarChartDocument 5.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
489     //SOT_FORMATSTR_ID_GRAPHOBJ
490     m_TranslTable.push_back(FormatEntry("application/x-openoffice-graphobj;windows_formatname=\"Graphic Object\"", "Graphic Object", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
491     //SOT_FORMATSTR_ID_STARWRITER_60
492     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.writer", "Writer 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
493     //SOT_FORMATSTR_ID_STARWRITERWEB_60
494     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.writer.web", "Writer/Web 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
495     //SOT_FORMATSTR_ID_STARWRITERGLOB_60
496     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.writer.global", "Writer/Global 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
497     //SOT_FORMATSTR_ID_STARWDRAW_60
498     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.draw", "Draw 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
499     //SOT_FORMATSTR_ID_STARIMPRESS_60
500     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.impress", "Impress 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
501     //SOT_FORMATSTR_ID_STARCALC_60
502     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.calc", "Calc 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
503     //SOT_FORMATSTR_ID_STARCHART_60
504     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.chart", "Chart 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
505     //SOT_FORMATSTR_ID_STARMATH_60
506     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.math", "Math 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
507     //SOT_FORMATSTR_ID_DIALOG_60
508     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.dialog", "Dialog 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
509     //SOT_FORMATSTR_ID_BMP
510     m_TranslTable.push_back(FormatEntry("image/bmp", "Windows Bitmap", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
511     //SOT_FORMATSTR_ID_PNG
512     m_TranslTable.push_back(FormatEntry("image/png", "PNG", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
513     //SOT_FORMATSTR_ID_DUMMY3
514     m_TranslTable.push_back(FormatEntry("application/x-openoffice-dummy3;windows_formatname=\"SO_DUMMYFORMAT_3\"", "SO_DUMMYFORMAT_3", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
515     //SOT_FORMATSTR_ID_DUMMY4
516     m_TranslTable.push_back(FormatEntry("application/x-openoffice-dummy4;windows_formatname=\"SO_DUMMYFORMAT_4\"", "SO_DUMMYFORMAT_4", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
517 }
518 
519 // -------------------------------------------------
520 //
521 // -------------------------------------------------
522 
523 void SAL_CALL CDataFormatTranslator::findDataFlavorForStandardFormatId( sal_Int32 aStandardFormatId, DataFlavor& aDataFlavor ) const
524 {
525     /*
526         we break the for loop if we find the first CF_INVALID
527         because in the translation table the entries with a
528         standard clipboard format id appear before the other
529         entries with CF_INVALID
530     */
531     vector< FormatEntry >::const_iterator citer_end = m_TranslTable.end( );
532     for ( vector< FormatEntry >::const_iterator citer = m_TranslTable.begin( ); citer != citer_end; ++citer )
533     {
534         sal_Int32 stdId = citer->aStandardFormatId;
535         if ( aStandardFormatId == stdId )
536         {
537             aDataFlavor = citer->aDataFlavor;
538             break;
539         }
540         else if ( stdId == CF_INVALID )
541             break;
542     }
543 }
544 
545 // -------------------------------------------------
546 //
547 // -------------------------------------------------
548 
549 void SAL_CALL CDataFormatTranslator::findDataFlavorForNativeFormatName( const OUString& aNativeFormatName, DataFlavor& aDataFlavor ) const
550 {
551     vector< FormatEntry >::const_iterator citer_end = m_TranslTable.end( );
552     for ( vector< FormatEntry >::const_iterator citer = m_TranslTable.begin( );
553           citer != citer_end;
554           ++citer )
555     {
556         if ( aNativeFormatName.equalsIgnoreAsciiCase( citer->aNativeFormatName ) )
557         {
558             aDataFlavor = citer->aDataFlavor;
559             break;
560         }
561     }
562 }
563 
564 // -------------------------------------------------
565 //
566 // -------------------------------------------------
567 
568 void SAL_CALL CDataFormatTranslator::findStandardFormatIdForCharset( const OUString& aCharset, Any& aAny ) const
569 {
570     if ( aCharset.equalsIgnoreAsciiCase( OUSTR( utf-16 ) ) )
571         aAny <<= static_cast< sal_Int32 >( CF_UNICODETEXT );
572     else
573     {
574         sal_Int32 wincp = getWinCPFromMimeCharset( aCharset );
575         if ( IsOEMCP ( wincp ) )
576             aAny <<= static_cast< sal_Int32 >( CF_OEMTEXT );
577     }
578 }
579 
580 // -------------------------------------------------
581 //
582 // -------------------------------------------------
583 
584 void SAL_CALL CDataFormatTranslator::setStandardFormatIdForNativeFormatName( const OUString& aNativeFormatName, Any& aAny ) const
585 {
586     vector< FormatEntry >::const_iterator citer_end = m_TranslTable.end( );
587     for ( vector< FormatEntry >::const_iterator citer = m_TranslTable.begin( ); citer != citer_end; ++citer )
588     {
589         if ( aNativeFormatName.equalsIgnoreAsciiCase( citer->aNativeFormatName ) &&
590              (CF_INVALID != citer->aStandardFormatId) )
591         {
592             aAny <<= citer->aStandardFormatId;
593             break;
594         }
595     }
596 }
597 
598 // -------------------------------------------------
599 //
600 // -------------------------------------------------
601 
602 void SAL_CALL CDataFormatTranslator::findStdFormatIdOrNativeFormatNameForFullMediaType(
603     const Reference< XMimeContentTypeFactory >& aRefXMimeFactory,
604     const OUString& aFullMediaType,
605     Any& aAny ) const
606 {
607     vector< FormatEntry >::const_iterator citer_end = m_TranslTable.end( );
608     for ( vector< FormatEntry >::const_iterator citer = m_TranslTable.begin( ); citer != citer_end; ++citer )
609     {
610         Reference< XMimeContentType >
611         refXMime( aRefXMimeFactory->createMimeContentType( citer->aDataFlavor.MimeType ) );
612         if ( aFullMediaType.equalsIgnoreAsciiCase( refXMime->getFullMediaType( ) ) )
613         {
614             sal_Int32 cf = citer->aStandardFormatId;
615             if ( CF_INVALID != cf )
616                 aAny <<= cf;
617             else
618             {
619                 OSL_ENSURE( citer->aNativeFormatName.getLength( ),
620                     "Invalid standard format id and empty native format name in translation table" );
621                 aAny <<= citer->aNativeFormatName;
622             }
623             break;
624         }
625     }
626 }
627 
628 // -------------------------------------------------
629 //
630 // -------------------------------------------------
631 
632 inline sal_Bool CDataFormatTranslator::isTextPlainMediaType( const OUString& fullMediaType ) const
633 {
634     return (fullMediaType.equalsIgnoreAsciiCase(OUSTR(text/plain)));
635 }
636 
637 // -------------------------------------------------
638 //
639 // -------------------------------------------------
640 
641 DataFlavor SAL_CALL CDataFormatTranslator::mkDataFlv(const OUString& cnttype, const OUString& hpname, Type dtype)
642 {
643     DataFlavor dflv;
644     dflv.MimeType             = cnttype;
645     dflv.HumanPresentableName = hpname;
646     dflv.DataType             = dtype;
647     return dflv;
648 }
649