1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <osl/diagnose.h>
22 #include "ftransl.hxx"
23 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
24 #include <com/sun/star/datatransfer/MimeContentTypeFactory.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include "../misc/ImplHelper.hxx"
29 #pragma warning(push,1)
30 #pragma warning(disable:4917)
37 #define IMPL_NAME "com.sun.star.datatransfer.DataFormatTranslator"
39 #define MODULE_PRIVATE
40 #define CPPUTYPE_SEQSALINT8 getCppuType( (const Sequence< sal_Int8 >*) 0 )
41 #define CPPUTYPE_DEFAULT CPPUTYPE_SEQSALINT8
42 #define CPPUTYPE_OUSTR getCppuType( (const OUString*) 0 )
43 #define CPPUTYPE_SALINT32 getCppuType( ( sal_Int32 * ) 0 )
44 #define EMPTY_OUSTR OUString()
46 const OUString
Windows_FormatName ("windows_formatname");
47 const com::sun::star::uno::Type CppuType_ByteSequence
= ::getCppuType((const com::sun::star::uno::Sequence
<sal_Int8
>*)0);
48 const com::sun::star::uno::Type CppuType_String
= ::getCppuType((const OUString
*)0);
50 //------------------------------------------------------------------------
51 // namespace directives
52 //------------------------------------------------------------------------
57 using namespace com::sun::star::uno
;
58 using namespace com::sun::star::lang
;
59 using namespace com::sun::star::datatransfer
;
60 using namespace com::sun::star::container
;
62 //------------------------------------------------------------------------
64 //------------------------------------------------------------------------
66 namespace MODULE_PRIVATE
68 Sequence
< OUString
> SAL_CALL
DataFormatTranslator_getSupportedServiceNames( )
70 Sequence
< OUString
> aRet(1);
71 aRet
[0] = OUString("com.sun.star.datatransfer.DataFormatTranslator");
76 //------------------------------------------------
78 //------------------------------------------------
80 FormatEntry::FormatEntry()
84 //------------------------------------------------
86 //------------------------------------------------
88 FormatEntry::FormatEntry(
89 const char* mime_content_type
,
90 const char* human_presentable_name
,
91 const char* native_format_name
,
92 CLIPFORMAT std_clipboard_format_id
,
93 ::com::sun::star::uno::Type
const & cppu_type
)
95 aDataFlavor
.MimeType
= OUString::createFromAscii(mime_content_type
);
96 aDataFlavor
.HumanPresentableName
= OUString::createFromAscii(human_presentable_name
);
97 aDataFlavor
.DataType
= cppu_type
;
99 if (native_format_name
)
100 aNativeFormatName
= OUString::createFromAscii(native_format_name
);
102 aNativeFormatName
= OUString::createFromAscii(human_presentable_name
);
104 aStandardFormatId
= std_clipboard_format_id
;
107 //------------------------------------------------------------------------
109 //------------------------------------------------------------------------
111 CDataFormatTranslator::CDataFormatTranslator( const Reference
< XComponentContext
>& rxContext
) :
112 m_xContext( rxContext
)
114 initTranslationTable( );
117 //------------------------------------------------------------------------
119 //------------------------------------------------------------------------
121 Any SAL_CALL
CDataFormatTranslator::getSystemDataTypeFromDataFlavor( const DataFlavor
& aDataFlavor
)
122 throw( RuntimeException
)
128 Reference
< XMimeContentTypeFactory
> refXMimeCntFactory
= MimeContentTypeFactory::create( m_xContext
);
130 Reference
< XMimeContentType
>
131 refXMimeCntType( refXMimeCntFactory
->createMimeContentType( aDataFlavor
.MimeType
) );
133 OUString fullMediaType
= refXMimeCntType
->getFullMediaType( );
134 if ( isTextPlainMediaType( fullMediaType
) )
136 // default is CF_TEXT
137 aAny
<<= static_cast< sal_Int32
>( CF_TEXT
);
139 if ( refXMimeCntType
->hasParameter( "charset" ) )
141 // but maybe it is unicode text or oem text
142 OUString charset
= refXMimeCntType
->getParameterValue( "charset" );
143 findStandardFormatIdForCharset( charset
, aAny
);
148 if (refXMimeCntType
->hasParameter(Windows_FormatName
))
150 OUString winfmtname
= refXMimeCntType
->getParameterValue(Windows_FormatName
);
153 setStandardFormatIdForNativeFormatName( winfmtname
, aAny
);
156 findStdFormatIdOrNativeFormatNameForFullMediaType( refXMimeCntFactory
, fullMediaType
, aAny
);
159 catch( IllegalArgumentException
& )
161 OSL_FAIL( "Invalid content-type detected!" );
163 catch( NoSuchElementException
& )
165 OSL_FAIL( "Illegal content-type parameter" );
169 OSL_FAIL( "Unexpected error" );
176 //------------------------------------------------------------------------
178 //------------------------------------------------------------------------
180 DataFlavor SAL_CALL
CDataFormatTranslator::getDataFlavorFromSystemDataType( const Any
& aSysDataType
)
181 throw( RuntimeException
)
183 OSL_PRECOND( aSysDataType
.hasValue( ), "Empty system data type delivered" );
185 DataFlavor aFlavor
= mkDataFlv( EMPTY_OUSTR
, EMPTY_OUSTR
, CPPUTYPE_SEQSALINT8
);
187 if ( aSysDataType
.getValueType( ) == CPPUTYPE_SALINT32
)
189 sal_Int32 clipformat
= CF_INVALID
;
190 aSysDataType
>>= clipformat
;
191 if ( CF_INVALID
!= clipformat
)
192 findDataFlavorForStandardFormatId( clipformat
, aFlavor
);
194 else if ( aSysDataType
.getValueType( ) == CPPUTYPE_OUSTR
)
196 OUString nativeFormatName
;
197 aSysDataType
>>= nativeFormatName
;
199 findDataFlavorForNativeFormatName( nativeFormatName
, aFlavor
);
202 OSL_FAIL( "Invalid data type received" );
207 // -------------------------------------------------
209 // -------------------------------------------------
211 OUString SAL_CALL
CDataFormatTranslator::getImplementationName( )
212 throw( RuntimeException
)
214 return OUString( IMPL_NAME
);
217 // -------------------------------------------------
219 // -------------------------------------------------
221 sal_Bool SAL_CALL
CDataFormatTranslator::supportsService( const OUString
& ServiceName
)
222 throw( RuntimeException
)
224 Sequence
< OUString
> SupportedServicesNames
= DataFormatTranslator_getSupportedServiceNames();
226 for ( sal_Int32 n
= SupportedServicesNames
.getLength(); n
--; )
227 if ( SupportedServicesNames
[n
] == ServiceName
)
233 // -------------------------------------------------
235 // -------------------------------------------------
237 Sequence
< OUString
> SAL_CALL
CDataFormatTranslator::getSupportedServiceNames( )
238 throw( RuntimeException
)
240 return DataFormatTranslator_getSupportedServiceNames( );
243 // -------------------------------------------------
244 // to optimize searching we add all entries with a
245 // standard clipboard format number first, in the
246 // table before the entries with CF_INVALID
247 // if we are searching for a standard clipboard
248 // format number we can stop if we find the first
250 // -------------------------------------------------
252 void SAL_CALL
CDataFormatTranslator::initTranslationTable()
254 //SOT_FORMATSTR_ID_DIF
255 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-dif;windows_formatname=\"DIF\"", "DIF", "DIF", CF_DIF
, CPPUTYPE_DEFAULT
));
257 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_DIB
, CPPUTYPE_DEFAULT
));
258 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_BITMAP
, CPPUTYPE_DEFAULT
));
260 m_TranslTable
.push_back(FormatEntry("text/plain;charset=utf-16", "Unicode-Text", "", CF_UNICODETEXT
, CppuType_String
));
261 // Format Locale - for internal use
262 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-locale;windows_formatname=\"Locale\"", "Locale", "Locale", CF_LOCALE
, CPPUTYPE_DEFAULT
));
264 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-wmf;windows_formatname=\"Image WMF\"", "Windows MetaFile", "Image WMF", CF_METAFILEPICT
, CPPUTYPE_DEFAULT
));
266 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-emf;windows_formatname=\"Image EMF\"", "Windows Enhanced MetaFile", "Image EMF", CF_ENHMETAFILE
, CPPUTYPE_DEFAULT
));
267 // SOT_FORMAT_FILE_LIST
268 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", "FileList", CF_HDROP
, CPPUTYPE_DEFAULT
));
269 //SOT_FORMATSTR_ID_SYLK
270 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sylk;windows_formatname=\"Sylk\"", "Sylk", "Sylk", CF_SYLK
, CPPUTYPE_DEFAULT
) );
271 // SOT_FORMAT_GDIMETAFILE
272 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"", "GDIMetaFile", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
273 // SOT_FORMAT_PRIVATE
274 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-private;windows_formatname=\"Private\"", "Private", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
276 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-file;windows_formatname=\"FileName\"", "FileName", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
278 m_TranslTable
.push_back(FormatEntry("text/richtext", "Rich Text Format", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
279 // SOT_FORMATSTR_ID_DRAWING
280 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-drawing;windows_formatname=\"Drawing Format\"", "Drawing Format", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
281 // SOT_FORMATSTR_ID_SVXB
282 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-svbx;windows_formatname=\"SVXB (StarView Bitmap/Animation)\"", "SVXB (StarView Bitmap/Animation)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
283 // SOT_FORMATSTR_ID_SVIM
284 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-svim;windows_formatname=\"SVIM (StarView ImageMap)\"", "SVIM (StarView ImageMap)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
285 // SOT_FORMATSTR_ID_XFA
286 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-xfa;windows_formatname=\"XFA (XOutDev FillAttr)\"", "XFA (XOutDev FillAttr)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
287 // SOT_FORMATSTR_ID_EDITENGINE
288 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-editengine;windows_formatname=\"EditEngineFormat\"", "EditEngineFormat", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
289 // SOT_FORMATSTR_ID_INTERNALLINK_STATE
290 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-internallink-state;windows_formatname=\"StatusInfo vom SvxInternalLink\"", "StatusInfo vom SvxInternalLink", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
291 // SOT_FORMATSTR_ID_SOLK
292 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-solk;windows_formatname=\"SOLK (StarOffice Link)\"", "SOLK (StarOffice Link)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
293 // SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
294 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-netscape-bookmark;windows_formatname=\"Netscape Bookmark\"", "Netscape Bookmark", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
295 // SOT_FORMATSTR_ID_TREELISTBOX
296 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-treelistbox;windows_formatname=\"SV_LBOX_DD_FORMAT\"", "SV_LBOX_DD_FORMAT", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
297 // SOT_FORMATSTR_ID_NATIVE
298 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-native;windows_formatname=\"Native\"", "Native", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
299 // SOT_FORMATSTR_ID_OWNERLINK
300 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-ownerlink;windows_formatname=\"OwnerLink\"", "OwnerLink", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
301 // SOT_FORMATSTR_ID_STARSERVER
302 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starserver;windows_formatname=\"StarServerFormat\"", "StarServerFormat", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
303 // SOT_FORMATSTR_ID_STAROBJECT
304 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starobject;windows_formatname=\"StarObjectFormat\"", "StarObjectFormat", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
305 // SOT_FORMATSTR_ID_APPLETOBJECT
306 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-appletobject;windows_formatname=\"Applet Object\"", "Applet Object", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
307 // SOT_FORMATSTR_ID_PLUGIN_OBJECT
308 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-plugin-object;windows_formatname=\"PlugIn Object\"", "PlugIn Object", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
309 // SOT_FORMATSTR_ID_STARWRITER_30
310 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starwriter-30;windows_formatname=\"StarWriter 3.0\"", "StarWriter 3.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
311 //SOT_FORMATSTR_ID_STARWRITER_40
312 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starwriter-40;windows_formatname=\"StarWriter 4.0\"", "StarWriter 4.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
313 //SOT_FORMATSTR_ID_STARWRITER_50
314 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starwriter-50;windows_formatname=\"StarWriter 5.0\"", "StarWriter 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
315 //SOT_FORMATSTR_ID_STARWRITERWEB_40
316 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
));
317 //SOT_FORMATSTR_ID_STARWRITERWEB_50
318 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
));
319 //SOT_FORMATSTR_ID_STARWRITERGLOB_40
320 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
));
321 // SOT_FORMATSTR_ID_STARWRITERGLOB_50
322 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
));
323 //SOT_FORMATSTR_ID_STARDRAW
324 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-stardraw;windows_formatname=\"StarDrawDocument\"", "StarDrawDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
325 //SOT_FORMATSTR_ID_STARDRAW_40
326 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-stardraw-40;windows_formatname=\"StarDrawDocument 4.0\"", "StarDrawDocument 4.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
327 //SOT_FORMATSTR_ID_STARIMPRESS_50
328 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starimpress-50;windows_formatname=\"StarImpress 5.0\"", "StarImpress 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
329 // SOT_FORMATSTR_ID_STARDRAW_50
330 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-stardraw-50;windows_formatname=\"StarDraw 5.0\"", "StarDraw 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
331 //SOT_FORMATSTR_ID_STARCALC
332 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starcalc;windows_formatname=\"StarCalcDocument\"", "StarCalcDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
333 //SOT_FORMATSTR_ID_STARCALC_40
334 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starcalc-40;windows_formatname=\"StarCalc 4.0\"", "StarCalc 4.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
335 // SOT_FORMATSTR_ID_STARCALC_50
336 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starcalc-50;windows_formatname=\"StarCalc 5.0\"", "StarCalc 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
337 // SOT_FORMATSTR_ID_STARCHART
338 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starchart;windows_formatname=\"StarChartDocument\"", "StarChartDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
339 // SOT_FORMATSTR_ID_STARCHART_40
340 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starchart-40;windows_formatname=\"StarChartDocument 4.0\"", "StarChartDocument 4.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
341 // SOT_FORMATSTR_ID_STARCHART_50
342 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starchart-50;windows_formatname=\"StarChart 5.0\"", "StarChart 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
343 //SOT_FORMATSTR_ID_STARIMAGE
344 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starimage;windows_formatname=\"StarImageDocument\"", "StarImageDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
345 //SOT_FORMATSTR_ID_STARIMAGE_40
346 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starimage-40;windows_formatname=\"StarImageDocument 4.0\"", "StarImageDocument 4.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
347 //SOT_FORMATSTR_ID_STARIMAGE_50
348 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starimage-50;windows_formatname=\"StarImage 5.0\"", "StarImage 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
349 //SOT_FORMATSTR_ID_STARMATH
350 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starmath;windows_formatname=\"StarMath\"", "StarMath", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
351 //SOT_FORMATSTR_ID_STARMATH_40
352 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starmath-40;windows_formatname=\"StarMathDocument 4.0\"", "StarMathDocument 4.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
353 //SOT_FORMATSTR_ID_STARMATH_50
354 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starmath-50;windows_formatname=\"StarMath 5.0\"", "StarMath 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
355 //SOT_FORMATSTR_ID_STAROBJECT_PAINTDOC
356 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starobject-paintdoc;windows_formatname=\"StarObjectPaintDocument\"", "StarObjectPaintDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
357 //SOT_FORMATSTR_ID_FILLED_AREA
358 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-filled-area;windows_formatname=\"FilledArea\"", "FilledArea", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
359 //SOT_FORMATSTR_ID_HTML
360 m_TranslTable
.push_back(FormatEntry("text/html", "HTML (HyperText Markup Language)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
361 //SOT_FORMATSTR_ID_HTML_SIMPLE
362 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-html-simple;windows_formatname=\"HTML Format\"", "HTML Format", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
363 //SOT_FORMATSTR_ID_CHAOS
364 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-chaos;windows_formatname=\"FORMAT_CHAOS\"", "FORMAT_CHAOS", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
365 //SOT_FORMATSTR_ID_CNT_MSGATTACHFILE
366 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-msgattachfile;windows_formatname=\"CNT_MSGATTACHFILE_FORMAT\"", "CNT_MSGATTACHFILE_FORMAT", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
367 //SOT_FORMATSTR_ID_BIFF_5
368 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-biff5;windows_formatname=\"Biff5\"", "Biff5", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
369 //SOT_FORMATSTR_ID_BIFF__5
370 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-biff-5;windows_formatname=\"Biff 5\"", "Biff 5", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
371 //SOT_FORMATSTR_ID_BIFF_8
372 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-biff-8;windows_formatname=\"Biff8\"", "Biff8", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
373 //SOT_FORMATSTR_ID_SYLK_BIGCAPS
374 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sylk-bigcaps;windows_formatname=\"SYLK\"", "SYLK", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
375 //SOT_FORMATSTR_ID_LINK
376 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-link;windows_formatname=\"Link\"", "Link", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
377 //SOT_FORMATSTR_ID_STARDRAW_TABBAR
378 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-stardraw-tabbar;windows_formatname=\"StarDraw TabBar\"", "StarDraw TabBar", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
379 //SOT_FORMATSTR_ID_SONLK
380 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sonlk;windows_formatname=\"SONLK (StarOffice Navi Link)\"", "SONLK (StarOffice Navi Link)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
381 //SOT_FORMATSTR_ID_MSWORD_DOC
382 m_TranslTable
.push_back(FormatEntry("application/msword", "MSWordDoc", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
383 //SOT_FORMATSTR_ID_STAR_FRAMESET_DOC
384 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-star-frameset-doc;windows_formatname=\"StarFrameSetDocument\"", "StarFrameSetDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
385 //SOT_FORMATSTR_ID_OFFICE_DOC
386 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-office-doc;windows_formatname=\"OfficeDocument\"", "OfficeDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
387 //SOT_FORMATSTR_ID_NOTES_DOCINFO
388 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-notes-docinfo;windows_formatname=\"NotesDocInfo\"", "NotesDocInfo", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
389 //SOT_FORMATSTR_ID_NOTES_HNOTE
390 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-notes-hnote;windows_formatname=\"NoteshNote\"", "NoteshNote", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
391 //SOT_FORMATSTR_ID_NOTES_NATIVE
392 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-notes-native;windows_formatname=\"Native\"", "Native", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
393 //SOT_FORMATSTR_ID_SFX_DOC
394 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sfx-doc;windows_formatname=\"SfxDocument\"", "SfxDocument", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
395 //SOT_FORMATSTR_ID_EVDF
396 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
));
397 //SOT_FORMATSTR_ID_ESDF
398 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
));
399 //SOT_FORMATSTR_ID_IDF
400 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-idf;windows_formatname=\"IDF (Iconview Dummy Format)\"", "IDF (Iconview Dummy Format)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
401 //SOT_FORMATSTR_ID_EFTP
402 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-eftp;windows_formatname=\"EFTP (Explorer Ftp File)\"", "EFTP (Explorer Ftp File)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
403 //SOT_FORMATSTR_ID_EFD
404 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-efd;windows_formatname=\"EFD (Explorer Ftp Dir)\"", "EFD (Explorer Ftp Dir)", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
405 //SOT_FORMATSTR_ID_SVX_FORMFIELDEXCH
406 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-svx-formfieldexch;windows_formatname=\"SvxFormFieldExch\"", "SvxFormFieldExch", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
407 //SOT_FORMATSTR_ID_EXTENDED_TABBAR
408 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-extended-tabbar;windows_formatname=\"ExtendedTabBar\"", "ExtendedTabBar", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
409 //SOT_FORMATSTR_ID_SBA_DATAEXCHANGE
410 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-dataexchange;windows_formatname=\"SBA-DATAFORMAT\"", "SBA-DATAFORMAT", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
411 //SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE
412 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-fielddataexchange;windows_formatname=\"SBA-FIELDFORMAT\"", "SBA-FIELDFORMAT", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
413 //SOT_FORMATSTR_ID_SBA_PRIVATE_URL
414 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-private-url;windows_formatname=\"SBA-PRIVATEURLFORMAT\"", "SBA-PRIVATEURLFORMAT", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
415 //SOT_FORMATSTR_ID_SBA_TABED
416 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-tabed;windows_formatname=\"Tabed\"", "Tabed", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
417 //SOT_FORMATSTR_ID_SBA_TABID
418 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-tabid;windows_formatname=\"Tabid\"", "Tabid", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
419 //SOT_FORMATSTR_ID_SBA_JOIN
420 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-join;windows_formatname=\"SBA-JOINFORMAT\"", "SBA-JOINFORMAT", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
421 //SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
422 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
));
423 //SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR
424 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
));
425 //SOT_FORMATSTR_ID_EMBED_SOURCE
426 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
));
427 //SOT_FORMATSTR_ID_LINK_SOURCE
428 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
));
429 //SOT_FORMATSTR_ID_EMBEDDED_OBJ
430 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
));
431 //SOT_FORMATSTR_ID_FILECONTENT
432 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-filecontent;windows_formatname=\"" CFSTR_FILECONTENTS
"\"", CFSTR_FILECONTENTS
, NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
433 //SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
434 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-filegrpdescriptor;windows_formatname=\"" CFSTR_FILEDESCRIPTOR
"\"", CFSTR_FILEDESCRIPTOR
, NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
435 //SOT_FORMATSTR_ID_FILENAME
436 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-filename;windows_formatname=\"" CFSTR_FILENAME
"\"", CFSTR_FILENAME
, NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
437 //SOT_FORMATSTR_ID_SD_OLE
438 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sd-ole;windows_formatname=\"SD-OLE\"", "SD-OLE", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
439 //SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
440 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-embedded-obj-ole;windows_formatname=\"Embedded Object\"", "Embedded Object", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
441 //SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
442 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-embed-source-ole;windows_formatname=\"Embed Source\"", "Embed Source", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
443 //SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE
444 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-objectdescriptor-ole;windows_formatname=\"Object Descriptor\"", "Object Descriptor", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
445 //SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR_OLE
446 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-linkdescriptor-ole;windows_formatname=\"Link Source Descriptor\"", "Link Source Descriptor", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
447 //SOT_FORMATSTR_ID_LINK_SOURCE_OLE
448 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-link-source-ole;windows_formatname=\"Link Source\"", "Link Source", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
449 //SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE
450 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-ctrldataexchange;windows_formatname=\"SBA-CTRLFORMAT\"", "SBA-CTRLFORMAT", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
451 //SOT_FORMATSTR_ID_OUTPLACE_OBJ
452 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-outplace-obj;windows_formatname=\"OutPlace Object\"", "OutPlace Object", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
453 //SOT_FORMATSTR_ID_CNT_OWN_CLIP
454 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-cnt-own-clip;windows_formatname=\"CntOwnClipboard\"", "CntOwnClipboard", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
455 //SOT_FORMATSTR_ID_INET_IMAGE
456 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-inet-image;windows_formatname=\"SO-INet-Image\"", "SO-INet-Image", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
457 //SOT_FORMATSTR_ID_NETSCAPE_IMAGE
458 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-netscape-image;windows_formatname=\"Netscape Image Format\"", "Netscape Image Format", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
459 //SOT_FORMATSTR_ID_SBA_FORMEXCHANGE
460 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
461 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-sba-reportexchange;windows_formatname=\"SBA_REPORTEXCHANGE\"", "SBA_REPORTEXCHANGE", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
462 //SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
463 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-uniformresourcelocator;windows_formatname=\"UniformResourceLocator\"", "UniformResourceLocator", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
464 //SOT_FORMATSTR_ID_STARCHARTDOCUMENT_50
465 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-starchartdocument-50;windows_formatname=\"StarChartDocument 5.0\"", "StarChartDocument 5.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
466 //SOT_FORMATSTR_ID_GRAPHOBJ
467 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-graphobj;windows_formatname=\"Graphic Object\"", "Graphic Object", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
468 //SOT_FORMATSTR_ID_STARWRITER_60
469 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.writer", "Writer 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
470 //SOT_FORMATSTR_ID_STARWRITERWEB_60
471 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.writer.web", "Writer/Web 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
472 //SOT_FORMATSTR_ID_STARWRITERGLOB_60
473 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.writer.global", "Writer/Global 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
474 //SOT_FORMATSTR_ID_STARWDRAW_60
475 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.draw", "Draw 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
476 //SOT_FORMATSTR_ID_STARIMPRESS_60
477 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.impress", "Impress 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
478 //SOT_FORMATSTR_ID_STARCALC_60
479 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.calc", "Calc 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
480 //SOT_FORMATSTR_ID_STARCHART_60
481 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.chart", "Chart 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
482 //SOT_FORMATSTR_ID_STARMATH_60
483 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.math", "Math 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
484 //SOT_FORMATSTR_ID_DIALOG_60
485 m_TranslTable
.push_back(FormatEntry("application/vnd.sun.xml.dialog", "Dialog 6.0", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
486 //SOT_FORMATSTR_ID_BMP
487 m_TranslTable
.push_back(FormatEntry("image/bmp", "Windows Bitmap", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
488 //SOT_FORMATSTR_ID_DUMMY3
489 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-dummy3;windows_formatname=\"SO_DUMMYFORMAT_3\"", "SO_DUMMYFORMAT_3", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
490 //SOT_FORMATSTR_ID_DUMMY4
491 m_TranslTable
.push_back(FormatEntry("application/x-openoffice-dummy4;windows_formatname=\"SO_DUMMYFORMAT_4\"", "SO_DUMMYFORMAT_4", NULL
, CF_INVALID
, CPPUTYPE_DEFAULT
));
494 // -------------------------------------------------
496 // -------------------------------------------------
498 void SAL_CALL
CDataFormatTranslator::findDataFlavorForStandardFormatId( sal_Int32 aStandardFormatId
, DataFlavor
& aDataFlavor
) const
501 we break the for loop if we find the first CF_INVALID
502 because in the translation table the entries with a
503 standard clipboard format id appear before the other
504 entries with CF_INVALID
506 vector
< FormatEntry
>::const_iterator citer_end
= m_TranslTable
.end( );
507 for ( vector
< FormatEntry
>::const_iterator citer
= m_TranslTable
.begin( ); citer
!= citer_end
; ++citer
)
509 sal_Int32 stdId
= citer
->aStandardFormatId
;
510 if ( aStandardFormatId
== stdId
)
512 aDataFlavor
= citer
->aDataFlavor
;
515 else if ( stdId
== CF_INVALID
)
520 // -------------------------------------------------
522 // -------------------------------------------------
524 void SAL_CALL
CDataFormatTranslator::findDataFlavorForNativeFormatName( const OUString
& aNativeFormatName
, DataFlavor
& aDataFlavor
) const
526 vector
< FormatEntry
>::const_iterator citer_end
= m_TranslTable
.end( );
527 for ( vector
< FormatEntry
>::const_iterator citer
= m_TranslTable
.begin( );
531 if ( aNativeFormatName
.equalsIgnoreAsciiCase( citer
->aNativeFormatName
) )
533 aDataFlavor
= citer
->aDataFlavor
;
539 // -------------------------------------------------
541 // -------------------------------------------------
543 void SAL_CALL
CDataFormatTranslator::findStandardFormatIdForCharset( const OUString
& aCharset
, Any
& aAny
) const
545 if ( aCharset
.equalsIgnoreAsciiCase( "utf-16" ) )
546 aAny
<<= static_cast< sal_Int32
>( CF_UNICODETEXT
);
549 sal_Int32 wincp
= getWinCPFromMimeCharset( aCharset
);
550 if ( IsOEMCP ( wincp
) )
551 aAny
<<= static_cast< sal_Int32
>( CF_OEMTEXT
);
555 // -------------------------------------------------
557 // -------------------------------------------------
559 void SAL_CALL
CDataFormatTranslator::setStandardFormatIdForNativeFormatName( const OUString
& aNativeFormatName
, Any
& aAny
) const
561 vector
< FormatEntry
>::const_iterator citer_end
= m_TranslTable
.end( );
562 for ( vector
< FormatEntry
>::const_iterator citer
= m_TranslTable
.begin( ); citer
!= citer_end
; ++citer
)
564 if ( aNativeFormatName
.equalsIgnoreAsciiCase( citer
->aNativeFormatName
) &&
565 (CF_INVALID
!= citer
->aStandardFormatId
) )
567 aAny
<<= citer
->aStandardFormatId
;
573 // -------------------------------------------------
575 // -------------------------------------------------
577 void SAL_CALL
CDataFormatTranslator::findStdFormatIdOrNativeFormatNameForFullMediaType(
578 const Reference
< XMimeContentTypeFactory
>& aRefXMimeFactory
,
579 const OUString
& aFullMediaType
,
582 vector
< FormatEntry
>::const_iterator citer_end
= m_TranslTable
.end( );
583 for ( vector
< FormatEntry
>::const_iterator citer
= m_TranslTable
.begin( ); citer
!= citer_end
; ++citer
)
585 Reference
< XMimeContentType
>
586 refXMime( aRefXMimeFactory
->createMimeContentType( citer
->aDataFlavor
.MimeType
) );
587 if ( aFullMediaType
.equalsIgnoreAsciiCase( refXMime
->getFullMediaType( ) ) )
589 sal_Int32 cf
= citer
->aStandardFormatId
;
590 if ( CF_INVALID
!= cf
)
594 OSL_ENSURE( citer
->aNativeFormatName
.getLength( ),
595 "Invalid standard format id and empty native format name in translation table" );
596 aAny
<<= citer
->aNativeFormatName
;
603 // -------------------------------------------------
605 // -------------------------------------------------
607 inline sal_Bool
CDataFormatTranslator::isTextPlainMediaType( const OUString
& fullMediaType
) const
609 return fullMediaType
.equalsIgnoreAsciiCase("text/plain");
612 // -------------------------------------------------
614 // -------------------------------------------------
616 DataFlavor SAL_CALL
CDataFormatTranslator::mkDataFlv(const OUString
& cnttype
, const OUString
& hpname
, Type dtype
)
619 dflv
.MimeType
= cnttype
;
620 dflv
.HumanPresentableName
= hpname
;
621 dflv
.DataType
= dtype
;
625 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */