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